Funding operations provide comprehensive functionality for managing deposits, withdrawals, and internal transfers between different account types and external wallets.
Execute cryptocurrency withdrawals to external addresses with fee calculation and status tracking.
/**
* Withdraw cryptocurrency to external address
* @param code - Currency code (e.g., 'BTC', 'ETH')
* @param amount - Amount to withdraw
* @param address - Destination address
* @param tag - Memo/tag for currencies that require it (optional)
* @param params - Additional withdrawal parameters
* @returns Withdrawal response object
*/
withdraw(code: string, amount: number, address: string, tag?: string, params?: Dict): Promise<WithdrawalResponse>;
interface WithdrawalResponse {
id: string; // Withdrawal ID
txid?: string; // Blockchain transaction ID (when available)
timestamp: number; // Withdrawal request timestamp
datetime: string; // Withdrawal request datetime
currency: string; // Currency code
amount: number; // Withdrawal amount
address: string; // Destination address
tag?: string; // Memo/tag if applicable
status: WithdrawalStatus; // Current withdrawal status
updated?: number; // Last update timestamp
fee?: { // Withdrawal fee
currency: string;
cost: number;
};
network?: string; // Network used for withdrawal
info: any; // Raw exchange-specific data
}
type WithdrawalStatus = 'pending' | 'ok' | 'failed' | 'canceled';
/**
* Fetch withdrawal history
* @param code - Currency code to filter by (optional)
* @param since - Timestamp to fetch withdrawals from (optional)
* @param limit - Maximum number of withdrawals to fetch (optional)
* @param params - Additional parameters
* @returns Array of withdrawal transactions
*/
fetchWithdrawals(code?: string, since?: number, limit?: number, params?: Dict): Promise<Transaction[]>;Usage Examples:
// Withdraw Bitcoin
const btcWithdrawal = await exchange.withdraw(
'BTC',
0.001,
'bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh',
undefined, // No tag needed for BTC
{ network: 'BTC' }
);
console.log(`BTC withdrawal initiated: ${btcWithdrawal.id}`);
// Withdraw USDT on TRC20 network
const usdtWithdrawal = await exchange.withdraw(
'USDT',
100,
'TYDzsYUEpvnYmQk4zGP9sWWcTEd2MiAtW6',
undefined,
{ network: 'TRC20' }
);
// Withdraw Stellar Lumens with memo
const xlmWithdrawal = await exchange.withdraw(
'XLM',
100,
'GDQP2KPQGKIHYJGXNUIYOMHARUARCA7DJT5FO2FFOOKY3B2WSQHG4W37',
'12345', // Memo required
);
// Check withdrawal history
const withdrawals = await exchange.fetchWithdrawals('BTC', undefined, 10);
withdrawals.forEach(withdrawal => {
console.log(`${withdrawal.currency}: ${withdrawal.amount} -> ${withdrawal.address} (${withdrawal.status})`);
});Transfer funds between different account types within the same exchange.
/**
* Transfer funds between internal accounts
* @param code - Currency code
* @param amount - Amount to transfer
* @param fromAccount - Source account type
* @param toAccount - Destination account type
* @param params - Additional transfer parameters
* @returns Transfer response object
*/
transfer(code: string, amount: number, fromAccount: string, toAccount: string, params?: Dict): Promise<TransferEntry>;
interface TransferEntry {
id: string; // Transfer ID
timestamp: number; // Transfer timestamp
datetime: string; // Transfer datetime
currency: string; // Currency code
amount: number; // Transfer amount
fromAccount: string; // Source account
toAccount: string; // Destination account
status: string; // Transfer status
info: any; // Raw exchange data
}Usage Examples:
// Transfer from spot to futures account
const transfer = await exchange.transfer('USDT', 1000, 'spot', 'future');
console.log(`Transferred ${transfer.amount} ${transfer.currency} from ${transfer.fromAccount} to ${transfer.toAccount}`);
// Common account types: 'spot', 'margin', 'future', 'swap', 'funding', 'option'
const marginTransfer = await exchange.transfer('BTC', 0.1, 'spot', 'margin');Track incoming deposits and their confirmation status.
/**
* Fetch deposit history
* @param code - Currency code to filter by (optional)
* @param since - Timestamp to fetch deposits from (optional)
* @param limit - Maximum number of deposits to fetch (optional)
* @param params - Additional parameters
* @returns Array of deposit transactions
*/
fetchDeposits(code?: string, since?: number, limit?: number, params?: Dict): Promise<Transaction[]>;
interface Transaction {
id: string; // Transaction ID
txid?: string; // Blockchain transaction hash
timestamp: number; // Transaction timestamp
datetime: string; // Transaction datetime
currency: string; // Currency code
amount: number; // Transaction amount
address?: string; // Address used for transaction
tag?: string; // Memo/tag if applicable
status: TransactionStatus; // Transaction status
type: 'deposit' | 'withdrawal'; // Transaction type
updated?: number; // Last update timestamp
fee?: { // Transaction fee
currency: string;
cost: number;
};
network?: string; // Network used
info: any; // Raw exchange data
}
type TransactionStatus = 'pending' | 'ok' | 'failed' | 'canceled';Usage Examples:
// Check recent deposits
const deposits = await exchange.fetchDeposits(undefined, undefined, 20);
console.log(`Recent deposits: ${deposits.length}`);
deposits.forEach(deposit => {
console.log(`${deposit.currency}: ${deposit.amount} (${deposit.status})`);
if (deposit.txid) {
console.log(` TX: ${deposit.txid}`);
}
});
// Monitor pending deposits
const pendingDeposits = deposits.filter(d => d.status === 'pending');
console.log(`Pending deposits: ${pendingDeposits.length}`);
// Check deposits for specific currency
const btcDeposits = await exchange.fetchDeposits('BTC');
const totalBtcDeposited = btcDeposits
.filter(d => d.status === 'ok')
.reduce((sum, d) => sum + d.amount, 0);
console.log(`Total BTC deposited: ${totalBtcDeposited}`);