aftermath-ts-sdk 1.2.64 → 1.2.65
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/general/dynamicGas/dynamicGas.d.ts +34 -0
- package/dist/general/dynamicGas/dynamicGas.d.ts.map +1 -1
- package/dist/general/dynamicGas/dynamicGas.js +34 -0
- package/dist/general/dynamicGas/dynamicGasTypes.d.ts +25 -0
- package/dist/general/dynamicGas/dynamicGasTypes.d.ts.map +1 -1
- package/dist/general/prices/prices.d.ts +73 -0
- package/dist/general/prices/prices.d.ts.map +1 -1
- package/dist/general/prices/prices.js +73 -0
- package/dist/general/providers/aftermath.d.ts +106 -25
- package/dist/general/providers/aftermath.d.ts.map +1 -1
- package/dist/general/providers/aftermath.js +108 -27
- package/dist/general/providers/aftermathApi.d.ts +127 -8
- package/dist/general/providers/aftermathApi.d.ts.map +1 -1
- package/dist/general/providers/aftermathApi.js +132 -12
- package/dist/general/types/castingTypes.d.ts +0 -7
- package/dist/general/types/castingTypes.d.ts.map +1 -1
- package/dist/general/types/castingTypes.js +6 -0
- package/dist/general/types/generalTypes.d.ts +228 -7
- package/dist/general/types/generalTypes.d.ts.map +1 -1
- package/dist/general/types/suiTypes.d.ts +0 -16
- package/dist/general/types/suiTypes.d.ts.map +1 -1
- package/dist/general/types/suiTypes.js +3 -25
- package/dist/general/utils/casting.d.ts +159 -3
- package/dist/general/utils/casting.d.ts.map +1 -1
- package/dist/general/utils/casting.js +162 -16
- package/dist/general/utils/fixedUtils.d.ts +89 -2
- package/dist/general/utils/fixedUtils.d.ts.map +1 -1
- package/dist/general/utils/fixedUtils.js +81 -4
- package/dist/general/utils/helpers.d.ts +320 -9
- package/dist/general/utils/helpers.d.ts.map +1 -1
- package/dist/general/utils/helpers.js +350 -89
- package/dist/general/utils/iFixedUtils.d.ts +64 -0
- package/dist/general/utils/iFixedUtils.d.ts.map +1 -1
- package/dist/general/utils/iFixedUtils.js +64 -0
- package/dist/general/wallet/wallet.d.ts +75 -0
- package/dist/general/wallet/wallet.d.ts.map +1 -1
- package/dist/general/wallet/wallet.js +75 -5
- package/dist/packages/auth/auth.d.ts +113 -0
- package/dist/packages/auth/auth.d.ts.map +1 -1
- package/dist/packages/auth/auth.js +129 -15
- package/dist/packages/auth/authTypes.d.ts +66 -0
- package/dist/packages/auth/authTypes.d.ts.map +1 -1
- package/dist/packages/coin/coin.d.ts +250 -0
- package/dist/packages/coin/coin.d.ts.map +1 -1
- package/dist/packages/coin/coin.js +238 -14
- package/dist/packages/coin/coinTypes.d.ts +93 -0
- package/dist/packages/coin/coinTypes.d.ts.map +1 -1
- package/dist/packages/dca/dca.d.ts +124 -35
- package/dist/packages/dca/dca.d.ts.map +1 -1
- package/dist/packages/dca/dca.js +127 -37
- package/dist/packages/dca/dcaTypes.d.ts +213 -28
- package/dist/packages/dca/dcaTypes.d.ts.map +1 -1
- package/dist/packages/farms/farms.d.ts +184 -1
- package/dist/packages/farms/farms.d.ts.map +1 -1
- package/dist/packages/farms/farms.js +185 -11
- package/dist/packages/farms/farmsStakedPosition.d.ts +140 -6
- package/dist/packages/farms/farmsStakedPosition.d.ts.map +1 -1
- package/dist/packages/farms/farmsStakedPosition.js +189 -144
- package/dist/packages/farms/farmsStakingPool.d.ts +161 -1
- package/dist/packages/farms/farmsStakingPool.d.ts.map +1 -1
- package/dist/packages/farms/farmsStakingPool.js +176 -70
- package/dist/packages/farms/farmsTypes.d.ts +283 -2
- package/dist/packages/farms/farmsTypes.d.ts.map +1 -1
- package/dist/packages/farms/farmsTypes.js +18 -0
- package/dist/packages/limitOrders/limitOrders.d.ts +108 -21
- package/dist/packages/limitOrders/limitOrders.d.ts.map +1 -1
- package/dist/packages/limitOrders/limitOrders.js +110 -22
- package/dist/packages/limitOrders/limitOrdersTypes.d.ts +142 -0
- package/dist/packages/limitOrders/limitOrdersTypes.d.ts.map +1 -1
- package/dist/packages/multisig/multisig.d.ts +33 -4
- package/dist/packages/multisig/multisig.d.ts.map +1 -1
- package/dist/packages/multisig/multisig.js +33 -4
- package/dist/packages/multisig/multisigTypes.d.ts +17 -0
- package/dist/packages/multisig/multisigTypes.d.ts.map +1 -1
- package/dist/packages/perpetuals/api/perpetualsApi.d.ts.map +1 -1
- package/dist/packages/pools/pool.d.ts +327 -85
- package/dist/packages/pools/pool.d.ts.map +1 -1
- package/dist/packages/pools/pool.js +333 -91
- package/dist/packages/pools/pools.d.ts +299 -37
- package/dist/packages/pools/pools.d.ts.map +1 -1
- package/dist/packages/pools/pools.js +306 -52
- package/dist/packages/pools/poolsTypes.d.ts +267 -2
- package/dist/packages/pools/poolsTypes.d.ts.map +1 -1
- package/dist/packages/referralVault/referralVault.d.ts +37 -0
- package/dist/packages/referralVault/referralVault.d.ts.map +1 -1
- package/dist/packages/referralVault/referralVault.js +37 -0
- package/dist/packages/router/router.d.ts +213 -17
- package/dist/packages/router/router.d.ts.map +1 -1
- package/dist/packages/router/router.js +214 -18
- package/dist/packages/router/routerTypes.d.ts +198 -14
- package/dist/packages/router/routerTypes.d.ts.map +1 -1
- package/dist/packages/staking/staking.d.ts +301 -43
- package/dist/packages/staking/staking.d.ts.map +1 -1
- package/dist/packages/staking/staking.js +308 -51
- package/dist/packages/staking/stakingTypes.d.ts +426 -6
- package/dist/packages/staking/stakingTypes.d.ts.map +1 -1
- package/dist/packages/staking/stakingTypes.js +19 -0
- package/dist/packages/sui/sui.d.ts +39 -0
- package/dist/packages/sui/sui.d.ts.map +1 -1
- package/dist/packages/sui/sui.js +39 -0
- package/dist/packages/userData/userData.d.ts +66 -12
- package/dist/packages/userData/userData.d.ts.map +1 -1
- package/dist/packages/userData/userData.js +66 -12
- package/dist/packages/userData/userDataTypes.d.ts +19 -0
- package/dist/packages/userData/userDataTypes.d.ts.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -1
- package/package.json +1 -1
- package/dist/general/historicalData/historicalData.d.ts +0 -15
- package/dist/general/historicalData/historicalData.d.ts.map +0 -1
- package/dist/general/historicalData/historicalData.js +0 -45
- package/dist/general/historicalData/historicalDataTypes.d.ts +0 -10
- package/dist/general/historicalData/historicalDataTypes.d.ts.map +0 -1
- 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
|
|
13
|
-
*
|
|
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
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* @param
|
|
20
|
-
* @returns
|
|
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
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* @param
|
|
29
|
-
* @returns
|
|
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
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
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
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
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
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
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
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* @deprecated
|
|
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
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* @
|
|
71
|
-
* @
|
|
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
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* @
|
|
81
|
-
* @
|
|
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;
|
|
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"}
|
package/dist/packages/dca/dca.js
CHANGED
|
@@ -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
|
|
26
|
-
*
|
|
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
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* @param
|
|
37
|
-
* @returns
|
|
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
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* @param
|
|
48
|
-
* @returns
|
|
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
|
-
//
|
|
99
|
+
// Transactions
|
|
57
100
|
// =========================================================================
|
|
58
101
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
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
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
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
|
-
//
|
|
149
|
+
// Interactions
|
|
80
150
|
// =========================================================================
|
|
81
151
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
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
|
-
//
|
|
173
|
+
// Interactions - Deprecated
|
|
94
174
|
// =========================================================================
|
|
95
175
|
/**
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* @deprecated
|
|
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
|
-
//
|
|
188
|
+
// User Public Key
|
|
108
189
|
// =========================================================================
|
|
109
190
|
/**
|
|
110
|
-
* Fetches the
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
* @
|
|
114
|
-
* @
|
|
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
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* @
|
|
126
|
-
* @
|
|
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
|
};
|