ccxt 4.2.79 → 4.2.81

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.
Files changed (43) hide show
  1. package/README.md +3 -3
  2. package/build.sh +1 -1
  3. package/dist/ccxt.browser.js +752 -73
  4. package/dist/ccxt.browser.min.js +3 -3
  5. package/dist/cjs/ccxt.js +1 -1
  6. package/dist/cjs/src/base/Exchange.js +35 -3
  7. package/dist/cjs/src/binance.js +91 -1
  8. package/dist/cjs/src/bybit.js +178 -1
  9. package/dist/cjs/src/deribit.js +155 -0
  10. package/dist/cjs/src/gate.js +200 -5
  11. package/dist/cjs/src/hyperliquid.js +54 -10
  12. package/dist/cjs/src/okx.js +19 -42
  13. package/dist/cjs/src/pro/binance.js +5 -5
  14. package/dist/cjs/src/pro/bitopro.js +2 -1
  15. package/dist/cjs/src/pro/gemini.js +3 -2
  16. package/dist/cjs/src/pro/phemex.js +7 -2
  17. package/dist/cjs/src/upbit.js +2 -0
  18. package/js/ccxt.d.ts +3 -3
  19. package/js/ccxt.js +1 -1
  20. package/js/src/abstract/upbit.d.ts +1 -0
  21. package/js/src/base/Exchange.d.ts +14 -5
  22. package/js/src/base/Exchange.js +35 -3
  23. package/js/src/base/types.d.ts +21 -0
  24. package/js/src/binance.d.ts +23 -3
  25. package/js/src/binance.js +91 -1
  26. package/js/src/bybit.d.ts +22 -1
  27. package/js/src/bybit.js +178 -1
  28. package/js/src/deribit.d.ts +22 -1
  29. package/js/src/deribit.js +155 -0
  30. package/js/src/gate.d.ts +22 -1
  31. package/js/src/gate.js +200 -5
  32. package/js/src/hyperliquid.d.ts +1 -0
  33. package/js/src/hyperliquid.js +54 -10
  34. package/js/src/okx.d.ts +0 -1
  35. package/js/src/okx.js +19 -42
  36. package/js/src/pro/binance.js +5 -5
  37. package/js/src/pro/bitopro.js +2 -1
  38. package/js/src/pro/gemini.d.ts +2 -2
  39. package/js/src/pro/gemini.js +3 -2
  40. package/js/src/pro/phemex.js +7 -2
  41. package/js/src/upbit.js +2 -0
  42. package/package.json +1 -1
  43. package/skip-tests.json +7 -2
package/js/src/deribit.js CHANGED
@@ -73,6 +73,8 @@ export default class deribit extends Exchange {
73
73
  'fetchMyTrades': true,
74
74
  'fetchOHLCV': true,
75
75
  'fetchOpenOrders': true,
76
+ 'fetchOption': true,
77
+ 'fetchOptionChain': true,
76
78
  'fetchOrder': true,
77
79
  'fetchOrderBook': true,
78
80
  'fetchOrders': false,
@@ -3459,6 +3461,159 @@ export default class deribit extends Exchange {
3459
3461
  'info': greeks,
3460
3462
  };
3461
3463
  }
