@cetusprotocol/aggregator-sdk 0.0.0-experimental-20250107115504 → 0.0.0-experimental-20250107152012
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 +17 -1
- package/dist/index.mjs +17 -1
- package/dist/src/errors.d.ts +2 -1
- package/package.json +1 -1
- package/src/api.ts +17 -1
- package/src/errors.ts +3 -0
- package/tests/router.test.ts +20 -0
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
|
}
|
|
@@ -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,
|
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
|
}
|
|
@@ -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,
|
package/dist/src/errors.d.ts
CHANGED
|
@@ -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
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
|
-
|
|
132
|
+
|
|
117
133
|
|
|
118
134
|
return {
|
|
119
135
|
amountIn: ZERO,
|
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
|
}
|
package/tests/router.test.ts
CHANGED
|
@@ -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
|
})
|