A wrapped token for any of the Compound III tokens.
Compound III tokens like cUSDCv3 and cWETHv3 are rebasing tokens. Protocols are designed to work with tokens that do not automatically increase balances like rebasing tokens do. The standard solution to this problem is to use a wrapped token. This wrapped token allows other protocols to more easily integrate with Compound III tokens and treat it like any standard ERC20 token.
CometWrapper
was designed to nullify inflation attacks which could cause losses for users. It's a method of manipulating the price of Wrapped tokens which enables attackers to steal underlying tokens from target depositors or make it prohibitively expensive for future depositors to use the contract.
To nullify inflation attacks, CometWrapper
maintains internal accounting of all Compound III tokens deposited and withdrawn. This internal accounting only gets updated through the functions mint
, redeem
, deposit
and withdraw
. This means that any direct transfer of Compound III tokens will not be recognized by the CometWrapper
contract to prevent malicious actors from manipulating the exchange rate of Wrapped Compound III token to the actual Compound III token. The tradeoff is that any tokens directly transferred to CometWrapper
will be forever locked and unrecoverable.
CometWrapper
implements the ERC4626 Tokenized Vault Standard and is used like any other ERC4626 contracts.
To wrap a Compound III token like cUSDCv3, you will need to have cUSDCv3 balance in your wallet and then do the following:
comet.allow(cometWrapperAddress, true)
- allow CometWrapper to move your cUSDCv3 tokens from your wallet to the CometWrapper contract when you calldeposit
ormint
.cometWrapper.mint(amount, receiver)
- the first parameter is the amount of Wrapped tokens to be minted. ORcometWrapper.deposit(amount, receiver)
- the first parameter is the amount of Comet tokens that will be deposited.
To witdhraw a Compound III token like cUSDCv3, you may use either withdraw
or redeem
. For example:
cometWrapper.withdraw(amount, receiver, owner)
-amount
is the number of Compound III tokens to be withdrawn. You can only withdraw tokens that you deposited.cometWrapper.redeem(amount, receiver, owner)
-amount
is the number of Wrapped Compound III tokens to be redeemed in exchange for the deposited Compound III tokens.