@bluefin-exchange/pro-sdk 0.1.17 → 0.1.19

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.
package/README.md CHANGED
@@ -40,6 +40,6 @@ openapi-generator generate -i ../resources/bluefin-api.yaml -c ./sdk/openapitool
40
40
 
41
41
  ```bash
42
42
  npm install
43
- npm install ts-node
43
+ npm install -g ts-node
44
44
  ts-node example.ts
45
45
  ```
package/dist/example.js CHANGED
@@ -87,15 +87,13 @@ function main() {
87
87
  const client = new index_1.BluefinProSdk(bfSigner, "devnet", new library_sui_1.SuiClient({ url: "https://fullnode.testnet.sui.io:443" }));
88
88
  yield client.initialize();
89
89
  try {
90
- yield client.deposit("1000");
90
+ // Disable for now as the account does not have enough coins
91
+ // await client.deposit((0.03*1e9).toString());
91
92
  // Get Market Data from Exchange Data API
92
93
  const exchangeInfo = (yield client.exchangeDataApi.getExchangeInfo()).data;
93
94
  logger.info(`Exchange Info: ${JSON.stringify(exchangeInfo)}`);
94
- // Find SUI-PERP market
95
- const perpMarket = exchangeInfo.markets.find((m) => m.symbol === "SUI-PERP");
96
- if (!perpMarket) {
97
- throw new Error("SUI-PERP market not found");
98
- }
95
+ // Find the first market available if any
96
+ const perpMarket = exchangeInfo.markets.length > 0 ? exchangeInfo.markets[0] : (() => { throw new Error("No market is available"); })();
99
97
  logger.info(`Selected market: ${JSON.stringify(perpMarket)}`);
100
98
  const symbol = perpMarket.symbol;
101
99
  // Get market data
package/dist/src/api.d.ts CHANGED
@@ -225,6 +225,50 @@ export declare const AccountEventType: {
225
225
  readonly AccountTransactionUpdate: "AccountTransactionUpdate";
226
226
  };
227
227
  export type AccountEventType = typeof AccountEventType[keyof typeof AccountEventType];
228
+ /**
229
+ *
230
+ * @export
231
+ * @interface AccountFundingRateHistory
232
+ */
233
+ export interface AccountFundingRateHistory {
234
+ /**
235
+ *
236
+ * @type {Array<AccountFundingRateHistoryData>}
237
+ * @memberof AccountFundingRateHistory
238
+ */
239
+ 'data': Array<AccountFundingRateHistoryData>;
240
+ }
241
+ /**
242
+ *
243
+ * @export
244
+ * @interface AccountFundingRateHistoryData
245
+ */
246
+ export interface AccountFundingRateHistoryData {
247
+ /**
248
+ * Payment amount in e9 format.
249
+ * @type {string}
250
+ * @memberof AccountFundingRateHistoryData
251
+ */
252
+ 'payment_amount_e9': string;
253
+ /**
254
+ * Market address.
255
+ * @type {string}
256
+ * @memberof AccountFundingRateHistoryData
257
+ */
258
+ 'symbol': string;
259
+ /**
260
+ * Execution timestamp in milliseconds since Unix epoch.
261
+ * @type {number}
262
+ * @memberof AccountFundingRateHistoryData
263
+ */
264
+ 'executed_at': number;
265
+ /**
266
+ * Computed timestamp in milliseconds since Unix epoch.
267
+ * @type {number}
268
+ * @memberof AccountFundingRateHistoryData
269
+ */
270
+ 'computed_at': number;
271
+ }
228
272
  /**
229
273
  *
230
274
  * @export
@@ -2464,6 +2508,24 @@ export interface Position {
2464
2508
  * @memberof Position
2465
2509
  */
2466
2510
  'updatedAtMillis': number;
2511
+ /**
2512
+ * Total funding rate payment (e9 format).
2513
+ * @type {string}
2514
+ * @memberof Position
2515
+ */
2516
+ 'fundingRatePaymentAllTimeE9': string;
2517
+ /**
2518
+ * Funding rate payment since last position change (e9 format).
2519
+ * @type {string}
2520
+ * @memberof Position
2521
+ */
2522
+ 'fundingRatePaymentSinceChangeE9': string;
2523
+ /**
2524
+ * Funding rate payment since position opened (e9 format).
2525
+ * @type {string}
2526
+ * @memberof Position
2527
+ */
2528
+ 'fundingRatePaymentSinceOpenedE9': string;
2467
2529
  }
2468
2530
  /**
2469
2531
  * The side of the position, either long or short
@@ -3374,6 +3436,16 @@ export declare const AccountDataApiAxiosParamCreator: (configuration?: Configura
3374
3436
  * @throws {RequiredError}
3375
3437
  */
3376
3438
  getAccountDetails: (options?: RawAxiosRequestConfig) => Promise<RequestArgs>;
3439
+ /**
3440
+ *
3441
+ * @summary Get user\'s funding rate history
3442
+ * @param {string} [accountAddress] Account address to filter funding rate history by.
3443
+ * @param {number} [limit] Default 500; max 1000.
3444
+ * @param {number} [page] The page number to retrieve in a paginated response.
3445
+ * @param {*} [options] Override http request option.
3446
+ * @throws {RequiredError}
3447
+ */
3448
+ getAccountFundingRateHistory: (accountAddress?: string, limit?: number, page?: number, options?: RawAxiosRequestConfig) => Promise<RequestArgs>;
3377
3449
  /**
3378
3450
  *
3379
3451
  * @summary Get user\'s account preferences.
@@ -3384,7 +3456,7 @@ export declare const AccountDataApiAxiosParamCreator: (configuration?: Configura
3384
3456
  /**
3385
3457
  *
3386
3458
  * @summary Get user\'s trade history.
3387
- * @param {string} symbol Market address to filter trades by.
3459
+ * @param {string} [symbol] Market address to filter trades by. If not specified, returns trades for all markets.
3388
3460
  * @param {number} [startTimeAtMillis] Start time in milliseconds. Defaults to 7 days ago if not specified.
3389
3461
  * @param {number} [endTimeAtMillis] End time in milliseconds. Defaults to now if not specified. Must be greater than start time and must be less than 7 days apart.
3390
3462
  * @param {number} [limit] Default 500; max 1000.
@@ -3393,7 +3465,7 @@ export declare const AccountDataApiAxiosParamCreator: (configuration?: Configura
3393
3465
  * @param {*} [options] Override http request option.
3394
3466
  * @throws {RequiredError}
3395
3467
  */
3396
- getAccountTrades: (symbol: string, startTimeAtMillis?: number, endTimeAtMillis?: number, limit?: number, tradeType?: TradeType, page?: number, options?: RawAxiosRequestConfig) => Promise<RequestArgs>;
3468
+ getAccountTrades: (symbol?: string, startTimeAtMillis?: number, endTimeAtMillis?: number, limit?: number, tradeType?: TradeType, page?: number, options?: RawAxiosRequestConfig) => Promise<RequestArgs>;
3397
3469
  /**
3398
3470
  *
3399
3471
  * @summary Get user\'s transaction history (any change in balance).
@@ -3420,6 +3492,16 @@ export declare const AccountDataApiFp: (configuration?: Configuration) => {
3420
3492
  * @throws {RequiredError}
3421
3493
  */
3422
3494
  getAccountDetails(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Account>>;
3495
+ /**
3496
+ *
3497
+ * @summary Get user\'s funding rate history
3498
+ * @param {string} [accountAddress] Account address to filter funding rate history by.
3499
+ * @param {number} [limit] Default 500; max 1000.
3500
+ * @param {number} [page] The page number to retrieve in a paginated response.
3501
+ * @param {*} [options] Override http request option.
3502
+ * @throws {RequiredError}
3503
+ */
3504
+ getAccountFundingRateHistory(accountAddress?: string, limit?: number, page?: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<AccountFundingRateHistory>>;
3423
3505
  /**
3424
3506
  *
3425
3507
  * @summary Get user\'s account preferences.
@@ -3430,7 +3512,7 @@ export declare const AccountDataApiFp: (configuration?: Configuration) => {
3430
3512
  /**
3431
3513
  *
3432
3514
  * @summary Get user\'s trade history.
3433
- * @param {string} symbol Market address to filter trades by.
3515
+ * @param {string} [symbol] Market address to filter trades by. If not specified, returns trades for all markets.
3434
3516
  * @param {number} [startTimeAtMillis] Start time in milliseconds. Defaults to 7 days ago if not specified.
3435
3517
  * @param {number} [endTimeAtMillis] End time in milliseconds. Defaults to now if not specified. Must be greater than start time and must be less than 7 days apart.
3436
3518
  * @param {number} [limit] Default 500; max 1000.
@@ -3439,7 +3521,7 @@ export declare const AccountDataApiFp: (configuration?: Configuration) => {
3439
3521
  * @param {*} [options] Override http request option.
3440
3522
  * @throws {RequiredError}
3441
3523
  */
3442
- getAccountTrades(symbol: string, startTimeAtMillis?: number, endTimeAtMillis?: number, limit?: number, tradeType?: TradeType, page?: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<Trade>>>;
3524
+ getAccountTrades(symbol?: string, startTimeAtMillis?: number, endTimeAtMillis?: number, limit?: number, tradeType?: TradeType, page?: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<Trade>>>;
3443
3525
  /**
3444
3526
  *
3445
3527
  * @summary Get user\'s transaction history (any change in balance).
@@ -3466,6 +3548,16 @@ export declare const AccountDataApiFactory: (configuration?: Configuration, base
3466
3548
  * @throws {RequiredError}
3467
3549
  */
3468
3550
  getAccountDetails(options?: RawAxiosRequestConfig): AxiosPromise<Account>;
3551
+ /**
3552
+ *
3553
+ * @summary Get user\'s funding rate history
3554
+ * @param {string} [accountAddress] Account address to filter funding rate history by.
3555
+ * @param {number} [limit] Default 500; max 1000.
3556
+ * @param {number} [page] The page number to retrieve in a paginated response.
3557
+ * @param {*} [options] Override http request option.
3558
+ * @throws {RequiredError}
3559
+ */
3560
+ getAccountFundingRateHistory(accountAddress?: string, limit?: number, page?: number, options?: RawAxiosRequestConfig): AxiosPromise<AccountFundingRateHistory>;
3469
3561
  /**
3470
3562
  *
3471
3563
  * @summary Get user\'s account preferences.
@@ -3476,7 +3568,7 @@ export declare const AccountDataApiFactory: (configuration?: Configuration, base
3476
3568
  /**
3477
3569
  *
3478
3570
  * @summary Get user\'s trade history.
3479
- * @param {string} symbol Market address to filter trades by.
3571
+ * @param {string} [symbol] Market address to filter trades by. If not specified, returns trades for all markets.
3480
3572
  * @param {number} [startTimeAtMillis] Start time in milliseconds. Defaults to 7 days ago if not specified.
3481
3573
  * @param {number} [endTimeAtMillis] End time in milliseconds. Defaults to now if not specified. Must be greater than start time and must be less than 7 days apart.
3482
3574
  * @param {number} [limit] Default 500; max 1000.
@@ -3485,7 +3577,7 @@ export declare const AccountDataApiFactory: (configuration?: Configuration, base
3485
3577
  * @param {*} [options] Override http request option.
3486
3578
  * @throws {RequiredError}
3487
3579
  */
3488
- getAccountTrades(symbol: string, startTimeAtMillis?: number, endTimeAtMillis?: number, limit?: number, tradeType?: TradeType, page?: number, options?: RawAxiosRequestConfig): AxiosPromise<Array<Trade>>;
3580
+ getAccountTrades(symbol?: string, startTimeAtMillis?: number, endTimeAtMillis?: number, limit?: number, tradeType?: TradeType, page?: number, options?: RawAxiosRequestConfig): AxiosPromise<Array<Trade>>;
3489
3581
  /**
3490
3582
  *
3491
3583
  * @summary Get user\'s transaction history (any change in balance).
@@ -3515,6 +3607,17 @@ export declare class AccountDataApi extends BaseAPI {
3515
3607
  * @memberof AccountDataApi
3516
3608
  */
3517
3609
  getAccountDetails(options?: RawAxiosRequestConfig): Promise<import("axios").AxiosResponse<Account, any>>;
3610
+ /**
3611
+ *
3612
+ * @summary Get user\'s funding rate history
3613
+ * @param {string} [accountAddress] Account address to filter funding rate history by.
3614
+ * @param {number} [limit] Default 500; max 1000.
3615
+ * @param {number} [page] The page number to retrieve in a paginated response.
3616
+ * @param {*} [options] Override http request option.
3617
+ * @throws {RequiredError}
3618
+ * @memberof AccountDataApi
3619
+ */
3620
+ getAccountFundingRateHistory(accountAddress?: string, limit?: number, page?: number, options?: RawAxiosRequestConfig): Promise<import("axios").AxiosResponse<AccountFundingRateHistory, any>>;
3518
3621
  /**
3519
3622
  *
3520
3623
  * @summary Get user\'s account preferences.
@@ -3526,7 +3629,7 @@ export declare class AccountDataApi extends BaseAPI {
3526
3629
  /**
3527
3630
  *
3528
3631
  * @summary Get user\'s trade history.
3529
- * @param {string} symbol Market address to filter trades by.
3632
+ * @param {string} [symbol] Market address to filter trades by. If not specified, returns trades for all markets.
3530
3633
  * @param {number} [startTimeAtMillis] Start time in milliseconds. Defaults to 7 days ago if not specified.
3531
3634
  * @param {number} [endTimeAtMillis] End time in milliseconds. Defaults to now if not specified. Must be greater than start time and must be less than 7 days apart.
3532
3635
  * @param {number} [limit] Default 500; max 1000.
@@ -3536,7 +3639,7 @@ export declare class AccountDataApi extends BaseAPI {
3536
3639
  * @throws {RequiredError}
3537
3640
  * @memberof AccountDataApi
3538
3641
  */
3539
- getAccountTrades(symbol: string, startTimeAtMillis?: number, endTimeAtMillis?: number, limit?: number, tradeType?: TradeType, page?: number, options?: RawAxiosRequestConfig): Promise<import("axios").AxiosResponse<Trade[], any>>;
3642
+ getAccountTrades(symbol?: string, startTimeAtMillis?: number, endTimeAtMillis?: number, limit?: number, tradeType?: TradeType, page?: number, options?: RawAxiosRequestConfig): Promise<import("axios").AxiosResponse<Trade[], any>>;
3540
3643
  /**
3541
3644
  *
3542
3645
  * @summary Get user\'s transaction history (any change in balance).
package/dist/src/api.js CHANGED
@@ -444,6 +444,46 @@ const AccountDataApiAxiosParamCreator = function (configuration) {
444
444
  options: localVarRequestOptions,
445
445
  };
446
446
  }),
447
+ /**
448
+ *
449
+ * @summary Get user\'s funding rate history
450
+ * @param {string} [accountAddress] Account address to filter funding rate history by.
451
+ * @param {number} [limit] Default 500; max 1000.
452
+ * @param {number} [page] The page number to retrieve in a paginated response.
453
+ * @param {*} [options] Override http request option.
454
+ * @throws {RequiredError}
455
+ */
456
+ getAccountFundingRateHistory: (accountAddress_1, limit_1, page_1, ...args_1) => __awaiter(this, [accountAddress_1, limit_1, page_1, ...args_1], void 0, function* (accountAddress, limit, page, options = {}) {
457
+ const localVarPath = `/api/v1/account/fundingRateHistory`;
458
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
459
+ const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
460
+ let baseOptions;
461
+ if (configuration) {
462
+ baseOptions = configuration.baseOptions;
463
+ }
464
+ const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options);
465
+ const localVarHeaderParameter = {};
466
+ const localVarQueryParameter = {};
467
+ // authentication bearerAuth required
468
+ // http bearer authentication required
469
+ yield (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration);
470
+ if (accountAddress !== undefined) {
471
+ localVarQueryParameter['accountAddress'] = accountAddress;
472
+ }
473
+ if (limit !== undefined) {
474
+ localVarQueryParameter['limit'] = limit;
475
+ }
476
+ if (page !== undefined) {
477
+ localVarQueryParameter['page'] = page;
478
+ }
479
+ (0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
480
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
481
+ localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
482
+ return {
483
+ url: (0, common_1.toPathString)(localVarUrlObj),
484
+ options: localVarRequestOptions,
485
+ };
486
+ }),
447
487
  /**
448
488
  *
449
489
  * @summary Get user\'s account preferences.
@@ -475,7 +515,7 @@ const AccountDataApiAxiosParamCreator = function (configuration) {
475
515
  /**
476
516
  *
477
517
  * @summary Get user\'s trade history.
478
- * @param {string} symbol Market address to filter trades by.
518
+ * @param {string} [symbol] Market address to filter trades by. If not specified, returns trades for all markets.
479
519
  * @param {number} [startTimeAtMillis] Start time in milliseconds. Defaults to 7 days ago if not specified.
480
520
  * @param {number} [endTimeAtMillis] End time in milliseconds. Defaults to now if not specified. Must be greater than start time and must be less than 7 days apart.
481
521
  * @param {number} [limit] Default 500; max 1000.
@@ -485,8 +525,6 @@ const AccountDataApiAxiosParamCreator = function (configuration) {
485
525
  * @throws {RequiredError}
486
526
  */
487
527
  getAccountTrades: (symbol_1, startTimeAtMillis_1, endTimeAtMillis_1, limit_1, tradeType_1, page_1, ...args_1) => __awaiter(this, [symbol_1, startTimeAtMillis_1, endTimeAtMillis_1, limit_1, tradeType_1, page_1, ...args_1], void 0, function* (symbol, startTimeAtMillis, endTimeAtMillis, limit, tradeType, page, options = {}) {
488
- // verify required parameter 'symbol' is not null or undefined
489
- (0, common_1.assertParamExists)('getAccountTrades', 'symbol', symbol);
490
528
  const localVarPath = `/api/v1/account/trades`;
491
529
  // use dummy base URL string because the URL constructor only accepts absolute URLs.
492
530
  const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
@@ -603,6 +641,24 @@ const AccountDataApiFp = function (configuration) {
603
641
  return (axios, basePath) => (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
604
642
  });
605
643
  },
644
+ /**
645
+ *
646
+ * @summary Get user\'s funding rate history
647
+ * @param {string} [accountAddress] Account address to filter funding rate history by.
648
+ * @param {number} [limit] Default 500; max 1000.
649
+ * @param {number} [page] The page number to retrieve in a paginated response.
650
+ * @param {*} [options] Override http request option.
651
+ * @throws {RequiredError}
652
+ */
653
+ getAccountFundingRateHistory(accountAddress, limit, page, options) {
654
+ return __awaiter(this, void 0, void 0, function* () {
655
+ var _a, _b, _c;
656
+ const localVarAxiosArgs = yield localVarAxiosParamCreator.getAccountFundingRateHistory(accountAddress, limit, page, options);
657
+ const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0;
658
+ const localVarOperationServerBasePath = (_c = (_b = base_1.operationServerMap['AccountDataApi.getAccountFundingRateHistory']) === null || _b === void 0 ? void 0 : _b[localVarOperationServerIndex]) === null || _c === void 0 ? void 0 : _c.url;
659
+ return (axios, basePath) => (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
660
+ });
661
+ },
606
662
  /**
607
663
  *
608
664
  * @summary Get user\'s account preferences.
@@ -621,7 +677,7 @@ const AccountDataApiFp = function (configuration) {
621
677
  /**
622
678
  *
623
679
  * @summary Get user\'s trade history.
624
- * @param {string} symbol Market address to filter trades by.
680
+ * @param {string} [symbol] Market address to filter trades by. If not specified, returns trades for all markets.
625
681
  * @param {number} [startTimeAtMillis] Start time in milliseconds. Defaults to 7 days ago if not specified.
626
682
  * @param {number} [endTimeAtMillis] End time in milliseconds. Defaults to now if not specified. Must be greater than start time and must be less than 7 days apart.
627
683
  * @param {number} [limit] Default 500; max 1000.
@@ -679,6 +735,18 @@ const AccountDataApiFactory = function (configuration, basePath, axios) {
679
735
  getAccountDetails(options) {
680
736
  return localVarFp.getAccountDetails(options).then((request) => request(axios, basePath));
681
737
  },
738
+ /**
739
+ *
740
+ * @summary Get user\'s funding rate history
741
+ * @param {string} [accountAddress] Account address to filter funding rate history by.
742
+ * @param {number} [limit] Default 500; max 1000.
743
+ * @param {number} [page] The page number to retrieve in a paginated response.
744
+ * @param {*} [options] Override http request option.
745
+ * @throws {RequiredError}
746
+ */
747
+ getAccountFundingRateHistory(accountAddress, limit, page, options) {
748
+ return localVarFp.getAccountFundingRateHistory(accountAddress, limit, page, options).then((request) => request(axios, basePath));
749
+ },
682
750
  /**
683
751
  *
684
752
  * @summary Get user\'s account preferences.
@@ -691,7 +759,7 @@ const AccountDataApiFactory = function (configuration, basePath, axios) {
691
759
  /**
692
760
  *
693
761
  * @summary Get user\'s trade history.
694
- * @param {string} symbol Market address to filter trades by.
762
+ * @param {string} [symbol] Market address to filter trades by. If not specified, returns trades for all markets.
695
763
  * @param {number} [startTimeAtMillis] Start time in milliseconds. Defaults to 7 days ago if not specified.
696
764
  * @param {number} [endTimeAtMillis] End time in milliseconds. Defaults to now if not specified. Must be greater than start time and must be less than 7 days apart.
697
765
  * @param {number} [limit] Default 500; max 1000.
@@ -738,6 +806,19 @@ class AccountDataApi extends base_1.BaseAPI {
738
806
  getAccountDetails(options) {
739
807
  return (0, exports.AccountDataApiFp)(this.configuration).getAccountDetails(options).then((request) => request(this.axios, this.basePath));
740
808
  }
809
+ /**
810
+ *
811
+ * @summary Get user\'s funding rate history
812
+ * @param {string} [accountAddress] Account address to filter funding rate history by.
813
+ * @param {number} [limit] Default 500; max 1000.
814
+ * @param {number} [page] The page number to retrieve in a paginated response.
815
+ * @param {*} [options] Override http request option.
816
+ * @throws {RequiredError}
817
+ * @memberof AccountDataApi
818
+ */
819
+ getAccountFundingRateHistory(accountAddress, limit, page, options) {
820
+ return (0, exports.AccountDataApiFp)(this.configuration).getAccountFundingRateHistory(accountAddress, limit, page, options).then((request) => request(this.axios, this.basePath));
821
+ }
741
822
  /**
742
823
  *
743
824
  * @summary Get user\'s account preferences.
@@ -751,7 +832,7 @@ class AccountDataApi extends base_1.BaseAPI {
751
832
  /**
752
833
  *
753
834
  * @summary Get user\'s trade history.
754
- * @param {string} symbol Market address to filter trades by.
835
+ * @param {string} [symbol] Market address to filter trades by. If not specified, returns trades for all markets.
755
836
  * @param {number} [startTimeAtMillis] Start time in milliseconds. Defaults to 7 days ago if not specified.
756
837
  * @param {number} [endTimeAtMillis] End time in milliseconds. Defaults to now if not specified. Must be greater than start time and must be less than 7 days apart.
757
838
  * @param {number} [limit] Default 500; max 1000.
package/dist/src/sdk.js CHANGED
@@ -141,7 +141,7 @@ class BluefinProSdk {
141
141
  yield this.setContractsConfig();
142
142
  yield this.initializeTxBuilder();
143
143
  yield this.loginAndUpdateToken();
144
- this.updateTokenInterval = setInterval(() => this.refreshToken(), 10000);
144
+ this.updateTokenInterval = setInterval(() => this.refreshToken(), 120000);
145
145
  this.isConnected = true;
146
146
  });
147
147
  }
package/example.ts CHANGED
@@ -111,18 +111,15 @@ async function main() {
111
111
  await client.initialize();
112
112
 
113
113
  try {
114
- await client.deposit("1000");
114
+ // Disable for now as the account does not have enough coins
115
+ // await client.deposit((0.03*1e9).toString());
116
+
115
117
  // Get Market Data from Exchange Data API
116
118
  const exchangeInfo = (await client.exchangeDataApi.getExchangeInfo()).data;
117
119
  logger.info(`Exchange Info: ${JSON.stringify(exchangeInfo)}`);
118
120
 
119
- // Find SUI-PERP market
120
- const perpMarket = exchangeInfo.markets.find(
121
- (m: Market) => m.symbol === "SUI-PERP",
122
- );
123
- if (!perpMarket) {
124
- throw new Error("SUI-PERP market not found");
125
- }
121
+ // Find the first market available if any
122
+ const perpMarket = exchangeInfo.markets.length > 0 ? exchangeInfo.markets[0] : (() => { throw new Error("No market is available"); })();
126
123
  logger.info(`Selected market: ${JSON.stringify(perpMarket)}`);
127
124
 
128
125
  const symbol = perpMarket.symbol;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluefin-exchange/pro-sdk",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "description": "OpenAPI client for @bluefin-exchange/pro-sdk",
5
5
  "author": "Bluefin",
6
6
  "repository": {
package/src/api.ts CHANGED
@@ -247,6 +247,50 @@ export const AccountEventType = {
247
247
  export type AccountEventType = typeof AccountEventType[keyof typeof AccountEventType];
248
248
 
249
249
 
250
+ /**
251
+ *
252
+ * @export
253
+ * @interface AccountFundingRateHistory
254
+ */
255
+ export interface AccountFundingRateHistory {
256
+ /**
257
+ *
258
+ * @type {Array<AccountFundingRateHistoryData>}
259
+ * @memberof AccountFundingRateHistory
260
+ */
261
+ 'data': Array<AccountFundingRateHistoryData>;
262
+ }
263
+ /**
264
+ *
265
+ * @export
266
+ * @interface AccountFundingRateHistoryData
267
+ */
268
+ export interface AccountFundingRateHistoryData {
269
+ /**
270
+ * Payment amount in e9 format.
271
+ * @type {string}
272
+ * @memberof AccountFundingRateHistoryData
273
+ */
274
+ 'payment_amount_e9': string;
275
+ /**
276
+ * Market address.
277
+ * @type {string}
278
+ * @memberof AccountFundingRateHistoryData
279
+ */
280
+ 'symbol': string;
281
+ /**
282
+ * Execution timestamp in milliseconds since Unix epoch.
283
+ * @type {number}
284
+ * @memberof AccountFundingRateHistoryData
285
+ */
286
+ 'executed_at': number;
287
+ /**
288
+ * Computed timestamp in milliseconds since Unix epoch.
289
+ * @type {number}
290
+ * @memberof AccountFundingRateHistoryData
291
+ */
292
+ 'computed_at': number;
293
+ }
250
294
  /**
251
295
  *
252
296
  * @export
@@ -2580,6 +2624,24 @@ export interface Position {
2580
2624
  * @memberof Position
2581
2625
  */
2582
2626
  'updatedAtMillis': number;
2627
+ /**
2628
+ * Total funding rate payment (e9 format).
2629
+ * @type {string}
2630
+ * @memberof Position
2631
+ */
2632
+ 'fundingRatePaymentAllTimeE9': string;
2633
+ /**
2634
+ * Funding rate payment since last position change (e9 format).
2635
+ * @type {string}
2636
+ * @memberof Position
2637
+ */
2638
+ 'fundingRatePaymentSinceChangeE9': string;
2639
+ /**
2640
+ * Funding rate payment since position opened (e9 format).
2641
+ * @type {string}
2642
+ * @memberof Position
2643
+ */
2644
+ 'fundingRatePaymentSinceOpenedE9': string;
2583
2645
  }
2584
2646
 
2585
2647
 
@@ -3547,6 +3609,55 @@ export const AccountDataApiAxiosParamCreator = function (configuration?: Configu
3547
3609
 
3548
3610
 
3549
3611
 
3612
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
3613
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
3614
+ localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
3615
+
3616
+ return {
3617
+ url: toPathString(localVarUrlObj),
3618
+ options: localVarRequestOptions,
3619
+ };
3620
+ },
3621
+ /**
3622
+ *
3623
+ * @summary Get user\'s funding rate history
3624
+ * @param {string} [accountAddress] Account address to filter funding rate history by.
3625
+ * @param {number} [limit] Default 500; max 1000.
3626
+ * @param {number} [page] The page number to retrieve in a paginated response.
3627
+ * @param {*} [options] Override http request option.
3628
+ * @throws {RequiredError}
3629
+ */
3630
+ getAccountFundingRateHistory: async (accountAddress?: string, limit?: number, page?: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
3631
+ const localVarPath = `/api/v1/account/fundingRateHistory`;
3632
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
3633
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
3634
+ let baseOptions;
3635
+ if (configuration) {
3636
+ baseOptions = configuration.baseOptions;
3637
+ }
3638
+
3639
+ const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
3640
+ const localVarHeaderParameter = {} as any;
3641
+ const localVarQueryParameter = {} as any;
3642
+
3643
+ // authentication bearerAuth required
3644
+ // http bearer authentication required
3645
+ await setBearerAuthToObject(localVarHeaderParameter, configuration)
3646
+
3647
+ if (accountAddress !== undefined) {
3648
+ localVarQueryParameter['accountAddress'] = accountAddress;
3649
+ }
3650
+
3651
+ if (limit !== undefined) {
3652
+ localVarQueryParameter['limit'] = limit;
3653
+ }
3654
+
3655
+ if (page !== undefined) {
3656
+ localVarQueryParameter['page'] = page;
3657
+ }
3658
+
3659
+
3660
+
3550
3661
  setSearchParams(localVarUrlObj, localVarQueryParameter);
3551
3662
  let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
3552
3663
  localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
@@ -3593,7 +3704,7 @@ export const AccountDataApiAxiosParamCreator = function (configuration?: Configu
3593
3704
  /**
3594
3705
  *
3595
3706
  * @summary Get user\'s trade history.
3596
- * @param {string} symbol Market address to filter trades by.
3707
+ * @param {string} [symbol] Market address to filter trades by. If not specified, returns trades for all markets.
3597
3708
  * @param {number} [startTimeAtMillis] Start time in milliseconds. Defaults to 7 days ago if not specified.
3598
3709
  * @param {number} [endTimeAtMillis] End time in milliseconds. Defaults to now if not specified. Must be greater than start time and must be less than 7 days apart.
3599
3710
  * @param {number} [limit] Default 500; max 1000.
@@ -3602,9 +3713,7 @@ export const AccountDataApiAxiosParamCreator = function (configuration?: Configu
3602
3713
  * @param {*} [options] Override http request option.
3603
3714
  * @throws {RequiredError}
3604
3715
  */
3605
- getAccountTrades: async (symbol: string, startTimeAtMillis?: number, endTimeAtMillis?: number, limit?: number, tradeType?: TradeType, page?: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
3606
- // verify required parameter 'symbol' is not null or undefined
3607
- assertParamExists('getAccountTrades', 'symbol', symbol)
3716
+ getAccountTrades: async (symbol?: string, startTimeAtMillis?: number, endTimeAtMillis?: number, limit?: number, tradeType?: TradeType, page?: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
3608
3717
  const localVarPath = `/api/v1/account/trades`;
3609
3718
  // use dummy base URL string because the URL constructor only accepts absolute URLs.
3610
3719
  const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
@@ -3742,6 +3851,21 @@ export const AccountDataApiFp = function(configuration?: Configuration) {
3742
3851
  const localVarOperationServerBasePath = operationServerMap['AccountDataApi.getAccountDetails']?.[localVarOperationServerIndex]?.url;
3743
3852
  return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
3744
3853
  },
3854
+ /**
3855
+ *
3856
+ * @summary Get user\'s funding rate history
3857
+ * @param {string} [accountAddress] Account address to filter funding rate history by.
3858
+ * @param {number} [limit] Default 500; max 1000.
3859
+ * @param {number} [page] The page number to retrieve in a paginated response.
3860
+ * @param {*} [options] Override http request option.
3861
+ * @throws {RequiredError}
3862
+ */
3863
+ async getAccountFundingRateHistory(accountAddress?: string, limit?: number, page?: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<AccountFundingRateHistory>> {
3864
+ const localVarAxiosArgs = await localVarAxiosParamCreator.getAccountFundingRateHistory(accountAddress, limit, page, options);
3865
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
3866
+ const localVarOperationServerBasePath = operationServerMap['AccountDataApi.getAccountFundingRateHistory']?.[localVarOperationServerIndex]?.url;
3867
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
3868
+ },
3745
3869
  /**
3746
3870
  *
3747
3871
  * @summary Get user\'s account preferences.
@@ -3757,7 +3881,7 @@ export const AccountDataApiFp = function(configuration?: Configuration) {
3757
3881
  /**
3758
3882
  *
3759
3883
  * @summary Get user\'s trade history.
3760
- * @param {string} symbol Market address to filter trades by.
3884
+ * @param {string} [symbol] Market address to filter trades by. If not specified, returns trades for all markets.
3761
3885
  * @param {number} [startTimeAtMillis] Start time in milliseconds. Defaults to 7 days ago if not specified.
3762
3886
  * @param {number} [endTimeAtMillis] End time in milliseconds. Defaults to now if not specified. Must be greater than start time and must be less than 7 days apart.
3763
3887
  * @param {number} [limit] Default 500; max 1000.
@@ -3766,7 +3890,7 @@ export const AccountDataApiFp = function(configuration?: Configuration) {
3766
3890
  * @param {*} [options] Override http request option.
3767
3891
  * @throws {RequiredError}
3768
3892
  */
3769
- async getAccountTrades(symbol: string, startTimeAtMillis?: number, endTimeAtMillis?: number, limit?: number, tradeType?: TradeType, page?: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<Trade>>> {
3893
+ async getAccountTrades(symbol?: string, startTimeAtMillis?: number, endTimeAtMillis?: number, limit?: number, tradeType?: TradeType, page?: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<Trade>>> {
3770
3894
  const localVarAxiosArgs = await localVarAxiosParamCreator.getAccountTrades(symbol, startTimeAtMillis, endTimeAtMillis, limit, tradeType, page, options);
3771
3895
  const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
3772
3896
  const localVarOperationServerBasePath = operationServerMap['AccountDataApi.getAccountTrades']?.[localVarOperationServerIndex]?.url;
@@ -3809,6 +3933,18 @@ export const AccountDataApiFactory = function (configuration?: Configuration, ba
3809
3933
  getAccountDetails(options?: RawAxiosRequestConfig): AxiosPromise<Account> {
3810
3934
  return localVarFp.getAccountDetails(options).then((request) => request(axios, basePath));
3811
3935
  },
3936
+ /**
3937
+ *
3938
+ * @summary Get user\'s funding rate history
3939
+ * @param {string} [accountAddress] Account address to filter funding rate history by.
3940
+ * @param {number} [limit] Default 500; max 1000.
3941
+ * @param {number} [page] The page number to retrieve in a paginated response.
3942
+ * @param {*} [options] Override http request option.
3943
+ * @throws {RequiredError}
3944
+ */
3945
+ getAccountFundingRateHistory(accountAddress?: string, limit?: number, page?: number, options?: RawAxiosRequestConfig): AxiosPromise<AccountFundingRateHistory> {
3946
+ return localVarFp.getAccountFundingRateHistory(accountAddress, limit, page, options).then((request) => request(axios, basePath));
3947
+ },
3812
3948
  /**
3813
3949
  *
3814
3950
  * @summary Get user\'s account preferences.
@@ -3821,7 +3957,7 @@ export const AccountDataApiFactory = function (configuration?: Configuration, ba
3821
3957
  /**
3822
3958
  *
3823
3959
  * @summary Get user\'s trade history.
3824
- * @param {string} symbol Market address to filter trades by.
3960
+ * @param {string} [symbol] Market address to filter trades by. If not specified, returns trades for all markets.
3825
3961
  * @param {number} [startTimeAtMillis] Start time in milliseconds. Defaults to 7 days ago if not specified.
3826
3962
  * @param {number} [endTimeAtMillis] End time in milliseconds. Defaults to now if not specified. Must be greater than start time and must be less than 7 days apart.
3827
3963
  * @param {number} [limit] Default 500; max 1000.
@@ -3830,7 +3966,7 @@ export const AccountDataApiFactory = function (configuration?: Configuration, ba
3830
3966
  * @param {*} [options] Override http request option.
3831
3967
  * @throws {RequiredError}
3832
3968
  */
3833
- getAccountTrades(symbol: string, startTimeAtMillis?: number, endTimeAtMillis?: number, limit?: number, tradeType?: TradeType, page?: number, options?: RawAxiosRequestConfig): AxiosPromise<Array<Trade>> {
3969
+ getAccountTrades(symbol?: string, startTimeAtMillis?: number, endTimeAtMillis?: number, limit?: number, tradeType?: TradeType, page?: number, options?: RawAxiosRequestConfig): AxiosPromise<Array<Trade>> {
3834
3970
  return localVarFp.getAccountTrades(symbol, startTimeAtMillis, endTimeAtMillis, limit, tradeType, page, options).then((request) => request(axios, basePath));
3835
3971
  },
3836
3972
  /**
@@ -3869,6 +4005,20 @@ export class AccountDataApi extends BaseAPI {
3869
4005
  return AccountDataApiFp(this.configuration).getAccountDetails(options).then((request) => request(this.axios, this.basePath));
3870
4006
  }
3871
4007
 
4008
+ /**
4009
+ *
4010
+ * @summary Get user\'s funding rate history
4011
+ * @param {string} [accountAddress] Account address to filter funding rate history by.
4012
+ * @param {number} [limit] Default 500; max 1000.
4013
+ * @param {number} [page] The page number to retrieve in a paginated response.
4014
+ * @param {*} [options] Override http request option.
4015
+ * @throws {RequiredError}
4016
+ * @memberof AccountDataApi
4017
+ */
4018
+ public getAccountFundingRateHistory(accountAddress?: string, limit?: number, page?: number, options?: RawAxiosRequestConfig) {
4019
+ return AccountDataApiFp(this.configuration).getAccountFundingRateHistory(accountAddress, limit, page, options).then((request) => request(this.axios, this.basePath));
4020
+ }
4021
+
3872
4022
  /**
3873
4023
  *
3874
4024
  * @summary Get user\'s account preferences.
@@ -3883,7 +4033,7 @@ export class AccountDataApi extends BaseAPI {
3883
4033
  /**
3884
4034
  *
3885
4035
  * @summary Get user\'s trade history.
3886
- * @param {string} symbol Market address to filter trades by.
4036
+ * @param {string} [symbol] Market address to filter trades by. If not specified, returns trades for all markets.
3887
4037
  * @param {number} [startTimeAtMillis] Start time in milliseconds. Defaults to 7 days ago if not specified.
3888
4038
  * @param {number} [endTimeAtMillis] End time in milliseconds. Defaults to now if not specified. Must be greater than start time and must be less than 7 days apart.
3889
4039
  * @param {number} [limit] Default 500; max 1000.
@@ -3893,7 +4043,7 @@ export class AccountDataApi extends BaseAPI {
3893
4043
  * @throws {RequiredError}
3894
4044
  * @memberof AccountDataApi
3895
4045
  */
3896
- public getAccountTrades(symbol: string, startTimeAtMillis?: number, endTimeAtMillis?: number, limit?: number, tradeType?: TradeType, page?: number, options?: RawAxiosRequestConfig) {
4046
+ public getAccountTrades(symbol?: string, startTimeAtMillis?: number, endTimeAtMillis?: number, limit?: number, tradeType?: TradeType, page?: number, options?: RawAxiosRequestConfig) {
3897
4047
  return AccountDataApiFp(this.configuration).getAccountTrades(symbol, startTimeAtMillis, endTimeAtMillis, limit, tradeType, page, options).then((request) => request(this.axios, this.basePath));
3898
4048
  }
3899
4049
 
package/src/sdk.ts CHANGED
@@ -223,7 +223,7 @@ export class BluefinProSdk {
223
223
  await this.setContractsConfig();
224
224
  await this.initializeTxBuilder();
225
225
  await this.loginAndUpdateToken();
226
- this.updateTokenInterval = setInterval(() => this.refreshToken(), 10000);
226
+ this.updateTokenInterval = setInterval(() => this.refreshToken(), 120000);
227
227
  this.isConnected = true;
228
228
  }
229
229