@7kprotocol/sdk-ts 2.4.1 → 2.4.2-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -3
- package/lib/cjs/config/fetchClient.js +11 -19
- package/lib/cjs/config/index.js +22 -0
- package/lib/cjs/constants/_7k.js +6 -3
- package/lib/cjs/features/limitDca/cancelDcaOrder.js +7 -18
- package/lib/cjs/features/limitDca/cancelLimitOrder.js +7 -18
- package/lib/cjs/features/limitDca/claimExpiredLimitOrder.js +7 -18
- package/lib/cjs/features/limitDca/constants.js +1 -5
- package/lib/cjs/features/limitDca/getClosedDcaOrders.js +16 -27
- package/lib/cjs/features/limitDca/getClosedLimitOrders.js +15 -26
- package/lib/cjs/features/limitDca/getDcaOrderExecutions.js +16 -27
- package/lib/cjs/features/limitDca/getOpenDcaOrders.js +15 -26
- package/lib/cjs/features/limitDca/getOpenLimitOrders.js +15 -26
- package/lib/cjs/features/limitDca/placeDcaOrder.js +25 -36
- package/lib/cjs/features/limitDca/placeLimitOrder.js +14 -25
- package/lib/cjs/features/prices/index.js +47 -64
- package/lib/cjs/features/swap/buildTx.js +88 -39
- package/lib/cjs/features/swap/config.js +32 -32
- package/lib/cjs/features/swap/estimateGasFee.js +36 -46
- package/lib/cjs/features/swap/executeTx.js +52 -0
- package/lib/cjs/features/swap/getQuote.js +41 -31
- package/lib/cjs/features/swap/getSwapHistory.js +14 -25
- package/lib/cjs/features/swap/index.js +1 -0
- package/lib/cjs/index.js +16 -9
- package/lib/cjs/libs/getCoinOjectIdsByAmount.js +15 -24
- package/lib/cjs/libs/getSplitCoinForTx.js +8 -15
- package/lib/cjs/libs/groupSwapRoutes.js +10 -12
- package/lib/cjs/libs/protocols/aftermath/index.js +25 -36
- package/lib/cjs/libs/protocols/base.js +10 -3
- package/lib/cjs/libs/protocols/bluefin/index.js +26 -43
- package/lib/cjs/libs/protocols/bluefinx/client.js +35 -0
- package/lib/cjs/libs/protocols/bluefinx/index.js +48 -0
- package/lib/cjs/libs/protocols/bluefinx/types.js +10 -0
- package/lib/cjs/libs/protocols/bluemove/index.js +14 -25
- package/lib/cjs/libs/protocols/cetus/index.js +32 -43
- package/lib/cjs/libs/protocols/deepbookV3/sponsored.js +19 -30
- package/lib/cjs/libs/protocols/flowx/index.js +9 -20
- package/lib/cjs/libs/protocols/flowxV3/index.js +25 -39
- package/lib/cjs/libs/protocols/haedal_pmm/index.js +33 -0
- package/lib/cjs/libs/protocols/index.js +7 -2
- package/lib/cjs/libs/protocols/kriya/index.js +20 -31
- package/lib/cjs/libs/protocols/kriyaV3/index.js +54 -65
- package/lib/cjs/libs/protocols/magma/index.js +28 -40
- package/lib/cjs/libs/protocols/momentum/index.js +49 -0
- package/lib/cjs/libs/protocols/obric/index.js +20 -31
- package/lib/cjs/libs/protocols/springsui/index.js +14 -25
- package/lib/cjs/libs/protocols/steamm/index.js +57 -58
- package/lib/cjs/libs/protocols/stsui/index.js +14 -25
- package/lib/cjs/libs/protocols/suiswap/index.js +23 -34
- package/lib/cjs/libs/protocols/turbos/index.js +23 -38
- package/lib/cjs/libs/protocols/utils.js +1 -5
- package/lib/cjs/libs/swapWithRoute.js +17 -27
- package/lib/cjs/types/aggregator.js +17 -0
- package/lib/cjs/types/config/index.d.ts +9 -0
- package/lib/cjs/types/config/index.d.ts.map +1 -1
- package/lib/cjs/types/constants/_7k.d.ts +3 -3
- package/lib/cjs/types/constants/_7k.d.ts.map +1 -1
- package/lib/cjs/types/features/limitDca/constants.d.ts +1 -2
- package/lib/cjs/types/features/limitDca/constants.d.ts.map +1 -1
- package/lib/cjs/types/features/swap/buildTx.d.ts +2 -5
- package/lib/cjs/types/features/swap/buildTx.d.ts.map +1 -1
- package/lib/cjs/types/features/swap/config.d.ts.map +1 -1
- package/lib/cjs/types/features/swap/estimateGasFee.d.ts.map +1 -1
- package/lib/cjs/types/features/swap/executeTx.d.ts +24 -0
- package/lib/cjs/types/features/swap/executeTx.d.ts.map +1 -0
- package/lib/cjs/types/features/swap/getQuote.d.ts +8 -1
- package/lib/cjs/types/features/swap/getQuote.d.ts.map +1 -1
- package/lib/cjs/types/features/swap/index.d.ts +1 -0
- package/lib/cjs/types/features/swap/index.d.ts.map +1 -1
- package/lib/cjs/types/index.d.ts +13 -8
- package/lib/cjs/types/index.d.ts.map +1 -1
- package/lib/cjs/types/libs/getCoinOjectIdsByAmount.d.ts.map +1 -1
- package/lib/cjs/types/libs/getSplitCoinForTx.d.ts.map +1 -1
- package/lib/cjs/types/libs/groupSwapRoutes.d.ts.map +1 -1
- package/lib/cjs/types/libs/protocols/base.d.ts +6 -2
- package/lib/cjs/types/libs/protocols/base.d.ts.map +1 -1
- package/lib/cjs/types/libs/protocols/bluefin/index.d.ts.map +1 -1
- package/lib/cjs/types/libs/protocols/bluefinx/client.d.ts +13 -0
- package/lib/cjs/types/libs/protocols/bluefinx/client.d.ts.map +1 -0
- package/lib/cjs/types/libs/protocols/bluefinx/index.d.ts +17 -0
- package/lib/cjs/types/libs/protocols/bluefinx/index.d.ts.map +1 -0
- package/lib/cjs/types/libs/protocols/bluefinx/types.d.ts +34 -0
- package/lib/cjs/types/libs/protocols/bluefinx/types.d.ts.map +1 -0
- package/lib/cjs/types/libs/protocols/cetus/index.d.ts.map +1 -1
- package/lib/cjs/types/libs/protocols/deepbookV3/sponsored.d.ts.map +1 -1
- package/lib/cjs/types/libs/protocols/flowxV3/index.d.ts.map +1 -1
- package/lib/{esm/types/libs/protocols/deepbook → cjs/types/libs/protocols/haedal_pmm}/index.d.ts +1 -3
- package/lib/cjs/types/libs/protocols/haedal_pmm/index.d.ts.map +1 -0
- package/lib/cjs/types/libs/protocols/index.d.ts +7 -2
- package/lib/cjs/types/libs/protocols/index.d.ts.map +1 -1
- package/lib/cjs/types/libs/protocols/magma/index.d.ts.map +1 -1
- package/lib/cjs/types/libs/protocols/{deepbook → momentum}/index.d.ts +1 -3
- package/lib/cjs/types/libs/protocols/momentum/index.d.ts.map +1 -0
- package/lib/cjs/types/libs/protocols/steamm/index.d.ts +13 -2
- package/lib/cjs/types/libs/protocols/steamm/index.d.ts.map +1 -1
- package/lib/cjs/types/libs/protocols/suiswap/index.d.ts.map +1 -1
- package/lib/cjs/types/libs/protocols/turbos/index.d.ts.map +1 -1
- package/lib/cjs/types/libs/protocols/utils.d.ts +1 -2
- package/lib/cjs/types/libs/protocols/utils.d.ts.map +1 -1
- package/lib/cjs/types/libs/swapWithRoute.d.ts +3 -1
- package/lib/cjs/types/libs/swapWithRoute.d.ts.map +1 -1
- package/lib/cjs/types/types/aggregator.d.ts +36 -2
- package/lib/cjs/types/types/aggregator.d.ts.map +1 -1
- package/lib/cjs/types/types/tx.d.ts +1 -2
- package/lib/cjs/types/types/tx.d.ts.map +1 -1
- package/lib/cjs/types/utils/number.d.ts +1 -3
- package/lib/cjs/types/utils/number.d.ts.map +1 -1
- package/lib/cjs/types/utils/sui.d.ts +1 -1
- package/lib/cjs/types/utils/sui.d.ts.map +1 -1
- package/lib/cjs/utils/number.js +4 -10
- package/lib/cjs/utils/sui.js +71 -80
- package/lib/esm/config/index.js +22 -0
- package/lib/esm/constants/_7k.js +6 -3
- package/lib/esm/features/limitDca/constants.js +1 -2
- package/lib/esm/features/swap/buildTx.js +81 -20
- package/lib/esm/features/swap/config.js +19 -8
- package/lib/esm/features/swap/estimateGasFee.js +13 -9
- package/lib/esm/features/swap/executeTx.js +48 -0
- package/lib/esm/features/swap/getQuote.js +24 -3
- package/lib/esm/features/swap/index.js +1 -0
- package/lib/esm/index.mjs +8 -4
- package/lib/esm/libs/getCoinOjectIdsByAmount.js +7 -7
- package/lib/esm/libs/getSplitCoinForTx.js +4 -2
- package/lib/esm/libs/groupSwapRoutes.js +1 -2
- package/lib/esm/libs/protocols/base.js +10 -1
- package/lib/esm/libs/protocols/bluefin/index.js +2 -5
- package/lib/esm/libs/protocols/bluefinx/client.js +30 -0
- package/lib/esm/libs/protocols/bluefinx/index.js +44 -0
- package/lib/esm/libs/protocols/bluefinx/types.js +8 -0
- package/lib/esm/libs/protocols/cetus/index.js +1 -1
- package/lib/esm/libs/protocols/deepbookV3/sponsored.js +1 -1
- package/lib/esm/libs/protocols/flowxV3/index.js +1 -4
- package/lib/esm/libs/protocols/haedal_pmm/index.js +29 -0
- package/lib/esm/libs/protocols/index.js +7 -2
- package/lib/esm/libs/protocols/magma/index.js +1 -2
- package/lib/esm/libs/protocols/momentum/index.js +45 -0
- package/lib/esm/libs/protocols/steamm/index.js +58 -48
- package/lib/esm/libs/protocols/suiswap/index.js +1 -1
- package/lib/esm/libs/protocols/turbos/index.js +2 -6
- package/lib/esm/libs/protocols/utils.js +1 -2
- package/lib/esm/libs/swapWithRoute.js +2 -1
- package/lib/esm/types/aggregator.js +14 -1
- package/lib/esm/types/config/index.d.ts +9 -0
- package/lib/esm/types/config/index.d.ts.map +1 -1
- package/lib/esm/types/constants/_7k.d.ts +3 -3
- package/lib/esm/types/constants/_7k.d.ts.map +1 -1
- package/lib/esm/types/features/limitDca/constants.d.ts +1 -2
- package/lib/esm/types/features/limitDca/constants.d.ts.map +1 -1
- package/lib/esm/types/features/swap/buildTx.d.ts +2 -5
- package/lib/esm/types/features/swap/buildTx.d.ts.map +1 -1
- package/lib/esm/types/features/swap/config.d.ts.map +1 -1
- package/lib/esm/types/features/swap/estimateGasFee.d.ts.map +1 -1
- package/lib/esm/types/features/swap/executeTx.d.ts +24 -0
- package/lib/esm/types/features/swap/executeTx.d.ts.map +1 -0
- package/lib/esm/types/features/swap/getQuote.d.ts +8 -1
- package/lib/esm/types/features/swap/getQuote.d.ts.map +1 -1
- package/lib/esm/types/features/swap/index.d.ts +1 -0
- package/lib/esm/types/features/swap/index.d.ts.map +1 -1
- package/lib/esm/types/index.d.ts +13 -8
- package/lib/esm/types/index.d.ts.map +1 -1
- package/lib/esm/types/libs/getCoinOjectIdsByAmount.d.ts.map +1 -1
- package/lib/esm/types/libs/getSplitCoinForTx.d.ts.map +1 -1
- package/lib/esm/types/libs/groupSwapRoutes.d.ts.map +1 -1
- package/lib/esm/types/libs/protocols/base.d.ts +6 -2
- package/lib/esm/types/libs/protocols/base.d.ts.map +1 -1
- package/lib/esm/types/libs/protocols/bluefin/index.d.ts.map +1 -1
- package/lib/esm/types/libs/protocols/bluefinx/client.d.ts +13 -0
- package/lib/esm/types/libs/protocols/bluefinx/client.d.ts.map +1 -0
- package/lib/esm/types/libs/protocols/bluefinx/index.d.ts +17 -0
- package/lib/esm/types/libs/protocols/bluefinx/index.d.ts.map +1 -0
- package/lib/esm/types/libs/protocols/bluefinx/types.d.ts +34 -0
- package/lib/esm/types/libs/protocols/bluefinx/types.d.ts.map +1 -0
- package/lib/esm/types/libs/protocols/cetus/index.d.ts.map +1 -1
- package/lib/esm/types/libs/protocols/deepbookV3/sponsored.d.ts.map +1 -1
- package/lib/esm/types/libs/protocols/flowxV3/index.d.ts.map +1 -1
- package/lib/esm/types/libs/protocols/haedal_pmm/index.d.ts +9 -0
- package/lib/esm/types/libs/protocols/haedal_pmm/index.d.ts.map +1 -0
- package/lib/esm/types/libs/protocols/index.d.ts +7 -2
- package/lib/esm/types/libs/protocols/index.d.ts.map +1 -1
- package/lib/esm/types/libs/protocols/magma/index.d.ts.map +1 -1
- package/lib/esm/types/libs/protocols/momentum/index.d.ts +9 -0
- package/lib/esm/types/libs/protocols/momentum/index.d.ts.map +1 -0
- package/lib/esm/types/libs/protocols/steamm/index.d.ts +13 -2
- package/lib/esm/types/libs/protocols/steamm/index.d.ts.map +1 -1
- package/lib/esm/types/libs/protocols/suiswap/index.d.ts.map +1 -1
- package/lib/esm/types/libs/protocols/turbos/index.d.ts.map +1 -1
- package/lib/esm/types/libs/protocols/utils.d.ts +1 -2
- package/lib/esm/types/libs/protocols/utils.d.ts.map +1 -1
- package/lib/esm/types/libs/swapWithRoute.d.ts +3 -1
- package/lib/esm/types/libs/swapWithRoute.d.ts.map +1 -1
- package/lib/esm/types/types/aggregator.d.ts +36 -2
- package/lib/esm/types/types/aggregator.d.ts.map +1 -1
- package/lib/esm/types/types/tx.d.ts +1 -2
- package/lib/esm/types/types/tx.d.ts.map +1 -1
- package/lib/esm/types/utils/number.d.ts +1 -3
- package/lib/esm/types/utils/number.d.ts.map +1 -1
- package/lib/esm/types/utils/sui.d.ts +1 -1
- package/lib/esm/types/utils/sui.d.ts.map +1 -1
- package/lib/esm/utils/number.js +4 -6
- package/lib/esm/utils/sui.js +4 -3
- package/package.json +14 -15
- package/lib/cjs/libs/protocols/deepbook/index.js +0 -96
- package/lib/cjs/types/libs/protocols/deepbook/index.d.ts.map +0 -1
- package/lib/esm/libs/protocols/deepbook/index.js +0 -80
- package/lib/esm/types/libs/protocols/deepbook/index.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -6,6 +6,13 @@
|
|
|
6
6
|
npm i @7kprotocol/sdk-ts
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
+
This package requires `@pythnetwork/pyth-sui-js` as a peer dependency. If your
|
|
10
|
+
project does not have it, you need to install it.
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm i @pythnetwork/pyth-sui-js
|
|
14
|
+
```
|
|
15
|
+
|
|
9
16
|
## Usage
|
|
10
17
|
|
|
11
18
|
You can import the entire SDK as a module:
|
|
@@ -27,8 +34,24 @@ SDK functions.
|
|
|
27
34
|
|
|
28
35
|
### Set API Key
|
|
29
36
|
|
|
30
|
-
|
|
31
|
-
|
|
37
|
+
You can use our SDK with a default rate limit of **5 requests per second**
|
|
38
|
+
without needing an API key.
|
|
39
|
+
|
|
40
|
+
- For **frontend (in-browser) usage**, no API key is required, and the rate
|
|
41
|
+
limit cannot be increased.
|
|
42
|
+
|
|
43
|
+
- For **backend (server-side) usage**, the API key is **optional** for default
|
|
44
|
+
usage. However, to request a **higher rate limit**, you must provide both an
|
|
45
|
+
**API key** and **partner information**.
|
|
46
|
+
|
|
47
|
+
To request a rate limit increase, please submit your request at:
|
|
48
|
+
|
|
49
|
+
🔗 <https://7k.ag/collab> and select **"SDK - increase request rate"**.
|
|
50
|
+
|
|
51
|
+
| Usage | API Key Required | Default Rate Limit | Can Request Higher Rate Limit |
|
|
52
|
+
| -------- | ------------------------------------- | ------------------------------- | -------------------------------------------- |
|
|
53
|
+
| Frontend | No | 5 requests/second | No |
|
|
54
|
+
| Backend | Optional (required to increase limit) | 5 requests/second (without key) | Yes (requires API Key & partner information) |
|
|
32
55
|
|
|
33
56
|
```typescript
|
|
34
57
|
import { Config } from "@7kprotocol/sdk-ts";
|
|
@@ -49,12 +72,16 @@ Config.setSuiClient(suiClient);
|
|
|
49
72
|
console.log("Sui client", Config.getSuiClient());
|
|
50
73
|
```
|
|
51
74
|
|
|
52
|
-
Note: this package only supports **mainnet
|
|
75
|
+
Note: this package only supports **mainnet**.
|
|
53
76
|
|
|
54
77
|
## Swap
|
|
55
78
|
|
|
56
79
|
See [Swap](docs/SWAP.md).
|
|
57
80
|
|
|
81
|
+
## BluefinX
|
|
82
|
+
|
|
83
|
+
See [BluefinX](docs/BLUEFINX.md).
|
|
84
|
+
|
|
58
85
|
## Limit Orders
|
|
59
86
|
|
|
60
87
|
See [Limit Orders](docs/LIMIT.md).
|
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.fetchClient = fetchClient;
|
|
13
4
|
const index_1 = require("./index");
|
|
14
|
-
function fetchClient(input, init) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
5
|
+
async function fetchClient(input, init) {
|
|
6
|
+
const headers = new Headers(init?.headers);
|
|
7
|
+
const apiKey = (index_1.Config.getApiKey() || "").trim();
|
|
8
|
+
if (apiKey) {
|
|
9
|
+
headers.set("apiKey", apiKey);
|
|
10
|
+
}
|
|
11
|
+
const modifiedInit = {
|
|
12
|
+
...init,
|
|
13
|
+
headers,
|
|
14
|
+
};
|
|
15
|
+
return fetch(input, modifiedInit);
|
|
24
16
|
}
|
package/lib/cjs/config/index.js
CHANGED
|
@@ -2,10 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Config = void 0;
|
|
4
4
|
const client_1 = require("@mysten/sui/client");
|
|
5
|
+
const pyth_sui_js_1 = require("@pythnetwork/pyth-sui-js");
|
|
6
|
+
const HERMES_API = "https://hermes.pyth.network";
|
|
7
|
+
const WORMHOLE_STATE_ID = "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c";
|
|
8
|
+
const PYTH_STATE_ID = "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8";
|
|
5
9
|
let apiKey = "";
|
|
6
10
|
let suiClient = new client_1.SuiClient({
|
|
7
11
|
url: (0, client_1.getFullnodeUrl)("mainnet"),
|
|
8
12
|
});
|
|
13
|
+
let pythClient = new pyth_sui_js_1.SuiPythClient(suiClient, PYTH_STATE_ID, WORMHOLE_STATE_ID);
|
|
14
|
+
let pythConnection = new pyth_sui_js_1.SuiPriceServiceConnection(HERMES_API);
|
|
9
15
|
function setApiKey(key) {
|
|
10
16
|
apiKey = key;
|
|
11
17
|
}
|
|
@@ -18,10 +24,26 @@ function getSuiClient() {
|
|
|
18
24
|
function setSuiClient(client) {
|
|
19
25
|
suiClient = client;
|
|
20
26
|
}
|
|
27
|
+
function setPythClient(client) {
|
|
28
|
+
pythClient = client;
|
|
29
|
+
}
|
|
30
|
+
function getPythClient() {
|
|
31
|
+
return pythClient;
|
|
32
|
+
}
|
|
33
|
+
function setPythConnection(connection) {
|
|
34
|
+
pythConnection = connection;
|
|
35
|
+
}
|
|
36
|
+
function getPythConnection() {
|
|
37
|
+
return pythConnection;
|
|
38
|
+
}
|
|
21
39
|
const Config = {
|
|
22
40
|
setApiKey,
|
|
23
41
|
getApiKey,
|
|
24
42
|
setSuiClient,
|
|
25
43
|
getSuiClient,
|
|
44
|
+
setPythClient,
|
|
45
|
+
getPythClient,
|
|
46
|
+
setPythConnection,
|
|
47
|
+
getPythConnection,
|
|
26
48
|
};
|
|
27
49
|
exports.Config = Config;
|
package/lib/cjs/constants/_7k.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports._7K_VAULT = exports._7K_CONFIG = exports._7K_PACKAGE_ID = void 0;
|
|
4
|
-
exports._7K_PACKAGE_ID = "
|
|
4
|
+
exports._7K_PACKAGE_ID = "0xe8f996ea6ff38c557c253d3b93cfe2ebf393816487266786371aa4532a9229f2";
|
|
5
|
+
//legacy V3: "0x7ea6e27ad7af6f3b8671d59df1aaebd7c03dddab893e52a714227b2f4fe91519";
|
|
5
6
|
//legacy V2: "0xa13447019cd982d6bef91cf7b46ad384a52583b1dfc2bdecf31ef0c4bd787a0f";
|
|
6
7
|
//legacy V1: "0xd48e7cdc9e92bec69ce3baa75578010458a0c5b2733d661a84971e8cef6806bc";
|
|
7
|
-
exports._7K_CONFIG = "
|
|
8
|
-
|
|
8
|
+
exports._7K_CONFIG = "0x47442a93f7727d188ba7cb71031170d1786af70013cb7ad5115f3fe877ff0c54";
|
|
9
|
+
//legacy v3: "0x0f8fc23dbcc9362b72c7a4c5aa53fcefa02ebfbb83a812c8c262ccd2c076d9ee";
|
|
10
|
+
exports._7K_VAULT = "0x442ad50389ed5cda6f7a6f5a7ae6361a4c05ef1d9fb2e54fbba5a268d690bfe6";
|
|
11
|
+
//legacy v3: "0x39a3c55742c0e011b6f65548e73cf589e1ae5e82dbfab449ca57f24c3bcd9514";
|
|
@@ -1,25 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.cancelDcaOrder = cancelDcaOrder;
|
|
13
4
|
const transactions_1 = require("@mysten/sui/transactions");
|
|
14
5
|
const constants_1 = require("./constants");
|
|
15
|
-
function cancelDcaOrder(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
typeArguments: [payCoinType, targetCoinType],
|
|
22
|
-
});
|
|
23
|
-
return tx;
|
|
6
|
+
async function cancelDcaOrder({ orderId, payCoinType, targetCoinType, }) {
|
|
7
|
+
const tx = new transactions_1.Transaction();
|
|
8
|
+
tx.moveCall({
|
|
9
|
+
target: `${constants_1.DCA_ORDER_MODULE_ID}::cancel_dca_order`,
|
|
10
|
+
arguments: [tx.object(orderId), tx.object.clock()],
|
|
11
|
+
typeArguments: [payCoinType, targetCoinType],
|
|
24
12
|
});
|
|
13
|
+
return tx;
|
|
25
14
|
}
|
|
@@ -1,25 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.cancelLimitOrder = cancelLimitOrder;
|
|
13
4
|
const transactions_1 = require("@mysten/sui/transactions");
|
|
14
5
|
const constants_1 = require("./constants");
|
|
15
|
-
function cancelLimitOrder(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
arguments: [tx.object(orderId), tx.object.clock()],
|
|
22
|
-
});
|
|
23
|
-
return tx;
|
|
6
|
+
async function cancelLimitOrder({ orderId, payCoinType, targetCoinType, }) {
|
|
7
|
+
const tx = new transactions_1.Transaction();
|
|
8
|
+
tx.moveCall({
|
|
9
|
+
target: `${constants_1.LIMIT_ORDER_MODULE_ID}::cancel_limit_order`,
|
|
10
|
+
typeArguments: [payCoinType, targetCoinType],
|
|
11
|
+
arguments: [tx.object(orderId), tx.object.clock()],
|
|
24
12
|
});
|
|
13
|
+
return tx;
|
|
25
14
|
}
|
|
@@ -1,25 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.claimExpiredLimitOrder = claimExpiredLimitOrder;
|
|
13
4
|
const transactions_1 = require("@mysten/sui/transactions");
|
|
14
5
|
const constants_1 = require("./constants");
|
|
15
|
-
function claimExpiredLimitOrder(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
arguments: [tx.object(orderId), tx.object.clock()],
|
|
22
|
-
});
|
|
23
|
-
return tx;
|
|
6
|
+
async function claimExpiredLimitOrder({ orderId, payCoinType, targetCoinType, }) {
|
|
7
|
+
const tx = new transactions_1.Transaction();
|
|
8
|
+
tx.moveCall({
|
|
9
|
+
target: `${constants_1.LIMIT_ORDER_MODULE_ID}::claim_expired_order`,
|
|
10
|
+
typeArguments: [payCoinType, targetCoinType],
|
|
11
|
+
arguments: [tx.object(orderId), tx.object.clock()],
|
|
24
12
|
});
|
|
13
|
+
return tx;
|
|
25
14
|
}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.LO_DCA_API = exports.DCA_MAX_RATE = exports.CONFIG_MODULE_ID = exports.DCA_ORDER_MODULE_ID = exports.LIMIT_ORDER_MODULE_ID = exports.PACKAGE = exports.SLIPPAGE_SCALE = exports.RATE_SCALE = exports.GLOBAL_CONFIG_ID = void 0;
|
|
7
|
-
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
4
|
const apiEndpoints_1 = require("../../constants/apiEndpoints");
|
|
9
5
|
exports.GLOBAL_CONFIG_ID = "0xffc7f420b481ed7a012b42e125fd7e5716b5673759cf4629e5fcfebce970a72d";
|
|
10
6
|
exports.RATE_SCALE = BigInt("1000000000000");
|
|
@@ -13,5 +9,5 @@ exports.PACKAGE = "0x0ef0f805710cf53c10f29c4f73e1144a662747e1839689a846e2520cae1
|
|
|
13
9
|
exports.LIMIT_ORDER_MODULE_ID = `${exports.PACKAGE}::limit_order`;
|
|
14
10
|
exports.DCA_ORDER_MODULE_ID = `${exports.PACKAGE}::dca_order`;
|
|
15
11
|
exports.CONFIG_MODULE_ID = `${exports.PACKAGE}::config`;
|
|
16
|
-
exports.DCA_MAX_RATE =
|
|
12
|
+
exports.DCA_MAX_RATE = BigInt("18446744073709551615");
|
|
17
13
|
exports.LO_DCA_API = `${apiEndpoints_1.API_ENDPOINTS.LO_DCA}/api`;
|
|
@@ -1,34 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.getClosedDcaOrders = getClosedDcaOrders;
|
|
13
4
|
const fetchClient_1 = require("../../config/fetchClient");
|
|
14
5
|
const url_1 = require("../../libs/url");
|
|
15
6
|
const constants_1 = require("./constants");
|
|
16
|
-
function getClosedDcaOrders(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return orders;
|
|
33
|
-
});
|
|
7
|
+
async function getClosedDcaOrders({ owner, offset = 0, limit = 10, tokenPair, }) {
|
|
8
|
+
const queryParams = {
|
|
9
|
+
owner,
|
|
10
|
+
statuses: ["SUCCESS"],
|
|
11
|
+
offset,
|
|
12
|
+
limit,
|
|
13
|
+
orderType: "DCA",
|
|
14
|
+
tokenPair,
|
|
15
|
+
};
|
|
16
|
+
const paramsStr = (0, url_1.formatQueryParams)(queryParams);
|
|
17
|
+
const response = await (0, fetchClient_1.fetchClient)(`${constants_1.LO_DCA_API}/order-executions?${paramsStr}`);
|
|
18
|
+
if (!response.ok) {
|
|
19
|
+
throw new Error("Failed to fetch closed dca orders");
|
|
20
|
+
}
|
|
21
|
+
const orders = (await response.json());
|
|
22
|
+
return orders;
|
|
34
23
|
}
|
|
@@ -1,33 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.getClosedLimitOrders = getClosedLimitOrders;
|
|
13
4
|
const fetchClient_1 = require("../../config/fetchClient");
|
|
14
5
|
const url_1 = require("../../libs/url");
|
|
15
6
|
const constants_1 = require("./constants");
|
|
16
|
-
function getClosedLimitOrders(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return orders;
|
|
32
|
-
});
|
|
7
|
+
async function getClosedLimitOrders({ owner, offset = 0, limit = 10, tokenPair, }) {
|
|
8
|
+
const queryParams = {
|
|
9
|
+
owner,
|
|
10
|
+
statuses: ["CLOSED"],
|
|
11
|
+
offset,
|
|
12
|
+
limit,
|
|
13
|
+
tokenPair,
|
|
14
|
+
};
|
|
15
|
+
const paramsStr = (0, url_1.formatQueryParams)(queryParams);
|
|
16
|
+
const response = await (0, fetchClient_1.fetchClient)(`${constants_1.LO_DCA_API}/limit-orders?${paramsStr}`);
|
|
17
|
+
if (!response.ok) {
|
|
18
|
+
throw new Error("Failed to fetch closed limit orders");
|
|
19
|
+
}
|
|
20
|
+
const orders = (await response.json());
|
|
21
|
+
return orders;
|
|
33
22
|
}
|
|
@@ -1,34 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.getDcaOrderExecutions = getDcaOrderExecutions;
|
|
13
4
|
const fetchClient_1 = require("../../config/fetchClient");
|
|
14
5
|
const url_1 = require("../../libs/url");
|
|
15
6
|
const constants_1 = require("./constants");
|
|
16
|
-
function getDcaOrderExecutions(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return orders;
|
|
33
|
-
});
|
|
7
|
+
async function getDcaOrderExecutions({ owner, orderId, offset = 0, limit = 10, }) {
|
|
8
|
+
const queryParams = {
|
|
9
|
+
owner,
|
|
10
|
+
orderId,
|
|
11
|
+
statuses: ["SUCCESS"],
|
|
12
|
+
offset,
|
|
13
|
+
limit,
|
|
14
|
+
orderType: "DCA",
|
|
15
|
+
};
|
|
16
|
+
const paramsStr = (0, url_1.formatQueryParams)(queryParams);
|
|
17
|
+
const response = await (0, fetchClient_1.fetchClient)(`${constants_1.LO_DCA_API}/order-executions?${paramsStr}`);
|
|
18
|
+
if (!response.ok) {
|
|
19
|
+
throw new Error("Failed to fetch dca order executions");
|
|
20
|
+
}
|
|
21
|
+
const orders = (await response.json());
|
|
22
|
+
return orders;
|
|
34
23
|
}
|
|
@@ -1,33 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.getOpenDcaOrders = getOpenDcaOrders;
|
|
13
4
|
const fetchClient_1 = require("../../config/fetchClient");
|
|
14
5
|
const url_1 = require("../../libs/url");
|
|
15
6
|
const constants_1 = require("./constants");
|
|
16
|
-
function getOpenDcaOrders(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return orders;
|
|
32
|
-
});
|
|
7
|
+
async function getOpenDcaOrders({ owner, offset = 0, limit = 10, tokenPair, }) {
|
|
8
|
+
const queryParams = {
|
|
9
|
+
owner,
|
|
10
|
+
statuses: ["ACTIVE", "EXPIRED"],
|
|
11
|
+
offset,
|
|
12
|
+
limit,
|
|
13
|
+
tokenPair,
|
|
14
|
+
};
|
|
15
|
+
const paramsStr = (0, url_1.formatQueryParams)(queryParams);
|
|
16
|
+
const response = await (0, fetchClient_1.fetchClient)(`${constants_1.LO_DCA_API}/dca-orders?${paramsStr}`);
|
|
17
|
+
if (!response.ok) {
|
|
18
|
+
throw new Error("Failed to fetch open dca orders");
|
|
19
|
+
}
|
|
20
|
+
const orders = (await response.json());
|
|
21
|
+
return orders;
|
|
33
22
|
}
|
|
@@ -1,33 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.getOpenLimitOrders = getOpenLimitOrders;
|
|
13
4
|
const fetchClient_1 = require("../../config/fetchClient");
|
|
14
5
|
const url_1 = require("../../libs/url");
|
|
15
6
|
const constants_1 = require("./constants");
|
|
16
|
-
function getOpenLimitOrders(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return orders;
|
|
32
|
-
});
|
|
7
|
+
async function getOpenLimitOrders({ owner, offset = 0, limit = 10, tokenPair, }) {
|
|
8
|
+
const queryParams = {
|
|
9
|
+
owner,
|
|
10
|
+
statuses: ["ACTIVE", "EXPIRED"],
|
|
11
|
+
offset,
|
|
12
|
+
limit,
|
|
13
|
+
tokenPair,
|
|
14
|
+
};
|
|
15
|
+
const paramsStr = (0, url_1.formatQueryParams)(queryParams);
|
|
16
|
+
const response = await (0, fetchClient_1.fetchClient)(`${constants_1.LO_DCA_API}/limit-orders?${paramsStr}`);
|
|
17
|
+
if (!response.ok) {
|
|
18
|
+
throw new Error("Failed to fetch open limit orders");
|
|
19
|
+
}
|
|
20
|
+
const orders = (await response.json());
|
|
21
|
+
return orders;
|
|
33
22
|
}
|
|
@@ -1,44 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.placeDcaOrder = placeDcaOrder;
|
|
13
4
|
const constants_1 = require("./constants");
|
|
14
5
|
const transactions_1 = require("@mysten/sui/transactions");
|
|
15
|
-
function placeDcaOrder(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
balance: payCoinAmountEach,
|
|
23
|
-
});
|
|
24
|
-
coinElements.push(coin);
|
|
25
|
-
}
|
|
26
|
-
const vectorCoin = tx.makeMoveVec({
|
|
27
|
-
elements: coinElements,
|
|
28
|
-
});
|
|
29
|
-
tx.moveCall({
|
|
30
|
-
target: `${constants_1.DCA_ORDER_MODULE_ID}::place_dca_order`,
|
|
31
|
-
arguments: [
|
|
32
|
-
tx.object(constants_1.GLOBAL_CONFIG_ID),
|
|
33
|
-
vectorCoin,
|
|
34
|
-
tx.pure.u64(interval),
|
|
35
|
-
tx.pure.u64(slippage),
|
|
36
|
-
tx.pure.u64(minRate),
|
|
37
|
-
tx.pure.u64(maxRate),
|
|
38
|
-
tx.object.clock(),
|
|
39
|
-
],
|
|
40
|
-
typeArguments: [payCoinType, targetCoinType],
|
|
6
|
+
async function placeDcaOrder({ payCoinType, targetCoinType, payCoinAmountEach, numOrders, interval, slippage, minRate, maxRate, }) {
|
|
7
|
+
const tx = new transactions_1.Transaction();
|
|
8
|
+
const coinElements = [];
|
|
9
|
+
for (let i = 0; i < numOrders; i++) {
|
|
10
|
+
const coin = (0, transactions_1.coinWithBalance)({
|
|
11
|
+
type: payCoinType,
|
|
12
|
+
balance: payCoinAmountEach,
|
|
41
13
|
});
|
|
42
|
-
|
|
14
|
+
coinElements.push(coin);
|
|
15
|
+
}
|
|
16
|
+
const vectorCoin = tx.makeMoveVec({
|
|
17
|
+
elements: coinElements,
|
|
18
|
+
});
|
|
19
|
+
tx.moveCall({
|
|
20
|
+
target: `${constants_1.DCA_ORDER_MODULE_ID}::place_dca_order`,
|
|
21
|
+
arguments: [
|
|
22
|
+
tx.object(constants_1.GLOBAL_CONFIG_ID),
|
|
23
|
+
vectorCoin,
|
|
24
|
+
tx.pure.u64(interval),
|
|
25
|
+
tx.pure.u64(slippage),
|
|
26
|
+
tx.pure.u64(minRate),
|
|
27
|
+
tx.pure.u64(maxRate),
|
|
28
|
+
tx.object.clock(),
|
|
29
|
+
],
|
|
30
|
+
typeArguments: [payCoinType, targetCoinType],
|
|
43
31
|
});
|
|
32
|
+
return tx;
|
|
44
33
|
}
|