Skip to content

mint ​

Mint an exact number of vault shares to a receiver, pulling the required USDC from the caller.

Signature ​

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

Parameters ​

NameTypeDescription
sharesuint256Exact number of vault shares to mint (18 decimals).
receiveraddressAddress that will receive the shares.

Returns ​

NameTypeDescription
assetsuint256Amount of USDC pulled from the caller (6 decimals).

Preconditions ​

  • depositsPaused() must be false.
  • shares > 0.
  • receiver must be a non-zero address.
  • The caller must have approved at least the resulting assets of USDC to the vault. Quote the required amount with the read function previewMint(shares).

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

Example — mint 100 shares ​

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

const account = walletClient.account!
const shares = parseUnits('100', SHARE_DECIMALS)

// Simulate first — `result` is the USDC amount the vault will pull.
// Make sure your USDC allowance to the vault is >= this value
// before calling writeContract. (See Getting Started.)
const { request, result: requiredAssets } = await publicClient.simulateContract({
  account,
  address: VAULT,
  abi: liteUsdVaultAbi,
  functionName: 'mint',
  args: [shares, account.address],
})

console.log('Will pull', requiredAssets, 'USDC (raw, 6 decimals)')

const hash = await walletClient.writeContract(request)
await publicClient.waitForTransactionReceipt({ hash })

When to use this vs deposit ​

Use deposit when you have an exact USDC amount in mind. Use mint when you need an exact share amount — for example, when matching a pre-quoted position or rebalancing to a target share count.