@cetusprotocol/aggregator-sdk 0.3.10 → 0.3.11

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.d.mts CHANGED
@@ -75,6 +75,7 @@ declare const BLUEMOVE = "BLUEMOVE";
75
75
  declare const DEEPBOOKV3 = "DEEPBOOKV3";
76
76
  declare const SCALLOP = "SCALLOP";
77
77
  declare const SUILEND = "SUILEND";
78
+ declare const BLUEFIN = "BLUEFIN";
78
79
  declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
79
80
  type BuildRouterSwapParams = {
80
81
  routers: Router[];
@@ -266,4 +267,4 @@ declare enum Env {
266
267
  Testnet = 1
267
268
  }
268
269
 
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 };
270
+ export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, BLUEFIN, 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
@@ -75,6 +75,7 @@ declare const BLUEMOVE = "BLUEMOVE";
75
75
  declare const DEEPBOOKV3 = "DEEPBOOKV3";
76
76
  declare const SCALLOP = "SCALLOP";
77
77
  declare const SUILEND = "SUILEND";
78
+ declare const BLUEFIN = "BLUEFIN";
78
79
  declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
79
80
  type BuildRouterSwapParams = {
80
81
  routers: Router[];
@@ -266,4 +267,4 @@ declare enum Env {
266
267
  Testnet = 1
267
268
  }
268
269
 
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 };
270
+ export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, BLUEFIN, 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
@@ -6111,6 +6111,34 @@ var Suilend = class {
6111
6111
  }
6112
6112
  };
6113
6113
 
6114
+ // src/transaction/bluefin.ts
6115
+ var Bluefin = class {
6116
+ constructor(env) {
6117
+ if (env !== 0 /* Mainnet */) {
6118
+ throw new Error("Bluefin only supported on mainnet");
6119
+ }
6120
+ this.globalConfig = "0x03db251ba509a8d5d8777b6338836082335d93eecbdd09a11e190a1cff51c352";
6121
+ }
6122
+ swap(client, txb, path, inputCoin) {
6123
+ return __async(this, null, function* () {
6124
+ const { direction, from, target } = path;
6125
+ const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
6126
+ const args = [
6127
+ txb.object(this.globalConfig),
6128
+ txb.object(path.id),
6129
+ inputCoin,
6130
+ txb.object(CLOCK_ADDRESS)
6131
+ ];
6132
+ const res = txb.moveCall({
6133
+ target: `${client.publishedAtV2()}::bluefin::${func}`,
6134
+ typeArguments: [coinAType, coinBType],
6135
+ arguments: args
6136
+ });
6137
+ return res;
6138
+ });
6139
+ }
6140
+ };
6141
+
6114
6142
  // src/client.ts
6115
6143
  var CETUS = "CETUS";
6116
6144
  var DEEPBOOKV2 = "DEEPBOOK";
@@ -6127,8 +6155,9 @@ var BLUEMOVE = "BLUEMOVE";
6127
6155
  var DEEPBOOKV3 = "DEEPBOOKV3";
6128
6156
  var SCALLOP = "SCALLOP";
6129
6157
  var SUILEND = "SUILEND";
6158
+ var BLUEFIN = "BLUEFIN";
6130
6159
  var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
