-
Notifications
You must be signed in to change notification settings - Fork 2
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
Partial crowdfund support #51
Conversation
…ding full test suite
@@ -142,31 +169,13 @@ contract Crowdloan is Initializable, ICrowdloan, ReentrancyGuard { | |||
); | |||
|
|||
if (termsContract.getLoanStatus() < TermsContractLib.LoanStatus.REPAYMENT_CYCLE) { | |||
termsContract.startLoan(); | |||
termsContract.startRepaymentCycle(totalCrowdfunded); // TODO(Dan): change this to be the amount actually raised |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be
termsContract.startRepaymentCycle(_getPrincipalToken().balanceOf(address(this)))
,
which simply takes the balance at this point in time of the crowdloan contract.
This also removes the need to track totalCrowdfunded
within the fund and refund functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adibas03 Ah yes I thought about that. That approach might create a few problems:
-
Someone does a native ERC20 transfer to the smart contract, such that
_getPrincipalToken().balanceOf(address(this))
is > thanprincipalRequested
-
In TermsContract, we have a
require
that checks thatprincipalDisbursed
is not more thanprincipalRequested
-
If that happens, the funds are locked and can't be withdrawn
I think I can resolve it by removing totalCrowdfunded
, and instead just passing in the smaller of balanceOf(address(this))
and principalRequested
into the startRepaymentCycle
function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are to use a ceiling, it means we have to implement a cap for the withdrawal function as well, which makes withdrawing in bits more annoying, and would be better we have a simple withdraw function that takes the lesser of principalRequested
and balanceOf(address(this))
and transfers the said amount, after which it locks withdrawal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah just saw your message in the other post - makes sense. I'll implement the donations functionality today
@onggunhao Is this PR ready? |
moved to #54 |
crowdLoan