Skip to main content
The Teller contract is an audited smart contract that handles USYC subscriptions and redemptions. It is implemented with Solidity and you can interact with it using Solidity, TypeScript, or any other programming language that supports Ethereum smart contracts.
This quickstart uses testnet addresses. For mainnet addresses, see USYC Contract Addresses.
The following example shows you how to call the Teller contract to subscribe to and redeem USYC:
import "../IERC20.sol";

interface ITeller {
  function deposit(uint256 _assets, address _receiver) external returns (uint256);
  function redeem(uint256 _shares, address _receiver, address _account) external returns (uint256);
}

ITeller teller = ITeller(0x96424C885951ceb4B79fecb934eD857999e6f82B);

// Subscribe to USYC
IERC20 usdc = IERC20(0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238);
uint256 usdcAmount = 100 * 1e6; // 100.000000 USDC
address usycReceiver = address(this); // Address to receive USYC
usdc.approve(address(teller), usdcAmount);
uint256 usycPurchased = teller.deposit(usdcAmount, usycReceiver);

// Redeem USYC
IERC20 usyc = IERC20(0x38D3A3f8717F4DB1CcB4Ad7D8C755919440848A3);
uint256 usycAmount = 100 * 1e6; // 100.000000 USYC
address usdcReceiver = address(this); // Address to receive USDC
address usycAccount = address(this); // Address that holds USYC
uint256 usdcPayout = teller.redeem(usycAmount, usdcReceiver, usycAccount);
import { Address, erc20ABI, writeContract, getAccount } from "@wagmi/core";

const USYC_TELLER_ABI = [
  {
    inputs: [
      { internalType: "uint256", name: "_assets", type: "uint256" },
      { internalType: "address", name: "_receiver", type: "address" },
    ],
    name: "deposit",
    outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
    stateMutability: "nonpayable",
    type: "function",
  },
  {
    inputs: [
      { internalType: "uint256", name: "_amount", type: "uint256" },
      { internalType: "address", name: "_receiver", type: "address" },
      { internalType: "address", name: "_account", type: "address" },
    ],
    name: "redeem",
    outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
    stateMutability: "nonpayable",
    type: "function",
  },
] as const;

// Ethereum Sepolia Addresses
const SEPOLIA_CHAIN_ID = 11155111;
const USYC_TELLER_ADDRESS: Address =
  "0x96424C885951ceb4B79fecb934eD857999e6f82B";
const USDC_ADDRESS: Address = "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238";
const USYC_ADDRESS: Address = "0x38D3A3f8717F4DB1CcB4Ad7D8C755919440848A3";

const ONE_HUNDRED_USDC = BigInt(100_000000); // USDC uses 6 decimals
const ONE_HUNDRED_USYC = BigInt(100_000000); // USYC uses 6 decimals

// Subscribe to USYC
export const approveUSYCTellerToSpendUSDC = () =>
  writeContract({
    chainId: SEPOLIA_CHAIN_ID,
    address: USDC_ADDRESS,
    abi: erc20ABI,
    functionName: "approve",
    args: [USYC_TELLER_ADDRESS, ONE_HUNDRED_USDC],
  });

const usycReceiverAddress: Address = getAccount(); // Address to receive USYC

export const depositUSYC = () =>
  writeContract({
    chainId: SEPOLIA_CHAIN_ID,
    address: USYC_TELLER_ADDRESS,
    abi: USYC_TELLER_ABI,
    functionName: "deposit",
    args: [ONE_HUNDRED_USDC, usycReceiverAddress],
  });

// Redeem USYC
const usdcReceiverAddress: Address = getAccount(); // Address to receive USDC
const usycAccountAddress: Address = getAccount(); // Address that holds USYC

export const redeemUSYC = () =>
  writeContract({
    chainId: SEPOLIA_CHAIN_ID,
    address: USYC_TELLER_ADDRESS,
    abi: USYC_TELLER_ABI,
    functionName: "redeem",
    args: [ONE_HUNDRED_USYC, usdcReceiverAddress, usycAccountAddress],
  });