Binance.Bswap (binance v2.0.1)

Binance Swap Endpoints

Summary

Functions

Link to this function

get_bswap_add_liquidity_preview(poolId, type, quoteAsset, quoteQty, opts \\ [])

@spec get_bswap_add_liquidity_preview(any(), any(), any(), any(),
  recvWindow: any(),
  timestamp: any()
) ::
  {:ok, any()} | {:error, any()}

Add Liquidity Preview (USER_DATA)

Calculate expected share amount for adding liquidity in single or dual token.

Weight(IP): 150

Details:

  • METHOD: get
  • URL: /sapi/v1/bswap/addLiquidityPreview

Mandatory params:

  • poolId -
  • type - * SINGLE - for adding a single token
  • COMBINATION - for adding dual tokens
  • quoteAsset -
  • quoteQty -

Optional params:

  • timestamp - timestamp
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_bswap_claimed_history(opts \\ [])

@spec get_bswap_claimed_history(
  recvWindow: any(),
  limit: any(),
  endTime: any(),
  startTime: any(),
  type: any(),
  assetRewards: any(),
  poolId: any(),
  timestamp: any()
) :: {:ok, any()} | {:error, any()}

Get Claimed History (USER_DATA)

Get history of claimed rewards.

Weight(UID): 1000

Details:

  • METHOD: get
  • URL: /sapi/v1/bswap/claimedHistory

Mandatory params:

Optional params:

  • timestamp - timestamp
  • poolId -
  • assetRewards -
  • type - 0: Swap rewards, 1: Liquidity rewards, default to 0
  • startTime - UTC timestamp in ms
  • endTime - UTC timestamp in ms
  • limit - Default 3, max 100
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_bswap_liquidity(opts \\ [])

@spec get_bswap_liquidity(recvWindow: any(), poolId: any(), timestamp: any()) ::
  {:ok, any()} | {:error, any()}

Get liquidity information of a pool (USER_DATA)

Get liquidity information and user share of a pool.

Weight(IP):

  • 1 for one pool;
  • 10 when the poolId parameter is omitted;

Details:

  • METHOD: get
  • URL: /sapi/v1/bswap/liquidity

Mandatory params:

Optional params:

  • timestamp - timestamp
  • poolId -
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_bswap_liquidity_ops(opts \\ [])

@spec get_bswap_liquidity_ops(
  recvWindow: any(),
  limit: any(),
  endTime: any(),
  startTime: any(),
  operation: any(),
  poolId: any(),
  operationId: any(),
  timestamp: any()
) :: {:ok, any()} | {:error, any()}

Get Liquidity Operation Record (USER_DATA)

Get liquidity operation (add/remove) records.

Weight(UID): 3000

Details:

  • METHOD: get
  • URL: /sapi/v1/bswap/liquidityOps

Mandatory params:

Optional params:

  • timestamp - timestamp
  • operationId -
  • poolId -
  • operation -
  • startTime - UTC timestamp in ms
  • endTime - UTC timestamp in ms
  • limit - Default 500; max 1000.
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_bswap_pool_configure(opts \\ [])

@spec get_bswap_pool_configure(recvWindow: any(), poolId: any(), timestamp: any()) ::
  {:ok, any()} | {:error, any()}

Get Pool Configure (USER_DATA)

Weight(IP): 150

Details:

  • METHOD: get
  • URL: /sapi/v1/bswap/poolConfigure

Mandatory params:

Optional params:

  • timestamp - timestamp
  • poolId -
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_bswap_pools(opts \\ [])

@spec get_bswap_pools([]) :: {:ok, any()} | {:error, any()}

List All Swap Pools (MARKET_DATA)

Get metadata about all swap pools.

Weight(IP): 1

Details:

  • METHOD: get
  • URL: /sapi/v1/bswap/pools

Mandatory params:

Optional params:

Link to this function

get_bswap_quote(quoteAsset, baseAsset, quoteQty, opts \\ [])

@spec get_bswap_quote(any(), any(), any(), recvWindow: any(), timestamp: any()) ::
  {:ok, any()} | {:error, any()}

Request Quote (USER_DATA)

Request a quote for swap quote asset (selling asset) for base asset (buying asset), essentially price/exchange rates.

quoteQty is quantity of quote asset (to sell).

Please be noted the quote is for reference only, the actual price will change as the liquidity changes, it's recommended to swap immediate after request a quote for slippage prevention.

Weight(UID): 150

Details:

  • METHOD: get
  • URL: /sapi/v1/bswap/quote

Mandatory params:

  • quoteAsset -
  • baseAsset -
  • quoteQty -

Optional params:

  • timestamp - timestamp
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_bswap_remove_liquidity_preview(poolId, type, quoteAsset, shareAmount, opts \\ [])

@spec get_bswap_remove_liquidity_preview(any(), any(), any(), any(),
  recvWindow: any(),
  timestamp: any()
) ::
  {:ok, any()} | {:error, any()}

