@decibeltrade/sdk 0.2.3 → 0.2.4

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 (68) hide show
  1. package/dist/abi/generate-abis.js +9 -44
  2. package/dist/abi/types.js +1 -2
  3. package/dist/admin.js +10 -14
  4. package/dist/base.js +20 -27
  5. package/dist/constants.js +36 -43
  6. package/dist/fee-pay.js +1 -4
  7. package/dist/gas/gas-price-manager.js +3 -7
  8. package/dist/index.js +10 -26
  9. package/dist/order-event.types.js +1 -2
  10. package/dist/order-status.js +16 -23
  11. package/dist/read/account-overview/account-overview.reader.js +5 -9
  12. package/dist/read/account-overview/account-overview.types.d.ts +7 -7
  13. package/dist/read/account-overview/account-overview.types.js +23 -29
  14. package/dist/read/base-reader.js +5 -9
  15. package/dist/read/candlesticks/candlesticks.reader.js +8 -12
  16. package/dist/read/candlesticks/candlesticks.types.js +14 -20
  17. package/dist/read/delegations/delegations.reader.js +4 -8
  18. package/dist/read/delegations/delegations.types.js +6 -12
  19. package/dist/read/index.js +50 -68
  20. package/dist/read/leaderboard/leaderboard.reader.js +6 -10
  21. package/dist/read/leaderboard/leaderboard.types.js +10 -13
  22. package/dist/read/market-contexts/market-contexts.reader.js +4 -8
  23. package/dist/read/market-contexts/market-contexts.types.js +11 -17
  24. package/dist/read/market-depth/market-depth.reader.js +9 -13
  25. package/dist/read/market-depth/market-depth.types.js +8 -14
  26. package/dist/read/market-prices/market-prices.reader.js +11 -15
  27. package/dist/read/market-prices/market-prices.types.js +22 -25
  28. package/dist/read/market-trades/market-trades.reader.js +8 -12
  29. package/dist/read/market-trades/market-trades.types.js +18 -21
  30. package/dist/read/markets/markets.reader.js +7 -11
  31. package/dist/read/markets/markets.types.js +32 -35
  32. package/dist/read/pagination.types.js +4 -11
  33. package/dist/read/portfolio-chart/portfolio-chart.reader.js +4 -8
  34. package/dist/read/portfolio-chart/portfolio-chart.types.js +5 -11
  35. package/dist/read/types.js +58 -75
  36. package/dist/read/user-active-twaps/user-active-twaps.reader.js +5 -9
  37. package/dist/read/user-active-twaps/user-active-twaps.types.js +18 -24
  38. package/dist/read/user-bulk-orders/user-bulk-orders.reader.js +5 -9
  39. package/dist/read/user-bulk-orders/user-bulk-orders.types.js +16 -22
  40. package/dist/read/user-funding-history/user-funding-history.reader.js +5 -9
  41. package/dist/read/user-funding-history/user-funding-history.types.js +13 -19
  42. package/dist/read/user-notifications/user-notifications.reader.js +4 -8
  43. package/dist/read/user-notifications/user-notifications.types.js +19 -25
  44. package/dist/read/user-open-orders/user-open-orders.reader.js +5 -9
  45. package/dist/read/user-open-orders/user-open-orders.types.js +27 -33
  46. package/dist/read/user-order-history/user-order-history.reader.js +5 -9
  47. package/dist/read/user-order-history/user-order-history.types.js +32 -38
  48. package/dist/read/user-positions/user-positions.reader.js +5 -9
  49. package/dist/read/user-positions/user-positions.types.d.ts +13 -13
  50. package/dist/read/user-positions/user-positions.types.js +21 -27
  51. package/dist/read/user-subaccounts/user-subaccounts.reader.js +4 -8
  52. package/dist/read/user-subaccounts/user-subaccounts.types.js +8 -14
  53. package/dist/read/user-trade-history/user-trade-history.reader.js +5 -9
  54. package/dist/read/user-trade-history/user-trade-history.types.js +18 -24
  55. package/dist/read/vaults/vaults.reader.js +6 -10
  56. package/dist/read/vaults/vaults.types.js +53 -59
  57. package/dist/read/ws-subscription.d.ts +1 -1
  58. package/dist/read/ws-subscription.js +12 -19
  59. package/dist/subaccount-types.js +4 -10
  60. package/dist/transaction-builder.js +11 -16
  61. package/dist/tsconfig.tsbuildinfo +1 -1
  62. package/dist/utils.js +34 -50
  63. package/dist/write.d.ts +2 -2
  64. package/dist/write.d.ts.map +1 -1
  65. package/dist/write.js +22 -26
  66. package/package.json +1 -1
  67. package/src/read/ws-subscription.ts +2 -2
  68. package/src/write.ts +3 -3
