@cetusprotocol/aggregator-sdk 0.3.7 → 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.
@@ -74,6 +74,7 @@ declare const AFSUI = "AFSUI";
74
74
  declare const BLUEMOVE = "BLUEMOVE";
75
75
  declare const DEEPBOOKV3 = "DEEPBOOKV3";
76
76
  declare const SCALLOP = "SCALLOP";
77
+ declare const SUILEND = "SUILEND";
77
78
  declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
78
79
  type BuildRouterSwapParams = {
79
80
  routers: Router[];
@@ -265,4 +266,4 @@ declare enum Env {
265
266
  Testnet = 1
266
267
  }
267
268
 
268
- export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, BLUEMOVE, type BuildCoinResult, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, KRIYA, KRIYAV3, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, SCALLOP, type SwapInPoolsParams, type SwapInPoolsResult, 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 };
269
+ export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, BLUEMOVE, type BuildCoinResult, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, KRIYA, KRIYAV3, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, SCALLOP, SUILEND, type SwapInPoolsParams, type SwapInPoolsResult, 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/dist/index.d.ts CHANGED
@@ -74,6 +74,7 @@ declare const AFSUI = "AFSUI";
74
74
  declare const BLUEMOVE = "BLUEMOVE";
75
75
  declare const DEEPBOOKV3 = "DEEPBOOKV3";
76
76
  declare const SCALLOP = "SCALLOP";
77
+ declare const SUILEND = "SUILEND";
77
78
  declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
78
79
  type BuildRouterSwapParams = {
79
80
  routers: Router[];
@@ -265,4 +266,4 @@ declare enum Env {
265
266
  Testnet = 1
266
267
  }
267
268
 
268
- export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, BLUEMOVE, type BuildCoinResult, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, KRIYA, KRIYAV3, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, SCALLOP, type SwapInPoolsParams, type SwapInPoolsResult, 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 };
269
+ export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, BLUEMOVE, type BuildCoinResult, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, KRIYA, KRIYAV3, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, SCALLOP, SUILEND, type SwapInPoolsParams, type SwapInPoolsResult, 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/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;
@@ -6072,6 +6074,34 @@ var Scallop = class {
6072
6074
  }
6073
6075
  };
6074
6076
 
6077
+ // src/transaction/suilend.ts
6078
+ var Suilend = class {
6079
+ constructor(env) {
6080
+ if (env !== 0 /* Mainnet */) {
6081
+ throw new Error("Suilend only supported on mainnet");
6082
+ }
6083
+ this.liquid_staking_pool = env === 0 /* Mainnet */ ? "0x15eda7330c8f99c30e430b4d82fd7ab2af3ead4ae17046fcb224aa9bad394f6b" : "0x0";
6084
+ this.sui_system_state = env === 0 /* Mainnet */ ? "0x0000000000000000000000000000000000000000000000000000000000000005" : "0x0";
6085
+ }
6086
+ swap(client, txb, path, inputCoin) {
6087
+ return __async(this, null, function* () {
6088
+ const { direction, from, target } = path;
6089
+ const [func, springCoinType] = direction ? ["swap_a2b", target] : ["swap_b2a", from];
6090
+ const args = [
6091
+ txb.object(this.liquid_staking_pool),
6092
+ txb.object(this.sui_system_state),
6093
+ inputCoin
6094
+ ];
6095
+ const res = txb.moveCall({
6096
+ target: `${client.publishedAtV2()}::suilend::${func}`,
6097
+ typeArguments: [springCoinType],
6098
+ arguments: args
6099
+ });
6100
+ return res;
6101
+ });
6102
+ }
6103
+ };
6104
+
6075
6105
  // src/client.ts
6076
6106
  var CETUS = "CETUS";
6077
6107
  var DEEPBOOKV2 = "DEEPBOOK";
@@ -6087,11 +6117,12 @@ var AFSUI = "AFSUI";
6087
6117
  var BLUEMOVE = "BLUEMOVE";
6088
6118
  var DEEPBOOKV3 = "DEEPBOOKV3";