Remove Liquidity Preview (USER_DATA)

Calculate the expected asset amount of single token redemption or dual token redemption.

Weight(IP): 150

Details:

  • METHOD: get
  • URL: /sapi/v1/bswap/removeLiquidityPreview

Mandatory params:

  • poolId -
  • type - * SINGLE - remove and obtain a single token
  • COMBINATION - remove and obtain dual token
  • quoteAsset -
  • shareAmount -

Optional params:

  • timestamp - timestamp
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_bswap_swap(opts \\ [])

@spec get_bswap_swap(
  recvWindow: any(),
  limit: any(),
  baseAsset: any(),
  quoteAsset: any(),
  status: any(),
  endTime: any(),
  startTime: any(),
  swapId: any(),
  timestamp: any()
) :: {:ok, any()} | {:error, any()}

Get Swap History (USER_DATA)

Get swap history.

Weight(UID): 3000

Details:

  • METHOD: get
  • URL: /sapi/v1/bswap/swap

Mandatory params:

Optional params:

  • timestamp - timestamp
  • swapId -
  • startTime - UTC timestamp in ms
  • endTime - UTC timestamp in ms
  • status - * 0 - pending for swap
  • 1 - success
  • 2 - failed
  • quoteAsset -
  • baseAsset -
  • limit - default 3, max 100
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_bswap_unclaimed_rewards(opts \\ [])

@spec get_bswap_unclaimed_rewards(recvWindow: any(), type: any(), timestamp: any()) ::
  {:ok, any()} | {:error, any()}

Get Unclaimed Rewards Record (USER_DATA)

Get unclaimed rewards record.

Weight(UID): 1000

Details:

  • METHOD: get
  • URL: /sapi/v1/bswap/unclaimedRewards

Mandatory params:

Optional params:

  • timestamp - timestamp
  • type - 0: Swap rewards, 1: Liquidity rewards, default to 0
  • recvWindow - The value cannot be greater than 60000
Link to this function

post_bswap_claim_rewards(opts \\ [])

@spec post_bswap_claim_rewards(recvWindow: any(), type: any(), timestamp: any()) ::
  {:ok, any()} | {:error, any()}

Claim Rewards (TRADE)

Claim swap rewards or liquidity rewards

Weight(UID): 1000

Details:

  • METHOD: post
  • URL: /sapi/v1/bswap/claimRewards

Mandatory params:

Optional params:

  • timestamp - timestamp
  • type - 0: Swap rewards, 1: Liquidity rewards, default to 0
  • recvWindow - The value cannot be greater than 60000
Link to this function

post_bswap_liquidity_add(poolId, asset, quantity, opts \\ [])

@spec post_bswap_liquidity_add(any(), any(), any(),
  recvWindow: any(),
  type: any(),
  timestamp: any()
) ::
  {:ok, any()} | {:error, any()}

Add Liquidity (TRADE)

Add liquidity to a pool.

Weight(UID): 1000 (Additional: 3 times one second)

Details:

  • METHOD: post
  • URL: /sapi/v1/bswap/liquidityAdd

Mandatory params:

  • poolId -
  • asset -
  • quantity -

Optional params:

  • timestamp - timestamp
  • type - * Single - to add a single token
  • Combination - to add dual tokens
  • recvWindow - The value cannot be greater than 60000
Link to this function

post_bswap_liquidity_remove(poolId, type, shareAmount, opts \\ [])

@spec post_bswap_liquidity_remove(any(), any(), any(),
  recvWindow: any(),
  asset: any(),
  timestamp: any()
) ::
  {:ok, any()} | {:error, any()}

Remove Liquidity (TRADE)

Remove liquidity from a pool, type include SINGLE and COMBINATION, asset is mandatory for single asset removal

Weight(UID): 1000 (Additional: 3 times one second)

Details:

  • METHOD: post
  • URL: /sapi/v1/bswap/liquidityRemove

Mandatory params:

  • poolId -
  • type - * SINGLE - for single asset removal
  • COMBINATION - for combination of all coins removal
  • shareAmount -

Optional params:

  • timestamp - timestamp
  • asset - Mandatory for single asset removal
  • recvWindow - The value cannot be greater than 60000
Link to this function

post_bswap_swap(quoteAsset, baseAsset, quoteQty, opts \\ [])

@spec post_bswap_swap(any(), any(), any(), recvWindow: any(), timestamp: any()) ::
  {:ok, any()} | {:error, any()}

Swap (TRADE)

Swap quoteAsset for baseAsset.

Weight(UID): 1000 (Additional: 3 times one second)

Details:

  • METHOD: post
  • URL: /sapi/v1/bswap/swap

Mandatory params:

  • quoteAsset -
  • baseAsset -
  • quoteQty -

Optional params:

  • timestamp - timestamp
  • recvWindow - The value cannot be greater than 60000