6131
- var AggregatorClient8 = class {
6160
+ var AggregatorClient9 = class {
6132
6161
  constructor(endpoint, signer, client$1, env) {
6133
6162
  this.endpoint = endpoint ? processEndpoint(endpoint) : DEFAULT_ENDPOINT;
6134
6163
  this.client = client$1 || new client.SuiClient({ url: client.getFullnodeUrl("mainnet") });
@@ -6402,10 +6431,10 @@ var AggregatorClient8 = class {
6402
6431
  return "0x52eae33adeb44de55cfb3f281d4cc9e02d976181c0952f5323648b5717b33934";
6403
6432
  }
6404
6433
  }
6405
- // Include deepbookv3, scallop
6434
+ // Include deepbookv3, scallop, bluefin
6406
6435
  publishedAtV2() {
6407
6436
  if (this.env === 0 /* Mainnet */) {
6408
- return "0x16d9418726c26d8cb4ce8c9dd75917fa9b1c7bf47d38d7a1a22603135f0f2a56";
6437
+ return "0x3b6d71bdeb8ce5b06febfd3cfc29ecd60d50da729477c8b8038ecdae34541b91";
6409
6438
  } else {
6410
6439
  return "0xfd8a73ef0a4b928da9c27fc287dc37c1ca64df71da8e8eac7ca9ece55eb5f448";
6411
6440
  }
@@ -6474,6 +6503,8 @@ var AggregatorClient8 = class {
6474
6503
  return new Scallop(this.env);
6475
6504
  case SUILEND:
6476
6505
  return new Suilend(this.env);
6506
+ case BLUEFIN:
6507
+ return new Bluefin(this.env);
6477
6508
  default:
6478
6509
  throw new Error(`Unsupported dex ${provider}`);
6479
6510
  }
@@ -6783,7 +6814,8 @@ decimal.js/decimal.mjs:
6783
6814
 
6784
6815
  exports.AFSUI = AFSUI;
6785
6816
  exports.AFTERMATH = AFTERMATH;
6786
- exports.AggregatorClient = AggregatorClient8;
6817
+ exports.AggregatorClient = AggregatorClient9;
6818
+ exports.BLUEFIN = BLUEFIN;
6787
6819
  exports.BLUEMOVE = BLUEMOVE;
6788
6820
  exports.CETUS = CETUS;
6789
6821
  exports.CLOCK_ADDRESS = CLOCK_ADDRESS;
package/dist/index.mjs CHANGED
@@ -6109,6 +6109,34 @@ var Suilend = class {
6109
6109
  }
6110
6110
  };
6111
6111
 
6112
+ // src/transaction/bluefin.ts
6113
+ var Bluefin = class {
6114
+ constructor(env) {
6115
+ if (env !== 0 /* Mainnet */) {
6116
+ throw new Error("Bluefin only supported on mainnet");
6117
+ }
6118
+ this.globalConfig = "0x03db251ba509a8d5d8777b6338836082335d93eecbdd09a11e190a1cff51c352";
6119
+ }
6120
+ swap(client, txb, path, inputCoin) {
6121
+ return __async(this, null, function* () {
6122
+ const { direction, from, target } = path;
6123
+ const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
6124
+ const args = [
6125
+ txb.object(this.globalConfig),
6126
+ txb.object(path.id),
6127
+ inputCoin,
6128
+ txb.object(CLOCK_ADDRESS)
6129
+ ];
6130
+ const res = txb.moveCall({
6131
+ target: `${client.publishedAtV2()}::bluefin::${func}`,
6132
+ typeArguments: [coinAType, coinBType],
6133
+ arguments: args
6134
+ });
6135
+ return res;
6136
+ });
6137
+ }
6138
+ };
6139
+
6112
6140
  // src/client.ts
6113
6141
  var CETUS = "CETUS";
6114
6142
  var DEEPBOOKV2 = "DEEPBOOK";
@@ -6125,8 +6153,9 @@ var BLUEMOVE = "BLUEMOVE";
6125
6153
  var DEEPBOOKV3 = "DEEPBOOKV3";
6126
6154
  var SCALLOP = "SCALLOP";
6127
6155
  var SUILEND = "SUILEND";
6156
+ var BLUEFIN = "BLUEFIN";
6128
6157
  var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
6129
- var AggregatorClient8 = class {
6158
+ var AggregatorClient9 = class {
6130
6159
  constructor(endpoint, signer, client, env) {
6131
6160
  this.endpoint = endpoint ? processEndpoint(endpoint) : DEFAULT_ENDPOINT;
6132
6161
  this.client = client || new SuiClient({ url: getFullnodeUrl("mainnet") });
@@ -6400,10 +6429,10 @@ var AggregatorClient8 = class {
6400
6429
  return "0x52eae33adeb44de55cfb3f281d4cc9e02d976181c0952f5323648b5717b33934";
6401
6430
  }
6402
6431
  }
6403
- // Include deepbookv3, scallop
6432
+ // Include deepbookv3, scallop, bluefin
6404
6433
  publishedAtV2() {
6405
6434
  if (this.env === 0 /* Mainnet */) {
6406
- return "0x16d9418726c26d8cb4ce8c9dd75917fa9b1c7bf47d38d7a1a22603135f0f2a56";
6435
+ return "0x3b6d71bdeb8ce5b06febfd3cfc29ecd60d50da729477c8b8038ecdae34541b91";
6407
6436
  } else {
6408
6437
  return "0xfd8a73ef0a4b928da9c27fc287dc37c1ca64df71da8e8eac7ca9ece55eb5f448";
6409
6438
  }
@@ -6472,6 +6501,8 @@ var AggregatorClient8 = class {
6472
6501
  return new Scallop(this.env);
6473
6502
  case SUILEND:
6474
6503
  return new Suilend(this.env);
6504
+ case BLUEFIN:
6505
+ return new Bluefin(this.env);
6475
6506
  default:
6476
6507
  throw new Error(`Unsupported dex ${provider}`);
6477
6508
  }
@@ -6779,4 +6810,4 @@ decimal.js/decimal.mjs:
6779
6810
  *)
6780
6811
  */
6781
6812
 
6782
- 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 };
6813
+ export { AFSUI, AFTERMATH, AggregatorClient9 as AggregatorClient, BLUEFIN, 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 };
@@ -19,6 +19,7 @@ export declare const BLUEMOVE = "BLUEMOVE";
19
19
  export declare const DEEPBOOKV3 = "DEEPBOOKV3";
20
20
  export declare const SCALLOP = "SCALLOP";
21
21
  export declare const SUILEND = "SUILEND";
22
+ export declare const BLUEFIN = "BLUEFIN";
22
23
  export declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
23
24
  export type BuildRouterSwapParams = {
24
25
  routers: Router[];
@@ -0,0 +1,7 @@
1
+ import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
2
+ import { AggregatorClient, Dex, Env, Path } from "..";
3
+ export declare class Bluefin implements Dex {
4
+ private globalConfig;
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.3.10",
3
+ "version": "0.3.11",
4
4
  "sideEffects": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/client.ts CHANGED
@@ -38,6 +38,7 @@ import { buildInputCoin } from "./utils/coin"
38
38
  import { DeepbookV3 } from "./transaction/deepbook_v3"
39
39
  import { Scallop } from "./transaction/scallop"
40
40
  import { Suilend } from "./transaction/suilend"
41
+ import { Bluefin } from "./transaction/bluefin"
41
42
 
42
43
  export const CETUS = "CETUS"
43
44
  export const DEEPBOOKV2 = "DEEPBOOK"
@@ -54,6 +55,7 @@ export const BLUEMOVE = "BLUEMOVE"
54
55
  export const DEEPBOOKV3 = "DEEPBOOKV3"
55
56
  export const SCALLOP = "SCALLOP"
56
57
  export const SUILEND = "SUILEND"
58
+ export const BLUEFIN = "BLUEFIN"
57
59
  export const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2"
58
60
 
59
61
  export type BuildRouterSwapParams = {
@@ -408,12 +410,13 @@ export class AggregatorClient {
408
410
  }
409
411
  }
410
412
 
411
- // Include deepbookv3, scallop
413
+ // Include deepbookv3, scallop, bluefin
412
414
  publishedAtV2(): string {
413
415
  if (this.env === Env.Mainnet) {
414
416
  // return "0x43811be4677f5a5de7bf2dac740c10abddfaa524aee6b18e910eeadda8a2f6ae" // version 1, deepbookv3
415
417
  // return "0x6d70ffa7aa3f924c3f0b573d27d29895a0ee666aaff821073f75cb14af7fd01a" // version 3, deepbookv3 & scallop
416
- return "0x16d9418726c26d8cb4ce8c9dd75917fa9b1c7bf47d38d7a1a22603135f0f2a56" // version 4 add suilend
418
+ // return "0x16d9418726c26d8cb4ce8c9dd75917fa9b1c7bf47d38d7a1a22603135f0f2a56" // version 4, add suilend
419
+ return "0x3b6d71bdeb8ce5b06febfd3cfc29ecd60d50da729477c8b8038ecdae34541b91" // version 5, add bluefin
417
420
  } else {
418
421
  return "0xfd8a73ef0a4b928da9c27fc287dc37c1ca64df71da8e8eac7ca9ece55eb5f448"
419
422
  }
@@ -496,6 +499,8 @@ export class AggregatorClient {
496
499
  return new Scallop(this.env)
497
500
  case SUILEND:
498
501
  return new Suilend(this.env)
502
+ case BLUEFIN:
503
+ return new Bluefin(this.env)
499
504
  default:
500
505
  throw new Error(`Unsupported dex ${provider}`)
501
506
  }
@@ -0,0 +1,43 @@
1
+ import {
2
+ Transaction,
3
+ TransactionArgument,
4
+ TransactionObjectArgument,
5
+ } from "@mysten/sui/transactions"
6
+ import { AggregatorClient, CLOCK_ADDRESS, Dex, Env, Path } from ".."
7
+
8
+ export class Bluefin implements Dex {
9
+ private globalConfig: string
10
+
11
+ constructor(env: Env) {
12
+ if (env !== Env.Mainnet) {
13
+ throw new Error("Bluefin only supported on mainnet")
14
+ }
15
+
16
+ this.globalConfig =
17
+ "0x03db251ba509a8d5d8777b6338836082335d93eecbdd09a11e190a1cff51c352"
18
+ }
19
+
20
+ async swap(
21
+ client: AggregatorClient,
22
+ txb: Transaction,
23
+ path: Path,
24
+ inputCoin: TransactionObjectArgument
25
+ ): Promise<TransactionObjectArgument> {
26
+ const { direction, from, target } = path
27
+ const [func, coinAType, coinBType] = direction
28
+ ? ["swap_a2b", from, target]
29
+ : ["swap_b2a", target, from]
30
+ const args = [
31
+ txb.object(this.globalConfig),
32
+ txb.object(path.id),
33
+ inputCoin,
34
+ txb.object(CLOCK_ADDRESS),
35
+ ]
36
+ const res = txb.moveCall({
37
+ target: `${client.publishedAtV2()}::bluefin::${func}`,
38
+ typeArguments: [coinAType, coinBType],
39
+ arguments: args,
40
+ }) as TransactionArgument
41
+ return res
42
+ }
43
+ }
@@ -112,9 +112,9 @@ describe("router module", () => {
112
112
 
113
113
  test("Build router tx", async () => {
114
114
  const byAmountIn = true
115
- const amount = "400000000000"
115
+ const amount = "1000000000"
116
116
  const from = "0x2::sui::SUI"
117
- const target = "0xaf3aae4940a248739ce4964857381fc3f3149a6d05375bfbb2118592907e3bbb::dam::DAM"
117
+ const target = "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN"
118
118
 
119
119
  const res = await client.findRouters({
120
120
  from,
@@ -122,6 +122,7 @@ describe("router module", () => {
122
122
  amount: new BN(amount),
123
123
  byAmountIn,
124
124
  depth: 3,
125
+ providers: ["BLUEFIN"],
125
126
  })
126
127
 
127
128
  if (res != null) {