YO Protocol Documentation
Back to YO dApp
  • Welcome to YO
    • What is YO?
  • Why should I use YO?
  • FAQ
  • User Guides
    • How to Deposit into YO
  • How to Withdraw from YO
  • Protocol
    • YO Protocol
    • yoTokens
  • Contract Addresses
  • Security Audits
    • Immunefi Bug Bounty
  • Risks
  • API
  • Technical Guides
    • Deposit and Withdraw
  • Quick links
    • YO dApp
    • Follow us on X
    • Join our Telegram community
Powered by GitBook
On this page
  • ⚙️ Setup
  • Install Ethers
  • Connect to Base & Instantiate the Contract
  • 🔍 Simulate with preview* Functions
  • previewDeposit(assets)
  • previewMint(shares)
  • previewRedeem(shares)
  • ✍️ Execute Transactions
  • deposit(assets, receiver)
  • requestRedeem(yoTokens, receiver, owner)
  • Recap: Share-to-Asset Logic
  • Notes
  • 🔗 Contract Addresses (Base Chain)
  1. Technical Guides

Deposit and Withdraw

PreviousTechnical Guides

Last updated 23 days ago

This guide explains how to interact with the yoVaults smart contracts (yoETH, yoUSD, yoBTC) on the Base blockchain. These contracts implement the Tokenized Vault Standard, enabling users and integrators to deposit ERC-20 tokens ("assets") and receive yield-bearing yoTokens in return.

The guide outlines how to:

  • Connect to the vaults with Ethers.js

  • Use read functions (previewDeposit, previewMint, previewRedeem) to estimate outcomes

  • Execute deposit and redemption transactions

  • Understand how yoTokens ↔ assets conversion works

All vaults follow the same contract interface and live on Base chain (chain ID 8453).


⚙️ Setup

Install Ethers

npm install ethers

Connect to Base & Instantiate the Contract

import { ethers } from "ethers";
import abi from "./yoAbi.json"; // Use the ABI attached below 

const provider = new ethers.JsonRpcProvider("https://mainnet.base.org");
const signer = new ethers.Wallet(PRIVATE_KEY, provider);

const YO_VAULTS = {
  yoETH: "0x3a43aec53490cb9fa922847385d82fe25d0e9de7",
  yoUSD: "0x0000000f2eb9f69274678c76222b35eec7588a65",
  yoBTC: "0xbcbc8cb4d1e8ed048a6276a5e94a3e952660bcbc",
};

const vault = new ethers.Contract(YO_VAULTS.yoETH, abi, signer); // Swap as needed

🔍 Simulate with preview* Functions

These functions estimate how many shares or assets you'll receive/spend before making a transaction.

previewDeposit(assets)

Estimate how many yoTokens you get for a given asset amount:

const yoTokens = await vault.previewDeposit(ethers.parseUnits("1.0", 18));

previewMint(shares)

Estimate how many assets are needed to mint a specific number of yoTokens:

const assetsRequired = await vault.previewMint(ethers.parseUnits("1.0", 18));

maxWithdraw(owner)

Returns the maximum amount of assets that can currently be withdrawn by the given address.

const maxAssets = await vault.maxWithdraw(await signer.getAddress());

previewRedeem(shares)

Estimate how many assets you'd get back when redeeming yoTokens:

const assetsOut = await vault.previewRedeem(ethers.parseUnits("1.0", 18));

✍️ Execute Transactions

deposit(assets, receiver)

Deposit a specific amount of assets and receive yoTokens in return:

const tx = await vault.deposit(
  ethers.parseUnits("1.0", 18),       // Assets to deposit
  await signer.getAddress()           // Receiver of yoTokens
);
await tx.wait();

requestRedeem(yoTokens, receiver, owner)

Burn yoTokens and receive assets in return. You cannot request an exact asset amount.

const tx = await vault.requestRedeem(
  ethers.parseUnits("1.0", 18),       // yoTokens to redeem
  await signer.getAddress(),          // Receiver of assets
  await signer.getAddress()           // Owner of shares
);
await tx.wait();

Recap: Share-to-Asset Logic

You Want To...
Use This Function
Simulation Tool

Deposit assets for yoTokens

deposit()

previewDeposit()

Mint exact amount of yoTokens

mint()

previewMint()

Redeem yoTokens for assets

requestRedeem()

previewRedeem()


Notes

  • All values must be parsed using correct decimals (e.g. ethers.parseUnits("1.0", 18)).

    • ETH / yoETH decimals: 18

    • cbBTC / yoBTC decimals: 8

    • USDC / yoUSD decimals: 6

  • Only requestRedeem is supported for withdrawals because depending on the withdrawal amount, the yoVault may not have enough available liquidity to fill the redeem order. In those cases, the withdrawal will remain pending for up to 24 hours. The protocol will fill the redeem order and send the assets directly to the receiver specified in the requestRedeem transaction

  • All the yoVaults follow the same ABI and differ only by address.


🔗 Contract Addresses (Base Chain)

Vault
Address

yoETH

0x3a43aec53490cb9fa922847385d82fe25d0e9de7

yoUSD

0x0000000f2eb9f69274678c76222b35eec7588a65

yoBTC

0xbcbc8cb4d1e8ed048a6276a5e94a3e952660bcbc


ERC-4626
4KB
yoAbi.json