@cetusprotocol/aggregator-sdk 1.4.6 → 1.4.8

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 CHANGED
@@ -5,7 +5,7 @@
5
5
  "": {
6
6
  "name": "@cetusprotocol/aggregator-sdk",
7
7
  "dependencies": {
8
- "@mysten/sui": "^2.6.0",
8
+ "@mysten/sui": "^2.13.2",
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.2", "", { "dependencies": { "@mysten/utils": "^0.3.1", "@scure/base": "^2.0.0" } }, "sha512-c/nVRPJEV1fRZdKXhysVsy/yCPdiFt7jn6A4/7W2LH1ZPSVPzRkxtLY362D0zaLuBnyT5Y9d9nFLm3ixI8Goug=="],
113
+ "@mysten/bcs": ["@mysten/bcs@2.0.3", "", { "dependencies": { "@mysten/utils": "^0.3.1", "@scure/base": "^2.0.0" } }, "sha512-dwcaL4HNAsEGpU3hKUAsXgCZp9l6++e2A3THpzoYZ8e7bsy4XH1V0dXD5dIzgNcVZiZfb6ZnDMG+gdF6+1WOQA=="],
114
114
 
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=="],
115
+ "@mysten/sui": ["@mysten/sui@2.13.2", "", { "dependencies": { "@graphql-typed-document-node/core": "^3.2.0", "@mysten/bcs": "^2.0.3", "@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-M/H2CZJQyLyi0vvCJZ6rRzItJCsnh66v1OTI2VoBad2lau/BTuUKOEPjRpfU4YlVJcGR4h+RLCjDXV4ACuRKSA=="],
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 jsonRpc = require('@mysten/sui/jsonRpc');
6
+ var grpc = require('@mysten/sui/grpc');
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 = 1010405;
3419
+ var SDK_VERSION = 1010408;
3420
3420
  function parseRouterResponse(data, byAmountIn) {
3421
3421
  let packages = /* @__PURE__ */ new Map();
3422
3422
  if (data.packages) {
@@ -7857,12 +7857,11 @@ var PythAdapter = class {
7857
7857
  if (this.baseUpdateFee !== void 0) {
7858
7858
  return this.baseUpdateFee;
7859
7859
  }
7860
- const res = await this.client.getObject({
7861
- id: this.pythStateId,
7862
- options: { showContent: true }
7860
+ const { object } = await this.client.getObject({
7861
+ objectId: this.pythStateId,
7862
+ include: { json: true }
7863
7863
  });
7864
- const content = res.data?.content;
7865
- const json = content && "fields" in content ? content.fields : null;
7864
+ const json = object.json;
7866
7865
  if (!json) {
7867
7866
  throw new Error("Unable to fetch pyth state object");
7868
7867
  }
@@ -7870,21 +7869,16 @@ var PythAdapter = class {
7870
7869
  return this.baseUpdateFee;
7871
7870
  }
7872
7871
  async getPackageId(objectId) {
7873
- const res = await this.client.getObject({
7874
- id: objectId,
7875
- options: { showContent: true }
7872
+ const { object } = await this.client.getObject({
7873
+ objectId,
7874
+ include: { json: true }
7876
7875
  });
7877
- const content = res.data?.content;
7878
- const json = content && "fields" in content ? content.fields : null;
7876
+ const json = object.json;
7879
7877
  if (!json) {
7880
7878
  throw new Error(`Cannot fetch package id for object ${objectId}`);
7881
7879
  }
7882
7880
  if ("upgrade_cap" in json) {
7883
- const upgradeCap = json.upgrade_cap;
7884
- const packageId = upgradeCap?.fields?.package;
7885
- if (typeof packageId === "string") {
7886
- return packageId;
7887
- }
7881
+ return json.upgrade_cap.package;
7888
7882
  }
7889
7883
  throw new Error("upgrade_cap not found");
7890
7884
  }
@@ -7908,19 +7902,20 @@ var PythAdapter = class {
7908
7902
  const { id: tableId, fieldType } = await this.getPriceTableInfo();
7909
7903
  const feedIdBytes = Buffer.from(normalizedFeedId, "hex");
7910
7904
  try {
7911
- const result = await this.client.getDynamicFieldObject({
7905
+ const PriceIdentifier = bcs.bcs.struct("PriceIdentifier", {
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({
7912
7910
  parentId: tableId,
7913
7911
  name: {
7914
- type: `${fieldType}::price_identifier::PriceIdentifier`,
7915
- value: { bytes: Array.from(feedIdBytes) }
7912
+ type: fieldType,
7913
+ bcs: bcsBytes
7916
7914
  }
7917
7915
  });
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
- }
7916
+ const valueBcs = result.dynamicField.value.bcs;
7917
+ const valueBytes = valueBcs instanceof Uint8Array ? valueBcs : new Uint8Array(Object.values(valueBcs));
7918
+ const objectId = "0x" + Array.from(valueBytes).map((b) => b.toString(16).padStart(2, "0")).join("");
7924
7919
  this.priceFeedObjectIdCache.set(normalizedFeedId, objectId);
7925
7920
  return objectId;
7926
7921
  } catch {
@@ -7931,22 +7926,35 @@ var PythAdapter = class {
7931
7926
  if (this.priceTableInfo !== void 0) {
7932
7927
  return this.priceTableInfo;
7933
7928
  }
7934
- const result = await this.client.getDynamicFieldObject({
7935
- parentId: this.pythStateId,
7936
- name: {
7937
- type: "vector<u8>",
7938
- value: "price_info"
7929
+ let cursor = null;
7930
+ let hasNextPage = true;
7931
+ while (hasNextPage) {
7932
+ const dynamicFields = await this.client.listDynamicFields({
7933
+ parentId: this.pythStateId,
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
+ }
7939
7951
  }
7940
- });
7941
- if (!result.data?.type) {
7942
- throw new Error(
7943
- "Price Table not found, contract may not be initialized"
7944
- );
7952
+ hasNextPage = dynamicFields.hasNextPage;
7953
+ cursor = dynamicFields.cursor;
7945
7954
  }
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;
7955
+ throw new Error(
7956
+ "Price Table not found, contract may not be initialized"
7957
+ );
7950
7958
  }
7951
7959
  extractVaaBytesFromAccumulatorMessage(accumulatorMessage) {
7952
7960
  const trailingPayloadSize = accumulatorMessage.readUint8(6);
@@ -8130,21 +8138,21 @@ async function getOrCreateAccountCap(txb, client, owner) {
8130
8138
  }
8131
8139
  async function getAccountCap(client, owner) {
8132
8140
  const limit = 50;
8133
- let cursor = void 0;
8141
+ let cursor = null;
8134
8142
  while (true) {
8135
- const ownedObjects = await client.getOwnedObjects({
8143
+ const ownedObjects = await client.listOwnedObjects({
8136
8144
  owner,
8137
8145
  cursor,
8138
8146
  limit,
8139
- filter: { StructType: `${DEEPBOOK_PACKAGE_ID}::${DEEPBOOK_CUSTODIAN_V2_MODULE}::AccountCap` }
8147
+ type: `${DEEPBOOK_PACKAGE_ID}::${DEEPBOOK_CUSTODIAN_V2_MODULE}::AccountCap`
8140
8148
  });
8141
- if (ownedObjects.data.length !== 0) {
8142
- return ownedObjects.data[0].data?.objectId ?? null;
8149
+ if (ownedObjects.objects.length !== 0) {
8150
+ return ownedObjects.objects[0].objectId;
8143
8151
  }
8144
8152
  if (!ownedObjects.hasNextPage) {
8145
8153
  break;
8146
8154
  }
8147
- cursor = ownedObjects.nextCursor ?? void 0;
8155
+ cursor = ownedObjects.cursor;
8148
8156
  }
8149
8157
  return null;
8150
8158
  }
@@ -8172,10 +8180,10 @@ function getAggregatorV2Extend2PublishedAt(publishedAt, packages) {
8172
8180
  // src/utils/gas.ts
8173
8181
  var import_bn4 = __toESM(require_bn());
8174
8182
  function extractGasMetrics(result) {
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";
8183
+ const txResult = result.Transaction ?? result.FailedTransaction;
8184
+ const effects = txResult?.effects;
8185
+ if (!effects || !effects.status.success) {
8186
+ const errorMsg = effects?.status.success === false ? effects.status.error.message : "Unknown error";
8179
8187
  return {
8180
8188
  computationCost: "0",
8181
8189
  storageCost: "0",
@@ -8774,8 +8782,8 @@ var _AggregatorClient = class _AggregatorClient {
8774
8782
  constructor(params) {
8775
8783
  this.endpoint = params.endpoint ? processEndpoint(params.endpoint) : DEFAULT_ENDPOINT;
8776
8784
  const network = params.env === 1 /* Testnet */ ? "testnet" : "mainnet";
8777
- const rpcUrl = params.env === 1 /* Testnet */ ? "https://fullnode.testnet.sui.io:443" : "https://fullnode.mainnet.sui.io:443";
8778
- this.client = params.client ?? new jsonRpc.SuiJsonRpcClient({ network, url: rpcUrl });
8785
+ const grpcUrl = params.env === 1 /* Testnet */ ? "https://fullnode.testnet.sui.io:443" : "https://fullnode.mainnet.sui.io:443";
8786
+ this.client = params.client ?? new grpc.SuiGrpcClient({ network, baseUrl: grpcUrl });
8779
8787
  this.signer = params.signer || "";
8780
8788
  this.env = params.env || 0 /* Mainnet */;
8781
8789
  const config2 = _AggregatorClient.CONFIG[this.env];
@@ -8816,13 +8824,13 @@ var _AggregatorClient = class _AggregatorClient {
8816
8824
  }
8817
8825
  async getOneCoinUsedToMerge(coinType) {
8818
8826
  try {
8819
- const gotCoin = await this.client.getCoins({
8827
+ const gotCoin = await this.client.listCoins({
8820
8828
  owner: this.signer,
8821
8829
  coinType,
8822
8830
  limit: 1
8823
8831
  });
8824
- if (gotCoin.data.length === 1) {
8825
- return gotCoin.data[0].coinObjectId;
8832
+ if (gotCoin.objects.length === 1) {
8833
+ return gotCoin.objects[0].objectId;
8826
8834
  }
8827
8835
  return null;
8828
8836
  } catch (error) {
@@ -9234,7 +9242,7 @@ var _AggregatorClient = class _AggregatorClient {
9234
9242
  return outputCoin;
9235
9243
  }
9236
9244
  async routerSwap(params) {
9237
- const { router, inputCoin, slippage, txb, partner } = params;
9245
+ const { router, inputCoin, slippage, txb, partner, cetusDlmmPartner } = params;
9238
9246
  if (slippage > 1 || slippage < 0) {
9239
9247
  throw new Error(CLIENT_CONFIG.ERRORS.INVALID_SLIPPAGE);
9240
9248
  }
@@ -9268,7 +9276,8 @@ var _AggregatorClient = class _AggregatorClient {
9268
9276
  amountOut.toString(),
9269
9277
  amountLimit.toString(),
9270
9278
  priceInfoObjectIds,
9271
- partner ?? this.partner
9279
+ partner ?? this.partner,
9280
+ cetusDlmmPartner ?? this.cetusDlmmPartner
9272
9281
  );
9273
9282
  } else {
9274
9283
  return this.expectOutputSwapV3(
@@ -9343,7 +9352,7 @@ var _AggregatorClient = class _AggregatorClient {
9343
9352
  // auto build input coin
9344
9353
  // auto merge, transfer or destory target coin.
9345
9354
  async fastRouterSwap(params) {
9346
- const { router, slippage, txb, partner, payDeepFeeAmount } = params;
9355
+ const { router, slippage, txb, partner, cetusDlmmPartner, payDeepFeeAmount } = params;
9347
9356
  const fromCoinType = router.paths[0].from;
9348
9357
  const targetCoinType = router.paths[router.paths.length - 1].target;
9349
9358
  const byAmountIn = router.byAmountIn;
@@ -9384,6 +9393,7 @@ var _AggregatorClient = class _AggregatorClient {
9384
9393
  slippage,
9385
9394
  txb,
9386
9395
  partner: partner ?? this.partner,
9396
+ cetusDlmmPartner: cetusDlmmPartner ?? this.cetusDlmmPartner,
9387
9397
  deepbookv3DeepFee: deepCoin
9388
9398
  };
9389
9399
  const targetCoin = await this.routerSwap(routerSwapParams);
@@ -9565,16 +9575,18 @@ var _AggregatorClient = class _AggregatorClient {
9565
9575
  });
9566
9576
  }
9567
9577
  tx.setSenderIfNotSet(this.signer || "0x0");
9568
- const simulateRes = await this.client.devInspectTransactionBlock({
9569
- sender: this.signer || "0x0",
9570
- transactionBlock: tx
9578
+ const simulateRes = await this.client.simulateTransaction({
9579
+ transaction: tx,
9580
+ include: { events: true, effects: true }
9571
9581
  });
9572
- if (simulateRes.error) {
9573
- throw new Error("Simulation error: " + simulateRes.error);
9582
+ const txResult = simulateRes.Transaction ?? simulateRes.FailedTransaction;
9583
+ if (!txResult || simulateRes.$kind === "FailedTransaction") {
9584
+ const errorMsg = txResult?.status.success === false ? txResult.status.error.message : "Unknown error";
9585
+ throw new Error("Simulation error: " + errorMsg);
9574
9586
  }
9575
- const events = simulateRes.events ?? [];
9587
+ const events = txResult.events ?? [];
9576
9588
  const valueData = events.filter((item) => {
9577
- return item.type.includes("CalculatedSwapResultEvent");
9589
+ return item.eventType.includes("CalculatedSwapResultEvent");
9578
9590
  });
9579
9591
  if (valueData.length === 0 || valueData.length !== pools.length) {
9580
9592
  throw new Error("Simulate event result error");
@@ -9582,7 +9594,7 @@ var _AggregatorClient = class _AggregatorClient {
9582
9594
  let tempMaxAmount = byAmountIn ? new import_bn6.default(0) : new import_bn6.default(U64_MAX);
9583
9595
  let tempIndex = 0;
9584
9596
  for (let i = 0; i < valueData.length; i += 1) {
9585
- const eventJson2 = valueData[i].parsedJson;
9597
+ const eventJson2 = valueData[i].json;
9586
9598
  if (eventJson2?.data?.is_exceed) {
9587
9599
  continue;
9588
9600
  }
@@ -9600,11 +9612,11 @@ var _AggregatorClient = class _AggregatorClient {
9600
9612
  }
9601
9613
  }
9602
9614
  }
9603
- const eventJson = valueData[tempIndex].parsedJson;
9615
+ const eventJson = valueData[tempIndex].json;
9604
9616
  const eventData = eventJson?.data;
9605
9617
  const [decimalA, decimalB] = await Promise.all([
9606
- this.client.getCoinMetadata({ coinType: coinA }).then((res) => res?.decimals ?? null),
9607
- this.client.getCoinMetadata({ coinType: coinB }).then((res) => res?.decimals ?? null)
9618
+ this.client.getCoinMetadata({ coinType: coinA }).then((res) => res.coinMetadata?.decimals ?? null),
9619
+ this.client.getCoinMetadata({ coinType: coinB }).then((res) => res.coinMetadata?.decimals ?? null)
9608
9620
  ]);
9609
9621
  if (decimalA == null || decimalB == null) {
9610
9622
  throw new Error("Cannot get coin decimals");
@@ -9673,9 +9685,9 @@ var _AggregatorClient = class _AggregatorClient {
9673
9685
  }
9674
9686
  async devInspectTransactionBlock(txb) {
9675
9687
  txb.setSenderIfNotSet(this.signer || "0x0");
9676
- const res = await this.client.devInspectTransactionBlock({
9677
- sender: this.signer || "0x0",
9678
- transactionBlock: txb
9688
+ const res = await this.client.simulateTransaction({
9689
+ transaction: txb,
9690
+ include: { events: true, effects: true }
9679
9691
  });
9680
9692
  return res;
9681
9693
  }
@@ -9683,7 +9695,7 @@ var _AggregatorClient = class _AggregatorClient {
9683
9695
  const res = await this.client.signAndExecuteTransaction({
9684
9696
  transaction: txb,
9685
9697
  signer,
9686
- options: { showEffects: true, showEvents: true, showBalanceChanges: true }
9698
+ include: { effects: true, events: true, balanceChanges: true }
9687
9699
  });
9688
9700
  return res;
9689
9701
  }
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
- import * as _mysten_sui_jsonRpc from '@mysten/sui/jsonRpc';
2
- import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
1
+ import * as _mysten_sui_client from '@mysten/sui/client';
3
2
  import { TransactionObjectArgument, Transaction, TransactionArgument } from '@mysten/sui/transactions';
4
3
  import BN from 'bn.js';
5
4
  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 {
@@ -305,7 +305,7 @@ declare class PythAdapter {
305
305
  private priceTableInfo;
306
306
  private priceFeedObjectIdCache;
307
307
  private baseUpdateFee;
308
- constructor(client: SuiJsonRpcClient, pythStateId: ObjectId, wormholeStateId: ObjectId, hermesUrls: string[]);
308
+ constructor(client: SuiGrpcClient, pythStateId: ObjectId, wormholeStateId: ObjectId, hermesUrls: string[]);
309
309
  getPriceFeedsUpdateData(priceIDs: string[]): Promise<Buffer[]>;
310
310
  getBaseUpdateFee(): Promise<number>;
311
311
  getPackageId(objectId: ObjectId): Promise<string>;
@@ -361,6 +361,7 @@ type BuildRouterSwapParamsV3 = {
361
361
  slippage: number;
362
362
  txb: Transaction;
363
363
  partner?: string;
364
+ cetusDlmmPartner?: string;
364
365
  deepbookv3DeepFee?: TransactionObjectArgument;
365
366
  fixable?: boolean;
366
367
  };
@@ -369,6 +370,7 @@ type BuildFastRouterSwapParamsV3 = {
369
370
  slippage: number;
370
371
  txb: Transaction;
371
372
  partner?: string;
373
+ cetusDlmmPartner?: string;
372
374
  refreshAllCoins?: boolean;
373
375
  payDeepFeeAmount?: number;
374
376
  };
@@ -399,7 +401,7 @@ declare function getProvidersIncluding(includeProviders: string[]): string[];
399
401
  type AggregatorClientParams = {
400
402
  endpoint?: string;
401
403
  signer?: string;
402
- client?: SuiJsonRpcClient;
404
+ client?: SuiGrpcClient;
403
405
  env?: Env;
404
406
  pythUrls?: string[];
405
407
  apiKey?: string;
@@ -411,7 +413,7 @@ type AggregatorClientParams = {
411
413
  declare class AggregatorClient {
412
414
  endpoint: string;
413
415
  signer: string;
414
- client: SuiJsonRpcClient;
416
+ client: SuiGrpcClient;
415
417
  env: Env;
416
418
  apiKey: string;
417
419
  protected pythAdapter: PythAdapter;
@@ -453,8 +455,15 @@ declare class AggregatorClient {
453
455
  fixableRouterSwapV3(params: BuildRouterSwapParamsV3): Promise<TransactionObjectArgument>;
454
456
  swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResultV3>;
455
457
  updatePythPriceIDs(priceIDs: string[], txb: Transaction): Promise<Map<string, string>>;
456
- devInspectTransactionBlock(txb: Transaction): Promise<_mysten_sui_jsonRpc.DevInspectResults>;
457
- sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_jsonRpc.SuiTransactionBlockResponse>;
458
+ devInspectTransactionBlock(txb: Transaction): Promise<_mysten_sui_client.SuiClientTypes.SimulateTransactionResult<{
459
+ events: true;
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
+ }>>;
458
467
  }
459
468
 
460
469
  /**
@@ -487,7 +496,7 @@ type GetOrCreateAccountCapResult = {
487
496
  accountCap: TransactionObjectArgument;
488
497
  isCreate: boolean;
489
498
  };
490
- declare function getOrCreateAccountCap(txb: Transaction, client: SuiJsonRpcClient, owner: string): Promise<GetOrCreateAccountCapResult>;
499
+ declare function getOrCreateAccountCap(txb: Transaction, client: SuiGrpcClient, owner: string): Promise<GetOrCreateAccountCapResult>;
491
500
 
492
501
  /**
493
502
  * Represents a SUI address, which is a string.
@@ -637,23 +646,67 @@ interface Dex {
637
646
  }
638
647
 
639
648
  /**
640
- * Matches the shape of DevInspectResults from JSON-RPC.
649
+ * Matches the shape of SuiClientTypes.SimulateTransactionResult with effects included.
641
650
  * Using a local type so gas.ts can be used without importing the full SDK.
642
651
  */
643
652
  type SimulateTransactionResult = {
644
- effects: {
653
+ $kind: 'Transaction' | 'FailedTransaction';
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?: {
645
683
  status: {
646
- status: 'success' | 'failure';
647
- error?: string;
684
+ success: true;
685
+ error: null;
686
+ } | {
687
+ success: false;
688
+ error: {
689
+ message: string;
690
+ };
648
691
  };
649
- gasUsed: {
650
- computationCost: string;
651
- storageCost: string;
652
- storageRebate: string;
653
- nonRefundableStorageFee: string;
692
+ effects?: {
693
+ status: {
694
+ success: true;
695
+ error: null;
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
+ };
654
708
  };
655
709
  };
656
- error?: string | null;
657
710
  };
658
711
  interface GasMetrics {
659
712
  computationCost: string;
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import * as _mysten_sui_jsonRpc from '@mysten/sui/jsonRpc';
2
- import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
1
+ import * as _mysten_sui_client from '@mysten/sui/client';
3
2
  import { TransactionObjectArgument, Transaction, TransactionArgument } from '@mysten/sui/transactions';
4
3
  import BN from 'bn.js';
5
4
  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 {
@@ -305,7 +305,7 @@ declare class PythAdapter {
305
305
  private priceTableInfo;
306
306
  private priceFeedObjectIdCache;
307
307
  private baseUpdateFee;
308
- constructor(client: SuiJsonRpcClient, pythStateId: ObjectId, wormholeStateId: ObjectId, hermesUrls: string[]);
308
+ constructor(client: SuiGrpcClient, pythStateId: ObjectId, wormholeStateId: ObjectId, hermesUrls: string[]);
309
309
  getPriceFeedsUpdateData(priceIDs: string[]): Promise<Buffer[]>;
310
310
  getBaseUpdateFee(): Promise<number>;
311
311
  getPackageId(objectId: ObjectId): Promise<string>;
@@ -361,6 +361,7 @@ type BuildRouterSwapParamsV3 = {
361
361
  slippage: number;
362
362
  txb: Transaction;
363
363
  partner?: string;
364
+ cetusDlmmPartner?: string;
364
365
  deepbookv3DeepFee?: TransactionObjectArgument;
365
366
  fixable?: boolean;
366
367
  };
@@ -369,6 +370,7 @@ type BuildFastRouterSwapParamsV3 = {
369
370
  slippage: number;
370
371
  txb: Transaction;
371
372
  partner?: string;
373
+ cetusDlmmPartner?: string;
372
374
  refreshAllCoins?: boolean;
373
375
  payDeepFeeAmount?: number;
374
376
  };
@@ -399,7 +401,7 @@ declare function getProvidersIncluding(includeProviders: string[]): string[];
399
401
  type AggregatorClientParams = {
400
402
  endpoint?: string;
401
403
  signer?: string;
402
- client?: SuiJsonRpcClient;
404
+ client?: SuiGrpcClient;
403
405
  env?: Env;
404
406
  pythUrls?: string[];
405
407
  apiKey?: string;
@@ -411,7 +413,7 @@ type AggregatorClientParams = {
411
413
  declare class AggregatorClient {
412
414
  endpoint: string;
413
415
  signer: string;
414
- client: SuiJsonRpcClient;
416
+ client: SuiGrpcClient;
415
417
  env: Env;
416
418
  apiKey: string;
417
419
  protected pythAdapter: PythAdapter;
@@ -453,8 +455,15 @@ declare class AggregatorClient {
453
455
  fixableRouterSwapV3(params: BuildRouterSwapParamsV3): Promise<TransactionObjectArgument>;
454
456
  swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResultV3>;
455
457
  updatePythPriceIDs(priceIDs: string[], txb: Transaction): Promise<Map<string, string>>;
456
- devInspectTransactionBlock(txb: Transaction): Promise<_mysten_sui_jsonRpc.DevInspectResults>;
457
- sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_jsonRpc.SuiTransactionBlockResponse>;
458
+ devInspectTransactionBlock(txb: Transaction): Promise<_mysten_sui_client.SuiClientTypes.SimulateTransactionResult<{
459
+ events: true;
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
+ }>>;
458
467
  }
459
468
 
460
469
  /**
@@ -487,7 +496,7 @@ type GetOrCreateAccountCapResult = {
487
496
  accountCap: TransactionObjectArgument;
488
497
  isCreate: boolean;
489
498
  };
490
- declare function getOrCreateAccountCap(txb: Transaction, client: SuiJsonRpcClient, owner: string): Promise<GetOrCreateAccountCapResult>;
499
+ declare function getOrCreateAccountCap(txb: Transaction, client: SuiGrpcClient, owner: string): Promise<GetOrCreateAccountCapResult>;
491
500
 
492
501
  /**
493
502
  * Represents a SUI address, which is a string.
@@ -637,23 +646,67 @@ interface Dex {
637
646
  }
638
647
 
639
648
  /**
640
- * Matches the shape of DevInspectResults from JSON-RPC.
649
+ * Matches the shape of SuiClientTypes.SimulateTransactionResult with effects included.
641
650
  * Using a local type so gas.ts can be used without importing the full SDK.
642
651
  */
643
652
  type SimulateTransactionResult = {
644
- effects: {
653
+ $kind: 'Transaction' | 'FailedTransaction';
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?: {
645
683
  status: {
646
- status: 'success' | 'failure';
647
- error?: string;
684
+ success: true;
685
+ error: null;
686
+ } | {
687
+ success: false;
688
+ error: {
689
+ message: string;
690
+ };
648
691
  };
649
- gasUsed: {
650
- computationCost: string;
651
- storageCost: string;
652
- storageRebate: string;
653
- nonRefundableStorageFee: string;
692
+ effects?: {
693
+ status: {
694
+ success: true;
695
+ error: null;
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
+ };
654
708
  };
655
709
  };
656
- error?: string | null;
657
710
  };
658
711
  interface GasMetrics {
659
712
  computationCost: string;
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 { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
4
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
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 = 1010405;
3413
+ var SDK_VERSION = 1010408;
3414
3414
  function parseRouterResponse(data, byAmountIn) {
3415
3415
  let packages = /* @__PURE__ */ new Map();
3416
3416
  if (data.packages) {
@@ -7851,12 +7851,11 @@ var PythAdapter = class {
7851
7851
  if (this.baseUpdateFee !== void 0) {
7852
7852
  return this.baseUpdateFee;
7853
7853
  }
7854
- const res = await this.client.getObject({
7855
- id: this.pythStateId,
7856
- options: { showContent: true }
7854
+ const { object } = await this.client.getObject({
7855
+ objectId: this.pythStateId,
7856
+ include: { json: true }
7857
7857
  });
7858
- const content = res.data?.content;
7859
- const json = content && "fields" in content ? content.fields : null;
7858
+ const json = object.json;
7860
7859
  if (!json) {
7861
7860
  throw new Error("Unable to fetch pyth state object");
7862
7861
  }
@@ -7864,21 +7863,16 @@ var PythAdapter = class {
7864
7863
  return this.baseUpdateFee;
7865
7864
  }
7866
7865
  async getPackageId(objectId) {
7867
- const res = await this.client.getObject({
7868
- id: objectId,
7869
- options: { showContent: true }
7866
+ const { object } = await this.client.getObject({
7867
+ objectId,
7868
+ include: { json: true }
7870
7869
  });
7871
- const content = res.data?.content;
7872
- const json = content && "fields" in content ? content.fields : null;
7870
+ const json = object.json;
7873
7871
  if (!json) {
7874
7872
  throw new Error(`Cannot fetch package id for object ${objectId}`);
7875
7873
  }
7876
7874
  if ("upgrade_cap" in json) {
7877
- const upgradeCap = json.upgrade_cap;
7878
- const packageId = upgradeCap?.fields?.package;
7879
- if (typeof packageId === "string") {
7880
- return packageId;
7881
- }
7875
+ return json.upgrade_cap.package;
7882
7876
  }
7883
7877
  throw new Error("upgrade_cap not found");
7884
7878
  }
@@ -7902,19 +7896,20 @@ var PythAdapter = class {
7902
7896
  const { id: tableId, fieldType } = await this.getPriceTableInfo();
7903
7897
  const feedIdBytes = Buffer.from(normalizedFeedId, "hex");
7904
7898
  try {
7905
- const result = await this.client.getDynamicFieldObject({
7899
+ const PriceIdentifier = bcs.struct("PriceIdentifier", {
7900
+ bytes: bcs.vector(bcs.u8())
7901
+ });
7902
+ const bcsBytes = PriceIdentifier.serialize({ bytes: Array.from(feedIdBytes) }).toBytes();
7903
+ const result = await this.client.getDynamicField({
7906
7904
  parentId: tableId,
7907
7905
  name: {
7908
- type: `${fieldType}::price_identifier::PriceIdentifier`,
7909
- value: { bytes: Array.from(feedIdBytes) }
7906
+ type: fieldType,
7907
+ bcs: bcsBytes
7910
7908
  }
7911
7909
  });
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
- }
7910
+ const valueBcs = result.dynamicField.value.bcs;
7911
+ const valueBytes = valueBcs instanceof Uint8Array ? valueBcs : new Uint8Array(Object.values(valueBcs));
7912
+ const objectId = "0x" + Array.from(valueBytes).map((b) => b.toString(16).padStart(2, "0")).join("");
7918
7913
  this.priceFeedObjectIdCache.set(normalizedFeedId, objectId);
7919
7914
  return objectId;
7920
7915
  } catch {
@@ -7925,22 +7920,35 @@ var PythAdapter = class {
7925
7920
  if (this.priceTableInfo !== void 0) {
7926
7921
  return this.priceTableInfo;
7927
7922
  }
7928
- const result = await this.client.getDynamicFieldObject({
7929
- parentId: this.pythStateId,
7930
- name: {
7931
- type: "vector<u8>",
7932
- value: "price_info"
7923
+ let cursor = null;
7924
+ let hasNextPage = true;
7925
+ while (hasNextPage) {
7926
+ const dynamicFields = await this.client.listDynamicFields({
7927
+ parentId: this.pythStateId,
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
+ }
7933
7945
  }
7934
- });
7935
- if (!result.data?.type) {
7936
- throw new Error(
7937
- "Price Table not found, contract may not be initialized"
7938
- );
7946
+ hasNextPage = dynamicFields.hasNextPage;
7947
+ cursor = dynamicFields.cursor;
7939
7948
  }
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;
7949
+ throw new Error(
7950
+ "Price Table not found, contract may not be initialized"
7951
+ );
7944
7952
  }
7945
7953
  extractVaaBytesFromAccumulatorMessage(accumulatorMessage) {
7946
7954
  const trailingPayloadSize = accumulatorMessage.readUint8(6);
@@ -8124,21 +8132,21 @@ async function getOrCreateAccountCap(txb, client, owner) {
8124
8132
  }
8125
8133
  async function getAccountCap(client, owner) {
8126
8134
  const limit = 50;
8127
- let cursor = void 0;
8135
+ let cursor = null;
8128
8136
  while (true) {
8129
- const ownedObjects = await client.getOwnedObjects({
8137
+ const ownedObjects = await client.listOwnedObjects({
8130
8138
  owner,
8131
8139
  cursor,
8132
8140
  limit,
8133
- filter: { StructType: `${DEEPBOOK_PACKAGE_ID}::${DEEPBOOK_CUSTODIAN_V2_MODULE}::AccountCap` }
8141
+ type: `${DEEPBOOK_PACKAGE_ID}::${DEEPBOOK_CUSTODIAN_V2_MODULE}::AccountCap`
8134
8142
  });
8135
- if (ownedObjects.data.length !== 0) {
8136
- return ownedObjects.data[0].data?.objectId ?? null;
8143
+ if (ownedObjects.objects.length !== 0) {
8144
+ return ownedObjects.objects[0].objectId;
8137
8145
  }
8138
8146
  if (!ownedObjects.hasNextPage) {
8139
8147
  break;
8140
8148
  }
8141
- cursor = ownedObjects.nextCursor ?? void 0;
8149
+ cursor = ownedObjects.cursor;
8142
8150
  }
8143
8151
  return null;
8144
8152
  }
@@ -8166,10 +8174,10 @@ function getAggregatorV2Extend2PublishedAt(publishedAt, packages) {
8166
8174
  // src/utils/gas.ts
8167
8175
  var import_bn4 = __toESM(require_bn());
8168
8176
  function extractGasMetrics(result) {
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";
8177
+ const txResult = result.Transaction ?? result.FailedTransaction;
8178
+ const effects = txResult?.effects;
8179
+ if (!effects || !effects.status.success) {
8180
+ const errorMsg = effects?.status.success === false ? effects.status.error.message : "Unknown error";
8173
8181
  return {
8174
8182
  computationCost: "0",
8175
8183
  storageCost: "0",
@@ -8768,8 +8776,8 @@ var _AggregatorClient = class _AggregatorClient {
8768
8776
  constructor(params) {
8769
8777
  this.endpoint = params.endpoint ? processEndpoint(params.endpoint) : DEFAULT_ENDPOINT;
8770
8778
  const network = params.env === 1 /* Testnet */ ? "testnet" : "mainnet";
8771
- const rpcUrl = params.env === 1 /* Testnet */ ? "https://fullnode.testnet.sui.io:443" : "https://fullnode.mainnet.sui.io:443";
8772
- this.client = params.client ?? new SuiJsonRpcClient({ network, url: rpcUrl });
8779
+ const grpcUrl = params.env === 1 /* Testnet */ ? "https://fullnode.testnet.sui.io:443" : "https://fullnode.mainnet.sui.io:443";
8780
+ this.client = params.client ?? new SuiGrpcClient({ network, baseUrl: grpcUrl });
8773
8781
  this.signer = params.signer || "";
8774
8782
  this.env = params.env || 0 /* Mainnet */;
8775
8783
  const config2 = _AggregatorClient.CONFIG[this.env];
@@ -8810,13 +8818,13 @@ var _AggregatorClient = class _AggregatorClient {
8810
8818
  }
8811
8819
  async getOneCoinUsedToMerge(coinType) {
8812
8820
  try {
8813
- const gotCoin = await this.client.getCoins({
8821
+ const gotCoin = await this.client.listCoins({
8814
8822
  owner: this.signer,
8815
8823
  coinType,
8816
8824
  limit: 1
8817
8825
  });
8818
- if (gotCoin.data.length === 1) {
8819
- return gotCoin.data[0].coinObjectId;
8826
+ if (gotCoin.objects.length === 1) {
8827
+ return gotCoin.objects[0].objectId;
8820
8828
  }
8821
8829
  return null;
8822
8830
  } catch (error) {
@@ -9228,7 +9236,7 @@ var _AggregatorClient = class _AggregatorClient {
9228
9236
  return outputCoin;
9229
9237
  }
9230
9238
  async routerSwap(params) {
9231
- const { router, inputCoin, slippage, txb, partner } = params;
9239
+ const { router, inputCoin, slippage, txb, partner, cetusDlmmPartner } = params;
9232
9240
  if (slippage > 1 || slippage < 0) {
9233
9241
  throw new Error(CLIENT_CONFIG.ERRORS.INVALID_SLIPPAGE);
9234
9242
  }
@@ -9262,7 +9270,8 @@ var _AggregatorClient = class _AggregatorClient {
9262
9270
  amountOut.toString(),
9263
9271
  amountLimit.toString(),
9264
9272
  priceInfoObjectIds,
9265
- partner ?? this.partner
9273
+ partner ?? this.partner,
9274
+ cetusDlmmPartner ?? this.cetusDlmmPartner
9266
9275
  );
9267
9276
  } else {
9268
9277
  return this.expectOutputSwapV3(
@@ -9337,7 +9346,7 @@ var _AggregatorClient = class _AggregatorClient {
9337
9346
  // auto build input coin
9338
9347
  // auto merge, transfer or destory target coin.
9339
9348
  async fastRouterSwap(params) {
9340
- const { router, slippage, txb, partner, payDeepFeeAmount } = params;
9349
+ const { router, slippage, txb, partner, cetusDlmmPartner, payDeepFeeAmount } = params;
9341
9350
  const fromCoinType = router.paths[0].from;
9342
9351
  const targetCoinType = router.paths[router.paths.length - 1].target;
9343
9352
  const byAmountIn = router.byAmountIn;
@@ -9378,6 +9387,7 @@ var _AggregatorClient = class _AggregatorClient {
9378
9387
  slippage,
9379
9388
  txb,
9380
9389
  partner: partner ?? this.partner,
9390
+ cetusDlmmPartner: cetusDlmmPartner ?? this.cetusDlmmPartner,
9381
9391
  deepbookv3DeepFee: deepCoin
9382
9392
  };
9383
9393
  const targetCoin = await this.routerSwap(routerSwapParams);
@@ -9559,16 +9569,18 @@ var _AggregatorClient = class _AggregatorClient {
9559
9569
  });
9560
9570
  }
9561
9571
  tx.setSenderIfNotSet(this.signer || "0x0");
9562
- const simulateRes = await this.client.devInspectTransactionBlock({
9563
- sender: this.signer || "0x0",
9564
- transactionBlock: tx
9572
+ const simulateRes = await this.client.simulateTransaction({
9573
+ transaction: tx,
9574
+ include: { events: true, effects: true }
9565
9575
  });
9566
- if (simulateRes.error) {
9567
- throw new Error("Simulation error: " + simulateRes.error);
9576
+ const txResult = simulateRes.Transaction ?? simulateRes.FailedTransaction;
9577
+ if (!txResult || simulateRes.$kind === "FailedTransaction") {
9578
+ const errorMsg = txResult?.status.success === false ? txResult.status.error.message : "Unknown error";
9579
+ throw new Error("Simulation error: " + errorMsg);
9568
9580
  }
9569
- const events = simulateRes.events ?? [];
9581
+ const events = txResult.events ?? [];
9570
9582
  const valueData = events.filter((item) => {
9571
- return item.type.includes("CalculatedSwapResultEvent");
9583
+ return item.eventType.includes("CalculatedSwapResultEvent");
9572
9584
  });
9573
9585
  if (valueData.length === 0 || valueData.length !== pools.length) {
9574
9586
  throw new Error("Simulate event result error");
@@ -9576,7 +9588,7 @@ var _AggregatorClient = class _AggregatorClient {
9576
9588
  let tempMaxAmount = byAmountIn ? new import_bn6.default(0) : new import_bn6.default(U64_MAX);
9577
9589
  let tempIndex = 0;
9578
9590
  for (let i = 0; i < valueData.length; i += 1) {
9579
- const eventJson2 = valueData[i].parsedJson;
9591
+ const eventJson2 = valueData[i].json;
9580
9592
  if (eventJson2?.data?.is_exceed) {
9581
9593
  continue;
9582
9594
  }
@@ -9594,11 +9606,11 @@ var _AggregatorClient = class _AggregatorClient {
9594
9606
  }
9595
9607
  }
9596
9608
  }
9597
- const eventJson = valueData[tempIndex].parsedJson;
9609
+ const eventJson = valueData[tempIndex].json;
9598
9610
  const eventData = eventJson?.data;
9599
9611
  const [decimalA, decimalB] = await Promise.all([
9600
- this.client.getCoinMetadata({ coinType: coinA }).then((res) => res?.decimals ?? null),
9601
- this.client.getCoinMetadata({ coinType: coinB }).then((res) => res?.decimals ?? null)
9612
+ this.client.getCoinMetadata({ coinType: coinA }).then((res) => res.coinMetadata?.decimals ?? null),
9613
+ this.client.getCoinMetadata({ coinType: coinB }).then((res) => res.coinMetadata?.decimals ?? null)
9602
9614
  ]);
9603
9615
  if (decimalA == null || decimalB == null) {
9604
9616
  throw new Error("Cannot get coin decimals");
@@ -9667,9 +9679,9 @@ var _AggregatorClient = class _AggregatorClient {
9667
9679
  }
9668
9680
  async devInspectTransactionBlock(txb) {
9669
9681
  txb.setSenderIfNotSet(this.signer || "0x0");
9670
- const res = await this.client.devInspectTransactionBlock({
9671
- sender: this.signer || "0x0",
9672
- transactionBlock: txb
9682
+ const res = await this.client.simulateTransaction({
9683
+ transaction: txb,
9684
+ include: { events: true, effects: true }
9673
9685
  });
9674
9686
  return res;
9675
9687
  }
@@ -9677,7 +9689,7 @@ var _AggregatorClient = class _AggregatorClient {
9677
9689
  const res = await this.client.signAndExecuteTransaction({
9678
9690
  transaction: txb,
9679
9691
  signer,
9680
- options: { showEffects: true, showEvents: true, showBalanceChanges: true }
9692
+ include: { effects: true, events: true, balanceChanges: true }
9681
9693
  });
9682
9694
  return res;
9683
9695
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cetusprotocol/aggregator-sdk",
3
- "version": "1.4.6",
3
+ "version": "1.4.8",
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.6.0",
25
+ "@mysten/sui": "^2.13.2",
26
26
  "@pythnetwork/hermes-client": "^3.1.0",
27
27
  "bip39": "^3.1.0",
28
28
  "dotenv": "^16.4.5",