@cetusprotocol/aggregator-sdk 0.0.0-experimental-20241230111621 → 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 +20 -4
- package/dist/index.mjs +20 -4
- package/dist/src/errors.d.ts +2 -1
- package/package.json +1 -1
- package/src/api.ts +18 -2
- package/src/client.ts +5 -3
- 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
|
}
|
|
@@ -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 "
|
|
6484
|
+
return "0x43eb15e430096fda554c131b73c29a80aee0b9c3d7234d8b52e4a9b1ac5fb630";
|
|
6483
6485
|
} else {
|
|
6484
6486
|
return "0x52eae33adeb44de55cfb3f281d4cc9e02d976181c0952f5323648b5717b33934";
|
|
6485
6487
|
}
|
|
@@ -6487,7 +6489,7 @@ var AggregatorClient10 = class {
|
|
|
6487
6489
|
// Include deepbookv3, scallop, bluefin
|
|
6488
6490
|
publishedAtV2() {
|
|
6489
6491
|
if (this.env === 0 /* Mainnet */) {
|
|
6490
|
-
return "
|
|
6492
|
+
return "0x347dd58bbd11cd82c8b386b344729717c04a998da73386e82a239cc196d5706b";
|
|
6491
6493
|
} else {
|
|
6492
6494
|
return "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78";
|
|
6493
6495
|
}
|
|
@@ -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=
|
|
6798
|
+
url += "&v=1000315";
|
|
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 "
|
|
6482
|
+
return "0x43eb15e430096fda554c131b73c29a80aee0b9c3d7234d8b52e4a9b1ac5fb630";
|
|
6481
6483
|
} else {
|
|
6482
6484
|
return "0x52eae33adeb44de55cfb3f281d4cc9e02d976181c0952f5323648b5717b33934";
|
|
6483
6485
|
}
|
|
@@ -6485,7 +6487,7 @@ var AggregatorClient10 = class {
|
|
|
6485
6487
|
// Include deepbookv3, scallop, bluefin
|
|
6486
6488
|
publishedAtV2() {
|
|
6487
6489
|
if (this.env === 0 /* Mainnet */) {
|
|
6488
|
-
return "
|
|
6490
|
+
return "0x347dd58bbd11cd82c8b386b344729717c04a998da73386e82a239cc196d5706b";
|
|
6489
6491
|
} else {
|
|
6490
6492
|
return "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78";
|
|
6491
6493
|
}
|
|
@@ -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=
|
|
6796
|
+
url += "&v=1000315";
|
|
6781
6797
|
const response = yield fetch(url);
|
|
6782
6798
|
return response;
|
|
6783
6799
|
} catch (error) {
|
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,
|
|
@@ -170,7 +186,7 @@ async function getRouter(endpoint: string, params: FindRouterParams) {
|
|
|
170
186
|
}
|
|
171
187
|
|
|
172
188
|
// set newest sdk version
|
|
173
|
-
url += "&v=
|
|
189
|
+
url += "&v=1000315"
|
|
174
190
|
|
|
175
191
|
const response = await fetch(url)
|
|
176
192
|
return response
|
package/src/client.ts
CHANGED
|
@@ -40,7 +40,7 @@ import { Scallop } from "./transaction/scallop"
|
|
|
40
40
|
import { Suilend } from "./transaction/suilend"
|
|
41
41
|
import { Bluefin } from "./transaction/bluefin"
|
|
42
42
|
import { HaedalPmm } from "./transaction/haedal_pmm"
|
|
43
|
-
|
|
43
|
+
|
|
44
44
|
|
|
45
45
|
export const CETUS = "CETUS"
|
|
46
46
|
export const DEEPBOOKV2 = "DEEPBOOK"
|
|
@@ -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 "0x11451575c775a3e633437b827ecbc1eb51a5964b0302210b28f5b89880be21a2" // version 5
|
|
410
|
+
return "0x43eb15e430096fda554c131b73c29a80aee0b9c3d7234d8b52e4a9b1ac5fb630" // pre
|
|
410
411
|
} else {
|
|
411
412
|
// return "0x0ed287d6c3fe4962d0994ffddc1d19a15fba6a81533f3f0dcc2bbcedebce0637" // version 2
|
|
412
413
|
return "0x52eae33adeb44de55cfb3f281d4cc9e02d976181c0952f5323648b5717b33934"
|
|
@@ -421,7 +422,8 @@ export class AggregatorClient {
|
|
|
421
422
|
// return "0x16d9418726c26d8cb4ce8c9dd75917fa9b1c7bf47d38d7a1a22603135f0f2a56" // version 4, add suilend
|
|
422
423
|
// return "0x3b6d71bdeb8ce5b06febfd3cfc29ecd60d50da729477c8b8038ecdae34541b91" // version 5, add bluefin
|
|
423
424
|
// return "0x81ade554cb24a7564ca43a4bfb7381b08d9e5c5f375162c95215b696ab903502" // version 6, force upgrade scallop
|
|
424
|
-
return "
|
|
425
|
+
return "0x347dd58bbd11cd82c8b386b344729717c04a998da73386e82a239cc196d5706b"
|
|
426
|
+
// return "0x20d4f23a1d119c6887cea9b036035e57ae90b4cb3d7a0acb94dfed72a9095fb7" // pre
|
|
425
427
|
} else {
|
|
426
428
|
return "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78"
|
|
427
429
|
}
|
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
|
})
|