@@ -1,50 +1,15 @@
1
- "use strict";
2
1
  /**
3
2
  * ABI fetcher that gets all ABIs used by the Decibel SDK
4
3
  * Based on actual function calls found in the SDK source code
5
4
  */
6
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = k;
8
- var desc = Object.getOwnPropertyDescriptor(m, k);
9
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
- desc = { enumerable: true, get: function() { return m[k]; } };
11
- }
12
- Object.defineProperty(o, k2, desc);
13
- }) : (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- o[k2] = m[k];
16
- }));
17
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
- Object.defineProperty(o, "default", { enumerable: true, value: v });
19
- }) : function(o, v) {
20
- o["default"] = v;
21
- });
22
- var __importStar = (this && this.__importStar) || (function () {
23
- var ownKeys = function(o) {
24
- ownKeys = Object.getOwnPropertyNames || function (o) {
25
- var ar = [];
26
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
- return ar;
28
- };
29
- return ownKeys(o);
30
- };
31
- return function (mod) {
32
- if (mod && mod.__esModule) return mod;
33
- var result = {};
34
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
- __setModuleDefault(result, mod);
36
- return result;
37
- };
38
- })();
39
- Object.defineProperty(exports, "__esModule", { value: true });
40
- const ts_sdk_1 = require("@aptos-labs/ts-sdk");
41
- const fs = __importStar(require("fs"));
42
- const path = __importStar(require("path"));
43
- const constants_1 = require("../constants");
5
+ import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
6
+ import * as fs from "fs";
7
+ import * as path from "path";
8
+ import { NETNA_CONFIG, TESTNET_CONFIG } from "../constants";
44
9
  // @Todo: There should be a global config that takes care of config across all the packages and apps
45
10
  // @Todo: Generate ABIs for all the networks as well, or as per global config depending upon how that will work
46
11
  // Remove NETNA_CONFIG and use getSdkConfig() instead once we implement it as a global config
47
- const CONFIGS = [constants_1.NETNA_CONFIG, constants_1.TESTNET_CONFIG];
12
+ const CONFIGS = [NETNA_CONFIG, TESTNET_CONFIG];
48
13
  // All modules used in the SDK (extracted from source code analysis)
