Class: Bybit::RestApi::CryptoLoanService

Inherits:
BaseService show all
Defined in:
lib/bybit/rest_api/crypto_loan_service.rb

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Constructor Details

This class inherits a constructor from Bybit::RestApi::BaseService

Instance Method Details

#adjust_ltv(currency:, amount:, direction:, **kwargs) ⇒ Hash

Adjust collateral by adding or removing amount for crypto loan.

POST /v5/crypto-loan-common/adjust-ltv

Parameters:

  • currency (String)

    Collateral currency

  • amount (String)

    Amount to adjust

  • direction (Integer)

    Adjustment direction: add or remove collateral

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



14
15
16
17
18
# File 'lib/bybit/rest_api/crypto_loan_service.rb', line 14

def adjust_ltv(currency:, amount:, direction:, **kwargs)
  params = kwargs.merge(currency: currency, amount: amount, direction: direction)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :post, path: '/v5/crypto-loan-common/adjust-ltv', body: params)
end

#borrow_fixed(order_currency:, order_amount:, annual_rate:, term:, collateral_list:, **kwargs) ⇒ Hash

Create Fixed-Term Borrow Order

POST /v5/crypto-loan-fixed/borrow

Parameters:

  • order_currency (String)

    Order currency

  • order_amount (String)

    Order amount

  • annual_rate (String)

    Annual interest rate

  • term (String)

    Loan term

  • collateral_list (Array)

    List of collateral

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :auto_repay (String)

    Auto repay flag

  • :repay_type (String)

    Repay type

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



219
220
221
222
223
# File 'lib/bybit/rest_api/crypto_loan_service.rb', line 219

def borrow_fixed(order_currency:, order_amount:, annual_rate:, term:, collateral_list:, **kwargs)
  params = kwargs.merge(order_currency: order_currency, order_amount: order_amount, annual_rate: annual_rate, term: term, collateral_list: collateral_list)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :post, path: '/v5/crypto-loan-fixed/borrow', body: params)
end

#borrow_flexible(loan_currency:, loan_amount:, collateral_list:, **kwargs) ⇒ Hash

Create Flexible Borrow Order

POST /v5/crypto-loan-flexible/borrow

Parameters:

  • loan_currency (String)

    Loan currency

  • loan_amount (String)

    Loan amount

  • collateral_list (Array)

    Collateral coin list

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



341
342
343
344
345
# File 'lib/bybit/rest_api/crypto_loan_service.rb', line 341

def borrow_flexible(loan_currency:, loan_amount:, collateral_list:, **kwargs)
  params = kwargs.merge(loan_currency: loan_currency, loan_amount: loan_amount, collateral_list: collateral_list)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :post, path: '/v5/crypto-loan-flexible/borrow', body: params)
end

#cancel_fixed_borrow_order(order_id:, **kwargs) ⇒ Hash

Cancel Borrow Order

POST /v5/crypto-loan-fixed/borrow-order-cancel

Parameters:

  • order_id (String)

    Order ID

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



231
232
233
234
235
# File 'lib/bybit/rest_api/crypto_loan_service.rb', line 231

def cancel_fixed_borrow_order(order_id:, **kwargs)
  params = kwargs.merge(order_id: order_id)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :post, path: '/v5/crypto-loan-fixed/borrow-order-cancel', body: params)
end

#cancel_fixed_supply_order(order_id:, **kwargs) ⇒ Hash

Cancel Supply Order

POST /v5/crypto-loan-fixed/supply-order-cancel

Parameters:

  • order_id (String)

    Order ID

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :refunded_account (Integer)

    Refunded account

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



285
286
287
288
289
# File 'lib/bybit/rest_api/crypto_loan_service.rb', line 285

def cancel_fixed_supply_order(order_id:, **kwargs)
  params = kwargs.merge(order_id: order_id)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :post, path: '/v5/crypto-loan-fixed/supply-order-cancel', body: params)
end

#get_adjustment_history(**kwargs) ⇒ Hash

Get collateral adjustment history for crypto loan positions.

GET /v5/crypto-loan-common/adjustment-history

Parameters:

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :adjust_id (Integer)

    Adjustment record ID

  • :collateral_currency (String)

    Collateral currency filter

  • :limit (Integer)

    Number of records per page

  • :cursor (Integer)

    Pagination cursor

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



