aftermath-ts-sdk 1.2.63 → 1.2.64-docs.1

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 (117) hide show
  1. package/README.md +61 -27
  2. package/dist/general/dynamicGas/dynamicGas.d.ts +34 -0
  3. package/dist/general/dynamicGas/dynamicGas.d.ts.map +1 -1
  4. package/dist/general/dynamicGas/dynamicGas.js +34 -0
  5. package/dist/general/dynamicGas/dynamicGasTypes.d.ts +25 -0
  6. package/dist/general/dynamicGas/dynamicGasTypes.d.ts.map +1 -1
  7. package/dist/general/prices/prices.d.ts +73 -0
  8. package/dist/general/prices/prices.d.ts.map +1 -1
  9. package/dist/general/prices/prices.js +73 -0
  10. package/dist/general/providers/aftermath.d.ts +106 -25
  11. package/dist/general/providers/aftermath.d.ts.map +1 -1
  12. package/dist/general/providers/aftermath.js +108 -27
  13. package/dist/general/providers/aftermathApi.d.ts +127 -8
  14. package/dist/general/providers/aftermathApi.d.ts.map +1 -1
  15. package/dist/general/providers/aftermathApi.js +132 -12
  16. package/dist/general/types/castingTypes.d.ts +0 -7
  17. package/dist/general/types/castingTypes.d.ts.map +1 -1
  18. package/dist/general/types/castingTypes.js +6 -0
  19. package/dist/general/types/generalTypes.d.ts +228 -7
  20. package/dist/general/types/generalTypes.d.ts.map +1 -1
  21. package/dist/general/types/suiTypes.d.ts +0 -16
  22. package/dist/general/types/suiTypes.d.ts.map +1 -1
  23. package/dist/general/types/suiTypes.js +3 -25
  24. package/dist/general/utils/casting.d.ts +159 -3
  25. package/dist/general/utils/casting.d.ts.map +1 -1
  26. package/dist/general/utils/casting.js +162 -16
  27. package/dist/general/utils/fixedUtils.d.ts +89 -2
  28. package/dist/general/utils/fixedUtils.d.ts.map +1 -1
  29. package/dist/general/utils/fixedUtils.js +81 -4
  30. package/dist/general/utils/helpers.d.ts +320 -9
  31. package/dist/general/utils/helpers.d.ts.map +1 -1
  32. package/dist/general/utils/helpers.js +350 -89
  33. package/dist/general/utils/iFixedUtils.d.ts +64 -0
  34. package/dist/general/utils/iFixedUtils.d.ts.map +1 -1
  35. package/dist/general/utils/iFixedUtils.js +64 -0
  36. package/dist/general/wallet/wallet.d.ts +75 -0
  37. package/dist/general/wallet/wallet.d.ts.map +1 -1
  38. package/dist/general/wallet/wallet.js +75 -5
  39. package/dist/packages/auth/auth.d.ts +113 -0
  40. package/dist/packages/auth/auth.d.ts.map +1 -1
  41. package/dist/packages/auth/auth.js +129 -15
  42. package/dist/packages/auth/authTypes.d.ts +66 -0
  43. package/dist/packages/auth/authTypes.d.ts.map +1 -1
  44. package/dist/packages/coin/api/coinApi.d.ts.map +1 -1
  45. package/dist/packages/coin/api/coinApi.js +28 -20
  46. package/dist/packages/coin/coin.d.ts +250 -0
  47. package/dist/packages/coin/coin.d.ts.map +1 -1
  48. package/dist/packages/coin/coin.js +238 -14
  49. package/dist/packages/coin/coinTypes.d.ts +93 -0
  50. package/dist/packages/coin/coinTypes.d.ts.map +1 -1
  51. package/dist/packages/dca/dca.d.ts +124 -35
  52. package/dist/packages/dca/dca.d.ts.map +1 -1
  53. package/dist/packages/dca/dca.js +127 -37
  54. package/dist/packages/dca/dcaTypes.d.ts +213 -28
  55. package/dist/packages/dca/dcaTypes.d.ts.map +1 -1
  56. package/dist/packages/farms/farms.d.ts +184 -1
  57. package/dist/packages/farms/farms.d.ts.map +1 -1
  58. package/dist/packages/farms/farms.js +185 -11
  59. package/dist/packages/farms/farmsStakedPosition.d.ts +140 -6
  60. package/dist/packages/farms/farmsStakedPosition.d.ts.map +1 -1
  61. package/dist/packages/farms/farmsStakedPosition.js +189 -144
  62. package/dist/packages/farms/farmsStakingPool.d.ts +161 -1
  63. package/dist/packages/farms/farmsStakingPool.d.ts.map +1 -1
  64. package/dist/packages/farms/farmsStakingPool.js +176 -70
  65. package/dist/packages/farms/farmsTypes.d.ts +283 -2
  66. package/dist/packages/farms/farmsTypes.d.ts.map +1 -1
  67. package/dist/packages/farms/farmsTypes.js +18 -0
  68. package/dist/packages/limitOrders/limitOrders.d.ts +108 -21
  69. package/dist/packages/limitOrders/limitOrders.d.ts.map +1 -1
  70. package/dist/packages/limitOrders/limitOrders.js +110 -22
  71. package/dist/packages/limitOrders/limitOrdersTypes.d.ts +142 -0
  72. package/dist/packages/limitOrders/limitOrdersTypes.d.ts.map +1 -1
  73. package/dist/packages/multisig/multisig.d.ts +33 -4
  74. package/dist/packages/multisig/multisig.d.ts.map +1 -1
  75. package/dist/packages/multisig/multisig.js +33 -4
  76. package/dist/packages/multisig/multisigTypes.d.ts +17 -0
  77. package/dist/packages/multisig/multisigTypes.d.ts.map +1 -1
  78. package/dist/packages/perpetuals/api/perpetualsApi.d.ts.map +1 -1
  79. package/dist/packages/pools/pool.d.ts +327 -85
  80. package/dist/packages/pools/pool.d.ts.map +1 -1
  81. package/dist/packages/pools/pool.js +333 -91
  82. package/dist/packages/pools/pools.d.ts +299 -37
  83. package/dist/packages/pools/pools.d.ts.map +1 -1
  84. package/dist/packages/pools/pools.js +306 -52
  85. package/dist/packages/pools/poolsTypes.d.ts +267 -2
  86. package/dist/packages/pools/poolsTypes.d.ts.map +1 -1
  87. package/dist/packages/referralVault/referralVault.d.ts +37 -0
  88. package/dist/packages/referralVault/referralVault.d.ts.map +1 -1
  89. package/dist/packages/referralVault/referralVault.js +37 -0
  90. package/dist/packages/router/router.d.ts +213 -17
  91. package/dist/packages/router/router.d.ts.map +1 -1
  92. package/dist/packages/router/router.js +214 -18
  93. package/dist/packages/router/routerTypes.d.ts +198 -14
  94. package/dist/packages/router/routerTypes.d.ts.map +1 -1
  95. package/dist/packages/staking/staking.d.ts +301 -43
  96. package/dist/packages/staking/staking.d.ts.map +1 -1
  97. package/dist/packages/staking/staking.js +308 -51
  98. package/dist/packages/staking/stakingTypes.d.ts +426 -6
  99. package/dist/packages/staking/stakingTypes.d.ts.map +1 -1
  100. package/dist/packages/staking/stakingTypes.js +19 -0
  101. package/dist/packages/sui/sui.d.ts +39 -0
  102. package/dist/packages/sui/sui.d.ts.map +1 -1
  103. package/dist/packages/sui/sui.js +39 -0
  104. package/dist/packages/userData/userData.d.ts +66 -12
  105. package/dist/packages/userData/userData.d.ts.map +1 -1
  106. package/dist/packages/userData/userData.js +66 -12
  107. package/dist/packages/userData/userDataTypes.d.ts +19 -0
  108. package/dist/packages/userData/userDataTypes.d.ts.map +1 -1
  109. package/dist/types.d.ts.map +1 -1
  110. package/dist/types.js +0 -1
  111. package/package.json +1 -1
  112. package/dist/general/historicalData/historicalData.d.ts +0 -15
  113. package/dist/general/historicalData/historicalData.d.ts.map +0 -1
  114. package/dist/general/historicalData/historicalData.js +0 -45
  115. package/dist/general/historicalData/historicalDataTypes.d.ts +0 -10
  116. package/dist/general/historicalData/historicalDataTypes.d.ts.map +0 -1
  117. package/dist/general/historicalData/historicalDataTypes.js +0 -2