3464
+ async fetchOption(symbol, params = {}) {
3465
+ /**
3466
+ * @method
3467
+ * @name deribit#fetchOption
3468
+ * @description fetches option data that is commonly found in an option chain
3469
+ * @see https://docs.deribit.com/#public-get_book_summary_by_instrument
3470
+ * @param {string} symbol unified market symbol
3471
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3472
+ * @returns {object} an [option chain structure]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
3473
+ */
3474
+ await this.loadMarkets();
3475
+ const market = this.market(symbol);
3476
+ const request = {
3477
+ 'instrument_name': market['id'],
3478
+ };
3479
+ const response = await this.publicGetGetBookSummaryByInstrument(this.extend(request, params));
3480
+ //
3481
+ // {
3482
+ // "jsonrpc": "2.0",
3483
+ // "result": [
3484
+ // {
3485
+ // "mid_price": 0.04025,
3486
+ // "volume_usd": 11045.12,
3487
+ // "quote_currency": "BTC",
3488
+ // "estimated_delivery_price": 65444.72,
3489
+ // "creation_timestamp": 1711100949273,
3490
+ // "base_currency": "BTC",
3491
+ // "underlying_index": "BTC-27DEC24",
3492
+ // "underlying_price": 73742.14,
3493
+ // "volume": 4.0,
3494
+ // "interest_rate": 0.0,
3495
+ // "price_change": -6.9767,
3496
+ // "open_interest": 274.2,
3497
+ // "ask_price": 0.042,
3498
+ // "bid_price": 0.0385,
3499
+ // "instrument_name": "BTC-27DEC24-240000-C",
3500
+ // "mark_price": 0.04007735,
3501
+ // "last": 0.04,
3502
+ // "low": 0.04,
3503
+ // "high": 0.043
3504
+ // }
3505
+ // ],
3506
+ // "usIn": 1711100949273223,
3507
+ // "usOut": 1711100949273580,
3508
+ // "usDiff": 357,
3509
+ // "testnet": false
3510
+ // }
3511
+ //
3512
+ const result = this.safeList(response, 'result', []);
3513
+ const chain = this.safeDict(result, 0, {});
3514
+ return this.parseOption(chain, undefined, market);
3515
+ }
3516
+ async fetchOptionChain(code, params = {}) {
3517
+ /**
3518
+ * @method
3519
+ * @name deribit#fetchOptionChain
3520
+ * @description fetches data for an underlying asset that is commonly found in an option chain
3521
+ * @see https://docs.deribit.com/#public-get_book_summary_by_currency
3522
+ * @param {string} currency base currency to fetch an option chain for
3523
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3524
+ * @returns {object} a list of [option chain structures]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
3525
+ */
3526
+ await this.loadMarkets();
3527
+ const currency = this.currency(code);
3528
+ const request = {
3529
+ 'currency': currency['id'],
3530
+ 'kind': 'option',
3531
+ };
3532
+ const response = await this.publicGetGetBookSummaryByCurrency(this.extend(request, params));
3533
+ //
3534
+ // {
3535
+ // "jsonrpc": "2.0",
3536
+ // "result": [
3537
+ // {
3538
+ // "mid_price": 0.4075,
3539
+ // "volume_usd": 2836.83,
3540
+ // "quote_currency": "BTC",
3541
+ // "estimated_delivery_price": 65479.26,
3542
+ // "creation_timestamp": 1711101594477,
3543
+ // "base_currency": "BTC",
3544
+ // "underlying_index": "BTC-28JUN24",
3545
+ // "underlying_price": 68827.27,
3546
+ // "volume": 0.1,
3547
+ // "interest_rate": 0.0,
3548
+ // "price_change": 0.0,
3549
+ // "open_interest": 364.1,
3550
+ // "ask_price": 0.411,
3551
+ // "bid_price": 0.404,
3552
+ // "instrument_name": "BTC-28JUN24-42000-C",
3553
+ // "mark_price": 0.40752052,
3554
+ // "last": 0.423,
3555
+ // "low": 0.423,
3556
+ // "high": 0.423
3557
+ // }
3558
+ // ],
3559
+ // "usIn": 1711101594456388,
3560
+ // "usOut": 1711101594484065,
3561
+ // "usDiff": 27677,
3562
+ // "testnet": false
3563
+ // }
3564
+ //
3565
+ const result = this.safeList(response, 'result', []);
3566
+ return this.parseOptionChain(result, 'base_currency', 'instrument_name');
3567
+ }
3568
+ parseOption(chain, currency = undefined, market = undefined) {
3569
+ //
3570
+ // {
3571
+ // "mid_price": 0.04025,
3572
+ // "volume_usd": 11045.12,
3573
+ // "quote_currency": "BTC",
3574
+ // "estimated_delivery_price": 65444.72,
3575
+ // "creation_timestamp": 1711100949273,
3576
+ // "base_currency": "BTC",
3577
+ // "underlying_index": "BTC-27DEC24",
3578
+ // "underlying_price": 73742.14,
3579
+ // "volume": 4.0,
3580
+ // "interest_rate": 0.0,
3581
+ // "price_change": -6.9767,
3582
+ // "open_interest": 274.2,
3583
+ // "ask_price": 0.042,
3584
+ // "bid_price": 0.0385,
3585
+ // "instrument_name": "BTC-27DEC24-240000-C",
3586
+ // "mark_price": 0.04007735,
3587
+ // "last": 0.04,
3588
+ // "low": 0.04,
3589
+ // "high": 0.043
3590
+ // }
3591
+ //
3592
+ const marketId = this.safeString(chain, 'instrument_name');
3593
+ market = this.safeMarket(marketId, market);
3594
+ const currencyId = this.safeString(chain, 'base_currency');
3595
+ const code = this.safeCurrencyCode(currencyId, currency);
3596
+ const timestamp = this.safeInteger(chain, 'timestamp');
3597
+ return {
3598
+ 'info': chain,
3599
+ 'currency': code['code'],
3600
+ 'symbol': market['symbol'],
3601
+ 'timestamp': timestamp,
3602
+ 'datetime': this.iso8601(timestamp),
3603
+ 'impliedVolatility': undefined,
3604
+ 'openInterest': this.safeNumber(chain, 'open_interest'),
3605
+ 'bidPrice': this.safeNumber(chain, 'bid_price'),
3606
+ 'askPrice': this.safeNumber(chain, 'ask_price'),
3607
+ 'midPrice': this.safeNumber(chain, 'mid_price'),
3608
+ 'markPrice': this.safeNumber(chain, 'mark_price'),
3609
+ 'lastPrice': this.safeNumber(chain, 'last'),
3610
+ 'underlyingPrice': this.safeNumber(chain, 'underlying_price'),
3611
+ 'change': undefined,
3612
+ 'percentage': this.safeNumber(chain, 'price_change'),
3613
+ 'baseVolume': this.safeNumber(chain, 'volume'),
3614
+ 'quoteVolume': this.safeNumber(chain, 'volume_usd'),
3615
+ };
3616
+ }
3462
3617
  nonce() {
3463
3618
  return this.milliseconds();
3464
3619
  }
