@cetusprotocol/aggregator-sdk 0.0.2 → 0.0.3

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
@@ -114,6 +114,7 @@ type RouterData = {
114
114
  amountIn: BN;
115
115
  amountOut: BN;
116
116
  routes: Router[];
117
+ insufficientLiquidity: boolean;
117
118
  };
118
119
  type AggregatorResponse = {
119
120
  code: number;
package/dist/index.d.ts CHANGED
@@ -114,6 +114,7 @@ type RouterData = {
114
114
  amountIn: BN;
115
115
  amountOut: BN;
116
116
  routes: Router[];
117
+ insufficientLiquidity: boolean;
117
118
  };
118
119
  type AggregatorResponse = {
119
120
  code: number;
package/dist/index.js CHANGED
@@ -6459,7 +6459,8 @@ function swapInPools(client, params, config2) {
6459
6459
  amountOut: new import_bn3.BN((_e = event.amount_out) != null ? _e : 0),
6460
6460
  initialPrice
6461
6461
  }
6462
- ]
6462
+ ],
6463
+ insufficientLiquidity: false
6463
6464
  };
6464
6465
  const result = {
6465
6466
  isExceed: event.is_exceed,
@@ -6540,6 +6541,14 @@ var AggregatorClient = class {
6540
6541
  const res = parseRouterResponse(data.data);
6541
6542
  return res;
6542
6543
  }
6544
+ if (data.msg === "liquidity is not enough") {
6545
+ return {
6546
+ amountIn: ZERO,
6547
+ amountOut: ZERO,
6548
+ routes: [],
6549
+ insufficientLiquidity: true
6550
+ };
6551
+ }
6543
6552
  return null;
6544
6553
  });
6545
6554
  }
@@ -6687,6 +6696,7 @@ function parseRouterResponse(data) {
6687
6696
  return {
6688
6697
  amountIn: new import_bn4.default(data.amount_in.toString()),
6689
6698
  amountOut: new import_bn4.default(data.amount_out.toString()),
6699
+ insufficientLiquidity: false,
6690
6700
  routes: data.routes.map((route) => {
6691
6701
  return {
6692
6702
  path: route.path.map((path) => {
package/dist/index.mjs CHANGED
@@ -6457,7 +6457,8 @@ function swapInPools(client, params, config2) {
6457
6457
  amountOut: new import_bn3.BN((_e = event.amount_out) != null ? _e : 0),
6458
6458
  initialPrice
6459
6459
  }
6460
- ]
6460
+ ],
6461
+ insufficientLiquidity: false
6461
6462
  };
6462
6463
  const result = {
6463
6464
  isExceed: event.is_exceed,
@@ -6538,6 +6539,14 @@ var AggregatorClient = class {
6538
6539
  const res = parseRouterResponse(data.data);
6539
6540
  return res;
6540
6541
  }
6542
+ if (data.msg === "liquidity is not enough") {
6543
+ return {
6544
+ amountIn: ZERO,
6545
+ amountOut: ZERO,
6546
+ routes: [],
6547
+ insufficientLiquidity: true
6548
+ };
6549
+ }
6541
6550
  return null;
6542
6551
  });
6543
6552
  }
@@ -6685,6 +6694,7 @@ function parseRouterResponse(data) {
6685
6694
  return {
6686
6695
  amountIn: new import_bn4.default(data.amount_in.toString()),
6687
6696
  amountOut: new import_bn4.default(data.amount_out.toString()),
6697
+ insufficientLiquidity: false,
6688
6698
  routes: data.routes.map((route) => {
6689
6699
  return {
6690
6700
  path: route.path.map((path) => {
@@ -31,6 +31,7 @@ export type RouterData = {
31
31
  amountIn: BN;
32
32
  amountOut: BN;
33
33
  routes: Router[];
34
+ insufficientLiquidity: boolean;
34
35
  };
35
36
  export type AggregatorResponse = {
36
37
  code: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cetusprotocol/aggregator-sdk",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "sideEffects": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -38,4 +38,4 @@
38
38
  "ts-jest": "^29.1.3",
39
39
  "typescript": "^5.4.5"
40
40
  }
41
- }
41
+ }
package/src/client.ts CHANGED
@@ -16,7 +16,7 @@ import BN from "bn.js"
16
16
  import { swapInPools } from "./transaction/swap"
17
17
  import { completionCoin } from "./utils/coin"
18
18
  import { SUI_FRAMEWORK_ADDRESS } from "@mysten/sui/utils"
19
- import { AFTERMATH_AMM, JOIN_FUNC, PAY_MODULE, TURBOS_DEX } from "./const"
19
+ import { AFTERMATH_AMM, JOIN_FUNC, PAY_MODULE, TURBOS_DEX, ZERO } from "./const"
20
20
 
21
21
  export type ExtendedDetails = {
22
22
  aftermathPoolFlatness?: number
@@ -48,6 +48,7 @@ export type RouterData = {
48
48
  amountIn: BN
49
49
  amountOut: BN
50
50
  routes: Router[]
51
+ insufficientLiquidity: boolean
51
52
  }
52
53
 
53
54
  export type AggregatorResponse = {
@@ -190,6 +191,14 @@ export class AggregatorClient {
190
191
  return res
191
192
  }
192
193
 
194
+ if (data.msg === "liquidity is not enough") {
195
+ return {
196
+ amountIn: ZERO,
197
+ amountOut: ZERO,
198
+ routes: [],
199
+ insufficientLiquidity: true,
200
+ }
201
+ }
193
202
  return null
194
203
  }
195
204
 
@@ -343,6 +352,7 @@ function parseRouterResponse(data: any): RouterData {
343
352
  return {
344
353
  amountIn: new BN(data.amount_in.toString()),
345
354
  amountOut: new BN(data.amount_out.toString()),
355
+ insufficientLiquidity: false,
346
356
  routes: data.routes.map((route: any) => {
347
357
  return {
348
358
  path: route.path.map((path: any) => {
@@ -26,7 +26,6 @@ import { transferOrDestoryCoin } from "./common"
26
26
  import { GetDefaultSqrtPriceLimit } from "../math"
27
27
  import { flowxAmmSwapMovecall } from "./flowx"
28
28
  import { turbosSwapMovecall } from "./turbos"
29
- import { parseAftermathFeeType, parseTurbosPoolFeeType } from "~/utils/coin"
30
29
  import { AftermathAmmSwapMovecall } from "./aftermath"
31
30
  import { TransactionErrorCode } from "~/errors"
32
31
 
@@ -152,6 +152,7 @@ export async function swapInPools(
152
152
  initialPrice,
153
153
  },
154
154
  ],
155
+ insufficientLiquidity: false,
155
156
  }
156
157
 
157
158
  const result = {
@@ -120,13 +120,13 @@ describe("router module", () => {
120
120
  splitFactor: null,
121
121
  splitCount: 1,
122
122
  providers: [
123
- "AFTERMATH",
124
- "CETUS",
123
+ // "AFTERMATH",
124
+ // "CETUS",
125
125
  "DEEPBOOK",
126
- "KRIYA",
127
- "FLOWX",
128
- "AFTERMATH",
129
- "TRUBOS",
126
+ // "KRIYA",
127
+ // "FLOWX",
128
+ // "AFTERMATH",
129
+ // "TRUBOS",
130
130
  ],
131
131
  })
132
132