@@ -1,52 +1,138 @@
1
- import { CallerConfig, ObjectId } from "../../types";
1
+ import { CallerConfig, ObjectId, SuiAddress } from "../../types";
2
2
  import { Caller } from "../../general/utils/caller";
3
- import { SuiAddress } from "../../types";
4
3
  import { ApiDCAsOwnedBody, ApiDcaTransactionForCreateOrderBody, ApiDcaTransactionForCloseOrderBody, DcaOrderObject, DcaOrdersObject, ApiDcaCreateUserBody } from "./dcaTypes";
5
4
  import { Transaction } from "@mysten/sui/transactions";
5
+ /**
6
+ * The `Dca` class provides functionality for automating Dollar-Cost Averaging
7
+ * (DCA) strategies on the Aftermath platform. It allows you to create, query,
8
+ * and close DCA orders that execute periodic trades based on user-defined
9
+ * parameters.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const afSdk = new Aftermath("MAINNET");
14
+ * await afSdk.init(); // initialize provider
15
+ *
16
+ * const dca = afSdk.Dca();
17
+ * ```
18
+ */
6
19
  export declare class Dca extends Caller {
20
+ /**
21
+ * Contains static values related to DCA on the Aftermath platform, such as
22
+ * default gas usage for DCA transactions.
23
+ */
7
24
  static readonly constants: {
25
+ /**
26
+ * The default gas budget for DCA-related transactions (50 SUI).
27
+ */
8
28
  gasAmount: bigint;
9
29
  };
30
+ /**
31
+ * Creates a new instance of the `Dca` class, responsible for
32
+ * managing DCA orders (querying, creating, closing).
33
+ *
34
+ * @param config - Optional caller configuration, such as network and access token.
35
+ */
10
36
  constructor(config?: CallerConfig);
11
37
  /**
12
- * Fetches the API for dollar cost averaging orders list.
13
- * @deprecated please use `getActiveDcaOrders` and `getPastDcaOrders` instead
38
+ * **Deprecated**. Fetches both active and past DCA orders for a given user in one response.
39
+ * Use `getActiveDcaOrders` and `getPastDcaOrders` for a more explicit approach.
40
+ *
41
+ * @param inputs - Object containing the user's `walletAddress`.
42
+ * @returns A `DcaOrdersObject` grouping active and past orders.
43
+ *
44
+ * @deprecated Please use `getActiveDcaOrders` & `getPastDcaOrders` instead.
45
+ * @example
46
+ * ```typescript
47
+ * // Old usage:
48
+ * const allOrders = await dca.getAllDcaOrders({ walletAddress: "0x..." });
49
+ * console.log(allOrders.active, allOrders.past);
50
+ * ```
14
51
  */
15
52
  getAllDcaOrders(inputs: ApiDCAsOwnedBody): Promise<DcaOrdersObject>;
16
53
  /**
17
- * Fetches the API for dollar cost averaging active orders list.
18
- * @async
19
- * @param { ApiDCAsOwnedBody } inputs - An object containing the walletAddress.
20
- * @returns { Promise<DcaOrderObject[]> } A promise that resolves to object with array of fetched events for active dca's.
54
+ * Retrieves the currently active DCA orders for a specific user.
55
+ *
56
+ * @param inputs - An object containing the user's `walletAddress`.
57
+ * @returns A promise that resolves to an array of `DcaOrderObject` for the active orders.
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * const activeOrders = await dca.getActiveDcaOrders({ walletAddress: "0x..." });
62
+ * console.log(activeOrders); // Array of active DCA orders
63
+ * ```
21
64
  */
22
65
  getActiveDcaOrders(inputs: {
23
66
  walletAddress: SuiAddress;
24
67
  }): Promise<DcaOrderObject[]>;
25
68
  /**
26
- * Fetches the API for dollar cost averaging past orders list.
27
- * @async
28
- * @param { ApiDCAsOwnedBody } inputs - An object containing the walletAddress.
29
- * @returns { Promise<DcaOrderObject[]> } A promise that resolves to object with array of fetched events for past dca's.
69
+ * Retrieves the past (completed or canceled) DCA orders for a specific user.
70
+ *
71
+ * @param inputs - An object containing the user's `walletAddress`.
72
+ * @returns A promise that resolves to an array of `DcaOrderObject` for the past orders.
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * const pastOrders = await dca.getPastDcaOrders({ walletAddress: "0x..." });
77
+ * console.log(pastOrders); // Array of past DCA orders
78
+ * ```
30
79
  */
31
80
  getPastDcaOrders(inputs: {
32
81
  walletAddress: SuiAddress;
33
82
  }): Promise<DcaOrderObject[]>;
34
83
  /**
35
- * Fetches the API transaction for creating DCA order.
36
- * @param { ApiDcaTransactionForCreateOrderBody } inputs - The inputs for the transaction.
37
- * @returns { Promise<Transaction> } A promise that resolves with the API transaction.
84
+ * Builds a transaction block on the Aftermath API to create a new DCA order.
85
+ * The resulting `Transaction` can then be signed and executed by the user.
86
+ *
87
+ * @param inputs - The parameters describing the DCA order (coin types, amounts, frequency, etc.).
88
+ * @returns A `Transaction` object that can be signed and submitted to the Sui network.
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * const createOrderTx = await dca.getCreateDcaOrderTx({
93
+ * walletAddress: "0x<user>",
94
+ * allocateCoinType: "0x2::sui::SUI",
95
+ * allocateCoinAmount: BigInt(1_000_000_000),
96
+ * buyCoinType: "0x<coin>",
97
+ * frequencyMs: 3600000, // Every hour
98
+ * tradesAmount: 5,
99
+ * // ...other fields...
100
+ * });
101
+ * // sign & send the transaction
102
+ * ```
38
103
  */
39
104
  getCreateDcaOrderTx(inputs: ApiDcaTransactionForCreateOrderBody): Promise<Transaction>;
40
105
  /**
41
- * Fetches the API for canceling DCA order.
42
- * @param inputs - The inputs for the transaction.
43
- * @returns { Promise<boolean> } A promise that resolves with transaction execution status.
106
+ * Closes (cancels) an existing DCA order by sending a transaction with user signature.
107
+ * Typically used after generating a message to sign with `closeDcaOrdersMessageToSign`.
108
+ *
109
+ * @param inputs - Contains the user's `walletAddress`, plus the `bytes` and `signature` from message signing.
110
+ * @returns A boolean indicating success or failure (true if canceled).
111
+ *
112
+ * @example
113
+ * ```typescript
114
+ * const success = await dca.closeDcaOrder({
115
+ * walletAddress: "0x...",
116
+ * bytes: "0x<signed_bytes>",
117
+ * signature: "0x<signature>",
118
+ * });
119
+ * ```
44
120
  */
45
121
  closeDcaOrder(inputs: ApiDcaTransactionForCloseOrderBody): Promise<boolean>;
46
122
  /**
47
- * Method for getting the cancellation dca order message to sign.
48
- * @param inputs - The inputs for the message.
49
- * @returns Message to sign.
123
+ * Generates a JSON object representing the message to sign for canceling one or more DCA orders.
124
+ * The user can sign this message (converted to bytes) locally, then submit the signature to
125
+ * `closeDcaOrder`.
126
+ *
127
+ * @param inputs - An object containing `orderIds`, an array of order object IDs to cancel.
128
+ * @returns An object with `action: "CANCEL_DCA_ORDERS"` and the `order_object_ids`.
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * const msg = dca.closeDcaOrdersMessageToSign({ orderIds: ["0x<order1>", "0x<order2>"] });
133
+ * console.log(msg);
134
+ * // sign this as JSON or string-encode, then pass to closeDcaOrder
135
+ * ```
50
136
  */
51
137
  closeDcaOrdersMessageToSign(inputs: {
52
138
  orderIds: ObjectId[];
@@ -55,30 +141,33 @@ export declare class Dca extends Caller {
55
141
  order_object_ids: string[];
56
142
  };
57
143
  /**
58
- * Method for getting the creation user message to sign.
59
- * @param inputs - The inputs for the message.
60
- * @returns Message to sign.
61
- * @deprecated please use method from `userData` package instead
144
+ * **Deprecated**. Generates a message object used in older flows to create
145
+ * a DCA user account. Use the `userData` package for user key storage or account creation.
146
+ *
147
+ * @deprecated Please use method from `userData` package instead.
148
+ * @returns An object with `action: "CREATE_DCA_ACCOUNT"`.
62
149
  */
63
150
  createUserAccountMessageToSign(): {
64
151
  action: string;
65
152
  };
66
153
  /**
67
- * Fetches the API for users public key.
68
- * @async
69
- * @param { ApiDCAsOwnedBody } inputs - An object containing the walletAddress.
70
- * @returns { Promise<string | undefined> } A promise that resolves users public key.
71
- * @deprecated please use method `getUserPublicKey` from `userData` package instead
154
+ * **Deprecated**. Fetches the user's public key from the older DCA system.
155
+ * Please use `getUserPublicKey` from the `userData` package instead.
156
+ *
157
+ * @deprecated Use `userData` package method instead
158
+ * @param inputs - Contains the user's `walletAddress`.
159
+ * @returns The public key as a string or `undefined`.
72
160
  */
73
161
  getUserPublicKey(inputs: {
74
162
  walletAddress: SuiAddress;
75
163
  }): Promise<string | undefined>;
76
164
  /**
77
- * Fetches the API to create users public key.
78
- * @async
79
- * @param { ApiDcaCreateUserBody } inputs - The inputs for creating users public key on BE side.
80
- * @returns { Promise<boolean> } A promise that resolves to result if user pk has been created.
81
- * @deprecated please use method `createUserPublicKey` from `userData` package instead
165
+ * **Deprecated**. Creates the user's public key in the older DCA system.
166
+ * Please use `createUserPublicKey` from the `userData` package instead.
167
+ *
168
+ * @deprecated Use `userData` package method instead
169
+ * @param inputs - Body containing the user address, bytes, and signature.
170
+ * @returns `true` if the public key was successfully stored, otherwise `false`.
82
171
  */
83
172
  createUserPublicKey(inputs: ApiDcaCreateUserBody): Promise<boolean>;
84
173
  }
@@ -1 +1 @@
1
- {"version":3,"file":"dca.d.ts","sourceRoot":"","sources":["../../../src/packages/dca/dca.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACN,gBAAgB,EAChB,mCAAmC,EACnC,kCAAkC,EAClC,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,qBAAa,GAAI,SAAQ,MAAM;IAK9B,gBAAuB,SAAS;;MAE9B;gBAMU,MAAM,CAAC,EAAE,YAAY;IAQjC;;;OAGG;IAEU,eAAe,CAAC,MAAM,EAAE,gBAAgB;IAOrD;;;;;OAKG;IAEU,kBAAkB,CAAC,MAAM,EAAE;QAAE,aAAa,EAAE,UAAU,CAAA;KAAE;IAOrE;;;;;OAKG;IAEU,gBAAgB,CAAC,MAAM,EAAE;QAAE,aAAa,EAAE,UAAU,CAAA;KAAE;IAWnE;;;;OAIG;IAEU,mBAAmB,CAC/B,MAAM,EAAE,mCAAmC,GACzC,OAAO,CAAC,WAAW,CAAC;IAOvB;;;;OAIG;IAEU,aAAa,CACzB,MAAM,EAAE,kCAAkC,GACxC,OAAO,CAAC,OAAO,CAAC;IAWnB;;;;OAIG;IAEI,2BAA2B,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,QAAQ,EAAE,CAAA;KAAE,GAAG;QACrE,MAAM,EAAE,MAAM,CAAC;QACf,gBAAgB,EAAE,MAAM,EAAE,CAAC;KAC3B;IAWD;;;;;OAKG;IAEI,8BAA8B,IAAI;QACxC,MAAM,EAAE,MAAM,CAAC;KACf;IAUD;;;;;;OAMG;IAEU,gBAAgB,CAAC,MAAM,EAAE;QACrC,aAAa,EAAE,UAAU,CAAC;KAC1B,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAS/B;;;;;;OAMG;IAEU,mBAAmB,CAC/B,MAAM,EAAE,oBAAoB,GAC1B,OAAO,CAAC,OAAO,CAAC;CAMnB"}
1
+ {"version":3,"file":"dca.d.ts","sourceRoot":"","sources":["../../../src/packages/dca/dca.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EACN,gBAAgB,EAChB,mCAAmC,EACnC,kCAAkC,EAClC,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD;;;;;;;;;;;;;GAaG;AACH,qBAAa,GAAI,SAAQ,MAAM;IAK9B;;;OAGG;IACH,gBAAuB,SAAS;QAC/B;;WAEG;;MAEF;IAMF;;;;;OAKG;gBACS,MAAM,CAAC,EAAE,YAAY;IAQjC;;;;;;;;;;;;;;OAcG;IACU,eAAe,CAAC,MAAM,EAAE,gBAAgB;IAOrD;;;;;;;;;;;OAWG;IACU,kBAAkB,CAAC,MAAM,EAAE;QAAE,aAAa,EAAE,UAAU,CAAA;KAAE;IAOrE;;;;;;;;;;;OAWG;IACU,gBAAgB,CAAC,MAAM,EAAE;QAAE,aAAa,EAAE,UAAU,CAAA;KAAE;IAWnE;;;;;;;;;;;;;;;;;;;;OAoBG;IACU,mBAAmB,CAC/B,MAAM,EAAE,mCAAmC,GACzC,OAAO,CAAC,WAAW,CAAC;IAOvB;;;;;;;;;;;;;;;OAeG;IACU,aAAa,CACzB,MAAM,EAAE,kCAAkC,GACxC,OAAO,CAAC,OAAO,CAAC;IAWnB;;;;;;;;;;;;;;OAcG;IACI,2BAA2B,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,QAAQ,EAAE,CAAA;KAAE,GAAG;QACrE,MAAM,EAAE,MAAM,CAAC;QACf,gBAAgB,EAAE,MAAM,EAAE,CAAC;KAC3B;IAWD;;;;;;OAMG;IACI,8BAA8B,IAAI;QACxC,MAAM,EAAE,MAAM,CAAC;KACf;IAUD;;;;;;;OAOG;IACU,gBAAgB,CAAC,MAAM,EAAE;QACrC,aAAa,EAAE,UAAU,CAAC;KAC1B,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAS/B;;;;;;;OAOG;IACU,mBAAmB,CAC/B,MAAM,EAAE,oBAAoB,GAC1B,OAAO,CAAC,OAAO,CAAC;CAMnB"}
@@ -11,10 +11,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Dca = void 0;
13
13
  const caller_1 = require("../../general/utils/caller");
14
+ /**
15
+ * The `Dca` class provides functionality for automating Dollar-Cost Averaging
16
+ * (DCA) strategies on the Aftermath platform. It allows you to create, query,
17
+ * and close DCA orders that execute periodic trades based on user-defined
18
+ * parameters.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const afSdk = new Aftermath("MAINNET");
23
+ * await afSdk.init(); // initialize provider
24
+ *
25
+ * const dca = afSdk.Dca();
26
+ * ```
27
+ */
14
28
  class Dca extends caller_1.Caller {
15
29
  // =========================================================================
16
30
  // Constructor
17
31
  // =========================================================================
32
+ /**
33
+ * Creates a new instance of the `Dca` class, responsible for
34
+ * managing DCA orders (querying, creating, closing).
35
+ *
36
+ * @param config - Optional caller configuration, such as network and access token.
37
+ */
18
38
  constructor(config) {
19
39
  super(config, "dca");
20
40
  }
@@ -22,8 +42,19 @@ class Dca extends caller_1.Caller {
22
42
  // Class Objects
23
43
  // =========================================================================
24
44
  /**
25
- * Fetches the API for dollar cost averaging orders list.
26
- * @deprecated please use `getActiveDcaOrders` and `getPastDcaOrders` instead
45
+ * **Deprecated**. Fetches both active and past DCA orders for a given user in one response.
46
+ * Use `getActiveDcaOrders` and `getPastDcaOrders` for a more explicit approach.
47
+ *
48
+ * @param inputs - Object containing the user's `walletAddress`.
49
+ * @returns A `DcaOrdersObject` grouping active and past orders.
50
+ *
51
+ * @deprecated Please use `getActiveDcaOrders` & `getPastDcaOrders` instead.
52
+ * @example
53
+ * ```typescript
54
+ * // Old usage:
55
+ * const allOrders = await dca.getAllDcaOrders({ walletAddress: "0x..." });
56
+ * console.log(allOrders.active, allOrders.past);
57
+ * ```
27
58
  */
28
59
  getAllDcaOrders(inputs) {
29
60
  return __awaiter(this, void 0, void 0, function* () {
@@ -31,10 +62,16 @@ class Dca extends caller_1.Caller {
31
62
  });
32
63
  }
33
64
  /**
34
- * Fetches the API for dollar cost averaging active orders list.
35
- * @async
36
- * @param { ApiDCAsOwnedBody } inputs - An object containing the walletAddress.
37
- * @returns { Promise<DcaOrderObject[]> } A promise that resolves to object with array of fetched events for active dca's.
65
+ * Retrieves the currently active DCA orders for a specific user.
66
+ *
67
+ * @param inputs - An object containing the user's `walletAddress`.
68
+ * @returns A promise that resolves to an array of `DcaOrderObject` for the active orders.
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * const activeOrders = await dca.getActiveDcaOrders({ walletAddress: "0x..." });
73
+ * console.log(activeOrders); // Array of active DCA orders
74
+ * ```
38
75
  */
39
76
  getActiveDcaOrders(inputs) {
40
77
  return __awaiter(this, void 0, void 0, function* () {
@@ -42,10 +79,16 @@ class Dca extends caller_1.Caller {
42
79
  });
43
80
  }
44
81
  /**
45
- * Fetches the API for dollar cost averaging past orders list.
46
- * @async
47
- * @param { ApiDCAsOwnedBody } inputs - An object containing the walletAddress.
48
- * @returns { Promise<DcaOrderObject[]> } A promise that resolves to object with array of fetched events for past dca's.
82
+ * Retrieves the past (completed or canceled) DCA orders for a specific user.
83
+ *
84
+ * @param inputs - An object containing the user's `walletAddress`.
85
+ * @returns A promise that resolves to an array of `DcaOrderObject` for the past orders.
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * const pastOrders = await dca.getPastDcaOrders({ walletAddress: "0x..." });
90
+ * console.log(pastOrders); // Array of past DCA orders
91
+ * ```
49
92
  */
50
93
  getPastDcaOrders(inputs) {
51
94
  return __awaiter(this, void 0, void 0, function* () {
@@ -53,12 +96,28 @@ class Dca extends caller_1.Caller {
53
96
  });
54
97
  }
55
98
  // =========================================================================
56
- // Transactions
99
+ // Transactions
57
100
  // =========================================================================
58
101
  /**
59
- * Fetches the API transaction for creating DCA order.
60
- * @param { ApiDcaTransactionForCreateOrderBody } inputs - The inputs for the transaction.
61
- * @returns { Promise<Transaction> } A promise that resolves with the API transaction.
102
+ * Builds a transaction block on the Aftermath API to create a new DCA order.
103
+ * The resulting `Transaction` can then be signed and executed by the user.
104
+ *
105
+ * @param inputs - The parameters describing the DCA order (coin types, amounts, frequency, etc.).
106
+ * @returns A `Transaction` object that can be signed and submitted to the Sui network.
107
+ *
108
+ * @example
109
+ * ```typescript
110
+ * const createOrderTx = await dca.getCreateDcaOrderTx({
111
+ * walletAddress: "0x<user>",
112
+ * allocateCoinType: "0x2::sui::SUI",
113
+ * allocateCoinAmount: BigInt(1_000_000_000),
114
+ * buyCoinType: "0x<coin>",
115
+ * frequencyMs: 3600000, // Every hour
116
+ * tradesAmount: 5,
117
+ * // ...other fields...
118
+ * });
119
+ * // sign & send the transaction
120
+ * ```
62
121
  */
63
122
  getCreateDcaOrderTx(inputs) {
64
123
  return __awaiter(this, void 0, void 0, function* () {
@@ -66,9 +125,20 @@ class Dca extends caller_1.Caller {
66
125
  });
67
126
  }
68
127
  /**
69
- * Fetches the API for canceling DCA order.
70
- * @param inputs - The inputs for the transaction.
71
- * @returns { Promise<boolean> } A promise that resolves with transaction execution status.
128
+ * Closes (cancels) an existing DCA order by sending a transaction with user signature.
129
+ * Typically used after generating a message to sign with `closeDcaOrdersMessageToSign`.
130
+ *
131
+ * @param inputs - Contains the user's `walletAddress`, plus the `bytes` and `signature` from message signing.
132
+ * @returns A boolean indicating success or failure (true if canceled).
133
+ *
134
+ * @example
135
+ * ```typescript
136
+ * const success = await dca.closeDcaOrder({
137
+ * walletAddress: "0x...",
138
+ * bytes: "0x<signed_bytes>",
139
+ * signature: "0x<signature>",
140
+ * });
141
+ * ```
72
142
  */
73
143
  closeDcaOrder(inputs) {
74
144
  return __awaiter(this, void 0, void 0, function* () {
@@ -76,12 +146,22 @@ class Dca extends caller_1.Caller {
76
146
  });
77
147
  }
78
148
  // =========================================================================
79
- // Interactions
149
+ // Interactions
80
150
  // =========================================================================
81
151
  /**
82
- * Method for getting the cancellation dca order message to sign.
83
- * @param inputs - The inputs for the message.
84
- * @returns Message to sign.
152
+ * Generates a JSON object representing the message to sign for canceling one or more DCA orders.
153
+ * The user can sign this message (converted to bytes) locally, then submit the signature to
154
+ * `closeDcaOrder`.
155
+ *
156
+ * @param inputs - An object containing `orderIds`, an array of order object IDs to cancel.
157
+ * @returns An object with `action: "CANCEL_DCA_ORDERS"` and the `order_object_ids`.
158
+ *
159
+ * @example
160
+ * ```typescript
161
+ * const msg = dca.closeDcaOrdersMessageToSign({ orderIds: ["0x<order1>", "0x<order2>"] });
162
+ * console.log(msg);
163
+ * // sign this as JSON or string-encode, then pass to closeDcaOrder
164
+ * ```
85
165
  */
86
166
  closeDcaOrdersMessageToSign(inputs) {
87
167
  return {
@@ -90,13 +170,14 @@ class Dca extends caller_1.Caller {
90
170
  };
91
171
  }
92
172
  // =========================================================================
93
- // Interactions - Deprecated
173
+ // Interactions - Deprecated
94
174
  // =========================================================================
95
175
  /**
96
- * Method for getting the creation user message to sign.
97
- * @param inputs - The inputs for the message.
98
- * @returns Message to sign.
99
- * @deprecated please use method from `userData` package instead
176
+ * **Deprecated**. Generates a message object used in older flows to create
177
+ * a DCA user account. Use the `userData` package for user key storage or account creation.
178
+ *
179
+ * @deprecated Please use method from `userData` package instead.
180
+ * @returns An object with `action: "CREATE_DCA_ACCOUNT"`.
100
181
  */
101
182
  createUserAccountMessageToSign() {
102
183
  return {
@@ -104,14 +185,15 @@ class Dca extends caller_1.Caller {
104
185
  };
105
186
  }
106
187
  // =========================================================================
107
- // User Public Key
188
+ // User Public Key
108
189
  // =========================================================================
109
190
  /**
110
- * Fetches the API for users public key.
111
- * @async
112
- * @param { ApiDCAsOwnedBody } inputs - An object containing the walletAddress.
113
- * @returns { Promise<string | undefined> } A promise that resolves users public key.
114
- * @deprecated please use method `getUserPublicKey` from `userData` package instead
191
+ * **Deprecated**. Fetches the user's public key from the older DCA system.
192
+ * Please use `getUserPublicKey` from the `userData` package instead.
193
+ *
194
+ * @deprecated Use `userData` package method instead
195
+ * @param inputs - Contains the user's `walletAddress`.
196
+ * @returns The public key as a string or `undefined`.
115
197
  */
116
198
  getUserPublicKey(inputs) {
117
199
  return __awaiter(this, void 0, void 0, function* () {
@@ -119,11 +201,12 @@ class Dca extends caller_1.Caller {
119
201
  });
120
202
  }
121
203
  /**
122
- * Fetches the API to create users public key.
123
- * @async
124
- * @param { ApiDcaCreateUserBody } inputs - The inputs for creating users public key on BE side.
125
- * @returns { Promise<boolean> } A promise that resolves to result if user pk has been created.
126
- * @deprecated please use method `createUserPublicKey` from `userData` package instead
204
+ * **Deprecated**. Creates the user's public key in the older DCA system.
205
+ * Please use `createUserPublicKey` from the `userData` package instead.
206
+ *
207
+ * @deprecated Use `userData` package method instead
208
+ * @param inputs - Body containing the user address, bytes, and signature.
209
+ * @returns `true` if the public key was successfully stored, otherwise `false`.
127
210
  */
128
211
  createUserPublicKey(inputs) {
129
212
  return __awaiter(this, void 0, void 0, function* () {
@@ -135,6 +218,13 @@ exports.Dca = Dca;
135
218
  // =========================================================================
136
219
  // Constants
137
220
  // =========================================================================
221
+ /**
222
+ * Contains static values related to DCA on the Aftermath platform, such as
223
+ * default gas usage for DCA transactions.
224
+ */
138
225
  Dca.constants = {
226
+ /**
227
+ * The default gas budget for DCA-related transactions (50 SUI).
228
+ */
139
229
  gasAmount: BigInt(50000000),
140
230
  };