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 = {
  zircuit: {
    usdc: "0x3b952c8C9C44e8Fe201e2b26F6B2200203214cfF",
    vaultComposer: "0xa41f912a9AF4c086a6fefa5630305B44bbDfC6ef",
    vault: "0x91E6aD7CB1287eB9F6156F5969FD94292F0c7F20",
    underlyingOFT: "0xE76aa05D2cD49aeC3e1cb87Fa8B943b38522b10d",
  },
  base: {
    usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    vaultToken: "0xB3589d27214fF92F40bacb6e8F2087D3FfE6113E",
    underlyingAdapter: "0x322Aa541C733661737AbF973Bc896965177B761b",
  },
};

// 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?