@nightlylabs/dex-sdk 0.0.10 → 0.0.12

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/dist/index.cjs CHANGED
@@ -32,6 +32,7 @@ var index_exports = {};
32
32
  __export(index_exports, {
33
33
  AdminEndpoints: () => AdminEndpoints,
34
34
  BaseEndpoints: () => BaseEndpoints,
35
+ ChartInterval: () => ChartInterval,
35
36
  Client: () => Client,
36
37
  EndpointsV1: () => EndpointsV1,
37
38
  ExchangeProxies: () => ExchangeProxies,
@@ -61,7 +62,7 @@ var import_uuid = require("uuid");
61
62
 
62
63
  // generated_types/addApiKey.ts
63
64
  var ABI = {
64
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
65
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
65
66
  "name": "add_api_key",
66
67
  "friends": [],
67
68
  "exposed_functions": [
@@ -86,7 +87,7 @@ var addApiKey_default = ABI;
86
87
 
87
88
  // generated_types/cancelAllPerpOrders.ts
88
89
  var ABI2 = {
89
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
90
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
90
91
  "name": "cancel_all_perp_orders",
91
92
  "friends": [],
92
93
  "exposed_functions": [
@@ -109,7 +110,7 @@ var cancelAllPerpOrders_default = ABI2;
109
110
 
110
111
  // generated_types/cancelPerpOrders.ts
111
112
  var ABI3 = {
112
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
113
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
113
114
  "name": "cancel_perp_orders",
114
115
  "friends": [],
115
116
  "exposed_functions": [
@@ -134,7 +135,7 @@ var cancelPerpOrders_default = ABI3;
134
135
 
135
136
  // generated_types/createUser.ts
136
137
  var ABI4 = {
137
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
138
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
138
139
  "name": "create_user",
139
140
  "friends": [],
140
141
  "exposed_functions": [
@@ -159,7 +160,7 @@ var createUser_default = ABI4;
159
160
 
160
161
  // generated_types/depositToVault.ts
161
162
  var ABI5 = {
162
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
163
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
163
164
  "name": "deposit_to_vault",
164
165
  "friends": [],
165
166
  "exposed_functions": [
@@ -182,9 +183,34 @@ var ABI5 = {
182
183
  };
183
184
  var depositToVault_default = ABI5;
184
185
 
185
- // generated_types/lendToken.ts
186
+ // generated_types/depositToken.ts
186
187
  var ABI6 = {
187
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
188
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
189
+ "name": "deposit_token",
190
+ "friends": [],
191
+ "exposed_functions": [
192
+ {
193
+ "name": "deposit_token",
194
+ "visibility": "public",
195
+ "is_entry": true,
196
+ "is_view": false,
197
+ "generic_type_params": [],
198
+ "params": [
199
+ "&signer",
200
+ "u64",
201
+ "u64",
202
+ "0x1::object::Object<0x1::fungible_asset::Metadata>"
203
+ ],
204
+ "return": []
205
+ }
206
+ ],
207
+ "structs": []
208
+ };
209
+ var depositToken_default = ABI6;
210
+
211
+ // generated_types/lendToken.ts
212
+ var ABI7 = {
213
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
188
214
  "name": "lend_token",
189
215
  "friends": [],
190
216
  "exposed_functions": [
@@ -206,11 +232,11 @@ var ABI6 = {
206
232
  ],
207
233
  "structs": []
208
234
  };
209
- var lendToken_default = ABI6;
235
+ var lendToken_default = ABI7;
210
236
 
211
237
  // generated_types/placePerpLimitOrder.ts
212
- var ABI7 = {
213
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
238
+ var ABI8 = {
239
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
214
240
  "name": "place_perp_limit_order",
215
241
  "friends": [],
216
242
  "exposed_functions": [
@@ -234,11 +260,11 @@ var ABI7 = {
234
260
  ],
235
261
  "structs": []
236
262
  };
237
- var placePerpLimitOrder_default = ABI7;
263
+ var placePerpLimitOrder_default = ABI8;
238
264
 
239
265
  // generated_types/placePerpMarketOrder.ts
240
- var ABI8 = {
241
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
266
+ var ABI9 = {
267
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
242
268
  "name": "place_perp_market_order",
243
269
  "friends": [],
244
270
  "exposed_functions": [
@@ -261,11 +287,11 @@ var ABI8 = {
261
287
  ],
262
288
  "structs": []
263
289
  };
264
- var placePerpMarketOrder_default = ABI8;
290
+ var placePerpMarketOrder_default = ABI9;
265
291
 
266
292
  // generated_types/redeemToken.ts
267
- var ABI9 = {
268
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
293
+ var ABI10 = {
294
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
269
295
  "name": "redeem_token",
270
296
  "friends": [],
271
297
  "exposed_functions": [
@@ -287,11 +313,11 @@ var ABI9 = {
287
313
  ],
288
314
  "structs": []
289
315
  };
290
- var redeemToken_default = ABI9;
316
+ var redeemToken_default = ABI10;
291
317
 
292
318
  // generated_types/removeApiKey.ts
293
- var ABI10 = {
294
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
319
+ var ABI11 = {
320
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
295
321
  "name": "remove_api_key",
296
322
  "friends": [],
297
323
  "exposed_functions": [
@@ -311,11 +337,11 @@ var ABI10 = {
311
337
  ],
312
338
  "structs": []
313
339
  };
314
- var removeApiKey_default = ABI10;
340
+ var removeApiKey_default = ABI11;
315
341
 
316
342
  // generated_types/setAliasName.ts
317
- var ABI11 = {
318
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
343
+ var ABI12 = {
344
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
319
345
  "name": "set_alias_name",
320
346
  "friends": [],
321
347
  "exposed_functions": [
@@ -335,11 +361,11 @@ var ABI11 = {
335
361
  ],
336
362
  "structs": []
337
363
  };
338
- var setAliasName_default = ABI11;
364
+ var setAliasName_default = ABI12;
339
365
 
340
366
  // generated_types/setAutolend.ts
341
- var ABI12 = {
342
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
367
+ var ABI13 = {
368
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
343
369
  "name": "set_autolend",
344
370
  "friends": [],
345
371
  "exposed_functions": [
@@ -359,9 +385,19 @@ var ABI12 = {
359
385
  ],
360
386
  "structs": []
361
387
  };
362
- var setAutolend_default = ABI12;
388
+ var setAutolend_default = ABI13;
363
389
 
364
390
  // generated_types/typeshareTypes.ts
391
+ var ChartInterval = /* @__PURE__ */ ((ChartInterval3) => {
392
+ ChartInterval3["OneMinute"] = "OneMinute";
393
+ ChartInterval3["FiveMinutes"] = "FiveMinutes";
394
+ ChartInterval3["FifteenMinutes"] = "FifteenMinutes";
395
+ ChartInterval3["ThirtyMinutes"] = "ThirtyMinutes";
396
+ ChartInterval3["OneHour"] = "OneHour";
397
+ ChartInterval3["FourHours"] = "FourHours";
398
+ ChartInterval3["OneDay"] = "OneDay";
399
+ return ChartInterval3;
400
+ })(ChartInterval || {});
365
401
  var PerpetualMarketStatus = /* @__PURE__ */ ((PerpetualMarketStatus2) => {
366
402
  PerpetualMarketStatus2["Halted"] = "halted";
367
403
  PerpetualMarketStatus2["ReduceOnly"] = "reduceOnly";
@@ -385,6 +421,8 @@ var EndpointsV1 = /* @__PURE__ */ ((EndpointsV12) => {
385
421
  EndpointsV12["GetPerpMarketsData"] = "/v1/get_perp_markets_data";
386
422
  EndpointsV12["GetBorrowLendingData"] = "/v1/get_borrow_lending_data";
387
423
  EndpointsV12["SubmitSponsoredTransactionRequest"] = "/v1/submit_sponsored_transaction";
424
+ EndpointsV12["GetChartCandlesInRange"] = "/v1/public/chart_candles_in_range";
425
+ EndpointsV12["GetUsersByAddress"] = "/v1/get_users_by_address";
388
426
  return EndpointsV12;
389
427
  })(EndpointsV1 || {});
390
428
  var AdminEndpoints = /* @__PURE__ */ ((AdminEndpoints2) => {
@@ -422,8 +460,8 @@ var UserStatus = /* @__PURE__ */ ((UserStatus2) => {
422
460
  })(UserStatus || {});
423
461
 
424
462
  // generated_types/withdrawFromVault.ts
425
- var ABI13 = {
426
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
463
+ var ABI14 = {
464
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
427
465
  "name": "withdraw_from_vault",
428
466
  "friends": [],
429
467
  "exposed_functions": [
@@ -445,7 +483,7 @@ var ABI13 = {
445
483
  ],
446
484
  "structs": []
447
485
  };
448
- var withdrawFromVault_default = ABI13;
486
+ var withdrawFromVault_default = ABI14;
449
487
 
450
488
  // src/utils.ts
451
489
  var import_ts_sdk = require("@aptos-labs/ts-sdk");
@@ -533,6 +571,10 @@ var getTopicFromMessage = (data) => {
533
571
  return data.content.userId;
534
572
  case "SetAlias":
535
573
  return data.content.userId;
574
+ case "AddApiKey":
575
+ return data.content.userId;
576
+ case "RemoveApiKey":
577
+ return data.content.userId;
536
578
  }
537
579
  };
538
580
 
@@ -653,10 +695,33 @@ var Client = class _Client {
653
695
  const response = await this.sendGetJson("/v1/get_borrow_lending_data" /* GetBorrowLendingData */);
654
696
  return response;
655
697
  };
698
+ this.getChartCandlesInRange = async ({
699
+ interval,
700
+ marketName,
701
+ endTime = Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3),
702
+ startTime = Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3 - 24 * 60 * 60 * 1e3),
703
+ // default 24 back
704
+ cursor
705
+ }) => {
706
+ if (endTime && startTime && endTime < startTime) {
707
+ throw new Error("endTime must be greater than startTime");
708
+ }
709
+ const response = await this.sendGetJson("/v1/public/chart_candles_in_range" /* GetChartCandlesInRange */, {
710
+ marketName,
711
+ interval,
712
+ startTimestamp: startTime.toString(),
713
+ endTimestamp: endTime.toString(),
714
+ paginationCursor: cursor
715
+ });
716
+ };
656
717
  this.getPriceIndexes = async () => {
657
718
  const response = await this.sendGetJson("/v1/get_price_indexes" /* GetPriceIndexes */);
658
719
  return response;
659
720
  };
721
+ this.getUsersByAddress = async (payload) => {
722
+ const response = await this.sendPostJson(payload, "/v1/get_users_by_address" /* GetUsersByAddress */);
723
+ return response;
724
+ };
660
725
  this._aptos = connection;
661
726
  this._surf = (0, import_surf.createSurfClient)(this._aptos);
662
727
  this._apiKey = apiKey || generateApiKey();
@@ -914,6 +979,13 @@ var Client = class _Client {
914
979
  });
915
980
  return await this.submitSponsoredTransaction(tx, signature);
916
981
  }
982
+ async depositTokenPayload(params) {
983
+ return (0, import_surf.createEntryPayload)(depositToken_default, {
984
+ function: "deposit_token",
985
+ functionArguments: [params.userId, params.amount, params.tokenAddress],
986
+ typeArguments: []
987
+ });
988
+ }
917
989
  async depositToVault(params) {
918
990
  const payload = (0, import_surf.createEntryPayload)(depositToVault_default, {
919
991
  function: "deposit_to_vault",
@@ -1004,8 +1076,8 @@ var client_default = Client;
1004
1076
  var import_surf2 = require("@thalalabs/surf");
1005
1077
 
1006
1078
  // generated_types/faucetEntrypoints.ts
1007
- var ABI14 = {
1008
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
1079
+ var ABI15 = {
1080
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
1009
1081
  "name": "faucet_entrypoints",
1010
1082
  "friends": [],
1011
1083
  "exposed_functions": [
@@ -1036,11 +1108,11 @@ var ABI14 = {
1036
1108
  ],
1037
1109
  "structs": []
1038
1110
  };
1039
- var faucetEntrypoints_default = ABI14;
1111
+ var faucetEntrypoints_default = ABI15;
1040
1112
 
1041
1113
  // generated_types/testFaucet.ts
1042
- var ABI15 = {
1043
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
1114
+ var ABI16 = {
1115
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
1044
1116
  "name": "test_faucet",
1045
1117
  "friends": [],
1046
1118
  "exposed_functions": [
@@ -1077,7 +1149,7 @@ var ABI15 = {
1077
1149
  ],
1078
1150
  "return": [
1079
1151
  "0x1::object::ConstructorRef",
1080
- "0x1::object::Object<0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88::test_faucet::Token>"
1152
+ "0x1::object::Object<0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63::test_faucet::Token>"
1081
1153
  ]
1082
1154
  },
1083
1155
  {
@@ -1216,7 +1288,7 @@ var ABI15 = {
1216
1288
  "0x1::object::Object<0x1::fungible_asset::Metadata>"
1217
1289
  ],
1218
1290
  "return": [
1219
- "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88::test_faucet::FaucetToken"
1291
+ "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63::test_faucet::FaucetToken"
1220
1292
  ]
1221
1293
  }
1222
1294
  ],
@@ -1248,7 +1320,7 @@ var ABI15 = {
1248
1320
  "fields": [
1249
1321
  {
1250
1322
  "name": "tokens",
1251
- "type": "0x1::smart_table::SmartTable<vector<u8>, 0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88::test_faucet::FaucetToken>"
1323
+ "type": "0x1::smart_table::SmartTable<vector<u8>, 0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63::test_faucet::FaucetToken>"
1252
1324
  }
1253
1325
  ]
1254
1326
  },
@@ -1273,7 +1345,7 @@ var ABI15 = {
1273
1345
  }
1274
1346
  ]
1275
1347
  };
1276
- var testFaucet_default = ABI15;
1348
+ var testFaucet_default = ABI16;
1277
1349
 
1278
1350
  // src/testFaucet.ts
1279
1351
  var TestFaucet = class _TestFaucet extends client_default {
@@ -1339,6 +1411,7 @@ var TestFaucet = class _TestFaucet extends client_default {
1339
1411
  0 && (module.exports = {
1340
1412
  AdminEndpoints,
1341
1413
  BaseEndpoints,
1414
+ ChartInterval,
1342
1415
  Client,
1343
1416
  EndpointsV1,
1344
1417
  ExchangeProxies,
package/dist/index.d.cts CHANGED
@@ -4,6 +4,7 @@ import * as _thalalabs_surf_build_types_core from '@thalalabs/surf/build/types/c
4
4
  import * as _thalalabs_surf from '@thalalabs/surf';
5
5
  import WebSocket from 'isomorphic-ws';
6
6
 
7
+ type PaginationCursor = string;
7
8
  interface StatusResponse {
8
9
  status: string;
9
10
  }
@@ -29,6 +30,37 @@ interface BorrowLending {
29
30
  interface GetBorrowLendingDataResponse {
30
31
  data: Record<string, BorrowLending>;
31
32
  }
33
+ declare enum ChartInterval {
34
+ OneMinute = "OneMinute",
35
+ FiveMinutes = "FiveMinutes",
36
+ FifteenMinutes = "FifteenMinutes",
37
+ ThirtyMinutes = "ThirtyMinutes",
38
+ OneHour = "OneHour",
39
+ FourHours = "FourHours",
40
+ OneDay = "OneDay"
41
+ }
42
+ interface GetChartCandlesInRangeRequest {
43
+ marketName: string;
44
+ interval: ChartInterval;
45
+ startTimestamp: string;
46
+ endTimestamp: string;
47
+ paginationCursor?: PaginationCursor;
48
+ }
49
+ interface ChartCandle {
50
+ marketName: string;
51
+ open: string;
52
+ high: string;
53
+ low: string;
54
+ close: string;
55
+ volumeBase: string;
56
+ volumeQuote: string;
57
+ timestampOpen: string;
58
+ timestampClose: string;
59
+ }
60
+ interface GetChartCandlesInRangeResponse {
61
+ chartCandles: ChartCandle[];
62
+ paginationCursor?: PaginationCursor;
63
+ }
32
64
  interface GetPerpMarketsDataRequest {
33
65
  markets: string[];
34
66
  }
@@ -152,6 +184,7 @@ interface User {
152
184
  userId: string;
153
185
  alias: string;
154
186
  autolendEnabled: boolean;
187
+ ownerAddress: string;
155
188
  tokenBalances: Record<string, string>;
156
189
  positions: Record<string, PerpPosition>;
157
190
  perpOrders: Record<string, Order>;
@@ -167,6 +200,12 @@ interface GetUserDataResponse {
167
200
  userData: User;
168
201
  perpOrdersCount: string;
169
202
  }
203
+ interface GetUsersByAddressRequest {
204
+ userAddress: string;
205
+ }
206
+ interface GetUsersByAddressResponse {
207
+ users: User[];
208
+ }
170
209
  interface SubmitSponsoredTransactionRequest {
171
210
  sender: string;
172
211
  sequenceNumber: string;
@@ -307,6 +346,14 @@ interface SetAlias {
307
346
  userId: string;
308
347
  newAlias: string;
309
348
  }
349
+ interface AddApiKey {
350
+ userId: string;
351
+ apiKey: string;
352
+ }
353
+ interface RemoveApiKey {
354
+ userId: string;
355
+ apiKey: string;
356
+ }
310
357
  interface ErrorResponse {
311
358
  code: number;
312
359
  variant: string;
@@ -322,7 +369,9 @@ declare enum EndpointsV1 {
322
369
  GetPerpOrderBookData = "/v1/get_perp_orderbook_data",
323
370
  GetPerpMarketsData = "/v1/get_perp_markets_data",
324
371
  GetBorrowLendingData = "/v1/get_borrow_lending_data",
325
- SubmitSponsoredTransactionRequest = "/v1/submit_sponsored_transaction"
372
+ SubmitSponsoredTransactionRequest = "/v1/submit_sponsored_transaction",
373
+ GetChartCandlesInRange = "/v1/public/chart_candles_in_range",
374
+ GetUsersByAddress = "/v1/get_users_by_address"
326
375
  }
327
376
  declare enum AdminEndpoints {
328
377
  Placeholder = "/admin/placeholder"
@@ -437,6 +486,12 @@ type WsMessage = {
437
486
  } | {
438
487
  type: "SetAlias";
439
488
  content: SetAlias;
489
+ } | {
490
+ type: "AddApiKey";
491
+ content: AddApiKey;
492
+ } | {
493
+ type: "RemoveApiKey";
494
+ content: RemoveApiKey;
440
495
  };
441
496
  declare enum OrderStatus {
442
497
  Placed = "Placed",
@@ -500,6 +555,7 @@ declare class Client {
500
555
  cancelPerpOrders(params: CancelPerpOrdersParams): Promise<SubmitSponsoredTransactionResponse>;
501
556
  cancelAllPerpOrders(params: CancelAllPerpOrdersParams): Promise<SubmitSponsoredTransactionResponse>;
502
557
  setAutolend(params: SetAutolendParams): Promise<SubmitSponsoredTransactionResponse>;
558
+ depositTokenPayload(params: DepositTokenParams): Promise<_thalalabs_surf.EntryPayload>;
503
559
  depositToVault(params: DepositToVaultParams): Promise<SubmitSponsoredTransactionResponse>;
504
560
  withdrawFromVault(params: WithdrawFromVaultParams): Promise<SubmitSponsoredTransactionResponse>;
505
561
  redeemToken(params: RedeemTokenParams): Promise<SubmitSponsoredTransactionResponse>;
@@ -516,7 +572,9 @@ declare class Client {
516
572
  getPerpOrderBookData: (marketName: string) => Promise<GetPerpOrderBookDataResponse>;
517
573
  getPerpMarketsData: (markets: string[]) => Promise<GetPerpMarketsDataResponse>;
518
574
  getBorrowLendingData: () => Promise<GetBorrowLendingDataResponse>;
575
+ getChartCandlesInRange: ({ interval, marketName, endTime, startTime, cursor, }: IGetChartCandlesInRange) => Promise<void>;
519
576
  getPriceIndexes: () => Promise<GetPriceIndexesResponse>;
577
+ getUsersByAddress: (payload: GetUsersByAddressRequest) => Promise<GetUsersByAddressResponse>;
520
578
  }
521
579
  interface PlacePerpLimitOrderParams {
522
580
  userId: string;
@@ -568,6 +626,11 @@ interface DepositToVaultParams {
568
626
  vaultId: string;
569
627
  amount: string;
570
628
  }
629
+ interface DepositTokenParams {
630
+ userId: string;
631
+ amount: string;
632
+ tokenAddress: Address;
633
+ }
571
634
  interface WithdrawFromVaultParams {
572
635
  userId: string;
573
636
  vaultId: string;
@@ -586,6 +649,13 @@ interface LendTokenParams {
586
649
  amount: string;
587
650
  max: boolean;
588
651
  }
652
+ interface IGetChartCandlesInRange {
653
+ marketName: string;
654
+ interval: ChartInterval;
655
+ startTime?: number;
656
+ endTime?: number;
657
+ cursor?: PaginationCursor;
658
+ }
589
659
 
590
660
  declare const ExchangeProxies: {
591
661
  [key in Network]: string[];
@@ -608,4 +678,4 @@ declare const generateApiKey: () => _aptos_labs_ts_sdk.Ed25519Account;
608
678
  declare const getTopicFromCommand: (data: WsCommand) => string;
609
679
  declare const getTopicFromMessage: (data: WsMessage) => string;
610
680
 
611
- export { type AddApiKeyParams, type Address, AdminEndpoints, type BalanceChange, BaseEndpoints, type Borrow, type BorrowLending, type CancelAllPerpOrdersParams, type CancelPerpOrdersParams, type CanceledPerpOrders, Client, type Content, type CreateUserParams, type Deposit, type DepositToVaultParams, EndpointsV1, type ErrorResponse, type ExchangeConfig, ExchangeProxies, type Fees, type FundingCheckpoint, type FundingRate, GLOBAL_DENOMINATOR, type GetBorrowLendingDataResponse, type GetPerpMarketsDataRequest, type GetPerpMarketsDataResponse, type GetPerpOrderBookDataRequest, type GetPerpOrderBookDataResponse, type GetPerpetualMarketsConfigResponse, type GetPriceIndexesResponse, type GetTokensConfigResponse, type GetUserDataRequest, type GetUserDataResponse, type Lend, type LendTokenParams, type MarginStep, Network, type OracleUpdate, type OracleUpdates, type Order, type OrderFills, OrderSide, OrderStatus, OrderType, type OrderbookUpdate, type PerpMarketData, type PerpOrderBookData, type PerpPosition, type PerpetualMarketConfigEntry, PerpetualMarketStatus, type PlacePerpLimitOrder, type PlacePerpLimitOrderParams, type PlacePerpMarketOrder, type PlacePerpMarketOrderParams, type PriceIndex, type RedeemTokenParams, type Referral, type RemoveApiKeyParams, type RepayBorrow, type SetAlias, type SetAliasNameParams, type SetAutolend, type SetAutolendParams, Status, type StatusResponse, type SubmitSponsoredTransactionRequest, type SubmitSponsoredTransactionResponse, TestFaucet, type TimeResponse, type TokenConfigEntry, type Topic, type Trade, TradeRole, type TradesUpdate, type User, UserStatus, type UtilizationCurve, type VaultInvestment, type Withdraw, type WithdrawFromVaultParams, type WithdrawLend, type WsCommand, type WsFill, type WsMessage, generateApiKey, getRandomId, getTopicFromCommand, getTopicFromMessage, sleep, toSystemValue };
681
+ export { type AddApiKey, type AddApiKeyParams, type Address, AdminEndpoints, type BalanceChange, BaseEndpoints, type Borrow, type BorrowLending, type CancelAllPerpOrdersParams, type CancelPerpOrdersParams, type CanceledPerpOrders, type ChartCandle, ChartInterval, Client, type Content, type CreateUserParams, type Deposit, type DepositToVaultParams, type DepositTokenParams, EndpointsV1, type ErrorResponse, type ExchangeConfig, ExchangeProxies, type Fees, type FundingCheckpoint, type FundingRate, GLOBAL_DENOMINATOR, type GetBorrowLendingDataResponse, type GetChartCandlesInRangeRequest, type GetChartCandlesInRangeResponse, type GetPerpMarketsDataRequest, type GetPerpMarketsDataResponse, type GetPerpOrderBookDataRequest, type GetPerpOrderBookDataResponse, type GetPerpetualMarketsConfigResponse, type GetPriceIndexesResponse, type GetTokensConfigResponse, type GetUserDataRequest, type GetUserDataResponse, type GetUsersByAddressRequest, type GetUsersByAddressResponse, type IGetChartCandlesInRange, type Lend, type LendTokenParams, type MarginStep, Network, type OracleUpdate, type OracleUpdates, type Order, type OrderFills, OrderSide, OrderStatus, OrderType, type OrderbookUpdate, type PaginationCursor, type PerpMarketData, type PerpOrderBookData, type PerpPosition, type PerpetualMarketConfigEntry, PerpetualMarketStatus, type PlacePerpLimitOrder, type PlacePerpLimitOrderParams, type PlacePerpMarketOrder, type PlacePerpMarketOrderParams, type PriceIndex, type RedeemTokenParams, type Referral, type RemoveApiKey, type RemoveApiKeyParams, type RepayBorrow, type SetAlias, type SetAliasNameParams, type SetAutolend, type SetAutolendParams, Status, type StatusResponse, type SubmitSponsoredTransactionRequest, type SubmitSponsoredTransactionResponse, TestFaucet, type TimeResponse, type TokenConfigEntry, type Topic, type Trade, TradeRole, type TradesUpdate, type User, UserStatus, type UtilizationCurve, type VaultInvestment, type Withdraw, type WithdrawFromVaultParams, type WithdrawLend, type WsCommand, type WsFill, type WsMessage, generateApiKey, getRandomId, getTopicFromCommand, getTopicFromMessage, sleep, toSystemValue };
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ import * as _thalalabs_surf_build_types_core from '@thalalabs/surf/build/types/c
4
4
  import * as _thalalabs_surf from '@thalalabs/surf';
5
5
  import WebSocket from 'isomorphic-ws';
6
6
 
7
+ type PaginationCursor = string;
7
8
  interface StatusResponse {
8
9
  status: string;
9
10
  }
@@ -29,6 +30,37 @@ interface BorrowLending {
29
30
  interface GetBorrowLendingDataResponse {
30
31
  data: Record<string, BorrowLending>;
31
32
  }
33
+ declare enum ChartInterval {
34
+ OneMinute = "OneMinute",
35
+ FiveMinutes = "FiveMinutes",
36
+ FifteenMinutes = "FifteenMinutes",
37
+ ThirtyMinutes = "ThirtyMinutes",
38
+ OneHour = "OneHour",
39
+ FourHours = "FourHours",
40
+ OneDay = "OneDay"
41
+ }
42
+ interface GetChartCandlesInRangeRequest {
43
+ marketName: string;
44
+ interval: ChartInterval;
45
+ startTimestamp: string;
46
+ endTimestamp: string;
47
+ paginationCursor?: PaginationCursor;
48
+ }
49
+ interface ChartCandle {
50
+ marketName: string;
51
+ open: string;
52
+ high: string;
53
+ low: string;
54
+ close: string;
55
+ volumeBase: string;
56
+ volumeQuote: string;
57
+ timestampOpen: string;
58
+ timestampClose: string;
59
+ }
60
+ interface GetChartCandlesInRangeResponse {
61
+ chartCandles: ChartCandle[];
62
+ paginationCursor?: PaginationCursor;
63
+ }
32
64
  interface GetPerpMarketsDataRequest {
33
65
  markets: string[];
34
66
  }
@@ -152,6 +184,7 @@ interface User {
152
184
  userId: string;
153
185
  alias: string;
154
186
  autolendEnabled: boolean;
187
+ ownerAddress: string;
155
188
  tokenBalances: Record<string, string>;
156
189
  positions: Record<string, PerpPosition>;
157
190
  perpOrders: Record<string, Order>;
@@ -167,6 +200,12 @@ interface GetUserDataResponse {
167
200
  userData: User;
168
201
  perpOrdersCount: string;
169
202
  }
203
+ interface GetUsersByAddressRequest {
204
+ userAddress: string;
205
+ }
206
+ interface GetUsersByAddressResponse {
207
+ users: User[];
208
+ }
170
209
  interface SubmitSponsoredTransactionRequest {
171
210
  sender: string;
172
211
  sequenceNumber: string;
@@ -307,6 +346,14 @@ interface SetAlias {
307
346
  userId: string;
308
347
  newAlias: string;
309
348
  }
349
+ interface AddApiKey {
350
+ userId: string;
351
+ apiKey: string;
352
+ }
353
+ interface RemoveApiKey {
354
+ userId: string;
355
+ apiKey: string;
356
+ }
310
357
  interface ErrorResponse {
311
358
  code: number;
312
359
  variant: string;
@@ -322,7 +369,9 @@ declare enum EndpointsV1 {
322
369
  GetPerpOrderBookData = "/v1/get_perp_orderbook_data",
323
370
  GetPerpMarketsData = "/v1/get_perp_markets_data",
324
371
  GetBorrowLendingData = "/v1/get_borrow_lending_data",
325
- SubmitSponsoredTransactionRequest = "/v1/submit_sponsored_transaction"
372
+ SubmitSponsoredTransactionRequest = "/v1/submit_sponsored_transaction",
373
+ GetChartCandlesInRange = "/v1/public/chart_candles_in_range",
374
+ GetUsersByAddress = "/v1/get_users_by_address"
326
375
  }
327
376
  declare enum AdminEndpoints {
328
377
  Placeholder = "/admin/placeholder"
@@ -437,6 +486,12 @@ type WsMessage = {
437
486
  } | {
438
487
  type: "SetAlias";
439
488
  content: SetAlias;
489
+ } | {
490
+ type: "AddApiKey";
491
+ content: AddApiKey;
492
+ } | {
493
+ type: "RemoveApiKey";
494
+ content: RemoveApiKey;
440
495
  };
441
496
  declare enum OrderStatus {
442
497
  Placed = "Placed",
@@ -500,6 +555,7 @@ declare class Client {
500
555
  cancelPerpOrders(params: CancelPerpOrdersParams): Promise<SubmitSponsoredTransactionResponse>;
501
556
  cancelAllPerpOrders(params: CancelAllPerpOrdersParams): Promise<SubmitSponsoredTransactionResponse>;
502
557
  setAutolend(params: SetAutolendParams): Promise<SubmitSponsoredTransactionResponse>;
558
+ depositTokenPayload(params: DepositTokenParams): Promise<_thalalabs_surf.EntryPayload>;
503
559
  depositToVault(params: DepositToVaultParams): Promise<SubmitSponsoredTransactionResponse>;
504
560
  withdrawFromVault(params: WithdrawFromVaultParams): Promise<SubmitSponsoredTransactionResponse>;
505
561
  redeemToken(params: RedeemTokenParams): Promise<SubmitSponsoredTransactionResponse>;
@@ -516,7 +572,9 @@ declare class Client {
516
572
  getPerpOrderBookData: (marketName: string) => Promise<GetPerpOrderBookDataResponse>;
517
573
  getPerpMarketsData: (markets: string[]) => Promise<GetPerpMarketsDataResponse>;
518
574
  getBorrowLendingData: () => Promise<GetBorrowLendingDataResponse>;
575
+ getChartCandlesInRange: ({ interval, marketName, endTime, startTime, cursor, }: IGetChartCandlesInRange) => Promise<void>;
519
576
  getPriceIndexes: () => Promise<GetPriceIndexesResponse>;
577
+ getUsersByAddress: (payload: GetUsersByAddressRequest) => Promise<GetUsersByAddressResponse>;
520
578
  }
521
579
  interface PlacePerpLimitOrderParams {
522
580
  userId: string;
@@ -568,6 +626,11 @@ interface DepositToVaultParams {
568
626
  vaultId: string;
569
627
  amount: string;
570
628
  }
629
+ interface DepositTokenParams {
630
+ userId: string;
631
+ amount: string;
632
+ tokenAddress: Address;
633
+ }
571
634
  interface WithdrawFromVaultParams {
572
635
  userId: string;
573
636
  vaultId: string;
@@ -586,6 +649,13 @@ interface LendTokenParams {
586
649
  amount: string;
587
650
  max: boolean;
588
651
  }
652
+ interface IGetChartCandlesInRange {
653
+ marketName: string;
654
+ interval: ChartInterval;
655
+ startTime?: number;
656
+ endTime?: number;
657
+ cursor?: PaginationCursor;
658
+ }
589
659
 
590
660
  declare const ExchangeProxies: {
591
661
  [key in Network]: string[];
@@ -608,4 +678,4 @@ declare const generateApiKey: () => _aptos_labs_ts_sdk.Ed25519Account;
608
678
  declare const getTopicFromCommand: (data: WsCommand) => string;
609
679
  declare const getTopicFromMessage: (data: WsMessage) => string;
610
680
 
611
- export { type AddApiKeyParams, type Address, AdminEndpoints, type BalanceChange, BaseEndpoints, type Borrow, type BorrowLending, type CancelAllPerpOrdersParams, type CancelPerpOrdersParams, type CanceledPerpOrders, Client, type Content, type CreateUserParams, type Deposit, type DepositToVaultParams, EndpointsV1, type ErrorResponse, type ExchangeConfig, ExchangeProxies, type Fees, type FundingCheckpoint, type FundingRate, GLOBAL_DENOMINATOR, type GetBorrowLendingDataResponse, type GetPerpMarketsDataRequest, type GetPerpMarketsDataResponse, type GetPerpOrderBookDataRequest, type GetPerpOrderBookDataResponse, type GetPerpetualMarketsConfigResponse, type GetPriceIndexesResponse, type GetTokensConfigResponse, type GetUserDataRequest, type GetUserDataResponse, type Lend, type LendTokenParams, type MarginStep, Network, type OracleUpdate, type OracleUpdates, type Order, type OrderFills, OrderSide, OrderStatus, OrderType, type OrderbookUpdate, type PerpMarketData, type PerpOrderBookData, type PerpPosition, type PerpetualMarketConfigEntry, PerpetualMarketStatus, type PlacePerpLimitOrder, type PlacePerpLimitOrderParams, type PlacePerpMarketOrder, type PlacePerpMarketOrderParams, type PriceIndex, type RedeemTokenParams, type Referral, type RemoveApiKeyParams, type RepayBorrow, type SetAlias, type SetAliasNameParams, type SetAutolend, type SetAutolendParams, Status, type StatusResponse, type SubmitSponsoredTransactionRequest, type SubmitSponsoredTransactionResponse, TestFaucet, type TimeResponse, type TokenConfigEntry, type Topic, type Trade, TradeRole, type TradesUpdate, type User, UserStatus, type UtilizationCurve, type VaultInvestment, type Withdraw, type WithdrawFromVaultParams, type WithdrawLend, type WsCommand, type WsFill, type WsMessage, generateApiKey, getRandomId, getTopicFromCommand, getTopicFromMessage, sleep, toSystemValue };
681
+ export { type AddApiKey, type AddApiKeyParams, type Address, AdminEndpoints, type BalanceChange, BaseEndpoints, type Borrow, type BorrowLending, type CancelAllPerpOrdersParams, type CancelPerpOrdersParams, type CanceledPerpOrders, type ChartCandle, ChartInterval, Client, type Content, type CreateUserParams, type Deposit, type DepositToVaultParams, type DepositTokenParams, EndpointsV1, type ErrorResponse, type ExchangeConfig, ExchangeProxies, type Fees, type FundingCheckpoint, type FundingRate, GLOBAL_DENOMINATOR, type GetBorrowLendingDataResponse, type GetChartCandlesInRangeRequest, type GetChartCandlesInRangeResponse, type GetPerpMarketsDataRequest, type GetPerpMarketsDataResponse, type GetPerpOrderBookDataRequest, type GetPerpOrderBookDataResponse, type GetPerpetualMarketsConfigResponse, type GetPriceIndexesResponse, type GetTokensConfigResponse, type GetUserDataRequest, type GetUserDataResponse, type GetUsersByAddressRequest, type GetUsersByAddressResponse, type IGetChartCandlesInRange, type Lend, type LendTokenParams, type MarginStep, Network, type OracleUpdate, type OracleUpdates, type Order, type OrderFills, OrderSide, OrderStatus, OrderType, type OrderbookUpdate, type PaginationCursor, type PerpMarketData, type PerpOrderBookData, type PerpPosition, type PerpetualMarketConfigEntry, PerpetualMarketStatus, type PlacePerpLimitOrder, type PlacePerpLimitOrderParams, type PlacePerpMarketOrder, type PlacePerpMarketOrderParams, type PriceIndex, type RedeemTokenParams, type Referral, type RemoveApiKey, type RemoveApiKeyParams, type RepayBorrow, type SetAlias, type SetAliasNameParams, type SetAutolend, type SetAutolendParams, Status, type StatusResponse, type SubmitSponsoredTransactionRequest, type SubmitSponsoredTransactionResponse, TestFaucet, type TimeResponse, type TokenConfigEntry, type Topic, type Trade, TradeRole, type TradesUpdate, type User, UserStatus, type UtilizationCurve, type VaultInvestment, type Withdraw, type WithdrawFromVaultParams, type WithdrawLend, type WsCommand, type WsFill, type WsMessage, generateApiKey, getRandomId, getTopicFromCommand, getTopicFromMessage, sleep, toSystemValue };
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import { v4 as uuidv4 } from "uuid";
5
5
 
6
6
  // generated_types/addApiKey.ts
7
7
  var ABI = {
8
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
8
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
9
9
  "name": "add_api_key",
10
10
  "friends": [],
11
11
  "exposed_functions": [
@@ -30,7 +30,7 @@ var addApiKey_default = ABI;
30
30
 
31
31
  // generated_types/cancelAllPerpOrders.ts
32
32
  var ABI2 = {
33
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
33
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
34
34
  "name": "cancel_all_perp_orders",
35
35
  "friends": [],
36
36
  "exposed_functions": [
@@ -53,7 +53,7 @@ var cancelAllPerpOrders_default = ABI2;
53
53
 
54
54
  // generated_types/cancelPerpOrders.ts
55
55
  var ABI3 = {
56
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
56
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
57
57
  "name": "cancel_perp_orders",
58
58
  "friends": [],
59
59
  "exposed_functions": [
@@ -78,7 +78,7 @@ var cancelPerpOrders_default = ABI3;
78
78
 
79
79
  // generated_types/createUser.ts
80
80
  var ABI4 = {
81
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
81
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
82
82
  "name": "create_user",
83
83
  "friends": [],
84
84
  "exposed_functions": [
@@ -103,7 +103,7 @@ var createUser_default = ABI4;
103
103
 
104
104
  // generated_types/depositToVault.ts
105
105
  var ABI5 = {
106
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
106
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
107
107
  "name": "deposit_to_vault",
108
108
  "friends": [],
109
109
  "exposed_functions": [
@@ -126,9 +126,34 @@ var ABI5 = {
126
126
  };
127
127
  var depositToVault_default = ABI5;
128
128
 
129
- // generated_types/lendToken.ts
129
+ // generated_types/depositToken.ts
130
130
  var ABI6 = {
131
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
131
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
132
+ "name": "deposit_token",
133
+ "friends": [],
134
+ "exposed_functions": [
135
+ {
136
+ "name": "deposit_token",
137
+ "visibility": "public",
138
+ "is_entry": true,
139
+ "is_view": false,
140
+ "generic_type_params": [],
141
+ "params": [
142
+ "&signer",
143
+ "u64",
144
+ "u64",
145
+ "0x1::object::Object<0x1::fungible_asset::Metadata>"
146
+ ],
147
+ "return": []
148
+ }
149
+ ],
150
+ "structs": []
151
+ };
152
+ var depositToken_default = ABI6;
153
+
154
+ // generated_types/lendToken.ts
155
+ var ABI7 = {
156
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
132
157
  "name": "lend_token",
133
158
  "friends": [],
134
159
  "exposed_functions": [
@@ -150,11 +175,11 @@ var ABI6 = {
150
175
  ],
151
176
  "structs": []
152
177
  };
153
- var lendToken_default = ABI6;
178
+ var lendToken_default = ABI7;
154
179
 
155
180
  // generated_types/placePerpLimitOrder.ts
156
- var ABI7 = {
157
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
181
+ var ABI8 = {
182
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
158
183
  "name": "place_perp_limit_order",
159
184
  "friends": [],
160
185
  "exposed_functions": [
@@ -178,11 +203,11 @@ var ABI7 = {
178
203
  ],
179
204
  "structs": []
180
205
  };
181
- var placePerpLimitOrder_default = ABI7;
206
+ var placePerpLimitOrder_default = ABI8;
182
207
 
183
208
  // generated_types/placePerpMarketOrder.ts
184
- var ABI8 = {
185
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
209
+ var ABI9 = {
210
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
186
211
  "name": "place_perp_market_order",
187
212
  "friends": [],
188
213
  "exposed_functions": [
@@ -205,11 +230,11 @@ var ABI8 = {
205
230
  ],
206
231
  "structs": []
207
232
  };
208
- var placePerpMarketOrder_default = ABI8;
233
+ var placePerpMarketOrder_default = ABI9;
209
234
 
210
235
  // generated_types/redeemToken.ts
211
- var ABI9 = {
212
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
236
+ var ABI10 = {
237
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
213
238
  "name": "redeem_token",
214
239
  "friends": [],
215
240
  "exposed_functions": [
@@ -231,11 +256,11 @@ var ABI9 = {
231
256
  ],
232
257
  "structs": []
233
258
  };
234
- var redeemToken_default = ABI9;
259
+ var redeemToken_default = ABI10;
235
260
 
236
261
  // generated_types/removeApiKey.ts
237
- var ABI10 = {
238
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
262
+ var ABI11 = {
263
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
239
264
  "name": "remove_api_key",
240
265
  "friends": [],
241
266
  "exposed_functions": [
@@ -255,11 +280,11 @@ var ABI10 = {
255
280
  ],
256
281
  "structs": []
257
282
  };
258
- var removeApiKey_default = ABI10;
283
+ var removeApiKey_default = ABI11;
259
284
 
260
285
  // generated_types/setAliasName.ts
261
- var ABI11 = {
262
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
286
+ var ABI12 = {
287
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
263
288
  "name": "set_alias_name",
264
289
  "friends": [],
265
290
  "exposed_functions": [
@@ -279,11 +304,11 @@ var ABI11 = {
279
304
  ],
280
305
  "structs": []
281
306
  };
282
- var setAliasName_default = ABI11;
307
+ var setAliasName_default = ABI12;
283
308
 
284
309
  // generated_types/setAutolend.ts
285
- var ABI12 = {
286
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
310
+ var ABI13 = {
311
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
287
312
  "name": "set_autolend",
288
313
  "friends": [],
289
314
  "exposed_functions": [
@@ -303,9 +328,19 @@ var ABI12 = {
303
328
  ],
304
329
  "structs": []
305
330
  };
306
- var setAutolend_default = ABI12;
331
+ var setAutolend_default = ABI13;
307
332
 
308
333
  // generated_types/typeshareTypes.ts
334
+ var ChartInterval = /* @__PURE__ */ ((ChartInterval3) => {
335
+ ChartInterval3["OneMinute"] = "OneMinute";
336
+ ChartInterval3["FiveMinutes"] = "FiveMinutes";
337
+ ChartInterval3["FifteenMinutes"] = "FifteenMinutes";
338
+ ChartInterval3["ThirtyMinutes"] = "ThirtyMinutes";
339
+ ChartInterval3["OneHour"] = "OneHour";
340
+ ChartInterval3["FourHours"] = "FourHours";
341
+ ChartInterval3["OneDay"] = "OneDay";
342
+ return ChartInterval3;
343
+ })(ChartInterval || {});
309
344
  var PerpetualMarketStatus = /* @__PURE__ */ ((PerpetualMarketStatus2) => {
310
345
  PerpetualMarketStatus2["Halted"] = "halted";
311
346
  PerpetualMarketStatus2["ReduceOnly"] = "reduceOnly";
@@ -329,6 +364,8 @@ var EndpointsV1 = /* @__PURE__ */ ((EndpointsV12) => {
329
364
  EndpointsV12["GetPerpMarketsData"] = "/v1/get_perp_markets_data";
330
365
  EndpointsV12["GetBorrowLendingData"] = "/v1/get_borrow_lending_data";
331
366
  EndpointsV12["SubmitSponsoredTransactionRequest"] = "/v1/submit_sponsored_transaction";
367
+ EndpointsV12["GetChartCandlesInRange"] = "/v1/public/chart_candles_in_range";
368
+ EndpointsV12["GetUsersByAddress"] = "/v1/get_users_by_address";
332
369
  return EndpointsV12;
333
370
  })(EndpointsV1 || {});
334
371
  var AdminEndpoints = /* @__PURE__ */ ((AdminEndpoints2) => {
@@ -366,8 +403,8 @@ var UserStatus = /* @__PURE__ */ ((UserStatus2) => {
366
403
  })(UserStatus || {});
367
404
 
368
405
  // generated_types/withdrawFromVault.ts
369
- var ABI13 = {
370
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
406
+ var ABI14 = {
407
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
371
408
  "name": "withdraw_from_vault",
372
409
  "friends": [],
373
410
  "exposed_functions": [
@@ -389,7 +426,7 @@ var ABI13 = {
389
426
  ],
390
427
  "structs": []
391
428
  };
392
- var withdrawFromVault_default = ABI13;
429
+ var withdrawFromVault_default = ABI14;
393
430
 
394
431
  // src/utils.ts
395
432
  import { Account } from "@aptos-labs/ts-sdk";
@@ -477,6 +514,10 @@ var getTopicFromMessage = (data) => {
477
514
  return data.content.userId;
478
515
  case "SetAlias":
479
516
  return data.content.userId;
517
+ case "AddApiKey":
518
+ return data.content.userId;
519
+ case "RemoveApiKey":
520
+ return data.content.userId;
480
521
  }
481
522
  };
482
523
 
@@ -597,10 +638,33 @@ var Client = class _Client {
597
638
  const response = await this.sendGetJson("/v1/get_borrow_lending_data" /* GetBorrowLendingData */);
598
639
  return response;
599
640
  };
641
+ this.getChartCandlesInRange = async ({
642
+ interval,
643
+ marketName,
644
+ endTime = Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3),
645
+ startTime = Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3 - 24 * 60 * 60 * 1e3),
646
+ // default 24 back
647
+ cursor
648
+ }) => {
649
+ if (endTime && startTime && endTime < startTime) {
650
+ throw new Error("endTime must be greater than startTime");
651
+ }
652
+ const response = await this.sendGetJson("/v1/public/chart_candles_in_range" /* GetChartCandlesInRange */, {
653
+ marketName,
654
+ interval,
655
+ startTimestamp: startTime.toString(),
656
+ endTimestamp: endTime.toString(),
657
+ paginationCursor: cursor
658
+ });
659
+ };
600
660
  this.getPriceIndexes = async () => {
601
661
  const response = await this.sendGetJson("/v1/get_price_indexes" /* GetPriceIndexes */);
602
662
  return response;
603
663
  };
664
+ this.getUsersByAddress = async (payload) => {
665
+ const response = await this.sendPostJson(payload, "/v1/get_users_by_address" /* GetUsersByAddress */);
666
+ return response;
667
+ };
604
668
  this._aptos = connection;
605
669
  this._surf = createSurfClient(this._aptos);
606
670
  this._apiKey = apiKey || generateApiKey();
@@ -858,6 +922,13 @@ var Client = class _Client {
858
922
  });
859
923
  return await this.submitSponsoredTransaction(tx, signature);
860
924
  }
925
+ async depositTokenPayload(params) {
926
+ return createEntryPayload(depositToken_default, {
927
+ function: "deposit_token",
928
+ functionArguments: [params.userId, params.amount, params.tokenAddress],
929
+ typeArguments: []
930
+ });
931
+ }
861
932
  async depositToVault(params) {
862
933
  const payload = createEntryPayload(depositToVault_default, {
863
934
  function: "deposit_to_vault",
@@ -948,8 +1019,8 @@ var client_default = Client;
948
1019
  import { createEntryPayload as createEntryPayload2 } from "@thalalabs/surf";
949
1020
 
950
1021
  // generated_types/faucetEntrypoints.ts
951
- var ABI14 = {
952
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
1022
+ var ABI15 = {
1023
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
953
1024
  "name": "faucet_entrypoints",
954
1025
  "friends": [],
955
1026
  "exposed_functions": [
@@ -980,11 +1051,11 @@ var ABI14 = {
980
1051
  ],
981
1052
  "structs": []
982
1053
  };
983
- var faucetEntrypoints_default = ABI14;
1054
+ var faucetEntrypoints_default = ABI15;
984
1055
 
985
1056
  // generated_types/testFaucet.ts
986
- var ABI15 = {
987
- "address": "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88",
1057
+ var ABI16 = {
1058
+ "address": "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63",
988
1059
  "name": "test_faucet",
989
1060
  "friends": [],
990
1061
  "exposed_functions": [
@@ -1021,7 +1092,7 @@ var ABI15 = {
1021
1092
  ],
1022
1093
  "return": [
1023
1094
  "0x1::object::ConstructorRef",
1024
- "0x1::object::Object<0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88::test_faucet::Token>"
1095
+ "0x1::object::Object<0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63::test_faucet::Token>"
1025
1096
  ]
1026
1097
  },
1027
1098
  {
@@ -1160,7 +1231,7 @@ var ABI15 = {
1160
1231
  "0x1::object::Object<0x1::fungible_asset::Metadata>"
1161
1232
  ],
1162
1233
  "return": [
1163
- "0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88::test_faucet::FaucetToken"
1234
+ "0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63::test_faucet::FaucetToken"
1164
1235
  ]
1165
1236
  }
1166
1237
  ],
@@ -1192,7 +1263,7 @@ var ABI15 = {
1192
1263
  "fields": [
1193
1264
  {
1194
1265
  "name": "tokens",
1195
- "type": "0x1::smart_table::SmartTable<vector<u8>, 0xf715b33c9eaf39e3960b4aff30469ea768a6e728b9d0025cc82e7f9b20100a88::test_faucet::FaucetToken>"
1266
+ "type": "0x1::smart_table::SmartTable<vector<u8>, 0xfe6358e4a03d5e15e0ad22acfcb7b6edbab97b38e2d5bb5aef278726b5a5cd63::test_faucet::FaucetToken>"
1196
1267
  }
1197
1268
  ]
1198
1269
  },
@@ -1217,7 +1288,7 @@ var ABI15 = {
1217
1288
  }
1218
1289
  ]
1219
1290
  };
1220
- var testFaucet_default = ABI15;
1291
+ var testFaucet_default = ABI16;
1221
1292
 
1222
1293
  // src/testFaucet.ts
1223
1294
  var TestFaucet = class _TestFaucet extends client_default {
@@ -1282,6 +1353,7 @@ var TestFaucet = class _TestFaucet extends client_default {
1282
1353
  export {
1283
1354
  AdminEndpoints,
1284
1355
  BaseEndpoints,
1356
+ ChartInterval,
1285
1357
  Client,
1286
1358
  EndpointsV1,
1287
1359
  ExchangeProxies,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nightlylabs/dex-sdk",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {