@cetusprotocol/aggregator-sdk 0.2.1 → 0.3.0

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.lockb CHANGED
Binary file
package/dist/index.d.mts CHANGED
@@ -71,6 +71,7 @@ declare const AFTERMATH = "AFTERMATH";
71
71
  declare const HAEDAL = "HAEDAL";
72
72
  declare const VOLO = "VOLO";
73
73
  declare const AFSUI = "AFSUI";
74
+ declare const BLUEMOVE = "BLUEMOVE";
74
75
  type BuildRouterSwapParams = {
75
76
  routers: Router[];
76
77
  byAmountIn: boolean;
@@ -165,11 +166,19 @@ interface FindRouterParams {
165
166
  splitFactor?: number;
166
167
  splitCount?: number;
167
168
  providers?: string[];
169
+ liquidityChanges?: PreSwapLpChangeParams[];
170
+ }
171
+ interface PreSwapLpChangeParams {
172
+ poolID: string;
173
+ ticklower: number;
174
+ tickUpper: number;
175
+ deltaLiquidity: number;
168
176
  }
169
177
  type ExtendedDetails = {
170
178
  aftermathPoolFlatness?: number;
171
179
  aftermathLpSupplyType?: string;
172
180
  turbosFeeType?: string;
181
+ afterSqrtPrice?: string;
173
182
  };
174
183
  type Path = {
175
184
  id: string;
@@ -212,4 +221,4 @@ declare enum Env {
212
221
  Testnet = 1
213
222
  }
214
223
 
215
- export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, KRIYA, KRIYAV3, ONE, type Path, type Router, type RouterData, type RouterError, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, restituteMsafeFastRouterSwapParams };
224
+ export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, BLUEMOVE, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, KRIYA, KRIYAV3, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, restituteMsafeFastRouterSwapParams };
package/dist/index.d.ts CHANGED
@@ -71,6 +71,7 @@ declare const AFTERMATH = "AFTERMATH";
71
71
  declare const HAEDAL = "HAEDAL";
72
72
  declare const VOLO = "VOLO";
73
73
  declare const AFSUI = "AFSUI";
74
+ declare const BLUEMOVE = "BLUEMOVE";
74
75
  type BuildRouterSwapParams = {
75
76
  routers: Router[];
76
77
  byAmountIn: boolean;
@@ -165,11 +166,19 @@ interface FindRouterParams {
165
166
  splitFactor?: number;
166
167
  splitCount?: number;
167
168
  providers?: string[];
169
+ liquidityChanges?: PreSwapLpChangeParams[];
170
+ }
171
+ interface PreSwapLpChangeParams {
172
+ poolID: string;
173
+ ticklower: number;
174
+ tickUpper: number;
175
+ deltaLiquidity: number;
168
176
  }
169
177
  type ExtendedDetails = {
170
178
  aftermathPoolFlatness?: number;
171
179
  aftermathLpSupplyType?: string;
172
180
  turbosFeeType?: string;
181
+ afterSqrtPrice?: string;
173
182
  };
174
183
  type Path = {
175
184
  id: string;
@@ -212,4 +221,4 @@ declare enum Env {
212
221
  Testnet = 1
213
222
  }
214
223
 
215
- export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, KRIYA, KRIYAV3, ONE, type Path, type Router, type RouterData, type RouterError, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, restituteMsafeFastRouterSwapParams };
224
+ export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, BLUEMOVE, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, KRIYA, KRIYAV3, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, restituteMsafeFastRouterSwapParams };
package/dist/index.js CHANGED
@@ -5145,6 +5145,34 @@ var KriyaV2 = class {
5145
5145
  }
5146
5146
  };
5147
5147
 
5148
+ // src/transaction/kriya_v3.ts
5149
+ var KriyaV3 = class {
5150
+ constructor(env) {
5151
+ if (env !== 0 /* Mainnet */) {
5152
+ throw new Error("Kriya clmm only supported on mainnet");
5153
+ }
5154
+ this.version = "0xf5145a7ac345ca8736cf8c76047d00d6d378f30e81be6f6eb557184d9de93c78";
5155
+ }
5156
+ swap(client, txb, path, inputCoin) {
5157
+ return __async(this, null, function* () {
5158
+ const { direction, from, target } = path;
5159
+ const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
5160
+ const args = [
5161
+ txb.object(path.id),
5162
+ inputCoin,
5163
+ txb.object(this.version),
5164
+ txb.object(CLOCK_ADDRESS)
5165
+ ];
5166
+ const res = txb.moveCall({
5167
+ target: `${client.publishedAt()}::kriya_clmm::${func}`,
5168
+ typeArguments: [coinAType, coinBType],
5169
+ arguments: args
5170
+ });
5171
+ return res;
5172
+ });
5173
+ }
5174
+ };
5175
+
5148
5176
  // src/transaction/flowx_v2.ts