package/js/src/gate.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/gate.js';
2
- import type { Int, OrderSide, OrderType, OHLCV, Trade, FundingRateHistory, OpenInterest, Order, Balances, OrderRequest, FundingHistory, Str, Transaction, Ticker, OrderBook, Tickers, Greeks, Strings, Market, Currency, MarketInterface, TransferEntry, Leverage, Leverages, Num } from './base/types.js';
2
+ import type { Int, OrderSide, OrderType, OHLCV, Trade, FundingRateHistory, OpenInterest, Order, Balances, OrderRequest, FundingHistory, Str, Transaction, Ticker, OrderBook, Tickers, Greeks, Strings, Market, Currency, MarketInterface, TransferEntry, Leverage, Leverages, Num, OptionChain, Option } from './base/types.js';
3
3
  /**
4
4
  * @class gate
5
5
  * @augments Exchange
@@ -364,5 +364,26 @@ export default class gate extends Exchange {
364
364
  fetchLeverage(symbol: string, params?: {}): Promise<Leverage>;
365
365
  fetchLeverages(symbols?: string[], params?: {}): Promise<Leverages>;
366
366
  parseLeverage(leverage: any, market?: any): Leverage;
367
+ fetchOption(symbol: string, params?: {}): Promise<Option>;
368
+ fetchOptionChain(code: string, params?: {}): Promise<OptionChain>;
369
+ parseOption(chain: any, currency?: Currency, market?: Market): {
370
+ info: any;
371
+ currency: any;
372
+ symbol: string;
373
+ timestamp: number;
374
+ datetime: string;
375
+ impliedVolatility: any;
376
+ openInterest: any;
377
+ bidPrice: number;
378
+ askPrice: number;
379
+ midPrice: any;
380
+ markPrice: number;
381
+ lastPrice: number;
382
+ underlyingPrice: number;
383
+ change: any;
384
+ percentage: any;
385
+ baseVolume: any;
386
+ quoteVolume: any;
387
+ };
367
388
  handleErrors(code: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
368
389
  }
package/js/src/gate.js CHANGED
@@ -135,6 +135,8 @@ export default class gate extends Exchange {
135
135
  'fetchOpenInterest': false,
136
136
  'fetchOpenInterestHistory': true,
137
137
  'fetchOpenOrders': true,
138
+ 'fetchOption': true,
139
+ 'fetchOptionChain': true,
138
140
  'fetchOrder': true,
139
141
  'fetchOrderBook': true,
140
142
  'fetchPosition': true,
@@ -4234,8 +4236,17 @@ export default class gate extends Exchange {
4234
4236
  'account': account,
4235
4237
  };
4236
4238
  if (amount !== undefined) {
4237
- const amountKey = (market['spot']) ? 'amount' : 'size';
4238
- request[amountKey] = this.amountToPrecision(symbol, amount);
4239
+ if (market['spot']) {
4240
+ request['amount'] = this.amountToPrecision(symbol, amount);
4241
+ }
4242
+ else {
4243
+ if (side === 'sell') {
4244
+ request['size'] = Precise.stringNeg(this.amountToPrecision(symbol, amount));
4245
+ }
4246
+ else {
4247
+ request['size'] = this.amountToPrecision(symbol, amount);
4248
+ }
4249
+ }
4239
4250
  }
4240
4251
  if (price !== undefined) {
4241
4252
  request['price'] = this.priceToPrecision(symbol, price);
@@ -5033,8 +5044,8 @@ export default class gate extends Exchange {
5033
5044
  */
