withdraw ​
Withdraw an exact amount of USDC, burning the required vault shares from owner.
Signature ​
solidity
function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);Parameters ​
| Name | Type | Description |
|---|---|---|
assets | uint256 | Amount of USDC to withdraw (6 decimals), after the withdrawal fee. |
receiver | address | Address that will receive the USDC. |
owner | address | Address whose vault shares will be burned. |
Returns ​
| Name | Type | Description |
|---|---|---|
shares | uint256 | Amount of shares burned. |
Preconditions ​
withdrawalsPaused()must befalse.assets > 0.receiverandownermust be non-zero addresses.- If
owner != msg.sender, the caller needs a vault-shareallowance(owner, msg.sender) >= shares. Set this with the vault'sapprove(or have the owner do it). ownermust hold at leastsharesworth of vault shares (usepreviewWithdraw(assets)to quote).
Events emitted ​
solidity
event Withdraw(address indexed sender, address indexed receiver, address indexed owner, uint256 assets, uint256 shares);
event Transfer(address indexed from, address indexed to, uint256 value); // share burn, to = 0x0
event Approval(address indexed owner, address indexed spender, uint256 value); // only if allowance was usedExample — withdraw 500 USDC to self ​
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('500', USDC_DECIMALS)
const { request, result: sharesBurned } = await publicClient.simulateContract({
account,
address: VAULT,
abi: liteUsdVaultAbi,
functionName: 'withdraw',
args: [assets, account.address, account.address],
})
console.log('Will burn', sharesBurned, 'shares')
const hash = await walletClient.writeContract(request)
await publicClient.waitForTransactionReceipt({ hash })Notes ​
assetsis the amount the receiver gets net of the withdrawal fee. To withdraw exactly your full balance, preferredeem(balanceOf(account), …)— see the next page.

