@cetusprotocol/aggregator-sdk 0.3.21 → 0.3.23

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/dist/index.mjs CHANGED
@@ -5801,11 +5801,10 @@ function swapInPools(client, params, sender, env) {
5801
5801
  const targetCoin = completionCoin(target);
5802
5802
  const tx = new Transaction();
5803
5803
  const direction = compareCoins(fromCoin, targetCoin);
5804
- const integratePublishedAt = env === 0 /* Mainnet */ ? "0x3a5aa90ffa33d09100d7b6941ea1c0ffe6ab66e77062ddd26320c1b073aabb10" : "0x19dd42e05fa6c9988a60d30686ee3feb776672b5547e328d6dab16563da65293";
5804
+ const integratePublishedAt = env === 0 /* Mainnet */ ? "0x2d8c2e0fc6dd25b0214b3fa747e0fd27fd54608142cd2e4f64c1cd350cc4add4" : "0x4f920e1ef6318cfba77e20a0538a419a5a504c14230169438b99aba485db40a6";
5805
5805
  const coinA = direction ? fromCoin : targetCoin;
5806
5806
  const coinB = direction ? targetCoin : fromCoin;
5807
5807
  const typeArguments = [coinA, coinB];
5808
- console.log("typeArguments", typeArguments, integratePublishedAt);
5809
5808
  for (let i = 0; i < pools.length; i++) {
5810
5809
  const args = [
5811
5810
  tx.object(pools[i]),
@@ -5825,7 +5824,6 @@ function swapInPools(client, params, sender, env) {
5825
5824
  "InvalidWallet" /* InvalidWallet */
5826
5825
  );
5827
5826
  }
5828
- printTransaction(tx);
5829
5827
  const simulateRes = yield client.devInspectTransactionBlock({
5830
5828
  transactionBlock: tx,
5831
5829
  sender
@@ -5867,7 +5865,6 @@ function swapInPools(client, params, sender, env) {
5867
5865
  }
5868
5866
  }
5869
5867
  const event = valueData[tempIndex].parsedJson.data;
5870
- console.log("event", JSON.stringify(event, null, 2));
5871
5868
  const currentSqrtPrice = event.step_results[0].current_sqrt_price;
5872
5869
  const [decimalA, decimalB] = yield Promise.all([
5873
5870
  client.getCoinMetadata({ coinType: coinA }).then((metadata) => metadata == null ? void 0 : metadata.decimals),
@@ -6168,19 +6165,14 @@ var Bluefin = class {
6168
6165
  });
6169
6166
  }
6170
6167
  };
6168
+
6169
+ // src/transaction/haedal_pmm.ts
6171
6170
  var HaedalPmm = class {
6172
- constructor(env, suiClient) {
6171
+ constructor(env, pythPriceIDs) {
6173
6172
  if (env === 1 /* Testnet */) {
6174
- this.connection = new SuiPriceServiceConnection("https://hermes-beta.pyth.network");
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);
6173
+ throw new Error("HaedalPmm is not supported on testnet");
6183
6174
  }
6175
+ this.pythPriceIDs = pythPriceIDs;
6184
6176
  }
6185
6177
  swap(client, txb, path, inputCoin, packages) {
6186
6178
  return __async(this, null, function* () {
@@ -6197,17 +6189,24 @@ var HaedalPmm = class {
6197
6189
  basePriceSeed = path.extendedDetails.haedalPmmBasePriceSeed;
6198
6190
  quotePriceSeed = path.extendedDetails.haedalPmmQuotePriceSeed;
6199
6191
  }
6200
- const priceIDs = [basePriceSeed, quotePriceSeed];
6201
- const priceUpdateData = yield this.connection.getPriceFeedsUpdateData(priceIDs);
6202
- const priceInfoObjectIds = yield this.pythClient.updatePriceFeeds(txb, priceUpdateData, priceIDs);
6192
+ const basePriceInfoObjectId = this.pythPriceIDs.get(basePriceSeed);
6193
+ const quotePriceInfoObjectId = this.pythPriceIDs.get(quotePriceSeed);
6194
+ if (!basePriceInfoObjectId || !quotePriceInfoObjectId) {
6195
+ throw new Error(
6196
+ "Base price info object id or quote price info object id not found"
6197
+ );
6198
+ }
6203
6199
  const args = [
6204
6200
  txb.object(path.id),
6205
- txb.object(priceInfoObjectIds[0]),
6206
- txb.object(priceInfoObjectIds[1]),
6201
+ txb.object(basePriceInfoObjectId),
6202
+ txb.object(quotePriceInfoObjectId),
6207
6203
  inputCoin,
6208
6204
  txb.object(CLOCK_ADDRESS)
6209
6205
  ];
6210
- const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
6206
+ const publishedAt = getAggregatorV2ExtendPublishedAt(
6207
+ client.publishedAtV2Extend(),
6208
+ packages
6209
+ );
6211
6210
  const res = txb.moveCall({
6212
6211
  target: `${publishedAt}::haedalpmm::${func}`,
6213
6212
  typeArguments: [coinAType, coinBType],
@@ -6245,8 +6244,6 @@ var Alphafi = class {
6245
6244
  });
6246
6245
  }
6247
6246
  };
6248
-
6249
- // src/client.ts
6250
6247
  var CETUS = "CETUS";
6251
6248
  var DEEPBOOKV2 = "DEEPBOOK";
6252
6249
  var KRIYA = "KRIYA";
@@ -6273,13 +6270,20 @@ function isBuilderRouterSwapParams(params) {
6273
6270
  function isBuilderFastRouterSwapParams(params) {
6274
6271
  return Array.isArray(params.routers);
6275
6272
  }
6276
- var AggregatorClient19 = class {
6273
+ var _AggregatorClient = class _AggregatorClient {
6277
6274
  constructor(endpoint, signer, client, env) {
6278
6275
  this.endpoint = endpoint ? processEndpoint(endpoint) : DEFAULT_ENDPOINT;
6279
6276
  this.client = client || new SuiClient({ url: getFullnodeUrl("mainnet") });
6280
6277
  this.signer = signer || "";
6281
6278
  this.env = env || 0 /* Mainnet */;
6282
6279
  this.allCoins = /* @__PURE__ */ new Map();
6280
+ const config2 = _AggregatorClient.CONFIG[this.env];
6281
+ this.pythConnections = config2.connections;
6282
+ this.pythClient = new SuiPythClient(
6283
+ this.client,
6284
+ config2.pythStateId,
6285
+ config2.wormholeStateId
6286
+ );
6283
6287
  }
6284
6288
  getCoins(coinType, refresh = true) {
6285
6289
  return __async(this, null, function* () {
@@ -6323,7 +6327,7 @@ var AggregatorClient19 = class {
6323
6327
  return getRouterResult(this.endpoint, params);
6324
6328
  });
6325
6329
  }
6326
- expectInputSwap(txb, inputCoin, routers, amountOutLimit, partner, deepbookv3DeepFee, packages) {
6330
+ expectInputSwap(txb, inputCoin, routers, amountOutLimit, pythPriceIDs, partner, deepbookv3DeepFee, packages) {
6327
6331
  return __async(this, null, function* () {
6328
6332
  if (routers.length === 0) {
6329
6333
  throw new Error("No router found");
@@ -6339,13 +6343,28 @@ var AggregatorClient19 = class {
6339
6343
  }
6340
6344
  let nextCoin = inputCoins[i];
6341
6345
  for (const path of routers[i].path) {
6342
- const dex = this.newDex(path.provider, partner);
6343
- nextCoin = yield dex.swap(this, txb, path, nextCoin, packages, deepbookv3DeepFee);
6346
+ const dex = this.newDex(path.provider, pythPriceIDs, partner);
6347
+ nextCoin = yield dex.swap(
6348
+ this,
6349
+ txb,
6350
+ path,
6351
+ nextCoin,
6352
+ packages,
6353
+ deepbookv3DeepFee
6354
+ );
6344
6355
  }
6345
6356
  outputCoins.push(nextCoin);
6346
6357
  }
6347
- const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(this.publishedAtV2(), packages);
6348
- this.transferOrDestoryCoin(txb, inputCoin, inputCoinType, this.publishedAtV2());
6358
+ const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(
6359
+ this.publishedAtV2(),
6360
+ packages
6361
+ );
6362
+ this.transferOrDestoryCoin(
6363
+ txb,
6364
+ inputCoin,
6365
+ inputCoinType,
6366
+ this.publishedAtV2()
6367
+ );
6349
6368
  const mergedTargetCointhis = this.checkCoinThresholdAndMergeCoin(
6350
6369
  txb,
6351
6370
  outputCoins,
@@ -6362,7 +6381,10 @@ var AggregatorClient19 = class {
6362
6381
  const receipts = [];
6363
6382
  const targetCoins = [];
6364
6383
  const dex = new Cetus(this.env, partner);
6365
- const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(this.publishedAtV2(), packages);
6384
+ const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(
6385
+ this.publishedAtV2(),
6386
+ packages
6387
+ );
6366
6388
  for (let i = 0; i < routers.length; i++) {
6367
6389
  const router = routers[i];
6368
6390
  for (let j = router.path.length - 1; j >= 0; j--) {
@@ -6385,7 +6407,12 @@ var AggregatorClient19 = class {
6385
6407
  if (j === 0) {
6386
6408
  inputCoin = repayResult;
6387
6409
  } else {
6388
- this.transferOrDestoryCoin(txb, repayResult, path.from, aggregatorV2PublishedAt);
6410
+ this.transferOrDestoryCoin(
6411
+ txb,
6412
+ repayResult,
6413
+ path.from,
6414
+ aggregatorV2PublishedAt
6415
+ );
6389
6416
  }
6390
6417
  if (j === router.path.length - 1) {
6391
6418
  targetCoins.push(nextRepayCoin);
@@ -6393,7 +6420,12 @@ var AggregatorClient19 = class {
6393
6420
  }
6394
6421
  }
6395
6422
  const inputCoinType = routers[0].path[0].from;
6396
- this.transferOrDestoryCoin(txb, inputCoin, inputCoinType, aggregatorV2PublishedAt);
6423
+ this.transferOrDestoryCoin(
6424
+ txb,
6425
+ inputCoin,
6426
+ inputCoinType,
6427
+ aggregatorV2PublishedAt
6428
+ );
6397
6429
  if (targetCoins.length > 1) {
6398
6430
  const vec = txb.makeMoveVec({ elements: targetCoins.slice(1) });
6399
6431
  txb.moveCall({
@@ -6419,14 +6451,7 @@ var AggregatorClient19 = class {
6419
6451
  }
6420
6452
  routerSwap(params) {
6421
6453
  return __async(this, null, function* () {
6422
- const {
6423
- routers,
6424
- inputCoin,
6425
- slippage,
6426
- txb,
6427
- partner,
6428
- deepbookv3DeepFee
6429
- } = params;
6454
+ const { routers, inputCoin, slippage, txb, partner, deepbookv3DeepFee } = params;
6430
6455
  const routerData = Array.isArray(routers) ? routers : routers.routes;
6431
6456
  const byAmountIn = isBuilderRouterSwapParams(params) ? params.byAmountIn : params.routers.byAmountIn;
6432
6457
  const amountIn = routerData.reduce(
@@ -6443,14 +6468,19 @@ var AggregatorClient19 = class {
6443
6468
  slippage
6444
6469
  );
6445
6470
  const packages = isBuilderRouterSwapParams(params) ? void 0 : params.routers.packages;
6446
- console.log("packages11", packages);
6447
- const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(this.publishedAtV2(), packages);
6471
+ const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(
6472
+ this.publishedAtV2(),
6473
+ packages
6474
+ );
6475
+ const priceIDs = findPythPriceIDs(routerData);
6476
+ const priceInfoObjectIds = priceIDs.length > 0 ? yield this.updatePythPriceIDs(priceIDs, txb) : /* @__PURE__ */ new Map();
6448
6477
  if (byAmountIn) {
6449
6478
  const targetCoin2 = yield this.expectInputSwap(
6450
6479
  txb,
6451
6480
  inputCoin,
6452
6481
  routerData,
6453
6482
  amountLimit,
6483
+ priceInfoObjectIds,
6454
6484
  partner,
6455
6485
  deepbookv3DeepFee,
6456
6486
  packages
@@ -6460,7 +6490,12 @@ var AggregatorClient19 = class {
6460
6490
  const splitedInputCoins = txb.splitCoins(inputCoin, [
6461
6491
  amountLimit.toString()
6462
6492
  ]);
6463
- this.transferOrDestoryCoin(txb, inputCoin, routerData[0].path[0].from, aggregatorV2PublishedAt);
6493
+ this.transferOrDestoryCoin(
6494
+ txb,
6495
+ inputCoin,
6496
+ routerData[0].path[0].from,
6497
+ aggregatorV2PublishedAt
6498
+ );
6464
6499
  const targetCoin = yield this.expectOutputSwap(
6465
6500
  txb,
6466
6501
  splitedInputCoins[0],
@@ -6546,7 +6581,10 @@ var AggregatorClient19 = class {
6546
6581
  targetCoinType
6547
6582
  );
6548
6583
  const packages = isBuilderFastRouterSwapParams(params) ? void 0 : params.routers.packages;
6549
- const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(this.publishedAtV2(), packages);
6584
+ const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(
6585
+ this.publishedAtV2(),
6586
+ packages
6587
+ );
6550
6588
  txb.mergeCoins(targetCoinRes.targetCoin, [targetCoin]);
6551
6589
  if (targetCoinRes.isMintZeroCoin) {
6552
6590
  this.transferOrDestoryCoin(
@@ -6562,7 +6600,7 @@ var AggregatorClient19 = class {
6562
6600
  // Include cetus、deepbookv2、flowxv2 & v3、kriyav2 & v3、turbos、aftermath、haedal、afsui、volo、bluemove
6563
6601
  publishedAtV2() {
6564
6602
  if (this.env === 0 /* Mainnet */) {
6565
- return "0xf9c6f78322ed667909e05f6b42b2f5a67af6297503c905335e02a15148e9440d";
6603
+ return "0x2485feb9d42c7c3bcb8ecde555ad40f1b073d9fb4faf354fa2d30a0b183a23ce";
6566
6604
  } else {
6567
6605
  return "0x52eae33adeb44de55cfb3f281d4cc9e02d976181c0952f5323648b5717b33934";
6568
6606
  }
@@ -6607,7 +6645,7 @@ var AggregatorClient19 = class {
6607
6645
  });
6608
6646
  return targetCoin;
6609
6647
  }
6610
- newDex(provider, partner) {
6648
+ newDex(provider, pythPriceIDs, partner) {
6611
6649
  switch (provider) {
6612
6650
  case CETUS:
6613
6651
  return new Cetus(this.env, partner);
@@ -6644,7 +6682,7 @@ var AggregatorClient19 = class {
6644
6682
  case BLUEFIN:
6645
6683
  return new Bluefin(this.env);
6646
6684
  case HAEDALPMM:
6647
- return new HaedalPmm(this.env, this.client);
6685
+ return new HaedalPmm(this.env, pythPriceIDs);
6648
6686
  case ALPHAFI:
6649
6687
  return new Alphafi(this.env);
6650
6688
  default:
@@ -6693,7 +6731,82 @@ var AggregatorClient19 = class {
6693
6731
  return null;
6694
6732
  });
6695
6733
  }
6734
+ updatePythPriceIDs(priceIDs, txb) {
6735
+ return __async(this, null, function* () {
6736
+ let priceUpdateData = null;
6737
+ let lastError = null;
6738
+ for (const connection of this.pythConnections) {
6739
+ try {
6740
+ priceUpdateData = yield connection.getPriceFeedsUpdateData(priceIDs);
6741
+ break;
6742
+ } catch (e) {
6743
+ lastError = e;
6744
+ console.log("Error: ", e);
6745
+ continue;
6746
+ }
6747
+ }
6748
+ if (priceUpdateData == null) {
6749
+ throw new Error(
6750
+ `No pyth price seeds update data found: ${lastError == null ? void 0 : lastError.message}`
6751
+ );
6752
+ }
6753
+ let priceInfoObjectIds = [];
6754
+ try {
6755
+ priceInfoObjectIds = yield this.pythClient.updatePriceFeeds(
6756
+ txb,
6757
+ priceUpdateData,
6758
+ priceIDs
6759
+ );
6760
+ } catch (e) {
6761
+ throw new Error(`Failed to update price feeds: ${e}`);
6762
+ }
6763
+ let priceInfoObjectIdsMap = /* @__PURE__ */ new Map();
6764
+ for (let i = 0; i < priceIDs.length; i++) {
6765
+ priceInfoObjectIdsMap.set(priceIDs[i], priceInfoObjectIds[i]);
6766
+ }
6767
+ return priceInfoObjectIdsMap;
6768
+ });
6769
+ }
6696
6770
  };
6771
+ _AggregatorClient.CONFIG = {
6772
+ [1 /* Testnet */]: {
6773
+ connections: [
6774
+ new SuiPriceServiceConnection("https://hermes-beta.pyth.network")
6775
+ ],
6776
+ wormholeStateId: "0x31358d198147da50db32eda2562951d53973a0c0ad5ed738e9b17d88b213d790",
6777
+ pythStateId: "0x243759059f4c3111179da5878c12f68d612c21a8d54d85edc86164bb18be1c7c"
6778
+ },
6779
+ [0 /* Mainnet */]: {
6780
+ connections: [
6781
+ new SuiPriceServiceConnection(
6782
+ "https://cetus.liquify.com/api=X9LTVPQD7Y3R5N2A/hermes",
6783
+ {
6784
+ timeout: 3e3
6785
+ }
6786
+ ),
6787
+ new SuiPriceServiceConnection("https://hermes.pyth.network", {
6788
+ timeout: 3e3
6789
+ })
6790
+ ],
6791
+ wormholeStateId: "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c",
6792
+ pythStateId: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8"
6793
+ }
6794
+ };
6795
+ var AggregatorClient19 = _AggregatorClient;
6796
+ function findPythPriceIDs(routes) {
6797
+ const priceIDs = /* @__PURE__ */ new Set();
6798
+ for (const route of routes) {
6799
+ for (const path of route.path) {
6800
+ if (path.provider === HAEDALPMM) {
6801
+ if (path.extendedDetails && path.extendedDetails.haedalPmmBasePriceSeed && path.extendedDetails.haedalPmmQuotePriceSeed) {
6802
+ priceIDs.add(path.extendedDetails.haedalPmmBasePriceSeed);
6803
+ priceIDs.add(path.extendedDetails.haedalPmmQuotePriceSeed);
6804
+ }
6805
+ }
6806
+ }
6807
+ }
6808
+ return Array.from(priceIDs);
6809
+ }
6697
6810
  function parseRouterResponse(data, byAmountIn) {
6698
6811
  let totalDeepFee = 0;
6699
6812
  for (const route of data.routes) {
@@ -6918,7 +7031,7 @@ function getRouter(endpoint, params) {
6918
7031
  url += `&providers=${providers.join(",")}`;
6919
7032
  }
6920
7033
  }
6921
- url += "&v=1000321";
7034
+ url += "&v=1000323";
6922
7035
  const response = yield fetch(url);
6923
7036
  return response;
6924
7037
  } catch (error) {
@@ -7008,4 +7121,4 @@ decimal.js/decimal.mjs:
7008
7121
  *)
7009
7122
  */
7010
7123
 
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 };
7124
+ 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 };
@@ -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 connection;
6
- private pythClient;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cetusprotocol/aggregator-sdk",
3
- "version": "0.3.21",
3
+ "version": "0.3.23",
4
4
  "sideEffects": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
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('HoneyPot scam')>-1){
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=1000321"
193
+ url += "&v=1000323"
194
194
 
195
195
  const response = await fetch(url)
196
196
  return response