calculateOfferFees and offerFeePercentage.
Import
Usage
Parameters
Return Type
Example: Fee Preview
Error Handling
Related
- Withdrawals Guide - Complete withdrawal flow
- getMinimumWithdrawalOrderSize - Minimum order size
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Calculate withdrawal fees from the on-chain FeeModule contract
calculateOfferFees and offerFeePercentage.
import { getWithdrawalFee } from "@paxoslabs/amplify-sdk";
import { getWithdrawalFee, YieldType } from "@paxoslabs/amplify-sdk";
const fee = await getWithdrawalFee({
yieldType: YieldType.CORE,
chainId: 1,
assetAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
amount: "1.0",
offerAsset: "0x1234...5678", // vault shares
wantAsset: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
receiver: "0x5678...abcd",
});
console.log(fee.feeAmount); // bigint
console.log(fee.feePercentage); // bigint
| Parameter | Type | Required | Description |
|---|---|---|---|
yieldType | YieldType | Yes | Yield strategy type |
chainId | ChainId | Yes | Blockchain network ID |
assetAddress | Address | Yes | Asset address for vault lookup |
amount | string | Yes | Withdrawal amount as decimal string |
offerAsset | Address | Yes | Vault share token address |
wantAsset | Address | Yes | Token the user wants to receive |
receiver | Address | Yes | Address receiving the withdrawal |
interface GetWithdrawalFeeParams {
yieldType: YieldType;
chainId: ChainId;
assetAddress: Address;
amount: string;
offerAsset: Address;
wantAsset: Address;
receiver: Address;
}
interface WithdrawalFeeResult {
/** Fee amount in share token units */
feeAmount: bigint;
/** Fee percentage from the FeeModule */
feePercentage: bigint;
}
import { getWithdrawalFee, YieldType } from "@paxoslabs/amplify-sdk";
import { formatUnits } from "viem";
const fee = await getWithdrawalFee({
yieldType: YieldType.CORE,
chainId: 1,
assetAddress: usdcAddress,
amount: withdrawAmount,
offerAsset: vaultShareAddress,
wantAsset: usdcAddress,
receiver: userAddress,
});
const feeFormatted = formatUnits(fee.feeAmount, 18);
console.log(`Withdrawal fee: ${feeFormatted} shares`);
| Error Message Pattern | Description | Resolution |
|---|---|---|
"No vault found" | No vault matches parameters | Verify yieldType, asset, chainId |
"SDK not initialized" | SDK not initialized | Call initAmplifySDK() first |