@cetusprotocol/aggregator-sdk 0.3.21 → 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 +159 -41
- package/dist/index.mjs +159 -42
- 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 +229 -56
- 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
|
@@ -6168,19 +6168,14 @@ var Bluefin = class {
|
|
|
6168
6168
|
});
|
|
6169
6169
|
}
|
|
6170
6170
|
};
|
|
6171
|
+
|
|
6172
|
+
// src/transaction/haedal_pmm.ts
|
|
6171
6173
|
var HaedalPmm = class {
|
|
6172
|
-
constructor(env,
|
|
6174
|
+
constructor(env, pythPriceIDs) {
|
|
6173
6175
|
if (env === 1 /* Testnet */) {
|
|
6174
|
-
|
|
6175
|
-
const wormholeStateId = "0x31358d198147da50db32eda2562951d53973a0c0ad5ed738e9b17d88b213d790";
|
|
6176
|
-
const pythStateId = "0x243759059f4c3111179da5878c12f68d612c21a8d54d85edc86164bb18be1c7c";
|
|
6177
|
-
this.pythClient = new SuiPythClient(suiClient, pythStateId, wormholeStateId);
|
|
6178
|
-
} else {
|
|
6179
|
-
this.connection = new SuiPriceServiceConnection("https://hermes.pyth.network");
|
|
6180
|
-
const wormholeStateId = "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c";
|
|
6181
|
-
const pythStateId = "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8";
|
|
6182
|
-
this.pythClient = new SuiPythClient(suiClient, pythStateId, wormholeStateId);
|
|
6176
|
+
throw new Error("HaedalPmm is not supported on testnet");
|
|
6183
6177
|
}
|
|
6178
|
+
this.pythPriceIDs = pythPriceIDs;
|
|
6184
6179
|
}
|
|
6185
6180
|
swap(client, txb, path, inputCoin, packages) {
|
|
6186
6181
|
return __async(this, null, function* () {
|
|
@@ -6197,17 +6192,24 @@ var HaedalPmm = class {
|
|
|
6197
6192
|
basePriceSeed = path.extendedDetails.haedalPmmBasePriceSeed;
|
|
6198
6193
|
quotePriceSeed = path.extendedDetails.haedalPmmQuotePriceSeed;
|
|
6199
6194
|
}
|
|
6200
|
-
const
|
|
6201
|
-
const
|
|
6202
|
-
|
|
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
|
+
}
|
|
6203
6202
|
const args = [
|
|
6204
6203
|
txb.object(path.id),
|
|
6205
|
-
txb.object(
|
|
6206
|
-
txb.object(
|
|
6204
|
+
txb.object(basePriceInfoObjectId),
|
|
6205
|
+
txb.object(quotePriceInfoObjectId),
|
|
6207
6206
|
inputCoin,
|
|
6208
6207
|
txb.object(CLOCK_ADDRESS)
|
|
6209
6208
|
];
|
|
6210
|
-
const publishedAt = getAggregatorV2ExtendPublishedAt(
|
|
6209
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(
|
|
6210
|
+
client.publishedAtV2Extend(),
|
|
6211
|
+
packages
|
|
6212
|
+
);
|
|
6211
6213
|
const res = txb.moveCall({
|
|
6212
6214
|
target: `${publishedAt}::haedalpmm::${func}`,
|
|
6213
6215
|
typeArguments: [coinAType, coinBType],
|
|
@@ -6245,8 +6247,6 @@ var Alphafi = class {
|
|
|
6245
6247
|
});
|
|
6246
6248
|
}
|
|
6247
6249
|
};
|
|
6248
|
-
|
|
6249
|
-
// src/client.ts
|
|
6250
6250
|
var CETUS = "CETUS";
|
|
6251
6251
|
var DEEPBOOKV2 = "DEEPBOOK";
|
|
6252
6252
|
var KRIYA = "KRIYA";
|
|
@@ -6273,13 +6273,20 @@ function isBuilderRouterSwapParams(params) {
|
|
|
6273
6273
|
function isBuilderFastRouterSwapParams(params) {
|
|
6274
6274
|
return Array.isArray(params.routers);
|
|
6275
6275
|
}
|
|
6276
|
-
var
|
|
6276
|
+
var _AggregatorClient = class _AggregatorClient {
|
|
6277
6277
|
constructor(endpoint, signer, client, env) {
|
|
6278
6278
|
this.endpoint = endpoint ? processEndpoint(endpoint) : DEFAULT_ENDPOINT;
|
|
6279
6279
|
this.client = client || new SuiClient({ url: getFullnodeUrl("mainnet") });
|
|
6280
6280
|
this.signer = signer || "";
|
|
6281
6281
|
this.env = env || 0 /* Mainnet */;
|
|
6282
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
|
+
);
|
|
6283
6290
|
}
|
|
6284
6291
|
getCoins(coinType, refresh = true) {
|
|
6285
6292
|
return __async(this, null, function* () {
|
|
@@ -6323,7 +6330,7 @@ var AggregatorClient19 = class {
|
|
|
6323
6330
|
return getRouterResult(this.endpoint, params);
|
|
6324
6331
|
});
|
|
6325
6332
|
}
|
|
6326
|
-
expectInputSwap(txb, inputCoin, routers, amountOutLimit, partner, deepbookv3DeepFee, packages) {
|
|
6333
|
+
expectInputSwap(txb, inputCoin, routers, amountOutLimit, pythPriceIDs, partner, deepbookv3DeepFee, packages) {
|
|
6327
6334
|
return __async(this, null, function* () {
|
|
6328
6335
|
if (routers.length === 0) {
|
|
6329
6336
|
throw new Error("No router found");
|
|
@@ -6339,13 +6346,28 @@ var AggregatorClient19 = class {
|
|
|
6339
6346
|
}
|
|
6340
6347
|
let nextCoin = inputCoins[i];
|
|
6341
6348
|
for (const path of routers[i].path) {
|
|
6342
|
-
const dex = this.newDex(path.provider, partner);
|
|
6343
|
-
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
|
+
);
|
|
6344
6358
|
}
|
|
6345
6359
|
outputCoins.push(nextCoin);
|
|
6346
6360
|
}
|
|
6347
|
-
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(
|
|
6348
|
-
|
|
6361
|
+
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(
|
|
6362
|
+
this.publishedAtV2(),
|
|
6363
|
+
packages
|
|
6364
|
+
);
|
|
6365
|
+
this.transferOrDestoryCoin(
|
|
6366
|
+
txb,
|
|
6367
|
+
inputCoin,
|
|
6368
|
+
inputCoinType,
|
|
6369
|
+
this.publishedAtV2()
|
|
6370
|
+
);
|
|
6349
6371
|
const mergedTargetCointhis = this.checkCoinThresholdAndMergeCoin(
|
|
6350
6372
|
txb,
|
|
6351
6373
|
outputCoins,
|
|
@@ -6362,7 +6384,10 @@ var AggregatorClient19 = class {
|
|
|
6362
6384
|
const receipts = [];
|
|
6363
6385
|
const targetCoins = [];
|
|
6364
6386
|
const dex = new Cetus(this.env, partner);
|
|
6365
|
-
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(
|
|
6387
|
+
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(
|
|
6388
|
+
this.publishedAtV2(),
|
|
6389
|
+
packages
|
|
6390
|
+
);
|
|
6366
6391
|
for (let i = 0; i < routers.length; i++) {
|
|
6367
6392
|
const router = routers[i];
|
|
6368
6393
|
for (let j = router.path.length - 1; j >= 0; j--) {
|
|
@@ -6385,7 +6410,12 @@ var AggregatorClient19 = class {
|
|
|
6385
6410
|
if (j === 0) {
|
|
6386
6411
|
inputCoin = repayResult;
|
|
6387
6412
|
} else {
|
|
6388
|
-
this.transferOrDestoryCoin(
|
|
6413
|
+
this.transferOrDestoryCoin(
|
|
6414
|
+
txb,
|
|
6415
|
+
repayResult,
|
|
6416
|
+
path.from,
|
|
6417
|
+
aggregatorV2PublishedAt
|
|
6418
|
+
);
|
|
6389
6419
|
}
|
|
6390
6420
|
if (j === router.path.length - 1) {
|
|
6391
6421
|
targetCoins.push(nextRepayCoin);
|
|
@@ -6393,7 +6423,12 @@ var AggregatorClient19 = class {
|
|
|
6393
6423
|
}
|
|
6394
6424
|
}
|
|
6395
6425
|
const inputCoinType = routers[0].path[0].from;
|
|
6396
|
-
this.transferOrDestoryCoin(
|
|
6426
|
+
this.transferOrDestoryCoin(
|
|
6427
|
+
txb,
|
|
6428
|
+
inputCoin,
|
|
6429
|
+
inputCoinType,
|
|
6430
|
+
aggregatorV2PublishedAt
|
|
6431
|
+
);
|
|
6397
6432
|
if (targetCoins.length > 1) {
|
|
6398
6433
|
const vec = txb.makeMoveVec({ elements: targetCoins.slice(1) });
|
|
6399
6434
|
txb.moveCall({
|
|
@@ -6419,14 +6454,7 @@ var AggregatorClient19 = class {
|
|
|
6419
6454
|
}
|
|
6420
6455
|
routerSwap(params) {
|
|
6421
6456
|
return __async(this, null, function* () {
|
|
6422
|
-
const {
|
|
6423
|
-
routers,
|
|
6424
|
-
inputCoin,
|
|
6425
|
-
slippage,
|
|
6426
|
-
txb,
|
|
6427
|
-
partner,
|
|
6428
|
-
deepbookv3DeepFee
|
|
6429
|
-
} = params;
|
|
6457
|
+
const { routers, inputCoin, slippage, txb, partner, deepbookv3DeepFee } = params;
|
|
6430
6458
|
const routerData = Array.isArray(routers) ? routers : routers.routes;
|
|
6431
6459
|
const byAmountIn = isBuilderRouterSwapParams(params) ? params.byAmountIn : params.routers.byAmountIn;
|
|
6432
6460
|
const amountIn = routerData.reduce(
|
|
@@ -6444,13 +6472,19 @@ var AggregatorClient19 = class {
|
|
|
6444
6472
|
);
|
|
6445
6473
|
const packages = isBuilderRouterSwapParams(params) ? void 0 : params.routers.packages;
|
|
6446
6474
|
console.log("packages11", packages);
|
|
6447
|
-
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();
|
|
6448
6481
|
if (byAmountIn) {
|
|
6449
6482
|
const targetCoin2 = yield this.expectInputSwap(
|
|
6450
6483
|
txb,
|
|
6451
6484
|
inputCoin,
|
|
6452
6485
|
routerData,
|
|
6453
6486
|
amountLimit,
|
|
6487
|
+
priceInfoObjectIds,
|
|
6454
6488
|
partner,
|
|
6455
6489
|
deepbookv3DeepFee,
|
|
6456
6490
|
packages
|
|
@@ -6460,7 +6494,12 @@ var AggregatorClient19 = class {
|
|
|
6460
6494
|
const splitedInputCoins = txb.splitCoins(inputCoin, [
|
|
6461
6495
|
amountLimit.toString()
|
|
6462
6496
|
]);
|
|
6463
|
-
this.transferOrDestoryCoin(
|
|
6497
|
+
this.transferOrDestoryCoin(
|
|
6498
|
+
txb,
|
|
6499
|
+
inputCoin,
|
|
6500
|
+
routerData[0].path[0].from,
|
|
6501
|
+
aggregatorV2PublishedAt
|
|
6502
|
+
);
|
|
6464
6503
|
const targetCoin = yield this.expectOutputSwap(
|
|
6465
6504
|
txb,
|
|
6466
6505
|
splitedInputCoins[0],
|
|
@@ -6546,7 +6585,10 @@ var AggregatorClient19 = class {
|
|
|
6546
6585
|
targetCoinType
|
|
6547
6586
|
);
|
|
6548
6587
|
const packages = isBuilderFastRouterSwapParams(params) ? void 0 : params.routers.packages;
|
|
6549
|
-
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(
|
|
6588
|
+
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(
|
|
6589
|
+
this.publishedAtV2(),
|
|
6590
|
+
packages
|
|
6591
|
+
);
|
|
6550
6592
|
txb.mergeCoins(targetCoinRes.targetCoin, [targetCoin]);
|
|
6551
6593
|
if (targetCoinRes.isMintZeroCoin) {
|
|
6552
6594
|
this.transferOrDestoryCoin(
|
|
@@ -6607,7 +6649,7 @@ var AggregatorClient19 = class {
|
|
|
6607
6649
|
});
|
|
6608
6650
|
return targetCoin;
|
|
6609
6651
|
}
|
|
6610
|
-
newDex(provider, partner) {
|
|
6652
|
+
newDex(provider, pythPriceIDs, partner) {
|
|
6611
6653
|
switch (provider) {
|
|
6612
6654
|
case CETUS:
|
|
6613
6655
|
return new Cetus(this.env, partner);
|
|
@@ -6644,7 +6686,7 @@ var AggregatorClient19 = class {
|
|
|
6644
6686
|
case BLUEFIN:
|
|
6645
6687
|
return new Bluefin(this.env);
|
|
6646
6688
|
case HAEDALPMM:
|
|
6647
|
-
return new HaedalPmm(this.env,
|
|
6689
|
+
return new HaedalPmm(this.env, pythPriceIDs);
|
|
6648
6690
|
case ALPHAFI:
|
|
6649
6691
|
return new Alphafi(this.env);
|
|
6650
6692
|
default:
|
|
@@ -6693,7 +6735,82 @@ var AggregatorClient19 = class {
|
|
|
6693
6735
|
return null;
|
|
6694
6736
|
});
|
|
6695
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
|
+
}
|
|
6696
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
|
+
}
|
|
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
|
+
}
|
|
6697
6814
|
function parseRouterResponse(data, byAmountIn) {
|
|
6698
6815
|
let totalDeepFee = 0;
|
|
6699
6816
|
for (const route of data.routes) {
|
|
@@ -6918,7 +7035,7 @@ function getRouter(endpoint, params) {
|
|
|
6918
7035
|
url += `&providers=${providers.join(",")}`;
|
|
6919
7036
|
}
|
|
6920
7037
|
}
|
|
6921
|
-
url += "&v=
|
|
7038
|
+
url += "&v=1000322";
|
|
6922
7039
|
const response = yield fetch(url);
|
|
6923
7040
|
return response;
|
|
6924
7041
|
} catch (error) {
|
|
@@ -7008,4 +7125,4 @@ decimal.js/decimal.mjs:
|
|
|
7008
7125
|
*)
|
|
7009
7126
|
*/
|
|
7010
7127
|
|
|
7011
|
-
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
|