Section 17 of 18

Build
+15 Lynx

CErc20: Token Integration

Key takeaway: Compound V2's CErc20 is the wrapper around an underlying ERC-20 token, providing doTransferIn and doTransferOut helpers that handle the underlying's specific transfer semantics. These helpers measure actual balance deltas before and after the transfer rather than trusting the input amount, which is critical for fee-on-transfer or rebasing tokens. Forks that skip this defensive measurement break on USDT in fee-on mode or on any cToken market that lists a non-standard ERC-20.

What You Are Building

You are building the final integration layer that turns all the internal logic into a deployable contract. CErc20 inherits the entire CToken chain (CTokenStorage, CTokenInterest, CTokenMint, CTokenRedeem, CTokenBorrow, CTokenRepay, CTokenLiquidate) and adds four things: the public entry points, the underlying token transfer implementation, standard ERC-20 functions, and initialization.

This is the contract users actually interact with. Everything built so far has been internal functions. CErc20 wraps them with external functions, reentrancy protection, and the concrete doTransferIn/doTransferOut implementations that move real ERC-20 tokens.

Your Code

Solution.sol
Solidity
Loading editor...

Requirements

Write your implementation, then click Run Tests. Tests execute on the server.

Sign up free — keep reading + earn 15 Lynx

Zealynx Academy is free. Track your progress, earn Lynx, and climb the leaderboard.

Sign up free to continue

Already have an account? Log in