5034
5045
  await this.loadMarkets();
5035
5046
  const market = (symbol === undefined) ? undefined : this.market(symbol);
5036
- const stop = this.safeValue(params, 'stop');
5037
- params = this.omit(params, 'stop');
5047
+ const stop = this.safeBool2(params, 'stop', 'trigger');
5048
+ params = this.omit(params, ['stop', 'trigger']);
5038
5049
  const [type, query] = this.handleMarketTypeAndParams('cancelAllOrders', market, params);
5039
5050
  const [request, requestParams] = (type === 'spot') ? this.multiOrderSpotPrepareRequest(market, stop, query) : this.prepareRequest(market, type, query);
5040
5051
  let response = undefined;
@@ -5362,7 +5373,7 @@ export default class gate extends Exchange {
5362
5373
  'unrealizedPnl': this.parseNumber(unrealisedPnl),
5363
5374
  'realizedPnl': this.safeNumber(position, 'realised_pnl'),
5364
5375
  'contracts': this.parseNumber(Precise.stringAbs(size)),
5365
- 'contractSize': this.safeValue(market, 'contractSize'),
5376
+ 'contractSize': this.safeNumber(market, 'contractSize'),
5366
5377
  // 'realisedPnl': position['realised_pnl'],
5367
5378
  'marginRatio': undefined,
5368
5379
  'liquidationPrice': this.safeNumber(position, 'liq_price'),
@@ -7196,6 +7207,190 @@ export default class gate extends Exchange {
7196
7207
  'shortLeverage': leverageValue,
7197
7208
  };
7198
7209
  }