29
30
31
32
33
# File 'lib/bybit/rest_api/crypto_loan_service.rb', line 29

def get_adjustment_history(**kwargs)
  params = kwargs.dup
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :get, path: '/v5/crypto-loan-common/adjustment-history', params: params)
end

#get_collateral_data(**kwargs) ⇒ Hash

Get collateral currency data for crypto loan.

GET /v5/crypto-loan-common/collateral-data

Parameters:

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :currency (String)

    Collateral currency filter

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



41
42
43
44
45
# File 'lib/bybit/rest_api/crypto_loan_service.rb', line 41

def get_collateral_data(**kwargs)
  params = kwargs.dup
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.public_request(path: '/v5/crypto-loan-common/collateral-data', params: params)
end

#get_fixed_borrow_contract_info(**kwargs) ⇒ Hash

Get Borrow Contract Info

GET /v5/crypto-loan-fixed/borrow-contract-info

Parameters:

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :order_id (String)

    Order ID

  • :loan_id (String)

    Loan ID

  • :order_currency (String)

    Order currency

  • :term (String)

    Loan term

  • :limit (Integer)

    Limit for data size per page

  • :cursor (Integer)

    Cursor used for pagination

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



103
104
105
106
107
# File 'lib/bybit/rest_api/crypto_loan_service.rb', line 103

def get_fixed_borrow_contract_info(**kwargs)
  params = kwargs.dup
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :get, path: '/v5/crypto-loan-fixed/borrow-contract-info', params: params)
end

#get_fixed_borrow_order_info(**kwargs) ⇒ Hash

Get Borrow Order Info

GET /v5/crypto-loan-fixed/borrow-order-info

Parameters:

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :order_id (String)

    Order ID

  • :order_currency (String)

    Order currency

  • :state (String)

    Order state

  • :term (String)

    Loan term

  • :limit (Integer)

    Limit for data size per page

  • :cursor (Integer)

    Cursor used for pagination

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



120
121
122
123
124
# File 'lib/bybit/rest_api/crypto_loan_service.rb', line 120

def get_fixed_borrow_order_info(**kwargs)
  params = kwargs.dup
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :get, path: '/v5/crypto-loan-fixed/borrow-order-info', params: params)
end

#get_fixed_borrow_order_quote(**kwargs) ⇒ Hash

Get Borrow Market Quotes

GET /v5/crypto-loan-fixed/borrow-order-quote

Parameters:

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :order_currency (String)

    Order currency

  • :term (String)

    Loan term

  • :order_by (String)

    Order by field

  • :sort (Integer)

    Sort direction

  • :limit (Integer)

    Limit for data size per page

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



136
137
138
139
140
# File 'lib/bybit/rest_api/crypto_loan_service.rb', line 136

def get_fixed_borrow_order_quote(**kwargs)
  params = kwargs.dup
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.public_request(path: '/v5/crypto-loan-fixed/borrow-order-quote', params: params)
end

#get_fixed_renew_info(**kwargs) ⇒ Hash

Get Renewal Information

GET /v5/crypto-loan-fixed/renew-info

Parameters:

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :order_id (String)

    Order ID

  • :order_currency (String)

    Order currency

  • :limit (Integer)

    Limit for data size per page

  • :cursor (Integer)

    Cursor used for pagination

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



151
152
153
154
155
# File 'lib/bybit/rest_api/crypto_loan_service.rb', line 151

def get_fixed_renew_info(**kwargs)
  params = kwargs.dup
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :get, path: '/v5/crypto-loan-fixed/renew-info', params: params)
end

#get_fixed_supply_contract_info(**kwargs) ⇒ Hash

Get Supply Contract Info

GET /v5/crypto-loan-fixed/supply-contract-info

Parameters:

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :order_id (String)

    Order ID

  • :supply_id (String)

    Supply ID

  • :supply_currency (String)

    Supply currency

  • :term (String)

    Loan term

  • :limit (Integer)

    Limit for data size per page

  • :cursor (Integer)

    Cursor used for pagination

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



168
169
170
171
172
# File 'lib/bybit/rest_api/crypto_loan_service.rb', line 168

def get_fixed_supply_contract_info(**kwargs)
  params = kwargs.dup
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :get, path: '/v5/crypto-loan-fixed/supply-contract-info', params: params)
end

#get_fixed_supply_order_info(**kwargs) ⇒ Hash

