@cetusprotocol/aggregator-sdk 0.3.20 → 0.3.22
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.lockb +0 -0
- package/dist/index.d.mts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.js +161 -46
- package/dist/index.mjs +161 -47
- package/dist/src/client.d.ts +7 -2
- package/dist/src/transaction/haedal_pmm.d.ts +2 -4
- package/package.json +1 -1
- package/src/api.ts +2 -2
- package/src/client.ts +232 -58
- package/src/transaction/haedal.ts +1 -4
- package/src/transaction/haedal_pmm.ts +33 -24
- package/src/transaction/index.ts +9 -4
- package/tests/router.test.ts +25 -11
package/dist/index.mjs
CHANGED
|
@@ -5934,10 +5934,7 @@ var Haedal = class {
|
|
|
5934
5934
|
swap(client, txb, path, inputCoin, packages) {
|
|
5935
5935
|
return __async(this, null, function* () {
|
|
5936
5936
|
const { direction } = path;
|
|
5937
|
-
|
|
5938
|
-
throw new Error("Haedal not support b2a swap");
|
|
5939
|
-
}
|
|
5940
|
-
const func = "swap_a2b";
|
|
5937
|
+
const func = direction ? "swap_a2b" : "swap_b2a";
|
|
5941
5938
|
const args = [txb.object(path.id), txb.object("0x5"), inputCoin];
|
|
5942
5939
|
const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages);
|
|
5943
5940
|
const res = txb.moveCall({
|
|
@@ -6171,19 +6168,14 @@ var Bluefin = class {
|
|
|
6171
6168
|
});
|
|
6172
6169
|
}
|
|
6173
6170
|
};
|
|
6171
|
+
|
|
6172
|
+
// src/transaction/haedal_pmm.ts
|
|
6174
6173
|
var HaedalPmm = class {
|
|
6175
|
-
constructor(env,
|
|
6174
|
+
constructor(env, pythPriceIDs) {
|
|
6176
6175
|
if (env === 1 /* Testnet */) {
|
|
6177
|
-
|
|
6178
|
-
const wormholeStateId = "0x31358d198147da50db32eda2562951d53973a0c0ad5ed738e9b17d88b213d790";
|
|
6179
|
-
const pythStateId = "0x243759059f4c3111179da5878c12f68d612c21a8d54d85edc86164bb18be1c7c";
|
|
6180
|
-
this.pythClient = new SuiPythClient(suiClient, pythStateId, wormholeStateId);
|
|
6181
|
-
} else {
|
|
6182
|
-
this.connection = new SuiPriceServiceConnection("https://hermes.pyth.network");
|
|
6183
|
-
const wormholeStateId = "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c";
|
|
6184
|
-
const pythStateId = "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8";
|
|
6185
|
-
this.pythClient = new SuiPythClient(suiClient, pythStateId, wormholeStateId);
|
|
6176
|
+
throw new Error("HaedalPmm is not supported on testnet");
|
|
6186
6177
|
}
|
|
6178
|
+
this.pythPriceIDs = pythPriceIDs;
|
|
6187
6179
|
}
|
|
6188
6180
|
swap(client, txb, path, inputCoin, packages) {
|
|
6189
6181
|
return __async(this, null, function* () {
|
|
@@ -6200,17 +6192,24 @@ var HaedalPmm = class {
|
|
|
6200
6192
|
basePriceSeed = path.extendedDetails.haedalPmmBasePriceSeed;
|
|
6201
6193
|
quotePriceSeed = path.extendedDetails.haedalPmmQuotePriceSeed;
|
|
6202
6194
|
}
|
|
6203
|
-
const
|
|
6204
|
-
const
|
|
6205
|
-
|
|
6195
|
+
const basePriceInfoObjectId = this.pythPriceIDs.get(basePriceSeed);
|
|
6196
|
+
const quotePriceInfoObjectId = this.pythPriceIDs.get(quotePriceSeed);
|
|
6197
|
+
if (!basePriceInfoObjectId || !quotePriceInfoObjectId) {
|
|
6198
|
+
throw new Error(
|
|
6199
|
+
"Base price info object id or quote price info object id not found"
|
|
6200
|
+
);
|
|
6201
|
+
}
|
|
6206
6202
|
const args = [
|
|
6207
6203
|
txb.object(path.id),
|
|
6208
|
-
txb.object(
|
|
6209
|
-
txb.object(
|
|
6204
|
+
txb.object(basePriceInfoObjectId),
|
|
6205
|
+
txb.object(quotePriceInfoObjectId),
|
|
6210
6206
|
inputCoin,
|
|
6211
6207
|
txb.object(CLOCK_ADDRESS)
|
|
6212
6208
|
];
|
|
6213
|
-
const publishedAt = getAggregatorV2ExtendPublishedAt(
|
|
6209
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(
|
|
6210
|
+
client.publishedAtV2Extend(),
|
|
6211
|
+
packages
|
|
6212
|
+
);
|
|
6214
6213
|
const res = txb.moveCall({
|
|
6215
6214
|
target: `${publishedAt}::haedalpmm::${func}`,
|
|
6216
6215
|
typeArguments: [coinAType, coinBType],
|
|
@@ -6248,8 +6247,6 @@ var Alphafi = class {
|
|
|
6248
6247
|
});
|
|
6249
6248
|
}
|
|
6250
6249
|
};
|
|
6251
|
-
|
|
6252
|
-
// src/client.ts
|
|
6253
6250
|
var CETUS = "CETUS";
|
|
6254
6251
|
var DEEPBOOKV2 = "DEEPBOOK";
|
|
6255
6252
|
var KRIYA = "KRIYA";
|
|
@@ -6276,13 +6273,20 @@ function isBuilderRouterSwapParams(params) {
|
|
|
6276
6273
|
function isBuilderFastRouterSwapParams(params) {
|
|
6277
6274
|
return Array.isArray(params.routers);
|
|
6278
6275
|
}
|
|
6279
|
-
var
|
|
6276
|
+
var _AggregatorClient = class _AggregatorClient {
|
|
6280
6277
|
constructor(endpoint, signer, client, env) {
|
|
6281
6278
|
this.endpoint = endpoint ? processEndpoint(endpoint) : DEFAULT_ENDPOINT;
|
|
6282
6279
|
this.client = client || new SuiClient({ url: getFullnodeUrl("mainnet") });
|
|
6283
6280
|
this.signer = signer || "";
|
|
6284
6281
|
this.env = env || 0 /* Mainnet */;
|
|
6285
6282
|
this.allCoins = /* @__PURE__ */ new Map();
|
|
6283
|
+
const config2 = _AggregatorClient.CONFIG[this.env];
|
|
6284
|
+
this.pythConnections = config2.connections;
|
|
6285
|
+
this.pythClient = new SuiPythClient(
|
|
6286
|
+
this.client,
|
|
6287
|
+
config2.pythStateId,
|
|
6288
|
+
config2.wormholeStateId
|
|
6289
|
+
);
|
|
6286
6290
|
}
|
|
6287
6291
|
getCoins(coinType, refresh = true) {
|
|
6288
6292
|
return __async(this, null, function* () {
|
|
@@ -6326,7 +6330,7 @@ var AggregatorClient19 = class {
|
|
|
6326
6330
|
return getRouterResult(this.endpoint, params);
|
|
6327
6331
|
});
|
|
6328
6332
|
}
|
|
6329
|
-
expectInputSwap(txb, inputCoin, routers, amountOutLimit, partner, deepbookv3DeepFee, packages) {
|
|
6333
|
+
expectInputSwap(txb, inputCoin, routers, amountOutLimit, pythPriceIDs, partner, deepbookv3DeepFee, packages) {
|
|
6330
6334
|
return __async(this, null, function* () {
|
|
6331
6335
|
if (routers.length === 0) {
|
|
6332
6336
|
throw new Error("No router found");
|
|
@@ -6342,13 +6346,28 @@ var AggregatorClient19 = class {
|
|
|
6342
6346
|
}
|
|
6343
6347
|
let nextCoin = inputCoins[i];
|
|
6344
6348
|
for (const path of routers[i].path) {
|
|
6345
|
-
const dex = this.newDex(path.provider, partner);
|
|
6346
|
-
nextCoin = yield dex.swap(
|
|
6349
|
+
const dex = this.newDex(path.provider, pythPriceIDs, partner);
|
|
6350
|
+
nextCoin = yield dex.swap(
|
|
6351
|
+
this,
|
|
6352
|
+
txb,
|
|
6353
|
+
path,
|
|
6354
|
+
nextCoin,
|
|
6355
|
+
packages,
|
|
6356
|
+
deepbookv3DeepFee
|
|
6357
|
+
);
|
|
6347
6358
|
}
|
|
6348
6359
|
outputCoins.push(nextCoin);
|
|
6349
6360
|
}
|
|
6350
|
-
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(
|
|
6351
|
-
|
|
6361
|
+
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(
|
|
6362
|
+
this.publishedAtV2(),
|
|
6363
|
+
packages
|
|
6364
|
+
);
|
|
6365
|
+
this.transferOrDestoryCoin(
|
|
6366
|
+
txb,
|
|
6367
|
+
inputCoin,
|
|
6368
|
+
inputCoinType,
|
|
6369
|
+
this.publishedAtV2()
|
|
6370
|
+
);
|
|
6352
6371
|
const mergedTargetCointhis = this.checkCoinThresholdAndMergeCoin(
|
|
6353
6372
|
txb,
|
|
6354
6373
|
outputCoins,
|
|
@@ -6365,7 +6384,10 @@ var AggregatorClient19 = class {
|
|
|
6365
6384
|
const receipts = [];
|
|
6366
6385
|
const targetCoins = [];
|
|
6367
6386
|
const dex = new Cetus(this.env, partner);
|
|
6368
|
-
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(
|
|
6387
|
+
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(
|
|
6388
|
+
this.publishedAtV2(),
|
|
6389
|
+
packages
|
|
6390
|
+
);
|
|
6369
6391
|
for (let i = 0; i < routers.length; i++) {
|
|
6370
6392
|
const router = routers[i];
|
|
6371
6393
|
for (let j = router.path.length - 1; j >= 0; j--) {
|
|
@@ -6388,7 +6410,12 @@ var AggregatorClient19 = class {
|
|
|
6388
6410
|
if (j === 0) {
|
|
6389
6411
|
inputCoin = repayResult;
|
|
6390
6412
|
} else {
|
|
6391
|
-
this.transferOrDestoryCoin(
|
|
6413
|
+
this.transferOrDestoryCoin(
|
|
6414
|
+
txb,
|
|
6415
|
+
repayResult,
|
|
6416
|
+
path.from,
|
|
6417
|
+
aggregatorV2PublishedAt
|
|
6418
|
+
);
|
|
6392
6419
|
}
|
|
6393
6420
|
if (j === router.path.length - 1) {
|
|
6394
6421
|
targetCoins.push(nextRepayCoin);
|
|
@@ -6396,7 +6423,12 @@ var AggregatorClient19 = class {
|
|
|
6396
6423
|
}
|
|
6397
6424
|
}
|
|
6398
6425
|
const inputCoinType = routers[0].path[0].from;
|
|
6399
|
-
this.transferOrDestoryCoin(
|
|
6426
|
+
this.transferOrDestoryCoin(
|
|
6427
|
+
txb,
|
|
6428
|
+
inputCoin,
|
|
6429
|
+
inputCoinType,
|
|
6430
|
+
aggregatorV2PublishedAt
|
|
6431
|
+
);
|
|
6400
6432
|
if (targetCoins.length > 1) {
|
|
6401
6433
|
const vec = txb.makeMoveVec({ elements: targetCoins.slice(1) });
|
|
6402
6434
|
txb.moveCall({
|
|
@@ -6422,14 +6454,7 @@ var AggregatorClient19 = class {
|
|
|
6422
6454
|
}
|
|
6423
6455
|
routerSwap(params) {
|
|
6424
6456
|
return __async(this, null, function* () {
|
|
6425
|
-
const {
|
|
6426
|
-
routers,
|
|
6427
|
-
inputCoin,
|
|
6428
|
-
slippage,
|
|
6429
|
-
txb,
|
|
6430
|
-
partner,
|
|
6431
|
-
deepbookv3DeepFee
|
|
6432
|
-
} = params;
|
|
6457
|
+
const { routers, inputCoin, slippage, txb, partner, deepbookv3DeepFee } = params;
|
|
6433
6458
|
const routerData = Array.isArray(routers) ? routers : routers.routes;
|
|
6434
6459
|
const byAmountIn = isBuilderRouterSwapParams(params) ? params.byAmountIn : params.routers.byAmountIn;
|
|
6435
6460
|
const amountIn = routerData.reduce(
|
|
@@ -6447,13 +6472,19 @@ var AggregatorClient19 = class {
|
|
|
6447
6472
|
);
|
|
6448
6473
|
const packages = isBuilderRouterSwapParams(params) ? void 0 : params.routers.packages;
|
|
6449
6474
|
console.log("packages11", packages);
|
|
6450
|
-
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(
|
|
6475
|
+
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(
|
|
6476
|
+
this.publishedAtV2(),
|
|
6477
|
+
packages
|
|
6478
|
+
);
|
|
6479
|
+
const priceIDs = findPythPriceIDs(routerData);
|
|
6480
|
+
const priceInfoObjectIds = priceIDs.length > 0 ? yield this.updatePythPriceIDs(priceIDs, txb) : /* @__PURE__ */ new Map();
|
|
6451
6481
|
if (byAmountIn) {
|
|
6452
6482
|
const targetCoin2 = yield this.expectInputSwap(
|
|
6453
6483
|
txb,
|
|
6454
6484
|
inputCoin,
|
|
6455
6485
|
routerData,
|
|
6456
6486
|
amountLimit,
|
|
6487
|
+
priceInfoObjectIds,
|
|
6457
6488
|
partner,
|
|
6458
6489
|
deepbookv3DeepFee,
|
|
6459
6490
|
packages
|
|
@@ -6463,7 +6494,12 @@ var AggregatorClient19 = class {
|
|
|
6463
6494
|
const splitedInputCoins = txb.splitCoins(inputCoin, [
|
|
6464
6495
|
amountLimit.toString()
|
|
6465
6496
|
]);
|
|
6466
|
-
this.transferOrDestoryCoin(
|
|
6497
|
+
this.transferOrDestoryCoin(
|
|
6498
|
+
txb,
|
|
6499
|
+
inputCoin,
|
|
6500
|
+
routerData[0].path[0].from,
|
|
6501
|
+
aggregatorV2PublishedAt
|
|
6502
|
+
);
|
|
6467
6503
|
const targetCoin = yield this.expectOutputSwap(
|
|
6468
6504
|
txb,
|
|
6469
6505
|
splitedInputCoins[0],
|
|
@@ -6549,7 +6585,10 @@ var AggregatorClient19 = class {
|
|
|
6549
6585
|
targetCoinType
|
|
6550
6586
|
);
|
|
6551
6587
|
const packages = isBuilderFastRouterSwapParams(params) ? void 0 : params.routers.packages;
|
|
6552
|
-
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(
|
|
6588
|
+
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(
|
|
6589
|
+
this.publishedAtV2(),
|
|
6590
|
+
packages
|
|
6591
|
+
);
|
|
6553
6592
|
txb.mergeCoins(targetCoinRes.targetCoin, [targetCoin]);
|
|
6554
6593
|
if (targetCoinRes.isMintZeroCoin) {
|
|
6555
6594
|
this.transferOrDestoryCoin(
|
|
@@ -6565,7 +6604,7 @@ var AggregatorClient19 = class {
|
|
|
6565
6604
|
// Include cetus、deepbookv2、flowxv2 & v3、kriyav2 & v3、turbos、aftermath、haedal、afsui、volo、bluemove
|
|
6566
6605
|
publishedAtV2() {
|
|
6567
6606
|
if (this.env === 0 /* Mainnet */) {
|
|
6568
|
-
return "
|
|
6607
|
+
return "0xf9c6f78322ed667909e05f6b42b2f5a67af6297503c905335e02a15148e9440d";
|
|
6569
6608
|
} else {
|
|
6570
6609
|
return "0x52eae33adeb44de55cfb3f281d4cc9e02d976181c0952f5323648b5717b33934";
|
|
6571
6610
|
}
|
|
@@ -6610,7 +6649,7 @@ var AggregatorClient19 = class {
|
|
|
6610
6649
|
});
|
|
6611
6650
|
return targetCoin;
|
|
6612
6651
|
}
|
|
6613
|
-
newDex(provider, partner) {
|
|
6652
|
+
newDex(provider, pythPriceIDs, partner) {
|
|
6614
6653
|
switch (provider) {
|
|
6615
6654
|
case CETUS:
|
|
6616
6655
|
return new Cetus(this.env, partner);
|
|
@@ -6647,7 +6686,7 @@ var AggregatorClient19 = class {
|
|
|
6647
6686
|
case BLUEFIN:
|
|
6648
6687
|
return new Bluefin(this.env);
|
|
6649
6688
|
case HAEDALPMM:
|
|
6650
|
-
return new HaedalPmm(this.env,
|
|
6689
|
+
return new HaedalPmm(this.env, pythPriceIDs);
|
|
6651
6690
|
case ALPHAFI:
|
|
6652
6691
|
return new Alphafi(this.env);
|
|
6653
6692
|
default:
|
|
@@ -6696,7 +6735,82 @@ var AggregatorClient19 = class {
|
|
|
6696
6735
|
return null;
|
|
6697
6736
|
});
|
|
6698
6737
|
}
|
|
6738
|
+
updatePythPriceIDs(priceIDs, txb) {
|
|
6739
|
+
return __async(this, null, function* () {
|
|
6740
|
+
let priceUpdateData = null;
|
|
6741
|
+
let lastError = null;
|
|
6742
|
+
for (const connection of this.pythConnections) {
|
|
6743
|
+
try {
|
|
6744
|
+
priceUpdateData = yield connection.getPriceFeedsUpdateData(priceIDs);
|
|
6745
|
+
break;
|
|
6746
|
+
} catch (e) {
|
|
6747
|
+
lastError = e;
|
|
6748
|
+
console.log("Error: ", e);
|
|
6749
|
+
continue;
|
|
6750
|
+
}
|
|
6751
|
+
}
|
|
6752
|
+
if (priceUpdateData == null) {
|
|
6753
|
+
throw new Error(
|
|
6754
|
+
`No pyth price seeds update data found: ${lastError == null ? void 0 : lastError.message}`
|
|
6755
|
+
);
|
|
6756
|
+
}
|
|
6757
|
+
let priceInfoObjectIds = [];
|
|
6758
|
+
try {
|
|
6759
|
+
priceInfoObjectIds = yield this.pythClient.updatePriceFeeds(
|
|
6760
|
+
txb,
|
|
6761
|
+
priceUpdateData,
|
|
6762
|
+
priceIDs
|
|
6763
|
+
);
|
|
6764
|
+
} catch (e) {
|
|
6765
|
+
throw new Error(`Failed to update price feeds: ${e}`);
|
|
6766
|
+
}
|
|
6767
|
+
let priceInfoObjectIdsMap = /* @__PURE__ */ new Map();
|
|
6768
|
+
for (let i = 0; i < priceIDs.length; i++) {
|
|
6769
|
+
priceInfoObjectIdsMap.set(priceIDs[i], priceInfoObjectIds[i]);
|
|
6770
|
+
}
|
|
6771
|
+
return priceInfoObjectIdsMap;
|
|
6772
|
+
});
|
|
6773
|
+
}
|
|
6774
|
+
};
|
|
6775
|
+
_AggregatorClient.CONFIG = {
|
|
6776
|
+
[1 /* Testnet */]: {
|
|
6777
|
+
connections: [
|
|
6778
|
+
new SuiPriceServiceConnection("https://hermes-beta.pyth.network")
|
|
6779
|
+
],
|
|
6780
|
+
wormholeStateId: "0x31358d198147da50db32eda2562951d53973a0c0ad5ed738e9b17d88b213d790",
|
|
6781
|
+
pythStateId: "0x243759059f4c3111179da5878c12f68d612c21a8d54d85edc86164bb18be1c7c"
|
|
6782
|
+
},
|
|
6783
|
+
[0 /* Mainnet */]: {
|
|
6784
|
+
connections: [
|
|
6785
|
+
new SuiPriceServiceConnection(
|
|
6786
|
+
"https://cetus.liquify.com/api=X9LTVPQD7Y3R5N2A/hermes",
|
|
6787
|
+
{
|
|
6788
|
+
timeout: 3e3
|
|
6789
|
+
}
|
|
6790
|
+
),
|
|
6791
|
+
new SuiPriceServiceConnection("https://hermes.pyth.network", {
|
|
6792
|
+
timeout: 3e3
|
|
6793
|
+
})
|
|
6794
|
+
],
|
|
6795
|
+
wormholeStateId: "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c",
|
|
6796
|
+
pythStateId: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8"
|
|
6797
|
+
}
|
|
6699
6798
|
};
|
|
6799
|
+
var AggregatorClient19 = _AggregatorClient;
|
|
6800
|
+
function findPythPriceIDs(routes) {
|
|
6801
|
+
const priceIDs = /* @__PURE__ */ new Set();
|
|
6802
|
+
for (const route of routes) {
|
|
6803
|
+
for (const path of route.path) {
|
|
6804
|
+
if (path.provider === HAEDALPMM) {
|
|
6805
|
+
if (path.extendedDetails && path.extendedDetails.haedalPmmBasePriceSeed && path.extendedDetails.haedalPmmQuotePriceSeed) {
|
|
6806
|
+
priceIDs.add(path.extendedDetails.haedalPmmBasePriceSeed);
|
|
6807
|
+
priceIDs.add(path.extendedDetails.haedalPmmQuotePriceSeed);
|
|
6808
|
+
}
|
|
6809
|
+
}
|
|
6810
|
+
}
|
|
6811
|
+
}
|
|
6812
|
+
return Array.from(priceIDs);
|
|
6813
|
+
}
|
|
6700
6814
|
function parseRouterResponse(data, byAmountIn) {
|
|
6701
6815
|
let totalDeepFee = 0;
|
|
6702
6816
|
for (const route of data.routes) {
|
|
@@ -6921,7 +7035,7 @@ function getRouter(endpoint, params) {
|
|
|
6921
7035
|
url += `&providers=${providers.join(",")}`;
|
|
6922
7036
|
}
|
|
6923
7037
|
}
|
|
6924
|
-
url += "&v=
|
|
7038
|
+
url += "&v=1000322";
|
|
6925
7039
|
const response = yield fetch(url);
|
|
6926
7040
|
return response;
|
|
6927
7041
|
} catch (error) {
|
|
@@ -7011,4 +7125,4 @@ decimal.js/decimal.mjs:
|
|
|
7011
7125
|
*)
|
|
7012
7126
|
*/
|
|
7013
7127
|
|
|
7014
|
-
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI, AggregatorClient19 as AggregatorClient, BLUEFIN, BLUEMOVE, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, Env, FLOWXV2, FLOWXV3, HAEDAL, HAEDALPMM, KRIYA, KRIYAV3, ONE, SCALLOP, SPRINGSUI, SUILEND, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
|
|
7128
|
+
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI, AggregatorClient19 as AggregatorClient, BLUEFIN, BLUEMOVE, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, Env, FLOWXV2, FLOWXV3, HAEDAL, HAEDALPMM, KRIYA, KRIYAV3, ONE, SCALLOP, SPRINGSUI, SUILEND, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, findPythPriceIDs, fixSuiObjectId, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
|
package/dist/src/client.d.ts
CHANGED
|
@@ -75,10 +75,13 @@ export declare class AggregatorClient {
|
|
|
75
75
|
client: SuiClient;
|
|
76
76
|
env: Env;
|
|
77
77
|
private allCoins;
|
|
78
|
+
private pythConnections;
|
|
79
|
+
private pythClient;
|
|
80
|
+
private static readonly CONFIG;
|
|
78
81
|
constructor(endpoint?: string, signer?: string, client?: SuiClient, env?: Env);
|
|
79
82
|
getCoins(coinType: string, refresh?: boolean): Promise<CoinAsset[]>;
|
|
80
83
|
findRouters(params: FindRouterParams): Promise<RouterData | null>;
|
|
81
|
-
expectInputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], amountOutLimit: BN, partner?: string, deepbookv3DeepFee?: TransactionObjectArgument, packages?: Map<string, string>): Promise<TransactionObjectArgument>;
|
|
84
|
+
expectInputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], amountOutLimit: BN, pythPriceIDs: Map<string, string>, partner?: string, deepbookv3DeepFee?: TransactionObjectArgument, packages?: Map<string, string>): Promise<TransactionObjectArgument>;
|
|
82
85
|
expectOutputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], partner?: string, packages?: Map<string, string>): Promise<TransactionObjectArgument>;
|
|
83
86
|
swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResult | null>;
|
|
84
87
|
routerSwap(params: BuildRouterSwapParams | BuildRouterSwapParamsV2): Promise<TransactionObjectArgument>;
|
|
@@ -88,10 +91,12 @@ export declare class AggregatorClient {
|
|
|
88
91
|
deepbookv3DeepFeeType(): string;
|
|
89
92
|
transferOrDestoryCoin(txb: Transaction, coin: TransactionObjectArgument, coinType: string, aggregatorV2PublishedAt: string): void;
|
|
90
93
|
checkCoinThresholdAndMergeCoin(txb: Transaction, coins: TransactionObjectArgument[], coinType: string, amountLimit: BN, aggregatorV2PublishedAt: string): TransactionObjectArgument;
|
|
91
|
-
newDex(provider: string, partner?: string): Dex;
|
|
94
|
+
newDex(provider: string, pythPriceIDs: Map<string, string>, partner?: string): Dex;
|
|
92
95
|
signAndExecuteTransaction(txb: Transaction, signer: Signer): Promise<import("@mysten/sui/client").SuiTransactionBlockResponse>;
|
|
93
96
|
devInspectTransactionBlock(txb: Transaction): Promise<import("@mysten/sui/client").DevInspectResults>;
|
|
94
97
|
sendTransaction(txb: Transaction, signer: Signer): Promise<import("@mysten/sui/client").SuiTransactionBlockResponse>;
|
|
95
98
|
getDeepbookV3Config(): Promise<DeepbookV3Config | null>;
|
|
99
|
+
updatePythPriceIDs(priceIDs: string[], txb: Transaction): Promise<Map<string, string>>;
|
|
96
100
|
}
|
|
101
|
+
export declare function findPythPriceIDs(routes: Router[]): string[];
|
|
97
102
|
export declare function parseRouterResponse(data: any, byAmountIn: boolean): RouterData;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
2
2
|
import { AggregatorClient, Dex, Env, Path } from "..";
|
|
3
|
-
import { SuiClient } from "@mysten/sui/client";
|
|
4
3
|
export declare class HaedalPmm implements Dex {
|
|
5
|
-
private
|
|
6
|
-
|
|
7
|
-
constructor(env: Env, suiClient: SuiClient);
|
|
4
|
+
private pythPriceIDs;
|
|
5
|
+
constructor(env: Env, pythPriceIDs: Map<string, string>);
|
|
8
6
|
swap(client: AggregatorClient, txb: Transaction, path: Path, inputCoin: TransactionObjectArgument, packages?: Map<string, string>): Promise<TransactionObjectArgument>;
|
|
9
7
|
}
|
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -114,7 +114,7 @@ export async function getRouterResult(
|
|
|
114
114
|
const data = await response.json()
|
|
115
115
|
const insufficientLiquidity = data.msg === "liquidity is not enough"
|
|
116
116
|
|
|
117
|
-
if(data.msg && data.msg.indexOf(
|
|
117
|
+
if (data.msg && data.msg.indexOf("HoneyPot scam") > -1) {
|
|
118
118
|
return {
|
|
119
119
|
amountIn: ZERO,
|
|
120
120
|
amountOut: ZERO,
|
|
@@ -190,7 +190,7 @@ async function getRouter(endpoint: string, params: FindRouterParams) {
|
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
// set newest sdk version
|
|
193
|
-
url += "&v=
|
|
193
|
+
url += "&v=1000322"
|
|
194
194
|
|
|
195
195
|
const response = await fetch(url)
|
|
196
196
|
return response
|