Lines of code
<https://github.com/code-423n4/2023-11-canto/blob/335930cd53cf9a137504a57f1215be52c6d67cb3/asD/src/asD.sol#L52>
users will not be able to redeem their asD tokens for equivalent amount of NOTE because when minting cNOTE, 1 cNOTE doesnโt always equal 1 NOTE.
Link to site here
as of when the image above was taken, you needed exactly 1.0042 NOTES to be able to get 1 cNOTE, and you can see in the mint() function,
function mint(uint256 _amount) external {
CErc20Interface cNoteToken = CErc20Interface(cNote);
IERC20 note = IERC20(cNoteToken.underlying());
SafeERC20.safeTransferFrom(note, msg.sender, address(this), _amount);
SafeERC20.safeApprove(note, cNote, _amount);
uint256 returnCode = cNoteToken.mint(_amount);
// Mint returns 0 on success: https://docs.compound.finance/v2/ctokens/#mint
require(returnCode == 0, "Error when minting");
_mint(msg.sender, _amount);
}
if a user deposits 1 NOTE, the contract gets 0.9958 cNOTE and mint to the user 1 asD, whenever the user wants to burn that 1 asD for an equivalent 1 NOTE, the call to cNoteToken.redeemUnderlying(_amount) in burn() will revert as the contractโs balance of cNOTE will not be able to redeem 1 NOTE from the cNOTE contract.
The issue with this is that
> Main invariants
asD: It should always be possible to redeem 1 asD for 1 NOTE.
> check the Proof of Concept
Here you can see User A has unknowingly taken a share of User Bโs N0TE causing loss to User B, NOTE This is a simplified Instance, where in huge amount a lot of issues can arise as many users are in the protocol.
Manual review
my recommendation would be to require that the amount of cNOTE minted for the contract is equivalent to the amount of asD token to be minted to the user on the call to mint().
Other
The text was updated successfully, but these errors were encountered:
All reactions