Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MarginContract] Lender Withdraw Function #580

Open
djeck1432 opened this issue Feb 20, 2025 · 12 comments · May be fixed by #690
Open

[MarginContract] Lender Withdraw Function #580

djeck1432 opened this issue Feb 20, 2025 · 12 comments · May be fixed by #690
Labels

Comments

@djeck1432
Copy link
Owner

Your task is to implement a withdraw function for lenders to withdraw their token from our pools.

  • Check that user has enough token in the treasury to withdraw. Check that withdraw amount is not 0. If amount in the pool is not sufficient, provide an error that clearly states it.
  • Decrease token amount in the treasury balances and in the token pool
  • Transfer token from the contract to the user.
  • Emit a Withdrawn event
  • Write docstrings and tests
@sneaxhuh
Copy link

Hi @ djeck1432, I'd like to contribute by implementing the withdraw function.

Proposed Solution
The function will allow users to withdraw their available balance securely.
It will check if the user has sufficient funds before processing the transaction.
Necessary security validations (e.g., authentication, rate limiting) will be included.
Event logging and error handling will be implemented to track failed withdrawals.
If applicable, gas fees or transaction fees will be considered for blockchain-related withdrawals.
Plan of Action

  1. Validate User Input: Ensure the withdrawal amount is positive and within available balance.
  2. Check Balance: Fetch the user’s balance and verify sufficiency.
    Process Transaction: Deduct the amount and update the balance.
  3. Confirm & Log: Send a confirmation and log the transaction for audit purposes.
    Let me know if you have any specific requirements or constraints. I’ll proceed with the implementation and submit a PR soon. 🚀

Thanks!

@JuanPabloRodriguezC
Copy link
Contributor

JuanPabloRodriguezC commented Feb 22, 2025

Could I try solving this? I have been recently working on cairo smart contracts and I want to be more immersed in this project in various aspects. To solve this issue I will create events that match the possible outcomes like TokenWithdrawn, InsufficientBalance and InvalidWithdrawal. Then I would write assert macros to verify the conditions are met and then correct the token amounts after the withdrawal. Finally I will write tests possibly using snforge cheatcodes.
I like pineapple @jprodcano
ETA: 24 hours

@Goodnessukaigwe
Copy link

Good day, my name is Goodness, i am a blockchain developer. Please, can I be assigned this issue.

@KedwithGod
Copy link
Contributor

Good evening sir,
I will be more than happy to work on this task

@Belloabraham121
Copy link

Hi, I'm Iteooluwakisi!
I am a member of Web3Bridge and an experienced frontend developer proficient in ReactJS/NextJS, TypeScript, Solidity, cairo and Rust. I would like to work on this.

@kadoso-noni
Copy link

This is my first time contributting, and i will like to contribute to your project. With my expertise as a Fullstack Developer, I am confident that I am the right fit for this project. I am ready to contribute, collaborate, and deliver exceptional results.

@Divineifed1
Copy link

I like Pineapple,
I'm a full stackdeveloper with 4+ years experience
ETA 4 hours
Please may I pick this up?

@DEXTAR03
Copy link

Can I handle this task?

@Sam20my
Copy link

Sam20my commented Feb 26, 2025

I will love to take on this task

@KedwithGod
Copy link
Contributor

I am a Python developer; I can:

Build robust web applications using frameworks like Django and Flask.
Analyze and manipulate data with libraries such as Pandas and NumPy.
Design and integrate RESTful APIs for seamless communication between systems.
Implement testing and quality assurance practices to ensure reliable code.
Collaborate effectively in agile teams, adapting to changing project requirements.
Kindly assign me to this task

@dlaciport
Copy link
Contributor

Can I tackle this one?

@dlaciport dlaciport linked a pull request Mar 1, 2025 that will close this issue
@Daveside9
Copy link

let me take this please, I will implement the withdraw function, ensuring sufficient balance checks, treasury and pool updates, secure token transfers, and event emission. I will also write tests and documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.