49
14
  const SDK_MODULES = [
50
15
  "admin_apis",
@@ -60,9 +25,9 @@ const SDK_MODULES = [
60
25
  */
61
26
  function getAbiFilename(config) {
62
27
  // For CUSTOM networks, use a more descriptive name based on the config
63
- if (config.network === ts_sdk_1.Network.CUSTOM) {
28
+ if (config.network === Network.CUSTOM) {
64
29
  // Check if it's NETNA by comparing package address or other unique identifier
65
- if (config.deployment.package === constants_1.NETNA_CONFIG.deployment.package) {
30
+ if (config.deployment.package === NETNA_CONFIG.deployment.package) {
66
31
  return "json/netna.json";
67
32
  }
68
33
  return "json/custom.json";
@@ -80,13 +45,13 @@ async function fetchAllAbis(config) {
80
45
  console.error("❌ Error: config.package or CONFIG.fullnodeUrl is not set");
81
46
  process.exit(1);
82
47
  }
83
- const aptosConfig = new ts_sdk_1.AptosConfig({
48
+ const aptosConfig = new AptosConfig({
84
49
  network: config.network,
85
50
  fullnode: config.fullnodeUrl,
86
51
  });
87
52
  const abis = {};
88
53
  const errors = [];
89
- const aptos = new ts_sdk_1.Aptos(aptosConfig);
54
+ const aptos = new Aptos(aptosConfig);
90
55
  // Fetch entire modules at once (much more efficient!)
91
56
  for (const module of SDK_MODULES) {
92
57
  try {
package/dist/abi/types.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/dist/admin.js CHANGED
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DecibelAdminDex = void 0;
4
- const ts_sdk_1 = require("@aptos-labs/ts-sdk");
5
- const base_1 = require("./base");
6
- const constants_1 = require("./constants");
7
- const utils_1 = require("./utils");
8
- class DecibelAdminDex extends base_1.BaseSDK {
1
+ import { AccountAddress, createObjectAddress } from "@aptos-labs/ts-sdk";
2
+ import { BaseSDK } from "./base";
3
+ import { getVaultApiModule } from "./constants";
4
+ import { getMarketAddr } from "./utils";
5
+ export class DecibelAdminDex extends BaseSDK {
9
6
  /**
10
7
  * Initialize the global vault system. Only callable by the admin account.
11
8
  */
@@ -17,12 +14,12 @@ class DecibelAdminDex extends base_1.BaseSDK {
17
14
  });
18
15
  }
19
16
  getProtocolVaultAddress() {
20
- const vaultConfigObjectAddr = (0, ts_sdk_1.createObjectAddress)(ts_sdk_1.AccountAddress.fromString(this.config.deployment.package), "GlobalVaultConfig");
21
- const protocolVaultObjectAddr = (0, ts_sdk_1.createObjectAddress)(vaultConfigObjectAddr, "Decibel Protocol Vault");
17
+ const vaultConfigObjectAddr = createObjectAddress(AccountAddress.fromString(this.config.deployment.package), "GlobalVaultConfig");
18
+ const protocolVaultObjectAddr = createObjectAddress(vaultConfigObjectAddr, "Decibel Protocol Vault");
22
19
  return protocolVaultObjectAddr;
23
20
  }
24
21
  async initializeProtocolVault(collateralTokenAddr, initialFunding) {
25
- const vaultApiModule = (0, constants_1.getVaultApiModule)(this.config.compatVersion);
22
+ const vaultApiModule = getVaultApiModule(this.config.compatVersion);
26
23
  return await this.sendTx({
27
24
  function: `${this.config.deployment.package}::${vaultApiModule}::create_and_fund_vault`,
28
25
  typeArguments: [],
@@ -144,7 +141,7 @@ class DecibelAdminDex extends base_1.BaseSDK {
144
141
  });
145
142
  }
146
143
  async updateInternalOraclePrice(marketName, oraclePrice) {
147
- const marketAddr = (0, utils_1.getMarketAddr)(marketName, this.config.deployment.perpEngineGlobal);
144
+ const marketAddr = getMarketAddr(marketName, this.config.deployment.perpEngineGlobal);
148
145
  return await this.sendTx({
149
146
  function: `${this.config.deployment.package}::admin_apis::update_mark_for_internal_oracle`,
150
147
  typeArguments: [],
@@ -152,7 +149,7 @@ class DecibelAdminDex extends base_1.BaseSDK {
152
149
  });
153
150
  }
154
151
  async updatePythOraclePrice(marketName, vaa) {
155
- const marketAddr = (0, utils_1.getMarketAddr)(marketName, this.config.deployment.perpEngineGlobal);
152
+ const marketAddr = getMarketAddr(marketName, this.config.deployment.perpEngineGlobal);
156
153
  return await this.sendTx({
157
154
  function: `${this.config.deployment.package}::admin_apis::update_mark_for_pyth_oracle`,
158
155
  typeArguments: [],
@@ -203,4 +200,3 @@ class DecibelAdminDex extends base_1.BaseSDK {
203
200
  return balance[0];
204
201
  }
205
202
  }
206
- exports.DecibelAdminDex = DecibelAdminDex;
package/dist/base.js CHANGED
@@ -1,29 +1,23 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.BaseSDK = void 0;
7
- const ts_sdk_1 = require("@aptos-labs/ts-sdk");
8
- const netna_json_1 = __importDefault(require("./abi/json/netna.json"));
9
- const testnet_json_1 = __importDefault(require("./abi/json/testnet.json"));
10
- const constants_1 = require("./constants");
11
- const fee_pay_1 = require("./fee-pay");
12
- const transaction_builder_1 = require("./transaction-builder");
13
- const utils_1 = require("./utils");
1
+ import { Aptos, AptosConfig, } from "@aptos-labs/ts-sdk";
2
+ import netnaAbis from "./abi/json/netna.json";
3
+ import testnetAbis from "./abi/json/testnet.json";
4
+ import { NETNA_CONFIG, TESTNET_CONFIG } from "./constants";
5
+ import { submitFeePaidTransaction } from "./fee-pay";
6
+ import { buildSimpleTransactionSync } from "./transaction-builder";
7
+ import { generateRandomReplayProtectionNonce, getPrimarySubaccountAddr } from "./utils";
14
8
  const chainIdToAbi = {};
15
- if (constants_1.NETNA_CONFIG.chainId)
16
- chainIdToAbi[constants_1.NETNA_CONFIG.chainId] = netna_json_1.default;
17
- if (constants_1.TESTNET_CONFIG.chainId)
18
- chainIdToAbi[constants_1.TESTNET_CONFIG.chainId] = testnet_json_1.default;
19
- class BaseSDK {
9
+ if (NETNA_CONFIG.chainId)
10
+ chainIdToAbi[NETNA_CONFIG.chainId] = netnaAbis;
11
+ if (TESTNET_CONFIG.chainId)
12
+ chainIdToAbi[TESTNET_CONFIG.chainId] = testnetAbis;
13
+ export class BaseSDK {
20
14
  config;
21
15
  account;
22
16
  aptos;
23
17
  skipSimulate;
24
18
  noFeePayer;
25
19
  chainId;
26
- abi = netna_json_1.default;
20
+ abi = netnaAbis;
27
21
  gasPriceManager;
28
22
  /**
29
23
  * Time delta in milliseconds to add to Date.now() for expiration timestamps.
@@ -41,15 +35,15 @@ class BaseSDK {
41
35
  this.abi = abi;
42
36
  }
43
37
  else {
44
- this.abi = netna_json_1.default;
38
+ this.abi = netnaAbis;
45
39
  console.warn("Using NETNA ABI for unsupported chain id, this might cause issues with the transaction builder");
46
40
  }
47
- const aptosConfig = new ts_sdk_1.AptosConfig({
41
+ const aptosConfig = new AptosConfig({
48
42
  network: config.network,
49
43
  fullnode: config.fullnodeUrl,
50
44
  clientConfig: { API_KEY: opts?.nodeApiKey },
51
45
  });
52
- this.aptos = new ts_sdk_1.Aptos(aptosConfig);
46
+ this.aptos = new Aptos(aptosConfig);
53
47
  this.skipSimulate = opts?.skipSimulate ?? false;
54
48
  this.noFeePayer = opts?.noFeePayer ?? false;
55
49
  this.chainId = config.chainId;
@@ -94,13 +88,13 @@ class BaseSDK {
94
88
  });
95
89
  }
96
90
  else {
97
- return await (0, fee_pay_1.submitFeePaidTransaction)(this.config, transaction, senderAuthenticator);
91
+ return await submitFeePaidTransaction(this.config, transaction, senderAuthenticator);
98
92
  }
99
93
  }
100
94
  async buildTx(payload, sender) {
101
95
  const functionAbi = "function" in payload ? this.getABI(payload.function) : undefined;
102
96
  const withFeePayer = !this.noFeePayer;
103
- const replayProtectionNonce = (0, utils_1.generateRandomReplayProtectionNonce)();
97
+ const replayProtectionNonce = generateRandomReplayProtectionNonce();
104
98
  // This should never happen, but just in case
105
99
  if (!replayProtectionNonce) {
106
100
  throw new Error("Unable to generate replayProtectionNonce");
@@ -120,7 +114,7 @@ class BaseSDK {
120
114
  // 1. Fetch from network, this is a fallback, should only happen if gasPriceManager is not set
121
115
  gasUnitPrice = (await this.aptos.getGasPriceEstimation()).gas_estimate;
122
116
  }
123
- transaction = (0, transaction_builder_1.buildSimpleTransactionSync)({
117
+ transaction = buildSimpleTransactionSync({
124
118
  aptosConfig: this.aptos.config,
125
119
  sender,
126
120
  data: payload,
@@ -173,7 +167,6 @@ class BaseSDK {
173
167
  }
174
168
  }
175
169
  getPrimarySubaccountAddress(addr) {
176
- return (0, utils_1.getPrimarySubaccountAddr)(addr, this.config);
170
+ return getPrimarySubaccountAddr(addr, this.config);
177
171
  }
178
172
  }
179
- exports.BaseSDK = BaseSDK;
package/dist/constants.js CHANGED
@@ -1,96 +1,89 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QUERY_PARAM_KEYS = exports.NAMED_CONFIGS = exports.DOCKER_CONFIG = exports.LOCAL_CONFIG = exports.TESTNET_CONFIG = exports.TESTNET_DEPLOYMENT = exports.NETNA_CONFIG = exports.NETNA_DEPLOYMENT = exports.DEFAULT_COMPAT_VERSION = exports.TESTNET_COMPAT_VERSION = exports.CompatVersion = void 0;
4
- exports.getUsdcAddress = getUsdcAddress;
5
- exports.getTestcAddress = getTestcAddress;
6
- exports.getPerpEngineGlobalAddress = getPerpEngineGlobalAddress;
7
- exports.getVaultApiModule = getVaultApiModule;
8
- const ts_sdk_1 = require("@aptos-labs/ts-sdk");
9
- function getUsdcAddress(publisherAddr) {
10
- return (0, ts_sdk_1.createObjectAddress)(ts_sdk_1.AccountAddress.fromString(publisherAddr), new TextEncoder().encode("USDC"));
1
+ import { AccountAddress, createObjectAddress, Network } from "@aptos-labs/ts-sdk";
2
+ export function getUsdcAddress(publisherAddr) {
3
+ return createObjectAddress(AccountAddress.fromString(publisherAddr), new TextEncoder().encode("USDC"));
11
4
  }
12
- function getTestcAddress(publisherAddr) {
13
- return (0, ts_sdk_1.createObjectAddress)(ts_sdk_1.AccountAddress.fromString(publisherAddr), new TextEncoder().encode("TESTC"));
5
+ export function getTestcAddress(publisherAddr) {
6
+ return createObjectAddress(AccountAddress.fromString(publisherAddr), new TextEncoder().encode("TESTC"));
14
7
  }
15
- function getPerpEngineGlobalAddress(publisherAddr) {
16
- return (0, ts_sdk_1.createObjectAddress)(ts_sdk_1.AccountAddress.fromString(publisherAddr), new TextEncoder().encode("GlobalPerpEngine"));
8
+ export function getPerpEngineGlobalAddress(publisherAddr) {
9
+ return createObjectAddress(AccountAddress.fromString(publisherAddr), new TextEncoder().encode("GlobalPerpEngine"));
17
10
  }
18
- var CompatVersion;
11
+ export var CompatVersion;
19
12
  (function (CompatVersion) {
20
13
  CompatVersion["V0_0"] = "v0.0";
21
14
  CompatVersion["V0_1"] = "v0.1";
22
15
  CompatVersion["V0_2"] = "v0.2";
23
16
  CompatVersion["V0_3"] = "v0.3";
24
- })(CompatVersion || (exports.CompatVersion = CompatVersion = {}));
25
- exports.TESTNET_COMPAT_VERSION = CompatVersion.V0_2;
26
- exports.DEFAULT_COMPAT_VERSION = CompatVersion.V0_3;
17
+ })(CompatVersion || (CompatVersion = {}));
18
+ export const TESTNET_COMPAT_VERSION = CompatVersion.V0_2;
19
+ export const DEFAULT_COMPAT_VERSION = CompatVersion.V0_3;
27
20
  const NETNA_PACKAGE = "0xb8a5788314451ce4d2fbbad32e1bad88d4184b73943b7fe5166eab93cf1a5a95";
28
- exports.NETNA_DEPLOYMENT = {
21
+ export const NETNA_DEPLOYMENT = {
29
22
  package: NETNA_PACKAGE,
30
23
  usdc: getUsdcAddress(NETNA_PACKAGE).toString(),
31
24
  testc: getTestcAddress(NETNA_PACKAGE).toString(),
32
25
  perpEngineGlobal: getPerpEngineGlobalAddress(NETNA_PACKAGE).toString(),
33
26
  };
34
- exports.NETNA_CONFIG = {
35
- network: ts_sdk_1.Network.CUSTOM,
27
+ export const NETNA_CONFIG = {
28
+ network: Network.CUSTOM,
36
29
  fullnodeUrl: "https://api.netna.aptoslabs.com/v1",
37
30
  tradingHttpUrl: "https://api.netna.aptoslabs.com/decibel",
38
31
  tradingWsUrl: "wss://api.netna.aptoslabs.com/decibel/ws",
39
32
  gasStationUrl: "https://fee-payer-dev-netna-us-central1-410192433417.us-central1.run.app",
40
- deployment: exports.NETNA_DEPLOYMENT,
33
+ deployment: NETNA_DEPLOYMENT,
41
34
  chainId: 207,
42
- compatVersion: exports.DEFAULT_COMPAT_VERSION,
35
+ compatVersion: DEFAULT_COMPAT_VERSION,
43
36
  };
44
37
  const TESTNET_PACKAGE = "0x9f830083a19fb8b87395983ca9edaea2b0379c97be6dfe234bb914e6c6672844";
45
- exports.TESTNET_DEPLOYMENT = {
38
+ export const TESTNET_DEPLOYMENT = {
46
39
  package: TESTNET_PACKAGE,
47
40
  usdc: getUsdcAddress(TESTNET_PACKAGE).toString(),
48
41
  testc: getTestcAddress(TESTNET_PACKAGE).toString(),
49
42
  perpEngineGlobal: getPerpEngineGlobalAddress(TESTNET_PACKAGE).toString(),
50
43
  };
51
- exports.TESTNET_CONFIG = {
52
- network: ts_sdk_1.Network.TESTNET,
44
+ export const TESTNET_CONFIG = {
45
+ network: Network.TESTNET,
53
46
  fullnodeUrl: "https://api.testnet.aptoslabs.com/v1",
54
47
  tradingHttpUrl: "https://api.testnet.aptoslabs.com/decibel",
55
48
  tradingWsUrl: "wss://api.testnet.aptoslabs.com/decibel/ws",
56
49
  gasStationUrl: "https://fee-payer-staging-testnet-us-central1-502735673999.us-central1.run.app",
57
- deployment: exports.TESTNET_DEPLOYMENT,
50
+ deployment: TESTNET_DEPLOYMENT,
58
51
  chainId: 2,
59
- compatVersion: exports.TESTNET_COMPAT_VERSION,
52
+ compatVersion: TESTNET_COMPAT_VERSION,
60
53
  };
61
- exports.LOCAL_CONFIG = {
62
- network: ts_sdk_1.Network.CUSTOM,
54
+ export const LOCAL_CONFIG = {
55
+ network: Network.CUSTOM,
63
56
  fullnodeUrl: "http://localhost:8080/v1",
64
57
  tradingHttpUrl: "http://localhost:8084",
65
58
  tradingWsUrl: "ws://localhost:8083",
66
59
  gasStationUrl: "http://localhost:8085",
67
- deployment: exports.NETNA_DEPLOYMENT,
68
- compatVersion: exports.DEFAULT_COMPAT_VERSION,
60
+ deployment: NETNA_DEPLOYMENT,
61
+ compatVersion: DEFAULT_COMPAT_VERSION,
69
62
  };
70
- exports.DOCKER_CONFIG = {
71
- network: ts_sdk_1.Network.CUSTOM,
63
+ export const DOCKER_CONFIG = {
64
+ network: Network.CUSTOM,
72
65
  fullnodeUrl: "http://tradenet:8080/v1",
73
66
  tradingHttpUrl: "http://trading-api-http:8080",
74
67
  // nosemgrep: javascript.lang.security.detect-insecure-websocket.detect-insecure-websocket
75
68
  tradingWsUrl: "ws://trading-api-ws:8080",
76
69
  gasStationUrl: "http://fee-payer:8080",
77
- deployment: exports.NETNA_DEPLOYMENT,
78
- compatVersion: exports.DEFAULT_COMPAT_VERSION,
70
+ deployment: NETNA_DEPLOYMENT,
71
+ compatVersion: DEFAULT_COMPAT_VERSION,
79
72
  };
80
- exports.NAMED_CONFIGS = {
81
- netna: exports.NETNA_CONFIG,
82
- local: exports.LOCAL_CONFIG,
83
- docker: exports.DOCKER_CONFIG,
84
- testnet: exports.TESTNET_CONFIG,
73
+ export const NAMED_CONFIGS = {
74
+ netna: NETNA_CONFIG,
75
+ local: LOCAL_CONFIG,
76
+ docker: DOCKER_CONFIG,
77
+ testnet: TESTNET_CONFIG,
85
78
  };
86
- exports.QUERY_PARAM_KEYS = {
79
+ export const QUERY_PARAM_KEYS = {
87
80
  offset: "offset",
88
81
  limit: "limit",
89
82
  sortKey: "sort_key",
90
83
  sortDir: "sort_dir",
91
84
  searchTerm: "search_term",
92
85
  };
93
- function getVaultApiModule(compatVersion) {
86
+ export function getVaultApiModule(compatVersion) {
94
87
  if (compatVersion === CompatVersion.V0_1) {
95
88
  return `vault`;
96
89
  }
package/dist/fee-pay.js CHANGED
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.submitFeePaidTransaction = submitFeePaidTransaction;
4
1
  /**
5
2
  * Submit a transaction with fee payer support
6
3
  * @param config The Decibel configuration containing the gas station URL
@@ -8,7 +5,7 @@ exports.submitFeePaidTransaction = submitFeePaidTransaction;
8
5
  * @param senderAuthenticator The sender's authenticator
9
6
  * @returns A promise that resolves to the pending transaction response
10
7
  */
11
- async function submitFeePaidTransaction(config, transaction, senderAuthenticator) {
8
+ export async function submitFeePaidTransaction(config, transaction, senderAuthenticator) {
12
9
  const signatureBcs = Array.from(senderAuthenticator.bcsToBytes());
13
10
  const transactionBcs = Array.from(transaction.rawTransaction.bcsToBytes());
14
11
  const body = JSON.stringify({
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GasPriceManager = void 0;
4
- const ts_sdk_1 = require("@aptos-labs/ts-sdk");
5
- class GasPriceManager {
1
+ import { Aptos, AptosConfig } from "@aptos-labs/ts-sdk";
2
+ export class GasPriceManager {
6
3
  gasPrice = null;
7
4
  intervalId = null;
8
5
  aptos;
@@ -10,7 +7,7 @@ class GasPriceManager {
10
7
  isInitialized = false;
11
8
  multiplier;
12
9
  constructor(config, opts) {
13
- this.aptos = new ts_sdk_1.Aptos(new ts_sdk_1.AptosConfig({
10
+ this.aptos = new Aptos(new AptosConfig({
14
11
  network: config.network,
15
12
  fullnode: config.fullnodeUrl,
16
13
  clientConfig: { API_KEY: opts?.nodeApiKey },
@@ -90,4 +87,3 @@ class GasPriceManager {
90
87
  }
91
88
  }
92
89
  }
93
- exports.GasPriceManager = GasPriceManager;
package/dist/index.js CHANGED
@@ -1,26 +1,10 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./admin"), exports);
18
- __exportStar(require("./constants"), exports);
19
- __exportStar(require("./fee-pay"), exports);
20
- __exportStar(require("./gas/gas-price-manager"), exports);
21
- __exportStar(require("./order-event.types"), exports);
22
- __exportStar(require("./order-status"), exports);
23
- __exportStar(require("./read/index"), exports);
24
- __exportStar(require("./subaccount-types"), exports);
25
- __exportStar(require("./utils"), exports);
26
- __exportStar(require("./write"), exports);
1
+ export * from "./admin";
2
+ export * from "./constants";
3
+ export * from "./fee-pay";
4
+ export * from "./gas/gas-price-manager";
5
+ export * from "./order-event.types";
6
+ export * from "./order-status";
7
+ export * from "./read/index";
8
+ export * from "./subaccount-types";
9
+ export * from "./utils";
10
+ export * from "./write";
@@ -1,3 +1,2 @@
1
- "use strict";
2
1
  // Type definitions for OrderEvent returned by placeOrder transactions
3
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ export {};
@@ -1,26 +1,20 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.OrderStatusClient = exports.OrderStatusSchema = void 0;
7
- const v4_1 = __importDefault(require("zod/v4"));
1
+ import z from "zod/v4";
8
2
  // Order status response schema
9
- exports.OrderStatusSchema = v4_1.default.object({
10
- parent: v4_1.default.string(),
11
- market: v4_1.default.string(),
12
- order_id: v4_1.default.string(),
13
- status: v4_1.default.string(),
14
- orig_size: v4_1.default.number(),
15
- remaining_size: v4_1.default.number(),
16
- size_delta: v4_1.default.number(),
17
- price: v4_1.default.number(),
18
- is_buy: v4_1.default.boolean(),
19
- details: v4_1.default.string(),
20
- transaction_version: v4_1.default.number(),
21
- unix_ms: v4_1.default.number(),
3
+ export const OrderStatusSchema = z.object({
4
+ parent: z.string(),
5
+ market: z.string(),
6
+ order_id: z.string(),
7
+ status: z.string(),
8
+ orig_size: z.number(),
9
+ remaining_size: z.number(),
10
+ size_delta: z.number(),
11
+ price: z.number(),
12
+ is_buy: z.boolean(),
13
+ details: z.string(),
14
+ transaction_version: z.number(),
15
+ unix_ms: z.number(),
22
16
  });
23
- class OrderStatusClient {
17
+ export class OrderStatusClient {
24
18
  config;
25
19
  constructor(config) {
26
20
  this.config = config;
@@ -39,7 +33,7 @@ class OrderStatusClient {
39
33
  throw new Error(`HTTP error! status: ${response.status}`);
40
34
  }
41
35
  const data = await response.json();
42
- return exports.OrderStatusSchema.parse(data);
36
+ return OrderStatusSchema.parse(data);
43
37
  }
44
38
  catch (error) {
45
39
  console.error("Error fetching order status:", error);
@@ -83,4 +77,3 @@ class OrderStatusClient {
83
77
  return this.isSuccessStatus(status) || this.isFailureStatus(status);
84
78
  }
85
79
  }
86
- exports.OrderStatusClient = OrderStatusClient;
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AccountOverviewReader = void 0;
4
- const base_reader_1 = require("../base-reader");
5
- const account_overview_types_1 = require("./account-overview.types");
6
- class AccountOverviewReader extends base_reader_1.BaseReader {
1
+ import { BaseReader } from "../base-reader";
2
+ import { AccountOverviewSchema, AccountOverviewWsMessageSchema, } from "./account-overview.types";
3
+ export class AccountOverviewReader extends BaseReader {
7
4
  /**
8
5
  * Get the account overview for a given user
9
6
  * @param subAddr The subaccount address to get the account overview for
@@ -15,7 +12,7 @@ class AccountOverviewReader extends base_reader_1.BaseReader {
15
12
  queryParams.set("volume_window", volumeWindow);
16
13
  }
17
14
  const response = await this.getRequest({
18
- schema: account_overview_types_1.AccountOverviewSchema,
15
+ schema: AccountOverviewSchema,
19
16
  url: `${this.deps.config.tradingHttpUrl}/api/v1/account_overviews`,
20
17
  queryParams,
21
18
  options: fetchOptions,
@@ -30,7 +27,6 @@ class AccountOverviewReader extends base_reader_1.BaseReader {
30
27
  */
31
28
  subscribeByAddr(subAddr, onData) {
32
29
  const topic = `account_overview:${subAddr}`;
33
- return this.deps.ws.subscribe(topic, account_overview_types_1.AccountOverviewWsMessageSchema, onData);
30
+ return this.deps.ws.subscribe(topic, AccountOverviewWsMessageSchema, onData);
34
31
  }
35
32
  }
36
- exports.AccountOverviewReader = AccountOverviewReader;
@@ -33,19 +33,19 @@ export declare const AccountOverviewSchema: z.ZodObject<{
33
33
  }, z.core.$strip>;
34
34
  export declare const AccountOverviewWsMessageSchema: z.ZodObject<{
35
35
  account_overview: z.ZodObject<{
36
- perp_equity_balance: z.ZodNumber;
36
+ all_time_return: z.ZodNullable<z.ZodNumber>;
37
+ sharpe_ratio: z.ZodNullable<z.ZodNumber>;
38
+ max_drawdown: z.ZodNullable<z.ZodNumber>;
39
+ weekly_win_rate_12w: z.ZodNullable<z.ZodNumber>;
40
+ pnl_90d: z.ZodNullable<z.ZodNumber>;
41
+ average_leverage: z.ZodNullable<z.ZodNumber>;
37
42
  unrealized_pnl: z.ZodNumber;
43
+ perp_equity_balance: z.ZodNumber;
38
44
  unrealized_funding_cost: z.ZodNumber;
39
45
  cross_margin_ratio: z.ZodNumber;
40
46
  maintenance_margin: z.ZodNumber;
41
47
  cross_account_leverage_ratio: z.ZodNullable<z.ZodNumber>;
42
- all_time_return: z.ZodNullable<z.ZodNumber>;
43
- pnl_90d: z.ZodNullable<z.ZodNumber>;
44
- sharpe_ratio: z.ZodNullable<z.ZodNumber>;
45
- max_drawdown: z.ZodNullable<z.ZodNumber>;
46
- weekly_win_rate_12w: z.ZodNullable<z.ZodNumber>;
47
48
  average_cash_position: z.ZodNullable<z.ZodNumber>;
48
- average_leverage: z.ZodNullable<z.ZodNumber>;
49
49
  cross_account_position: z.ZodNumber;
50
50
  total_margin: z.ZodNumber;
51
51
  usdc_cross_withdrawable_balance: z.ZodNumber;
@@ -1,36 +1,30 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.AccountOverviewWsMessageSchema = exports.AccountOverviewSchema = exports.VolumeWindow = void 0;
7
- const v4_1 = __importDefault(require("zod/v4"));
8
- exports.VolumeWindow = {
1
+ import z from "zod/v4";
2
+ export const VolumeWindow = {
9
3
  SevenDays: "7d",
10
4
  FourteenDays: "14d",
11
5
  ThirtyDays: "30d",
12
6
  NinetyDays: "90d",
13
7
  };
14
- exports.AccountOverviewSchema = v4_1.default.object({
15
- perp_equity_balance: v4_1.default.number(),
16
- unrealized_pnl: v4_1.default.number(),
17
- unrealized_funding_cost: v4_1.default.number(),
18
- cross_margin_ratio: v4_1.default.number(),
19
- maintenance_margin: v4_1.default.number(),
20
- cross_account_leverage_ratio: v4_1.default.number().nullable(),
21
- volume: v4_1.default.number().nullable(),
22
- all_time_return: v4_1.default.number().nullable(),
23
- pnl_90d: v4_1.default.number().nullable(),
24
- sharpe_ratio: v4_1.default.number().nullable(),
25
- max_drawdown: v4_1.default.number().nullable(),
26
- weekly_win_rate_12w: v4_1.default.number().nullable(),
27
- average_cash_position: v4_1.default.number().nullable(),
28
- average_leverage: v4_1.default.number().nullable(),
29
- cross_account_position: v4_1.default.number(),
30
- total_margin: v4_1.default.number(),
31
- usdc_cross_withdrawable_balance: v4_1.default.number(),
32
- usdc_isolated_withdrawable_balance: v4_1.default.number(),
8
+ export const AccountOverviewSchema = z.object({
9
+ perp_equity_balance: z.number(),
10
+ unrealized_pnl: z.number(),
11
+ unrealized_funding_cost: z.number(),
12
+ cross_margin_ratio: z.number(),
13
+ maintenance_margin: z.number(),
14
+ cross_account_leverage_ratio: z.number().nullable(),
15
+ volume: z.number().nullable(),
16
+ all_time_return: z.number().nullable(),
17
+ pnl_90d: z.number().nullable(),
18
+ sharpe_ratio: z.number().nullable(),
19
+ max_drawdown: z.number().nullable(),
20
+ weekly_win_rate_12w: z.number().nullable(),
21
+ average_cash_position: z.number().nullable(),
22
+ average_leverage: z.number().nullable(),
23
+ cross_account_position: z.number(),
24
+ total_margin: z.number(),
25
+ usdc_cross_withdrawable_balance: z.number(),
26
+ usdc_isolated_withdrawable_balance: z.number(),
33
27
  });
34
- exports.AccountOverviewWsMessageSchema = v4_1.default.object({
35
- account_overview: exports.AccountOverviewSchema.omit({ volume: true }),
28
+ export const AccountOverviewWsMessageSchema = z.object({
29
+ account_overview: AccountOverviewSchema.omit({ volume: true }),
36
30
  });