get withdraw fee info
Retrieve the withdrawal fee details for the asset. Note: If the asset supports cross-chain interoperability, be sure to provide the root asset ID, along with the target chain and chain network parameters.
GET /v1/asset/withdrawal-fee HTTP/1.1
Host: testnetopenapi.hibit.app
Accept: */*
{
"code": 1,
"message": "text",
"data": {
"rootAssetId": "text",
"targetAssetId": "text",
"feeRate": "text",
"rateDecimal": "text",
"minFee": "text"
}
}
Code example
import {
hibitClient,
HibitNetwork,
Chain,
ChainNetwork,
MetaMaskWalletApi
} from '@delandlabs/hibit-sdk';
// Set up client options
hibitClient.setOptions({
network: HibitNetwork.Testnet, // or HibitNetwork.Mainnet
});
async function fetchWithdrawFee() {
const assetId = BigInt('10001');
const targetChain = Chain.Ethereum;
const targetChainNetwork = ChainNetwork.EvmMainNet;
try {
const feeInfo = await hibitClient.getWithdrawFee({
rootAssetId: assetId,
targetChain,
targetNetwork: targetChainNetwork
});
console.log('Withdraw fee info:', feeInfo);
} catch (err) {
console.error('Failed to fetch withdraw fee:', err);
}
}
fetchWithdrawFee();
Note on Withdrawal Fee Calculation Logic
This API employs two different modes for fee calculation, determined by the value of the feeRate field:
When feeRate > 0:
The withdrawal fee is calculated proportionally. feeRate is the rate used for calculation, and rateDecimal indicates its decimal precision.
In this mode, minFee acts as the true "minimum fee." If the calculated proportional fee is less than minFee, the minFee value will be charged instead.
When feeRate = 0 (Important):
This indicates that the API has already performed a dynamic calculation based on current market conditions (e.g., asset price ratios) and has determined a final, fixed fee.
In this scenario, the value in the minFee field is the actual, final withdrawal fee that should be charged. Developers should use this minFee value directly and ignore the feeRate.
SDK
Source code https://github.com/Deland-Labs/hibit-sdk
Example
Last updated