Documentation
API Reference
Withdraw
ℹ️

To interact with the Cede SDK, you need to create an instance of the SDK and register at least one exchange instance. Refer to the General info section for details.

Withdrawable Tokens

This method can be used to fetch all withdrawable tokens on a given exchange. Withdrawable tokens respects the following conditions:

  • A part of the balance is free, meaning that the user owns these tokens and these are not being used in open orders, loans, etc.
  • Store in a wallet type from the transferWalletTypes list, obtained from the getSupportedExchanges method. Because the Cede SDK is able to transfer tokens between wallet types.
  • The token can be withdrawn to at least one network and this network is enabled for withdrawals.

To get withdrawable tokens:

method: getWithdrawableBalances
params:

  • exchangeInstanceId - string
    The exchange instance ID for which you want to fetch the withdrawable tokens.
  • auth - The authentication object for the exchange. See authentication section for details.
  • network - string, optional
    The network's ID. If you want to get balances for a specific network, you can pass the network as a parameter. If not, the method will return the balances for all available networks. See Supported Networks for the list of supported networks.
  • forceRefresh - boolean, optional
    If true, fetches the balances from the exchange and updates the cache.
    Default: false.

response structure: Promise<GroupedBalances>, see GroupedBalances for details.

💡
The TTL on this method is 10_000ms.
const withdrawableTokens = await cedeSDK.api.getWithdrawableBalances({ exchangeInstanceId, auth, network: "ethereum" });

Withdrawable networks

To fetch all available withdraw networks on a given exchange and token, use:

method: getNetworks
params:

  • exchangeInstanceId - string
    The exchange instance ID for which you want to fetch the networks.
  • auth - The authentication object for the exchange. See authentication section for details.
  • tokenSymbol - TokenSymbol, optional
    Filters the networks by token. If not provided, all networks will be fetched.
  • opts.toDeposit - boolean, optional
    Filters the networks by deposit availability.
  • opts.toWithdraw - boolean, optional
    Filters the networks by withdrawal availability.
  • opts.requestPriority - 1 | 2 | 3, optional
    The request priority.
    Default: 2 (medium).

response structure: Promise<MarketNetwork[]>, see MarketNetwork for details and see Supported Networks for the list of supported networks.

💡

We offer unified network names and chainIds (EIP-155) for all exchanges, see Supported Networks. If the chain is not EVM, chainId is equal to undefined. You can use the "name" property to display the network name to the user. The network property must be used for the methods requiring the network.

 const withdrawableNetworks = await cedeSDK.api.getNetworks({ 
   exchangeInstanceId,
   auth,
   tokenSymbol: "AVAX",
   opts: {
     toWithdraw: true
   }
 });

Get Withdrawal Fee

To fetch the withdrawal fee for a given token and network, use:

method: getWithdrawalFee
params:

  • exchangeInstanceId - string
    The exchange instance ID for which you want to fetch the withdrawal fee.
  • auth - The authentication object for the exchange. See authentication section for details.
  • tokenSymbol - TokenSymbol
    The token's symbol.
  • amount - number
    The amount to be withdrawn.
  • network - string
    The network's ID. See Supported Networks for the list of supported networks.
  • opts.key - string, optional
    Required for Kraken. Represents a whitelisted withdrawal address key. Get this key from the getWhitelistedAddresses method.

response structure: Promise<{ amount: number, tokenSymbol: string }>.

  • amount - number
    The withdrawal fee amount.
  • tokenSymbol - string
    The fee token's symbol.
const fee = await cedeSDK.api.getWithdrawalFee({ 
  exchangeInstanceId,
  auth,
  tokenSymbol: "USDT",
  amount: 12,
  network: "ethereum",
});

Get whitelisted addresses

To fetch the whitelisted addresses for a given exchange, use:

method: getWhitelistedAddresses
params:

  • exchangeInstanceId - string
    The exchange instance ID for which you want to fetch the whitelisted addresses.
  • auth - The authentication object for the exchange. See authentication section for details.
  • network - string | number, optional
    The network's ID or chain ID. If not provided, the method will return the whitelisted addresses for all available networks. See Supported Networks for the list of supported networks.
  • tokenSymbol - string, optional
    Filters the whitelisted addresses by token. If not provided, all whitelisted addresses will be returned.

response structure: Promise<WhitelistedAddress[]>, see WhitelistedAddress for details.

const isWhitelisted = await cedeSDK.api.getWhitelistedAddresses({ 
  exchangeInstanceId,
  auth,
  network: "ethereum",
  tokenSymbol: "USDT"
});
💡

