Skip to content

deposit ​

Deposit a specified amount of USDC and mint vault shares to a receiver.

Signature ​

solidity
function deposit(uint256 assets, address receiver) external returns (uint256 shares);

Parameters ​

NameTypeDescription
assetsuint256Amount of USDC to deposit, in 6-decimal base units.
receiveraddressAddress that will receive the minted vault shares.

Returns ​

NameTypeDescription
sharesuint256Amount of shares minted (18 decimals).

Preconditions ​

  • depositsPaused() must be false — otherwise reverts.
  • assets > 0 — depositing zero reverts.
  • receiver must be a non-zero address.
  • The caller must have approved at least assets USDC to the vault (see Getting Started -> Approving USDC).
  • The caller must hold at least assets USDC.

Events emitted ​

solidity
event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);
event Transfer(address indexed from, address indexed to, uint256 value); // share mint, from = 0x0

Example — deposit 1,000 USDC ​

ts
import { parseUnits } from 'viem'
import { publicClient, walletClient } from './client'
import { liteUsdVaultAbi } from './abi'
import { VAULT, USDC_DECIMALS } from './constants'

const account = walletClient.account!
const assets = parseUnits('1000', USDC_DECIMALS)

// (Approve USDC first — see Getting Started.)

const { request, result: shares } = await publicClient.simulateContract({
  account,
  address: VAULT,
  abi: liteUsdVaultAbi,
  functionName: 'deposit',
  args: [assets, account.address],
})

console.log('Will mint', shares, 'shares')

const hash = await walletClient.writeContract(request)
const receipt = await publicClient.waitForTransactionReceipt({ hash })
console.log('Deposited in tx', receipt.transactionHash)

Notes ​

  • If you want to know the share amount without simulating, call the read function previewDeposit(assets).
  • To deposit on behalf of another wallet, set receiver to that wallet's address. The shares are minted directly to receiver; the caller still pays the USDC.