@7kprotocol/sdk-ts 3.5.2 → 3.6.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/lib/cjs/config/index.js +9 -0
- package/lib/cjs/constants/apiEndpoints.js +1 -1
- package/lib/cjs/features/metaAg/common.js +103 -0
- package/lib/cjs/features/metaAg/error.js +35 -0
- package/lib/cjs/features/metaAg/index.js +99 -115
- package/lib/cjs/features/metaAg/providers/bluefin7k.js +57 -0
- package/lib/cjs/features/metaAg/providers/{bluefin.js → bluefin7kLegacy.js} +13 -13
- package/lib/cjs/features/metaAg/providers/cetus.js +7 -7
- package/lib/cjs/features/metaAg/providers/flowx.js +6 -6
- package/lib/cjs/features/metaAg/providers/okx.js +182 -0
- package/lib/cjs/features/swap/buildTx.js +3 -0
- package/lib/cjs/features/swap/buildTxV2.js +10 -6
- package/lib/cjs/features/swap/config.js +2 -1
- package/lib/cjs/features/swap/getQuote.js +3 -2
- package/lib/cjs/libs/protocols/bluefinx/client.js +1 -1
- package/lib/cjs/types/config/index.d.ts +4 -0
- package/lib/cjs/types/config/index.d.ts.map +1 -1
- package/lib/cjs/types/features/metaAg/common.d.ts +24 -0
- package/lib/cjs/types/features/metaAg/common.d.ts.map +1 -0
- package/lib/cjs/types/features/metaAg/error.d.ts +60 -0
- package/lib/cjs/types/features/metaAg/error.d.ts.map +1 -0
- package/lib/cjs/types/features/metaAg/index.d.ts +11 -2
- package/lib/cjs/types/features/metaAg/index.d.ts.map +1 -1
- package/lib/cjs/types/features/metaAg/providers/bluefin7k.d.ts +11 -0
- package/lib/cjs/types/features/metaAg/providers/bluefin7k.d.ts.map +1 -0
- package/lib/cjs/types/features/metaAg/providers/bluefin7kLegacy.d.ts +11 -0
- package/lib/cjs/types/features/metaAg/providers/bluefin7kLegacy.d.ts.map +1 -0
- package/lib/cjs/types/features/metaAg/providers/cetus.d.ts +4 -5
- package/lib/cjs/types/features/metaAg/providers/cetus.d.ts.map +1 -1
- package/lib/cjs/types/features/metaAg/providers/flowx.d.ts +3 -3
- package/lib/cjs/types/features/metaAg/providers/flowx.d.ts.map +1 -1
- package/lib/cjs/types/features/metaAg/providers/okx.d.ts +21 -0
- package/lib/cjs/types/features/metaAg/providers/okx.d.ts.map +1 -0
- package/lib/cjs/types/features/swap/buildTx.d.ts.map +1 -1
- package/lib/cjs/types/features/swap/buildTxV2.d.ts +3 -3
- package/lib/cjs/types/features/swap/buildTxV2.d.ts.map +1 -1
- package/lib/cjs/types/features/swap/config.d.ts.map +1 -1
- package/lib/cjs/types/features/swap/getQuote.d.ts +1 -3
- package/lib/cjs/types/features/swap/getQuote.d.ts.map +1 -1
- package/lib/cjs/types/index.d.ts +3 -1
- package/lib/cjs/types/index.d.ts.map +1 -1
- package/lib/cjs/types/metaAg.js +10 -4
- package/lib/cjs/types/okx.js +6 -0
- package/lib/cjs/types/types/metaAg.d.ts +62 -12
- package/lib/cjs/types/types/metaAg.d.ts.map +1 -1
- package/lib/cjs/types/types/okx.d.ts +206 -0
- package/lib/cjs/types/types/okx.d.ts.map +1 -0
- package/lib/cjs/types/utils/sui.d.ts +1 -0
- package/lib/cjs/types/utils/sui.d.ts.map +1 -1
- package/lib/cjs/utils/sui.js +17 -1
- package/lib/esm/config/index.js +9 -0
- package/lib/esm/constants/apiEndpoints.js +1 -1
- package/lib/esm/features/metaAg/common.js +96 -0
- package/lib/esm/features/metaAg/error.js +33 -0
- package/lib/esm/features/metaAg/index.js +100 -116
- package/lib/esm/features/metaAg/providers/bluefin7k.js +55 -0
- package/lib/esm/features/metaAg/providers/{bluefin.js → bluefin7kLegacy.js} +11 -11
- package/lib/esm/features/metaAg/providers/cetus.js +7 -7
- package/lib/esm/features/metaAg/providers/flowx.js +6 -6
- package/lib/esm/features/metaAg/providers/okx.js +147 -0
- package/lib/esm/features/swap/buildTx.js +3 -0
- package/lib/esm/features/swap/buildTxV2.js +6 -2
- package/lib/esm/features/swap/config.js +2 -1
- package/lib/esm/features/swap/getQuote.js +3 -2
- package/lib/esm/libs/protocols/bluefinx/client.js +1 -1
- package/lib/esm/types/config/index.d.ts +4 -0
- package/lib/esm/types/config/index.d.ts.map +1 -1
- package/lib/esm/types/features/metaAg/common.d.ts +24 -0
- package/lib/esm/types/features/metaAg/common.d.ts.map +1 -0
- package/lib/esm/types/features/metaAg/error.d.ts +60 -0
- package/lib/esm/types/features/metaAg/error.d.ts.map +1 -0
- package/lib/esm/types/features/metaAg/index.d.ts +11 -2
- package/lib/esm/types/features/metaAg/index.d.ts.map +1 -1
- package/lib/esm/types/features/metaAg/providers/bluefin7k.d.ts +11 -0
- package/lib/esm/types/features/metaAg/providers/bluefin7k.d.ts.map +1 -0
- package/lib/esm/types/features/metaAg/providers/bluefin7kLegacy.d.ts +11 -0
- package/lib/esm/types/features/metaAg/providers/bluefin7kLegacy.d.ts.map +1 -0
- package/lib/esm/types/features/metaAg/providers/cetus.d.ts +4 -5
- package/lib/esm/types/features/metaAg/providers/cetus.d.ts.map +1 -1
- package/lib/esm/types/features/metaAg/providers/flowx.d.ts +3 -3
- package/lib/esm/types/features/metaAg/providers/flowx.d.ts.map +1 -1
- package/lib/esm/types/features/metaAg/providers/okx.d.ts +21 -0
- package/lib/esm/types/features/metaAg/providers/okx.d.ts.map +1 -0
- package/lib/esm/types/features/swap/buildTx.d.ts.map +1 -1
- package/lib/esm/types/features/swap/buildTxV2.d.ts +3 -3
- package/lib/esm/types/features/swap/buildTxV2.d.ts.map +1 -1
- package/lib/esm/types/features/swap/config.d.ts.map +1 -1
- package/lib/esm/types/features/swap/getQuote.d.ts +1 -3
- package/lib/esm/types/features/swap/getQuote.d.ts.map +1 -1
- package/lib/esm/types/index.d.ts +3 -1
- package/lib/esm/types/index.d.ts.map +1 -1
- package/lib/esm/types/metaAg.js +7 -2
- package/lib/esm/types/okx.js +5 -0
- package/lib/esm/types/types/metaAg.d.ts +62 -12
- package/lib/esm/types/types/metaAg.d.ts.map +1 -1
- package/lib/esm/types/types/okx.d.ts +206 -0
- package/lib/esm/types/types/okx.d.ts.map +1 -0
- package/lib/esm/types/utils/sui.d.ts +1 -0
- package/lib/esm/types/utils/sui.d.ts.map +1 -1
- package/lib/esm/utils/sui.js +16 -1
- package/package.json +3 -1
- package/lib/cjs/types/features/metaAg/providers/bluefin.d.ts +0 -11
- package/lib/cjs/types/features/metaAg/providers/bluefin.d.ts.map +0 -1
- package/lib/cjs/types/utils/condition.d.ts +0 -2
- package/lib/cjs/types/utils/condition.d.ts.map +0 -1
- package/lib/cjs/utils/condition.js +0 -8
- package/lib/esm/types/features/metaAg/providers/bluefin.d.ts +0 -11
- package/lib/esm/types/features/metaAg/providers/bluefin.d.ts.map +0 -1
- package/lib/esm/types/utils/condition.d.ts +0 -2
- package/lib/esm/types/utils/condition.d.ts.map +0 -1
- package/lib/esm/utils/condition.js +0 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
2
|
-
import { BuildTxResult
|
|
2
|
+
import { BuildTxResult } from "../../types/aggregator";
|
|
3
3
|
import { BuildTxParams, MultiSwapParams } from "../../types/tx";
|
|
4
4
|
/**
|
|
5
5
|
* Wave-based transaction builder that optimizes swap execution by:
|
|
@@ -7,8 +7,8 @@ import { BuildTxParams, MultiSwapParams } from "../../types/tx";
|
|
|
7
7
|
* 2. Merging redundant swaps to the same pool within each wave
|
|
8
8
|
* 3. Processing waves sequentially, passing intermediate tokens between waves
|
|
9
9
|
*/
|
|
10
|
-
export declare const buildTxV2: (
|
|
11
|
-
export declare const
|
|
10
|
+
export declare const buildTxV2: (params: BuildTxParams) => Promise<BuildTxResult>;
|
|
11
|
+
export declare const buildTxV2Int: ({ quoteResponse, accountAddress, slippage, commission: __commission, devInspect, extendTx, isSponsored, }: BuildTxParams, beforeBuildBluefinXTx?: (tx: Transaction, coinOut: TransactionObjectArgument | undefined) => void) => Promise<BuildTxResult>;
|
|
12
12
|
/**
|
|
13
13
|
* execute multiple swap in single transaction
|
|
14
14
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildTxV2.d.ts","sourceRoot":"","sources":["../../../../../src/features/swap/buildTxV2.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AAIlC,OAAO,EACL,aAAa,
|
|
1
|
+
{"version":3,"file":"buildTxV2.d.ts","sourceRoot":"","sources":["../../../../../src/features/swap/buildTxV2.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AAIlC,OAAO,EACL,aAAa,EAId,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAUhE;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GACpB,QAAQ,aAAa,KACpB,OAAO,CAAC,aAAa,CAEvB,CAAC;AAEF,eAAO,MAAM,YAAY,GACvB,2GAQG,aAAa,EAChB,wBAAwB,CACtB,EAAE,EAAE,WAAW,EACf,OAAO,EAAE,yBAAyB,GAAG,SAAS,KAC3C,IAAI,KACR,OAAO,CAAC,aAAa,CAwFvB,CAAC;AAiKF;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GAAU,iDAM7B,eAAe,uDAiDjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../../src/features/swap/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../../src/features/swap/config.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD,eAAO,MAAM,cAAc,EAAE,MAqL5B,CAAC;AAIF,wBAAsB,SAAS,oBAiB9B"}
|
|
@@ -17,13 +17,11 @@ interface Params {
|
|
|
17
17
|
taker?: string;
|
|
18
18
|
/** If true, excludes all liquidity sources that depend on pyth price feeds - pyth client use tx.gas to pay the fee*/
|
|
19
19
|
isSponsored?: boolean;
|
|
20
|
-
/** Custom API endpoint */
|
|
21
|
-
api?: string;
|
|
22
20
|
/** Maximum number of paths to consider for the quote */
|
|
23
21
|
maxPaths?: number;
|
|
24
22
|
}
|
|
25
23
|
export declare const DEFAULT_SOURCES: SourceDex[];
|
|
26
24
|
export declare const ORACLE_BASED_SOURCES: Set<SourceDex>;
|
|
27
|
-
export declare function getQuote({ tokenIn, tokenOut, amountIn, sources: _sources, commissionBps, targetPools, excludedPools, taker, isSponsored,
|
|
25
|
+
export declare function getQuote({ tokenIn, tokenOut, amountIn, sources: _sources, commissionBps, targetPools, excludedPools, taker, isSponsored, maxPaths, }: Params): Promise<QuoteResponse>;
|
|
28
26
|
export {};
|
|
29
27
|
//# sourceMappingURL=getQuote.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getQuote.d.ts","sourceRoot":"","sources":["../../../../../src/features/swap/getQuote.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getQuote.d.ts","sourceRoot":"","sources":["../../../../../src/features/swap/getQuote.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,aAAa,EACb,SAAS,EACV,MAAM,wBAAwB,CAAC;AAEhC,UAAU,MAAM;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB;;;kEAG8D;IAC9D,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,qDAAqD;IACrD,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qHAAqH;IACrH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,eAAe,EAAE,SAAS,EA0BtC,CAAC;AAEF,eAAO,MAAM,oBAAoB,gBAM/B,CAAC;AAEH,wBAAsB,QAAQ,CAAC,EAC7B,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,OAAO,EAAE,QAA0B,EACnC,aAAa,EACb,WAAW,EACX,aAAa,EACb,KAAK,EACL,WAAW,EACX,QAAQ,GACT,EAAE,MAAM,0BA8CR"}
|
package/lib/cjs/types/index.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ declare const setSuiClient: (client: import("@mysten/sui/dist/cjs/client").SuiCl
|
|
|
11
11
|
export { buildTx, buildTxV2, cancelDcaOrder, cancelLimitOrder, claimExpiredLimitOrder, Config, DEFAULT_SOURCES, estimateGasFee, executeBluefinTx, executeTx, getClosedDcaOrders, getClosedLimitOrders, getDcaOrderExecutions, getOpenDcaOrders, getOpenLimitOrders, getQuote, getSuiClient, getSuiPrice, getSwapHistory, getTokenPrice, getTokenPrices, MetaAg, multiSwap, placeDcaOrder, placeLimitOrder, setSuiClient, };
|
|
12
12
|
declare const _default: {
|
|
13
13
|
Config: {
|
|
14
|
+
setApi: (url: string) => void;
|
|
15
|
+
getApi: () => string;
|
|
14
16
|
setApiKey: (key: string) => void;
|
|
15
17
|
getApiKey: () => string;
|
|
16
18
|
setBluefinXApiKey: (key: string) => void;
|
|
@@ -30,7 +32,7 @@ declare const _default: {
|
|
|
30
32
|
getQuote: typeof getQuote;
|
|
31
33
|
estimateGasFee: typeof estimateGasFee;
|
|
32
34
|
buildTx: ({ quoteResponse, accountAddress, slippage, commission: __commission, devInspect, extendTx, isSponsored, }: import("./types/tx").BuildTxParams) => Promise<import("./types/aggregator").BuildTxResult>;
|
|
33
|
-
buildTxV2: (
|
|
35
|
+
buildTxV2: (params: import("./types/tx").BuildTxParams) => Promise<import("./types/aggregator").BuildTxResult>;
|
|
34
36
|
multiSwap: ({ sender, slippageBps, swaps, tx, commission, }: import("./types/tx").MultiSwapParams) => Promise<Record<string, import("@mysten/sui/dist/cjs/transactions").TransactionObjectArgument>>;
|
|
35
37
|
getSwapHistory: typeof getSwapHistory;
|
|
36
38
|
executeTx: (tx: import("./types/aggregator").AggregatorTx, signature: string, signedTxBytes: string, options?: import("@mysten/sui/dist/cjs/client").SuiTransactionBlockResponseOptions) => Promise<import("@mysten/sui/dist/cjs/client").SuiTransactionBlockResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,OAAO,EACL,OAAO,EACP,SAAS,EACT,eAAe,EACf,cAAc,EACd,SAAS,EACT,QAAQ,EACR,cAAc,EACd,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,eAAe,EAChB,MAAM,qBAAqB,CAAC;AAG7B,QAAA,MAAM,YAAY,uDAAsB,CAAC;AACzC,QAAA,MAAM,YAAY,mEAAsB,CAAC;AAEzC,OAAO,EACL,OAAO,EACP,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EAEtB,MAAM,EACN,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAElB,QAAQ,EAER,YAAY,EACZ,WAAW,EACX,cAAc,EAEd,aAAa,EACb,cAAc,EACd,MAAM,EACN,SAAS,EAET,aAAa,EAEb,eAAe,EACf,YAAY,GACb,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,OAAO,EACL,OAAO,EACP,SAAS,EACT,eAAe,EACf,cAAc,EACd,SAAS,EACT,QAAQ,EACR,cAAc,EACd,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,eAAe,EAChB,MAAM,qBAAqB,CAAC;AAG7B,QAAA,MAAM,YAAY,uDAAsB,CAAC;AACzC,QAAA,MAAM,YAAY,mEAAsB,CAAC;AAEzC,OAAO,EACL,OAAO,EACP,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EAEtB,MAAM,EACN,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAElB,QAAQ,EAER,YAAY,EACZ,WAAW,EACX,cAAc,EAEd,aAAa,EACb,cAAc,EACd,MAAM,EACN,SAAS,EAET,aAAa,EAEb,eAAe,EACf,YAAY,GACb,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,wBAwCE"}
|
package/lib/cjs/types/metaAg.js
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isSwapAPIProvider = exports.isAggregatorProvider = exports.EProvider = void 0;
|
|
4
4
|
var EProvider;
|
|
5
5
|
(function (EProvider) {
|
|
6
|
+
EProvider["BLUEFIN7K_LEGACY"] = "bluefin7k_legacy";
|
|
6
7
|
EProvider["BLUEFIN7K"] = "bluefin7k";
|
|
7
8
|
EProvider["CETUS"] = "cetus";
|
|
8
9
|
EProvider["FLOWX"] = "flowx";
|
|
10
|
+
EProvider["OKX"] = "okx";
|
|
9
11
|
})(EProvider || (exports.EProvider = EProvider = {}));
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
const isAggregatorProvider = (provider) => provider.kind === EProvider.BLUEFIN7K_LEGACY ||
|
|
13
|
+
provider.kind === EProvider.BLUEFIN7K ||
|
|
14
|
+
provider.kind === EProvider.CETUS ||
|
|
15
|
+
provider.kind === EProvider.FLOWX;
|
|
16
|
+
exports.isAggregatorProvider = isAggregatorProvider;
|
|
17
|
+
const isSwapAPIProvider = (provider) => provider.kind === EProvider.OKX;
|
|
18
|
+
exports.isSwapAPIProvider = isSwapAPIProvider;
|
|
@@ -1,24 +1,34 @@
|
|
|
1
|
+
import type { QuoteResponse, SourceDex } from "@bluefin-exchange/bluefin7k-aggregator-sdk";
|
|
1
2
|
import type { PreSwapLpChangeParams, RouterDataV3 } from "@cetusprotocol/aggregator-sdk";
|
|
2
3
|
import type { AggregatorQuoter, Protocol } from "@flowx-finance/sdk";
|
|
3
4
|
import type { GasCostSummary } from "@mysten/sui/client";
|
|
5
|
+
import { SignatureWithBytes } from "@mysten/sui/cryptography";
|
|
4
6
|
import type { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
5
|
-
import { QuoteResponse, SourceDex } from "./aggregator";
|
|
7
|
+
import { QuoteResponse as LegacyQuoteResponse, SourceDex as LegacySourceDex } from "./aggregator";
|
|
8
|
+
import { OkxSwapResponseData } from "./okx";
|
|
6
9
|
export declare enum EProvider {
|
|
10
|
+
BLUEFIN7K_LEGACY = "bluefin7k_legacy",
|
|
7
11
|
BLUEFIN7K = "bluefin7k",
|
|
8
12
|
CETUS = "cetus",
|
|
9
|
-
FLOWX = "flowx"
|
|
13
|
+
FLOWX = "flowx",
|
|
14
|
+
OKX = "okx"
|
|
10
15
|
}
|
|
11
16
|
type ProviderBaseOptions = {
|
|
12
17
|
api?: string;
|
|
13
18
|
apiKey?: string;
|
|
14
19
|
disabled?: boolean;
|
|
15
20
|
};
|
|
16
|
-
export type
|
|
17
|
-
sources?:
|
|
21
|
+
export type BluefinLegacyProviderOptions = ProviderBaseOptions & {
|
|
22
|
+
sources?: LegacySourceDex[];
|
|
18
23
|
maxPaths?: number;
|
|
19
24
|
excludedPools?: string[];
|
|
20
25
|
targetPools?: string[];
|
|
21
26
|
};
|
|
27
|
+
export type Bluefin7kProviderOptions = ProviderBaseOptions & {
|
|
28
|
+
sources?: SourceDex[];
|
|
29
|
+
excludedPools?: string[];
|
|
30
|
+
targetPools?: string[];
|
|
31
|
+
};
|
|
22
32
|
export type FlowxProviderOptions = ProviderBaseOptions & {
|
|
23
33
|
sources?: Protocol[];
|
|
24
34
|
excludePools?: string[];
|
|
@@ -34,12 +44,20 @@ export type CetusProviderOptions = ProviderBaseOptions & {
|
|
|
34
44
|
depth?: number;
|
|
35
45
|
liquidityChanges?: PreSwapLpChangeParams[];
|
|
36
46
|
};
|
|
47
|
+
export type OkxProviderOptions = Required<Omit<ProviderBaseOptions, "api">> & {
|
|
48
|
+
api?: string;
|
|
49
|
+
secretKey: string;
|
|
50
|
+
apiPassphrase: string;
|
|
51
|
+
projectId: string;
|
|
52
|
+
};
|
|
37
53
|
export interface MetaAgOptions {
|
|
38
54
|
/**If not specified, all providers will be used */
|
|
39
55
|
providers?: {
|
|
40
|
-
[EProvider.
|
|
56
|
+
[EProvider.BLUEFIN7K_LEGACY]?: BluefinLegacyProviderOptions;
|
|
57
|
+
[EProvider.BLUEFIN7K]?: Bluefin7kProviderOptions;
|
|
41
58
|
[EProvider.FLOWX]?: FlowxProviderOptions;
|
|
42
59
|
[EProvider.CETUS]?: CetusProviderOptions;
|
|
60
|
+
[EProvider.OKX]?: OkxProviderOptions;
|
|
43
61
|
};
|
|
44
62
|
/**Mainnet Json Rpc url, if not specified, the default mainnet url will be used */
|
|
45
63
|
fullnodeUrl?: string;
|
|
@@ -57,9 +75,11 @@ export interface MetaAgOptions {
|
|
|
57
75
|
tipBps?: number;
|
|
58
76
|
}
|
|
59
77
|
export interface MetaQuoteOptions {
|
|
60
|
-
|
|
61
|
-
|
|
78
|
+
coinTypeIn: string;
|
|
79
|
+
coinTypeOut: string;
|
|
62
80
|
amountIn: string;
|
|
81
|
+
/** Required for RFQ providers (ie: BluefinX) */
|
|
82
|
+
signer?: string;
|
|
63
83
|
/**
|
|
64
84
|
* Timeout for quote operation in milliseconds
|
|
65
85
|
* @default 2000ms
|
|
@@ -76,7 +96,22 @@ export interface MetaSimulationOptions {
|
|
|
76
96
|
/** If specify, defer the simulation that could reduce the time to display quote result, you must update the quote via the id on callback
|
|
77
97
|
* else await all quote and simulation before return
|
|
78
98
|
*/
|
|
79
|
-
onSimulated?: (payload:
|
|
99
|
+
onSimulated?: (payload: MetaQuote) => void;
|
|
100
|
+
}
|
|
101
|
+
export interface MetaFastSwapOptions {
|
|
102
|
+
/** Quote object from the quote operation */
|
|
103
|
+
quote: MetaQuote;
|
|
104
|
+
/** Signer address (owner of `coinIn`) */
|
|
105
|
+
signer: string;
|
|
106
|
+
/** If true, use the gas coin for the swap
|
|
107
|
+
* @default true */
|
|
108
|
+
useGasCoin?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Sign the transaction bytes
|
|
111
|
+
* @param txBytes - base64 transaction bytes
|
|
112
|
+
* @returns - signature with bytes
|
|
113
|
+
*/
|
|
114
|
+
signTransaction: (txBytes: string) => Promise<SignatureWithBytes>;
|
|
80
115
|
}
|
|
81
116
|
export interface MetaSwapOptions {
|
|
82
117
|
/** Quote object from the quote operation */
|
|
@@ -92,6 +127,9 @@ export interface MetaSwapOptions {
|
|
|
92
127
|
}
|
|
93
128
|
export type FlowxQuoteResponse = Awaited<ReturnType<AggregatorQuoter["getRoutes"]>>;
|
|
94
129
|
export type MetaQuote = ({
|
|
130
|
+
provider: EProvider.BLUEFIN7K_LEGACY;
|
|
131
|
+
quote: LegacyQuoteResponse;
|
|
132
|
+
} | {
|
|
95
133
|
provider: EProvider.BLUEFIN7K;
|
|
96
134
|
quote: QuoteResponse;
|
|
97
135
|
} | {
|
|
@@ -100,6 +138,9 @@ export type MetaQuote = ({
|
|
|
100
138
|
} | {
|
|
101
139
|
provider: EProvider.FLOWX;
|
|
102
140
|
quote: FlowxQuoteResponse;
|
|
141
|
+
} | {
|
|
142
|
+
provider: EProvider.OKX;
|
|
143
|
+
quote: OkxSwapResponseData;
|
|
103
144
|
}) & {
|
|
104
145
|
/** uuid to keep track the quote result, used to apply simulation result on quote on callback `onSimulated`*/
|
|
105
146
|
id: string;
|
|
@@ -118,10 +159,19 @@ export type MetaQuote = ({
|
|
|
118
159
|
/** Estimate gas consumption if the transaction is executed */
|
|
119
160
|
gasUsed?: GasCostSummary;
|
|
120
161
|
};
|
|
121
|
-
export
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
162
|
+
export interface QuoteProvider {
|
|
163
|
+
readonly kind: EProvider;
|
|
164
|
+
quote(_quoteOptions: MetaQuoteOptions): Promise<MetaQuote | null>;
|
|
165
|
+
}
|
|
166
|
+
export interface SwapAPIProvider extends QuoteProvider {
|
|
167
|
+
readonly kind: EProvider.OKX;
|
|
168
|
+
fastSwap(options: MetaFastSwapOptions): Promise<string>;
|
|
169
|
+
}
|
|
170
|
+
export interface AggregatorProvider extends QuoteProvider {
|
|
171
|
+
readonly kind: EProvider.BLUEFIN7K_LEGACY | EProvider.BLUEFIN7K | EProvider.CETUS | EProvider.FLOWX;
|
|
172
|
+
swap(options: MetaSwapOptions): Promise<TransactionObjectArgument>;
|
|
125
173
|
}
|
|
174
|
+
export declare const isAggregatorProvider: (provider: QuoteProvider) => provider is AggregatorProvider;
|
|
175
|
+
export declare const isSwapAPIProvider: (provider: QuoteProvider) => provider is SwapAPIProvider;
|
|
126
176
|
export {};
|
|
127
177
|
//# sourceMappingURL=metaAg.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metaAg.d.ts","sourceRoot":"","sources":["../../../../src/types/metaAg.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,YAAY,EACb,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EACV,WAAW,EACX,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AAClC,OAAO,
|
|
1
|
+
{"version":3,"file":"metaAg.d.ts","sourceRoot":"","sources":["../../../../src/types/metaAg.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,SAAS,EACV,MAAM,4CAA4C,CAAC;AACpD,OAAO,KAAK,EACV,qBAAqB,EACrB,YAAY,EACb,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EACV,WAAW,EACX,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AAClC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
|
+
/**
|
|
2
|
+
* OKX DEX Swap API Types
|
|
3
|
+
* Documentation: https://web3.okx.com/vi/build/dev-docs/wallet-api/dex-swap
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Gas level options for swap transactions
|
|
7
|
+
*/
|
|
8
|
+
export type GasLevel = "average" | "fast" | "slow";
|
|
9
|
+
/**
|
|
10
|
+
* Swap mode options
|
|
11
|
+
*/
|
|
12
|
+
export type SwapMode = "exactIn" | "exactOut";
|
|
13
|
+
/**
|
|
14
|
+
* Swap API Request Parameters (v6)
|
|
15
|
+
*/
|
|
16
|
+
export interface OkxSwapRequest {
|
|
17
|
+
/** Unique identifier for the chain */
|
|
18
|
+
chainIndex?: string;
|
|
19
|
+
/** The input amount of a token to be sold (set in minimal divisible units, e.g., 1.00 USDT set as 1000000) */
|
|
20
|
+
amount: string;
|
|
21
|
+
/** Swap mode: "exactIn" or "exactOut" (default: "exactIn"). exactOut only supports Ethereum, Base, BSC, Arbitrum chains and Uni v3 protocols */
|
|
22
|
+
swapMode?: SwapMode;
|
|
23
|
+
/** The contract address of a token you want to send (e.g., 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee for native token) */
|
|
24
|
+
fromTokenAddress: string;
|
|
25
|
+
/** The contract address of a token you want to receive */
|
|
26
|
+
toTokenAddress: string;
|
|
27
|
+
/** Slippage limit. For EVM: 0-100. For Solana: 0-less than 100 (e.g., 0.5 means 0.5%) */
|
|
28
|
+
slippagePercent: string;
|
|
29
|
+
/** User's wallet address */
|
|
30
|
+
userWalletAddress: string;
|
|
31
|
+
/** Recipient address of a purchased token (if not set, userWalletAddress will receive the token) */
|
|
32
|
+
swapReceiverAddress?: string;
|
|
33
|
+
/** The percentage of fromTokenAmount sent to referrer. Min > 0, max 10 for Solana, 3 for all other chains. Maximum of nine decimal places */
|
|
34
|
+
feePercent?: string;
|
|
35
|
+
/** Wallet address to receive commission fee for fromToken. Must set feePercent together. Can only choose either fromToken or toToken commission per transaction */
|
|
36
|
+
fromTokenReferrerWalletAddress?: string;
|
|
37
|
+
/** Wallet address to receive commission fee for toToken. Must set feePercent together. Can only choose either fromToken or toToken commission per transaction */
|
|
38
|
+
toTokenReferrerWalletAddress?: string;
|
|
39
|
+
/** Positive slippage percentage (0-10, max 1 decimal point). Solana only, whitelist/enterprise clients only */
|
|
40
|
+
positiveSlippagePercent?: string;
|
|
41
|
+
/** Wallet address that receives positive slippage. Must set positiveSlippagePercent together. Solana only, whitelist/enterprise clients only */
|
|
42
|
+
positiveSlippageFeeAddress?: string;
|
|
43
|
+
/** The gas (in wei) for the swap transaction. EVM only. If too low, an error will be returned */
|
|
44
|
+
gasLimit?: string;
|
|
45
|
+
/** Target gas price level (defaults to "average"). EVM only */
|
|
46
|
+
gasLevel?: GasLevel;
|
|
47
|
+
/** Used for Solana transactions, similar to gasPrice on Ethereum. Determines transaction priority */
|
|
48
|
+
computeUnitPrice?: string;
|
|
49
|
+
/** Used for Solana transactions, similar to gasLimit on Ethereum. If tips is not 0, computeUnitPrice should be set to 0 */
|
|
50
|
+
computeUnitLimit?: string;
|
|
51
|
+
/** Jito tips in SOL. Maximum is "2", minimum is "0.0000000001". Used for MEV protection. Solana only */
|
|
52
|
+
tips?: string;
|
|
53
|
+
/** DexId of liquidity pool for limited quotes, multiple separated by comma (e.g., "1,50,180") */
|
|
54
|
+
dexIds?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Token information
|
|
58
|
+
*/
|
|
59
|
+
export interface OkxTokenInfo {
|
|
60
|
+
/** Token contract address */
|
|
61
|
+
tokenContractAddress: string;
|
|
62
|
+
/** Token symbol (e.g., "USDC") */
|
|
63
|
+
tokenSymbol: string;
|
|
64
|
+
/** Token unit price in USD (may be null for special cases) */
|
|
65
|
+
tokenUnitPrice: string | null;
|
|
66
|
+
/** Decimal number defining smallest unit */
|
|
67
|
+
decimal: string;
|
|
68
|
+
/** Whether the token is a honeypot token */
|
|
69
|
+
isHoneyPot: boolean;
|
|
70
|
+
/** Token tax rate (0-1, where 0.01 = 1%) */
|
|
71
|
+
taxRate: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* DEX Protocol information
|
|
75
|
+
*/
|
|
76
|
+
export interface OkxDexProtocol {
|
|
77
|
+
/** Name of the liquidity protocol (e.g., "Uniswap V3") */
|
|
78
|
+
dexName: string;
|
|
79
|
+
/** Percentage of assets handled by the protocol */
|
|
80
|
+
percent: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Sub-router information
|
|
84
|
+
*/
|
|
85
|
+
export interface OkxSubRouter {
|
|
86
|
+
/** Liquidity protocol used on the path */
|
|
87
|
+
dexProtocol: OkxDexProtocol;
|
|
88
|
+
/** Index of the from token */
|
|
89
|
+
fromTokenIndex: string;
|
|
90
|
+
/** Index of the to token */
|
|
91
|
+
toTokenIndex: string;
|
|
92
|
+
/** Information of token to be sold */
|
|
93
|
+
fromToken: OkxTokenInfo;
|
|
94
|
+
/** Information of token to be bought */
|
|
95
|
+
toToken: OkxTokenInfo;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Main router information (deprecated in v6, kept for backward compatibility)
|
|
99
|
+
* In v6, dexRouterList is an array of OkxSubRouter directly
|
|
100
|
+
*/
|
|
101
|
+
export interface OkxRouter {
|
|
102
|
+
/** One of the main paths for the token swap */
|
|
103
|
+
router: string;
|
|
104
|
+
/** Percentage of assets handled by the main path */
|
|
105
|
+
routerPercent: string;
|
|
106
|
+
/** Quote path sub data set */
|
|
107
|
+
subRouterList: OkxSubRouter[];
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Quote comparison information
|
|
111
|
+
*/
|
|
112
|
+
export interface OkxQuoteCompare {
|
|
113
|
+
/** DEX name of the quote route */
|
|
114
|
+
dexName: string;
|
|
115
|
+
/** DEX logo of the quote route */
|
|
116
|
+
dexLogo: string;
|
|
117
|
+
/** Estimated network fee (USD) of the quote route */
|
|
118
|
+
tradeFee: string;
|
|
119
|
+
/** Received amount of the quote route */
|
|
120
|
+
amountOut: string;
|
|
121
|
+
/** Price impact percentage */
|
|
122
|
+
priceImpactPercentage: string;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Transaction data model
|
|
126
|
+
*/
|
|
127
|
+
export interface OkxTransactionData {
|
|
128
|
+
/** Additional signing data (if required). When tips is specified, represents calldata of jito tips transfer */
|
|
129
|
+
signatureData?: string[];
|
|
130
|
+
/** User's wallet address */
|
|
131
|
+
from: string;
|
|
132
|
+
/** Estimated amount of the gas limit (increase by 50% for accurate data) */
|
|
133
|
+
gas: string;
|
|
134
|
+
/** Gas price in wei */
|
|
135
|
+
gasPrice?: string;
|
|
136
|
+
/** EIP-1559: Recommended priority cost of gas per unit */
|
|
137
|
+
maxPriorityFeePerGas?: string;
|
|
138
|
+
/** The contract address of OKX DEX router */
|
|
139
|
+
to: string;
|
|
140
|
+
/** The amount of native tokens (in wei) to be sent to the contract */
|
|
141
|
+
value: string;
|
|
142
|
+
/** The maximum amount of a token to spend when price reaches upper limit of slippage (applies to exactOut mode) */
|
|
143
|
+
maxSpendAmount?: string;
|
|
144
|
+
/** The minimum amount of a token to buy when price reaches upper limit of slippage */
|
|
145
|
+
minReceiveAmount: string;
|
|
146
|
+
/** Call data */
|
|
147
|
+
data: string;
|
|
148
|
+
/** Current transaction slippage value */
|
|
149
|
+
slippagePercent: string;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Router result data
|
|
153
|
+
*/
|
|
154
|
+
export interface OkxRouterResult {
|
|
155
|
+
/** Unique identifier for the chain */
|
|
156
|
+
chainIndex: string;
|
|
157
|
+
/** Context slot (for Solana) */
|
|
158
|
+
contextSlot?: number;
|
|
159
|
+
/** Quote path data set - array of sub-routers */
|
|
160
|
+
dexRouterList: OkxSubRouter[];
|
|
161
|
+
/** Estimated gas consumption in smallest units (e.g., wei) */
|
|
162
|
+
estimateGasFee: string;
|
|
163
|
+
/** Information of token to be sold */
|
|
164
|
+
fromToken: OkxTokenInfo;
|
|
165
|
+
/** The input amount of a token to be sold */
|
|
166
|
+
fromTokenAmount: string;
|
|
167
|
+
/** Price impact percentage = (Received value – Paid value) / Paid value. Can be positive if received value exceeds paid value */
|
|
168
|
+
priceImpactPercent: string;
|
|
169
|
+
/** Router identifier */
|
|
170
|
+
router: string;
|
|
171
|
+
/** Swap mode: "exactIn" or "exactOut" */
|
|
172
|
+
swapMode: SwapMode;
|
|
173
|
+
/** Information of token to be bought */
|
|
174
|
+
toToken: OkxTokenInfo;
|
|
175
|
+
/** The resulting amount of a token to be bought */
|
|
176
|
+
toTokenAmount: string;
|
|
177
|
+
/** Estimated network fee (USD) of the quote route */
|
|
178
|
+
tradeFee: string;
|
|
179
|
+
/** Comparison of quote routes */
|
|
180
|
+
quoteCompareList?: OkxQuoteCompare[];
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Swap API Response Data
|
|
184
|
+
*/
|
|
185
|
+
export interface OkxSwapResponseData {
|
|
186
|
+
/** Quote path data */
|
|
187
|
+
routerResult: OkxRouterResult;
|
|
188
|
+
/** Contract data model */
|
|
189
|
+
tx: OkxTransactionData;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* OKX API Standard Response Wrapper
|
|
193
|
+
*/
|
|
194
|
+
export interface OkxApiResponse<T> {
|
|
195
|
+
/** Response code ("0" indicates success) */
|
|
196
|
+
code: string;
|
|
197
|
+
/** Response data array */
|
|
198
|
+
data: T[];
|
|
199
|
+
/** Response message */
|
|
200
|
+
msg: string;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Complete Swap API Response
|
|
204
|
+
*/
|
|
205
|
+
export type OkxSwapResponse = OkxApiResponse<OkxSwapResponseData>;
|
|
206
|
+
//# sourceMappingURL=okx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"okx.d.ts","sourceRoot":"","sources":["../../../../src/types/okx.ts"],"names":[],"mappings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B;IAC1B,EAAE,EAAE,kBAAkB,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,uBAAuB;IACvB,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,cAAc,CAAC,mBAAmB,CAAC,CAAC"}
|
|
@@ -53,5 +53,6 @@ export declare const SuiUtils: {
|
|
|
53
53
|
collectDust(tx: Transaction, coinType: string, coin: TransactionArgument): void;
|
|
54
54
|
transferOrDestroyZeroCoin(tx: Transaction, coinType: string, coin: TransactionArgument, address: string): void;
|
|
55
55
|
};
|
|
56
|
+
export declare const isSystemAddress: (address: string) => boolean;
|
|
56
57
|
export {};
|
|
57
58
|
//# sourceMappingURL=sui.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sui.d.ts","sourceRoot":"","sources":["../../../../src/utils/sui.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sui.d.ts","sourceRoot":"","sources":["../../../../src/utils/sui.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EAEV,sBAAsB,EACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAc5E,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;;;;2BAUxB,WAAW,YACL,MAAM,WACP,mBAAmB;oBASd,WAAW,YAAY,MAAM,QAAQ,mBAAmB;kCASlE,WAAW,YACL,MAAM,QACV,mBAAmB,WAChB,MAAM;CAQlB,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,SAAS,MAAM,YAY9C,CAAC"}
|
package/lib/cjs/utils/sui.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SuiUtils = void 0;
|
|
3
|
+
exports.isSystemAddress = exports.SuiUtils = void 0;
|
|
4
|
+
const aggregator_sdk_1 = require("@cetusprotocol/aggregator-sdk");
|
|
4
5
|
const transactions_1 = require("@mysten/sui/transactions");
|
|
5
6
|
const utils_1 = require("@mysten/sui/utils");
|
|
6
7
|
const config_1 = require("../config");
|
|
@@ -217,3 +218,18 @@ exports.SuiUtils = {
|
|
|
217
218
|
});
|
|
218
219
|
},
|
|
219
220
|
};
|
|
221
|
+
const isSystemAddress = (address) => {
|
|
222
|
+
const addr = (0, utils_1.normalizeSuiAddress)(address);
|
|
223
|
+
const addresses = [
|
|
224
|
+
utils_1.SUI_SYSTEM_ADDRESS,
|
|
225
|
+
utils_1.MOVE_STDLIB_ADDRESS,
|
|
226
|
+
utils_1.SUI_FRAMEWORK_ADDRESS,
|
|
227
|
+
utils_1.SUI_CLOCK_OBJECT_ID,
|
|
228
|
+
utils_1.SUI_RANDOM_OBJECT_ID,
|
|
229
|
+
aggregator_sdk_1.SUI_SYSTEM_STATE_OBJECT_ID,
|
|
230
|
+
"0x0",
|
|
231
|
+
].map((v) => (0, utils_1.normalizeSuiAddress)(v));
|
|
232
|
+
return addresses.includes(addr);
|
|
233
|
+
};
|
|
234
|
+
exports.isSystemAddress = isSystemAddress;
|
|
235
|
+
console.log((0, exports.isSystemAddress)("0x0"));
|
package/lib/esm/config/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { SuiPriceServiceConnection, SuiPythClient, } from "@pythnetwork/pyth-sui
|
|
|
3
3
|
const HERMES_API = "https://hermes.pyth.network";
|
|
4
4
|
const WORMHOLE_STATE_ID = "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c";
|
|
5
5
|
const PYTH_STATE_ID = "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8";
|
|
6
|
+
let api = "";
|
|
6
7
|
let apiKey = "";
|
|
7
8
|
let bluefinXApiKey = "";
|
|
8
9
|
let suiClient = new SuiClient({
|
|
@@ -10,6 +11,12 @@ let suiClient = new SuiClient({
|
|
|
10
11
|
});
|
|
11
12
|
let pythClient = new SuiPythClient(suiClient, PYTH_STATE_ID, WORMHOLE_STATE_ID);
|
|
12
13
|
let pythConnection = new SuiPriceServiceConnection(HERMES_API);
|
|
14
|
+
function setApi(url) {
|
|
15
|
+
api = url;
|
|
16
|
+
}
|
|
17
|
+
function getApi() {
|
|
18
|
+
return api;
|
|
19
|
+
}
|
|
13
20
|
function setApiKey(key) {
|
|
14
21
|
apiKey = key;
|
|
15
22
|
}
|
|
@@ -41,6 +48,8 @@ function getPythConnection() {
|
|
|
41
48
|
return pythConnection;
|
|
42
49
|
}
|
|
43
50
|
const Config = {
|
|
51
|
+
setApi,
|
|
52
|
+
getApi,
|
|
44
53
|
setApiKey,
|
|
45
54
|
getApiKey,
|
|
46
55
|
setBluefinXApiKey,
|