Skip to main content
This tutorial walks through depositing USDC into C0. By the end, you’ll have minted C0 and started accruing yield automatically.

View deposit.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 like injected() from @wagmi/core.)
import { createConfig, http } from "@wagmi/core";
import { mainnet } from "@wagmi/core/chains";
import { privateKeyToAccount } from "viem/accounts";

const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);

const config = createConfig({
  chains: [mainnet],
  transports: { [mainnet.id]: http(process.env.ETH_RPC_URL) },
});

2. Approve the SwapFacility to spend USDC

The SwapFacility needs an ERC-20 allowance to pull USDC out of your account.
import {
  waitForTransactionReceipt,
  writeContract,
} from "@wagmi/core";
import { erc20Abi, parseUnits } from "viem";
import { addresses } from "@camino-treasury/sdk";

const USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" as const;
const { swapFacility } = addresses[mainnet.id];
const amount = parseUnits("100", 6); // 100 USDC

const approveHash = await writeContract(config, {
  account,
  address: USDC,
  abi: erc20Abi,
  functionName: "approve",
  args: [swapFacility, amount],
});
await waitForTransactionReceipt(config, { hash: approveHash });

3. Swap USDC → C0

Call swap on the SwapFacility to mint C0 1:1 (minus any protocol fees).
import { writeSwapFacilitySwap } from "@camino-treasury/sdk";

const { c0 } = addresses[mainnet.id];

const swapHash = await writeSwapFacilitySwap(config, {
  account,
  address: swapFacility,
  args: [USDC, c0, amount, account.address],
});
await waitForTransactionReceipt(config, { hash: swapHash });
After the swap, account.address holds 100 C0 and starts accruing yield automatically.

What’s next