The getWhitelistedAddresses method is available for Binance, Kraken and Gate.io . Use the getSupportedExchanges method and the flag provideWhitelistedAddresses to check if the method is available for a specific exchange.

Prepare withdrawal

Given a set of withdrawal parameters, this method validates each one of them. For example, it compares the available balance against the balance to be withdrawn or checks minimum withdrawal amounts, among other validations.

Binance requires two keys for withdrawals: one for reading and one for writing. If you are using Binance, you need to register a new exchange instance with API keys that have whitelisted IP addresses. Then, you must pass the newly registered exchange instance ID as fromExchangeInstanceId and the read-only exchange instance ID as readonlyExchangeInstanceId.

💡

The prepareWithdrawal method is optional but we encourage you to use it to validate withdrawal parameters.

method: prepareWithdrawal
params:

  • fromExchangeInstanceId - string
    The exchange instance ID from which you want to withdraw.
  • auth - The authentication object for the exchange. See authentication section for details.
  • tokenSymbol - string
    The token's symbol.
  • amount - number
    The amount to be withdrawn.
  • network - string
    The network's ID. See Supported Networks for the list of supported networks.
  • readonlyExchangeInstanceId - string, optional
    Required for exchanges using two keys for withdrawals (e.g. Binance).

response structure: Promise<"success">. The method will throw an error if the validation fails.

await cedeSDK.api.prepareWithdrawal({ 
  exchangeInstanceId,
  auth,
  tokenSymbol: "AVAX",
  amount: 1,
  address: "0x123456789",
  network: "avacchain"
});

Create withdrawal

Submits a withdrawal request to the exchange, initiating the process to transfer funds out of the exchange wallet(s).

This method submits the withdrawal request to the exchange and returns the internal transaction ID. To retrieve the status, the transaction hash and other details of the withdrawal request, use the getWithdrawalById method. Note that the exchange doesn't assign instantly the transaction hash to the withdrawal request, so the transaction hash will be unknown until the exchange assigns it.

Binance requires two keys for withdrawals: one for reading and one for writing. If you are using Binance, you need to register a new exchange instance with API keys that have whitelisted IP addresses. Then, you must pass the newly registered exchange instance ID as fromExchangeInstanceId and the read-only exchange instance ID as readonlyExchangeInstanceId.

method: createWithdrawal
params:

  • fromExchangeInstanceId - string
    The exchange instance ID from which you want to withdraw.
  • auth - The authentication object for the exchange. See authentication section for details.
  • tokenSymbol - string
    The token's symbol.
  • amount - number
    The amount to be withdrawn.
  • address - string
    The withdrawal address. For Kraken, this should be the whitelisted withdrawal key.
  • network - string
    The network's ID. See Supported Networks for the list of supported networks
  • totpCode - string, optional
    Required for exchanges with 2FA (In the future you should use getSupportedExchanges to check if an exchange needs the 2FA but actually there is no field. Coinbase requires 2FA for withdrawals and OAuth).
  • readonlyExchangeInstanceId - string, optional
    Required for exchanges using two keys for withdrawals (e.g. Binance).
  • withdrawalTag - string, optional
    Required for some networks.

response structure: Promise<PureTransaction>, see PureTransaction for details.

  const withdrawal = await cedeSDK.api.createWithdrawal({ 
    fromExchangeInstanceId,
    auth,
    tokenSymbol: "USDT",
    amount: 12,
    address: "0x123456789",
    network: "ethereum",
    totpCode: "123456" // Coinbase requires 2FA
});

Get withdrawal by ID

Retrieves specific withdrawal data using the unique withdrawal ID, providing detailed information regarding the status, the transaction hash and other details of the withdrawal request.

method: getWithdrawalById
params:

  • exchangeInstanceId - string
    The exchange instance ID from which you want to withdraw.
  • auth - The authentication object for the exchange. See authentication section for details.
  • withdrawalId - string
    The withdrawal ID. This ID is unique for each withdrawal and is generated by the exchange.
  • tokenSymbol - string
    The token's symbol.
  • timestamp - number
    The timestamp of the withdrawal.
    The timestamp doesn't need to be totally accurate, but it should be close to the withdrawal time up to 10 seconds.

response structure: Promise<PureTransaction>, see PureTransaction for details.

  const withdrawal = await cedeSDK.api.getWithdrawalById({ 
    exchangeInstanceId, 
    auth,
    withdrawalId: "60748946115", 
    tokenSymbol: "ETH",
    timestamp: 1696512793776
  });