@7kprotocol/sdk-ts 2.4.0 → 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 +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 +36 -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 +5 -3
- 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 +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 +36 -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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/libs/protocols/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/libs/protocols/utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAE7D"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { Transaction } from "@mysten/sui/transactions";
|
|
2
2
|
import { Config, TxSorSwap } from "../types/aggregator";
|
|
3
3
|
import { TransactionResultItem } from "../types/sui";
|
|
4
|
-
export declare function swapWithRoute({ route, inputCoinObject, currentAccount, config, tx, }: {
|
|
4
|
+
export declare function swapWithRoute({ route, inputCoinObject, currentAccount, config, pythMap, tx, }: {
|
|
5
5
|
route: TxSorSwap[];
|
|
6
6
|
inputCoinObject: TransactionResultItem;
|
|
7
7
|
currentAccount: string;
|
|
8
8
|
config: Config;
|
|
9
|
+
/** map price feed id to onchain priceInfoObject id */
|
|
10
|
+
pythMap: Record<string, string>;
|
|
9
11
|
tx: Transaction;
|
|
10
12
|
}): Promise<TransactionResultItem | undefined>;
|
|
11
13
|
//# sourceMappingURL=swapWithRoute.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swapWithRoute.d.ts","sourceRoot":"","sources":["../../../../src/libs/swapWithRoute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD,wBAAsB,aAAa,CAAC,EAClC,KAAK,EACL,eAAe,EACf,cAAc,EACd,MAAM,EACN,EAAE,GACH,EAAE;IACD,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,eAAe,EAAE,qBAAqB,CAAC;IACvC,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,WAAW,CAAC;CACjB,GAAG,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"swapWithRoute.d.ts","sourceRoot":"","sources":["../../../../src/libs/swapWithRoute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD,wBAAsB,aAAa,CAAC,EAClC,KAAK,EACL,eAAe,EACf,cAAc,EACd,MAAM,EACN,OAAO,EACP,EAAE,GACH,EAAE;IACD,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,eAAe,EAAE,qBAAqB,CAAC;IACvC,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,EAAE,EAAE,WAAW,CAAC;CACjB,GAAG,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAmB7C"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
2
|
+
import { BluefinXTx } from "../libs/protocols/bluefinx/types";
|
|
3
|
+
export { BluefinXTx };
|
|
4
|
+
export type SourceDex = "suiswap" | "turbos" | "cetus" | "bluemove" | "kriya" | "kriya_v3" | "aftermath" | "deepbook_v3" | "flowx" | "flowx_v3" | "bluefin" | "bluefinx" | "springsui" | "obric" | "stsui" | "steamm" | "steamm_oracle_quoter" | "magma" | "haedal_pmm" | "momentum";
|
|
2
5
|
export type SorSwap = {
|
|
3
6
|
poolId: string;
|
|
4
7
|
assetInIndex: number;
|
|
@@ -41,6 +44,8 @@ export type QuoteResponse = {
|
|
|
41
44
|
swapAmount: string;
|
|
42
45
|
returnAmount: string;
|
|
43
46
|
returnAmountWithDecimal: string;
|
|
47
|
+
returnAmountAfterCommission: string;
|
|
48
|
+
returnAmountAfterCommissionWithDecimal: string;
|
|
44
49
|
returnAmountConsiderGasFees?: string;
|
|
45
50
|
returnAmountWithoutSwapFees?: string;
|
|
46
51
|
swapAmountWithDecimal: string;
|
|
@@ -83,13 +88,15 @@ export interface Config {
|
|
|
83
88
|
bluefin: DexConfig & {
|
|
84
89
|
globalConfig: string;
|
|
85
90
|
};
|
|
91
|
+
bluefinx: DexConfig & {
|
|
92
|
+
globalConfig: string;
|
|
93
|
+
};
|
|
86
94
|
bluemove: DexConfig & {
|
|
87
95
|
dexInfo: string;
|
|
88
96
|
};
|
|
89
97
|
cetus: DexConfig & {
|
|
90
98
|
globalConfig: string;
|
|
91
99
|
};
|
|
92
|
-
deepbook: DexConfig;
|
|
93
100
|
deepbook_v3: DexConfig & {
|
|
94
101
|
sponsor: string;
|
|
95
102
|
sponsorFund: string;
|
|
@@ -116,9 +123,36 @@ export interface Config {
|
|
|
116
123
|
};
|
|
117
124
|
steamm: DexConfig & {
|
|
118
125
|
script: string;
|
|
126
|
+
oracle: string;
|
|
119
127
|
};
|
|
120
128
|
magma: DexConfig & {
|
|
121
129
|
globalConfig: string;
|
|
122
130
|
};
|
|
131
|
+
haedal_pmm: DexConfig;
|
|
132
|
+
momentum: DexConfig & {
|
|
133
|
+
version: string;
|
|
134
|
+
};
|
|
123
135
|
}
|
|
136
|
+
export type ExtraOracle = {
|
|
137
|
+
Pyth?: {
|
|
138
|
+
price_identifier: {
|
|
139
|
+
bytes: number[];
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
Switchboard?: {
|
|
143
|
+
object_id: string;
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
export type AggregatorTx = Transaction | BluefinXTx;
|
|
147
|
+
export declare const isSuiTransaction: (tx: AggregatorTx) => tx is Transaction;
|
|
148
|
+
/**
|
|
149
|
+
* Check if the sor response is a bluefinx routing
|
|
150
|
+
* @param sor
|
|
151
|
+
* @returns boolean
|
|
152
|
+
*/
|
|
153
|
+
export declare const isBluefinXRouting: (sor: QuoteResponse) => boolean;
|
|
154
|
+
export type BuildTxResult = {
|
|
155
|
+
tx: AggregatorTx;
|
|
156
|
+
coinOut?: TransactionObjectArgument;
|
|
157
|
+
};
|
|
124
158
|
//# sourceMappingURL=aggregator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aggregator.d.ts","sourceRoot":"","sources":["../../../../src/types/aggregator.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,QAAQ,GACR,OAAO,GACP,UAAU,GACV,OAAO,GACP,UAAU,GACV,WAAW,GACX,
|
|
1
|
+
{"version":3,"file":"aggregator.d.ts","sourceRoot":"","sources":["../../../../src/types/aggregator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,U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MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACvD,KAAK,EAAE,SAAS,GAAG;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,UAAU,EAAE,SAAS,CAAC;IACtB,QAAQ,EAAE,SAAS,GAAG;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3C;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,EAAE;QAAE,gBAAgB,EAAE;YAAE,KAAK,EAAE,MAAM,EAAE,CAAA;SAAE,CAAA;KAAE,CAAC;IACjD,WAAW,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,UAAU,CAAC;AAEpD,eAAO,MAAM,gBAAgB,GAAI,IAAI,YAAY,KAAG,EAAE,IAAI,WAC/B,CAAC;AAE5B;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,KAAK,aAAa,YAMnD,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,YAAY,CAAC;IACjB,OAAO,CAAC,EAAE,yBAAyB,CAAC;CACrC,CAAC"}
|
|
@@ -1,20 +1,54 @@
|
|
|
1
1
|
import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
2
2
|
import { Commission, QuoteResponse } from "./aggregator";
|
|
3
|
-
import BigNumber from "bignumber.js";
|
|
4
3
|
export interface CommonParams {
|
|
4
|
+
/** Quote response from 7k api */
|
|
5
5
|
quoteResponse: QuoteResponse;
|
|
6
|
+
/** User address */
|
|
6
7
|
accountAddress: string;
|
|
7
|
-
|
|
8
|
+
/** Slippage tolerance, ex: 0.01 (1%) */
|
|
9
|
+
slippage: number | string;
|
|
10
|
+
/** Commission for partner */
|
|
8
11
|
commission: Commission;
|
|
12
|
+
/**
|
|
13
|
+
* Give Flexibility to insert custom commands before or after swap
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const rawTx = new Transaction();
|
|
17
|
+
* // Add custom commands to rawTx
|
|
18
|
+
* rawTx.moveCall({
|
|
19
|
+
* target: "0x2222222::example::claim",
|
|
20
|
+
* arguments: [],
|
|
21
|
+
* });
|
|
22
|
+
* const { tx, coinOut } = await buildTx({
|
|
23
|
+
* quoteResponse,
|
|
24
|
+
* accountAddress,
|
|
25
|
+
* slippage,
|
|
26
|
+
* commission,
|
|
27
|
+
* extendTx: {
|
|
28
|
+
* tx: rawTx,
|
|
29
|
+
* coinIn: rawTx.object(coinObjectId),
|
|
30
|
+
* },
|
|
31
|
+
* });
|
|
32
|
+
* // add more commands after the swap if needed, and remember to consume the coinOut object
|
|
33
|
+
* tx.transferObjects([coinOut], tx.pure.address(accountAddress));
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
9
36
|
extendTx?: {
|
|
10
37
|
tx: Transaction;
|
|
11
38
|
coinIn?: TransactionObjectArgument;
|
|
12
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* If true, indicates that the transaction is sponsored and its gas object should not be modified.
|
|
42
|
+
* In this case, the gas object is expected to be already set up correctly for the sponsored transaction.
|
|
43
|
+
*/
|
|
44
|
+
isSponsored?: boolean;
|
|
13
45
|
}
|
|
14
46
|
export interface BuildTxParams extends CommonParams {
|
|
47
|
+
/** Developer inspection mode */
|
|
15
48
|
devInspect?: boolean;
|
|
16
49
|
}
|
|
17
50
|
export interface EstimateGasFeeParams extends CommonParams {
|
|
51
|
+
/** Sui price in usd for gas estimation */
|
|
18
52
|
suiPrice?: number;
|
|
19
53
|
}
|
|
20
54
|
//# sourceMappingURL=tx.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx.d.ts","sourceRoot":"","sources":["../../../../src/types/tx.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"tx.d.ts","sourceRoot":"","sources":["../../../../src/types/tx.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAEzD,MAAM,WAAW,YAAY;IAC3B,iCAAiC;IACjC,aAAa,EAAE,aAAa,CAAC;IAC7B,mBAAmB;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,wCAAwC;IACxC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,6BAA6B;IAC7B,UAAU,EAAE,UAAU,CAAC;IACvB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,QAAQ,CAAC,EAAE;QACT,EAAE,EAAE,WAAW,CAAC;QAChB,MAAM,CAAC,EAAE,yBAAyB,CAAC;KACpC,CAAC;IACF;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,aAAc,SAAQ,YAAY;IACjD,gCAAgC;IAChC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function formatBalance(balance: BigNumber.Value, decimals: number): BigNumber;
|
|
3
|
-
export declare function formatRawBalance(balance: BigNumber.Value, decimals: number): BigNumber;
|
|
1
|
+
export declare function formatBalance(balance: bigint, decimals: number): number;
|
|
4
2
|
//# sourceMappingURL=number.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../../../src/utils/number.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../../../src/utils/number.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAK9D"}
|
|
@@ -49,7 +49,7 @@ export declare const SuiUtils: {
|
|
|
49
49
|
$kind: "NestedResult";
|
|
50
50
|
NestedResult: [number, number];
|
|
51
51
|
};
|
|
52
|
-
|
|
52
|
+
collectDust(tx: Transaction, coinType: string, coin: TransactionArgument): void;
|
|
53
53
|
};
|
|
54
54
|
export {};
|
|
55
55
|
//# sourceMappingURL=sui.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sui.d.ts","sourceRoot":"","sources":["../../../../src/utils/sui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EACL,UAAU,EAEV,sBAAsB,EACvB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"sui.d.ts","sourceRoot":"","sources":["../../../../src/utils/sui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EACL,UAAU,EAEV,sBAAsB,EACvB,MAAM,oBAAoB,CAAC;AAM5B,KAAK,QAAQ,CAAC,CAAC,IAAI;IACjB,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,KAAK,SAAS,GAAG;IACf,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF,KAAK,cAAc,GAAG,KAAK,GAAG,SAAS,CAAC;AAExC,eAAO,MAAM,QAAQ;uBAET,MAAM,GAAG,mBAAmB,OAC/B,WAAW,GACf,mBAAmB;4BAMP,KAAK,CAAC,MAAM,GAAG,mBAAmB,CAAC,OAC3C,WAAW,GACf,mBAAmB,GAAG,SAAS;2BAsBtB,MAAM,cACJ,MAAM,GAAG,mBAAmB,OACnC,WAAW,GACf,mBAAmB;mCAYV,MAAM,SACT;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,UACtC,MAAM,OACT,WAAW;;;;gCAoBgB,MAAM,iBAAiB,MAAM;qCAoCtD,UAAU,EAAE,YACT,MAAM,OACX,WAAW;uCAsBuB;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;sCA8BhE,MAAM,SACP;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE;iCA6BvC,MAAM,SACN,sBAAsB,mBACb,cAAc,GAC7B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;4BAyBD,MAAM;oBAQd,WAAW,YAAY,MAAM;;;;iBAQhC,WAAW,YAAY,MAAM;;;;wBASpC,WAAW,YACL,MAAM,cACJ,mBAAmB;;;;wBAU3B,WAAW,YACL,MAAM,WACP,mBAAmB;;;;oBASd,WAAW,YAAY,MAAM,QAAQ,mBAAmB;CAOzE,CAAC"}
|
package/lib/cjs/utils/number.js
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
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.formatBalance = formatBalance;
|
|
7
|
-
exports.formatRawBalance = formatRawBalance;
|
|
8
|
-
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
9
4
|
function formatBalance(balance, decimals) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return new bignumber_js_1.default(rawBalance.toFixed(0));
|
|
5
|
+
const exp = BigInt(Math.pow(10, decimals));
|
|
6
|
+
const whole = balance / exp;
|
|
7
|
+
const remain = balance % exp;
|
|
8
|
+
return Number(whole) + Number(remain) / Number(exp);
|
|
15
9
|
}
|
package/lib/cjs/utils/sui.js
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
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.SuiUtils = void 0;
|
|
13
4
|
const transactions_1 = require("@mysten/sui/transactions");
|
|
14
5
|
const utils_1 = require("@mysten/sui/utils");
|
|
15
6
|
const token_1 = require("./token");
|
|
16
7
|
const config_1 = require("../config");
|
|
8
|
+
const _7k_1 = require("../constants/_7k");
|
|
17
9
|
exports.SuiUtils = {
|
|
18
10
|
getSuiCoin(amount, txb) {
|
|
19
11
|
const [coin] = txb.splitCoins(txb.gas, [amount]);
|
|
@@ -59,32 +51,30 @@ exports.SuiUtils = {
|
|
|
59
51
|
return coinA;
|
|
60
52
|
}
|
|
61
53
|
},
|
|
62
|
-
mergeAllUserCoins(coinType, signerAddress) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
txb.splitCoins(txb.gas, [totalBalance]);
|
|
77
|
-
}
|
|
78
|
-
const coinObjectsIds = coins.map((coin) => coin.coinObjectId);
|
|
79
|
-
if (coins.length > 1) {
|
|
80
|
-
txb.mergeCoins(txb.object(coinObjectsIds[0]), coinObjectsIds.slice(1).map((coin) => txb.object(coin)));
|
|
81
|
-
}
|
|
82
|
-
return txb;
|
|
54
|
+
async mergeAllUserCoins(coinType, signerAddress) {
|
|
55
|
+
try {
|
|
56
|
+
const coins = await exports.SuiUtils.getAllUserCoins({
|
|
57
|
+
address: signerAddress,
|
|
58
|
+
type: coinType,
|
|
59
|
+
});
|
|
60
|
+
let totalBalance = BigInt(0);
|
|
61
|
+
coins.forEach((coin) => {
|
|
62
|
+
totalBalance += BigInt(coin.balance);
|
|
63
|
+
});
|
|
64
|
+
const txb = new transactions_1.Transaction();
|
|
65
|
+
if ((0, token_1.checkIsSui)(coinType)) {
|
|
66
|
+
totalBalance = totalBalance - BigInt("1000");
|
|
67
|
+
txb.splitCoins(txb.gas, [totalBalance]);
|
|
83
68
|
}
|
|
84
|
-
|
|
85
|
-
|
|
69
|
+
const coinObjectsIds = coins.map((coin) => coin.coinObjectId);
|
|
70
|
+
if (coins.length > 1) {
|
|
71
|
+
txb.mergeCoins(txb.object(coinObjectsIds[0]), coinObjectsIds.slice(1).map((coin) => txb.object(coin)));
|
|
86
72
|
}
|
|
87
|
-
|
|
73
|
+
return txb;
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
console.log(error);
|
|
77
|
+
}
|
|
88
78
|
},
|
|
89
79
|
mergeAllCoinsWithoutFetch(coins, coinType, txb) {
|
|
90
80
|
let totalBalance = BigInt(0);
|
|
@@ -100,33 +90,31 @@ exports.SuiUtils = {
|
|
|
100
90
|
txb.mergeCoins(txb.object(coinObjectsIds[0]), coinObjectsIds.slice(1).map((coin) => txb.object(coin)));
|
|
101
91
|
}
|
|
102
92
|
},
|
|
103
|
-
getAllUserCoins(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
if (!res.hasNextPage || iter === 8) {
|
|
119
|
-
cursor = null;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
catch (error) {
|
|
123
|
-
console.log(error);
|
|
93
|
+
async getAllUserCoins({ address, type }) {
|
|
94
|
+
let cursor = undefined;
|
|
95
|
+
let coins = [];
|
|
96
|
+
let iter = 0;
|
|
97
|
+
do {
|
|
98
|
+
try {
|
|
99
|
+
const res = await config_1.Config.getSuiClient().getCoins({
|
|
100
|
+
owner: address,
|
|
101
|
+
coinType: type,
|
|
102
|
+
cursor: cursor,
|
|
103
|
+
limit: 50,
|
|
104
|
+
});
|
|
105
|
+
coins = coins.concat(res.data);
|
|
106
|
+
cursor = res.nextCursor;
|
|
107
|
+
if (!res.hasNextPage || iter === 8) {
|
|
124
108
|
cursor = null;
|
|
125
109
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
console.log(error);
|
|
113
|
+
cursor = null;
|
|
114
|
+
}
|
|
115
|
+
iter++;
|
|
116
|
+
} while (cursor !== null);
|
|
117
|
+
return coins;
|
|
130
118
|
},
|
|
131
119
|
getCoinsGreaterThanAmount(amount, coins) {
|
|
132
120
|
const coinsWithBalance = [];
|
|
@@ -148,25 +136,28 @@ exports.SuiUtils = {
|
|
|
148
136
|
throw new Error("Insufficient balance");
|
|
149
137
|
}
|
|
150
138
|
},
|
|
151
|
-
getOwnedObjectsByPage(
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
139
|
+
async getOwnedObjectsByPage(owner, query, paginationArgs = "all") {
|
|
140
|
+
let result = [];
|
|
141
|
+
let hasNextPage = true;
|
|
142
|
+
const queryAll = paginationArgs === "all";
|
|
143
|
+
let nextCursor = queryAll ? null : paginationArgs.cursor;
|
|
144
|
+
do {
|
|
145
|
+
const res = await config_1.Config.getSuiClient().getOwnedObjects({
|
|
146
|
+
owner,
|
|
147
|
+
...query,
|
|
148
|
+
cursor: nextCursor,
|
|
149
|
+
limit: queryAll ? null : paginationArgs.limit,
|
|
150
|
+
});
|
|
151
|
+
if (res.data) {
|
|
152
|
+
result = [...result, ...res.data];
|
|
153
|
+
hasNextPage = res.hasNextPage;
|
|
154
|
+
nextCursor = res.nextCursor;
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
hasNextPage = false;
|
|
158
|
+
}
|
|
159
|
+
} while (queryAll && hasNextPage);
|
|
160
|
+
return { data: result, nextCursor, hasNextPage };
|
|
170
161
|
},
|
|
171
162
|
isValidStructTag(value) {
|
|
172
163
|
try {
|
|
@@ -204,11 +195,11 @@ exports.SuiUtils = {
|
|
|
204
195
|
arguments: [balance],
|
|
205
196
|
})[0];
|
|
206
197
|
},
|
|
207
|
-
|
|
198
|
+
collectDust(tx, coinType, coin) {
|
|
208
199
|
tx.moveCall({
|
|
209
|
-
target:
|
|
200
|
+
target: `${_7k_1._7K_PACKAGE_ID}::vault::collect_dust`,
|
|
210
201
|
typeArguments: [coinType],
|
|
211
|
-
arguments: [
|
|
202
|
+
arguments: [tx.object(_7k_1._7K_VAULT), tx.object(_7k_1._7K_CONFIG), coin],
|
|
212
203
|
});
|
|
213
204
|
},
|
|
214
205
|
};
|
package/lib/esm/config/index.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { SuiClient, getFullnodeUrl } from "@mysten/sui/client";
|
|
2
|
+
import { SuiPriceServiceConnection, SuiPythClient, } from "@pythnetwork/pyth-sui-js";
|
|
3
|
+
const HERMES_API = "https://hermes.pyth.network";
|
|
4
|
+
const WORMHOLE_STATE_ID = "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c";
|
|
5
|
+
const PYTH_STATE_ID = "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8";
|
|
2
6
|
let apiKey = "";
|
|
3
7
|
let suiClient = new SuiClient({
|
|
4
8
|
url: getFullnodeUrl("mainnet"),
|
|
5
9
|
});
|
|
10
|
+
let pythClient = new SuiPythClient(suiClient, PYTH_STATE_ID, WORMHOLE_STATE_ID);
|
|
11
|
+
let pythConnection = new SuiPriceServiceConnection(HERMES_API);
|
|
6
12
|
function setApiKey(key) {
|
|
7
13
|
apiKey = key;
|
|
8
14
|
}
|
|
@@ -15,10 +21,26 @@ function getSuiClient() {
|
|
|
15
21
|
function setSuiClient(client) {
|
|
16
22
|
suiClient = client;
|
|
17
23
|
}
|
|
24
|
+
function setPythClient(client) {
|
|
25
|
+
pythClient = client;
|
|
26
|
+
}
|
|
27
|
+
function getPythClient() {
|
|
28
|
+
return pythClient;
|
|
29
|
+
}
|
|
30
|
+
function setPythConnection(connection) {
|
|
31
|
+
pythConnection = connection;
|
|
32
|
+
}
|
|
33
|
+
function getPythConnection() {
|
|
34
|
+
return pythConnection;
|
|
35
|
+
}
|
|
18
36
|
const Config = {
|
|
19
37
|
setApiKey,
|
|
20
38
|
getApiKey,
|
|
21
39
|
setSuiClient,
|
|
22
40
|
getSuiClient,
|
|
41
|
+
setPythClient,
|
|
42
|
+
getPythClient,
|
|
43
|
+
setPythConnection,
|
|
44
|
+
getPythConnection,
|
|
23
45
|
};
|
|
24
46
|
export { Config };
|
package/lib/esm/constants/_7k.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
export const _7K_PACKAGE_ID = "
|
|
1
|
+
export const _7K_PACKAGE_ID = "0xe8f996ea6ff38c557c253d3b93cfe2ebf393816487266786371aa4532a9229f2";
|
|
2
|
+
//legacy V3: "0x7ea6e27ad7af6f3b8671d59df1aaebd7c03dddab893e52a714227b2f4fe91519";
|
|
2
3
|
//legacy V2: "0xa13447019cd982d6bef91cf7b46ad384a52583b1dfc2bdecf31ef0c4bd787a0f";
|
|
3
4
|
//legacy V1: "0xd48e7cdc9e92bec69ce3baa75578010458a0c5b2733d661a84971e8cef6806bc";
|
|
4
|
-
export const _7K_CONFIG = "
|
|
5
|
-
|
|
5
|
+
export const _7K_CONFIG = "0x47442a93f7727d188ba7cb71031170d1786af70013cb7ad5115f3fe877ff0c54";
|
|
6
|
+
//legacy v3: "0x0f8fc23dbcc9362b72c7a4c5aa53fcefa02ebfbb83a812c8c262ccd2c076d9ee";
|
|
7
|
+
export const _7K_VAULT = "0x442ad50389ed5cda6f7a6f5a7ae6361a4c05ef1d9fb2e54fbba5a268d690bfe6";
|
|
8
|
+
//legacy v3: "0x39a3c55742c0e011b6f65548e73cf589e1ae5e82dbfab449ca57f24c3bcd9514";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import BigNumber from "bignumber.js";
|
|
2
1
|
import { API_ENDPOINTS } from "../../constants/apiEndpoints";
|
|
3
2
|
export const GLOBAL_CONFIG_ID = "0xffc7f420b481ed7a012b42e125fd7e5716b5673759cf4629e5fcfebce970a72d";
|
|
4
3
|
export const RATE_SCALE = BigInt("1000000000000");
|
|
@@ -7,5 +6,5 @@ export const PACKAGE = "0x0ef0f805710cf53c10f29c4f73e1144a662747e1839689a846e252
|
|
|
7
6
|
export const LIMIT_ORDER_MODULE_ID = `${PACKAGE}::limit_order`;
|
|
8
7
|
export const DCA_ORDER_MODULE_ID = `${PACKAGE}::dca_order`;
|
|
9
8
|
export const CONFIG_MODULE_ID = `${PACKAGE}::config`;
|
|
10
|
-
export const DCA_MAX_RATE =
|
|
9
|
+
export const DCA_MAX_RATE = BigInt("18446744073709551615");
|
|
11
10
|
export const LO_DCA_API = `${API_ENDPOINTS.LO_DCA}/api`;
|