7210
+ async fetchOption(symbol, params = {}) {
7211
+ /**
7212
+ * @method
7213
+ * @name gate#fetchOption
7214
+ * @description fetches option data that is commonly found in an option chain
7215
+ * @see https://www.gate.io/docs/developers/apiv4/en/#query-specified-contract-detail
7216
+ * @param {string} symbol unified market symbol
7217
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
7218
+ * @returns {object} an [option chain structure]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
7219
+ */
7220
+ await this.loadMarkets();
7221
+ const market = this.market(symbol);
7222
+ const request = {
7223
+ 'contract': market['id'],
7224
+ };
7225
+ const response = await this.publicOptionsGetContractsContract(this.extend(request, params));
7226
+ //
7227
+ // {
7228
+ // "is_active": true,
7229
+ // "mark_price_round": "0.01",
7230
+ // "settle_fee_rate": "0.00015",
7231
+ // "bid1_size": 30,
7232
+ // "taker_fee_rate": "0.0003",
7233
+ // "price_limit_fee_rate": "0.1",
7234
+ // "order_price_round": "0.1",
7235
+ // "tag": "month",
7236
+ // "ref_rebate_rate": "0",
7237
+ // "name": "ETH_USDT-20240628-4500-C",
7238
+ // "strike_price": "4500",
7239
+ // "ask1_price": "280.5",
7240
+ // "ref_discount_rate": "0",
7241
+ // "order_price_deviate": "0.2",
7242
+ // "ask1_size": -19,
7243
+ // "mark_price_down": "155.45",
7244
+ // "orderbook_id": 11724695,
7245
+ // "is_call": true,
7246
+ // "last_price": "188.7",
7247
+ // "mark_price": "274.26",
7248
+ // "underlying": "ETH_USDT",
7249
+ // "create_time": 1688024882,
7250
+ // "settle_limit_fee_rate": "0.1",
7251
+ // "orders_limit": 10,
7252
+ // "mark_price_up": "403.83",
7253
+ // "position_size": 80,
7254
+ // "order_size_max": 10000,
7255
+ // "position_limit": 100000,
7256
+ // "multiplier": "0.01",
7257
+ // "order_size_min": 1,
7258
+ // "trade_size": 229,
7259
+ // "underlying_price": "3326.6",
7260
+ // "maker_fee_rate": "0.0003",
7261
+ // "expiration_time": 1719561600,
7262
+ // "trade_id": 15,
7263
+ // "bid1_price": "269.3"
7264
+ // }
7265
+ //
7266
+ return this.parseOption(response, undefined, market);
7267
+ }
7268
+ async fetchOptionChain(code, params = {}) {
7269
+ /**
7270
+ * @method
7271
+ * @name gate#fetchOptionChain
7272
+ * @description fetches data for an underlying asset that is commonly found in an option chain
7273
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-all-the-contracts-with-specified-underlying-and-expiration-time
7274
+ * @param {string} currency base currency to fetch an option chain for
7275
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
7276
+ * @param {string} [params.underlying] the underlying asset, can be obtained from fetchUnderlyingAssets ()
7277
+ * @param {int} [params.expiration] unix timestamp of the expiration time
7278
+ * @returns {object} a list of [option chain structures]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
7279
+ */
7280
+ await this.loadMarkets();
7281
+ const currency = this.currency(code);
7282
+ const request = {
7283
+ 'underlying': currency['code'] + '_USDT',
7284
+ };
7285
+ const response = await this.publicOptionsGetContracts(this.extend(request, params));
7286
+ //
7287
+ // [
7288
+ // {
7289
+ // "is_active": true,
7290
+ // "mark_price_round": "0.1",
7291
+ // "settle_fee_rate": "0.00015",
7292
+ // "bid1_size": 434,
7293
+ // "taker_fee_rate": "0.0003",
7294
+ // "price_limit_fee_rate": "0.1",
7295
+ // "order_price_round": "1",
7296
+ // "tag": "day",
7297
+ // "ref_rebate_rate": "0",
7298
+ // "name": "BTC_USDT-20240324-63500-P",
7299
+ // "strike_price": "63500",
7300
+ // "ask1_price": "387",
7301
+ // "ref_discount_rate": "0",
7302
+ // "order_price_deviate": "0.15",
7303
+ // "ask1_size": -454,
7304
+ // "mark_price_down": "124.3",
7305
+ // "orderbook_id": 29600,
7306
+ // "is_call": false,
7307
+ // "last_price": "0",
7308
+ // "mark_price": "366.6",
7309
+ // "underlying": "BTC_USDT",
7310
+ // "create_time": 1711118829,
7311
+ // "settle_limit_fee_rate": "0.1",
7312
+ // "orders_limit": 10,
7313
+ // "mark_price_up": "630",
7314
+ // "position_size": 0,
7315
+ // "order_size_max": 10000,
7316
+ // "position_limit": 10000,
7317
+ // "multiplier": "0.01",
7318
+ // "order_size_min": 1,
7319
+ // "trade_size": 0,
7320
+ // "underlying_price": "64084.65",
7321
+ // "maker_fee_rate": "0.0003",
7322
+ // "expiration_time": 1711267200,
7323
+ // "trade_id": 0,
7324
+ // "bid1_price": "307"
7325
+ // },
7326
+ // ]
7327
+ //
7328
+ return this.parseOptionChain(response, undefined, 'name');
7329
+ }
7330
+ parseOption(chain, currency = undefined, market = undefined) {
7331
+ //
7332
+ // {
7333
+ // "is_active": true,
7334
+ // "mark_price_round": "0.1",
7335
+ // "settle_fee_rate": "0.00015",
7336
+ // "bid1_size": 434,
7337
+ // "taker_fee_rate": "0.0003",
7338
+ // "price_limit_fee_rate": "0.1",
7339
+ // "order_price_round": "1",
7340
+ // "tag": "day",
7341
+ // "ref_rebate_rate": "0",
7342
+ // "name": "BTC_USDT-20240324-63500-P",
7343
+ // "strike_price": "63500",
7344
+ // "ask1_price": "387",
7345
+ // "ref_discount_rate": "0",
7346
+ // "order_price_deviate": "0.15",
7347
+ // "ask1_size": -454,
7348
+ // "mark_price_down": "124.3",
7349
+ // "orderbook_id": 29600,
7350
+ // "is_call": false,
7351
+ // "last_price": "0",
7352
+ // "mark_price": "366.6",
7353
+ // "underlying": "BTC_USDT",
7354
+ // "create_time": 1711118829,
7355
+ // "settle_limit_fee_rate": "0.1",
7356
+ // "orders_limit": 10,
7357
+ // "mark_price_up": "630",
7358
+ // "position_size": 0,
7359
+ // "order_size_max": 10000,
7360
+ // "position_limit": 10000,
7361
+ // "multiplier": "0.01",
7362
+ // "order_size_min": 1,
7363
+ // "trade_size": 0,
7364
+ // "underlying_price": "64084.65",
7365
+ // "maker_fee_rate": "0.0003",
7366
+ // "expiration_time": 1711267200,
7367
+ // "trade_id": 0,
7368
+ // "bid1_price": "307"
7369
+ // }
7370
+ //
7371
+ const marketId = this.safeString(chain, 'name');
7372
+ market = this.safeMarket(marketId, market);
7373
+ const timestamp = this.safeTimestamp(chain, 'create_time');
7374
+ return {
7375
+ 'info': chain,
7376
+ 'currency': undefined,
7377
+ 'symbol': market['symbol'],
7378
+ 'timestamp': timestamp,
7379
+ 'datetime': this.iso8601(timestamp),
7380
+ 'impliedVolatility': undefined,
7381
+ 'openInterest': undefined,
7382
+ 'bidPrice': this.safeNumber(chain, 'bid1_price'),
7383
+ 'askPrice': this.safeNumber(chain, 'ask1_price'),
7384
+ 'midPrice': undefined,
7385
+ 'markPrice': this.safeNumber(chain, 'mark_price'),
7386
+ 'lastPrice': this.safeNumber(chain, 'last_price'),
7387
+ 'underlyingPrice': this.safeNumber(chain, 'underlying_price'),
7388
+ 'change': undefined,
7389
+ 'percentage': undefined,
7390
+ 'baseVolume': undefined,
7391
+ 'quoteVolume': undefined,
7392
+ };
7393
+ }
7199
7394
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
7200
7395
  if (response === undefined) {
7201
7396
  return undefined;
@@ -73,6 +73,7 @@ export default class hyperliquid extends Exchange {
73
73
  modifyMarginHelper(symbol: string, amount: any, type: any, params?: {}): Promise<any>;
74
74
  transfer(code: string, amount: number, fromAccount: string, toAccount: string, params?: {}): Promise<TransferEntry>;
75
75
  withdraw(code: string, amount: any, address: any, tag?: any, params?: {}): Promise<any>;
76
+ formatVaultAddress(address?: Str): string;
76
77
  handlePublicAddress(methodName: string, params: Dict): any[];
77
78
  handleErrors(code: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
78
79
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
@@ -771,6 +771,8 @@ export default class hyperliquid extends Exchange {
771
771
  */
772
772
  await this.loadMarkets();
773
773
  const market = this.market(symbol);
774
+ const vaultAddress = this.safeString(params, 'vaultAddress');
775
+ params = this.omit(params, 'vaultAddress');
774
776
  symbol = market['symbol'];
775
777
  const order = {
776
778
  'symbol': symbol,
@@ -780,7 +782,11 @@ export default class hyperliquid extends Exchange {
780
782
  'price': price,
781
783
  'params': params,
782
784
  };
783
- const response = await this.createOrders([order], params);
785
+ const globalParams = {};
786
+ if (vaultAddress !== undefined) {
787
+ globalParams['vaultAddress'] = vaultAddress;
788
+ }
789
+ const response = await this.createOrders([order], globalParams);
784
790
  const first = this.safeDict(response, 0);
785
791
  return first;
786
792
  }
@@ -831,7 +837,6 @@ export default class hyperliquid extends Exchange {
831
837
  const amount = this.safeString(rawOrder, 'amount');
832
838
  const price = this.safeString(rawOrder, 'price');
833
839
  let orderParams = this.safeDict(rawOrder, 'params', {});
834
- orderParams = this.extend(params, orderParams);
835
840
  const clientOrderId = this.safeString2(orderParams, 'clientOrderId', 'client_id');
836
841
  const slippage = this.safeString(orderParams, 'slippage', defaultSlippage);
837
842
  let defaultTimeInForce = (isMarket) ? 'ioc' : 'gtc';
@@ -879,6 +884,7 @@ export default class hyperliquid extends Exchange {
879
884
  'tif': timeInForce,
880
885
  };
881
886
  }
887
+ orderParams = this.omit(orderParams, ['clientOrderId', 'slippage', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'timeInForce', 'client_id']);
882
888
  const orderObj = {
883
889
  'a': this.parseToInt(market['baseId']),
884
890
  'b': isBuy,
@@ -891,9 +897,9 @@ export default class hyperliquid extends Exchange {
891
897
  if (clientOrderId !== undefined) {
892
898
  orderObj['c'] = clientOrderId;
893
899
  }
894
- orderReq.push(orderObj);
900
+ orderReq.push(this.extend(orderObj, orderParams));
895
901
  }
896
- const vaultAddress = this.safeString(params, 'vaultAddress');
902
+ const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
897
903
  const orderAction = {
898
904
  'type': 'order',
899
905
  'orders': orderReq,
@@ -910,6 +916,10 @@ export default class hyperliquid extends Exchange {
910
916
  'signature': signature,
911
917
  // 'vaultAddress': vaultAddress,
912
918
  };
919
+ if (vaultAddress !== undefined) {
920
+ params = this.omit(params, 'vaultAddress');
921
+ request['vaultAddress'] = vaultAddress;
922
+ }
913
923
  const response = await this.privatePostExchange(this.extend(request, params));
914
924
  //
915
925
  // {
@@ -1002,10 +1012,14 @@ export default class hyperliquid extends Exchange {
1002
1012
  }
1003
1013
  }
1004
1014
  cancelAction['cancels'] = cancelReq;
1005
- const vaultAddress = this.safeString(params, 'vaultAddress');
1015
+ const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
1006
1016
  const signature = this.signL1Action(cancelAction, nonce, vaultAddress);
1007
1017
  request['action'] = cancelAction;
1008
1018
  request['signature'] = signature;
1019
+ if (vaultAddress !== undefined) {
1020
+ params = this.omit(params, 'vaultAddress');
1021
+ request['vaultAddress'] = vaultAddress;
1022
+ }
1009
1023
  const response = await this.privatePostExchange(this.extend(request, params));
1010
1024
  //
1011
1025
  // {
@@ -1123,7 +1137,7 @@ export default class hyperliquid extends Exchange {
1123
1137
  'type': 'batchModify',
1124
1138
  'modifies': [modifyReq],
1125
1139
  };
1126
- const vaultAddress = this.safeString(params, 'vaultAddress');
1140
+ const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
1127
1141
  const signature = this.signL1Action(modifyAction, nonce, vaultAddress);
1128
1142
  const request = {
1129
1143
  'action': modifyAction,
@@ -1131,6 +1145,10 @@ export default class hyperliquid extends Exchange {
1131
1145
  'signature': signature,
1132
1146
  // 'vaultAddress': vaultAddress,
1133
1147
  };
1148
+ if (vaultAddress !== undefined) {
1149
+ params = this.omit(params, 'vaultAddress');
1150
+ request['vaultAddress'] = vaultAddress;
1151
+ }
1134
1152
  const response = await this.privatePostExchange(this.extend(request, params));
1135
1153
  //
1136
1154
  // {
@@ -1729,7 +1747,7 @@ export default class hyperliquid extends Exchange {
1729
1747
  'isolated': isIsolated,
1730
1748
  'hedged': undefined,
1731
1749
  'side': side,
1732
- 'contracts': this.parseNumber(quantity),
1750
+ 'contracts': this.safeNumber(entry, 'szi'),
1733
1751
  'contractSize': undefined,
1734
1752
  'entryPrice': this.safeNumber(entry, 'entryPx'),
1735
1753
  'markPrice': undefined,
@@ -1776,7 +1794,13 @@ export default class hyperliquid extends Exchange {
1776
1794
  'isCross': isCross,
1777
1795
  'leverage': leverage,
1778
1796
  };
1779
- const vaultAddress = this.safeString(params, 'vaultAddress');
1797
+ let vaultAddress = this.safeString(params, 'vaultAddress');
1798
+ if (vaultAddress !== undefined) {
1799
+ params = this.omit(params, 'vaultAddress');
1800
+ if (vaultAddress.startsWith('0x')) {
1801
+ vaultAddress = vaultAddress.replace('0x', '');
1802
+ }
1803
+ }
1780
1804
  const signature = this.signL1Action(updateAction, nonce, vaultAddress);
1781
1805
  const request = {
1782
1806
  'action': updateAction,
@@ -1784,6 +1808,9 @@ export default class hyperliquid extends Exchange {
1784
1808
  'signature': signature,
1785
1809
  // 'vaultAddress': vaultAddress,
1786
1810
  };
1811
+ if (vaultAddress !== undefined) {
1812
+ request['vaultAddress'] = vaultAddress;
1813
+ }
1787
1814
  const response = await this.privatePostExchange(this.extend(request, params));
1788
1815
  //
1789
1816
  // {
@@ -1822,7 +1849,7 @@ export default class hyperliquid extends Exchange {
1822
1849
  'isCross': isCross,
1823
1850
  'leverage': leverage,
1824
1851
  };
1825
- const vaultAddress = this.safeString(params, 'vaultAddress');
1852
+ const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
1826
1853
  const signature = this.signL1Action(updateAction, nonce, vaultAddress);
1827
1854
  const request = {
1828
1855
  'action': updateAction,
@@ -1830,6 +1857,10 @@ export default class hyperliquid extends Exchange {
1830
1857
  'signature': signature,
1831
1858
  // 'vaultAddress': vaultAddress,
1832
1859
  };
1860
+ if (vaultAddress !== undefined) {
1861
+ params = this.omit(params, 'vaultAddress');
1862
+ request['vaultAddress'] = vaultAddress;
1863
+ }
1833
1864
  const response = await this.privatePostExchange(this.extend(request, params));
1834
1865
  //
1835
1866
  // {
@@ -1882,7 +1913,7 @@ export default class hyperliquid extends Exchange {
1882
1913
  'isBuy': true,
1883
1914
  'ntli': sz,
1884
1915
  };
1885
- const vaultAddress = this.safeString(params, 'vaultAddress');
1916
+ const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
1886
1917
  const signature = this.signL1Action(updateAction, nonce, vaultAddress);
1887
1918
  const request = {
1888
1919
  'action': updateAction,
@@ -1890,6 +1921,10 @@ export default class hyperliquid extends Exchange {
1890
1921
  'signature': signature,
1891
1922
  // 'vaultAddress': vaultAddress,
1892
1923
  };
1924
+ if (vaultAddress !== undefined) {
1925
+ params = this.omit(params, 'vaultAddress');
1926
+ request['vaultAddress'] = vaultAddress;
1927
+ }
1893
1928
  const response = await this.privatePostExchange(this.extend(request, params));
1894
1929
  //
1895
1930
  // {
@@ -1988,6 +2023,15 @@ export default class hyperliquid extends Exchange {
1988
2023
  const response = await this.privatePostExchange(this.extend(request, params));
1989
2024
  return response;
1990
2025
  }
2026
+ formatVaultAddress(address = undefined) {
2027
+ if (address === undefined) {
2028
+ return undefined;
2029
+ }
2030
+ if (address.startsWith('0x')) {
2031
+ return address.replace('0x', '');
2032
+ }
2033
+ return address;
2034
+ }
1991
2035
  handlePublicAddress(methodName, params) {
1992
2036
  let userAux = undefined;
1993
2037
  [userAux, params] = this.handleOptionAndParams(params, methodName, 'user');
package/js/src/okx.d.ts CHANGED
@@ -28,7 +28,6 @@ export default class okx extends Exchange {
28
28
  fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
29
29
  parseTicker(ticker: any, market?: Market): Ticker;
30
30
  fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
31
- fetchTickersByType(type: any, symbols?: Strings, params?: {}): Promise<import("./base/types.js").Dictionary<Ticker>>;
32
31
  fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
33
32
  parseTrade(trade: any, market?: Market): Trade;
34
33
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;