Get Supply Order Info

GET /v5/crypto-loan-fixed/supply-order-info

Parameters:

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :order_id (String)

    Order ID

  • :order_currency (String)

    Order currency

  • :state (String)

    Order state

  • :term (String)

    Loan term

  • :limit (Integer)

    Limit for data size per page

  • :cursor (Integer)

    Cursor used for pagination

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



185
186
187
188
189
# File 'lib/bybit/rest_api/crypto_loan_service.rb', line 185

def get_fixed_supply_order_info(**kwargs)
  params = kwargs.dup
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :get, path: '/v5/crypto-loan-fixed/supply-order-info', params: params)
end

#get_fixed_supply_order_quote(**kwargs) ⇒ Hash

Get Supply Market Quotes

GET /v5/crypto-loan-fixed/supply-order-quote

Parameters:

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :order_currency (String)

    Order currency

  • :term (String)

    Loan term

  • :order_by (String)

    Order by field

  • :sort (Integer)

    Sort direction

  • :limit (Integer)

    Limit for data size per page

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



201
202
203
204
205
# File 'lib/bybit/rest_api/crypto_loan_service.rb', line 201

def get_fixed_supply_order_quote(**kwargs)
  params = kwargs.dup
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.public_request(path: '/v5/crypto-loan-fixed/supply-order-quote', params: params)
end

#get_flexible_borrow_history(**kwargs) ⇒ Hash

Get Flexible Borrow History

GET /v5/crypto-loan-flexible/borrow-history

Parameters:

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :order_id (String)

    Order ID of the borrow order

  • :loan_currency (String)

    Loan currency

  • :limit (Integer)

    Limit for data size per page

  • :cursor (Integer)

    Cursor for pagination

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



300
301
302
303
304
# File 'lib/bybit/rest_api/crypto_loan_service.rb', line 300

def get_flexible_borrow_history(**kwargs)
  params = kwargs.dup
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :get, path: '/v5/crypto-loan-flexible/borrow-history', params: params)
end

#get_flexible_ongoing_coin(**kwargs) ⇒ Hash

Get Ongoing Flexible Borrow Info

GET /v5/crypto-loan-flexible/ongoing-coin

Parameters:

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :loan_currency (String)

    Loan currency

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



312
313
314
315
316
# File 'lib/bybit/rest_api/crypto_loan_service.rb', line 312

def get_flexible_ongoing_coin(**kwargs)
  params = kwargs.dup
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :get, path: '/v5/crypto-loan-flexible/ongoing-coin', params: params)
end

#get_flexible_repayment_history(**kwargs) ⇒ Hash

Get Flexible Repayment History

GET /v5/crypto-loan-flexible/repayment-history

Parameters:

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :repay_id (String)

    Repayment ID

  • :loan_currency (String)

    Loan currency

  • :limit (Integer)

    Limit for data size per page

  • :cursor (Integer)

    Cursor for pagination

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



327
328
329
330
331
# File 'lib/bybit/rest_api/crypto_loan_service.rb', line 327

def get_flexible_repayment_history(**kwargs)
  params = kwargs.dup
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :get, path: '/v5/crypto-loan-flexible/repayment-history', params: params)
end

#get_loanable_data(**kwargs) ⇒ Hash

Get loanable currency data for crypto loan.

GET /v5/crypto-loan-common/loanable-data

Parameters:

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :currency (String)

    Loanable currency filter

  • :vip_level (String)

    VIP level filter

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



54
55
56
57
58
# File 'lib/bybit/rest_api/crypto_loan_service.rb', line 54

def get_loanable_data(**kwargs)
  params = kwargs.dup
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :get, path: '/v5/crypto-loan-common/loanable-data', params: params)
end

#get_max_collateral_amount(currency:, **kwargs) ⇒ Hash

Get maximum collateral redeem amount for a currency.

GET /v5/crypto-loan-common/max-collateral-amount

Parameters:

  • currency (String)

    Collateral currency

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



66
67
68
69
70
# File 'lib/bybit/rest_api/crypto_loan_service.rb', line 66

def get_max_collateral_amount(currency:, **kwargs)
  params = kwargs.merge(currency: currency)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :get, path: '/v5/crypto-loan-common/max-collateral-amount', params: params)
end

#get_max_loan(currency:, collateral_list:, **kwargs) ⇒ Hash

