@cetusprotocol/aggregator-sdk 0.3.15 → 0.3.16

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.js CHANGED
@@ -5621,6 +5621,8 @@ function getAggregatorServerErrorMessage(code) {
5621
5621
  return "No router";
5622
5622
  case 10003 /* InsufficientLiquidity */:
5623
5623
  return "Insufficient Liquidity";
5624
+ case 10004 /* HoneyPot */:
5625
+ return "Target token is detected as a HoneyPot scam";
5624
5626
  default:
5625
5627
  return "Unknown error";
5626
5628
  }
@@ -6479,7 +6481,7 @@ var AggregatorClient10 = class {
6479
6481
  // Include cetus、deepbookv2、flowxv2 & v3、kriyav2 & v3、turbos、aftermath、haedal、afsui、volo、bluemove
6480
6482
  publishedAt() {
6481
6483
  if (this.env === 0 /* Mainnet */) {
6482
- return "0x11451575c775a3e633437b827ecbc1eb51a5964b0302210b28f5b89880be21a2";
6484
+ return "0x3fb42ddf908af45f9fc3c59eab227888ff24ba2e137b3b55bf80920fd47e11af";
6483
6485
  } else {
6484
6486
  return "0x52eae33adeb44de55cfb3f281d4cc9e02d976181c0952f5323648b5717b33934";
6485
6487
  }
@@ -6726,11 +6728,25 @@ function getRouterResult(endpoint, params) {
6726
6728
  };
6727
6729
  }
6728
6730
  const data = yield response.json();
6731
+ const insufficientLiquidity = data.msg === "liquidity is not enough";
6732
+ if (data.msg && data.msg.indexOf("HoneyPot scam") > -1) {
6733
+ return {
6734
+ amountIn: ZERO,
6735
+ amountOut: ZERO,
6736
+ routes: [],
6737
+ insufficientLiquidity,
6738
+ error: {
6739
+ code: 10004 /* HoneyPot */,
6740
+ msg: getAggregatorServerErrorMessage(
6741
+ 10004 /* HoneyPot */
6742
+ )
6743
+ }
6744
+ };
6745
+ }
6729
6746
  if (data.data != null) {
6730
6747
  const res = parseRouterResponse(data.data);
6731
6748
  return res;
6732
6749
  }
6733
- const insufficientLiquidity = data.msg === "liquidity is not enough";
6734
6750
  return {
6735
6751
  amountIn: ZERO,
6736
6752
  amountOut: ZERO,
@@ -6779,7 +6795,7 @@ function getRouter(endpoint, params) {
6779
6795
  url += `&providers=${providers.join(",")}`;
6780
6796
  }
6781
6797
  }
6782
- url += "&v=1000315";
6798
+ url += "&v=1000316";
6783
6799
  const response = yield fetch(url);
6784
6800
  return response;
6785
6801
  } catch (error) {
package/dist/index.mjs CHANGED
@@ -5619,6 +5619,8 @@ function getAggregatorServerErrorMessage(code) {
5619
5619
  return "No router";
5620
5620
  case 10003 /* InsufficientLiquidity */:
5621
5621
  return "Insufficient Liquidity";
5622
+ case 10004 /* HoneyPot */:
5623
+ return "Target token is detected as a HoneyPot scam";
5622
5624
  default:
5623
5625
  return "Unknown error";
5624
5626
  }
@@ -6477,7 +6479,7 @@ var AggregatorClient10 = class {
6477
6479
  // Include cetus、deepbookv2、flowxv2 & v3、kriyav2 & v3、turbos、aftermath、haedal、afsui、volo、bluemove
6478
6480
  publishedAt() {
6479
6481
  if (this.env === 0 /* Mainnet */) {
6480
- return "0x11451575c775a3e633437b827ecbc1eb51a5964b0302210b28f5b89880be21a2";
6482
+ return "0x3fb42ddf908af45f9fc3c59eab227888ff24ba2e137b3b55bf80920fd47e11af";
6481
6483
  } else {
6482
6484
  return "0x52eae33adeb44de55cfb3f281d4cc9e02d976181c0952f5323648b5717b33934";
6483
6485
  }
@@ -6724,11 +6726,25 @@ function getRouterResult(endpoint, params) {
6724
6726
  };
6725
6727
  }
6726
6728
  const data = yield response.json();
6729
+ const insufficientLiquidity = data.msg === "liquidity is not enough";
6730
+ if (data.msg && data.msg.indexOf("HoneyPot scam") > -1) {
6731
+ return {
6732
+ amountIn: ZERO,
6733
+ amountOut: ZERO,
6734
+ routes: [],
6735
+ insufficientLiquidity,
6736
+ error: {
6737
+ code: 10004 /* HoneyPot */,
6738
+ msg: getAggregatorServerErrorMessage(
6739
+ 10004 /* HoneyPot */
6740
+ )
6741
+ }
6742
+ };
6743
+ }
6727
6744
  if (data.data != null) {
6728
6745
  const res = parseRouterResponse(data.data);
6729
6746
  return res;
6730
6747
  }
6731
- const insufficientLiquidity = data.msg === "liquidity is not enough";
6732
6748
  return {
6733
6749
  amountIn: ZERO,
6734
6750
  amountOut: ZERO,
@@ -6777,7 +6793,7 @@ function getRouter(endpoint, params) {
6777
6793
  url += `&providers=${providers.join(",")}`;
6778
6794
  }
6779
6795
  }
6780
- url += "&v=1000315";
6796
+ url += "&v=1000316";
6781
6797
  const response = yield fetch(url);
6782
6798
  return response;
6783
6799
  } catch (error) {
@@ -33,6 +33,7 @@ export declare enum AggregatorServerErrorCode {
33
33
  CalculateError = 10000,
34
34
  NumberTooLarge = 10001,
35
35
  NoRouter = 10002,
36
- InsufficientLiquidity = 10003
36
+ InsufficientLiquidity = 10003,
37
+ HoneyPot = 10004
37
38
  }
38
39
  export declare function getAggregatorServerErrorMessage(code: AggregatorServerErrorCode): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cetusprotocol/aggregator-sdk",
3
- "version": "0.3.15",
3
+ "version": "0.3.16",
4
4
  "sideEffects": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/api.ts CHANGED
@@ -109,11 +109,27 @@ export async function getRouterResult(
109
109
  }
110
110
  }
111
111
  const data = await response.json()
112
+ const insufficientLiquidity = data.msg === "liquidity is not enough"
113
+
114
+ if(data.msg && data.msg.indexOf('HoneyPot scam')>-1){
115
+ return {
116
+ amountIn: ZERO,
117
+ amountOut: ZERO,
118
+ routes: [],
119
+ insufficientLiquidity,
120
+ error: {
121
+ code: AggregatorServerErrorCode.HoneyPot,
122
+ msg: getAggregatorServerErrorMessage(
123
+ AggregatorServerErrorCode.HoneyPot
124
+ ),
125
+ },
126
+ }
127
+ }
112
128
  if (data.data != null) {
113
129
  const res = parseRouterResponse(data.data)
114
130
  return res
115
131
  }
116
- const insufficientLiquidity = data.msg === "liquidity is not enough"
132
+
117
133
 
118
134
  return {
119
135
  amountIn: ZERO,
@@ -170,7 +186,7 @@ async function getRouter(endpoint: string, params: FindRouterParams) {
170
186
  }
171
187
 
172
188
  // set newest sdk version
173
- url += "&v=1000315"
189
+ url += "&v=1000316"
174
190
 
175
191
  const response = await fetch(url)
176
192
  return response
package/src/client.ts CHANGED
@@ -406,7 +406,8 @@ export class AggregatorClient {
406
406
  // Include cetus、deepbookv2、flowxv2 & v3、kriyav2 & v3、turbos、aftermath、haedal、afsui、volo、bluemove
407
407
  publishedAt(): string {
408
408
  if (this.env === Env.Mainnet) {
409
- return "0x11451575c775a3e633437b827ecbc1eb51a5964b0302210b28f5b89880be21a2" // version 5
409
+ return "0x3fb42ddf908af45f9fc3c59eab227888ff24ba2e137b3b55bf80920fd47e11af" // version 6
410
+ // return "0x807c6697636bafa674dcf67570a1a95c3cc35dd9a44614558ef8ef9ed4aa83ad" // pre
410
411
  } else {
411
412
  // return "0x0ed287d6c3fe4962d0994ffddc1d19a15fba6a81533f3f0dcc2bbcedebce0637" // version 2
412
413
  return "0x52eae33adeb44de55cfb3f281d4cc9e02d976181c0952f5323648b5717b33934"
package/src/errors.ts CHANGED
@@ -51,6 +51,7 @@ export enum AggregatorServerErrorCode {
51
51
  NumberTooLarge = 10001,
52
52
  NoRouter = 10002,
53
53
  InsufficientLiquidity = 10003,
54
+ HoneyPot = 10004
54
55
  }
55
56
 
56
57
  export function getAggregatorServerErrorMessage(
@@ -65,6 +66,8 @@ export function getAggregatorServerErrorMessage(
65
66
  return "No router"
66
67
  case AggregatorServerErrorCode.InsufficientLiquidity:
67
68
  return "Insufficient Liquidity"
69
+ case AggregatorServerErrorCode.HoneyPot:
70
+ return "Target token is detected as a HoneyPot scam"
68
71
  default:
69
72
  return "Unknown error"
70
73
  }
@@ -35,7 +35,7 @@ describe("router module", () => {
35
35
 
36
36
  // const wallet = keypair.getPublicKey().toSuiAddress()
37
37
  // console.log("wallet: ", wallet)
38
- const wallet = "0x326ce9894f08dcaa337fa232641cc34db957aec9ff6614c1186bc9a7508df0bb"
38
+ const wallet = "0x0005e9b405ab0424b6494b64d3d5b79b6715d06d284585faffe1ee1a873ba8a3"
39
39
 
40
40
  const endpoint = aggregatorURL
41
41
 
@@ -110,8 +110,8 @@ describe("router module", () => {
110
110
 
111
111
  test("Build router tx", async () => {
112
112
  const byAmountIn = true
113
- const amount = "3574839"
114
- const target = "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC"
113
+ const amount = "746028139919"
114
+ const target = "0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT"
115
115
  const from = "0x2::sui::SUI"
116
116
 
117
117
  const res = await client.findRouters({
@@ -120,7 +120,7 @@ describe("router module", () => {
120
120
  amount: new BN(amount),
121
121
  byAmountIn,
122
122
  depth: 3,
123
- providers: ["HAEDALPMM"],
123
+ // providers: ["HAEDAL"],
124
124
  })
125
125
 
126
126
  if (res != null) {
@@ -345,4 +345,24 @@ describe("router module", () => {
345
345
  const config = await client.getDeepbookV3Config()
346
346
  console.log("config", config)
347
347
  }, 60000)
348
+
349
+
350
+ test("Find router", async () => {
351
+ const amount = "4239267610000000000"
352
+ const res = await client.findRouters({
353
+ from: '0x2::sui::SUI',
354
+ target: '0x188c6239bda71ba5751990cc0271e91b6362c67bccf7aa381e018db7fe39c6d7::BUILD::BUILD',
355
+ amount: new BN(amount),
356
+ byAmountIn: true,
357
+ depth: 3,
358
+ splitCount: 1,
359
+ providers: ["CETUS"],
360
+ })
361
+
362
+ if (res != null) {
363
+ console.log(JSON.stringify(res, null, 2))
364
+ }
365
+ console.log("amount in", res?.amountIn.toString())
366
+ console.log("amount out", res?.amountOut.toString())
367
+ })
348
368
  })