6089
6119
  var SCALLOP = "SCALLOP";
6120
+ var SUILEND = "SUILEND";
6090
6121
  var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
6091
6122
  var AggregatorClient8 = class {
6092
- constructor(endpoint, signer, client, env) {
6123
+ constructor(endpoint, signer, client$1, env) {
6093
6124
  this.endpoint = endpoint ? processEndpoint(endpoint) : DEFAULT_ENDPOINT;
6094
- this.client = client || new SuiClient({ url: getFullnodeUrl("mainnet") });
6125
+ this.client = client$1 || new client.SuiClient({ url: client.getFullnodeUrl("mainnet") });
6095
6126
  this.signer = signer || "";
6096
6127
  this.env = env || 0 /* Mainnet */;
6097
6128
  this.allCoins = /* @__PURE__ */ new Map();
@@ -6209,7 +6240,7 @@ var AggregatorClient8 = class {
6209
6240
  if (targetCoins.length > 1) {
6210
6241
  const vec = txb.makeMoveVec({ elements: targetCoins.slice(1) });
6211
6242
  txb.moveCall({
6212
- target: `${SUI_FRAMEWORK_ADDRESS}::pay::join_vec`,
6243
+ target: `${utils.SUI_FRAMEWORK_ADDRESS}::pay::join_vec`,
6213
6244
  typeArguments: [routers[0].path[routers[0].path.length - 1].target],
6214
6245
  arguments: [targetCoins[0], vec]
6215
6246
  });
@@ -6231,7 +6262,15 @@ var AggregatorClient8 = class {
6231
6262
  }
6232
6263
  routerSwap(params) {
6233
6264
  return __async(this, null, function* () {
6234
- const { routers, inputCoin, slippage, byAmountIn, txb, partner, deepbookv3DeepFee } = params;
6265
+ const {
6266
+ routers,
6267
+ inputCoin,
6268
+ slippage,
6269
+ byAmountIn,
6270
+ txb,
6271
+ partner,
6272
+ deepbookv3DeepFee
6273
+ } = params;
6235
6274
  const amountIn = routers.reduce(
6236
6275
  (acc, router) => acc.add(router.amountIn),
6237
6276
  new import_bn5.default(0)
@@ -6357,7 +6396,7 @@ var AggregatorClient8 = class {
6357
6396
  // Include deepbookv3, scallop
6358
6397
  publishedAtV2() {
6359
6398
  if (this.env === 0 /* Mainnet */) {
6360
- return "0x6d70ffa7aa3f924c3f0b573d27d29895a0ee666aaff821073f75cb14af7fd01a";
6399
+ return "0x16d9418726c26d8cb4ce8c9dd75917fa9b1c7bf47d38d7a1a22603135f0f2a56";
6361
6400
  } else {
6362
6401
  return "0xfd8a73ef0a4b928da9c27fc287dc37c1ca64df71da8e8eac7ca9ece55eb5f448";
6363
6402
  }
@@ -6381,7 +6420,7 @@ var AggregatorClient8 = class {
6381
6420
  if (coins.length > 1) {
6382
6421
  let vec = txb.makeMoveVec({ elements: coins.slice(1) });
6383
6422
  txb.moveCall({
6384
- target: `${SUI_FRAMEWORK_ADDRESS}::pay::join_vec`,
6423
+ target: `${utils.SUI_FRAMEWORK_ADDRESS}::pay::join_vec`,
6385
6424
  typeArguments: [coinType],
6386
6425
  arguments: [coins[0], vec]
6387
6426
  });
@@ -6424,6 +6463,8 @@ var AggregatorClient8 = class {
6424
6463
  return new Bluemove(this.env);
6425
6464
  case SCALLOP:
6426
6465
  return new Scallop(this.env);
6466
+ case SUILEND:
6467
+ return new Suilend(this.env);
6427
6468
  default:
6428
6469
  throw new Error(`Unsupported dex ${provider}`);
6429
6470
  }
@@ -6641,7 +6682,7 @@ function getRouter(endpoint, params) {
6641
6682
  url += `&providers=${providers.join(",")}`;
6642
6683
  }
6643
6684
  }
6644
- url += "&v=1000304";
6685
+ url += "&v=1000309";
6645
6686
  const response = yield fetch(url);
6646
6687
  return response;
6647
6688
  } catch (error) {
@@ -6731,4 +6772,49 @@ decimal.js/decimal.mjs:
6731
6772
  *)
6732
6773
  */
6733
6774
 
6734
- export { AFSUI, AFTERMATH, AggregatorClient8 as AggregatorClient, BLUEMOVE, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, Env, FLOWXV2, FLOWXV3, HAEDAL, KRIYA, KRIYAV3, ONE, SCALLOP, 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;
@@ -6074,6 +6072,34 @@ var Scallop = class {
6074
6072
  }
6075
6073
  };
6076
6074
 
6075
+ // src/transaction/suilend.ts
6076
+ var Suilend = class {
6077
+ constructor(env) {
6078
+ if (env !== 0 /* Mainnet */) {
6079
+ throw new Error("Suilend only supported on mainnet");
6080
+ }
6081
+ this.liquid_staking_pool = env === 0 /* Mainnet */ ? "0x15eda7330c8f99c30e430b4d82fd7ab2af3ead4ae17046fcb224aa9bad394f6b" : "0x0";
6082
+ this.sui_system_state = env === 0 /* Mainnet */ ? "0x0000000000000000000000000000000000000000000000000000000000000005" : "0x0";
6083
+ }
6084
+ swap(client, txb, path, inputCoin) {
6085
+ return __async(this, null, function* () {
6086
+ const { direction, from, target } = path;
6087
+ const [func, springCoinType] = direction ? ["swap_a2b", target] : ["swap_b2a", from];
6088
+ const args = [
6089
+ txb.object(this.liquid_staking_pool),
6090
+ txb.object(this.sui_system_state),
6091
+ inputCoin
6092
+ ];
6093
+ const res = txb.moveCall({
6094
+ target: `${client.publishedAtV2()}::suilend::${func}`,
6095
+ typeArguments: [springCoinType],
6096
+ arguments: args
6097
+ });
6098
+ return res;
6099
+ });
6100
+ }
6101
+ };
6102
+
6077
6103
  // src/client.ts
6078
6104
  var CETUS = "CETUS";
6079
6105
  var DEEPBOOKV2 = "DEEPBOOK";
@@ -6089,11 +6115,12 @@ var AFSUI = "AFSUI";
6089
6115
  var BLUEMOVE = "BLUEMOVE";
6090
6116
  var DEEPBOOKV3 = "DEEPBOOKV3";
6091
6117
  var SCALLOP = "SCALLOP";
6118
+ var SUILEND = "SUILEND";
6092
6119
  var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
6093
6120
  var AggregatorClient8 = class {
6094
- constructor(endpoint, signer, client$1, env) {
6121
+ constructor(endpoint, signer, client, env) {
6095
6122
  this.endpoint = endpoint ? processEndpoint(endpoint) : DEFAULT_ENDPOINT;
6096
- this.client = client$1 || new client.SuiClient({ url: client.getFullnodeUrl("mainnet") });
6123
+ this.client = client || new SuiClient({ url: getFullnodeUrl("mainnet") });
6097
6124
  this.signer = signer || "";
6098
6125
  this.env = env || 0 /* Mainnet */;
6099
6126
  this.allCoins = /* @__PURE__ */ new Map();
@@ -6211,7 +6238,7 @@ var AggregatorClient8 = class {
6211
6238
  if (targetCoins.length > 1) {
6212
6239
  const vec = txb.makeMoveVec({ elements: targetCoins.slice(1) });
6213
6240
  txb.moveCall({
6214
- target: `${utils.SUI_FRAMEWORK_ADDRESS}::pay::join_vec`,
6241
+ target: `${SUI_FRAMEWORK_ADDRESS}::pay::join_vec`,
6215
6242
  typeArguments: [routers[0].path[routers[0].path.length - 1].target],
6216
6243
  arguments: [targetCoins[0], vec]
6217
6244
  });
@@ -6233,7 +6260,15 @@ var AggregatorClient8 = class {
6233
6260
  }
6234
6261
  routerSwap(params) {
6235
6262
  return __async(this, null, function* () {
6236
- const { routers, inputCoin, slippage, byAmountIn, txb, partner, deepbookv3DeepFee } = params;
6263
+ const {
6264
+ routers,
6265
+ inputCoin,
6266
+ slippage,
6267
+ byAmountIn,
6268
+ txb,
6269
+ partner,
6270
+ deepbookv3DeepFee
6271
+ } = params;
6237
6272
  const amountIn = routers.reduce(
6238
6273
  (acc, router) => acc.add(router.amountIn),
6239
6274
  new import_bn5.default(0)
@@ -6359,7 +6394,7 @@ var AggregatorClient8 = class {
6359
6394
  // Include deepbookv3, scallop
6360
6395
  publishedAtV2() {
6361
6396
  if (this.env === 0 /* Mainnet */) {
6362
- return "0x6d70ffa7aa3f924c3f0b573d27d29895a0ee666aaff821073f75cb14af7fd01a";
6397
+ return "0x16d9418726c26d8cb4ce8c9dd75917fa9b1c7bf47d38d7a1a22603135f0f2a56";
6363
6398
  } else {
6364
6399
  return "0xfd8a73ef0a4b928da9c27fc287dc37c1ca64df71da8e8eac7ca9ece55eb5f448";
6365
6400
  }
@@ -6383,7 +6418,7 @@ var AggregatorClient8 = class {
6383
6418
  if (coins.length > 1) {
6384
6419
  let vec = txb.makeMoveVec({ elements: coins.slice(1) });
6385
6420
  txb.moveCall({
6386
- target: `${utils.SUI_FRAMEWORK_ADDRESS}::pay::join_vec`,
6421
+ target: `${SUI_FRAMEWORK_ADDRESS}::pay::join_vec`,
6387
6422
  typeArguments: [coinType],
6388
6423
  arguments: [coins[0], vec]
6389
6424
  });
@@ -6426,6 +6461,8 @@ var AggregatorClient8 = class {
6426
6461
  return new Bluemove(this.env);
6427
6462
  case SCALLOP:
6428
6463
  return new Scallop(this.env);
6464
+ case SUILEND:
6465
+ return new Suilend(this.env);
6429
6466
  default:
6430
6467
  throw new Error(`Unsupported dex ${provider}`);
6431
6468
  }
@@ -6643,7 +6680,7 @@ function getRouter(endpoint, params) {
6643
6680
  url += `&providers=${providers.join(",")}`;
6644
6681
  }
6645
6682
  }
6646
- url += "&v=1000304";
6683
+ url += "&v=1000309";
6647
6684
  const response = yield fetch(url);
6648
6685
  return response;
6649
6686
  } catch (error) {
@@ -6733,48 +6770,4 @@ decimal.js/decimal.mjs:
6733
6770
  *)
6734
6771
  */
6735
6772
 
6736
- exports.AFSUI = AFSUI;
6737
- exports.AFTERMATH = AFTERMATH;
6738
- exports.AggregatorClient = AggregatorClient8;
6739
- exports.BLUEMOVE = BLUEMOVE;
6740
- exports.CETUS = CETUS;
6741
- exports.CLOCK_ADDRESS = CLOCK_ADDRESS;
6742
- exports.DEEPBOOKV2 = DEEPBOOKV2;
6743
- exports.DEEPBOOKV3 = DEEPBOOKV3;
6744
- exports.DEFAULT_ENDPOINT = DEFAULT_ENDPOINT;
6745
- exports.Env = Env;
6746
- exports.FLOWXV2 = FLOWXV2;
6747
- exports.FLOWXV3 = FLOWXV3;
6748
- exports.HAEDAL = HAEDAL;
6749
- exports.KRIYA = KRIYA;
6750
- exports.KRIYAV3 = KRIYAV3;
6751
- exports.ONE = ONE;
6752
- exports.SCALLOP = SCALLOP;
6753
- exports.TEN_POW_NINE = TEN_POW_NINE;
6754
- exports.TURBOS = TURBOS;
6755
- exports.TWO = TWO;
6756
- exports.U128 = U128;
6757
- exports.U64_MAX = U64_MAX;
6758
- exports.U64_MAX_BN = U64_MAX_BN;
6759
- exports.VOLO = VOLO;
6760
- exports.ZERO = ZERO;
6761
- exports.buildInputCoin = buildInputCoin;
6762
- exports.checkInvalidSuiAddress = checkInvalidSuiAddress;
6763
- exports.compareCoins = compareCoins;
6764
- exports.completionCoin = completionCoin;
6765
- exports.composeType = composeType;
6766
- exports.createTarget = createTarget;
6767
- exports.dealWithFastRouterSwapParamsForMsafe = dealWithFastRouterSwapParamsForMsafe;
6768
- exports.extractAddressFromType = extractAddressFromType;
6769
- exports.extractStructTagFromType = extractStructTagFromType;
6770
- exports.fixSuiObjectId = fixSuiObjectId;
6771
- exports.getDeepbookV3Config = getDeepbookV3Config;
6772
- exports.getRouterResult = getRouterResult;
6773
- exports.isSortedSymbols = isSortedSymbols;
6774
- exports.mintZeroCoin = mintZeroCoin;
6775
- exports.normalizeCoinType = normalizeCoinType;
6776
- exports.parseRouterResponse = parseRouterResponse;
6777
- exports.patchFixSuiObjectId = patchFixSuiObjectId;
6778
- exports.printTransaction = printTransaction;
6779
- exports.processEndpoint = processEndpoint;
6780
- 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 };
@@ -18,6 +18,7 @@ export declare const AFSUI = "AFSUI";
18
18
  export declare const BLUEMOVE = "BLUEMOVE";
19
19
  export declare const DEEPBOOKV3 = "DEEPBOOKV3";
20
20
  export declare const SCALLOP = "SCALLOP";
21
+ export declare const SUILEND = "SUILEND";
21
22
  export declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
22
23
  export type BuildRouterSwapParams = {
23
24
  routers: Router[];
@@ -0,0 +1,8 @@
1
+ import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
2
+ import { AggregatorClient, Dex, Env, Path } from "..";
3
+ export declare class Suilend implements Dex {
4
+ private liquid_staking_pool;
5
+ private sui_system_state;
6
+ constructor(env: Env);
7
+ swap(client: AggregatorClient, txb: Transaction, path: Path, inputCoin: TransactionObjectArgument): Promise<TransactionObjectArgument>;
8
+ }
package/package.json CHANGED
@@ -1,9 +1,8 @@
1
1
  {
2
2
  "name": "@cetusprotocol/aggregator-sdk",
3
- "version": "0.3.7",
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=1000304"
171
+ url += "&v=1000309"
172
172
 
173
173
  const response = await fetch(url)
174
174
  return response
@@ -238,7 +238,7 @@ export type DeepbookV3Config = {
238
238
  is_alternative_payment: boolean
239
239
  alternative_payment_amount: number
240
240
  trade_cap: string
241
- balance_manager: string
241
+ balance_manager: string
242
242
  deep_fee_vault: number
243
243
  whitelist: number
244
244
  package_version: 0
package/src/client.ts CHANGED
@@ -37,6 +37,8 @@ import { CoinAsset } from "./types/sui"
37
37
  import { buildInputCoin } from "./utils/coin"
38
38
  import { DeepbookV3 } from "./transaction/deepbook_v3"
39
39
  import { Scallop } from "./transaction/scallop"
40
+ import { Suilend } from "./transaction/suilend"
41
+
40
42
  export const CETUS = "CETUS"
41
43
  export const DEEPBOOKV2 = "DEEPBOOK"
42
44
  export const KRIYA = "KRIYA"
@@ -51,7 +53,7 @@ export const AFSUI = "AFSUI"
51
53
  export const BLUEMOVE = "BLUEMOVE"
52
54
  export const DEEPBOOKV3 = "DEEPBOOKV3"
53
55
  export const SCALLOP = "SCALLOP"
54
-
56
+ export const SUILEND = "SUILEND"
55
57
  export const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2"
56
58
 
57
59
  export type BuildRouterSwapParams = {
@@ -97,15 +99,23 @@ export class AggregatorClient {
97
99
  public env: Env
98
100
  private allCoins: Map<string, CoinAsset[]>
99
101
 
100
- constructor(endpoint?: string, signer?: string, client?: SuiClient, env?: Env) {
102
+ constructor(
103
+ endpoint?: string,
104
+ signer?: string,
105
+ client?: SuiClient,
106
+ env?: Env
107
+ ) {
101
108
  this.endpoint = endpoint ? processEndpoint(endpoint) : DEFAULT_ENDPOINT
102
- this.client = client || new SuiClient({url: getFullnodeUrl('mainnet')})
109
+ this.client = client || new SuiClient({ url: getFullnodeUrl("mainnet") })
103
110
  this.signer = signer || ""
104
111
  this.env = env || Env.Mainnet
105
112
  this.allCoins = new Map<string, CoinAsset[]>()
106
113
  }
107
114
 
108
- async getCoins(coinType: string, refresh: boolean = true): Promise<CoinAsset[]> {
115
+ async getCoins(
116
+ coinType: string,
117
+ refresh: boolean = true
118
+ ): Promise<CoinAsset[]> {
109
119
  if (this.signer === "") {
110
120
  throw new Error("Signer is required, but not provided.")
111
121
  }
@@ -155,7 +165,7 @@ export class AggregatorClient {
155
165
  routers: Router[],
156
166
  amountOutLimit: BN,
157
167
  partner?: string,
158
- deepbookv3DeepFee?: TransactionObjectArgument,
168
+ deepbookv3DeepFee?: TransactionObjectArgument
159
169
  ) {
160
170
  if (routers.length === 0) {
161
171
  throw new Error("No router found")
@@ -257,7 +267,15 @@ export class AggregatorClient {
257
267
  async routerSwap(
258
268
  params: BuildRouterSwapParams
259
269
  ): Promise<TransactionObjectArgument> {
260
- const { routers, inputCoin, slippage, byAmountIn, txb, partner, deepbookv3DeepFee } = params
270
+ const {
271
+ routers,
272
+ inputCoin,
273
+ slippage,
274
+ byAmountIn,
275
+ txb,
276
+ partner,
277
+ deepbookv3DeepFee,
278
+ } = params
261
279
  const amountIn = routers.reduce(
262
280
  (acc, router) => acc.add(router.amountIn),
263
281
  new BN(0)
@@ -314,7 +332,6 @@ export class AggregatorClient {
314
332
 
315
333
  const fromCoinType = routers[0].path[0].from
316
334
 
317
-
318
335
  let fromCoins = await this.getCoins(fromCoinType, refreshAllCoins)
319
336
 
320
337
  const targetCoinType = routers[0].path[routers[0].path.length - 1].target
@@ -395,7 +412,8 @@ export class AggregatorClient {
395
412
  publishedAtV2(): string {
396
413
  if (this.env === Env.Mainnet) {
397
414
  // return "0x43811be4677f5a5de7bf2dac740c10abddfaa524aee6b18e910eeadda8a2f6ae" // version 1, deepbookv3
398
- return "0x6d70ffa7aa3f924c3f0b573d27d29895a0ee666aaff821073f75cb14af7fd01a" // version 3, deepbookv3 & scallop
415
+ // return "0x6d70ffa7aa3f924c3f0b573d27d29895a0ee666aaff821073f75cb14af7fd01a" // version 3, deepbookv3 & scallop
416
+ return "0x16d9418726c26d8cb4ce8c9dd75917fa9b1c7bf47d38d7a1a22603135f0f2a56" // version 4 add suilend
399
417
  } else {
400
418
  return "0xfd8a73ef0a4b928da9c27fc287dc37c1ca64df71da8e8eac7ca9ece55eb5f448"
401
419
  }
@@ -476,6 +494,8 @@ export class AggregatorClient {
476
494
  return new Bluemove(this.env)
477
495
  case SCALLOP:
478
496
  return new Scallop(this.env)
497
+ case SUILEND:
498
+ return new Suilend(this.env)
479
499
  default:
480
500
  throw new Error(`Unsupported dex ${provider}`)
481
501
  }
@@ -558,7 +578,8 @@ export function parseRouterResponse(data: any): RouterData {
558
578
  turbosFeeType: path.extended_details?.turbos_fee_type,
559
579
  afterSqrtPrice: path.extended_details?.after_sqrt_price,
560
580
  deepbookv3DeepFee: path.extended_details?.deepbookv3_deep_fee,
561
- scallopScoinTreasury: path.extended_details?.scallop_scoin_treasury,
581
+ scallopScoinTreasury:
582
+ path.extended_details?.scallop_scoin_treasury,
562
583
  }
563
584
  }
564
585
 
@@ -0,0 +1,52 @@
1
+ import {
2
+ Transaction,
3
+ TransactionObjectArgument,
4
+ } from "@mysten/sui/transactions"
5
+ import { AggregatorClient, CLOCK_ADDRESS, Dex, Env, Path } from ".."
6
+
7
+ export class Suilend implements Dex {
8
+ private liquid_staking_pool: string
9
+ private sui_system_state: string
10
+
11
+ constructor(env: Env) {
12
+ if (env !== Env.Mainnet) {
13
+ throw new Error("Suilend only supported on mainnet")
14
+ }
15
+
16
+ this.liquid_staking_pool = env === Env.Mainnet
17
+ ? "0x15eda7330c8f99c30e430b4d82fd7ab2af3ead4ae17046fcb224aa9bad394f6b"
18
+ : "0x0"
19
+
20
+ this.sui_system_state =
21
+ env === Env.Mainnet
22
+ ? "0x0000000000000000000000000000000000000000000000000000000000000005"
23
+ : "0x0"
24
+ }
25
+
26
+ async swap(
27
+ client: AggregatorClient,
28
+ txb: Transaction,
29
+ path: Path,
30
+ inputCoin: TransactionObjectArgument
31
+ ): Promise<TransactionObjectArgument> {
32
+ const { direction, from, target } = path
33
+
34
+ const [func, springCoinType] = direction
35
+ ? ["swap_a2b", target]
36
+ : ["swap_b2a", from]
37
+
38
+ const args = [
39
+ txb.object(this.liquid_staking_pool),
40
+ txb.object(this.sui_system_state),
41
+ inputCoin,
42
+ ]
43
+
44
+ const res = txb.moveCall({
45
+ target: `${client.publishedAtV2()}::suilend::${func}`,
46
+ typeArguments: [springCoinType],
47
+ arguments: args,
48
+ }) as TransactionObjectArgument
49
+
50
+ return res
51
+ }
52
+ }
@@ -113,8 +113,8 @@ describe("router module", () => {
113
113
  test("Build router tx", async () => {
114
114
  const byAmountIn = true
115
115
  const amount = "320000"
116
- const target = "0x2::sui::SUI"
117
- const from = "0x26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc::eth::ETH"
116
+ const from = "0x2::sui::SUI"
117
+ const target = "0x83556891f4a0f233ce7b05cfe7f957d4020492a34f5405b2cb9377d060bef4bf::spring_sui::SPRING_SUI"
118
118
 
119
119
  const res = await client.findRouters({
120
120
  from,
@@ -123,8 +123,8 @@ describe("router module", () => {
123
123
  byAmountIn,
124
124
  depth: 3,
125
125
  providers: [
126
- "SCALLOP",
127
- "CETUS",
126
+ "SUILEND",
127
+ // "CETUS",
128
128
  // "DEEPBOOKV3",
129
129
  // "DEEPBOOK",
130
130
  // "AFTERMATH",
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
- ]