5149
5177
  var FlowxV2 = class {
5150
5178
  constructor(env) {
@@ -5168,6 +5196,36 @@ var FlowxV2 = class {
5168
5196
  }
5169
5197
  };
5170
5198
 
5199
+ // src/transaction/flowx_v3.ts
5200
+ var FlowxV3 = class {
5201
+ constructor(env) {
5202
+ if (env !== 0 /* Mainnet */) {
5203
+ throw new Error("Flowx clmm only supported on mainnet");
5204
+ }
5205
+ this.versioned = "0x67624a1533b5aff5d0dfcf5e598684350efd38134d2d245f475524c03a64e656";
5206
+ this.poolRegistry = "0x27565d24a4cd51127ac90e4074a841bbe356cca7bf5759ddc14a975be1632abc";
5207
+ }
5208
+ swap(client, txb, path, inputCoin) {
5209
+ return __async(this, null, function* () {
5210
+ const { direction, from, target } = path;
5211
+ const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
5212
+ const args = [
5213
+ txb.object(this.poolRegistry),
5214
+ txb.pure.u64(path.feeRate * 1e6),
5215
+ inputCoin,
5216
+ txb.object(this.versioned),
5217
+ txb.object(CLOCK_ADDRESS)
5218
+ ];
5219
+ const res = txb.moveCall({
5220
+ target: `${client.publishedAt()}::flowx_clmm::${func}`,
5221
+ typeArguments: [coinAType, coinBType],
5222
+ arguments: args
5223
+ });
5224
+ return res;
5225
+ });
5226
+ }
5227
+ };
5228
+
5171
5229
  // src/transaction/turbos.ts
5172
5230
  var Turbos = class {
5173
5231
  constructor(env) {
@@ -5207,7 +5265,7 @@ var Turbos = class {
5207
5265
  var Cetus = class {
5208
5266
  constructor(env, partner) {
5209
5267
  this.globalConfig = env === 0 /* Mainnet */ ? "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f" : "0x6f4149091a5aea0e818e7243a13adcfb403842d670b9a2089de058512620687a";
5210
- this.partner = partner != null ? partner : "0x639b5e433da31739e800cd085f356e64cae222966d0f1b11bd9dc76b322ff58b";
5268
+ this.partner = (partner != null ? partner : env === 0 /* Mainnet */) ? "0x639b5e433da31739e800cd085f356e64cae222966d0f1b11bd9dc76b322ff58b" : "0x8e0b7668a79592f70fbfb1ae0aebaf9e2019a7049783b9a4b6fe7c6ae038b528";
5211
5269
  }
5212
5270
  flash_swap(client, txb, path, by_amount_in) {
5213
5271
  const { direction, from, target } = path;
@@ -5797,7 +5855,10 @@ function swapInPools(client, params, sender) {
5797
5855
  target: targetCoin,
5798
5856
  feeRate: event.fee_rate,
5799
5857
  amountIn: event.amount_in,
5800
- amountOut: event.amount_out
5858
+ amountOut: event.amount_out,
5859
+ extendedDetails: {
5860
+ afterSqrtPrice: event.after_sqrt_price
5861
+ }
5801
5862
  }
5802
5863
  ],
5803
5864
  amountIn: new import_bn4.BN((_d = event.amount_in) != null ? _d : 0),
@@ -5815,34 +5876,6 @@ function swapInPools(client, params, sender) {
5815
5876
  });
5816
5877
  }
5817
5878
 
5818
- // src/transaction/kriya_v3.ts
5819
- var KriyaV3 = class {
5820
- constructor(env) {
5821
- if (env !== 0 /* Mainnet */) {
5822
- throw new Error("Kriya clmm only supported on mainnet");
5823
- }
5824
- this.version = "0xf5145a7ac345ca8736cf8c76047d00d6d378f30e81be6f6eb557184d9de93c78";
5825
- }
5826
- swap(client, txb, path, inputCoin) {
5827
- return __async(this, null, function* () {
5828
- const { direction, from, target } = path;
5829
- const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
5830
- const args = [
5831
- txb.object(path.id),
5832
- inputCoin,
5833
- txb.object(this.version),
5834
- txb.object(CLOCK_ADDRESS)
5835
- ];
5836
- const res = txb.moveCall({
5837
- target: `${client.publishedAt()}::kriya_clmm::${func}`,
5838
- typeArguments: [coinAType, coinBType],
5839
- arguments: args
5840
- });
5841
- return res;
5842
- });
5843
- }
5844
- };
5845
-
5846
5879
  // src/transaction/haedal.ts
5847
5880
  var Haedal = class {
5848
5881
  constructor(env) {
@@ -5936,28 +5969,21 @@ var Volo = class {
5936
5969
  }
5937
5970
  };
5938
5971
 
5939
- // src/transaction/flowx_v3.ts
5940
- var FlowxV3 = class {
5972
+ // src/transaction/bluemove.ts
5973
+ var Bluemove = class {
5941
5974
  constructor(env) {
5942
5975
  if (env !== 0 /* Mainnet */) {
5943
- throw new Error("Flowx clmm only supported on mainnet");
5976
+ throw new Error("Bluemove only supported on mainnet");
5944
5977
  }
5945
- this.versioned = "0x67624a1533b5aff5d0dfcf5e598684350efd38134d2d245f475524c03a64e656";
5946
- this.poolRegistry = "0x27565d24a4cd51127ac90e4074a841bbe356cca7bf5759ddc14a975be1632abc";
5978
+ this.dexInfo = "0x3f2d9f724f4a1ce5e71676448dc452be9a6243dac9c5b975a588c8c867066e92";
5947
5979
  }
5948
5980
  swap(client, txb, path, inputCoin) {
5949
5981
  return __async(this, null, function* () {
5950
5982
  const { direction, from, target } = path;
5951
5983
  const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
5952
- const args = [
5953
- txb.object(this.poolRegistry),
5954
- txb.pure.u64(path.feeRate * 1e6),
5955
- inputCoin,
5956
- txb.object(this.versioned),
5957
- txb.object(CLOCK_ADDRESS)
5958
- ];
5984
+ const args = [txb.object(this.dexInfo), inputCoin];
5959
5985
  const res = txb.moveCall({
5960
- target: `${client.publishedAt()}::flowx_clmm::${func}`,
5986
+ target: `${client.publishedAt()}::bluemove::${func}`,
5961
5987
  typeArguments: [coinAType, coinBType],
5962
5988
  arguments: args
5963
5989
  });
@@ -5978,6 +6004,7 @@ var AFTERMATH = "AFTERMATH";
5978
6004
  var HAEDAL = "HAEDAL";
5979
6005
  var VOLO = "VOLO";
5980
6006
  var AFSUI = "AFSUI";
6007
+ var BLUEMOVE = "BLUEMOVE";
5981
6008
  var AggregatorClient6 = class {
5982
6009
  constructor(endpoint, signer, client, env) {
5983
6010
  this.endpoint = endpoint;
@@ -6215,9 +6242,9 @@ var AggregatorClient6 = class {
6215
6242
  }
6216
6243
  publishedAt() {
6217
6244
  if (this.env === 0 /* Mainnet */) {
6218
- return "0xeffc8ae61f439bb34c9b905ff8f29ec56873dcedf81c7123ff2f1f67c45ec302";
6245
+ return "0x764b8132a94d35abc9dfd91b23a0757b2a717d5ecb04c03098794aa2a508db91";
6219
6246
  } else {
6220
- return "0x0";
6247
+ return "0x6cbaa3e9fbe902d90191b12f315932bc58079cba422bafbd4b4369f80e61f595";
6221
6248
  }
6222
6249
  }
6223
6250
  transferOrDestoryCoin(txb, coin, coinType) {
@@ -6269,6 +6296,8 @@ var AggregatorClient6 = class {
6269
6296
  return new Afsui(this.env);
6270
6297
  case VOLO:
6271
6298
  return new Volo(this.env);
6299
+ case BLUEMOVE:
6300
+ return new Bluemove(this.env);
6272
6301
  default:
6273
6302
  throw new Error(`Unsupported dex ${provider}`);
6274
6303
  }
@@ -6315,16 +6344,17 @@ function parseRouterResponse(data) {
6315
6344
  routes: data.routes.map((route) => {
6316
6345
  return {
6317
6346
  path: route.path.map((path) => {
6318
- var _a, _b;
6347
+ var _a, _b, _c;
6319
6348
  let version;
6320
6349
  if (path.provider === AFTERMATH) {
6321
6350
  version = path.extended_details.aftermath_pool_flatness === 0 ? "v2" : "v3";
6322
6351
  }
6323
6352
  let extendedDetails;
6324
- if (path.provider === TURBOS || path.provider === AFTERMATH) {
6353
+ if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS) {
6325
6354
  extendedDetails = {
6326
6355
  aftermathLpSupplyType: (_a = path.extended_details) == null ? void 0 : _a.aftermath_lp_supply_type,
6327
- turbosFeeType: (_b = path.extended_details) == null ? void 0 : _b.turbos_fee_type
6356
+ turbosFeeType: (_b = path.extended_details) == null ? void 0 : _b.turbos_fee_type,
6357
+ afterSqrtPrice: (_c = path.extended_details) == null ? void 0 : _c.after_sqrt_price
6328
6358
  };
6329
6359
  }
6330
6360
  return {
@@ -6379,38 +6409,15 @@ var restituteMsafeFastRouterSwapParams = (data) => {
6379
6409
  // src/api.ts
6380
6410
  function getRouterResult(endpoint, params) {
6381
6411
  return __async(this, null, function* () {
6382
- const {
6383
- from,
6384
- target,
6385
- amount,
6386
- byAmountIn,
6387
- depth,
6388
- splitAlgorithm,
6389
- splitFactor,
6390
- splitCount,
6391
- providers
6392
- } = params;
6393
- const fromCoin = completionCoin(from);
6394
- const targetCoin = completionCoin(target);
6395
- let url = `${endpoint}?from=${fromCoin}&target=${targetCoin}&amount=${amount.toString()}&by_amount_in=${byAmountIn}`;
6396
- if (depth) {
6397
- url += `&depth=${depth}`;
6398
- }
6399
- if (splitAlgorithm) {
6400
- url += `&split_algorithm=${splitAlgorithm}`;
6401
- }
6402
- if (splitFactor) {
6403
- url += `&split_factor=${splitFactor}`;
6404
- }
6405
- if (splitCount) {
6406
- url += `&split_count=${splitCount}`;
6412
+ let response;
6413
+ if (params.liquidityChanges && params.liquidityChanges.length > 0) {
6414
+ response = yield postRouterWithLiquidityChanges(endpoint, params);
6415
+ } else {
6416
+ response = yield getRouter(endpoint, params);
6407
6417
  }
6408
- if (providers) {
6409
- if (providers.length > 0) {
6410
- url += `&providers=${providers.join(",")}`;
6411
- }
6418
+ if (!response) {
6419
+ return null;
6412
6420
  }
6413
- const response = yield fetch(url);
6414
6421
  if (!response.ok) {
6415
6422
  return {
6416
6423
  amountIn: ZERO,
@@ -6445,6 +6452,99 @@ function getRouterResult(endpoint, params) {
6445
6452
  };
6446
6453
  });
6447
6454
  }
6455
+ function getRouter(endpoint, params) {
6456
+ return __async(this, null, function* () {
6457
+ try {
6458
+ const {
6459
+ from,
6460
+ target,
6461
+ amount,
6462
+ byAmountIn,
6463
+ depth,
6464
+ splitAlgorithm,
6465
+ splitFactor,
6466
+ splitCount,
6467
+ providers
6468
+ } = params;
6469
+ const fromCoin = completionCoin(from);
6470
+ const targetCoin = completionCoin(target);
6471
+ let url = `${endpoint}?from=${fromCoin}&target=${targetCoin}&amount=${amount.toString()}&by_amount_in=${byAmountIn}`;
6472
+ if (depth) {
6473
+ url += `&depth=${depth}`;
6474
+ }
6475
+ if (splitAlgorithm) {
6476
+ url += `&split_algorithm=${splitAlgorithm}`;
6477
+ }
6478
+ if (splitFactor) {
6479
+ url += `&split_factor=${splitFactor}`;
6480
+ }
6481
+ if (splitCount) {
6482
+ url += `&split_count=${splitCount}`;
6483
+ }
6484
+ if (providers) {
6485
+ if (providers.length > 0) {
6486
+ url += `&providers=${providers.join(",")}`;
6487
+ }
6488
+ }
6489
+ const response = yield fetch(url);
6490
+ return response;
6491
+ } catch (error) {
6492
+ console.error(error);
6493
+ return null;
6494
+ }
6495
+ });
6496
+ }
6497
+ function postRouterWithLiquidityChanges(endpoint, params) {
6498
+ return __async(this, null, function* () {
6499
+ const {
6500
+ from,
6501
+ target,
6502
+ amount,
6503
+ byAmountIn,
6504
+ depth,
6505
+ splitAlgorithm,
6506
+ splitFactor,
6507
+ splitCount,
6508
+ providers,
6509
+ liquidityChanges
6510
+ } = params;
6511
+ const fromCoin = completionCoin(from);
6512
+ const targetCoin = completionCoin(target);
6513
+ const url = `${endpoint}`;
6514
+ const providersStr = providers == null ? void 0 : providers.join(",");
6515
+ const requestData = {
6516
+ from: fromCoin,
6517
+ target: targetCoin,
6518
+ amount: Number(amount.toString()),
6519
+ by_amount_in: byAmountIn,
6520
+ depth,
6521
+ split_algorithm: splitAlgorithm,
6522
+ split_factor: splitFactor,
6523
+ split_count: splitCount,
6524
+ providers: providersStr,
6525
+ liquidity_changes: liquidityChanges.map((change) => ({
6526
+ pool: change.poolID,
6527
+ tick_lower: change.ticklower,
6528
+ tick_upper: change.tickUpper,
6529
+ delta_liquidity: change.deltaLiquidity
6530
+ }))
6531
+ };
6532
+ console.log("requestData", JSON.stringify(requestData, null, 2));
6533
+ try {
6534
+ const response = yield fetch(url, {
6535
+ method: "POST",
6536
+ headers: {
6537
+ "Content-Type": "application/json"
6538
+ },
6539
+ body: JSON.stringify(requestData)
6540
+ });
6541
+ return response;
6542
+ } catch (error) {
6543
+ console.error("Error:", error);
6544
+ return null;
6545
+ }
6546
+ });
6547
+ }
6448
6548
 
6449
6549
  // src/index.ts
6450
6550
  var Env = /* @__PURE__ */ ((Env2) => {
@@ -6467,6 +6567,7 @@ decimal.js/decimal.mjs:
6467
6567
  exports.AFSUI = AFSUI;
6468
6568
  exports.AFTERMATH = AFTERMATH;
6469
6569
  exports.AggregatorClient = AggregatorClient6;
6570
+ exports.BLUEMOVE = BLUEMOVE;
6470
6571
  exports.CETUS = CETUS;
6471
6572
  exports.CLOCK_ADDRESS = CLOCK_ADDRESS;
6472
6573
  exports.DEEPBOOKV2 = DEEPBOOKV2;
package/dist/index.mjs CHANGED
@@ -5143,6 +5143,34 @@ var KriyaV2 = class {
5143
5143
  }
5144
5144
  };
5145
5145
 
5146
+ // src/transaction/kriya_v3.ts
5147
+ var KriyaV3 = class {
5148
+ constructor(env) {
5149
+ if (env !== 0 /* Mainnet */) {
5150
+ throw new Error("Kriya clmm only supported on mainnet");
5151
+ }
5152
+ this.version = "0xf5145a7ac345ca8736cf8c76047d00d6d378f30e81be6f6eb557184d9de93c78";
5153
+ }
5154
+ swap(client, txb, path, inputCoin) {
5155
+ return __async(this, null, function* () {
5156
+ const { direction, from, target } = path;
5157
+ const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
5158
+ const args = [
5159
+ txb.object(path.id),
5160
+ inputCoin,
5161
+ txb.object(this.version),
5162
+ txb.object(CLOCK_ADDRESS)
5163
+ ];
5164
+ const res = txb.moveCall({
5165
+ target: `${client.publishedAt()}::kriya_clmm::${func}`,
5166
+ typeArguments: [coinAType, coinBType],
5167
+ arguments: args
5168
+ });
5169
+ return res;
5170
+ });
5171
+ }
5172
+ };
5173
+
5146
5174
  // src/transaction/flowx_v2.ts
5147
5175
  var FlowxV2 = class {
5148
5176
  constructor(env) {
@@ -5166,6 +5194,36 @@ var FlowxV2 = class {
5166
5194
  }
5167
5195
  };
5168
5196
 
5197
+ // src/transaction/flowx_v3.ts
5198
+ var FlowxV3 = class {
5199
+ constructor(env) {
5200
+ if (env !== 0 /* Mainnet */) {
5201
+ throw new Error("Flowx clmm only supported on mainnet");
5202
+ }
5203
+ this.versioned = "0x67624a1533b5aff5d0dfcf5e598684350efd38134d2d245f475524c03a64e656";
5204
+ this.poolRegistry = "0x27565d24a4cd51127ac90e4074a841bbe356cca7bf5759ddc14a975be1632abc";
5205
+ }
5206
+ swap(client, txb, path, inputCoin) {
5207
+ return __async(this, null, function* () {
5208
+ const { direction, from, target } = path;
5209
+ const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
5210
+ const args = [
5211
+ txb.object(this.poolRegistry),
5212
+ txb.pure.u64(path.feeRate * 1e6),
5213
+ inputCoin,
5214
+ txb.object(this.versioned),
5215
+ txb.object(CLOCK_ADDRESS)
5216
+ ];
5217
+ const res = txb.moveCall({
5218
+ target: `${client.publishedAt()}::flowx_clmm::${func}`,
5219
+ typeArguments: [coinAType, coinBType],
5220
+ arguments: args
5221
+ });
5222
+ return res;
5223
+ });
5224
+ }
5225
+ };
5226
+
5169
5227
  // src/transaction/turbos.ts
5170
5228
  var Turbos = class {
5171
5229
  constructor(env) {
@@ -5205,7 +5263,7 @@ var Turbos = class {
5205
5263
  var Cetus = class {
5206
5264
  constructor(env, partner) {
5207
5265
  this.globalConfig = env === 0 /* Mainnet */ ? "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f" : "0x6f4149091a5aea0e818e7243a13adcfb403842d670b9a2089de058512620687a";
5208
- this.partner = partner != null ? partner : "0x639b5e433da31739e800cd085f356e64cae222966d0f1b11bd9dc76b322ff58b";
5266
+ this.partner = (partner != null ? partner : env === 0 /* Mainnet */) ? "0x639b5e433da31739e800cd085f356e64cae222966d0f1b11bd9dc76b322ff58b" : "0x8e0b7668a79592f70fbfb1ae0aebaf9e2019a7049783b9a4b6fe7c6ae038b528";
5209
5267
  }
5210
5268
  flash_swap(client, txb, path, by_amount_in) {
5211
5269
  const { direction, from, target } = path;
@@ -5795,7 +5853,10 @@ function swapInPools(client, params, sender) {
5795
5853
  target: targetCoin,
5796
5854
  feeRate: event.fee_rate,
5797
5855
  amountIn: event.amount_in,
5798
- amountOut: event.amount_out
5856
+ amountOut: event.amount_out,
5857
+ extendedDetails: {
5858
+ afterSqrtPrice: event.after_sqrt_price
5859
+ }
5799
5860
  }
5800
5861
  ],
5801
5862
  amountIn: new import_bn4.BN((_d = event.amount_in) != null ? _d : 0),
@@ -5813,34 +5874,6 @@ function swapInPools(client, params, sender) {
5813
5874
  });
5814
5875
  }
5815
5876
 
5816
- // src/transaction/kriya_v3.ts
5817
- var KriyaV3 = class {
5818
- constructor(env) {
5819
- if (env !== 0 /* Mainnet */) {
5820
- throw new Error("Kriya clmm only supported on mainnet");
5821
- }
5822
- this.version = "0xf5145a7ac345ca8736cf8c76047d00d6d378f30e81be6f6eb557184d9de93c78";
5823
- }
5824
- swap(client, txb, path, inputCoin) {
5825
- return __async(this, null, function* () {
5826
- const { direction, from, target } = path;
5827
- const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
5828
- const args = [
5829
- txb.object(path.id),
5830
- inputCoin,
5831
- txb.object(this.version),
5832
- txb.object(CLOCK_ADDRESS)
5833
- ];
5834
- const res = txb.moveCall({
5835
- target: `${client.publishedAt()}::kriya_clmm::${func}`,
5836
- typeArguments: [coinAType, coinBType],
5837
- arguments: args
5838
- });
5839
- return res;
5840
- });
5841
- }
5842
- };
5843
-
5844
5877
  // src/transaction/haedal.ts
5845
5878
  var Haedal = class {
5846
5879
  constructor(env) {
@@ -5934,28 +5967,21 @@ var Volo = class {
5934
5967
  }
5935
5968
  };
5936
5969
 
5937
- // src/transaction/flowx_v3.ts
5938
- var FlowxV3 = class {
5970
+ // src/transaction/bluemove.ts
5971
+ var Bluemove = class {
5939
5972
  constructor(env) {
5940
5973
  if (env !== 0 /* Mainnet */) {
5941
- throw new Error("Flowx clmm only supported on mainnet");
5974
+ throw new Error("Bluemove only supported on mainnet");
5942
5975
  }
5943
- this.versioned = "0x67624a1533b5aff5d0dfcf5e598684350efd38134d2d245f475524c03a64e656";
5944
- this.poolRegistry = "0x27565d24a4cd51127ac90e4074a841bbe356cca7bf5759ddc14a975be1632abc";
5976
+ this.dexInfo = "0x3f2d9f724f4a1ce5e71676448dc452be9a6243dac9c5b975a588c8c867066e92";
5945
5977
  }
5946
5978
  swap(client, txb, path, inputCoin) {
5947
5979
  return __async(this, null, function* () {
5948
5980
  const { direction, from, target } = path;
5949
5981
  const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
5950
- const args = [
5951
- txb.object(this.poolRegistry),
5952
- txb.pure.u64(path.feeRate * 1e6),
5953
- inputCoin,
5954
- txb.object(this.versioned),
5955
- txb.object(CLOCK_ADDRESS)
5956
- ];
5982
+ const args = [txb.object(this.dexInfo), inputCoin];
5957
5983
  const res = txb.moveCall({
5958
- target: `${client.publishedAt()}::flowx_clmm::${func}`,
5984
+ target: `${client.publishedAt()}::bluemove::${func}`,
5959
5985
  typeArguments: [coinAType, coinBType],
5960
5986
  arguments: args
5961
5987
  });
@@ -5976,6 +6002,7 @@ var AFTERMATH = "AFTERMATH";
5976
6002
  var HAEDAL = "HAEDAL";
5977
6003
  var VOLO = "VOLO";
5978
6004
  var AFSUI = "AFSUI";
6005
+ var BLUEMOVE = "BLUEMOVE";
5979
6006
  var AggregatorClient6 = class {
5980
6007
  constructor(endpoint, signer, client, env) {
5981
6008
  this.endpoint = endpoint;
@@ -6213,9 +6240,9 @@ var AggregatorClient6 = class {
6213
6240
  }
6214
6241
  publishedAt() {
6215
6242
  if (this.env === 0 /* Mainnet */) {
6216
- return "0xeffc8ae61f439bb34c9b905ff8f29ec56873dcedf81c7123ff2f1f67c45ec302";
6243
+ return "0x764b8132a94d35abc9dfd91b23a0757b2a717d5ecb04c03098794aa2a508db91";
6217
6244
  } else {
6218
- return "0x0";
6245
+ return "0x6cbaa3e9fbe902d90191b12f315932bc58079cba422bafbd4b4369f80e61f595";
6219
6246
  }
6220
6247
  }
6221
6248
  transferOrDestoryCoin(txb, coin, coinType) {
@@ -6267,6 +6294,8 @@ var AggregatorClient6 = class {
6267
6294
  return new Afsui(this.env);
6268
6295
  case VOLO:
6269
6296
  return new Volo(this.env);
6297
+ case BLUEMOVE:
6298
+ return new Bluemove(this.env);
6270
6299
  default:
6271
6300
  throw new Error(`Unsupported dex ${provider}`);
6272
6301
  }
@@ -6313,16 +6342,17 @@ function parseRouterResponse(data) {
6313
6342
  routes: data.routes.map((route) => {
6314
6343
  return {
6315
6344
  path: route.path.map((path) => {
6316
- var _a, _b;
6345
+ var _a, _b, _c;
6317
6346
  let version;
6318
6347
  if (path.provider === AFTERMATH) {
6319
6348
  version = path.extended_details.aftermath_pool_flatness === 0 ? "v2" : "v3";
6320
6349
  }
6321
6350
  let extendedDetails;
6322
- if (path.provider === TURBOS || path.provider === AFTERMATH) {
6351
+ if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS) {
6323
6352
  extendedDetails = {
6324
6353
  aftermathLpSupplyType: (_a = path.extended_details) == null ? void 0 : _a.aftermath_lp_supply_type,
6325
- turbosFeeType: (_b = path.extended_details) == null ? void 0 : _b.turbos_fee_type
6354
+ turbosFeeType: (_b = path.extended_details) == null ? void 0 : _b.turbos_fee_type,
6355
+ afterSqrtPrice: (_c = path.extended_details) == null ? void 0 : _c.after_sqrt_price
6326
6356
  };
6327
6357
  }
6328
6358
  return {
@@ -6377,38 +6407,15 @@ var restituteMsafeFastRouterSwapParams = (data) => {
6377
6407
  // src/api.ts
6378
6408
  function getRouterResult(endpoint, params) {
6379
6409
  return __async(this, null, function* () {
6380
- const {
6381
- from,
6382
- target,
6383
- amount,
6384
- byAmountIn,
6385
- depth,
6386
- splitAlgorithm,
6387
- splitFactor,
6388
- splitCount,
6389
- providers
6390
- } = params;
6391
- const fromCoin = completionCoin(from);
6392
- const targetCoin = completionCoin(target);
6393
- let url = `${endpoint}?from=${fromCoin}&target=${targetCoin}&amount=${amount.toString()}&by_amount_in=${byAmountIn}`;
6394
- if (depth) {
6395
- url += `&depth=${depth}`;
6396
- }
6397
- if (splitAlgorithm) {
6398
- url += `&split_algorithm=${splitAlgorithm}`;
6399
- }
6400
- if (splitFactor) {
6401
- url += `&split_factor=${splitFactor}`;
6402
- }
6403
- if (splitCount) {
6404
- url += `&split_count=${splitCount}`;
6410
+ let response;
6411
+ if (params.liquidityChanges && params.liquidityChanges.length > 0) {
6412
+ response = yield postRouterWithLiquidityChanges(endpoint, params);
6413
+ } else {
6414
+ response = yield getRouter(endpoint, params);
6405
6415
  }
6406
- if (providers) {
6407
- if (providers.length > 0) {
6408
- url += `&providers=${providers.join(",")}`;
6409
- }
6416
+ if (!response) {
6417
+ return null;
6410
6418
  }
6411
- const response = yield fetch(url);
6412
6419
  if (!response.ok) {
6413
6420
  return {
6414
6421
  amountIn: ZERO,
@@ -6443,6 +6450,99 @@ function getRouterResult(endpoint, params) {
6443
6450
  };
6444
6451
  });
6445
6452
  }
6453
+ function getRouter(endpoint, params) {
6454
+ return __async(this, null, function* () {
6455
+ try {
6456
+ const {
6457
+ from,
6458
+ target,
6459
+ amount,
6460
+ byAmountIn,
6461
+ depth,
6462
+ splitAlgorithm,
6463
+ splitFactor,
6464
+ splitCount,
6465
+ providers
6466
+ } = params;
6467
+ const fromCoin = completionCoin(from);
6468
+ const targetCoin = completionCoin(target);
6469
+ let url = `${endpoint}?from=${fromCoin}&target=${targetCoin}&amount=${amount.toString()}&by_amount_in=${byAmountIn}`;
6470
+ if (depth) {
6471
+ url += `&depth=${depth}`;
6472
+ }
6473
+ if (splitAlgorithm) {
6474
+ url += `&split_algorithm=${splitAlgorithm}`;
6475
+ }
6476
+ if (splitFactor) {
6477
+ url += `&split_factor=${splitFactor}`;
6478
+ }
6479
+ if (splitCount) {
6480
+ url += `&split_count=${splitCount}`;
6481
+ }
6482
+ if (providers) {
6483
+ if (providers.length > 0) {
6484
+ url += `&providers=${providers.join(",")}`;
6485
+ }
6486
+ }
6487
+ const response = yield fetch(url);
6488
+ return response;
6489
+ } catch (error) {
6490
+ console.error(error);
6491
+ return null;
6492
+ }
6493
+ });
6494
+ }
6495
+ function postRouterWithLiquidityChanges(endpoint, params) {
6496
+ return __async(this, null, function* () {
6497
+ const {
6498
+ from,
6499
+ target,
6500
+ amount,
6501
+ byAmountIn,
6502
+ depth,
6503
+ splitAlgorithm,
6504
+ splitFactor,
6505
+ splitCount,
6506
+ providers,
6507
+ liquidityChanges
6508
+ } = params;
6509
+ const fromCoin = completionCoin(from);
6510
+ const targetCoin = completionCoin(target);
6511
+ const url = `${endpoint}`;
6512
+ const providersStr = providers == null ? void 0 : providers.join(",");
6513
+ const requestData = {
6514
+ from: fromCoin,
6515
+ target: targetCoin,
6516
+ amount: Number(amount.toString()),
6517
+ by_amount_in: byAmountIn,
6518
+ depth,
6519
+ split_algorithm: splitAlgorithm,
6520
+ split_factor: splitFactor,
6521
+ split_count: splitCount,
6522
+ providers: providersStr,
6523
+ liquidity_changes: liquidityChanges.map((change) => ({
6524
+ pool: change.poolID,
6525
+ tick_lower: change.ticklower,
6526
+ tick_upper: change.tickUpper,
6527
+ delta_liquidity: change.deltaLiquidity
6528
+ }))
6529
+ };
6530
+ console.log("requestData", JSON.stringify(requestData, null, 2));
6531
+ try {
6532
+ const response = yield fetch(url, {
6533
+ method: "POST",
6534
+ headers: {
6535
+ "Content-Type": "application/json"
6536
+ },
6537
+ body: JSON.stringify(requestData)
6538
+ });
6539
+ return response;
6540
+ } catch (error) {
6541
+ console.error("Error:", error);
6542
+ return null;
6543
+ }
6544
+ });
6545
+ }
6446
6546
 
6447
6547
  // src/index.ts
6448
6548
  var Env = /* @__PURE__ */ ((Env2) => {
@@ -6462,4 +6562,4 @@ decimal.js/decimal.mjs:
6462
6562
  *)
6463
6563
  */
6464
6564
 
6465
- export { AFSUI, AFTERMATH, AggregatorClient6 as AggregatorClient, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, Env, FLOWXV2, FLOWXV3, HAEDAL, KRIYA, KRIYAV3, ONE, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, restituteMsafeFastRouterSwapParams };
6565
+ export { AFSUI, AFTERMATH, AggregatorClient6 as AggregatorClient, BLUEMOVE, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, Env, FLOWXV2, FLOWXV3, HAEDAL, KRIYA, KRIYAV3, ONE, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, restituteMsafeFastRouterSwapParams };
package/dist/src/api.d.ts CHANGED
@@ -10,11 +10,19 @@ export interface FindRouterParams {
10
10
  splitFactor?: number;
11
11
  splitCount?: number;
12
12
  providers?: string[];
13
+ liquidityChanges?: PreSwapLpChangeParams[];
14
+ }
15
+ export interface PreSwapLpChangeParams {
16
+ poolID: string;
17
+ ticklower: number;
18
+ tickUpper: number;
19
+ deltaLiquidity: number;
13
20
  }
14
21
  export type ExtendedDetails = {
15
22
  aftermathPoolFlatness?: number;
16
23
  aftermathLpSupplyType?: string;
17
24
  turbosFeeType?: string;
25
+ afterSqrtPrice?: string;
18
26
  };
19
27
  export type Path = {
20
28
  id: string;
@@ -15,6 +15,7 @@ export declare const AFTERMATH = "AFTERMATH";
15
15
  export declare const HAEDAL = "HAEDAL";
16
16
  export declare const VOLO = "VOLO";
17
17
  export declare const AFSUI = "AFSUI";
18
+ export declare const BLUEMOVE = "BLUEMOVE";
18
19
  export type BuildRouterSwapParams = {
19
20
  routers: Router[];
20
21
  byAmountIn: boolean;
@@ -0,0 +1,7 @@
1
+ import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
2
+ import { AggregatorClient, Dex, Env, Path } from "..";
3
+ export declare class Bluemove implements Dex {
4
+ private dexInfo;
5
+ constructor(env: Env);
6
+ swap(client: AggregatorClient, txb: Transaction, path: Path, inputCoin: TransactionObjectArgument): Promise<TransactionObjectArgument>;
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cetusprotocol/aggregator-sdk",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "sideEffects": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/api.ts CHANGED
@@ -18,12 +18,21 @@ export interface FindRouterParams {
18
18
  splitFactor?: number
19
19
  splitCount?: number
20
20
  providers?: string[]
21
+ liquidityChanges?: PreSwapLpChangeParams[]
22
+ }
23
+
24
+ export interface PreSwapLpChangeParams {
25
+ poolID: string
26
+ ticklower: number
27
+ tickUpper: number
28
+ deltaLiquidity: number
21
29
  }
22
30
 
23
31
  export type ExtendedDetails = {
24
32
  aftermathPoolFlatness?: number
25
33
  aftermathLpSupplyType?: string
26
34
  turbosFeeType?: string
35
+ afterSqrtPrice?: string
27
36
  }
28
37
 
29
38
  export type Path = {
@@ -69,45 +78,17 @@ export async function getRouterResult(
69
78
  endpoint: string,
70
79
  params: FindRouterParams
71
80
  ): Promise<RouterData | null> {
72
- const {
73
- from,
74
- target,
75
- amount,
76
- byAmountIn,
77
- depth,
78
- splitAlgorithm,
79
- splitFactor,
80
- splitCount,
81
- providers,
82
- } = params
83
- const fromCoin = completionCoin(from)
84
- const targetCoin = completionCoin(target)
85
-
86
- let url = `${endpoint}?from=${fromCoin}&target=${targetCoin}&amount=${amount.toString()}&by_amount_in=${byAmountIn}`
87
-
88
- if (depth) {
89
- url += `&depth=${depth}`
81
+ let response
82
+ if (params.liquidityChanges && params.liquidityChanges.length > 0) {
83
+ response = await postRouterWithLiquidityChanges(endpoint, params)
84
+ } else {
85
+ response = await getRouter(endpoint, params)
90
86
  }
91
87
 
92
- if (splitAlgorithm) {
93
- url += `&split_algorithm=${splitAlgorithm}`
88
+ if (!response) {
89
+ return null
94
90
  }
95
91
 
96
- if (splitFactor) {
97
- url += `&split_factor=${splitFactor}`
98
- }
99
-
100
- if (splitCount) {
101
- url += `&split_count=${splitCount}`
102
- }
103
-
104
- if (providers) {
105
- if (providers.length > 0) {
106
- url += `&providers=${providers.join(",")}`
107
- }
108
- }
109
-
110
- const response = await fetch(url)
111
92
  if (!response.ok) {
112
93
  return {
113
94
  amountIn: ZERO,
@@ -142,3 +123,111 @@ export async function getRouterResult(
142
123
  },
143
124
  }
144
125
  }
126
+
127
+ async function getRouter(endpoint: string, params: FindRouterParams) {
128
+ try {
129
+ const {
130
+ from,
131
+ target,
132
+ amount,
133
+ byAmountIn,
134
+ depth,
135
+ splitAlgorithm,
136
+ splitFactor,
137
+ splitCount,
138
+ providers,
139
+ } = params
140
+ const fromCoin = completionCoin(from)
141
+ const targetCoin = completionCoin(target)
142
+
143
+ let url = `${endpoint}?from=${fromCoin}&target=${targetCoin}&amount=${amount.toString()}&by_amount_in=${byAmountIn}`
144
+
145
+ if (depth) {
146
+ url += `&depth=${depth}`
147
+ }
148
+
149
+ if (splitAlgorithm) {
150
+ url += `&split_algorithm=${splitAlgorithm}`
151
+ }
152
+
153
+ if (splitFactor) {
154
+ url += `&split_factor=${splitFactor}`
155
+ }
156
+
157
+ if (splitCount) {
158
+ url += `&split_count=${splitCount}`
159
+ }
160
+
161
+ if (providers) {
162
+ if (providers.length > 0) {
163
+ url += `&providers=${providers.join(",")}`
164
+ }
165
+ }
166
+
167
+ const response = await fetch(url)
168
+ return response
169
+ } catch (error) {
170
+ console.error(error)
171
+ return null
172
+ }
173
+ }
174
+
175
+ async function postRouterWithLiquidityChanges(
176
+ endpoint: string,
177
+ params: FindRouterParams
178
+ ) {
179
+ const {
180
+ from,
181
+ target,
182
+ amount,
183
+ byAmountIn,
184
+ depth,
185
+ splitAlgorithm,
186
+ splitFactor,
187
+ splitCount,
188
+ providers,
189
+ liquidityChanges,
190
+ } = params
191
+
192
+ const fromCoin = completionCoin(from)
193
+ const targetCoin = completionCoin(target)
194
+
195
+ const url = `${endpoint}`
196
+
197
+ const providersStr = providers?.join(",")
198
+
199
+ const requestData = {
200
+ from: fromCoin,
201
+ target: targetCoin,
202
+ amount: Number(amount.toString()),
203
+ by_amount_in: byAmountIn,
204
+ depth,
205
+ split_algorithm: splitAlgorithm,
206
+ split_factor: splitFactor,
207
+ split_count: splitCount,
208
+ providers: providersStr,
209
+ liquidity_changes: liquidityChanges!.map((change) => ({
210
+ pool: change.poolID,
211
+ tick_lower: change.ticklower,
212
+ tick_upper: change.tickUpper,
213
+ delta_liquidity: change.deltaLiquidity,
214
+ })),
215
+ }
216
+
217
+ console.log("requestData", JSON.stringify(requestData, null, 2))
218
+
219
+ try {
220
+ const response = await fetch(url, {
221
+ method: "POST",
222
+ headers: {
223
+ "Content-Type": "application/json",
224
+ },
225
+ body: JSON.stringify(requestData),
226
+ })
227
+
228
+ return response
229
+ } catch (error) {
230
+ console.error("Error:", error)
231
+ return null
232
+ }
233
+ }
package/src/client.ts CHANGED
@@ -19,18 +19,19 @@ import {
19
19
  import { Aftermath } from "./transaction/aftermath"
20
20
  import { DeepbookV2 } from "./transaction/deepbook_v2"
21
21
  import { KriyaV2 } from "./transaction/kriya_v2"
22
+ import { KriyaV3 } from "./transaction/kriya_v3"
22
23
  import { FlowxV2 } from "./transaction/flowx_v2"
24
+ import { FlowxV3 } from "./transaction/flowx_v3"
23
25
  import { Turbos } from "./transaction/turbos"
24
26
  import { Cetus } from "./transaction/cetus"
25
27
  import { swapInPools } from "./transaction/swap"
26
28
  import { CalculateAmountLimit } from "./math"
27
- import { buildInputCoin } from "./utils/coin"
28
- import { CoinAsset } from "./types/sui"
29
- import { KriyaV3 } from "./transaction/kriya_v3"
30
29
  import { Haedal } from "./transaction/haedal"
31
30
  import { Afsui } from "./transaction/afsui"
32
31
  import { Volo } from "./transaction/volo"
33
- import { FlowxV3 } from "./transaction/flowx_v3"
32
+ import { Bluemove } from "./transaction/bluemove"
33
+ import { CoinAsset } from "./types/sui"
34
+ import { buildInputCoin } from "./utils/coin"
34
35
 
35
36
  export const CETUS = "CETUS"
36
37
  export const DEEPBOOKV2 = "DEEPBOOK"
@@ -43,6 +44,7 @@ export const AFTERMATH = "AFTERMATH"
43
44
  export const HAEDAL = "HAEDAL"
44
45
  export const VOLO = "VOLO"
45
46
  export const AFSUI = "AFSUI"
47
+ export const BLUEMOVE = "BLUEMOVE"
46
48
 
47
49
  export type BuildRouterSwapParams = {
48
50
  routers: Router[]
@@ -335,9 +337,9 @@ export class AggregatorClient {
335
337
 
336
338
  publishedAt(): string {
337
339
  if (this.env === Env.Mainnet) {
338
- return "0xeffc8ae61f439bb34c9b905ff8f29ec56873dcedf81c7123ff2f1f67c45ec302"
340
+ return "0x764b8132a94d35abc9dfd91b23a0757b2a717d5ecb04c03098794aa2a508db91"
339
341
  } else {
340
- return "0x0"
342
+ return "0x6cbaa3e9fbe902d90191b12f315932bc58079cba422bafbd4b4369f80e61f595"
341
343
  }
342
344
  }
343
345
 
@@ -402,6 +404,8 @@ export class AggregatorClient {
402
404
  return new Afsui(this.env)
403
405
  case VOLO:
404
406
  return new Volo(this.env)
407
+ case BLUEMOVE:
408
+ return new Bluemove(this.env)
405
409
  default:
406
410
  throw new Error(`Unsupported dex ${provider}`)
407
411
  }
@@ -454,11 +458,16 @@ export function parseRouterResponse(data: any): RouterData {
454
458
  }
455
459
 
456
460
  let extendedDetails
457
- if (path.provider === TURBOS || path.provider === AFTERMATH) {
461
+ if (
462
+ path.provider === TURBOS ||
463
+ path.provider === AFTERMATH ||
464
+ path.provider === CETUS
465
+ ) {
458
466
  extendedDetails = {
459
467
  aftermathLpSupplyType:
460
468
  path.extended_details?.aftermath_lp_supply_type,
461
469
  turbosFeeType: path.extended_details?.turbos_fee_type,
470
+ afterSqrtPrice: path.extended_details?.after_sqrt_price,
462
471
  }
463
472
  }
464
473
 
@@ -0,0 +1,41 @@
1
+ import {
2
+ Transaction,
3
+ TransactionObjectArgument,
4
+ } from "@mysten/sui/transactions"
5
+ import { AggregatorClient, Dex, Env, Path } from ".."
6
+
7
+ export class Bluemove implements Dex {
8
+ private dexInfo: string
9
+
10
+ constructor(env: Env) {
11
+ if (env !== Env.Mainnet) {
12
+ throw new Error("Bluemove only supported on mainnet")
13
+ }
14
+
15
+ this.dexInfo =
16
+ "0x3f2d9f724f4a1ce5e71676448dc452be9a6243dac9c5b975a588c8c867066e92"
17
+ }
18
+
19
+ async swap(
20
+ client: AggregatorClient,
21
+ txb: Transaction,
22
+ path: Path,
23
+ inputCoin: TransactionObjectArgument
24
+ ): Promise<TransactionObjectArgument> {
25
+ const { direction, from, target } = path
26
+
27
+ const [func, coinAType, coinBType] = direction
28
+ ? ["swap_a2b", from, target]
29
+ : ["swap_b2a", target, from]
30
+
31
+ const args = [txb.object(this.dexInfo), inputCoin]
32
+
33
+ const res = txb.moveCall({
34
+ target: `${client.publishedAt()}::bluemove::${func}`,
35
+ typeArguments: [coinAType, coinBType],
36
+ arguments: args,
37
+ }) as TransactionObjectArgument
38
+
39
+ return res
40
+ }
41
+ }
@@ -22,8 +22,9 @@ export class Cetus implements Dex {
22
22
  : "0x6f4149091a5aea0e818e7243a13adcfb403842d670b9a2089de058512620687a"
23
23
 
24
24
  this.partner =
25
- partner ??
26
- "0x639b5e433da31739e800cd085f356e64cae222966d0f1b11bd9dc76b322ff58b"
25
+ partner ?? env === Env.Mainnet
26
+ ? "0x639b5e433da31739e800cd085f356e64cae222966d0f1b11bd9dc76b322ff58b"
27
+ : "0x8e0b7668a79592f70fbfb1ae0aebaf9e2019a7049783b9a4b6fe7c6ae038b528"
27
28
  }
28
29
 
29
30
  flash_swap(
@@ -131,6 +131,9 @@ export async function swapInPools(
131
131
  feeRate: event.fee_rate,
132
132
  amountIn: event.amount_in,
133
133
  amountOut: event.amount_out,
134
+ extendedDetails: {
135
+ afterSqrtPrice: event.after_sqrt_price,
136
+ },
134
137
  },
135
138
  ],
136
139
  amountIn: new BN(event.amount_in ?? 0),
@@ -1,7 +1,14 @@
1
1
  import { describe, test } from "@jest/globals"
2
2
  import dotenv from "dotenv"
3
3
  import { AggregatorClient } from "~/client"
4
- import { M_CETUS, M_NAVI, M_SSWP, M_SUI, M_USDC } from "./test_data.test"
4
+ import {
5
+ M_CETUS,
6
+ M_HASUI,
7
+ M_NAVI,
8
+ M_SSWP,
9
+ M_SUI,
10
+ M_USDC,
11
+ } from "./test_data.test"
5
12
  import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519"
6
13
  import { printTransaction } from "~/utils/transaction"
7
14
  import BN from "bn.js"
@@ -116,7 +123,7 @@ describe("router module", () => {
116
123
  byAmountIn: true,
117
124
  depth: 3,
118
125
  splitCount: 1,
119
- // providers: ["CETUS"],
126
+ providers: ["CETUS"],
120
127
  })
121
128
 
122
129
  if (res != null) {
@@ -130,9 +137,6 @@ describe("router module", () => {
130
137
  const byAmountIn = true
131
138
  const amount = "1000000000"
132
139
 
133
- // const from = M_USDC
134
- // const target = M_SUI
135
-
136
140
  const from = M_SUI
137
141
  // const target =
138
142
  // "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI"
@@ -155,7 +159,7 @@ describe("router module", () => {
155
159
  // "KRIYA",
156
160
  // "KRIYAV3",
157
161
  // "TURBOS",
158
- "FLOWXV3",
162
+ "BLUEMOVE",
159
163
  ],
160
164
  })
161
165
 
@@ -290,4 +294,88 @@ describe("router module", () => {
290
294
  }
291
295
  }
292
296
  }, 60000000)
297
+
298
+ test("Build router with liquidity changes", async () => {
299
+ const byAmountIn = true
300
+ const amount = "1000000000"
301
+
302
+ // const from = M_USDC
303
+ // const target = M_SUI
304
+
305
+ const from = M_SUI
306
+ // const target =
307
+ // "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI"
308
+ // const target =
309
+ // "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc::afsui::AFSUI"
310
+
311
+ const target = M_HASUI
312
+
313
+ const res = await client.findRouters({
314
+ from,
315
+ target,
316
+ amount: new BN(amount),
317
+ byAmountIn,
318
+ depth: 2,
319
+ providers: [
320
+ "CETUS",
321
+ // "DEEPBOOK",
322
+ // "AFTERMATH",
323
+ // "FLOWX",
324
+ // "KRIYA",
325
+ // "KRIYAV3",
326
+ // "TURBOS",
327
+ // "FLOWXV3",
328
+ ],
329
+ liquidityChanges: [
330
+ {
331
+ poolID:
332
+ "0x871d8a227114f375170f149f7e9d45be822dd003eba225e83c05ac80828596bc",
333
+ ticklower: 100,
334
+ tickUpper: 394,
335
+ deltaLiquidity: -5498684,
336
+ },
337
+ {
338
+ poolID:
339
+ "0x871d8a227114f375170f149f7e9d45be822dd003eba225e83c05ac80828596bc",
340
+ ticklower: 100,
341
+ tickUpper: 394,
342
+ deltaLiquidity: 986489,
343
+ },
344
+ ],
345
+ })
346
+
347
+ if (res != null) {
348
+ console.log(JSON.stringify(res, null, 2))
349
+ }
350
+
351
+ console.log("amount in", res?.amountIn.toString())
352
+ console.log("amount out", res?.amountOut.toString())
353
+
354
+ const txb = new Transaction()
355
+
356
+ if (res != null) {
357
+ console.log(JSON.stringify(res, null, 2))
358
+ await client.fastRouterSwap({
359
+ routers: res.routes,
360
+ byAmountIn,
361
+ txb,
362
+ slippage: 0.01,
363
+ isMergeTragetCoin: false,
364
+ refreshAllCoins: true,
365
+ })
366
+
367
+ printTransaction(txb)
368
+
369
+ let result = await client.devInspectTransactionBlock(txb)
370
+ console.log("🚀 ~ file: router.test.ts:180 ~ test ~ result:", result)
371
+
372
+ // if (result.effects.status.status === "success") {
373
+ // console.log("Sim exec transaction success")
374
+ // const result = await client.signAndExecuteTransaction(txb, keypair)
375
+ // // console.log("result", result)
376
+ // } else {
377
+ // console.log("result", result)
378
+ // }
379
+ }
380
+ }, 600000)
293
381
  })