Module: Binance::Spot::Bswap

Included in:
Binance::Spot
Defined in:
lib/binance/spot/bswap.rb

Overview

Bswap endpoints

Instance Method Summary collapse

Instance Method Details

#add_liquidity(poolId:, asset:, quantity:, **kwargs) ⇒ Object

Add Liquidity (TRADE)

POST /sapi/v1/bswap/liquidityAdd

Parameters:

  • poolId (Integer)
  • asset (String)
  • quantity (Float)
  • kwargs (Hash)

Options Hash (**kwargs):

  • :type (String)

    “Single” to add a single token; “Combination” to add dual tokens. Default “Single”

  • :recvWindow (Integer)

    The value cannot be greater than 60000

See Also:



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/binance/spot/bswap.rb', line 40

def add_liquidity(poolId:, asset:, quantity:, **kwargs)
  Binance::Utils::Validation.require_param('poolId', poolId)
  Binance::Utils::Validation.require_param('asset', asset)
  Binance::Utils::Validation.require_param('quantity', quantity)

  @session.sign_request(:post, '/sapi/v1/bswap/liquidityAdd', params: kwargs.merge(
    poolId: poolId,
    asset: asset,
    quantity: quantity
  ))
end

#add_liquidity_preview(poolId:, type:, quoteAsset:, quoteQty:, **kwargs) ⇒ Object

Add Liquidity Preview (USER_DATA)

GET /sapi/v1/bswap/addLiquidityPreview

Parameters:

  • poolId (Integer)
  • type (String)

    “SINGLE” for adding a single token; “COMBINATION” for adding dual tokens

  • quoteAsset (String)
  • quoteQty (Float)
  • kwargs (Hash)

Options Hash (**kwargs):

  • :recvWindow (Integer)

    The value cannot be greater than 60000

See Also:



177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/binance/spot/bswap.rb', line 177

def add_liquidity_preview(poolId:, type:, quoteAsset:, quoteQty:, **kwargs)
  Binance::Utils::Validation.require_param('poolId', poolId)
  Binance::Utils::Validation.require_param('type', type)
  Binance::Utils::Validation.require_param('quoteAsset', quoteAsset)
  Binance::Utils::Validation.require_param('quoteQty', quoteQty)

  @session.sign_request(:get, '/sapi/v1/bswap/addLiquidityPreview', params: kwargs.merge(
    poolId: poolId,
    type: type,
    quoteAsset: quoteAsset,
    quoteQty: quoteQty
  ))
end

#get_liquidity_info(**kwargs) ⇒ Object

Get liquidity information of a pool (USER_DATA)

GET /sapi/v1/bswap/liquidity

Parameters:

  • kwargs (Hash)

Options Hash (**kwargs):

  • :poolId (Integer)
  • :recvWindow (Integer)

    The value cannot be greater than 60000

See Also:



25
26
27
# File 'lib/binance/spot/bswap.rb', line 25

def get_liquidity_info(**kwargs)
  @session.sign_request(:get, '/sapi/v1/bswap/liquidity', params: kwargs)
end

#get_liquidity_operation_record(**kwargs) ⇒ Object

Get Liquidity Operation Record (USER_DATA)

GET /sapi/v1/bswap/liquidityOps

Parameters:

  • kwargs (Hash)

Options Hash (**kwargs):

  • :operationId (Integer)
  • :poolId (Integer)
  • :operation (String)

    ADD or REMOVE

  • :startTime (Integer)
  • :endTime (Integer)
  • :limit (Integer)

    default 3, max 100

  • :recvWindow (Integer)

    The value cannot be greater than 60000

See Also:



88
89
90
# File 'lib/binance/spot/bswap.rb', line 88

def get_liquidity_operation_record(**kwargs)
  @session.sign_request(:get, '/sapi/v1/bswap/liquidityOps', params: kwargs)
end

#get_pool_config(**kwargs) ⇒ Object

Get Pool Configure (USER_DATA)

GET /sapi/v1/bswap/poolConfigure

Parameters:

  • kwargs (Hash)

Options Hash (**kwargs):

  • :poolId (Integer)
  • :recvWindow (Integer)

    The value cannot be greater than 60000

See Also:



162
163
164
# File 'lib/binance/spot/bswap.rb', line 162

def get_pool_config(**kwargs)
  @session.sign_request(:get, '/sapi/v1/bswap/poolConfigure', params: kwargs)
end

#get_swap_history(**kwargs) ⇒ Object

Get Swap History (USER_DATA)

GET /sapi/v1/bswap/swap

Parameters:

  • kwargs (Hash)

Options Hash (**kwargs):

  • :swapId (Integer)
  • :startTime (Integer)
  • :endTime (Integer)
  • :status (Integer)

    0: pending for swap, 1: success, 2: failed

  • :quoteAsset (String)
  • :baseAsset (String)
  • :limit (Integer)
  • :recvWindow (Integer)

    The value cannot be greater than 60000

See Also:



