binance-connector-ruby 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,217 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Binance
4
+ class Spot
5
+ # Bswap endpoints
6
+ # @see https://binance-docs.github.io/apidocs/spot/en/#bswap-endpoints
7
+ module Bswap
8
+ # List All Swap Pools (MARKET_DATA)
9
+ #
10
+ # GET /sapi/v1/bswap/pools
11
+ #
12
+ # @see https://binance-docs.github.io/apidocs/spot/en/#list-all-swap-pools-market_data
13
+ def swap_pools
14
+ @session.limit_request(path: '/sapi/v1/bswap/pools')
15
+ end
16
+
17
+ # Get liquidity information of a pool (USER_DATA)
18
+ #
19
+ # GET /sapi/v1/bswap/liquidity
20
+ #
21
+ # @param kwargs [Hash]
22
+ # @option kwargs [Integer] :poolId
23
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
24
+ # @see https://binance-docs.github.io/apidocs/spot/en/#get-liquidity-information-of-a-pool-user_data
25
+ def get_liquidity_info(**kwargs)
26
+ @session.sign_request(:get, '/sapi/v1/bswap/liquidity', params: kwargs)
27
+ end
28
+
29
+ # Add Liquidity (TRADE)
30
+ #
31
+ # POST /sapi/v1/bswap/liquidityAdd
32
+ #
33
+ # @param poolId [Integer]
34
+ # @param asset [String]
35
+ # @param quantity [Float]
36
+ # @param kwargs [Hash]
37
+ # @option kwargs [String] :type "Single" to add a single token; "Combination" to add dual tokens. Default "Single"
38
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
39
+ # @see https://binance-docs.github.io/apidocs/spot/en/#add-liquidity-trade
40
+ def add_liquidity(poolId:, asset:, quantity:, **kwargs)
41
+ Binance::Utils::Validation.require_param('poolId', poolId)
42
+ Binance::Utils::Validation.require_param('asset', asset)
43
+ Binance::Utils::Validation.require_param('quantity', quantity)
44
+
45
+ @session.sign_request(:post, '/sapi/v1/bswap/liquidityAdd', params: kwargs.merge(
46
+ poolId: poolId,
47
+ asset: asset,
48
+ quantity: quantity
49
+ ))
50
+ end
51
+
52
+ # Remove Liquidity (TRADE)
53
+ #
54
+ # POST /sapi/v1/bswap/liquidityRemove
55
+ #
56
+ # @param poolId [Integer]
57
+ # @param type [String] SINGLE for single asset removal, COMBINATION for combination of all coins removal
58
+ # @param shareAmount [Float]
59
+ # @param kwargs [Hash]
60
+ # @option kwargs [String Array] :asset Mandatory for single asset removal
61
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
62
+ # @see https://binance-docs.github.io/apidocs/spot/en/#remove-liquidity-trade
63
+ def remove_liquidity(poolId:, type:, shareAmount:, **kwargs)
64
+ Binance::Utils::Validation.require_param('poolId', poolId)
65
+ Binance::Utils::Validation.require_param('type', type)
66
+ Binance::Utils::Validation.require_param('shareAmount', shareAmount)
67
+
68
+ @session.sign_request(:post, '/sapi/v1/bswap/liquidityRemove', params: kwargs.merge(
69
+ poolId: poolId,
70
+ type: type,
71
+ shareAmount: shareAmount
72
+ ))
73
+ end
74
+
75
+ # Get Liquidity Operation Record (USER_DATA)
76
+ #
77
+ # GET /sapi/v1/bswap/liquidityOps
78
+ #
79
+ # @param kwargs [Hash]
80
+ # @option kwargs [Integer] :operationId
81
+ # @option kwargs [Integer] :poolId
82
+ # @option kwargs [String] :operation ADD or REMOVE
83
+ # @option kwargs [Integer] :startTime
84
+ # @option kwargs [Integer] :endTime
85
+ # @option kwargs [Integer] :limit default 3, max 100
86
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
87
+ # @see https://binance-docs.github.io/apidocs/spot/en/#get-liquidity-operation-record-user_data
88
+ def get_liquidity_operation_record(**kwargs)
89
+ @session.sign_request(:get, '/sapi/v1/bswap/liquidityOps', params: kwargs)
90
+ end
91
+
92
+ # Request Quote (USER_DATA)
93
+ #
94
+ # GET /sapi/v1/bswap/quote
95
+ #
96
+ # @param quoteAsset [String]
97
+ # @param baseAsset [String]
98
+ # @param quoteQty [Float]
99
+ # @param kwargs [Hash]
100
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
101
+ # @see https://binance-docs.github.io/apidocs/spot/en/#request-quote-user_data
102
+ def request_quote(quoteAsset:, baseAsset:, quoteQty:, **kwargs)
103
+ Binance::Utils::Validation.require_param('quoteAsset', quoteAsset)
104
+ Binance::Utils::Validation.require_param('baseAsset', baseAsset)
105
+ Binance::Utils::Validation.require_param('quoteQty', quoteQty)
106
+
107
+ @session.sign_request(:get, '/sapi/v1/bswap/quote', params: kwargs.merge(
108
+ quoteAsset: quoteAsset,
109
+ baseAsset: baseAsset,
110
+ quoteQty: quoteQty
111
+ ))
112
+ end
113
+
114
+ # Swap (TRADE)
115
+ #
116
+ # POST /sapi/v1/bswap/swap
117
+ #
118
+ # @param quoteAsset [String]
119
+ # @param baseAsset [String]
120
+ # @param quoteQty [Float]
121
+ # @param [Hash] kwargs
122
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
123
+ # @see https://binance-docs.github.io/apidocs/spot/en/#swap-trade
124
+ def swap(quoteAsset:, baseAsset:, quoteQty:, **kwargs)
125
+ Binance::Utils::Validation.require_param('quoteAsset', quoteAsset)
126
+ Binance::Utils::Validation.require_param('baseAsset', baseAsset)
127
+ Binance::Utils::Validation.require_param('quoteQty', quoteQty)
128
+
129
+ @session.sign_request(:post, '/sapi/v1/bswap/swap', params: kwargs.merge(
130
+ quoteAsset: quoteAsset,
131
+ baseAsset: baseAsset,
132
+ quoteQty: quoteQty
133
+ ))
134
+ end
135
+
136
+ # Get Swap History (USER_DATA)
137
+ #
138
+ # GET /sapi/v1/bswap/swap
139
+ #
140
+ # @param kwargs [Hash]
141
+ # @option kwargs [Integer] :swapId
142
+ # @option kwargs [Integer] :startTime
143
+ # @option kwargs [Integer] :endTime
144
+ # @option kwargs [Integer] :status 0: pending for swap, 1: success, 2: failed
145
+ # @option kwargs [String] :quoteAsset
146
+ # @option kwargs [String] :baseAsset
147
+ # @option kwargs [Integer] :limit
148
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
149
+ # @see https://binance-docs.github.io/apidocs/spot/en/#get-swap-history-user_data
150
+ def get_swap_history(**kwargs)
151
+ @session.sign_request(:get, '/sapi/v1/bswap/swap', params: kwargs)
152
+ end
153
+
154
+ # Get Pool Configure (USER_DATA)
155
+ #
156
+ # GET /sapi/v1/bswap/poolConfigure
157
+ #
158
+ # @param kwargs [Hash]
159
+ # @option kwargs [Integer] :poolId
160
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
161
+ # @see https://binance-docs.github.io/apidocs/spot/en/#get-pool-configure-user_data
162
+ def get_pool_config(**kwargs)
163
+ @session.sign_request(:get, '/sapi/v1/bswap/poolConfigure', params: kwargs)
164
+ end
165
+
166
+ # Add Liquidity Preview (USER_DATA)
167
+ #
168
+ # GET /sapi/v1/bswap/addLiquidityPreview
169
+ #
170
+ # @param poolId [Integer]
171
+ # @param type [String] "SINGLE" for adding a single token; "COMBINATION" for adding dual tokens
172
+ # @param quoteAsset [String]
173
+ # @param quoteQty [Float]
174
+ # @param [Hash] kwargs
175
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
176
+ # @see https://binance-docs.github.io/apidocs/spot/en/#add-liquidity-preview-user_data
177
+ def add_liquidity_preview(poolId:, type:, quoteAsset:, quoteQty:, **kwargs)
178
+ Binance::Utils::Validation.require_param('poolId', poolId)
179
+ Binance::Utils::Validation.require_param('type', type)
180
+ Binance::Utils::Validation.require_param('quoteAsset', quoteAsset)
181
+ Binance::Utils::Validation.require_param('quoteQty', quoteQty)
182
+
183
+ @session.sign_request(:get, '/sapi/v1/bswap/addLiquidityPreview', params: kwargs.merge(
184
+ poolId: poolId,
185
+ type: type,
186
+ quoteAsset: quoteAsset,
187
+ quoteQty: quoteQty
188
+ ))
189
+ end
190
+
191
+ # Remove Liquidity Preview (USER_DATA)
192
+ #
193
+ # GET /sapi/v1/bswap/removeLiquidityPreview
194
+ #
195
+ # @param poolId [Integer]
196
+ # @param type [String] "SINGLE" for removing a single token; "COMBINATION" for removing dual tokens
197
+ # @param quoteAsset [String]
198
+ # @param shareAmount [Float]
199
+ # @param [Hash] kwargs
200
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
201
+ # @see https://binance-docs.github.io/apidocs/spot/en/#remove-liquidity-preview-user_data
202
+ def remove_liquidity_preview(poolId:, type:, quoteAsset:, shareAmount:, **kwargs)
203
+ Binance::Utils::Validation.require_param('poolId', poolId)
204
+ Binance::Utils::Validation.require_param('type', type)
205
+ Binance::Utils::Validation.require_param('quoteAsset', quoteAsset)
206
+ Binance::Utils::Validation.require_param('shareAmount', shareAmount)
207
+
208
+ @session.sign_request(:get, '/sapi/v1/bswap/removeLiquidityPreview', params: kwargs.merge(
209
+ poolId: poolId,
210
+ type: type,
211
+ quoteAsset: quoteAsset,
212
+ shareAmount: shareAmount
213
+ ))
214
+ end
215
+ end
216
+ end
217
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Binance
4
+ class Spot
5
+ # C2C endpoints
6
+ # @see https://binance-docs.github.io/apidocs/spot/en/#c2c-endpoints
7
+ module C2C
8
+ # Get C2C Trade History (USER_DATA)
9
+ #
10
+ # GET /sapi/v1/c2c/orderMatch/listUserOrderHistory
11
+ #
12
+ # @param tradeType [String]
13
+ # @option kwargs [Integer] :startTimestamp
14
+ # @option kwargs [Integer] :endTimestamp
15
+ # @option kwargs [Integer] :page
16
+ # @option kwargs [Integer] :rows
17
+ # @option kwargs [Integer] :recvWindow
18
+ # @option kwargs [Integer] :timestamp
19
+ # @see https://binance-docs.github.io/apidocs/spot/en/#get-c2c-trade-history-user_data
20
+ def c2c_trade_history(tradeType:, **kwargs)
21
+ Binance::Utils::Validation.require_param('tradeType', tradeType)
22
+
23
+ @session.sign_request(:get, '/sapi/v1/c2c/orderMatch/listUserOrderHistory', params: kwargs.merge(tradeType: tradeType))
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Binance
4
+ class Spot
5
+ # Fiat endpoints
6
+ # @see https://binance-docs.github.io/apidocs/spot/en/#fiat-endpoints
7
+ module Fiat
8
+ # Get Fiat Deposit/Withdraw History (USER_DATA)
9
+ #
10
+ # GET /sapi/v1/fiat/orders
11
+ #
12
+ # @param transactionType [String] 0-deposit,1-withdraw
13
+ # @param kwargs [Hash]
14
+ # @option kwargs [Integer] :beginTime If beginTime and endTime are not sent, the recent 30-day data will be returned.
15
+ # @option kwargs [Integer] :endTime If beginTime and endTime are not sent, the recent 30-day data will be returned.
16
+ # @option kwargs [Integer] :page default 1
17
+ # @option kwargs [Integer] :rows default 100, max 500
18
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
19
+ # @see https://binance-docs.github.io/apidocs/spot/en/#get-fiat-deposit-withdraw-history-user_data
20
+ def fiat_deposit_withdraw_history(transactionType:, **kwargs)
21
+ Binance::Utils::Validation.require_param('transactionType', transactionType)
22
+
23
+ @session.sign_request(:get, '/sapi/v1/fiat/orders', params: kwargs.merge(
24
+ transactionType: transactionType
25
+ ))
26
+ end
27
+
28
+ # Get Fiat Payments History (USER_DATA)
29
+ #
30
+ # GET /sapi/v1/fiat/payments
31
+ #
32
+ # @param transactionType [String] 0-buy,1-sell
33
+ # @param kwargs [Hash]
34
+ # @option kwargs [Integer] :beginTime If beginTime and endTime are not sent, the recent 30-day data will be returned.
35
+ # @option kwargs [Integer] :endTime If beginTime and endTime are not sent, the recent 30-day data will be returned.
36
+ # @option kwargs [Integer] :page default 1
37
+ # @option kwargs [Integer] :rows default 100, max 500
38
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
39
+ # @see https://binance-docs.github.io/apidocs/spot/en/#get-fiat-payments-history-user_data
40
+ def fiat_payment_history(transactionType:, **kwargs)
41
+ Binance::Utils::Validation.require_param('transactionType', transactionType)
42
+
43
+ @session.sign_request(:get, '/sapi/v1/fiat/payments', params: kwargs.merge(
44
+ transactionType: transactionType
45
+ ))
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,357 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Binance
4
+ class Spot
5
+ # Futures endpoints
6
+ # @see https://binance-docs.github.io/apidocs/spot/en/#futures
7
+ module Futures
8
+ # New Future Account Transfer (USER_DATA)
9
+ #
10
+ # POST /sapi/v1/futures/transfer
11
+ #
12
+ # Execute transfer between spot account and futures account.
13
+ #
14
+ # @param asset [String]
15
+ # @param amount [Float]
16
+ # @param type [Integer] 1: transfer from spot account to USDT-M futures account. <br>
17
+ # 2: transfer from USDT-M futures account to spot account. <br>
18
+ # 3: transfer from spot account to COIN-M futures account. <br>
19
+ # 4: transfer from COIN-M futures account to spot account. <br>
20
+ # @param kwargs [Hash]
21
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
22
+ # @see https://binance-docs.github.io/apidocs/spot/en/#new-future-account-transfer-user_data
23
+ def futures_account_transfer(asset:, amount:, type:, **kwargs)
24
+ Binance::Utils::Validation.require_param('asset', asset)
25
+ Binance::Utils::Validation.require_param('amount', amount)
26
+ Binance::Utils::Validation.require_param('type', type)
27
+
28
+ @session.sign_request(:post, '/sapi/v1/futures/transfer', params: kwargs.merge(
29
+ asset: asset,
30
+ amount: amount,
31
+ type: type
32
+ ))
33
+ end
34
+
35
+ # Get Future Account Transaction History List (USER_DATA)
36
+ #
37
+ # GET /sapi/v1/futures/transfer
38
+ #
39
+ # @param asset [String]
40
+ # @param startTime [Integer]
41
+ # @param kwargs [Hash]
42
+ # @option kwargs [Integer] :endTime
43
+ # @option kwargs [Integer] :current Currently querying page. Start from 1. Default:1
44
+ # @option kwargs [Integer] :size Default:10 Max:100
45
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
46
+ # @see https://binance-docs.github.io/apidocs/spot/en/#get-future-account-transaction-history-list-user_data
47
+ def futures_account_transfer_history(asset:, startTime:, **kwargs)
48
+ Binance::Utils::Validation.require_param('asset', asset)
49
+ Binance::Utils::Validation.require_param('startTime', startTime)
50
+
51
+ @session.sign_request(:get, '/sapi/v1/futures/transfer', params: kwargs.merge(
52
+ asset: asset,
53
+ startTime: startTime
54
+ ))
55
+ end
56
+
57
+ # Borrow For Cross-Collateral (TRADE)
58
+ #
59
+ # POST /sapi/v1/futures/loan/borrow
60
+ #
61
+ # @param coin [String]
62
+ # @param collateralCoin [String]
63
+ # @param kwargs [Hash]
64
+ # @option kwargs [Float] :amount Mandatory when collateralAmount is empty.
65
+ # @option kwargs [Float] :collateralAmount Mandatory when amount is empty.
66
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
67
+ # @see https://binance-docs.github.io/apidocs/spot/en/#borrow-for-cross-collateral-trade
68
+ def cross_collateral_borrow(coin:, collateralCoin:, **kwargs)
69
+ Binance::Utils::Validation.require_param('coin', coin)
70
+ Binance::Utils::Validation.require_param('collateralCoin', collateralCoin)
71
+
72
+ @session.sign_request(:post, '/sapi/v1/futures/loan/borrow', params: kwargs.merge(
73
+ coin: coin,
74
+ collateralCoin: collateralCoin
75
+ ))
76
+ end
77
+
78
+ # Cross-Collateral Borrow History (USER_DATA)
79
+ #
80
+ # GET /sapi/v1/futures/loan/borrow/history
81
+ #
82
+ # @param kwargs [Hash]
83
+ # @option kwargs [String] :coin
84
+ # @option kwargs [Integer] :startTime
85
+ # @option kwargs [Integer] :endTime
86
+ # @option kwargs [Integer] :limit default 500, max 1000
87
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
88
+ # @see https://binance-docs.github.io/apidocs/spot/en/#cross-collateral-borrow-history-user_data
89
+ def cross_collateral_borrow_history(**kwargs)
90
+ @session.sign_request(:get, '/sapi/v1/futures/loan/borrow/history', params: kwargs)
91
+ end
92
+
93
+ # Repay For Cross-Collateral (TRADE)
94
+ #
95
+ # POST /sapi/v1/futures/loan/repay
96
+ #
97
+ # @param coin [String]
98
+ # @param collateralCoin [String]
99
+ # @param amount [Float]
100
+ # @param kwargs [Hash]
101
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
102
+ # @see https://binance-docs.github.io/apidocs/spot/en/#repay-for-cross-collateral-trade
103
+ def cross_collateral_repay(coin:, collateralCoin:, amount:, **kwargs)
104
+ Binance::Utils::Validation.require_param('coin', coin)
105
+ Binance::Utils::Validation.require_param('collateralCoin', collateralCoin)
106
+ Binance::Utils::Validation.require_param('amount', amount)
107
+
108
+ @session.sign_request(:post, '/sapi/v1/futures/loan/repay', params: kwargs.merge(
109
+ coin: coin,
110
+ collateralCoin: collateralCoin,
111
+ amount: amount
112
+ ))
113
+ end
114
+
115
+ # Cross-Collateral Repayment History (USER_DATA)
116
+ #
117
+ # GET /sapi/v1/futures/loan/repay/history
118
+ #
119
+ # @param kwargs [Hash]
120
+ # @option kwargs [String] :coin
121
+ # @option kwargs [Integer] :startTime
122
+ # @option kwargs [Integer] :endTime
123
+ # @option kwargs [Integer] :limit default 500, max 1000
124
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
125
+ # @see https://binance-docs.github.io/apidocs/spot/en/#cross-collateral-repayment-history-user_data
126
+ def cross_collateral_repay_history(**kwargs)
127
+ @session.sign_request(:get, '/sapi/v1/futures/loan/repay/history', params: kwargs)
128
+ end
129
+
130
+ # Cross-Collateral Wallet (USER_DATA)
131
+ #
132
+ # GET /sapi/v2/futures/loan/wallet
133
+ #
134
+ # @param kwargs [Hash]
135
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
136
+ # @see https://binance-docs.github.io/apidocs/spot/en/#cross-collateral-wallet-v2-user_data
137
+ def cross_collateral_wallet(**kwargs)
138
+ @session.sign_request(:get, '/sapi/v2/futures/loan/wallet', params: kwargs)
139
+ end
140
+
141
+ # Cross-Collateral Information (USER_DATA)
142
+ #
143
+ # GET /sapi/v2/futures/loan/configs
144
+ #
145
+ # @param kwargs [Hash]
146
+ # @option kwargs [String] :loanCoin
147
+ # @option kwargs [String] :collateralCoin
148
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
149
+ # @see https://binance-docs.github.io/apidocs/spot/en/#cross-collateral-information-v2-user_data
150
+ def cross_collateral_info(**kwargs)
151
+ @session.sign_request(:get, '/sapi/v2/futures/loan/configs', params: kwargs)
152
+ end
153
+
154
+ # Calculate Rate After Adjust Cross-Collateral LTV (USER_DATA)
155
+ #
156
+ # GET /sapi/v2/futures/loan/calcAdjustLevel
157
+ #
158
+ # @param loanCoin [String]
159
+ # @param collateralCoin [String]
160
+ # @param amount [Float]
161
+ # @param direction [String] "ADDITIONAL", "REDUCED"
162
+ # @param kwargs [Hash]
163
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
164
+ # @see https://binance-docs.github.io/apidocs/spot/en/#calculate-rate-after-adjust-cross-collateral-ltv-v2-user_data
165
+ def calculate_adjust_rate(loanCoin:, collateralCoin:, amount:, direction:, **kwargs)
166
+ Binance::Utils::Validation.require_param('loanCoin', loanCoin)
167
+ Binance::Utils::Validation.require_param('collateralCoin', collateralCoin)
168
+ Binance::Utils::Validation.require_param('amount', amount)
169
+ Binance::Utils::Validation.require_param('direction', direction)
170
+
171
+ @session.sign_request(:get, '/sapi/v2/futures/loan/calcAdjustLevel', params: kwargs.merge(
172
+ loanCoin: loanCoin,
173
+ collateralCoin: collateralCoin,
174
+ amount: amount,
175
+ direction: direction
176
+ ))
177
+ end
178
+
179
+ # Get Max Amount for Adjust Cross-Collateral LTV (USER_DATA)
180
+ #
181
+ # GET /sapi/v2/futures/loan/calcMaxAdjustAmount
182
+ #
183
+ # @param loanCoin [String]
184
+ # @param collateralCoin [String]
185
+ # @param kwargs [Hash]
186
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
187
+ # @see https://binance-docs.github.io/apidocs/spot/en/#get-max-amount-for-adjust-cross-collateral-ltv-v2-user_data
188
+ def calculate_adjust_max_amount(loanCoin:, collateralCoin:, **kwargs)
189
+ Binance::Utils::Validation.require_param('loanCoin', loanCoin)
190
+ Binance::Utils::Validation.require_param('collateralCoin', collateralCoin)
191
+
192
+ @session.sign_request(:get, '/sapi/v2/futures/loan/calcMaxAdjustAmount', params: kwargs.merge(
193
+ loanCoin: loanCoin,
194
+ collateralCoin: collateralCoin
195
+ ))
196
+ end
197
+
198
+ # Adjust Cross-Collateral LTV (TRADE)
199
+ #
200
+ # POST /sapi/v2/futures/loan/adjustCollateral
201
+ #
202
+ # @param loanCoin [String]
203
+ # @param collateralCoin [String]
204
+ # @param amount [Float]
205
+ # @param direction [String] "ADDITIONAL", "REDUCED"
206
+ # @param kwargs [Hash]
207
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
208
+ # @see https://binance-docs.github.io/apidocs/spot/en/#adjust-cross-collateral-ltv-v2-trade
209
+ def adjust_cross_collateral(loanCoin:, collateralCoin:, amount:, direction:, **kwargs)
210
+ Binance::Utils::Validation.require_param('loanCoin', loanCoin)
211
+ Binance::Utils::Validation.require_param('collateralCoin', collateralCoin)
212
+ Binance::Utils::Validation.require_param('amount', amount)
213
+ Binance::Utils::Validation.require_param('direction', direction)
214
+
215
+ @session.sign_request(:post, '/sapi/v2/futures/loan/adjustCollateral', params: kwargs.merge(
216
+ loanCoin: loanCoin,
217
+ collateralCoin: collateralCoin,
218
+ amount: amount,
219
+ direction: direction
220
+ ))
221
+ end
222
+
223
+ # Adjust Cross-Collateral LTV History (USER_DATA)
224
+ #
225
+ # GET /sapi/v1/futures/loan/adjustCollateral/history
226
+ #
227
+ # All data will be returned if loanCoin or collateralCoin is not sent
228
+ #
229
+ # @param kwargs [Hash]
230
+ # @option kwargs [String] :loanCoin
231
+ # @option kwargs [String] :collateralCoin
232
+ # @option kwargs [Integer] :startTime
233
+ # @option kwargs [Integer] :endTime
234
+ # @option kwargs [Integer] :limit default 500, max 1000
235
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
236
+ # @see https://binance-docs.github.io/apidocs/spot/en/#adjust-cross-collateral-ltv-history-user_data
237
+ def adjust_cross_collateral_history(**kwargs)
238
+ @session.sign_request(:get, '/sapi/v1/futures/loan/adjustCollateral/history', params: kwargs)
239
+ end
240
+
241
+ # Cross-Collateral Liquidation History (USER_DATA)
242
+ #
243
+ # GET /sapi/v1/futures/loan/liquidationHistory
244
+ #
245
+ # All data will be returned if loanCoin or collateralCoin is not sent
246
+ #
247
+ # @param kwargs [Hash]
248
+ # @option kwargs [String] :loanCoin
249
+ # @option kwargs [String] :collateralCoin
250
+ # @option kwargs [Integer] :startTime
251
+ # @option kwargs [Integer] :endTime
252
+ # @option kwargs [Integer] :limit default 500, max 1000
253
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
254
+ # @see https://binance-docs.github.io/apidocs/spot/en/#cross-collateral-liquidation-history-user_data
255
+ def cross_collateral_liquidation_history(**kwargs)
256
+ @session.sign_request(:get, '/sapi/v1/futures/loan/liquidationHistory', params: kwargs)
257
+ end
258
+
259
+ # Check Collateral Repay Limit (USER_DATA)
260
+ #
261
+ # GET /sapi/v1/futures/loan/collateralRepayLimit
262
+ #
263
+ # Check the maximum and minimum limit when repay with collateral.
264
+ #
265
+ # @param coin [String]
266
+ # @param collateralCoin [String]
267
+ # @param kwargs [Hash]
268
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
269
+ # @see https://binance-docs.github.io/apidocs/spot/en/#check-collateral-repay-limit-user_data
270
+ def collateral_repay_limit(coin:, collateralCoin:, **kwargs)
271
+ Binance::Utils::Validation.require_param('coin', coin)
272
+ Binance::Utils::Validation.require_param('collateralCoin', collateralCoin)
273
+
274
+ @session.sign_request(:get, '/sapi/v1/futures/loan/collateralRepayLimit', params: kwargs.merge(
275
+ coin: coin,
276
+ collateralCoin: collateralCoin
277
+ ))
278
+ end
279
+
280
+ # Get Collateral Repay Quote (USER_DATA)
281
+ #
282
+ # GET /sapi/v1/futures/loan/collateralRepay
283
+ #
284
+ # Get quote before repay with collateral is mandatory, the quote will be valid within 25 seconds.
285
+ #
286
+ # @param coin [String]
287
+ # @param collateralCoin [String]
288
+ # @param amount [Float]
289
+ # @param kwargs [Hash]
290
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
291
+ # @see https://binance-docs.github.io/apidocs/spot/en/#get-collateral-repay-quote-user_data
292
+ def collateral_repay_quote(coin:, collateralCoin:, amount:, **kwargs)
293
+ Binance::Utils::Validation.require_param('coin', coin)
294
+ Binance::Utils::Validation.require_param('collateralCoin', collateralCoin)
295
+ Binance::Utils::Validation.require_param('amount', amount)
296
+
297
+ @session.sign_request(:get, '/sapi/v1/futures/loan/collateralRepay', params: kwargs.merge(
298
+ coin: coin,
299
+ collateralCoin: collateralCoin,
300
+ amount: amount
301
+ ))
302
+ end
303
+
304
+ # Repay with Collateral (USER_DATA)
305
+ #
306
+ # POST /sapi/v1/futures/loan/collateralRepay
307
+ #
308
+ # Repay with collateral. Get quote before repay with collateral is mandatory, the quote will be valid within 25 seconds.
309
+ #
310
+ # @param quoteId [String]
311
+ # @param kwargs [Hash]
312
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
313
+ # @see https://binance-docs.github.io/apidocs/spot/en/#repay-with-collateral-user_data
314
+ def repay_with_collateral(quoteId:, **kwargs)
315
+ Binance::Utils::Validation.require_param('quoteId', quoteId)
316
+
317
+ @session.sign_request(:post, '/sapi/v1/futures/loan/collateralRepay', params: kwargs.merge(
318
+ quoteId: quoteId
319
+ ))
320
+ end
321
+
322
+ # Collateral Repayment Result (USER_DATA)
323
+ #
324
+ # GET /sapi/v1/futures/loan/collateralRepayResult
325
+ #
326
+ # Check collateral repayment result.
327
+ #
328
+ # @param quoteId [String]
329
+ # @param kwargs [Hash]
330
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
331
+ # @see https://binance-docs.github.io/apidocs/spot/en/#collateral-repayment-result-user_data
332
+ def repayment_result(quoteId:, **kwargs)
333
+ Binance::Utils::Validation.require_param('quoteId', quoteId)
334
+
335
+ @session.sign_request(:get, '/sapi/v1/futures/loan/collateralRepayResult', params: kwargs.merge(
336
+ quoteId: quoteId
337
+ ))
338
+ end
339
+
340
+ # Cross-Collateral Interest History (USER_DATA)
341
+ #
342
+ # GET /sapi/v1/futures/loan/interestHistory
343
+ #
344
+ # @param kwargs [Hash]
345
+ # @option kwargs [String] :collateralCoin
346
+ # @option kwargs [Integer] :startTime
347
+ # @option kwargs [Integer] :endTime
348
+ # @option kwargs [Integer] :current Currently querying page. Start from 1. Default:1
349
+ # @option kwargs [Integer] :limit default 500, max 1000
350
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
351
+ # @see https://binance-docs.github.io/apidocs/spot/en/#cross-collateral-interest-history-user_data
352
+ def cross_collateral_interest_history(**kwargs)
353
+ @session.sign_request(:get, '/sapi/v1/futures/loan/interestHistory', params: kwargs)
354
+ end
355
+ end
356
+ end
357
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Binance
4
+ class Spot
5
+ # all loan endpoints
6
+ # @see https://binance-docs.github.io/apidocs/spot/en/#crypto-loans-endpoints
7
+ module Loan
8
+ # Get Crypto Loans Income History (USER_DATA)
9
+ #
10
+ # GET /sapi/v1/loan/income
11
+ #
12
+ # @param asset [String]
13
+ # @option kwargs [String] :type
14
+ # @option kwargs [Integer] :startTime
15
+ # @option kwargs [Integer] :endTime
16
+ # @option kwargs [Integer] :limit default 20, max 100
17
+ # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
18
+ # @see https://binance-docs.github.io/apidocs/spot/en/#get-crypto-loans-income-history-user_data
19
+ def get_loan_history(asset:, **kwargs)
20
+ Binance::Utils::Validation.require_param('asset', asset)
21
+
22
+ @session.sign_request(:get, '/sapi/v1/loan/income', params: kwargs.merge(asset: asset))
23
+ end
24
+ end
25
+ end
26
+ end