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

Feat/repay proposal #106

Merged
merged 6 commits into from
Jan 29, 2025

Conversation

armaanansari121
Copy link
Contributor

@armaanansari121 armaanansari121 commented Jan 25, 2025

closes #100

I added a two fields in the Proposal struct
released_collateral which keeps track of how much of the collateral has been released.
amount_repaid which keeps track of how much amount has been repaid in dollars.

The logic in repay_proposal:
Added a new parameter called amount, which is the repaying amount in USD.
Then I calculate how much amount is being repaid in tokens.
If the amount being repaid in this transaction in USD + amount already paid in USD is >= proposal amount in USD. Then we cap it to be equal to the total amount. and adjust the tokens to be transferred accordingly.
Once we have the final amount in tokens, we start to calculate the interests, and protocol fees. We transfer the amount with interest to the lender.
Now to release collateral, We calculate how much percentage of the loan has been repaid. And release the collateral, so that the total collateral released is that same percentage.
Finally we store the updated proposal, and the interests earned.
And if the loan is repaid in full we emit the event.

Copy link

vercel bot commented Jan 25, 2025

@armaanansari121 is attempting to deploy a commit to the peerprotocol Team on Vercel.

A member of the Team first needs to authorize it.

@armaanansari121
Copy link
Contributor Author

Here's what I have changed/fixed in this commit.
Changes

@armaanansari121 armaanansari121 marked this pull request as ready for review January 28, 2025 19:37
Copy link
Collaborator

@Dprof-in-tech Dprof-in-tech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beautifully done. Thank you for your contributions.

@Dprof-in-tech Dprof-in-tech merged commit 6eadc52 into Peerprotocol:main Jan 29, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cairo: Research and Modify the Repay_proposal() function
2 participants