@cetusprotocol/aggregator-sdk 0.0.0-experimental-20241121205059 → 0.0.0-experimental-20241126185121

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.cjs CHANGED
@@ -6074,6 +6074,35 @@ var Scallop = class {
6074
6074
  }
6075
6075
  };
6076
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
+ txb.object(CLOCK_ADDRESS)
6095
+ ];
6096
+ const res = txb.moveCall({
6097
+ target: `${client.publishedAtV2()}::suilend::${func}`,
6098
+ typeArguments: [springCoinType],
6099
+ arguments: args
6100
+ });
6101
+ return res;
6102
+ });
6103
+ }
6104
+ };
6105
+
6077
6106
  // src/client.ts
6078
6107
  var CETUS = "CETUS";
6079
6108
  var DEEPBOOKV2 = "DEEPBOOK";
@@ -6089,8 +6118,9 @@ var AFSUI = "AFSUI";
6089
6118
  var BLUEMOVE = "BLUEMOVE";
6090
6119
  var DEEPBOOKV3 = "DEEPBOOKV3";
6091
6120
  var SCALLOP = "SCALLOP";
6121
+ var SUILEND = "SUILEND";
6092
6122
  var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
6093
- var AggregatorClient8 = class {
6123
+ var AggregatorClient9 = class {
6094
6124
  constructor(endpoint, signer, client$1, env) {
6095
6125
  this.endpoint = endpoint ? processEndpoint(endpoint) : DEFAULT_ENDPOINT;
6096
6126
  this.client = client$1 || new client.SuiClient({ url: client.getFullnodeUrl("mainnet") });
@@ -6233,7 +6263,15 @@ var AggregatorClient8 = class {
6233
6263
  }
6234
6264
  routerSwap(params) {
6235
6265
  return __async(this, null, function* () {
6236
- const { routers, inputCoin, slippage, byAmountIn, txb, partner, deepbookv3DeepFee } = params;
6266
+ const {
6267
+ routers,
6268
+ inputCoin,
6269
+ slippage,
6270
+ byAmountIn,
6271
+ txb,
6272
+ partner,
6273
+ deepbookv3DeepFee
6274
+ } = params;
6237
6275
  const amountIn = routers.reduce(
6238
6276
  (acc, router) => acc.add(router.amountIn),
6239
6277
  new import_bn5.default(0)
@@ -6359,7 +6397,7 @@ var AggregatorClient8 = class {
6359
6397
  // Include deepbookv3, scallop
6360
6398
  publishedAtV2() {
6361
6399
  if (this.env === 0 /* Mainnet */) {
6362
- return "0x6d70ffa7aa3f924c3f0b573d27d29895a0ee666aaff821073f75cb14af7fd01a";
6400
+ return "0xe1e3b5d3061053fbfa297690eb764eca730caf8a288d96f81e3d95fb7ae3b625";
6363
6401
  } else {
6364
6402
  return "0xfd8a73ef0a4b928da9c27fc287dc37c1ca64df71da8e8eac7ca9ece55eb5f448";
6365
6403
  }
@@ -6426,6 +6464,8 @@ var AggregatorClient8 = class {
6426
6464
  return new Bluemove(this.env);
6427
6465
  case SCALLOP:
6428
6466
  return new Scallop(this.env);
6467
+ case SUILEND:
6468
+ return new Suilend(this.env);
6429
6469
  default:
6430
6470
  throw new Error(`Unsupported dex ${provider}`);
6431
6471
  }
@@ -6643,7 +6683,7 @@ function getRouter(endpoint, params) {
6643
6683
  url += `&providers=${providers.join(",")}`;
6644
6684
  }
6645
6685
  }
6646
- url += "&v=1000304";
6686
+ url += "&v=1000307";
6647
6687
  const response = yield fetch(url);
6648
6688
  return response;
6649
6689
  } catch (error) {
@@ -6735,7 +6775,7 @@ decimal.js/decimal.mjs:
6735
6775
 
6736
6776
  exports.AFSUI = AFSUI;
6737
6777
  exports.AFTERMATH = AFTERMATH;
6738
- exports.AggregatorClient = AggregatorClient8;
6778
+ exports.AggregatorClient = AggregatorClient9;
6739
6779
  exports.BLUEMOVE = BLUEMOVE;
6740
6780
  exports.CETUS = CETUS;
6741
6781
  exports.CLOCK_ADDRESS = CLOCK_ADDRESS;
@@ -6750,6 +6790,7 @@ exports.KRIYA = KRIYA;
6750
6790
  exports.KRIYAV3 = KRIYAV3;
6751
6791
  exports.ONE = ONE;
6752
6792
  exports.SCALLOP = SCALLOP;
6793
+ exports.SUILEND = SUILEND;
6753
6794
  exports.TEN_POW_NINE = TEN_POW_NINE;
6754
6795
  exports.TURBOS = TURBOS;
6755
6796
  exports.TWO = TWO;
package/dist/index.d.cts 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.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
@@ -6072,6 +6072,35 @@ var Scallop = class {
6072
6072
  }
6073
6073
  };
6074
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
+ txb.object(CLOCK_ADDRESS)
6093
+ ];
6094
+ const res = txb.moveCall({
6095
+ target: `${client.publishedAtV2()}::suilend::${func}`,
6096
+ typeArguments: [springCoinType],
6097
+ arguments: args
6098
+ });
6099
+ return res;
6100
+ });
6101
+ }
6102
+ };
6103
+
6075
6104
  // src/client.ts
6076
6105
  var CETUS = "CETUS";
6077
6106
  var DEEPBOOKV2 = "DEEPBOOK";
@@ -6087,8 +6116,9 @@ var AFSUI = "AFSUI";
6087
6116
  var BLUEMOVE = "BLUEMOVE";
6088
6117
  var DEEPBOOKV3 = "DEEPBOOKV3";
6089
6118
  var SCALLOP = "SCALLOP";
6119
+ var SUILEND = "SUILEND";
6090
6120
  var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
6091
- var AggregatorClient8 = class {
6121
+ var AggregatorClient9 = class {
6092
6122
  constructor(endpoint, signer, client, env) {
6093
6123
  this.endpoint = endpoint ? processEndpoint(endpoint) : DEFAULT_ENDPOINT;
6094
6124
  this.client = client || new SuiClient({ url: getFullnodeUrl("mainnet") });
@@ -6231,7 +6261,15 @@ var AggregatorClient8 = class {
6231
6261
  }
6232
6262
  routerSwap(params) {
6233
6263
  return __async(this, null, function* () {
6234
- const { routers, inputCoin, slippage, byAmountIn, txb, partner, deepbookv3DeepFee } = params;
6264
+ const {
6265
+ routers,
6266
+ inputCoin,
6267
+ slippage,
6268
+ byAmountIn,
6269
+ txb,
6270
+ partner,
6271
+ deepbookv3DeepFee
6272
+ } = params;
6235
6273
  const amountIn = routers.reduce(
6236
6274
  (acc, router) => acc.add(router.amountIn),
6237
6275
  new import_bn5.default(0)
@@ -6357,7 +6395,7 @@ var AggregatorClient8 = class {
6357
6395
  // Include deepbookv3, scallop
6358
6396
  publishedAtV2() {
6359
6397
  if (this.env === 0 /* Mainnet */) {
6360
- return "0x6d70ffa7aa3f924c3f0b573d27d29895a0ee666aaff821073f75cb14af7fd01a";
6398
+ return "0xe1e3b5d3061053fbfa297690eb764eca730caf8a288d96f81e3d95fb7ae3b625";
6361
6399
  } else {
6362
6400
  return "0xfd8a73ef0a4b928da9c27fc287dc37c1ca64df71da8e8eac7ca9ece55eb5f448";
6363
6401
  }
@@ -6424,6 +6462,8 @@ var AggregatorClient8 = class {
6424
6462
  return new Bluemove(this.env);
6425
6463
  case SCALLOP:
6426
6464
  return new Scallop(this.env);
6465
+ case SUILEND:
6466
+ return new Suilend(this.env);
6427
6467
  default:
6428
6468
  throw new Error(`Unsupported dex ${provider}`);
6429
6469
  }
@@ -6641,7 +6681,7 @@ function getRouter(endpoint, params) {
6641
6681
  url += `&providers=${providers.join(",")}`;
6642
6682
  }
6643
6683
  }
6644
- url += "&v=1000304";
6684
+ url += "&v=1000307";
6645
6685
  const response = yield fetch(url);
6646
6686
  return response;
6647
6687
  } catch (error) {
@@ -6731,4 +6771,4 @@ decimal.js/decimal.mjs:
6731
6771
  *)
6732
6772
  */
6733
6773
 
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 };
6774
+ export { AFSUI, AFTERMATH, AggregatorClient9 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,6 +1,6 @@
1
1
  {
2
2
  "name": "@cetusprotocol/aggregator-sdk",
3
- "version": "0.0.0-experimental-20241121205059",
3
+ "version": "0.0.0-experimental-20241126185121",
4
4
  "sideEffects": false,
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
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=1000307"
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 "0xe1e3b5d3061053fbfa297690eb764eca730caf8a288d96f81e3d95fb7ae3b625" // mainnnet pre
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,53 @@
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
+ txb.object(CLOCK_ADDRESS),
43
+ ]
44
+
45
+ const res = txb.moveCall({
46
+ target: `${client.publishedAtV2()}::suilend::${func}`,
47
+ typeArguments: [springCoinType],
48
+ arguments: args,
49
+ }) as TransactionObjectArgument
50
+
51
+ return res
52
+ }
53
+ }