-
Notifications
You must be signed in to change notification settings - Fork 19
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
Support future yield borrow #116
base: main
Are you sure you want to change the base?
Conversation
contracts/v3/alchemix/Alchemist.sol
Outdated
if (_totalCredit < _amount) { | ||
uint256 _remainingAmount = _amount.sub(_totalCredit); | ||
_cdp.totalDebt = _cdp.totalDebt.add(_remainingAmount).add( | ||
_remainingAmount.mul(borrowFee).div(PERCENT_RESOLUTION) |
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.
The Debt is increased with _remainingAmount.mul(borrowFee).div(PERCENT_RESOLUTION)
However nothing else is done with this amount.
For comparison function harvest() has this call to do something with the fees:
if (_feeAmount > 0) {
token.safeTransfer(rewards, _feeAmount);
}
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.
@gpersoon I have updated the code. The fee will be sent to reward address now
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.
I think the number of xtoken send should also be subtracted with the _borrowFeeAmount
something like:
_amount = _amount.sub(__borrowFeeAmount);
Otherwise, who is paying for the fees?
(please doublecheck if my hunch is correct)
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.
_amount should be the same.
Otherwise, who is paying for the fees?
The fee is paid by the user. The user needs to clear debt to get its collateral back
}); | ||
|
||
// describe('mint', () => { | ||
// let depositAmt = parseEther('5000'); |
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.
The test for mint() is commented out.
While it is extra important because it includes the borrowFee now, so some additional test will be necessary.
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 is issue for setting whitelist in Transmuter. I cannot figure out why it is failing in the test
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.
I do see you have an additional setWhitelist that isn't in the original.
metavault/test/v3/Alchemist.test.js
Lines 798 to 800 in 2ae878e
// await token.connect(minter).approve(alchemist.address, depositAmt); | |
// await alUsd.connect(deployer).setWhitelist(alchemist.address, true); | |
// }); |
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.
yes. I added it for debugging because setWhitelist
is not working at line 811
metavault/test/v3/Alchemist.test.js
Line 811 in 2ae878e
// // await alUsd.connect(deployer).setWhitelist(alchemist.address, true); |
No description provided.