Estimate Order Fee
Endpoint Information
Endpoint: POST /api/v1/orders/estimate_charge
Description: Estimate order fee with automatic exchange rate conversion. The backend automatically resolves the asset precision on the target chain based on chain_id and target_currency, returning price_target and charge_target in the correct native precision.
Authentication: API Key + Signature. See Authorization
Note: This is a Maker API endpoint. The
X-Maker-Addrheader is required and must be included in both the request headers and signature string.
Request Parameters
| Field | Type | Required | Description |
|---|---|---|---|
| is_buy | bool | Yes | Whether it's a buy order |
| ticker | string | Yes | Stock symbol |
| exchange | int | Yes | Exchange code (0=US Stock, 1=HK Stock) |
| quantity | string | Yes | Quantity (regular precision) |
| price | string | Yes | Stock's native currency price (regular precision, NOT wei) USD for US stocks, HKD for HK stocks |
| asset | string | No | Asset contract address. If provided, it must match the address resolved from target_currency on the specified chain — a mismatch returns a 400 error |
| target_currency | string | No | Target stablecoin (USDT or USDC), defaults to USDT. The backend resolves the corresponding contract address from the chain whitelist |
| chain_id | int | No | Chain ID used to resolve the asset address and precision. Defaults to the default chain (BSC) if not provided |
Response Parameters
| Field | Type | Description |
|---|---|---|
| base_currency | string | Base currency (USD for US stocks, HKD for HK stocks) |
| charge_base | string | Fee in base currency (regular precision) |
| target_currency | string | Target stablecoin (USDT or USDC) |
| charge_target | string | Fee in target stablecoin (native precision of the asset on the target chain) |
| price_base | string | Price in base currency (regular precision, same as request price) |
| price_target | string | Price in target currency (native precision of the asset on the target chain) |
| exchange_rate | float | Exchange rate from base currency to target currency |
| chain_id | int | The chain ID used for this estimate |
| asset_address | string | The resolved asset contract address on the target chain (derived from target_currency and chain_id) |
Precision Reference
charge_target and price_target precision is determined by chain_id and asset. The backend queries the on-chain contract dynamically:
| Chain | chain_id | USDT Decimals | Example: 260 USD |
|---|---|---|---|
| BSC (default) | 56 | 18 | 260000000000000000000 |
| HashKey Chain | 177 | 6 | 260000000 |
These fields can be used directly as the price and incentive fields when constructing an order — no client-side precision conversion needed.
Request Examples
BSC (omit chain_id, uses default)
curl -X POST "{API_BASE_URL}/api/v1/orders/estimate_charge" \
-H "X-API-Key: YOUR_API_KEY" \
-H "X-Maker-Addr: YOUR_MAKER_ADDRESS" \
-H "X-API-Timestamp: 1715100000000" \
-H "X-API-Signature: GENERATED_SIGNATURE" \
-H "Content-Type: application/json" \
-d '{
"is_buy": true,
"ticker": "AAPLs",
"exchange": 0,
"quantity": "100",
"price": "260",
"target_currency": "USDT",
"chain_id": 56
}'HashKey Chain
curl -X POST "{API_BASE_URL}/api/v1/orders/estimate_charge" \
-H "X-API-Key: YOUR_API_KEY" \
-H "X-Maker-Addr: YOUR_MAKER_ADDRESS" \
-H "X-API-Timestamp: 1715100000000" \
-H "X-API-Signature: GENERATED_SIGNATURE" \
-H "Content-Type: application/json" \
-d '{
"is_buy": true,
"ticker": "AAPLs",
"exchange": 0,
"quantity": "100",
"price": "260",
"target_currency": "USDT",
"chain_id": 177
}'Response Examples
BSC (USDT 18 decimals)
{
"code": 0,
"data": {
"base_currency": "USD",
"charge_base": "3.36",
"target_currency": "USDT",
"charge_target": "3377745527638190000",
"price_base": "260",
"price_target": "261373165829145650000",
"exchange_rate": 0.994746339683381,
"chain_id": 56,
"asset_address": "0x55d398326f99059fF775485246999027B3197955"
}
}HashKey Chain (USDT 6 decimals)
{
"code": 0,
"data": {
"base_currency": "USD",
"charge_base": "3.36",
"target_currency": "USDT",
"charge_target": "3377745",
"price_base": "260",
"price_target": "261373165",
"exchange_rate": 0.994746339683381,
"chain_id": 177,
"asset_address": "0xTokenAddressOnHashKey"
}
}Notes
- Input precision:
quantityandpriceuse regular human-readable precision — do not pass wei values - Output precision:
charge_targetandprice_targetuse the native precision of the asset on the target chain, and can be used directly as order fields - Asset address resolution:
asset_addressin the response is resolved fromtarget_currency+chain_idvia the server-side whitelist. Clients can use this value directly as theassetfield when constructing an order - Asset validation: If
assetis provided in the request, it must exactly match the address resolved fromtarget_currencyon the specified chain. A mismatch returns a 400 error - Different chains use different precisions for the same stablecoin (BSC USDT=18, HashKey USDT=6) — always pass the correct
chain_idto get the right precision - Fee estimate is for reference only; actual fee is determined at transaction time