View withdraw.ts on GitHub
Runnable script in the SDK repo.
1. Set up the config
Build a wagmi config with a private key account. (For browser/dApp usage, swap the private key for a connector likeinjected() from @wagmi/core.)
2. Read your C0 balance
Default to redeeming everything you hold.3. Approve the SwapAdapter to spend C0
4. Swap C0 → USDC
CallswapOut on the SwapAdapter to route C0 through Uniswap V3 to USDC in a single transaction. We apply a 0.25% slippage buffer based on the input amount (the C0/USDC pool tracks ~1:1, so this is a tight but safe floor).
minAmountOut, so you’re protected against slippage and front-running.
What’s next
- How to deposit USDC into C0 — mint C0 from USDC
- Swap Adapter — full Uniswap V3 routing surface
- Swap Facility — direct mint/redeem against M (alternative path)