Calculate the maximum borrowable amount given collateral list.

POST /v5/crypto-loan-common/max-loan

Parameters:

  • currency (String)

    Loan currency

  • collateral_list (Array)

    List of collateral currencies and amounts

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



79
80
81
82
83
# File 'lib/bybit/rest_api/crypto_loan_service.rb', line 79

def get_max_loan(currency:, collateral_list:, **kwargs)
  params = kwargs.merge(currency: currency, collateral_list: collateral_list)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :post, path: '/v5/crypto-loan-common/max-loan', body: params)
end

#get_positionObject

Get current crypto loan position.

GET /v5/crypto-loan-common/position



88
89
90
# File 'lib/bybit/rest_api/crypto_loan_service.rb', line 88

def get_position
  @session.sign_request(method: :get, path: '/v5/crypto-loan-common/position')
end

#renew_fixed(loan_id:, collateral_list:, **kwargs) ⇒ Hash

Renew Loan

POST /v5/crypto-loan-fixed/renew

Parameters:

  • loan_id (String)

    Loan ID

  • collateral_list (Array)

    List of collateral

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



257
258
259
260
261
# File 'lib/bybit/rest_api/crypto_loan_service.rb', line 257

def renew_fixed(loan_id:, collateral_list:, **kwargs)
  params = kwargs.merge(loan_id: loan_id, collateral_list: collateral_list)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :post, path: '/v5/crypto-loan-fixed/renew', body: params)
end

#repay_fixed_fully(loan_id:, loan_currency:, **kwargs) ⇒ Hash

Fully Repay Loan

POST /v5/crypto-loan-fixed/fully-repay

Parameters:

  • loan_id (String)

    Loan ID

  • loan_currency (String)

    Loan currency

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



244
245
246
247
248
# File 'lib/bybit/rest_api/crypto_loan_service.rb', line 244

def repay_fixed_fully(loan_id:, loan_currency:, **kwargs)
  params = kwargs.merge(loan_id: loan_id, loan_currency: loan_currency)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :post, path: '/v5/crypto-loan-fixed/fully-repay', body: params)
end

#repay_fixed_with_collateral(loan_id:, loan_currency:, collateral_coin:, amount:, **kwargs) ⇒ Hash

Repay with Collateral

POST /v5/crypto-loan-fixed/repay-collateral

Parameters:

  • loan_id (Integer)

    Loan ID

  • loan_currency (String)

    Loan currency

  • collateral_coin (String)

    Collateral coin

  • amount (String)

    Repay amount

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



272
273
274
275
276
# File 'lib/bybit/rest_api/crypto_loan_service.rb', line 272

def repay_fixed_with_collateral(loan_id:, loan_currency:, collateral_coin:, amount:, **kwargs)
  params = kwargs.merge(loan_id: loan_id, loan_currency: loan_currency, collateral_coin: collateral_coin, amount: amount)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :post, path: '/v5/crypto-loan-fixed/repay-collateral', body: params)
end

#repay_flexible(loan_currency:, amount:, **kwargs) ⇒ Hash

Repay Flexible Loan

POST /v5/crypto-loan-flexible/repay

Parameters:

  • loan_currency (String)

    Loan currency

  • amount (String)

    Repayment amount

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



354
355
356
357
358
# File 'lib/bybit/rest_api/crypto_loan_service.rb', line 354

def repay_flexible(loan_currency:, amount:, **kwargs)
  params = kwargs.merge(loan_currency: loan_currency, amount: amount)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :post, path: '/v5/crypto-loan-flexible/repay', body: params)
end

#repay_flexible_with_collateral(loan_currency:, collateral_coin:, amount:, **kwargs) ⇒ Hash

Repay with Collateral

POST /v5/crypto-loan-flexible/repay-collateral

Parameters:

  • loan_currency (String)

    Loan currency

  • collateral_coin (String)

    Collateral coin

  • amount (String)

    Repayment amount

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



368
369
370
371
372
# File 'lib/bybit/rest_api/crypto_loan_service.rb', line 368

def repay_flexible_with_collateral(loan_currency:, collateral_coin:, amount:, **kwargs)
  params = kwargs.merge(loan_currency: loan_currency, collateral_coin: collateral_coin, amount: amount)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.sign_request(method: :post, path: '/v5/crypto-loan-flexible/repay-collateral', body: params)
end