Vault Integration Guide

This guide will walk you through integrating the cross-chain vault system into your DeFi application. Whether you're building a portfolio dashboard, a yield optimizer, or a wallet interface, this guide provides the architecture you need to offer seamless cross-chain vault interactions. The vaults leverage the ERC-4626 standard.

Frontend Implementation

1. Setup: Web3 Provider & Contracts

import {
  AbiCoder,
  Contract,
  JsonRpcProvider,
  formatUnits,
  parseUnits,
  Wallet,
  ethers,
} from "ethers";
import { Options } from "@layerzerolabs/lz-v2-utilities";

// Contract ABIs (import from artifacts)
import VaultABI from './abis/Vault.json';
import VaultComposerABI from './abis/VaultComposer.json';
import VaultTokenABI from './abis/VaultToken.json';
import UnderlyingOFTABI from "./abis/UnderlyingOFT.json";
import ERC20ABI from './abis/ERC20.json';
import VaultComposerABI from "./abis/VaultComposer.json"

// Contract addresses by chain
const CONTRACTS = {
  base: {
    usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    vaultComposer: "0xBb801ED781dF31F660cC743bEf7Bb9D04B030923",
    vault: "0x03067bbD0d41E3Fe4A0bb6ca67c99e7352Da4CAE",
    underlyingOFT: "0xd7aBC360dfcF1B6dD0a03138235e12A2bc1c1C8B",
  },
  eth: {
    usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    vaultToken: "0x07C898e77310870770f88d18a01009cB65A1c1a9",
    underlyingAdapter: "0xd58E8c1c83d598aD76B5f0E26B4a25cdB885d190",
  },
};

// LayerZero Endpoint IDs
const LZ_EID = {
  zircuit: 30303,
  mainnet: 30101,
  base: 30184,
};

2. Fetching Vault Data

3. Preview Deposit

4. Execute Deposit (Cross-Chain)

5. Preview Withdraw

6. Execute Withdraw (Cross-Chain)


Error Handling

Common Errors

Last updated

Was this helpful?