Skip to main content

Overview

The Swap Facility is the canonical entry/exit for C0. It mints C0 by accepting M (or a whitelisted M-extension) and burns C0 to release M. Treasury yield accrues to M; wrapping into C0 makes that yield non-rebasing and ERC-20-compatible. For deposits (USDC/USDT → C0), call swap on the Swap Facility directly — this is the path the deposit tutorial walks through. For withdrawals (C0 → USDC/USDT), the canonical user-facing path is the Swap Adapter, which routes through Uniswap V3.

Reads

import { createConfig, http } from "@wagmi/core";
import { mainnet } from "@wagmi/core/chains";
import {
  readSwapFacilityIsApprovedExtension,
  addresses,
} from "@camino-treasury/sdk";

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

const isC0Whitelisted = await readSwapFacilityIsApprovedExtension(config, {
  address: addresses[mainnet.id].swapFacility,
  args: [addresses[mainnet.id].c0],
});

Writes

swap

Swap an input asset (M, a whitelisted M-extension, or a JMI-allowed asset like USDC) → another whitelisted extension. The most common flow: mint C0 from USDC.
import {
  simulateSwapFacilitySwap,
  writeSwapFacilitySwap,
  addresses,
} from "@camino-treasury/sdk";

const { c0, swapFacility } = addresses[mainnet.id];
const USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";

// Approve the SwapFacility to pull USDC first (use viem's erc20Abi
// + writeContract from @wagmi/core, or the wallet's existing approve flow).

const { request } = await simulateSwapFacilitySwap(config, {
  account,
  address: swapFacility,
  args: [
    USDC,            // tokenIn
    c0,              // tokenOut
    100_000_000n,    // amountIn (100, 6 decimals)
    "0xYourAddress", // recipient
  ],
});

const txHash = await writeSwapFacilitySwap(config, request);

Watch events

import { watchSwapFacilityEvent, addresses } from "@camino-treasury/sdk";

const unwatch = watchSwapFacilityEvent(config, {
  address: addresses[mainnet.id].swapFacility,
  onLogs: (logs) => console.log(logs),
});