Skip to main content

Documentation Index

Fetch the complete documentation index at: https://developers.paxoslabs.com/llms.txt

Use this file to discover all available pages before exploring further.

Prepare transaction data for submitting a withdrawal order through the unified withdrawal wrapper. prepareWithdrawal() is the recommended execution helper for most integrations.
prepareWithdrawal() does not check or enforce allowance. Run prepareWithdrawalAuthorization first if you need approval routing.

Import

import { prepareWithdrawal } from '@paxoslabs/amplify-sdk'

Usage

// First discover the vault
const [vault] = await getVaultsByConfig({
  yieldType: 'CORE',
  chainId: 1,
})

const txData = await prepareWithdrawal({
  vaultName: vault.name,
  wantAsset: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC
  withdrawAmount: '1.0', // Vault shares to offer
  userAddress: '0x1234...',
  chainId: 1,
})

const hash = await walletClient.writeContract(txData)

Parameters

ParameterTypeRequiredDescription
vaultNamestringYesVault name from AmplifyVault.name (e.g. from getVaultsByConfig())
wantAssetAddressYesToken address user wants to receive
withdrawAmountstringYesVault shares to withdraw (decimal string)
userAddressAddressYesUser wallet address
chainIdnumberYesChain ID

Return Type

Returns PrepareWithdrawalResult (alias of WithdrawOrderTxData), ready for writeContract.
1

Discover vault

const [vault] = await getVaultsByConfig({
  yieldType: "CORE",
  chainId: 1,
});
2

Check Authorization

const auth = await prepareWithdrawalAuthorization({
  vaultName: vault.name,
  wantAsset: USDC_ADDRESS,
  withdrawAmount: "1.0",
  userAddress,
  chainId: 1,
});

if (isWithdrawApprovalAuth(auth)) {
  await walletClient.writeContract(auth.txData);
}
3

Prepare Withdrawal Tx

const withdrawTx = await prepareWithdrawal({
  vaultName: vault.name,
  wantAsset: USDC_ADDRESS,
  withdrawAmount: "1.0",
  userAddress,
  chainId: 1,
});
4

Submit Transaction

await walletClient.writeContract(withdrawTx);