@cetusprotocol/aggregator-sdk 0.3.8 → 0.3.9

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.js CHANGED
@@ -1,6 +1,8 @@
1
- import { SuiClient, getFullnodeUrl } from '@mysten/sui/client';
2
- import { normalizeSuiObjectId, SUI_FRAMEWORK_ADDRESS } from '@mysten/sui/utils';
3
- import { Transaction } from '@mysten/sui/transactions';
1
+ 'use strict';
2
+
3
+ var client = require('@mysten/sui/client');
4
+ var utils = require('@mysten/sui/utils');
5
+ var transactions = require('@mysten/sui/transactions');
4
6
 
5
7
  var __create = Object.create;
6
8
  var __defProp = Object.defineProperty;
@@ -47,7 +49,7 @@ var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__
47
49
  // file that has been converted to a CommonJS file using a Babel-
48
50
  // compatible transform (i.e. "__esModule" has not been set), then set
49
51
  // "default" to the CommonJS "module.exports" for node compatibility.
50
- __defProp(target, "default", { value: mod2, enumerable: true }) ,
52
+ !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
51
53
  mod2
52
54
  ));
53
55
  var __async = (__this, __arguments, generator) => {
@@ -5388,7 +5390,7 @@ function extractStructTagFromType(type) {
5388
5390
  const isSuiCoin = _type === GAS_TYPE_ARG || _type === GAS_TYPE_ARG_LONG;
5389
5391
  const structTag = {
5390
5392
  full_address: _type,
5391
- address: isSuiCoin ? "0x2" : normalizeSuiObjectId(parts[0]),
5393
+ address: isSuiCoin ? "0x2" : utils.normalizeSuiObjectId(parts[0]),
5392
5394
  module: parts[1],
5393
5395
  name: parts[2],
5394
5396
  type_arguments: [],
@@ -5413,7 +5415,7 @@ function normalizeCoinType(coinType) {
5413
5415
  }
5414
5416
  function fixSuiObjectId(value) {
5415
5417
  if (value.toLowerCase().startsWith("0x")) {
5416
- return normalizeSuiObjectId(value);
5418
+ return utils.normalizeSuiObjectId(value);
5417
5419
  }
5418
5420
  return value;
5419
5421
  }
@@ -5768,7 +5770,7 @@ function swapInPools(client, params, sender, env) {
5768
5770
  const { from, target, amount, byAmountIn, pools } = params;
5769
5771
  const fromCoin = completionCoin(from);
5770
5772
  const targetCoin = completionCoin(target);
5771
- const tx = new Transaction();
5773
+ const tx = new transactions.Transaction();
5772
5774
  const direction = compareCoins(fromCoin, targetCoin);
5773
5775
  const integratePublishedAt = env === 0 /* Mainnet */ ? "0x3a5aa90ffa33d09100d7b6941ea1c0ffe6ab66e77062ddd26320c1b073aabb10" : "0x19dd42e05fa6c9988a60d30686ee3feb776672b5547e328d6dab16563da65293";
5774
5776
  const coinA = direction ? fromCoin : targetCoin;
@@ -6118,9 +6120,9 @@ var SCALLOP = "SCALLOP";
6118
6120
  var SUILEND = "SUILEND";
6119
6121
  var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
6120
6122
  var AggregatorClient8 = class {
6121
- constructor(endpoint, signer, client, env) {
6123
+ constructor(endpoint, signer, client$1, env) {
6122
6124
  this.endpoint = endpoint ? processEndpoint(endpoint) : DEFAULT_ENDPOINT;
6123
- this.client = client || new SuiClient({ url: getFullnodeUrl("mainnet") });
6125
+ this.client = client$1 || new client.SuiClient({ url: client.getFullnodeUrl("mainnet") });
6124
6126
  this.signer = signer || "";
6125
6127
  this.env = env || 0 /* Mainnet */;
6126
6128
  this.allCoins = /* @__PURE__ */ new Map();
@@ -6238,7 +6240,7 @@ var AggregatorClient8 = class {
6238
6240
  if (targetCoins.length > 1) {
6239
6241
  const vec = txb.makeMoveVec({ elements: targetCoins.slice(1) });
6240
6242
  txb.moveCall({
6241
- target: `${SUI_FRAMEWORK_ADDRESS}::pay::join_vec`,
6243
+ target: `${utils.SUI_FRAMEWORK_ADDRESS}::pay::join_vec`,
6242
6244
  typeArguments: [routers[0].path[routers[0].path.length - 1].target],
6243
6245
  arguments: [targetCoins[0], vec]
6244
6246
  });
@@ -6418,7 +6420,7 @@ var AggregatorClient8 = class {
6418
6420
  if (coins.length > 1) {
6419
6421
  let vec = txb.makeMoveVec({ elements: coins.slice(1) });
6420
6422
  txb.moveCall({
6421
- target: `${SUI_FRAMEWORK_ADDRESS}::pay::join_vec`,
6423
+ target: `${utils.SUI_FRAMEWORK_ADDRESS}::pay::join_vec`,
6422
6424
  typeArguments: [coinType],
6423
6425
  arguments: [coins[0], vec]
6424
6426
  });
@@ -6680,7 +6682,7 @@ function getRouter(endpoint, params) {
6680
6682
  url += `&providers=${providers.join(",")}`;
6681
6683
  }
6682
6684
  }
6683
- url += "&v=1000307";
6685
+ url += "&v=1000309";
6684
6686
  const response = yield fetch(url);
6685
6687
  return response;
6686
6688
  } catch (error) {
@@ -6770,4 +6772,49 @@ decimal.js/decimal.mjs:
6770
6772
  *)
6771
6773
  */
6772
6774
 
6773
- export { AFSUI, AFTERMATH, AggregatorClient8 as AggregatorClient, BLUEMOVE, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, Env, FLOWXV2, FLOWXV3, HAEDAL, KRIYA, KRIYAV3, ONE, SCALLOP, SUILEND, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
6775
+ exports.AFSUI = AFSUI;
6776
+ exports.AFTERMATH = AFTERMATH;
6777
+ exports.AggregatorClient = AggregatorClient8;
6778
+ exports.BLUEMOVE = BLUEMOVE;
6779
+ exports.CETUS = CETUS;
6780
+ exports.CLOCK_ADDRESS = CLOCK_ADDRESS;
6781
+ exports.DEEPBOOKV2 = DEEPBOOKV2;
6782
+ exports.DEEPBOOKV3 = DEEPBOOKV3;
6783
+ exports.DEFAULT_ENDPOINT = DEFAULT_ENDPOINT;
6784
+ exports.Env = Env;
6785
+ exports.FLOWXV2 = FLOWXV2;
6786
+ exports.FLOWXV3 = FLOWXV3;
6787
+ exports.HAEDAL = HAEDAL;
6788
+ exports.KRIYA = KRIYA;
6789
+ exports.KRIYAV3 = KRIYAV3;
6790
+ exports.ONE = ONE;
6791
+ exports.SCALLOP = SCALLOP;
6792
+ exports.SUILEND = SUILEND;
6793
+ exports.TEN_POW_NINE = TEN_POW_NINE;
6794
+ exports.TURBOS = TURBOS;
6795
+ exports.TWO = TWO;
6796
+ exports.U128 = U128;
6797
+ exports.U64_MAX = U64_MAX;
6798
+ exports.U64_MAX_BN = U64_MAX_BN;
6799
+ exports.VOLO = VOLO;
6800
+ exports.ZERO = ZERO;
6801
+ exports.buildInputCoin = buildInputCoin;
6802
+ exports.checkInvalidSuiAddress = checkInvalidSuiAddress;
6803
+ exports.compareCoins = compareCoins;
6804
+ exports.completionCoin = completionCoin;
6805
+ exports.composeType = composeType;
6806
+ exports.createTarget = createTarget;
6807
+ exports.dealWithFastRouterSwapParamsForMsafe = dealWithFastRouterSwapParamsForMsafe;
6808
+ exports.extractAddressFromType = extractAddressFromType;
6809
+ exports.extractStructTagFromType = extractStructTagFromType;
6810
+ exports.fixSuiObjectId = fixSuiObjectId;
6811
+ exports.getDeepbookV3Config = getDeepbookV3Config;
6812
+ exports.getRouterResult = getRouterResult;
6813
+ exports.isSortedSymbols = isSortedSymbols;
6814
+ exports.mintZeroCoin = mintZeroCoin;
6815
+ exports.normalizeCoinType = normalizeCoinType;
6816
+ exports.parseRouterResponse = parseRouterResponse;
6817
+ exports.patchFixSuiObjectId = patchFixSuiObjectId;
6818
+ exports.printTransaction = printTransaction;
6819
+ exports.processEndpoint = processEndpoint;
6820
+ exports.restituteMsafeFastRouterSwapParams = restituteMsafeFastRouterSwapParams;
@@ -1,8 +1,6 @@
1
- 'use strict';
2
-
3
- var client = require('@mysten/sui/client');
4
- var utils = require('@mysten/sui/utils');
5
- var transactions = require('@mysten/sui/transactions');
1
+ import { SuiClient, getFullnodeUrl } from '@mysten/sui/client';
2
+ import { normalizeSuiObjectId, SUI_FRAMEWORK_ADDRESS } from '@mysten/sui/utils';
3
+ import { Transaction } from '@mysten/sui/transactions';
6
4
 
7
5
  var __create = Object.create;
8
6
  var __defProp = Object.defineProperty;
@@ -49,7 +47,7 @@ var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__
49
47
  // file that has been converted to a CommonJS file using a Babel-
50
48
  // compatible transform (i.e. "__esModule" has not been set), then set
51
49
  // "default" to the CommonJS "module.exports" for node compatibility.
52
- __defProp(target, "default", { value: mod2, enumerable: true }) ,
50
+ !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
53
51
  mod2
54
52
  ));
55
53
  var __async = (__this, __arguments, generator) => {
@@ -5390,7 +5388,7 @@ function extractStructTagFromType(type) {
5390
5388
  const isSuiCoin = _type === GAS_TYPE_ARG || _type === GAS_TYPE_ARG_LONG;
5391
5389
  const structTag = {
5392
5390
  full_address: _type,
5393
- address: isSuiCoin ? "0x2" : utils.normalizeSuiObjectId(parts[0]),
5391
+ address: isSuiCoin ? "0x2" : normalizeSuiObjectId(parts[0]),
5394
5392
  module: parts[1],
5395
5393
  name: parts[2],
5396
5394
  type_arguments: [],
@@ -5415,7 +5413,7 @@ function normalizeCoinType(coinType) {
5415
5413
  }
5416
5414
  function fixSuiObjectId(value) {
5417
5415
  if (value.toLowerCase().startsWith("0x")) {
5418
- return utils.normalizeSuiObjectId(value);
5416
+ return normalizeSuiObjectId(value);
5419
5417
  }
5420
5418
  return value;
5421
5419
  }
@@ -5770,7 +5768,7 @@ function swapInPools(client, params, sender, env) {
5770
5768
  const { from, target, amount, byAmountIn, pools } = params;
5771
5769
  const fromCoin = completionCoin(from);
5772
5770
  const targetCoin = completionCoin(target);
5773
- const tx = new transactions.Transaction();
5771
+ const tx = new Transaction();
5774
5772
  const direction = compareCoins(fromCoin, targetCoin);
5775
5773
  const integratePublishedAt = env === 0 /* Mainnet */ ? "0x3a5aa90ffa33d09100d7b6941ea1c0ffe6ab66e77062ddd26320c1b073aabb10" : "0x19dd42e05fa6c9988a60d30686ee3feb776672b5547e328d6dab16563da65293";
5776
5774
  const coinA = direction ? fromCoin : targetCoin;
@@ -6120,9 +6118,9 @@ var SCALLOP = "SCALLOP";
6120
6118
  var SUILEND = "SUILEND";
6121
6119
  var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
6122
6120
  var AggregatorClient8 = class {
6123
- constructor(endpoint, signer, client$1, env) {
6121
+ constructor(endpoint, signer, client, env) {
6124
6122
  this.endpoint = endpoint ? processEndpoint(endpoint) : DEFAULT_ENDPOINT;
6125
- this.client = client$1 || new client.SuiClient({ url: client.getFullnodeUrl("mainnet") });
6123
+ this.client = client || new SuiClient({ url: getFullnodeUrl("mainnet") });
6126
6124
  this.signer = signer || "";
6127
6125
  this.env = env || 0 /* Mainnet */;
6128
6126
  this.allCoins = /* @__PURE__ */ new Map();
@@ -6240,7 +6238,7 @@ var AggregatorClient8 = class {
6240
6238
  if (targetCoins.length > 1) {
6241
6239
  const vec = txb.makeMoveVec({ elements: targetCoins.slice(1) });
6242
6240
  txb.moveCall({
6243
- target: `${utils.SUI_FRAMEWORK_ADDRESS}::pay::join_vec`,
6241
+ target: `${SUI_FRAMEWORK_ADDRESS}::pay::join_vec`,
6244
6242
  typeArguments: [routers[0].path[routers[0].path.length - 1].target],
6245
6243
  arguments: [targetCoins[0], vec]
6246
6244
  });
@@ -6420,7 +6418,7 @@ var AggregatorClient8 = class {
6420
6418
  if (coins.length > 1) {
6421
6419
  let vec = txb.makeMoveVec({ elements: coins.slice(1) });
6422
6420
  txb.moveCall({
6423
- target: `${utils.SUI_FRAMEWORK_ADDRESS}::pay::join_vec`,
6421
+ target: `${SUI_FRAMEWORK_ADDRESS}::pay::join_vec`,
6424
6422
  typeArguments: [coinType],
6425
6423
  arguments: [coins[0], vec]
6426
6424
  });
@@ -6682,7 +6680,7 @@ function getRouter(endpoint, params) {
6682
6680
  url += `&providers=${providers.join(",")}`;
6683
6681
  }
6684
6682
  }
6685
- url += "&v=1000307";
6683
+ url += "&v=1000309";
6686
6684
  const response = yield fetch(url);
6687
6685
  return response;
6688
6686
  } catch (error) {
@@ -6772,49 +6770,4 @@ decimal.js/decimal.mjs:
6772
6770
  *)
6773
6771
  */
6774
6772
 
6775
- exports.AFSUI = AFSUI;
6776
- exports.AFTERMATH = AFTERMATH;
6777
- exports.AggregatorClient = AggregatorClient8;
6778
- exports.BLUEMOVE = BLUEMOVE;
6779
- exports.CETUS = CETUS;
6780
- exports.CLOCK_ADDRESS = CLOCK_ADDRESS;
6781
- exports.DEEPBOOKV2 = DEEPBOOKV2;
6782
- exports.DEEPBOOKV3 = DEEPBOOKV3;
6783
- exports.DEFAULT_ENDPOINT = DEFAULT_ENDPOINT;
6784
- exports.Env = Env;
6785
- exports.FLOWXV2 = FLOWXV2;
6786
- exports.FLOWXV3 = FLOWXV3;
6787
- exports.HAEDAL = HAEDAL;
6788
- exports.KRIYA = KRIYA;
6789
- exports.KRIYAV3 = KRIYAV3;
6790
- exports.ONE = ONE;
6791
- exports.SCALLOP = SCALLOP;
6792
- exports.SUILEND = SUILEND;
6793
- exports.TEN_POW_NINE = TEN_POW_NINE;
6794
- exports.TURBOS = TURBOS;
6795
- exports.TWO = TWO;
6796
- exports.U128 = U128;
6797
- exports.U64_MAX = U64_MAX;
6798
- exports.U64_MAX_BN = U64_MAX_BN;
6799
- exports.VOLO = VOLO;
6800
- exports.ZERO = ZERO;
6801
- exports.buildInputCoin = buildInputCoin;
6802
- exports.checkInvalidSuiAddress = checkInvalidSuiAddress;
6803
- exports.compareCoins = compareCoins;
6804
- exports.completionCoin = completionCoin;
6805
- exports.composeType = composeType;
6806
- exports.createTarget = createTarget;
6807
- exports.dealWithFastRouterSwapParamsForMsafe = dealWithFastRouterSwapParamsForMsafe;
6808
- exports.extractAddressFromType = extractAddressFromType;
6809
- exports.extractStructTagFromType = extractStructTagFromType;
6810
- exports.fixSuiObjectId = fixSuiObjectId;
6811
- exports.getDeepbookV3Config = getDeepbookV3Config;
6812
- exports.getRouterResult = getRouterResult;
6813
- exports.isSortedSymbols = isSortedSymbols;
6814
- exports.mintZeroCoin = mintZeroCoin;
6815
- exports.normalizeCoinType = normalizeCoinType;
6816
- exports.parseRouterResponse = parseRouterResponse;
6817
- exports.patchFixSuiObjectId = patchFixSuiObjectId;
6818
- exports.printTransaction = printTransaction;
6819
- exports.processEndpoint = processEndpoint;
6820
- exports.restituteMsafeFastRouterSwapParams = restituteMsafeFastRouterSwapParams;
6773
+ export { AFSUI, AFTERMATH, AggregatorClient8 as AggregatorClient, BLUEMOVE, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, Env, FLOWXV2, FLOWXV3, HAEDAL, KRIYA, KRIYAV3, ONE, SCALLOP, SUILEND, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
package/package.json CHANGED
@@ -1,9 +1,8 @@
1
1
  {
2
2
  "name": "@cetusprotocol/aggregator-sdk",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "sideEffects": false,
5
5
  "main": "dist/index.js",
6
- "type": "module",
7
6
  "types": "dist/index.d.ts",
8
7
  "module": "dist/index.js",
9
8
  "scripts": {
package/src/api.ts CHANGED
@@ -168,7 +168,7 @@ async function getRouter(endpoint: string, params: FindRouterParams) {
168
168
  }
169
169
 
170
170
  // set newest sdk version
171
- url += "&v=1000307"
171
+ url += "&v=1000309"
172
172
 
173
173
  const response = await fetch(url)
174
174
  return response
package/test.json DELETED
@@ -1,5 +0,0 @@
1
- [
2
- [Path { id: "0x0d1b1746d220bd5ebac5231c7685480a16f1c707a46306095a4c67dc7ce4dcae", edge_id: "0x0d1b1746d220bd5ebac5231c7685480a16f1c707a46306095a4c67dc7ce4dcae", provider: "DEEPBOOKV3", from: "0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP", target: "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI", direction: true, fee_rate: Decimal(0), lot_size: 1000000, amount_in: 0, amount_out: 0, max_depth: 3, extended_details: None, allow_bidirection: true
3
- }
4
- ]
5
- ]
File without changes