150
151
152
# File 'lib/binance/spot/bswap.rb', line 150

def get_swap_history(**kwargs)
  @session.sign_request(:get, '/sapi/v1/bswap/swap', params: kwargs)
end

#remove_liquidity(poolId:, type:, shareAmount:, **kwargs) ⇒ Object

Remove Liquidity (TRADE)

POST /sapi/v1/bswap/liquidityRemove

Parameters:

  • poolId (Integer)
  • type (String)

    SINGLE for single asset removal, COMBINATION for combination of all coins removal

  • shareAmount (Float)
  • kwargs (Hash)

Options Hash (**kwargs):

  • :asset (String Array)

    Mandatory for single asset removal

  • :recvWindow (Integer)

    The value cannot be greater than 60000

See Also:



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/binance/spot/bswap.rb', line 63

def remove_liquidity(poolId:, type:, shareAmount:, **kwargs)
  Binance::Utils::Validation.require_param('poolId', poolId)
  Binance::Utils::Validation.require_param('type', type)
  Binance::Utils::Validation.require_param('shareAmount', shareAmount)

  @session.sign_request(:post, '/sapi/v1/bswap/liquidityRemove', params: kwargs.merge(
    poolId: poolId,
    type: type,
    shareAmount: shareAmount
  ))
end

#remove_liquidity_preview(poolId:, type:, quoteAsset:, shareAmount:, **kwargs) ⇒ Object

Remove Liquidity Preview (USER_DATA)

GET /sapi/v1/bswap/removeLiquidityPreview

Parameters:

  • poolId (Integer)
  • type (String)

    “SINGLE” for removing a single token; “COMBINATION” for removing dual tokens

  • quoteAsset (String)
  • shareAmount (Float)
  • kwargs (Hash)

Options Hash (**kwargs):

  • :recvWindow (Integer)

    The value cannot be greater than 60000

See Also:



202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/binance/spot/bswap.rb', line 202

def remove_liquidity_preview(poolId:, type:, quoteAsset:, shareAmount:, **kwargs)
  Binance::Utils::Validation.require_param('poolId', poolId)
  Binance::Utils::Validation.require_param('type', type)
  Binance::Utils::Validation.require_param('quoteAsset', quoteAsset)
  Binance::Utils::Validation.require_param('shareAmount', shareAmount)

  @session.sign_request(:get, '/sapi/v1/bswap/removeLiquidityPreview', params: kwargs.merge(
    poolId: poolId,
    type: type,
    quoteAsset: quoteAsset,
    shareAmount: shareAmount
  ))
end

#request_quote(quoteAsset:, baseAsset:, quoteQty:, **kwargs) ⇒ Object

Request Quote (USER_DATA)

GET /sapi/v1/bswap/quote

Parameters:

  • quoteAsset (String)
  • baseAsset (String)
  • quoteQty (Float)
  • kwargs (Hash)

Options Hash (**kwargs):

  • :recvWindow (Integer)

    The value cannot be greater than 60000

See Also:



102
103
104
105
106
107
108
109
110
111
112
# File 'lib/binance/spot/bswap.rb', line 102

def request_quote(quoteAsset:, baseAsset:, quoteQty:, **kwargs)
  Binance::Utils::Validation.require_param('quoteAsset', quoteAsset)
  Binance::Utils::Validation.require_param('baseAsset', baseAsset)
  Binance::Utils::Validation.require_param('quoteQty', quoteQty)

  @session.sign_request(:get, '/sapi/v1/bswap/quote', params: kwargs.merge(
    quoteAsset: quoteAsset,
    baseAsset: baseAsset,
    quoteQty: quoteQty
  ))
end

#swap(quoteAsset:, baseAsset:, quoteQty:, **kwargs) ⇒ Object

Swap (TRADE)

POST /sapi/v1/bswap/swap

Parameters:

  • quoteAsset (String)
  • baseAsset (String)
  • quoteQty (Float)
  • kwargs (Hash)

Options Hash (**kwargs):

  • :recvWindow (Integer)

    The value cannot be greater than 60000

See Also:



124
125
126
127
128
129
130
131
132
133
134
# File 'lib/binance/spot/bswap.rb', line 124

def swap(quoteAsset:, baseAsset:, quoteQty:, **kwargs)
  Binance::Utils::Validation.require_param('quoteAsset', quoteAsset)
  Binance::Utils::Validation.require_param('baseAsset', baseAsset)
  Binance::Utils::Validation.require_param('quoteQty', quoteQty)

  @session.sign_request(:post, '/sapi/v1/bswap/swap', params: kwargs.merge(
    quoteAsset: quoteAsset,
    baseAsset: baseAsset,
    quoteQty: quoteQty
  ))
end

#swap_poolsObject

List All Swap Pools (MARKET_DATA)

GET /sapi/v1/bswap/pools



13
14
15
# File 'lib/binance/spot/bswap.rb', line 13

def swap_pools
  @session.limit_request(path: '/sapi/v1/bswap/pools')
end