Shielding Tokens (Wrapping)

Shielding converts regular ERC-20 or ETH into confidential tokens (cTokens). This is how users obtain encrypted balances while preserving ERC-20-like functionality.

Although technically a “wrap,” shielding better conveys the privacy aspect.

How Shielding Works: Step-by-Step

  1. Check if a wrapper exists for your token

    • Each token has a dedicated wrapper contract.

    • If it exists → use it.

    • If not → anyone can deploy one (see Section 6).

  2. Approve the wrapper (for ERC-20 only)

    • Grant the wrapper permission to transfer your tokens

    • token.approve(wrapperAddress, amount)

  3. Call the shield function

    • wrapper.wrap(recipientAddress, amount)

    • For ETH: Include the amount as msg.value

    • For ERC-20: Tokens are transferred from you

  4. Pay shield fee

    • Fees are paid in the original token (eg, USDC, ETH…), not in cTokens. This ensures accurate protocol revenue accounting and avoids circular dependencies.

    • The fee is calculated as a percentage (basis points) of the amount

    • All fees are sent to the protocol fee recipient address (configured in the FeeManager contract). This address is publicly visible on-chain.

  5. Receive confidential tokens

    • Wrapper mints cTokens to your address

    • Your balance is encrypted as euint64

    • Amount is immediately usable for confidential transfers

Shield Flow Diagram:

Last updated