@cetusprotocol/aggregator-sdk 1.4.9 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bun.lock +3 -3
- package/dist/index.cjs +141 -86
- package/dist/index.d.cts +23 -72
- package/dist/index.d.ts +23 -72
- package/dist/index.js +141 -87
- package/package.json +2 -2
package/bun.lock
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"": {
|
|
6
6
|
"name": "@cetusprotocol/aggregator-sdk",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@mysten/sui": "^2.
|
|
8
|
+
"@mysten/sui": "^2.6.0",
|
|
9
9
|
"@pythnetwork/hermes-client": "^3.1.0",
|
|
10
10
|
"bip39": "^3.1.0",
|
|
11
11
|
"dotenv": "^16.4.5",
|
|
@@ -110,9 +110,9 @@
|
|
|
110
110
|
|
|
111
111
|
"@jridgewell/trace-mapping": ["@jridgewell/trace-mapping@0.3.30", "", { "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" } }, "sha512-GQ7Nw5G2lTu/BtHTKfXhKHok2WGetd4XYcVKGx00SjAk8GMwgJM3zr6zORiPGuOE+/vkc90KtTosSSvaCjKb2Q=="],
|
|
112
112
|
|
|
113
|
-
"@mysten/bcs": ["@mysten/bcs@2.0.
|
|
113
|
+
"@mysten/bcs": ["@mysten/bcs@2.0.2", "", { "dependencies": { "@mysten/utils": "^0.3.1", "@scure/base": "^2.0.0" } }, "sha512-c/nVRPJEV1fRZdKXhysVsy/yCPdiFt7jn6A4/7W2LH1ZPSVPzRkxtLY362D0zaLuBnyT5Y9d9nFLm3ixI8Goug=="],
|
|
114
114
|
|
|
115
|
-
"@mysten/sui": ["@mysten/sui@2.
|
|
115
|
+
"@mysten/sui": ["@mysten/sui@2.6.0", "", { "dependencies": { "@graphql-typed-document-node/core": "^3.2.0", "@mysten/bcs": "^2.0.2", "@mysten/utils": "^0.3.1", "@noble/curves": "^2.0.1", "@noble/hashes": "^2.0.1", "@protobuf-ts/grpcweb-transport": "^2.11.1", "@protobuf-ts/runtime": "^2.11.1", "@protobuf-ts/runtime-rpc": "^2.11.1", "@scure/base": "^2.0.0", "@scure/bip32": "^2.0.1", "@scure/bip39": "^2.0.1", "gql.tada": "^1.9.0", "graphql": "^16.12.0", "poseidon-lite": "0.2.1", "valibot": "^1.2.0" } }, "sha512-Dp3z7mDuUCXGgldQ3/AtC1iDiK48XTuAi//fPrHdxEaMl+f5VLjbYtB+mlKNC1SVYLKOUjTeF/RA9qfEBY++pA=="],
|
|
116
116
|
|
|
117
117
|
"@mysten/utils": ["@mysten/utils@0.3.1", "", { "dependencies": { "@scure/base": "^2.0.0" } }, "sha512-36KhxG284uhDdSnlkyNaS6fzKTX9FpP2WQWOwUKIRsqQFFIm2ooCf2TP1IuqrtMpkairwpiWkAS0eg7cpemVzg=="],
|
|
118
118
|
|
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var transactions = require('@mysten/sui/transactions');
|
|
4
4
|
var JSONbig = require('json-bigint');
|
|
5
5
|
var utils = require('@mysten/sui/utils');
|
|
6
|
-
var
|
|
6
|
+
var jsonRpc = require('@mysten/sui/jsonRpc');
|
|
7
7
|
var hermesClient = require('@pythnetwork/hermes-client');
|
|
8
8
|
var bcs = require('@mysten/sui/bcs');
|
|
9
9
|
|
|
@@ -3416,7 +3416,7 @@ var AGGREGATOR_V3_CONFIG = {
|
|
|
3416
3416
|
};
|
|
3417
3417
|
|
|
3418
3418
|
// src/api.ts
|
|
3419
|
-
var SDK_VERSION =
|
|
3419
|
+
var SDK_VERSION = 1010501;
|
|
3420
3420
|
function parseRouterResponse(data, byAmountIn) {
|
|
3421
3421
|
let packages = /* @__PURE__ */ new Map();
|
|
3422
3422
|
if (data.packages) {
|
|
@@ -7857,11 +7857,12 @@ var PythAdapter = class {
|
|
|
7857
7857
|
if (this.baseUpdateFee !== void 0) {
|
|
7858
7858
|
return this.baseUpdateFee;
|
|
7859
7859
|
}
|
|
7860
|
-
const
|
|
7861
|
-
|
|
7862
|
-
|
|
7860
|
+
const res = await this.client.getObject({
|
|
7861
|
+
id: this.pythStateId,
|
|
7862
|
+
options: { showContent: true }
|
|
7863
7863
|
});
|
|
7864
|
-
const
|
|
7864
|
+
const content = res.data?.content;
|
|
7865
|
+
const json = content && "fields" in content ? content.fields : null;
|
|
7865
7866
|
if (!json) {
|
|
7866
7867
|
throw new Error("Unable to fetch pyth state object");
|
|
7867
7868
|
}
|
|
@@ -7869,16 +7870,21 @@ var PythAdapter = class {
|
|
|
7869
7870
|
return this.baseUpdateFee;
|
|
7870
7871
|
}
|
|
7871
7872
|
async getPackageId(objectId) {
|
|
7872
|
-
const
|
|
7873
|
-
objectId,
|
|
7874
|
-
|
|
7873
|
+
const res = await this.client.getObject({
|
|
7874
|
+
id: objectId,
|
|
7875
|
+
options: { showContent: true }
|
|
7875
7876
|
});
|
|
7876
|
-
const
|
|
7877
|
+
const content = res.data?.content;
|
|
7878
|
+
const json = content && "fields" in content ? content.fields : null;
|
|
7877
7879
|
if (!json) {
|
|
7878
7880
|
throw new Error(`Cannot fetch package id for object ${objectId}`);
|
|
7879
7881
|
}
|
|
7880
7882
|
if ("upgrade_cap" in json) {
|
|
7881
|
-
|
|
7883
|
+
const upgradeCap = json.upgrade_cap;
|
|
7884
|
+
const packageId = upgradeCap?.fields?.package;
|
|
7885
|
+
if (typeof packageId === "string") {
|
|
7886
|
+
return packageId;
|
|
7887
|
+
}
|
|
7882
7888
|
}
|
|
7883
7889
|
throw new Error("upgrade_cap not found");
|
|
7884
7890
|
}
|
|
@@ -7902,20 +7908,19 @@ var PythAdapter = class {
|
|
|
7902
7908
|
const { id: tableId, fieldType } = await this.getPriceTableInfo();
|
|
7903
7909
|
const feedIdBytes = Buffer.from(normalizedFeedId, "hex");
|
|
7904
7910
|
try {
|
|
7905
|
-
const
|
|
7906
|
-
bytes: bcs.bcs.vector(bcs.bcs.u8())
|
|
7907
|
-
});
|
|
7908
|
-
const bcsBytes = PriceIdentifier.serialize({ bytes: Array.from(feedIdBytes) }).toBytes();
|
|
7909
|
-
const result = await this.client.getDynamicField({
|
|
7911
|
+
const result = await this.client.getDynamicFieldObject({
|
|
7910
7912
|
parentId: tableId,
|
|
7911
7913
|
name: {
|
|
7912
|
-
type: fieldType
|
|
7913
|
-
|
|
7914
|
+
type: `${fieldType}::price_identifier::PriceIdentifier`,
|
|
7915
|
+
value: { bytes: Array.from(feedIdBytes) }
|
|
7914
7916
|
}
|
|
7915
7917
|
});
|
|
7916
|
-
const
|
|
7917
|
-
const
|
|
7918
|
-
const objectId = "
|
|
7918
|
+
const content = result.data?.content;
|
|
7919
|
+
const json = content && "fields" in content ? content.fields : null;
|
|
7920
|
+
const objectId = typeof json?.value === "string" ? json.value : void 0;
|
|
7921
|
+
if (!objectId) {
|
|
7922
|
+
return void 0;
|
|
7923
|
+
}
|
|
7919
7924
|
this.priceFeedObjectIdCache.set(normalizedFeedId, objectId);
|
|
7920
7925
|
return objectId;
|
|
7921
7926
|
} catch {
|
|
@@ -7926,35 +7931,22 @@ var PythAdapter = class {
|
|
|
7926
7931
|
if (this.priceTableInfo !== void 0) {
|
|
7927
7932
|
return this.priceTableInfo;
|
|
7928
7933
|
}
|
|
7929
|
-
|
|
7930
|
-
|
|
7931
|
-
|
|
7932
|
-
|
|
7933
|
-
|
|
7934
|
-
cursor
|
|
7935
|
-
});
|
|
7936
|
-
for (const field of dynamicFields.dynamicFields) {
|
|
7937
|
-
if (field.name.type === "vector<u8>") {
|
|
7938
|
-
const objectId = field.$kind === "DynamicObject" && field.childId ? field.childId : field.fieldId;
|
|
7939
|
-
const fieldObj = await this.client.getObject({
|
|
7940
|
-
objectId,
|
|
7941
|
-
include: { json: true }
|
|
7942
|
-
});
|
|
7943
|
-
const type = fieldObj.object.type;
|
|
7944
|
-
if (type.includes("table::Table")) {
|
|
7945
|
-
const innerTypes = type.replace(/.*table::Table</, "").replace(/>$/, "");
|
|
7946
|
-
const fieldType = innerTypes.split(",")[0].trim();
|
|
7947
|
-
this.priceTableInfo = { id: fieldObj.object.objectId, fieldType };
|
|
7948
|
-
return this.priceTableInfo;
|
|
7949
|
-
}
|
|
7950
|
-
}
|
|
7934
|
+
const result = await this.client.getDynamicFieldObject({
|
|
7935
|
+
parentId: this.pythStateId,
|
|
7936
|
+
name: {
|
|
7937
|
+
type: "vector<u8>",
|
|
7938
|
+
value: "price_info"
|
|
7951
7939
|
}
|
|
7952
|
-
|
|
7953
|
-
|
|
7940
|
+
});
|
|
7941
|
+
if (!result.data?.type) {
|
|
7942
|
+
throw new Error(
|
|
7943
|
+
"Price Table not found, contract may not be initialized"
|
|
7944
|
+
);
|
|
7954
7945
|
}
|
|
7955
|
-
|
|
7956
|
-
|
|
7957
|
-
|
|
7946
|
+
let type = result.data.type.replace("0x2::table::Table<", "");
|
|
7947
|
+
type = type.replace("::price_identifier::PriceIdentifier, 0x2::object::ID>", "");
|
|
7948
|
+
this.priceTableInfo = { id: result.data.objectId, fieldType: type };
|
|
7949
|
+
return this.priceTableInfo;
|
|
7958
7950
|
}
|
|
7959
7951
|
extractVaaBytesFromAccumulatorMessage(accumulatorMessage) {
|
|
7960
7952
|
const trailingPayloadSize = accumulatorMessage.readUint8(6);
|
|
@@ -8138,21 +8130,21 @@ async function getOrCreateAccountCap(txb, client, owner) {
|
|
|
8138
8130
|
}
|
|
8139
8131
|
async function getAccountCap(client, owner) {
|
|
8140
8132
|
const limit = 50;
|
|
8141
|
-
let cursor =
|
|
8133
|
+
let cursor = void 0;
|
|
8142
8134
|
while (true) {
|
|
8143
|
-
const ownedObjects = await client.
|
|
8135
|
+
const ownedObjects = await client.getOwnedObjects({
|
|
8144
8136
|
owner,
|
|
8145
8137
|
cursor,
|
|
8146
8138
|
limit,
|
|
8147
|
-
|
|
8139
|
+
filter: { StructType: `${DEEPBOOK_PACKAGE_ID}::${DEEPBOOK_CUSTODIAN_V2_MODULE}::AccountCap` }
|
|
8148
8140
|
});
|
|
8149
|
-
if (ownedObjects.
|
|
8150
|
-
return ownedObjects.
|
|
8141
|
+
if (ownedObjects.data.length !== 0) {
|
|
8142
|
+
return ownedObjects.data[0].data?.objectId ?? null;
|
|
8151
8143
|
}
|
|
8152
8144
|
if (!ownedObjects.hasNextPage) {
|
|
8153
8145
|
break;
|
|
8154
8146
|
}
|
|
8155
|
-
cursor = ownedObjects.
|
|
8147
|
+
cursor = ownedObjects.nextCursor ?? void 0;
|
|
8156
8148
|
}
|
|
8157
8149
|
return null;
|
|
8158
8150
|
}
|
|
@@ -8180,10 +8172,10 @@ function getAggregatorV2Extend2PublishedAt(publishedAt, packages) {
|
|
|
8180
8172
|
// src/utils/gas.ts
|
|
8181
8173
|
var import_bn4 = __toESM(require_bn());
|
|
8182
8174
|
function extractGasMetrics(result) {
|
|
8183
|
-
const
|
|
8184
|
-
const
|
|
8185
|
-
if (!
|
|
8186
|
-
const errorMsg =
|
|
8175
|
+
const effects = result.effects;
|
|
8176
|
+
const isSuccess = !result.error && effects.status.status === "success";
|
|
8177
|
+
if (!isSuccess) {
|
|
8178
|
+
const errorMsg = result.error ?? effects.status.error ?? "Unknown error";
|
|
8187
8179
|
return {
|
|
8188
8180
|
computationCost: "0",
|
|
8189
8181
|
storageCost: "0",
|
|
@@ -8647,6 +8639,68 @@ var FerraClmmRouter = class {
|
|
|
8647
8639
|
});
|
|
8648
8640
|
}
|
|
8649
8641
|
};
|
|
8642
|
+
var BoltRouter = class {
|
|
8643
|
+
constructor(_env) {
|
|
8644
|
+
}
|
|
8645
|
+
swap(txb, flattenedPath, swapContext, _extends) {
|
|
8646
|
+
const path = flattenedPath.path;
|
|
8647
|
+
if (!path.extendedDetails) {
|
|
8648
|
+
throw new Error("Extended details not found for BOLT");
|
|
8649
|
+
}
|
|
8650
|
+
this.validateExtendedDetails(path.extendedDetails);
|
|
8651
|
+
const swapData = this.prepareSwapData(flattenedPath);
|
|
8652
|
+
this.executeSwapContract(txb, swapData, swapContext);
|
|
8653
|
+
}
|
|
8654
|
+
validateExtendedDetails(extendedDetails) {
|
|
8655
|
+
if (!extendedDetails.bolt_pool_id) {
|
|
8656
|
+
throw new Error("BOLT pool id not found in extended details");
|
|
8657
|
+
}
|
|
8658
|
+
if (!extendedDetails.bolt_oracle_id) {
|
|
8659
|
+
throw new Error("BOLT oracle id not found in extended details");
|
|
8660
|
+
}
|
|
8661
|
+
if (!extendedDetails.bolt_quote_coin_type) {
|
|
8662
|
+
throw new Error("BOLT quote coin type not found in extended details");
|
|
8663
|
+
}
|
|
8664
|
+
}
|
|
8665
|
+
prepareSwapData(flattenedPath) {
|
|
8666
|
+
const path = flattenedPath.path;
|
|
8667
|
+
if (path.publishedAt == null) {
|
|
8668
|
+
throw new Error("BOLT not set publishedAt");
|
|
8669
|
+
}
|
|
8670
|
+
const extendedDetails = path.extendedDetails;
|
|
8671
|
+
const [baseType, quoteType] = path.direction ? [path.from, path.target] : [path.target, path.from];
|
|
8672
|
+
const amountIn = flattenedPath.isLastUseOfIntermediateToken ? AGGREGATOR_V3_CONFIG.MAX_AMOUNT_IN : path.amountIn;
|
|
8673
|
+
return {
|
|
8674
|
+
baseType,
|
|
8675
|
+
quoteType,
|
|
8676
|
+
a2b: path.direction,
|
|
8677
|
+
amountIn,
|
|
8678
|
+
publishedAt: path.publishedAt,
|
|
8679
|
+
poolId: extendedDetails.bolt_pool_id,
|
|
8680
|
+
oracleId: extendedDetails.bolt_oracle_id
|
|
8681
|
+
};
|
|
8682
|
+
}
|
|
8683
|
+
executeSwapContract(txb, swapData, swapContext) {
|
|
8684
|
+
txb.moveCall({
|
|
8685
|
+
target: `${swapData.publishedAt}::bolt::swap`,
|
|
8686
|
+
typeArguments: [swapData.baseType, swapData.quoteType],
|
|
8687
|
+
arguments: [
|
|
8688
|
+
swapContext,
|
|
8689
|
+
// swap_ctx
|
|
8690
|
+
txb.object(swapData.poolId),
|
|
8691
|
+
// pool: &mut LiquidityPool<T0>
|
|
8692
|
+
txb.object(swapData.oracleId),
|
|
8693
|
+
// oracle: &Oracle
|
|
8694
|
+
txb.object(utils.SUI_CLOCK_OBJECT_ID),
|
|
8695
|
+
// clock: &Clock
|
|
8696
|
+
txb.pure.bool(swapData.a2b),
|
|
8697
|
+
// a2b: bool
|
|
8698
|
+
txb.pure.u64(swapData.amountIn)
|
|
8699
|
+
// amount_in: u64
|
|
8700
|
+
]
|
|
8701
|
+
});
|
|
8702
|
+
}
|
|
8703
|
+
};
|
|
8650
8704
|
|
|
8651
8705
|
// src/client.ts
|
|
8652
8706
|
var CETUS = "CETUS";
|
|
@@ -8682,6 +8736,7 @@ var FULLSAIL = "FULLSAIL";
|
|
|
8682
8736
|
var CETUSDLMM = "CETUSDLMM";
|
|
8683
8737
|
var FERRADLMM = "FERRADLMM";
|
|
8684
8738
|
var FERRACLMM = "FERRACLMM";
|
|
8739
|
+
var BOLT = "BOLT";
|
|
8685
8740
|
var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v3";
|
|
8686
8741
|
var ALL_DEXES = [
|
|
8687
8742
|
CETUS,
|
|
@@ -8715,7 +8770,8 @@ var ALL_DEXES = [
|
|
|
8715
8770
|
FULLSAIL,
|
|
8716
8771
|
CETUSDLMM,
|
|
8717
8772
|
FERRADLMM,
|
|
8718
|
-
FERRACLMM
|
|
8773
|
+
FERRACLMM,
|
|
8774
|
+
BOLT
|
|
8719
8775
|
];
|
|
8720
8776
|
function getAllProviders() {
|
|
8721
8777
|
return ALL_DEXES;
|
|
@@ -8782,8 +8838,8 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
8782
8838
|
constructor(params) {
|
|
8783
8839
|
this.endpoint = params.endpoint ? processEndpoint(params.endpoint) : DEFAULT_ENDPOINT;
|
|
8784
8840
|
const network = params.env === 1 /* Testnet */ ? "testnet" : "mainnet";
|
|
8785
|
-
const
|
|
8786
|
-
this.client = params.client ?? new
|
|
8841
|
+
const rpcUrl = params.env === 1 /* Testnet */ ? "https://fullnode.testnet.sui.io:443" : "https://fullnode.mainnet.sui.io:443";
|
|
8842
|
+
this.client = params.client ?? new jsonRpc.SuiJsonRpcClient({ network, url: rpcUrl });
|
|
8787
8843
|
this.signer = params.signer || "";
|
|
8788
8844
|
this.env = params.env || 0 /* Mainnet */;
|
|
8789
8845
|
const config2 = _AggregatorClient.CONFIG[this.env];
|
|
@@ -8824,13 +8880,13 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
8824
8880
|
}
|
|
8825
8881
|
async getOneCoinUsedToMerge(coinType) {
|
|
8826
8882
|
try {
|
|
8827
|
-
const gotCoin = await this.client.
|
|
8883
|
+
const gotCoin = await this.client.getCoins({
|
|
8828
8884
|
owner: this.signer,
|
|
8829
8885
|
coinType,
|
|
8830
8886
|
limit: 1
|
|
8831
8887
|
});
|
|
8832
|
-
if (gotCoin.
|
|
8833
|
-
return gotCoin.
|
|
8888
|
+
if (gotCoin.data.length === 1) {
|
|
8889
|
+
return gotCoin.data[0].coinObjectId;
|
|
8834
8890
|
}
|
|
8835
8891
|
return null;
|
|
8836
8892
|
} catch (error) {
|
|
@@ -8923,6 +8979,8 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
8923
8979
|
return new FerraDlmmRouter(this.env);
|
|
8924
8980
|
case FERRACLMM:
|
|
8925
8981
|
return new FerraClmmRouter(this.env);
|
|
8982
|
+
case BOLT:
|
|
8983
|
+
return new BoltRouter(this.env);
|
|
8926
8984
|
default:
|
|
8927
8985
|
throw new Error(
|
|
8928
8986
|
`${CLIENT_CONFIG.ERRORS.UNSUPPORTED_DEX} ${provider}`
|
|
@@ -9242,7 +9300,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9242
9300
|
return outputCoin;
|
|
9243
9301
|
}
|
|
9244
9302
|
async routerSwap(params) {
|
|
9245
|
-
const { router, inputCoin, slippage, txb, partner
|
|
9303
|
+
const { router, inputCoin, slippage, txb, partner } = params;
|
|
9246
9304
|
if (slippage > 1 || slippage < 0) {
|
|
9247
9305
|
throw new Error(CLIENT_CONFIG.ERRORS.INVALID_SLIPPAGE);
|
|
9248
9306
|
}
|
|
@@ -9276,8 +9334,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9276
9334
|
amountOut.toString(),
|
|
9277
9335
|
amountLimit.toString(),
|
|
9278
9336
|
priceInfoObjectIds,
|
|
9279
|
-
partner ?? this.partner
|
|
9280
|
-
cetusDlmmPartner ?? this.cetusDlmmPartner
|
|
9337
|
+
partner ?? this.partner
|
|
9281
9338
|
);
|
|
9282
9339
|
} else {
|
|
9283
9340
|
return this.expectOutputSwapV3(
|
|
@@ -9352,7 +9409,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9352
9409
|
// auto build input coin
|
|
9353
9410
|
// auto merge, transfer or destory target coin.
|
|
9354
9411
|
async fastRouterSwap(params) {
|
|
9355
|
-
const { router, slippage, txb, partner,
|
|
9412
|
+
const { router, slippage, txb, partner, payDeepFeeAmount } = params;
|
|
9356
9413
|
const fromCoinType = router.paths[0].from;
|
|
9357
9414
|
const targetCoinType = router.paths[router.paths.length - 1].target;
|
|
9358
9415
|
const byAmountIn = router.byAmountIn;
|
|
@@ -9393,7 +9450,6 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9393
9450
|
slippage,
|
|
9394
9451
|
txb,
|
|
9395
9452
|
partner: partner ?? this.partner,
|
|
9396
|
-
cetusDlmmPartner: cetusDlmmPartner ?? this.cetusDlmmPartner,
|
|
9397
9453
|
deepbookv3DeepFee: deepCoin
|
|
9398
9454
|
};
|
|
9399
9455
|
const targetCoin = await this.routerSwap(routerSwapParams);
|
|
@@ -9575,18 +9631,16 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9575
9631
|
});
|
|
9576
9632
|
}
|
|
9577
9633
|
tx.setSenderIfNotSet(this.signer || "0x0");
|
|
9578
|
-
const simulateRes = await this.client.
|
|
9579
|
-
|
|
9580
|
-
|
|
9634
|
+
const simulateRes = await this.client.devInspectTransactionBlock({
|
|
9635
|
+
sender: this.signer || "0x0",
|
|
9636
|
+
transactionBlock: tx
|
|
9581
9637
|
});
|
|
9582
|
-
|
|
9583
|
-
|
|
9584
|
-
const errorMsg = txResult?.status.success === false ? txResult.status.error.message : "Unknown error";
|
|
9585
|
-
throw new Error("Simulation error: " + errorMsg);
|
|
9638
|
+
if (simulateRes.error) {
|
|
9639
|
+
throw new Error("Simulation error: " + simulateRes.error);
|
|
9586
9640
|
}
|
|
9587
|
-
const events =
|
|
9641
|
+
const events = simulateRes.events ?? [];
|
|
9588
9642
|
const valueData = events.filter((item) => {
|
|
9589
|
-
return item.
|
|
9643
|
+
return item.type.includes("CalculatedSwapResultEvent");
|
|
9590
9644
|
});
|
|
9591
9645
|
if (valueData.length === 0 || valueData.length !== pools.length) {
|
|
9592
9646
|
throw new Error("Simulate event result error");
|
|
@@ -9594,7 +9648,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9594
9648
|
let tempMaxAmount = byAmountIn ? new import_bn6.default(0) : new import_bn6.default(U64_MAX);
|
|
9595
9649
|
let tempIndex = 0;
|
|
9596
9650
|
for (let i = 0; i < valueData.length; i += 1) {
|
|
9597
|
-
const eventJson2 = valueData[i].
|
|
9651
|
+
const eventJson2 = valueData[i].parsedJson;
|
|
9598
9652
|
if (eventJson2?.data?.is_exceed) {
|
|
9599
9653
|
continue;
|
|
9600
9654
|
}
|
|
@@ -9612,11 +9666,11 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9612
9666
|
}
|
|
9613
9667
|
}
|
|
9614
9668
|
}
|
|
9615
|
-
const eventJson = valueData[tempIndex].
|
|
9669
|
+
const eventJson = valueData[tempIndex].parsedJson;
|
|
9616
9670
|
const eventData = eventJson?.data;
|
|
9617
9671
|
const [decimalA, decimalB] = await Promise.all([
|
|
9618
|
-
this.client.getCoinMetadata({ coinType: coinA }).then((res) => res
|
|
9619
|
-
this.client.getCoinMetadata({ coinType: coinB }).then((res) => res
|
|
9672
|
+
this.client.getCoinMetadata({ coinType: coinA }).then((res) => res?.decimals ?? null),
|
|
9673
|
+
this.client.getCoinMetadata({ coinType: coinB }).then((res) => res?.decimals ?? null)
|
|
9620
9674
|
]);
|
|
9621
9675
|
if (decimalA == null || decimalB == null) {
|
|
9622
9676
|
throw new Error("Cannot get coin decimals");
|
|
@@ -9685,9 +9739,9 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9685
9739
|
}
|
|
9686
9740
|
async devInspectTransactionBlock(txb) {
|
|
9687
9741
|
txb.setSenderIfNotSet(this.signer || "0x0");
|
|
9688
|
-
const res = await this.client.
|
|
9689
|
-
|
|
9690
|
-
|
|
9742
|
+
const res = await this.client.devInspectTransactionBlock({
|
|
9743
|
+
sender: this.signer || "0x0",
|
|
9744
|
+
transactionBlock: txb
|
|
9691
9745
|
});
|
|
9692
9746
|
return res;
|
|
9693
9747
|
}
|
|
@@ -9695,7 +9749,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9695
9749
|
const res = await this.client.signAndExecuteTransaction({
|
|
9696
9750
|
transaction: txb,
|
|
9697
9751
|
signer,
|
|
9698
|
-
|
|
9752
|
+
options: { showEffects: true, showEvents: true, showBalanceChanges: true }
|
|
9699
9753
|
});
|
|
9700
9754
|
return res;
|
|
9701
9755
|
}
|
|
@@ -9780,6 +9834,7 @@ exports.AggregatorError = AggregatorError;
|
|
|
9780
9834
|
exports.AggregatorServerErrorCode = AggregatorServerErrorCode;
|
|
9781
9835
|
exports.BLUEFIN = BLUEFIN;
|
|
9782
9836
|
exports.BLUEMOVE = BLUEMOVE;
|
|
9837
|
+
exports.BOLT = BOLT;
|
|
9783
9838
|
exports.CETUS = CETUS;
|
|
9784
9839
|
exports.CETUSDLMM = CETUSDLMM;
|
|
9785
9840
|
exports.CETUS_DEX = CETUS_DEX;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _mysten_sui_jsonRpc from '@mysten/sui/jsonRpc';
|
|
2
|
+
import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
2
3
|
import { TransactionObjectArgument, Transaction, TransactionArgument } from '@mysten/sui/transactions';
|
|
3
4
|
import BN from 'bn.js';
|
|
4
5
|
import Decimal from 'decimal.js';
|
|
5
|
-
import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
6
6
|
import { Signer } from '@mysten/sui/cryptography';
|
|
7
7
|
|
|
8
8
|
interface FindRouterParams {
|
|
@@ -128,6 +128,9 @@ type ExtendedDetails = {
|
|
|
128
128
|
sevenk_oracle_config_b?: string;
|
|
129
129
|
/** @deprecated SevenK DEX is no longer active. */
|
|
130
130
|
sevenk_lp_cap_type?: string;
|
|
131
|
+
bolt_pool_id?: string;
|
|
132
|
+
bolt_oracle_id?: string;
|
|
133
|
+
bolt_quote_coin_type?: string;
|
|
131
134
|
};
|
|
132
135
|
type Path = {
|
|
133
136
|
id: string;
|
|
@@ -305,7 +308,7 @@ declare class PythAdapter {
|
|
|
305
308
|
private priceTableInfo;
|
|
306
309
|
private priceFeedObjectIdCache;
|
|
307
310
|
private baseUpdateFee;
|
|
308
|
-
constructor(client:
|
|
311
|
+
constructor(client: SuiJsonRpcClient, pythStateId: ObjectId, wormholeStateId: ObjectId, hermesUrls: string[]);
|
|
309
312
|
getPriceFeedsUpdateData(priceIDs: string[]): Promise<Buffer[]>;
|
|
310
313
|
getBaseUpdateFee(): Promise<number>;
|
|
311
314
|
getPackageId(objectId: ObjectId): Promise<string>;
|
|
@@ -353,6 +356,7 @@ declare const FULLSAIL = "FULLSAIL";
|
|
|
353
356
|
declare const CETUSDLMM = "CETUSDLMM";
|
|
354
357
|
declare const FERRADLMM = "FERRADLMM";
|
|
355
358
|
declare const FERRACLMM = "FERRACLMM";
|
|
359
|
+
declare const BOLT = "BOLT";
|
|
356
360
|
declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v3";
|
|
357
361
|
declare const ALL_DEXES: string[];
|
|
358
362
|
type BuildRouterSwapParamsV3 = {
|
|
@@ -361,7 +365,6 @@ type BuildRouterSwapParamsV3 = {
|
|
|
361
365
|
slippage: number;
|
|
362
366
|
txb: Transaction;
|
|
363
367
|
partner?: string;
|
|
364
|
-
cetusDlmmPartner?: string;
|
|
365
368
|
deepbookv3DeepFee?: TransactionObjectArgument;
|
|
366
369
|
fixable?: boolean;
|
|
367
370
|
};
|
|
@@ -370,7 +373,6 @@ type BuildFastRouterSwapParamsV3 = {
|
|
|
370
373
|
slippage: number;
|
|
371
374
|
txb: Transaction;
|
|
372
375
|
partner?: string;
|
|
373
|
-
cetusDlmmPartner?: string;
|
|
374
376
|
refreshAllCoins?: boolean;
|
|
375
377
|
payDeepFeeAmount?: number;
|
|
376
378
|
};
|
|
@@ -401,7 +403,7 @@ declare function getProvidersIncluding(includeProviders: string[]): string[];
|
|
|
401
403
|
type AggregatorClientParams = {
|
|
402
404
|
endpoint?: string;
|
|
403
405
|
signer?: string;
|
|
404
|
-
client?:
|
|
406
|
+
client?: SuiJsonRpcClient;
|
|
405
407
|
env?: Env;
|
|
406
408
|
pythUrls?: string[];
|
|
407
409
|
apiKey?: string;
|
|
@@ -413,7 +415,7 @@ type AggregatorClientParams = {
|
|
|
413
415
|
declare class AggregatorClient {
|
|
414
416
|
endpoint: string;
|
|
415
417
|
signer: string;
|
|
416
|
-
client:
|
|
418
|
+
client: SuiJsonRpcClient;
|
|
417
419
|
env: Env;
|
|
418
420
|
apiKey: string;
|
|
419
421
|
protected pythAdapter: PythAdapter;
|
|
@@ -455,15 +457,8 @@ declare class AggregatorClient {
|
|
|
455
457
|
fixableRouterSwapV3(params: BuildRouterSwapParamsV3): Promise<TransactionObjectArgument>;
|
|
456
458
|
swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResultV3>;
|
|
457
459
|
updatePythPriceIDs(priceIDs: string[], txb: Transaction): Promise<Map<string, string>>;
|
|
458
|
-
devInspectTransactionBlock(txb: Transaction): Promise<
|
|
459
|
-
|
|
460
|
-
effects: true;
|
|
461
|
-
}>>;
|
|
462
|
-
sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiClientTypes.TransactionResult<{
|
|
463
|
-
effects: true;
|
|
464
|
-
events: true;
|
|
465
|
-
balanceChanges: true;
|
|
466
|
-
}>>;
|
|
460
|
+
devInspectTransactionBlock(txb: Transaction): Promise<_mysten_sui_jsonRpc.DevInspectResults>;
|
|
461
|
+
sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_jsonRpc.SuiTransactionBlockResponse>;
|
|
467
462
|
}
|
|
468
463
|
|
|
469
464
|
/**
|
|
@@ -496,7 +491,7 @@ type GetOrCreateAccountCapResult = {
|
|
|
496
491
|
accountCap: TransactionObjectArgument;
|
|
497
492
|
isCreate: boolean;
|
|
498
493
|
};
|
|
499
|
-
declare function getOrCreateAccountCap(txb: Transaction, client:
|
|
494
|
+
declare function getOrCreateAccountCap(txb: Transaction, client: SuiJsonRpcClient, owner: string): Promise<GetOrCreateAccountCapResult>;
|
|
500
495
|
|
|
501
496
|
/**
|
|
502
497
|
* Represents a SUI address, which is a string.
|
|
@@ -646,67 +641,23 @@ interface Dex {
|
|
|
646
641
|
}
|
|
647
642
|
|
|
648
643
|
/**
|
|
649
|
-
* Matches the shape of
|
|
644
|
+
* Matches the shape of DevInspectResults from JSON-RPC.
|
|
650
645
|
* Using a local type so gas.ts can be used without importing the full SDK.
|
|
651
646
|
*/
|
|
652
647
|
type SimulateTransactionResult = {
|
|
653
|
-
|
|
654
|
-
Transaction?: {
|
|
655
|
-
status: {
|
|
656
|
-
success: true;
|
|
657
|
-
error: null;
|
|
658
|
-
} | {
|
|
659
|
-
success: false;
|
|
660
|
-
error: {
|
|
661
|
-
message: string;
|
|
662
|
-
};
|
|
663
|
-
};
|
|
664
|
-
effects?: {
|
|
665
|
-
status: {
|
|
666
|
-
success: true;
|
|
667
|
-
error: null;
|
|
668
|
-
} | {
|
|
669
|
-
success: false;
|
|
670
|
-
error: {
|
|
671
|
-
message: string;
|
|
672
|
-
};
|
|
673
|
-
};
|
|
674
|
-
gasUsed: {
|
|
675
|
-
computationCost: string;
|
|
676
|
-
storageCost: string;
|
|
677
|
-
storageRebate: string;
|
|
678
|
-
nonRefundableStorageFee: string;
|
|
679
|
-
};
|
|
680
|
-
};
|
|
681
|
-
};
|
|
682
|
-
FailedTransaction?: {
|
|
648
|
+
effects: {
|
|
683
649
|
status: {
|
|
684
|
-
|
|
685
|
-
error
|
|
686
|
-
} | {
|
|
687
|
-
success: false;
|
|
688
|
-
error: {
|
|
689
|
-
message: string;
|
|
690
|
-
};
|
|
650
|
+
status: 'success' | 'failure';
|
|
651
|
+
error?: string;
|
|
691
652
|
};
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
success: false;
|
|
698
|
-
error: {
|
|
699
|
-
message: string;
|
|
700
|
-
};
|
|
701
|
-
};
|
|
702
|
-
gasUsed: {
|
|
703
|
-
computationCost: string;
|
|
704
|
-
storageCost: string;
|
|
705
|
-
storageRebate: string;
|
|
706
|
-
nonRefundableStorageFee: string;
|
|
707
|
-
};
|
|
653
|
+
gasUsed: {
|
|
654
|
+
computationCost: string;
|
|
655
|
+
storageCost: string;
|
|
656
|
+
storageRebate: string;
|
|
657
|
+
nonRefundableStorageFee: string;
|
|
708
658
|
};
|
|
709
659
|
};
|
|
660
|
+
error?: string | null;
|
|
710
661
|
};
|
|
711
662
|
interface GasMetrics {
|
|
712
663
|
computationCost: string;
|
|
@@ -1121,4 +1072,4 @@ declare class CoinUtils {
|
|
|
1121
1072
|
static calculateTotalBalance(coins: CoinAsset[]): bigint;
|
|
1122
1073
|
}
|
|
1123
1074
|
|
|
1124
|
-
export { AFSUI, AFTERMATH, AFTERMATH_AMM, AFTERMATH_MODULE, AGGREGATOR, AGGREGATOR_V3_CONFIG, ALL_DEXES, ALPHAFI, AggregatorClient, type AggregatorClientParams, AggregatorConfig, AggregatorError, type AggregatorErrorCode, type AggregatorResponse, AggregatorServerErrorCode, BLUEFIN, BLUEMOVE, type BigNumber, type BuildCoinResult, type BuildFastMergeSwapParams, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildFastRouterSwapParamsV3, type BuildMergeSwapParams, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, type BuildRouterSwapParamsV3, CETUS, CETUSDLMM, CETUS_DEX, CETUS_MODULE, CETUS_PUBLISHED_AT, CHECK_COINS_THRESHOLD_FUNC, CLIENT_CONFIG, CLOCK_ADDRESS, type CoinAsset, CoinInfoAddress, CoinStoreAddress, CoinUtils, type ComparisonResult, ConfigErrorCode, DEEPBOOKV2, DEEPBOOKV3, DEEPBOOK_CLOB_V2_MODULE, DEEPBOOK_CUSTODIAN_V2_MODULE, DEEPBOOK_DEX, DEEPBOOK_MODULE, DEEPBOOK_PACKAGE_ID, DEEPBOOK_PUBLISHED_AT, DEEPBOOK_V3_DEEP_FEE_TYPES, DEFAULT_AGG_V2_ENDPOINT, DEFAULT_AGG_V3_ENDPOINT, DEFAULT_ENDPOINT, DEFAULT_GAS_BUDGET_FOR_MERGE, DEFAULT_GAS_BUDGET_FOR_SPLIT, DEFAULT_GAS_BUDGET_FOR_STAKE, DEFAULT_GAS_BUDGET_FOR_TRANSFER, DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI, DEFAULT_NFT_TRANSFER_GAS_FEE, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FERRACLMM, FERRADLMM, FLOWXV2, FLOWXV3, FLOWX_AMM, FLOWX_AMM_MODULE, FULLSAIL, type FindRouterParams, FlashSwapA2BFunc, FlashSwapB2AFunc, FlashSwapFunc, FlashSwapWithPartnerA2BFunc, FlashSwapWithPartnerB2AFunc, FlashSwapWithPartnerFunc, type FlattenedPath, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, type GasMetrics, type GetOrCreateAccountCapResult, HAEDAL, HAEDALHMMV2, HAEDALPMM, HAWAL, INTEGRATE, JOIN_FUNC, KRIYA, KRIYAV3, KRIYA_DEX, KRIYA_MODULE, MAGMA, MAINNET_AFTERMATH_INSURANCE_FUND_ID, MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, MAINNET_AFTERMATH_REFERRAL_VAULT_ID, MAINNET_AFTERMATH_REGISTRY_ID, MAINNET_AFTERMATH_TREASURY_ID, MAINNET_CETUS_V3_PUBLISHED_AT, MAINNET_FLOWX_AMM_CONTAINER_ID, METASTABLE, MOMENTUM, type MergeRoute, type MergeSwapFromCoin, type MergeSwapInputCoin, type MergeSwapParams, type MergeSwapRouterData, type NFT, OBRIC, ONE, PACKAGE_NAMES, PAY_MODULE, POOL_MODULT, PUBLISHED_ADDRESSES, PYTH_CONFIG, type Package, type Path, type PathV2, type PreSwapLpChangeParams, type ProcessedRouterData, type PythConfig, REPAY_FLASH_SWAP_A2B_FUNC, REPAY_FLASH_SWAP_B2A_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC, RepayFalshSwapFunc, RepayFlashSwapWithPartnerFunc, type Router, type RouterData, type RouterDataV2, type RouterDataV3, type RouterError, type RouterV2, SCALLOP, SEVENK, SPRINGSUI, STEAMM, STEAMM_OMM, STEAMM_OMM_V2, SUILEND, SUI_SYSTEM_STATE_OBJECT_ID, SWAP_A2B_FUNC, SWAP_B2A_FUNC, type SimulateTransactionResult, type SuiAddress, type SuiBasicTypes, type SuiInputTypes, type SuiMoveObject, type SuiObjectIdType, type SuiResource, type SuiStructTag, type SuiTxArg, SuiZeroCoinFn, type SwapGasAnalysis, type SwapInPoolsParams, type SwapInPoolsResultV3, TEN_POW_NINE, TESTNET_AFTERMATH_INSURANCE_FUND_ID, TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, TESTNET_AFTERMATH_REFERRAL_VAULT_ID, TESTNET_AFTERMATH_REGISTRY_ID, TESTNET_AFTERMATH_TREASURY_ID, TESTNET_CETUS_V3_PUBLISHED_AT, TESTNET_FLOWX_AMM_CONTAINER_ID, TRANSFER_ACCOUNT_CAP, TRANSFER_OR_DESTORY_COIN_FUNC, TURBOS, TURBOS_DEX, TURBOS_MODULE, TURBOS_VERSIONED, TWO, TransactionErrorCode, TypesErrorCode, U128, U64_MAX, U64_MAX_BN, UTILS_MODULE, VOLO, ZERO, buildInputCoin, calculateGasEfficiency, calculatePriceImpact, checkInvalidSuiAddress, compareCoins, compareGasMetrics, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, exportToCSV, exportToJSON, extractAddressFromType, extractGasMetrics, extractStructTagFromType, extractTimestampFromDowngradeUuid6, fixSuiObjectId, formatGasMetrics, generateDowngradeUuid6, generateSimpleDowngradeUuid6, getAggregatorServerErrorMessage, getAggregatorV2Extend2PublishedAt, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getAllProviders, getDeepbookV3Config, getDefaultSuiInputType, getMergeSwapResult, getOrCreateAccountCap, getProvidersExcluding, getProvidersIncluding, getRouterResult, isSortedSymbols, isValidDowngradeUuid6, mintZeroCoin, normalizeCoinType, parseAftermathFeeType, parseTurbosPoolFeeType, patchFixSuiObjectId, printTransaction, processEndpoint, processFlattenRoutes, restituteMsafeFastRouterSwapParams };
|
|
1075
|
+
export { AFSUI, AFTERMATH, AFTERMATH_AMM, AFTERMATH_MODULE, AGGREGATOR, AGGREGATOR_V3_CONFIG, ALL_DEXES, ALPHAFI, AggregatorClient, type AggregatorClientParams, AggregatorConfig, AggregatorError, type AggregatorErrorCode, type AggregatorResponse, AggregatorServerErrorCode, BLUEFIN, BLUEMOVE, BOLT, type BigNumber, type BuildCoinResult, type BuildFastMergeSwapParams, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildFastRouterSwapParamsV3, type BuildMergeSwapParams, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, type BuildRouterSwapParamsV3, CETUS, CETUSDLMM, CETUS_DEX, CETUS_MODULE, CETUS_PUBLISHED_AT, CHECK_COINS_THRESHOLD_FUNC, CLIENT_CONFIG, CLOCK_ADDRESS, type CoinAsset, CoinInfoAddress, CoinStoreAddress, CoinUtils, type ComparisonResult, ConfigErrorCode, DEEPBOOKV2, DEEPBOOKV3, DEEPBOOK_CLOB_V2_MODULE, DEEPBOOK_CUSTODIAN_V2_MODULE, DEEPBOOK_DEX, DEEPBOOK_MODULE, DEEPBOOK_PACKAGE_ID, DEEPBOOK_PUBLISHED_AT, DEEPBOOK_V3_DEEP_FEE_TYPES, DEFAULT_AGG_V2_ENDPOINT, DEFAULT_AGG_V3_ENDPOINT, DEFAULT_ENDPOINT, DEFAULT_GAS_BUDGET_FOR_MERGE, DEFAULT_GAS_BUDGET_FOR_SPLIT, DEFAULT_GAS_BUDGET_FOR_STAKE, DEFAULT_GAS_BUDGET_FOR_TRANSFER, DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI, DEFAULT_NFT_TRANSFER_GAS_FEE, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FERRACLMM, FERRADLMM, FLOWXV2, FLOWXV3, FLOWX_AMM, FLOWX_AMM_MODULE, FULLSAIL, type FindRouterParams, FlashSwapA2BFunc, FlashSwapB2AFunc, FlashSwapFunc, FlashSwapWithPartnerA2BFunc, FlashSwapWithPartnerB2AFunc, FlashSwapWithPartnerFunc, type FlattenedPath, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, type GasMetrics, type GetOrCreateAccountCapResult, HAEDAL, HAEDALHMMV2, HAEDALPMM, HAWAL, INTEGRATE, JOIN_FUNC, KRIYA, KRIYAV3, KRIYA_DEX, KRIYA_MODULE, MAGMA, MAINNET_AFTERMATH_INSURANCE_FUND_ID, MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, MAINNET_AFTERMATH_REFERRAL_VAULT_ID, MAINNET_AFTERMATH_REGISTRY_ID, MAINNET_AFTERMATH_TREASURY_ID, MAINNET_CETUS_V3_PUBLISHED_AT, MAINNET_FLOWX_AMM_CONTAINER_ID, METASTABLE, MOMENTUM, type MergeRoute, type MergeSwapFromCoin, type MergeSwapInputCoin, type MergeSwapParams, type MergeSwapRouterData, type NFT, OBRIC, ONE, PACKAGE_NAMES, PAY_MODULE, POOL_MODULT, PUBLISHED_ADDRESSES, PYTH_CONFIG, type Package, type Path, type PathV2, type PreSwapLpChangeParams, type ProcessedRouterData, type PythConfig, REPAY_FLASH_SWAP_A2B_FUNC, REPAY_FLASH_SWAP_B2A_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC, RepayFalshSwapFunc, RepayFlashSwapWithPartnerFunc, type Router, type RouterData, type RouterDataV2, type RouterDataV3, type RouterError, type RouterV2, SCALLOP, SEVENK, SPRINGSUI, STEAMM, STEAMM_OMM, STEAMM_OMM_V2, SUILEND, SUI_SYSTEM_STATE_OBJECT_ID, SWAP_A2B_FUNC, SWAP_B2A_FUNC, type SimulateTransactionResult, type SuiAddress, type SuiBasicTypes, type SuiInputTypes, type SuiMoveObject, type SuiObjectIdType, type SuiResource, type SuiStructTag, type SuiTxArg, SuiZeroCoinFn, type SwapGasAnalysis, type SwapInPoolsParams, type SwapInPoolsResultV3, TEN_POW_NINE, TESTNET_AFTERMATH_INSURANCE_FUND_ID, TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, TESTNET_AFTERMATH_REFERRAL_VAULT_ID, TESTNET_AFTERMATH_REGISTRY_ID, TESTNET_AFTERMATH_TREASURY_ID, TESTNET_CETUS_V3_PUBLISHED_AT, TESTNET_FLOWX_AMM_CONTAINER_ID, TRANSFER_ACCOUNT_CAP, TRANSFER_OR_DESTORY_COIN_FUNC, TURBOS, TURBOS_DEX, TURBOS_MODULE, TURBOS_VERSIONED, TWO, TransactionErrorCode, TypesErrorCode, U128, U64_MAX, U64_MAX_BN, UTILS_MODULE, VOLO, ZERO, buildInputCoin, calculateGasEfficiency, calculatePriceImpact, checkInvalidSuiAddress, compareCoins, compareGasMetrics, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, exportToCSV, exportToJSON, extractAddressFromType, extractGasMetrics, extractStructTagFromType, extractTimestampFromDowngradeUuid6, fixSuiObjectId, formatGasMetrics, generateDowngradeUuid6, generateSimpleDowngradeUuid6, getAggregatorServerErrorMessage, getAggregatorV2Extend2PublishedAt, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getAllProviders, getDeepbookV3Config, getDefaultSuiInputType, getMergeSwapResult, getOrCreateAccountCap, getProvidersExcluding, getProvidersIncluding, getRouterResult, isSortedSymbols, isValidDowngradeUuid6, mintZeroCoin, normalizeCoinType, parseAftermathFeeType, parseTurbosPoolFeeType, patchFixSuiObjectId, printTransaction, processEndpoint, processFlattenRoutes, restituteMsafeFastRouterSwapParams };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _mysten_sui_jsonRpc from '@mysten/sui/jsonRpc';
|
|
2
|
+
import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
2
3
|
import { TransactionObjectArgument, Transaction, TransactionArgument } from '@mysten/sui/transactions';
|
|
3
4
|
import BN from 'bn.js';
|
|
4
5
|
import Decimal from 'decimal.js';
|
|
5
|
-
import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
6
6
|
import { Signer } from '@mysten/sui/cryptography';
|
|
7
7
|
|
|
8
8
|
interface FindRouterParams {
|
|
@@ -128,6 +128,9 @@ type ExtendedDetails = {
|
|
|
128
128
|
sevenk_oracle_config_b?: string;
|
|
129
129
|
/** @deprecated SevenK DEX is no longer active. */
|
|
130
130
|
sevenk_lp_cap_type?: string;
|
|
131
|
+
bolt_pool_id?: string;
|
|
132
|
+
bolt_oracle_id?: string;
|
|
133
|
+
bolt_quote_coin_type?: string;
|
|
131
134
|
};
|
|
132
135
|
type Path = {
|
|
133
136
|
id: string;
|
|
@@ -305,7 +308,7 @@ declare class PythAdapter {
|
|
|
305
308
|
private priceTableInfo;
|
|
306
309
|
private priceFeedObjectIdCache;
|
|
307
310
|
private baseUpdateFee;
|
|
308
|
-
constructor(client:
|
|
311
|
+
constructor(client: SuiJsonRpcClient, pythStateId: ObjectId, wormholeStateId: ObjectId, hermesUrls: string[]);
|
|
309
312
|
getPriceFeedsUpdateData(priceIDs: string[]): Promise<Buffer[]>;
|
|
310
313
|
getBaseUpdateFee(): Promise<number>;
|
|
311
314
|
getPackageId(objectId: ObjectId): Promise<string>;
|
|
@@ -353,6 +356,7 @@ declare const FULLSAIL = "FULLSAIL";
|
|
|
353
356
|
declare const CETUSDLMM = "CETUSDLMM";
|
|
354
357
|
declare const FERRADLMM = "FERRADLMM";
|
|
355
358
|
declare const FERRACLMM = "FERRACLMM";
|
|
359
|
+
declare const BOLT = "BOLT";
|
|
356
360
|
declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v3";
|
|
357
361
|
declare const ALL_DEXES: string[];
|
|
358
362
|
type BuildRouterSwapParamsV3 = {
|
|
@@ -361,7 +365,6 @@ type BuildRouterSwapParamsV3 = {
|
|
|
361
365
|
slippage: number;
|
|
362
366
|
txb: Transaction;
|
|
363
367
|
partner?: string;
|
|
364
|
-
cetusDlmmPartner?: string;
|
|
365
368
|
deepbookv3DeepFee?: TransactionObjectArgument;
|
|
366
369
|
fixable?: boolean;
|
|
367
370
|
};
|
|
@@ -370,7 +373,6 @@ type BuildFastRouterSwapParamsV3 = {
|
|
|
370
373
|
slippage: number;
|
|
371
374
|
txb: Transaction;
|
|
372
375
|
partner?: string;
|
|
373
|
-
cetusDlmmPartner?: string;
|
|
374
376
|
refreshAllCoins?: boolean;
|
|
375
377
|
payDeepFeeAmount?: number;
|
|
376
378
|
};
|
|
@@ -401,7 +403,7 @@ declare function getProvidersIncluding(includeProviders: string[]): string[];
|
|
|
401
403
|
type AggregatorClientParams = {
|
|
402
404
|
endpoint?: string;
|
|
403
405
|
signer?: string;
|
|
404
|
-
client?:
|
|
406
|
+
client?: SuiJsonRpcClient;
|
|
405
407
|
env?: Env;
|
|
406
408
|
pythUrls?: string[];
|
|
407
409
|
apiKey?: string;
|
|
@@ -413,7 +415,7 @@ type AggregatorClientParams = {
|
|
|
413
415
|
declare class AggregatorClient {
|
|
414
416
|
endpoint: string;
|
|
415
417
|
signer: string;
|
|
416
|
-
client:
|
|
418
|
+
client: SuiJsonRpcClient;
|
|
417
419
|
env: Env;
|
|
418
420
|
apiKey: string;
|
|
419
421
|
protected pythAdapter: PythAdapter;
|
|
@@ -455,15 +457,8 @@ declare class AggregatorClient {
|
|
|
455
457
|
fixableRouterSwapV3(params: BuildRouterSwapParamsV3): Promise<TransactionObjectArgument>;
|
|
456
458
|
swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResultV3>;
|
|
457
459
|
updatePythPriceIDs(priceIDs: string[], txb: Transaction): Promise<Map<string, string>>;
|
|
458
|
-
devInspectTransactionBlock(txb: Transaction): Promise<
|
|
459
|
-
|
|
460
|
-
effects: true;
|
|
461
|
-
}>>;
|
|
462
|
-
sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiClientTypes.TransactionResult<{
|
|
463
|
-
effects: true;
|
|
464
|
-
events: true;
|
|
465
|
-
balanceChanges: true;
|
|
466
|
-
}>>;
|
|
460
|
+
devInspectTransactionBlock(txb: Transaction): Promise<_mysten_sui_jsonRpc.DevInspectResults>;
|
|
461
|
+
sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_jsonRpc.SuiTransactionBlockResponse>;
|
|
467
462
|
}
|
|
468
463
|
|
|
469
464
|
/**
|
|
@@ -496,7 +491,7 @@ type GetOrCreateAccountCapResult = {
|
|
|
496
491
|
accountCap: TransactionObjectArgument;
|
|
497
492
|
isCreate: boolean;
|
|
498
493
|
};
|
|
499
|
-
declare function getOrCreateAccountCap(txb: Transaction, client:
|
|
494
|
+
declare function getOrCreateAccountCap(txb: Transaction, client: SuiJsonRpcClient, owner: string): Promise<GetOrCreateAccountCapResult>;
|
|
500
495
|
|
|
501
496
|
/**
|
|
502
497
|
* Represents a SUI address, which is a string.
|
|
@@ -646,67 +641,23 @@ interface Dex {
|
|
|
646
641
|
}
|
|
647
642
|
|
|
648
643
|
/**
|
|
649
|
-
* Matches the shape of
|
|
644
|
+
* Matches the shape of DevInspectResults from JSON-RPC.
|
|
650
645
|
* Using a local type so gas.ts can be used without importing the full SDK.
|
|
651
646
|
*/
|
|
652
647
|
type SimulateTransactionResult = {
|
|
653
|
-
|
|
654
|
-
Transaction?: {
|
|
655
|
-
status: {
|
|
656
|
-
success: true;
|
|
657
|
-
error: null;
|
|
658
|
-
} | {
|
|
659
|
-
success: false;
|
|
660
|
-
error: {
|
|
661
|
-
message: string;
|
|
662
|
-
};
|
|
663
|
-
};
|
|
664
|
-
effects?: {
|
|
665
|
-
status: {
|
|
666
|
-
success: true;
|
|
667
|
-
error: null;
|
|
668
|
-
} | {
|
|
669
|
-
success: false;
|
|
670
|
-
error: {
|
|
671
|
-
message: string;
|
|
672
|
-
};
|
|
673
|
-
};
|
|
674
|
-
gasUsed: {
|
|
675
|
-
computationCost: string;
|
|
676
|
-
storageCost: string;
|
|
677
|
-
storageRebate: string;
|
|
678
|
-
nonRefundableStorageFee: string;
|
|
679
|
-
};
|
|
680
|
-
};
|
|
681
|
-
};
|
|
682
|
-
FailedTransaction?: {
|
|
648
|
+
effects: {
|
|
683
649
|
status: {
|
|
684
|
-
|
|
685
|
-
error
|
|
686
|
-
} | {
|
|
687
|
-
success: false;
|
|
688
|
-
error: {
|
|
689
|
-
message: string;
|
|
690
|
-
};
|
|
650
|
+
status: 'success' | 'failure';
|
|
651
|
+
error?: string;
|
|
691
652
|
};
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
success: false;
|
|
698
|
-
error: {
|
|
699
|
-
message: string;
|
|
700
|
-
};
|
|
701
|
-
};
|
|
702
|
-
gasUsed: {
|
|
703
|
-
computationCost: string;
|
|
704
|
-
storageCost: string;
|
|
705
|
-
storageRebate: string;
|
|
706
|
-
nonRefundableStorageFee: string;
|
|
707
|
-
};
|
|
653
|
+
gasUsed: {
|
|
654
|
+
computationCost: string;
|
|
655
|
+
storageCost: string;
|
|
656
|
+
storageRebate: string;
|
|
657
|
+
nonRefundableStorageFee: string;
|
|
708
658
|
};
|
|
709
659
|
};
|
|
660
|
+
error?: string | null;
|
|
710
661
|
};
|
|
711
662
|
interface GasMetrics {
|
|
712
663
|
computationCost: string;
|
|
@@ -1121,4 +1072,4 @@ declare class CoinUtils {
|
|
|
1121
1072
|
static calculateTotalBalance(coins: CoinAsset[]): bigint;
|
|
1122
1073
|
}
|
|
1123
1074
|
|
|
1124
|
-
export { AFSUI, AFTERMATH, AFTERMATH_AMM, AFTERMATH_MODULE, AGGREGATOR, AGGREGATOR_V3_CONFIG, ALL_DEXES, ALPHAFI, AggregatorClient, type AggregatorClientParams, AggregatorConfig, AggregatorError, type AggregatorErrorCode, type AggregatorResponse, AggregatorServerErrorCode, BLUEFIN, BLUEMOVE, type BigNumber, type BuildCoinResult, type BuildFastMergeSwapParams, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildFastRouterSwapParamsV3, type BuildMergeSwapParams, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, type BuildRouterSwapParamsV3, CETUS, CETUSDLMM, CETUS_DEX, CETUS_MODULE, CETUS_PUBLISHED_AT, CHECK_COINS_THRESHOLD_FUNC, CLIENT_CONFIG, CLOCK_ADDRESS, type CoinAsset, CoinInfoAddress, CoinStoreAddress, CoinUtils, type ComparisonResult, ConfigErrorCode, DEEPBOOKV2, DEEPBOOKV3, DEEPBOOK_CLOB_V2_MODULE, DEEPBOOK_CUSTODIAN_V2_MODULE, DEEPBOOK_DEX, DEEPBOOK_MODULE, DEEPBOOK_PACKAGE_ID, DEEPBOOK_PUBLISHED_AT, DEEPBOOK_V3_DEEP_FEE_TYPES, DEFAULT_AGG_V2_ENDPOINT, DEFAULT_AGG_V3_ENDPOINT, DEFAULT_ENDPOINT, DEFAULT_GAS_BUDGET_FOR_MERGE, DEFAULT_GAS_BUDGET_FOR_SPLIT, DEFAULT_GAS_BUDGET_FOR_STAKE, DEFAULT_GAS_BUDGET_FOR_TRANSFER, DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI, DEFAULT_NFT_TRANSFER_GAS_FEE, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FERRACLMM, FERRADLMM, FLOWXV2, FLOWXV3, FLOWX_AMM, FLOWX_AMM_MODULE, FULLSAIL, type FindRouterParams, FlashSwapA2BFunc, FlashSwapB2AFunc, FlashSwapFunc, FlashSwapWithPartnerA2BFunc, FlashSwapWithPartnerB2AFunc, FlashSwapWithPartnerFunc, type FlattenedPath, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, type GasMetrics, type GetOrCreateAccountCapResult, HAEDAL, HAEDALHMMV2, HAEDALPMM, HAWAL, INTEGRATE, JOIN_FUNC, KRIYA, KRIYAV3, KRIYA_DEX, KRIYA_MODULE, MAGMA, MAINNET_AFTERMATH_INSURANCE_FUND_ID, MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, MAINNET_AFTERMATH_REFERRAL_VAULT_ID, MAINNET_AFTERMATH_REGISTRY_ID, MAINNET_AFTERMATH_TREASURY_ID, MAINNET_CETUS_V3_PUBLISHED_AT, MAINNET_FLOWX_AMM_CONTAINER_ID, METASTABLE, MOMENTUM, type MergeRoute, type MergeSwapFromCoin, type MergeSwapInputCoin, type MergeSwapParams, type MergeSwapRouterData, type NFT, OBRIC, ONE, PACKAGE_NAMES, PAY_MODULE, POOL_MODULT, PUBLISHED_ADDRESSES, PYTH_CONFIG, type Package, type Path, type PathV2, type PreSwapLpChangeParams, type ProcessedRouterData, type PythConfig, REPAY_FLASH_SWAP_A2B_FUNC, REPAY_FLASH_SWAP_B2A_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC, RepayFalshSwapFunc, RepayFlashSwapWithPartnerFunc, type Router, type RouterData, type RouterDataV2, type RouterDataV3, type RouterError, type RouterV2, SCALLOP, SEVENK, SPRINGSUI, STEAMM, STEAMM_OMM, STEAMM_OMM_V2, SUILEND, SUI_SYSTEM_STATE_OBJECT_ID, SWAP_A2B_FUNC, SWAP_B2A_FUNC, type SimulateTransactionResult, type SuiAddress, type SuiBasicTypes, type SuiInputTypes, type SuiMoveObject, type SuiObjectIdType, type SuiResource, type SuiStructTag, type SuiTxArg, SuiZeroCoinFn, type SwapGasAnalysis, type SwapInPoolsParams, type SwapInPoolsResultV3, TEN_POW_NINE, TESTNET_AFTERMATH_INSURANCE_FUND_ID, TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, TESTNET_AFTERMATH_REFERRAL_VAULT_ID, TESTNET_AFTERMATH_REGISTRY_ID, TESTNET_AFTERMATH_TREASURY_ID, TESTNET_CETUS_V3_PUBLISHED_AT, TESTNET_FLOWX_AMM_CONTAINER_ID, TRANSFER_ACCOUNT_CAP, TRANSFER_OR_DESTORY_COIN_FUNC, TURBOS, TURBOS_DEX, TURBOS_MODULE, TURBOS_VERSIONED, TWO, TransactionErrorCode, TypesErrorCode, U128, U64_MAX, U64_MAX_BN, UTILS_MODULE, VOLO, ZERO, buildInputCoin, calculateGasEfficiency, calculatePriceImpact, checkInvalidSuiAddress, compareCoins, compareGasMetrics, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, exportToCSV, exportToJSON, extractAddressFromType, extractGasMetrics, extractStructTagFromType, extractTimestampFromDowngradeUuid6, fixSuiObjectId, formatGasMetrics, generateDowngradeUuid6, generateSimpleDowngradeUuid6, getAggregatorServerErrorMessage, getAggregatorV2Extend2PublishedAt, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getAllProviders, getDeepbookV3Config, getDefaultSuiInputType, getMergeSwapResult, getOrCreateAccountCap, getProvidersExcluding, getProvidersIncluding, getRouterResult, isSortedSymbols, isValidDowngradeUuid6, mintZeroCoin, normalizeCoinType, parseAftermathFeeType, parseTurbosPoolFeeType, patchFixSuiObjectId, printTransaction, processEndpoint, processFlattenRoutes, restituteMsafeFastRouterSwapParams };
|
|
1075
|
+
export { AFSUI, AFTERMATH, AFTERMATH_AMM, AFTERMATH_MODULE, AGGREGATOR, AGGREGATOR_V3_CONFIG, ALL_DEXES, ALPHAFI, AggregatorClient, type AggregatorClientParams, AggregatorConfig, AggregatorError, type AggregatorErrorCode, type AggregatorResponse, AggregatorServerErrorCode, BLUEFIN, BLUEMOVE, BOLT, type BigNumber, type BuildCoinResult, type BuildFastMergeSwapParams, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildFastRouterSwapParamsV3, type BuildMergeSwapParams, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, type BuildRouterSwapParamsV3, CETUS, CETUSDLMM, CETUS_DEX, CETUS_MODULE, CETUS_PUBLISHED_AT, CHECK_COINS_THRESHOLD_FUNC, CLIENT_CONFIG, CLOCK_ADDRESS, type CoinAsset, CoinInfoAddress, CoinStoreAddress, CoinUtils, type ComparisonResult, ConfigErrorCode, DEEPBOOKV2, DEEPBOOKV3, DEEPBOOK_CLOB_V2_MODULE, DEEPBOOK_CUSTODIAN_V2_MODULE, DEEPBOOK_DEX, DEEPBOOK_MODULE, DEEPBOOK_PACKAGE_ID, DEEPBOOK_PUBLISHED_AT, DEEPBOOK_V3_DEEP_FEE_TYPES, DEFAULT_AGG_V2_ENDPOINT, DEFAULT_AGG_V3_ENDPOINT, DEFAULT_ENDPOINT, DEFAULT_GAS_BUDGET_FOR_MERGE, DEFAULT_GAS_BUDGET_FOR_SPLIT, DEFAULT_GAS_BUDGET_FOR_STAKE, DEFAULT_GAS_BUDGET_FOR_TRANSFER, DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI, DEFAULT_NFT_TRANSFER_GAS_FEE, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FERRACLMM, FERRADLMM, FLOWXV2, FLOWXV3, FLOWX_AMM, FLOWX_AMM_MODULE, FULLSAIL, type FindRouterParams, FlashSwapA2BFunc, FlashSwapB2AFunc, FlashSwapFunc, FlashSwapWithPartnerA2BFunc, FlashSwapWithPartnerB2AFunc, FlashSwapWithPartnerFunc, type FlattenedPath, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, type GasMetrics, type GetOrCreateAccountCapResult, HAEDAL, HAEDALHMMV2, HAEDALPMM, HAWAL, INTEGRATE, JOIN_FUNC, KRIYA, KRIYAV3, KRIYA_DEX, KRIYA_MODULE, MAGMA, MAINNET_AFTERMATH_INSURANCE_FUND_ID, MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, MAINNET_AFTERMATH_REFERRAL_VAULT_ID, MAINNET_AFTERMATH_REGISTRY_ID, MAINNET_AFTERMATH_TREASURY_ID, MAINNET_CETUS_V3_PUBLISHED_AT, MAINNET_FLOWX_AMM_CONTAINER_ID, METASTABLE, MOMENTUM, type MergeRoute, type MergeSwapFromCoin, type MergeSwapInputCoin, type MergeSwapParams, type MergeSwapRouterData, type NFT, OBRIC, ONE, PACKAGE_NAMES, PAY_MODULE, POOL_MODULT, PUBLISHED_ADDRESSES, PYTH_CONFIG, type Package, type Path, type PathV2, type PreSwapLpChangeParams, type ProcessedRouterData, type PythConfig, REPAY_FLASH_SWAP_A2B_FUNC, REPAY_FLASH_SWAP_B2A_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC, RepayFalshSwapFunc, RepayFlashSwapWithPartnerFunc, type Router, type RouterData, type RouterDataV2, type RouterDataV3, type RouterError, type RouterV2, SCALLOP, SEVENK, SPRINGSUI, STEAMM, STEAMM_OMM, STEAMM_OMM_V2, SUILEND, SUI_SYSTEM_STATE_OBJECT_ID, SWAP_A2B_FUNC, SWAP_B2A_FUNC, type SimulateTransactionResult, type SuiAddress, type SuiBasicTypes, type SuiInputTypes, type SuiMoveObject, type SuiObjectIdType, type SuiResource, type SuiStructTag, type SuiTxArg, SuiZeroCoinFn, type SwapGasAnalysis, type SwapInPoolsParams, type SwapInPoolsResultV3, TEN_POW_NINE, TESTNET_AFTERMATH_INSURANCE_FUND_ID, TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, TESTNET_AFTERMATH_REFERRAL_VAULT_ID, TESTNET_AFTERMATH_REGISTRY_ID, TESTNET_AFTERMATH_TREASURY_ID, TESTNET_CETUS_V3_PUBLISHED_AT, TESTNET_FLOWX_AMM_CONTAINER_ID, TRANSFER_ACCOUNT_CAP, TRANSFER_OR_DESTORY_COIN_FUNC, TURBOS, TURBOS_DEX, TURBOS_MODULE, TURBOS_VERSIONED, TWO, TransactionErrorCode, TypesErrorCode, U128, U64_MAX, U64_MAX_BN, UTILS_MODULE, VOLO, ZERO, buildInputCoin, calculateGasEfficiency, calculatePriceImpact, checkInvalidSuiAddress, compareCoins, compareGasMetrics, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, exportToCSV, exportToJSON, extractAddressFromType, extractGasMetrics, extractStructTagFromType, extractTimestampFromDowngradeUuid6, fixSuiObjectId, formatGasMetrics, generateDowngradeUuid6, generateSimpleDowngradeUuid6, getAggregatorServerErrorMessage, getAggregatorV2Extend2PublishedAt, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getAllProviders, getDeepbookV3Config, getDefaultSuiInputType, getMergeSwapResult, getOrCreateAccountCap, getProvidersExcluding, getProvidersIncluding, getRouterResult, isSortedSymbols, isValidDowngradeUuid6, mintZeroCoin, normalizeCoinType, parseAftermathFeeType, parseTurbosPoolFeeType, patchFixSuiObjectId, printTransaction, processEndpoint, processFlattenRoutes, restituteMsafeFastRouterSwapParams };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { coinWithBalance, Transaction } from '@mysten/sui/transactions';
|
|
2
2
|
import JSONbig from 'json-bigint';
|
|
3
3
|
import { normalizeSuiObjectId, SUI_CLOCK_OBJECT_ID } from '@mysten/sui/utils';
|
|
4
|
-
import {
|
|
4
|
+
import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
5
5
|
import { HermesClient } from '@pythnetwork/hermes-client';
|
|
6
6
|
import { bcs } from '@mysten/sui/bcs';
|
|
7
7
|
|
|
@@ -3410,7 +3410,7 @@ var AGGREGATOR_V3_CONFIG = {
|
|
|
3410
3410
|
};
|
|
3411
3411
|
|
|
3412
3412
|
// src/api.ts
|
|
3413
|
-
var SDK_VERSION =
|
|
3413
|
+
var SDK_VERSION = 1010501;
|
|
3414
3414
|
function parseRouterResponse(data, byAmountIn) {
|
|
3415
3415
|
let packages = /* @__PURE__ */ new Map();
|
|
3416
3416
|
if (data.packages) {
|
|
@@ -7851,11 +7851,12 @@ var PythAdapter = class {
|
|
|
7851
7851
|
if (this.baseUpdateFee !== void 0) {
|
|
7852
7852
|
return this.baseUpdateFee;
|
|
7853
7853
|
}
|
|
7854
|
-
const
|
|
7855
|
-
|
|
7856
|
-
|
|
7854
|
+
const res = await this.client.getObject({
|
|
7855
|
+
id: this.pythStateId,
|
|
7856
|
+
options: { showContent: true }
|
|
7857
7857
|
});
|
|
7858
|
-
const
|
|
7858
|
+
const content = res.data?.content;
|
|
7859
|
+
const json = content && "fields" in content ? content.fields : null;
|
|
7859
7860
|
if (!json) {
|
|
7860
7861
|
throw new Error("Unable to fetch pyth state object");
|
|
7861
7862
|
}
|
|
@@ -7863,16 +7864,21 @@ var PythAdapter = class {
|
|
|
7863
7864
|
return this.baseUpdateFee;
|
|
7864
7865
|
}
|
|
7865
7866
|
async getPackageId(objectId) {
|
|
7866
|
-
const
|
|
7867
|
-
objectId,
|
|
7868
|
-
|
|
7867
|
+
const res = await this.client.getObject({
|
|
7868
|
+
id: objectId,
|
|
7869
|
+
options: { showContent: true }
|
|
7869
7870
|
});
|
|
7870
|
-
const
|
|
7871
|
+
const content = res.data?.content;
|
|
7872
|
+
const json = content && "fields" in content ? content.fields : null;
|
|
7871
7873
|
if (!json) {
|
|
7872
7874
|
throw new Error(`Cannot fetch package id for object ${objectId}`);
|
|
7873
7875
|
}
|
|
7874
7876
|
if ("upgrade_cap" in json) {
|
|
7875
|
-
|
|
7877
|
+
const upgradeCap = json.upgrade_cap;
|
|
7878
|
+
const packageId = upgradeCap?.fields?.package;
|
|
7879
|
+
if (typeof packageId === "string") {
|
|
7880
|
+
return packageId;
|
|
7881
|
+
}
|
|
7876
7882
|
}
|
|
7877
7883
|
throw new Error("upgrade_cap not found");
|
|
7878
7884
|
}
|
|
@@ -7896,20 +7902,19 @@ var PythAdapter = class {
|
|
|
7896
7902
|
const { id: tableId, fieldType } = await this.getPriceTableInfo();
|
|
7897
7903
|
const feedIdBytes = Buffer.from(normalizedFeedId, "hex");
|
|
7898
7904
|
try {
|
|
7899
|
-
const
|
|
7900
|
-
bytes: bcs.vector(bcs.u8())
|
|
7901
|
-
});
|
|
7902
|
-
const bcsBytes = PriceIdentifier.serialize({ bytes: Array.from(feedIdBytes) }).toBytes();
|
|
7903
|
-
const result = await this.client.getDynamicField({
|
|
7905
|
+
const result = await this.client.getDynamicFieldObject({
|
|
7904
7906
|
parentId: tableId,
|
|
7905
7907
|
name: {
|
|
7906
|
-
type: fieldType
|
|
7907
|
-
|
|
7908
|
+
type: `${fieldType}::price_identifier::PriceIdentifier`,
|
|
7909
|
+
value: { bytes: Array.from(feedIdBytes) }
|
|
7908
7910
|
}
|
|
7909
7911
|
});
|
|
7910
|
-
const
|
|
7911
|
-
const
|
|
7912
|
-
const objectId = "
|
|
7912
|
+
const content = result.data?.content;
|
|
7913
|
+
const json = content && "fields" in content ? content.fields : null;
|
|
7914
|
+
const objectId = typeof json?.value === "string" ? json.value : void 0;
|
|
7915
|
+
if (!objectId) {
|
|
7916
|
+
return void 0;
|
|
7917
|
+
}
|
|
7913
7918
|
this.priceFeedObjectIdCache.set(normalizedFeedId, objectId);
|
|
7914
7919
|
return objectId;
|
|
7915
7920
|
} catch {
|
|
@@ -7920,35 +7925,22 @@ var PythAdapter = class {
|
|
|
7920
7925
|
if (this.priceTableInfo !== void 0) {
|
|
7921
7926
|
return this.priceTableInfo;
|
|
7922
7927
|
}
|
|
7923
|
-
|
|
7924
|
-
|
|
7925
|
-
|
|
7926
|
-
|
|
7927
|
-
|
|
7928
|
-
cursor
|
|
7929
|
-
});
|
|
7930
|
-
for (const field of dynamicFields.dynamicFields) {
|
|
7931
|
-
if (field.name.type === "vector<u8>") {
|
|
7932
|
-
const objectId = field.$kind === "DynamicObject" && field.childId ? field.childId : field.fieldId;
|
|
7933
|
-
const fieldObj = await this.client.getObject({
|
|
7934
|
-
objectId,
|
|
7935
|
-
include: { json: true }
|
|
7936
|
-
});
|
|
7937
|
-
const type = fieldObj.object.type;
|
|
7938
|
-
if (type.includes("table::Table")) {
|
|
7939
|
-
const innerTypes = type.replace(/.*table::Table</, "").replace(/>$/, "");
|
|
7940
|
-
const fieldType = innerTypes.split(",")[0].trim();
|
|
7941
|
-
this.priceTableInfo = { id: fieldObj.object.objectId, fieldType };
|
|
7942
|
-
return this.priceTableInfo;
|
|
7943
|
-
}
|
|
7944
|
-
}
|
|
7928
|
+
const result = await this.client.getDynamicFieldObject({
|
|
7929
|
+
parentId: this.pythStateId,
|
|
7930
|
+
name: {
|
|
7931
|
+
type: "vector<u8>",
|
|
7932
|
+
value: "price_info"
|
|
7945
7933
|
}
|
|
7946
|
-
|
|
7947
|
-
|
|
7934
|
+
});
|
|
7935
|
+
if (!result.data?.type) {
|
|
7936
|
+
throw new Error(
|
|
7937
|
+
"Price Table not found, contract may not be initialized"
|
|
7938
|
+
);
|
|
7948
7939
|
}
|
|
7949
|
-
|
|
7950
|
-
|
|
7951
|
-
|
|
7940
|
+
let type = result.data.type.replace("0x2::table::Table<", "");
|
|
7941
|
+
type = type.replace("::price_identifier::PriceIdentifier, 0x2::object::ID>", "");
|
|
7942
|
+
this.priceTableInfo = { id: result.data.objectId, fieldType: type };
|
|
7943
|
+
return this.priceTableInfo;
|
|
7952
7944
|
}
|
|
7953
7945
|
extractVaaBytesFromAccumulatorMessage(accumulatorMessage) {
|
|
7954
7946
|
const trailingPayloadSize = accumulatorMessage.readUint8(6);
|
|
@@ -8132,21 +8124,21 @@ async function getOrCreateAccountCap(txb, client, owner) {
|
|
|
8132
8124
|
}
|
|
8133
8125
|
async function getAccountCap(client, owner) {
|
|
8134
8126
|
const limit = 50;
|
|
8135
|
-
let cursor =
|
|
8127
|
+
let cursor = void 0;
|
|
8136
8128
|
while (true) {
|
|
8137
|
-
const ownedObjects = await client.
|
|
8129
|
+
const ownedObjects = await client.getOwnedObjects({
|
|
8138
8130
|
owner,
|
|
8139
8131
|
cursor,
|
|
8140
8132
|
limit,
|
|
8141
|
-
|
|
8133
|
+
filter: { StructType: `${DEEPBOOK_PACKAGE_ID}::${DEEPBOOK_CUSTODIAN_V2_MODULE}::AccountCap` }
|
|
8142
8134
|
});
|
|
8143
|
-
if (ownedObjects.
|
|
8144
|
-
return ownedObjects.
|
|
8135
|
+
if (ownedObjects.data.length !== 0) {
|
|
8136
|
+
return ownedObjects.data[0].data?.objectId ?? null;
|
|
8145
8137
|
}
|
|
8146
8138
|
if (!ownedObjects.hasNextPage) {
|
|
8147
8139
|
break;
|
|
8148
8140
|
}
|
|
8149
|
-
cursor = ownedObjects.
|
|
8141
|
+
cursor = ownedObjects.nextCursor ?? void 0;
|
|
8150
8142
|
}
|
|
8151
8143
|
return null;
|
|
8152
8144
|
}
|
|
@@ -8174,10 +8166,10 @@ function getAggregatorV2Extend2PublishedAt(publishedAt, packages) {
|
|
|
8174
8166
|
// src/utils/gas.ts
|
|
8175
8167
|
var import_bn4 = __toESM(require_bn());
|
|
8176
8168
|
function extractGasMetrics(result) {
|
|
8177
|
-
const
|
|
8178
|
-
const
|
|
8179
|
-
if (!
|
|
8180
|
-
const errorMsg =
|
|
8169
|
+
const effects = result.effects;
|
|
8170
|
+
const isSuccess = !result.error && effects.status.status === "success";
|
|
8171
|
+
if (!isSuccess) {
|
|
8172
|
+
const errorMsg = result.error ?? effects.status.error ?? "Unknown error";
|
|
8181
8173
|
return {
|
|
8182
8174
|
computationCost: "0",
|
|
8183
8175
|
storageCost: "0",
|
|
@@ -8641,6 +8633,68 @@ var FerraClmmRouter = class {
|
|
|
8641
8633
|
});
|
|
8642
8634
|
}
|
|
8643
8635
|
};
|
|
8636
|
+
var BoltRouter = class {
|
|
8637
|
+
constructor(_env) {
|
|
8638
|
+
}
|
|
8639
|
+
swap(txb, flattenedPath, swapContext, _extends) {
|
|
8640
|
+
const path = flattenedPath.path;
|
|
8641
|
+
if (!path.extendedDetails) {
|
|
8642
|
+
throw new Error("Extended details not found for BOLT");
|
|
8643
|
+
}
|
|
8644
|
+
this.validateExtendedDetails(path.extendedDetails);
|
|
8645
|
+
const swapData = this.prepareSwapData(flattenedPath);
|
|
8646
|
+
this.executeSwapContract(txb, swapData, swapContext);
|
|
8647
|
+
}
|
|
8648
|
+
validateExtendedDetails(extendedDetails) {
|
|
8649
|
+
if (!extendedDetails.bolt_pool_id) {
|
|
8650
|
+
throw new Error("BOLT pool id not found in extended details");
|
|
8651
|
+
}
|
|
8652
|
+
if (!extendedDetails.bolt_oracle_id) {
|
|
8653
|
+
throw new Error("BOLT oracle id not found in extended details");
|
|
8654
|
+
}
|
|
8655
|
+
if (!extendedDetails.bolt_quote_coin_type) {
|
|
8656
|
+
throw new Error("BOLT quote coin type not found in extended details");
|
|
8657
|
+
}
|
|
8658
|
+
}
|
|
8659
|
+
prepareSwapData(flattenedPath) {
|
|
8660
|
+
const path = flattenedPath.path;
|
|
8661
|
+
if (path.publishedAt == null) {
|
|
8662
|
+
throw new Error("BOLT not set publishedAt");
|
|
8663
|
+
}
|
|
8664
|
+
const extendedDetails = path.extendedDetails;
|
|
8665
|
+
const [baseType, quoteType] = path.direction ? [path.from, path.target] : [path.target, path.from];
|
|
8666
|
+
const amountIn = flattenedPath.isLastUseOfIntermediateToken ? AGGREGATOR_V3_CONFIG.MAX_AMOUNT_IN : path.amountIn;
|
|
8667
|
+
return {
|
|
8668
|
+
baseType,
|
|
8669
|
+
quoteType,
|
|
8670
|
+
a2b: path.direction,
|
|
8671
|
+
amountIn,
|
|
8672
|
+
publishedAt: path.publishedAt,
|
|
8673
|
+
poolId: extendedDetails.bolt_pool_id,
|
|
8674
|
+
oracleId: extendedDetails.bolt_oracle_id
|
|
8675
|
+
};
|
|
8676
|
+
}
|
|
8677
|
+
executeSwapContract(txb, swapData, swapContext) {
|
|
8678
|
+
txb.moveCall({
|
|
8679
|
+
target: `${swapData.publishedAt}::bolt::swap`,
|
|
8680
|
+
typeArguments: [swapData.baseType, swapData.quoteType],
|
|
8681
|
+
arguments: [
|
|
8682
|
+
swapContext,
|
|
8683
|
+
// swap_ctx
|
|
8684
|
+
txb.object(swapData.poolId),
|
|
8685
|
+
// pool: &mut LiquidityPool<T0>
|
|
8686
|
+
txb.object(swapData.oracleId),
|
|
8687
|
+
// oracle: &Oracle
|
|
8688
|
+
txb.object(SUI_CLOCK_OBJECT_ID),
|
|
8689
|
+
// clock: &Clock
|
|
8690
|
+
txb.pure.bool(swapData.a2b),
|
|
8691
|
+
// a2b: bool
|
|
8692
|
+
txb.pure.u64(swapData.amountIn)
|
|
8693
|
+
// amount_in: u64
|
|
8694
|
+
]
|
|
8695
|
+
});
|
|
8696
|
+
}
|
|
8697
|
+
};
|
|
8644
8698
|
|
|
8645
8699
|
// src/client.ts
|
|
8646
8700
|
var CETUS = "CETUS";
|
|
@@ -8676,6 +8730,7 @@ var FULLSAIL = "FULLSAIL";
|
|
|
8676
8730
|
var CETUSDLMM = "CETUSDLMM";
|
|
8677
8731
|
var FERRADLMM = "FERRADLMM";
|
|
8678
8732
|
var FERRACLMM = "FERRACLMM";
|
|
8733
|
+
var BOLT = "BOLT";
|
|
8679
8734
|
var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v3";
|
|
8680
8735
|
var ALL_DEXES = [
|
|
8681
8736
|
CETUS,
|
|
@@ -8709,7 +8764,8 @@ var ALL_DEXES = [
|
|
|
8709
8764
|
FULLSAIL,
|
|
8710
8765
|
CETUSDLMM,
|
|
8711
8766
|
FERRADLMM,
|
|
8712
|
-
FERRACLMM
|
|
8767
|
+
FERRACLMM,
|
|
8768
|
+
BOLT
|
|
8713
8769
|
];
|
|
8714
8770
|
function getAllProviders() {
|
|
8715
8771
|
return ALL_DEXES;
|
|
@@ -8776,8 +8832,8 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
8776
8832
|
constructor(params) {
|
|
8777
8833
|
this.endpoint = params.endpoint ? processEndpoint(params.endpoint) : DEFAULT_ENDPOINT;
|
|
8778
8834
|
const network = params.env === 1 /* Testnet */ ? "testnet" : "mainnet";
|
|
8779
|
-
const
|
|
8780
|
-
this.client = params.client ?? new
|
|
8835
|
+
const rpcUrl = params.env === 1 /* Testnet */ ? "https://fullnode.testnet.sui.io:443" : "https://fullnode.mainnet.sui.io:443";
|
|
8836
|
+
this.client = params.client ?? new SuiJsonRpcClient({ network, url: rpcUrl });
|
|
8781
8837
|
this.signer = params.signer || "";
|
|
8782
8838
|
this.env = params.env || 0 /* Mainnet */;
|
|
8783
8839
|
const config2 = _AggregatorClient.CONFIG[this.env];
|
|
@@ -8818,13 +8874,13 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
8818
8874
|
}
|
|
8819
8875
|
async getOneCoinUsedToMerge(coinType) {
|
|
8820
8876
|
try {
|
|
8821
|
-
const gotCoin = await this.client.
|
|
8877
|
+
const gotCoin = await this.client.getCoins({
|
|
8822
8878
|
owner: this.signer,
|
|
8823
8879
|
coinType,
|
|
8824
8880
|
limit: 1
|
|
8825
8881
|
});
|
|
8826
|
-
if (gotCoin.
|
|
8827
|
-
return gotCoin.
|
|
8882
|
+
if (gotCoin.data.length === 1) {
|
|
8883
|
+
return gotCoin.data[0].coinObjectId;
|
|
8828
8884
|
}
|
|
8829
8885
|
return null;
|
|
8830
8886
|
} catch (error) {
|
|
@@ -8917,6 +8973,8 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
8917
8973
|
return new FerraDlmmRouter(this.env);
|
|
8918
8974
|
case FERRACLMM:
|
|
8919
8975
|
return new FerraClmmRouter(this.env);
|
|
8976
|
+
case BOLT:
|
|
8977
|
+
return new BoltRouter(this.env);
|
|
8920
8978
|
default:
|
|
8921
8979
|
throw new Error(
|
|
8922
8980
|
`${CLIENT_CONFIG.ERRORS.UNSUPPORTED_DEX} ${provider}`
|
|
@@ -9236,7 +9294,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9236
9294
|
return outputCoin;
|
|
9237
9295
|
}
|
|
9238
9296
|
async routerSwap(params) {
|
|
9239
|
-
const { router, inputCoin, slippage, txb, partner
|
|
9297
|
+
const { router, inputCoin, slippage, txb, partner } = params;
|
|
9240
9298
|
if (slippage > 1 || slippage < 0) {
|
|
9241
9299
|
throw new Error(CLIENT_CONFIG.ERRORS.INVALID_SLIPPAGE);
|
|
9242
9300
|
}
|
|
@@ -9270,8 +9328,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9270
9328
|
amountOut.toString(),
|
|
9271
9329
|
amountLimit.toString(),
|
|
9272
9330
|
priceInfoObjectIds,
|
|
9273
|
-
partner ?? this.partner
|
|
9274
|
-
cetusDlmmPartner ?? this.cetusDlmmPartner
|
|
9331
|
+
partner ?? this.partner
|
|
9275
9332
|
);
|
|
9276
9333
|
} else {
|
|
9277
9334
|
return this.expectOutputSwapV3(
|
|
@@ -9346,7 +9403,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9346
9403
|
// auto build input coin
|
|
9347
9404
|
// auto merge, transfer or destory target coin.
|
|
9348
9405
|
async fastRouterSwap(params) {
|
|
9349
|
-
const { router, slippage, txb, partner,
|
|
9406
|
+
const { router, slippage, txb, partner, payDeepFeeAmount } = params;
|
|
9350
9407
|
const fromCoinType = router.paths[0].from;
|
|
9351
9408
|
const targetCoinType = router.paths[router.paths.length - 1].target;
|
|
9352
9409
|
const byAmountIn = router.byAmountIn;
|
|
@@ -9387,7 +9444,6 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9387
9444
|
slippage,
|
|
9388
9445
|
txb,
|
|
9389
9446
|
partner: partner ?? this.partner,
|
|
9390
|
-
cetusDlmmPartner: cetusDlmmPartner ?? this.cetusDlmmPartner,
|
|
9391
9447
|
deepbookv3DeepFee: deepCoin
|
|
9392
9448
|
};
|
|
9393
9449
|
const targetCoin = await this.routerSwap(routerSwapParams);
|
|
@@ -9569,18 +9625,16 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9569
9625
|
});
|
|
9570
9626
|
}
|
|
9571
9627
|
tx.setSenderIfNotSet(this.signer || "0x0");
|
|
9572
|
-
const simulateRes = await this.client.
|
|
9573
|
-
|
|
9574
|
-
|
|
9628
|
+
const simulateRes = await this.client.devInspectTransactionBlock({
|
|
9629
|
+
sender: this.signer || "0x0",
|
|
9630
|
+
transactionBlock: tx
|
|
9575
9631
|
});
|
|
9576
|
-
|
|
9577
|
-
|
|
9578
|
-
const errorMsg = txResult?.status.success === false ? txResult.status.error.message : "Unknown error";
|
|
9579
|
-
throw new Error("Simulation error: " + errorMsg);
|
|
9632
|
+
if (simulateRes.error) {
|
|
9633
|
+
throw new Error("Simulation error: " + simulateRes.error);
|
|
9580
9634
|
}
|
|
9581
|
-
const events =
|
|
9635
|
+
const events = simulateRes.events ?? [];
|
|
9582
9636
|
const valueData = events.filter((item) => {
|
|
9583
|
-
return item.
|
|
9637
|
+
return item.type.includes("CalculatedSwapResultEvent");
|
|
9584
9638
|
});
|
|
9585
9639
|
if (valueData.length === 0 || valueData.length !== pools.length) {
|
|
9586
9640
|
throw new Error("Simulate event result error");
|
|
@@ -9588,7 +9642,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9588
9642
|
let tempMaxAmount = byAmountIn ? new import_bn6.default(0) : new import_bn6.default(U64_MAX);
|
|
9589
9643
|
let tempIndex = 0;
|
|
9590
9644
|
for (let i = 0; i < valueData.length; i += 1) {
|
|
9591
|
-
const eventJson2 = valueData[i].
|
|
9645
|
+
const eventJson2 = valueData[i].parsedJson;
|
|
9592
9646
|
if (eventJson2?.data?.is_exceed) {
|
|
9593
9647
|
continue;
|
|
9594
9648
|
}
|
|
@@ -9606,11 +9660,11 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9606
9660
|
}
|
|
9607
9661
|
}
|
|
9608
9662
|
}
|
|
9609
|
-
const eventJson = valueData[tempIndex].
|
|
9663
|
+
const eventJson = valueData[tempIndex].parsedJson;
|
|
9610
9664
|
const eventData = eventJson?.data;
|
|
9611
9665
|
const [decimalA, decimalB] = await Promise.all([
|
|
9612
|
-
this.client.getCoinMetadata({ coinType: coinA }).then((res) => res
|
|
9613
|
-
this.client.getCoinMetadata({ coinType: coinB }).then((res) => res
|
|
9666
|
+
this.client.getCoinMetadata({ coinType: coinA }).then((res) => res?.decimals ?? null),
|
|
9667
|
+
this.client.getCoinMetadata({ coinType: coinB }).then((res) => res?.decimals ?? null)
|
|
9614
9668
|
]);
|
|
9615
9669
|
if (decimalA == null || decimalB == null) {
|
|
9616
9670
|
throw new Error("Cannot get coin decimals");
|
|
@@ -9679,9 +9733,9 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9679
9733
|
}
|
|
9680
9734
|
async devInspectTransactionBlock(txb) {
|
|
9681
9735
|
txb.setSenderIfNotSet(this.signer || "0x0");
|
|
9682
|
-
const res = await this.client.
|
|
9683
|
-
|
|
9684
|
-
|
|
9736
|
+
const res = await this.client.devInspectTransactionBlock({
|
|
9737
|
+
sender: this.signer || "0x0",
|
|
9738
|
+
transactionBlock: txb
|
|
9685
9739
|
});
|
|
9686
9740
|
return res;
|
|
9687
9741
|
}
|
|
@@ -9689,7 +9743,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
9689
9743
|
const res = await this.client.signAndExecuteTransaction({
|
|
9690
9744
|
transaction: txb,
|
|
9691
9745
|
signer,
|
|
9692
|
-
|
|
9746
|
+
options: { showEffects: true, showEvents: true, showBalanceChanges: true }
|
|
9693
9747
|
});
|
|
9694
9748
|
return res;
|
|
9695
9749
|
}
|
|
@@ -9760,4 +9814,4 @@ decimal.js/decimal.mjs:
|
|
|
9760
9814
|
*)
|
|
9761
9815
|
*/
|
|
9762
9816
|
|
|
9763
|
-
export { AFSUI, AFTERMATH, AFTERMATH_AMM, AFTERMATH_MODULE, AGGREGATOR, AGGREGATOR_V3_CONFIG, ALL_DEXES, ALPHAFI, AggregatorClient, AggregatorConfig, AggregatorError, AggregatorServerErrorCode, BLUEFIN, BLUEMOVE, CETUS, CETUSDLMM, CETUS_DEX, CETUS_MODULE, CETUS_PUBLISHED_AT, CHECK_COINS_THRESHOLD_FUNC, CLIENT_CONFIG, CLOCK_ADDRESS, CoinInfoAddress, CoinStoreAddress, CoinUtils, ConfigErrorCode, DEEPBOOKV2, DEEPBOOKV3, DEEPBOOK_CLOB_V2_MODULE, DEEPBOOK_CUSTODIAN_V2_MODULE, DEEPBOOK_DEX, DEEPBOOK_MODULE, DEEPBOOK_PACKAGE_ID, DEEPBOOK_PUBLISHED_AT, DEEPBOOK_V3_DEEP_FEE_TYPES, DEFAULT_AGG_V2_ENDPOINT, DEFAULT_AGG_V3_ENDPOINT, DEFAULT_ENDPOINT, DEFAULT_GAS_BUDGET_FOR_MERGE, DEFAULT_GAS_BUDGET_FOR_SPLIT, DEFAULT_GAS_BUDGET_FOR_STAKE, DEFAULT_GAS_BUDGET_FOR_TRANSFER, DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI, DEFAULT_NFT_TRANSFER_GAS_FEE, Env, FERRACLMM, FERRADLMM, FLOWXV2, FLOWXV3, FLOWX_AMM, FLOWX_AMM_MODULE, FULLSAIL, FlashSwapA2BFunc, FlashSwapB2AFunc, FlashSwapFunc, FlashSwapWithPartnerA2BFunc, FlashSwapWithPartnerB2AFunc, FlashSwapWithPartnerFunc, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, HAEDAL, HAEDALHMMV2, HAEDALPMM, HAWAL, INTEGRATE, JOIN_FUNC, KRIYA, KRIYAV3, KRIYA_DEX, KRIYA_MODULE, MAGMA, MAINNET_AFTERMATH_INSURANCE_FUND_ID, MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, MAINNET_AFTERMATH_REFERRAL_VAULT_ID, MAINNET_AFTERMATH_REGISTRY_ID, MAINNET_AFTERMATH_TREASURY_ID, MAINNET_CETUS_V3_PUBLISHED_AT, MAINNET_FLOWX_AMM_CONTAINER_ID, METASTABLE, MOMENTUM, OBRIC, ONE, PACKAGE_NAMES, PAY_MODULE, POOL_MODULT, PUBLISHED_ADDRESSES, PYTH_CONFIG, REPAY_FLASH_SWAP_A2B_FUNC, REPAY_FLASH_SWAP_B2A_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC, RepayFalshSwapFunc, RepayFlashSwapWithPartnerFunc, SCALLOP, SEVENK, SPRINGSUI, STEAMM, STEAMM_OMM, STEAMM_OMM_V2, SUILEND, SUI_SYSTEM_STATE_OBJECT_ID, SWAP_A2B_FUNC, SWAP_B2A_FUNC, SuiZeroCoinFn, TEN_POW_NINE, TESTNET_AFTERMATH_INSURANCE_FUND_ID, TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, TESTNET_AFTERMATH_REFERRAL_VAULT_ID, TESTNET_AFTERMATH_REGISTRY_ID, TESTNET_AFTERMATH_TREASURY_ID, TESTNET_CETUS_V3_PUBLISHED_AT, TESTNET_FLOWX_AMM_CONTAINER_ID, TRANSFER_ACCOUNT_CAP, TRANSFER_OR_DESTORY_COIN_FUNC, TURBOS, TURBOS_DEX, TURBOS_MODULE, TURBOS_VERSIONED, TWO, TransactionErrorCode, TypesErrorCode, U128, U64_MAX, U64_MAX_BN, UTILS_MODULE, VOLO, ZERO, buildInputCoin, calculateGasEfficiency, calculatePriceImpact, checkInvalidSuiAddress, compareCoins, compareGasMetrics, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, exportToCSV, exportToJSON, extractAddressFromType, extractGasMetrics, extractStructTagFromType, extractTimestampFromDowngradeUuid6, fixSuiObjectId, formatGasMetrics, generateDowngradeUuid6, generateSimpleDowngradeUuid6, getAggregatorServerErrorMessage, getAggregatorV2Extend2PublishedAt, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getAllProviders, getDeepbookV3Config, getDefaultSuiInputType, getMergeSwapResult, getOrCreateAccountCap, getProvidersExcluding, getProvidersIncluding, getRouterResult, isSortedSymbols, isValidDowngradeUuid6, mintZeroCoin, normalizeCoinType, parseAftermathFeeType, parseTurbosPoolFeeType, patchFixSuiObjectId, printTransaction, processEndpoint, processFlattenRoutes, restituteMsafeFastRouterSwapParams };
|
|
9817
|
+
export { AFSUI, AFTERMATH, AFTERMATH_AMM, AFTERMATH_MODULE, AGGREGATOR, AGGREGATOR_V3_CONFIG, ALL_DEXES, ALPHAFI, AggregatorClient, AggregatorConfig, AggregatorError, AggregatorServerErrorCode, BLUEFIN, BLUEMOVE, BOLT, CETUS, CETUSDLMM, CETUS_DEX, CETUS_MODULE, CETUS_PUBLISHED_AT, CHECK_COINS_THRESHOLD_FUNC, CLIENT_CONFIG, CLOCK_ADDRESS, CoinInfoAddress, CoinStoreAddress, CoinUtils, ConfigErrorCode, DEEPBOOKV2, DEEPBOOKV3, DEEPBOOK_CLOB_V2_MODULE, DEEPBOOK_CUSTODIAN_V2_MODULE, DEEPBOOK_DEX, DEEPBOOK_MODULE, DEEPBOOK_PACKAGE_ID, DEEPBOOK_PUBLISHED_AT, DEEPBOOK_V3_DEEP_FEE_TYPES, DEFAULT_AGG_V2_ENDPOINT, DEFAULT_AGG_V3_ENDPOINT, DEFAULT_ENDPOINT, DEFAULT_GAS_BUDGET_FOR_MERGE, DEFAULT_GAS_BUDGET_FOR_SPLIT, DEFAULT_GAS_BUDGET_FOR_STAKE, DEFAULT_GAS_BUDGET_FOR_TRANSFER, DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI, DEFAULT_NFT_TRANSFER_GAS_FEE, Env, FERRACLMM, FERRADLMM, FLOWXV2, FLOWXV3, FLOWX_AMM, FLOWX_AMM_MODULE, FULLSAIL, FlashSwapA2BFunc, FlashSwapB2AFunc, FlashSwapFunc, FlashSwapWithPartnerA2BFunc, FlashSwapWithPartnerB2AFunc, FlashSwapWithPartnerFunc, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, HAEDAL, HAEDALHMMV2, HAEDALPMM, HAWAL, INTEGRATE, JOIN_FUNC, KRIYA, KRIYAV3, KRIYA_DEX, KRIYA_MODULE, MAGMA, MAINNET_AFTERMATH_INSURANCE_FUND_ID, MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, MAINNET_AFTERMATH_REFERRAL_VAULT_ID, MAINNET_AFTERMATH_REGISTRY_ID, MAINNET_AFTERMATH_TREASURY_ID, MAINNET_CETUS_V3_PUBLISHED_AT, MAINNET_FLOWX_AMM_CONTAINER_ID, METASTABLE, MOMENTUM, OBRIC, ONE, PACKAGE_NAMES, PAY_MODULE, POOL_MODULT, PUBLISHED_ADDRESSES, PYTH_CONFIG, REPAY_FLASH_SWAP_A2B_FUNC, REPAY_FLASH_SWAP_B2A_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC, REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC, RepayFalshSwapFunc, RepayFlashSwapWithPartnerFunc, SCALLOP, SEVENK, SPRINGSUI, STEAMM, STEAMM_OMM, STEAMM_OMM_V2, SUILEND, SUI_SYSTEM_STATE_OBJECT_ID, SWAP_A2B_FUNC, SWAP_B2A_FUNC, SuiZeroCoinFn, TEN_POW_NINE, TESTNET_AFTERMATH_INSURANCE_FUND_ID, TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID, TESTNET_AFTERMATH_REFERRAL_VAULT_ID, TESTNET_AFTERMATH_REGISTRY_ID, TESTNET_AFTERMATH_TREASURY_ID, TESTNET_CETUS_V3_PUBLISHED_AT, TESTNET_FLOWX_AMM_CONTAINER_ID, TRANSFER_ACCOUNT_CAP, TRANSFER_OR_DESTORY_COIN_FUNC, TURBOS, TURBOS_DEX, TURBOS_MODULE, TURBOS_VERSIONED, TWO, TransactionErrorCode, TypesErrorCode, U128, U64_MAX, U64_MAX_BN, UTILS_MODULE, VOLO, ZERO, buildInputCoin, calculateGasEfficiency, calculatePriceImpact, checkInvalidSuiAddress, compareCoins, compareGasMetrics, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, exportToCSV, exportToJSON, extractAddressFromType, extractGasMetrics, extractStructTagFromType, extractTimestampFromDowngradeUuid6, fixSuiObjectId, formatGasMetrics, generateDowngradeUuid6, generateSimpleDowngradeUuid6, getAggregatorServerErrorMessage, getAggregatorV2Extend2PublishedAt, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getAllProviders, getDeepbookV3Config, getDefaultSuiInputType, getMergeSwapResult, getOrCreateAccountCap, getProvidersExcluding, getProvidersIncluding, getRouterResult, isSortedSymbols, isValidDowngradeUuid6, mintZeroCoin, normalizeCoinType, parseAftermathFeeType, parseTurbosPoolFeeType, patchFixSuiObjectId, printTransaction, processEndpoint, processFlattenRoutes, restituteMsafeFastRouterSwapParams };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cetusprotocol/aggregator-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"typescript": "^5.0.0"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@mysten/sui": "^2.
|
|
25
|
+
"@mysten/sui": "^2.6.0",
|
|
26
26
|
"@pythnetwork/hermes-client": "^3.1.0",
|
|
27
27
|
"bip39": "^3.1.0",
|
|
28
28
|
"dotenv": "^16.4.5",
|