Deposit to ERC20 Vaults

This section explains how to deposit ERC20 tokens into any Byzantine ERC20-compatible vault, including SymByzVaults and EigenByzVaults.

Step-by-Step Process

1. Approve Token Transfer

Before depositing, the user must approve the vault to transfer tokens on their behalf:

token.approve(address(vault), amount);

2. Call deposit()

Use the following function to deposit ERC20 tokens into the vault:

function deposit(
    uint256 assets,         
    address receiver    
) external returns (uint256 shares);
  • assets: the amount of ERC20 tokens to deposit.

  • receiver: the address that will receive the newly minted vault shares.

The function returns the number of shares minted for the receiver, which represent a proportional claim on the vault’s assets.

Choose the method that best suits your setup to deposit in a vault:

const VAULT_ADDRESS = "0x40aba78dbb81dbef26d892b6bef4e5fc23736bf5";

// Deposit 0.2 wstETH
await client.depositToVault(VAULT_ADDRESS, 200000000000000000);
const receipt = await tx.wait();
console.log("Deposit hash:", receipt.hash);

3. Important Considerations

  • If the vault is permissioned (isPrivateVault = true), the caller must be whitelisted.

  • If a deposit limit is enabled (isDepositLimit = true), the total deposits must remain within the configured limit.

  • The vault uses the convertToShares() function to determine how many shares are minted.

Choose the method that best suits your setup to read those datas:

const VAULT_ADDRESS = "0x40aba78dbb81dbef26d892b6bef4e5fc23736bf5";

const isPrivate = await client.isVaultPrivate(VAULT_ADDRESS);
const isAddressWhitelisted = await client.isAddressWhitelisted(VAULT_ADDRESS, address);
const isThereALimit = await client.isDepositLimitEnabled(VAULT_ADDRESS);
const whatIsTheLimit = await client.getVaultDepositLimit(VAULT_ADDRESS);

Last updated