@cetusprotocol/aggregator-sdk 0.0.0-experimental-20250811105138 → 0.0.0-experimental-20250813193744
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/README.md +4 -122
- package/benchmark-results/benchmark-results-2025-07-17T12-03-15-563Z.csv +3 -0
- package/benchmark-results/benchmark-results-2025-07-17T12-03-15-563Z.json +56 -0
- package/benchmark-results/benchmark-results-2025-07-17T12-03-34-148Z.csv +3 -0
- package/benchmark-results/benchmark-results-2025-07-17T12-03-34-148Z.json +56 -0
- package/benchmark-results/benchmark-results-2025-07-21T03-31-59-263Z.csv +21 -0
- package/benchmark-results/benchmark-results-2025-07-21T03-31-59-263Z.json +444 -0
- package/benchmark-results/benchmark-results-2025-07-21T07-54-54-916Z.csv +21 -0
- package/benchmark-results/benchmark-results-2025-07-21T07-54-54-916Z.json +503 -0
- package/benchmark-results/error-report-2025-07-17T12-03-34-148Z.md +18 -0
- package/benchmark-results/error-report-2025-07-21T03-31-59-263Z.md +18 -0
- package/benchmark-results/error-report-2025-07-21T07-54-54-916Z.md +18 -0
- package/benchmark-results/gas-analysis-report-2025-07-17T12-03-15-563Z.md +80 -0
- package/benchmark-results/gas-analysis-report-2025-07-17T12-03-34-148Z.md +80 -0
- package/benchmark-results/gas-analysis-report-2025-07-21T03-31-59-263Z.md +296 -0
- package/benchmark-results/gas-analysis-report-2025-07-21T07-54-54-916Z.md +323 -0
- package/dist/index.d.mts +290 -835
- package/dist/index.d.ts +290 -835
- package/dist/index.js +3391 -4066
- package/dist/index.mjs +3381 -3964
- package/package.json +4 -8
- package/.github/workflows/test.yml +0 -152
- package/.prettierrc +0 -11
- package/.vscode/settings.json +0 -8
- package/CLAUDE.md +0 -101
- package/docs/Cetus_Aggregator_V3_/346/216/245/345/217/243/346/226/207/346/241/243.md +0 -706
- package/docs/REFACTOR.md +0 -24
- package/docs//350/267/257/345/276/204/346/213/223/346/211/221/346/216/222/345/272/217.md +0 -208
package/README.md
CHANGED
|
@@ -29,123 +29,7 @@ Multi-Platform Support: Currently, we have integrated multiple mainstream DEXs o
|
|
|
29
29
|
|
|
30
30
|
By using our aggregator, you can trade more efficiently and securely on the Sui blockchain, fully leveraging the various opportunities brought by decentralized finance (DeFi).
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
The Cetus Aggregator SDK supports 25+ decentralized exchanges (DEXs) on the Sui blockchain:
|
|
35
|
-
|
|
36
|
-
- **Cetus**
|
|
37
|
-
- **DeepBook V3**
|
|
38
|
-
- **Kriya V2/V3**
|
|
39
|
-
- **FlowX V2/V3**
|
|
40
|
-
- **Turbos**
|
|
41
|
-
- **Aftermath**
|
|
42
|
-
- **Haedal**
|
|
43
|
-
- **Volo**
|
|
44
|
-
- **AfSui**
|
|
45
|
-
- **Bluemove**
|
|
46
|
-
- **Scallop**
|
|
47
|
-
- **Suilend**
|
|
48
|
-
- **Bluefin**
|
|
49
|
-
- **HaedalHMM**
|
|
50
|
-
- **Alphafi**
|
|
51
|
-
- **SpringSui**
|
|
52
|
-
- **Steamm CPMM**
|
|
53
|
-
- **Steamm OMM**
|
|
54
|
-
- **Metastable**
|
|
55
|
-
- **Obric**
|
|
56
|
-
- **HaWAL**
|
|
57
|
-
- **Momentum**
|
|
58
|
-
- **Magma**
|
|
59
|
-
- **Sevenk**
|
|
60
|
-
|
|
61
|
-
# Aggregator SDK V3
|
|
62
|
-
|
|
63
|
-
## Advantages of Aggregator Client V3
|
|
64
|
-
|
|
65
|
-
The new Aggregator Client V3 offers significant improvements over the previous version:
|
|
66
|
-
|
|
67
|
-
### Transaction Traceability
|
|
68
|
-
|
|
69
|
-
- **Complete Transaction History**: All swap transactions are fully traceable on the blockchain
|
|
70
|
-
- **Detailed Route Information**: Track exactly which DEXs and pools were used in multi-hop swaps
|
|
71
|
-
- **Gas Optimization Transparency**: See how transactions were optimized to reduce gas costs
|
|
72
|
-
|
|
73
|
-
### Transaction Merging for Gas Optimization
|
|
74
|
-
|
|
75
|
-
- **Reduced Gas Costs**: Significantly lower transaction fees through optimized execution paths
|
|
76
|
-
- **Smart Route Aggregation**: Automatically combines similar operations to minimize gas usage
|
|
77
|
-
|
|
78
|
-
### Enhanced Features
|
|
79
|
-
|
|
80
|
-
- **Increased Reliability**: More robust transaction execution with better error handling
|
|
81
|
-
|
|
82
|
-
## Migration from Aggregator Client to V3
|
|
83
|
-
|
|
84
|
-
### Installation
|
|
85
|
-
|
|
86
|
-
Both versions use the same package:
|
|
87
|
-
|
|
88
|
-
```bash
|
|
89
|
-
npm install @cetusprotocol/aggregator-sdk
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### Key Changes
|
|
93
|
-
|
|
94
|
-
1. **Client Initialization**
|
|
95
|
-
|
|
96
|
-
```typescript
|
|
97
|
-
// V2 (Legacy)
|
|
98
|
-
const client = new AggregatorClient({})
|
|
99
|
-
|
|
100
|
-
// V3 (New)
|
|
101
|
-
const client = new AggregatorClient({})
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
2. **Router Finding**
|
|
105
|
-
|
|
106
|
-
```typescript
|
|
107
|
-
// Both versions use the same API
|
|
108
|
-
const routers = await client.findRouters({
|
|
109
|
-
from: "0x2::sui::SUI",
|
|
110
|
-
target:
|
|
111
|
-
"0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS",
|
|
112
|
-
amount: new BN(1000000),
|
|
113
|
-
byAmountIn: true,
|
|
114
|
-
})
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
3. **Transaction Building**
|
|
118
|
-
|
|
119
|
-
```typescript
|
|
120
|
-
// V2 Method
|
|
121
|
-
await client.buildRouterSwap({
|
|
122
|
-
routers,
|
|
123
|
-
txb,
|
|
124
|
-
inputCoin,
|
|
125
|
-
slippage: 0.01,
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
// V3 Method (Recommended)
|
|
129
|
-
await client.fastRouterSwap({
|
|
130
|
-
routers,
|
|
131
|
-
txb,
|
|
132
|
-
slippage: 0.01,
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
// V3 Alternative (For PTB building)
|
|
136
|
-
const targetCoin = await client.routerSwap({
|
|
137
|
-
routers,
|
|
138
|
-
txb,
|
|
139
|
-
inputCoin,
|
|
140
|
-
slippage: 0.01,
|
|
141
|
-
})
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
4. **Benefits of Migration**
|
|
145
|
-
- Reduced gas costs through transaction merging
|
|
146
|
-
- Better transaction traceability
|
|
147
|
-
- Improved error handling and reliability
|
|
148
|
-
- Access to latest DEX integrations
|
|
32
|
+
# Aggregator SDK
|
|
149
33
|
|
|
150
34
|
## Install
|
|
151
35
|
|
|
@@ -248,20 +132,18 @@ CetusAggregatorV2ExtendV1 = { git = "https://github.com/CetusProtocol/aggregator
|
|
|
248
132
|
CetusAggregatorV2ExtendV2 = { git = "https://github.com/CetusProtocol/aggregator.git", subdir = "packages/cetus-aggregator-v2-extend-v2", rev = "mainnet", override = true }
|
|
249
133
|
```
|
|
250
134
|
|
|
251
|
-
# Simple Aggregator Contract Interface
|
|
252
|
-
|
|
253
|
-
- include: cetus, flowxv3, turbos, bluefin, haedalhmm, momentum, obric
|
|
135
|
+
# Simple Aggregator Contract Interface(include cetus, flowxv3, turbos, bluefin)
|
|
254
136
|
|
|
255
137
|
## Tags corresponding to different networks
|
|
256
138
|
|
|
257
139
|
| Contract | Tag of Repo | Latest published at address |
|
|
258
140
|
| --------------------- | ----------- | ------------------------------------------------------------------ |
|
|
259
|
-
| CetusAggregatorSimple | mainnet |
|
|
141
|
+
| CetusAggregatorSimple | mainnet | 0x594d67abc0778023ac852800578271dd7e18698ad06e6298034858c77612333d |
|
|
260
142
|
|
|
261
143
|
## Example
|
|
262
144
|
|
|
263
145
|
```
|
|
264
|
-
CetusAggregatorSimple = { git = "https://github.com/CetusProtocol/aggregator.git", subdir = "packages/cetus-aggregator-v2/simple-mainnet", rev = "mainnet-v1.
|
|
146
|
+
CetusAggregatorSimple = { git = "https://github.com/CetusProtocol/aggregator.git", subdir = "packages/cetus-aggregator-v2/simple-mainnet", rev = "mainnet-v1.49.1", override = true }
|
|
265
147
|
```
|
|
266
148
|
|
|
267
149
|
## Usage
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"v2": [
|
|
3
|
+
{
|
|
4
|
+
"gasMetrics": {
|
|
5
|
+
"computationCost": "1420000",
|
|
6
|
+
"storageCost": "8352400",
|
|
7
|
+
"storageRebate": "7290756",
|
|
8
|
+
"nonRefundableStorageFee": "73644",
|
|
9
|
+
"totalGasCost": "2555288",
|
|
10
|
+
"gasUsed": "1420000",
|
|
11
|
+
"gasPrice": "1000",
|
|
12
|
+
"success": true
|
|
13
|
+
},
|
|
14
|
+
"amountIn": "4c4b40",
|
|
15
|
+
"amountOut": "4a240be7",
|
|
16
|
+
"priceImpact": -24777.52,
|
|
17
|
+
"gasEfficiency": 486,
|
|
18
|
+
"provider": "MAGMA",
|
|
19
|
+
"route": [
|
|
20
|
+
"MAGMA"
|
|
21
|
+
],
|
|
22
|
+
"timestamp": 1752753791128
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"v3": [
|
|
26
|
+
{
|
|
27
|
+
"gasMetrics": {
|
|
28
|
+
"computationCost": "710000",
|
|
29
|
+
"storageCost": "8352400",
|
|
30
|
+
"storageRebate": "7290756",
|
|
31
|
+
"nonRefundableStorageFee": "73644",
|
|
32
|
+
"totalGasCost": "1845288",
|
|
33
|
+
"gasUsed": "710000",
|
|
34
|
+
"gasPrice": "1000",
|
|
35
|
+
"success": true
|
|
36
|
+
},
|
|
37
|
+
"amountIn": "4c4b40",
|
|
38
|
+
"amountOut": "4a289111",
|
|
39
|
+
"priceImpact": -24783.45,
|
|
40
|
+
"gasEfficiency": 674,
|
|
41
|
+
"provider": "MAGMA",
|
|
42
|
+
"route": [
|
|
43
|
+
"MAGMA"
|
|
44
|
+
],
|
|
45
|
+
"timestamp": 1752753794556
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
"summary": {
|
|
49
|
+
"v2AverageGas": "2555288",
|
|
50
|
+
"v3AverageGas": "1845288",
|
|
51
|
+
"gasSavingsPercent": 27.78,
|
|
52
|
+
"v2SuccessRate": 100,
|
|
53
|
+
"v3SuccessRate": 100,
|
|
54
|
+
"totalTests": 2
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"v2": [
|
|
3
|
+
{
|
|
4
|
+
"gasMetrics": {
|
|
5
|
+
"computationCost": "1420000",
|
|
6
|
+
"storageCost": "8352400",
|
|
7
|
+
"storageRebate": "7290756",
|
|
8
|
+
"nonRefundableStorageFee": "73644",
|
|
9
|
+
"totalGasCost": "2555288",
|
|
10
|
+
"gasUsed": "1420000",
|
|
11
|
+
"gasPrice": "1000",
|
|
12
|
+
"success": true
|
|
13
|
+
},
|
|
14
|
+
"amountIn": "4c4b40",
|
|
15
|
+
"amountOut": "4a289111",
|
|
16
|
+
"priceImpact": -24783.45,
|
|
17
|
+
"gasEfficiency": 486,
|
|
18
|
+
"provider": "MAGMA",
|
|
19
|
+
"route": [
|
|
20
|
+
"MAGMA"
|
|
21
|
+
],
|
|
22
|
+
"timestamp": 1752753809734
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"v3": [
|
|
26
|
+
{
|
|
27
|
+
"gasMetrics": {
|
|
28
|
+
"computationCost": "710000",
|
|
29
|
+
"storageCost": "8352400",
|
|
30
|
+
"storageRebate": "7290756",
|
|
31
|
+
"nonRefundableStorageFee": "73644",
|
|
32
|
+
"totalGasCost": "1845288",
|
|
33
|
+
"gasUsed": "710000",
|
|
34
|
+
"gasPrice": "1000",
|
|
35
|
+
"success": true
|
|
36
|
+
},
|
|
37
|
+
"amountIn": "4c4b40",
|
|
38
|
+
"amountOut": "4a289111",
|
|
39
|
+
"priceImpact": -24783.45,
|
|
40
|
+
"gasEfficiency": 674,
|
|
41
|
+
"provider": "MAGMA",
|
|
42
|
+
"route": [
|
|
43
|
+
"MAGMA"
|
|
44
|
+
],
|
|
45
|
+
"timestamp": 1752753813146
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
"summary": {
|
|
49
|
+
"v2AverageGas": "2555288",
|
|
50
|
+
"v3AverageGas": "1845288",
|
|
51
|
+
"gasSavingsPercent": 27.78,
|
|
52
|
+
"v2SuccessRate": 100,
|
|
53
|
+
"v3SuccessRate": 100,
|
|
54
|
+
"totalTests": 2
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Version,Provider,Success,AmountIn,AmountOut,TotalGasCost,ComputationCost,GasEfficiency,PriceImpact,Timestamp
|
|
2
|
+
V2,MAGMA,true,5000000,1258299255,2556656,1420000,492,-25065.98,1753068334517
|
|
3
|
+
V2,MAGMA,true,50000000,12574255625,2556656,1420000,4918,-25048.51,1753068346313
|
|
4
|
+
V2,MAGMA,true,500000000,125480226090,2764288,1420000,45393,-24996.04,1753068356111
|
|
5
|
+
V2,MAGMA,true,100000000000,24890183842651,5052200,2130000,4926603,-24790.18,1753068365179
|
|
6
|
+
V2,CETUS,true,500000,125980647,2829040,1420000,44,-25096.12,1753068374839
|
|
7
|
+
V2,CETUS,true,5000000,1258278343,2950184,1420000,426,-25065.56,1753068384363
|
|
8
|
+
V2,CETUS,true,50000000,12578426109,3014936,1420000,4172,-25056.85,1753068392839
|
|
9
|
+
V2,CETUS,true,10000000000,2515179479306,1913384,710000,1314518,-25051.79,1753068402439
|
|
10
|
+
V2,CETUS,true,10000000000,39721642,1913384,710000,20,99.6,1753068481963
|
|
11
|
+
V2,CETUS,true,100000000000,397530003,1913384,710000,207,99.6,1753068641345
|
|
12
|
+
V3,MAGMA,true,5000000,1258299255,1846656,710000,681,-25065.98,1753068338942
|
|
13
|
+
V3,MAGMA,true,50000000,12574255625,1846656,710000,6809,-25048.51,1753068351410
|
|
14
|
+
V3,MAGMA,true,500000000,125480226090,2054288,710000,61082,-24996.04,1753068360046
|
|
15
|
+
V3,MAGMA,true,100000000000,24890183842651,4342200,1420000,5732159,-24790.18,1753068369762
|
|
16
|
+
V3,CETUS,true,500000,125980647,2119040,710000,59,-25096.12,1753068379188
|
|
17
|
+
V3,CETUS,true,5000000,1258278343,2240184,710000,561,-25065.56,1753068387883
|
|
18
|
+
V3,CETUS,true,50000000,12578426109,3014936,1420000,4172,-25056.85,1753068397989
|
|
19
|
+
V3,CETUS,true,10000000000,2515179479306,1913384,710000,1314518,-25051.79,1753068407309
|
|
20
|
+
V3,CETUS,true,10000000000,39738545,2033464,710000,19,99.6,1753068558374
|
|
21
|
+
V3,CETUS,true,100000000000,398281652,1913384,710000,208,99.6,1753068718257
|