@cleave-protocol/ai-sdk 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +339 -2
- package/dist/index.cjs +1300 -0
- package/dist/index.d.cts +83 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.js +1263 -0
- package/package.json +86 -4
package/dist/index.js
ADDED
|
@@ -0,0 +1,1263 @@
|
|
|
1
|
+
import { tool } from "ai";
|
|
2
|
+
|
|
3
|
+
import { keccak_256 } from "@noble/hashes/sha3";
|
|
4
|
+
import { bytesToHex, hexToBytes } from "@noble/hashes/utils";
|
|
5
|
+
|
|
6
|
+
var ALLOWLIST = {
|
|
7
|
+
"version": "2026-11-02.5",
|
|
8
|
+
"nativeSentinel": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
|
9
|
+
"acrossHandler": "0x0F7Ae28dE1C8532170AD4ee566B5801485c13a0E",
|
|
10
|
+
"referral": {
|
|
11
|
+
"sameChainBps": 0,
|
|
12
|
+
"crossChainBps": 1,
|
|
13
|
+
"stablecoinBps": 0
|
|
14
|
+
},
|
|
15
|
+
"gas": {
|
|
16
|
+
"factory": "0x129f934211510b8C0Ac0ef07366f5dba92477c36",
|
|
17
|
+
"feeRecipient": "0x94a58bf17B32521259F5Ce5A9aa27Ee4a056323B",
|
|
18
|
+
"swap": {
|
|
19
|
+
"template": "0x122d0a1e55d6Cd966c906AB27C4C74e7a3B9eD79",
|
|
20
|
+
"versionTag": "0x9744c579ec32e4534ef3d6f2e0b49f87a1a014cc10f07a491df0e2ad2272dcc4",
|
|
21
|
+
"initCodeHash": "0xc76e4cbffcdff814308300ace2e74aca62fff95bb80571c64768e66352297672"
|
|
22
|
+
},
|
|
23
|
+
"cross_chain": {
|
|
24
|
+
"template": "0x9484F3f4930C0eF1b573a7062BAfF37E451f9035",
|
|
25
|
+
"versionTag": "0x3ecb2a726296395d5f34da76ea67f3d19c3d2970e1d33a394f758a7fcc87a008",
|
|
26
|
+
"initCodeHash": "0x3a228bdeea8677d726e9ef8c8cf180f15bbfd119e3bd09caf2ce894668e12ede"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"chains": {
|
|
30
|
+
"1": {
|
|
31
|
+
"name": "Ethereum",
|
|
32
|
+
"usdc": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
33
|
+
"usdcDecimals": 6,
|
|
34
|
+
"wrappedNative": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
|
35
|
+
"nativeSymbol": "ETH",
|
|
36
|
+
"wrappedSymbol": "WETH",
|
|
37
|
+
"composer": "0x436Ac858fD25706a8380b8AFb38Bc7538B852409",
|
|
38
|
+
"houseReferrer": "0x69d3661ac6935a33D59b8A6964f0523182A5ae7d",
|
|
39
|
+
"stablecoins": [
|
|
40
|
+
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
41
|
+
"0xdAC17F958D2ee523a2206206994597C13D831ec7"
|
|
42
|
+
],
|
|
43
|
+
"stargateRailId": "0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404",
|
|
44
|
+
"gasDeliveryShell": "0xed10296A4B2F4E51674E4dEdCA1f53Dd9e0259f4",
|
|
45
|
+
"gasPay": {
|
|
46
|
+
"routerV3": "0x30809f82f8Df91e976B02F09dc64E0da8eFB1e92",
|
|
47
|
+
"acrossUsdcAdapter": "0xdf88ef691b8eD60F61660fB5Ae937c405aB6415A",
|
|
48
|
+
"railId": "0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916"
|
|
49
|
+
},
|
|
50
|
+
"targets": {
|
|
51
|
+
"0x016750b998AaB0b4b07AA6a2276335053A798758": {
|
|
52
|
+
"role": "swap_shell",
|
|
53
|
+
"selectors": {
|
|
54
|
+
"0xab33b1ec": "swapWithBlob"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"0x5AfF91027390f731058AcC15E0A3F927b250c9FE": {
|
|
58
|
+
"role": "measured_shell",
|
|
59
|
+
"selectors": {
|
|
60
|
+
"0xe0b7822f": "swapMeasuredWithBlobV1"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"0x30809f82f8Df91e976B02F09dc64E0da8eFB1e92": {
|
|
64
|
+
"role": "router_v3",
|
|
65
|
+
"selectors": {
|
|
66
|
+
"0x84022178": "crossChainSwap",
|
|
67
|
+
"0xf79eec2e": "crossChainSwapNative",
|
|
68
|
+
"0x9edd28ad": "bridgeToken"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2": {
|
|
72
|
+
"role": "wrapped_native",
|
|
73
|
+
"selectors": {
|
|
74
|
+
"0xd0e30db0": "deposit",
|
|
75
|
+
"0x2e1a7d4d": "withdraw"
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"0x5c7BCd6E7De5423a257D81B442095A1a6ced35C5": {
|
|
79
|
+
"role": "across_spoke_pool",
|
|
80
|
+
"selectors": {
|
|
81
|
+
"0xad5425c6": "deposit"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"0x97CCDBea4632140639aD5eA9b944aa034eb15fD4": {
|
|
85
|
+
"role": "across_periphery_native_only",
|
|
86
|
+
"selectors": {
|
|
87
|
+
"0x609ea081": "depositNative"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"lanes": {
|
|
92
|
+
"10": {
|
|
93
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 10,
|
|
94
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 10,
|
|
95
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 10,
|
|
96
|
+
"0x61a012ca05dbda272441751b0a350f6bbf2996f752862f4eba3fce9c7e8a89e6": 10,
|
|
97
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30111,
|
|
98
|
+
"0xed0f0a3ae066b02930027c7cc065548bade2974a98f517699d023130faa00e23": 2
|
|
99
|
+
},
|
|
100
|
+
"56": {
|
|
101
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 56,
|
|
102
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 56,
|
|
103
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 56,
|
|
104
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30102
|
|
105
|
+
},
|
|
106
|
+
"137": {
|
|
107
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 137,
|
|
108
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 137,
|
|
109
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 137,
|
|
110
|
+
"0x61a012ca05dbda272441751b0a350f6bbf2996f752862f4eba3fce9c7e8a89e6": 137,
|
|
111
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30109,
|
|
112
|
+
"0xed0f0a3ae066b02930027c7cc065548bade2974a98f517699d023130faa00e23": 7
|
|
113
|
+
},
|
|
114
|
+
"8453": {
|
|
115
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 8453,
|
|
116
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 8453,
|
|
117
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 8453,
|
|
118
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30184,
|
|
119
|
+
"0xed0f0a3ae066b02930027c7cc065548bade2974a98f517699d023130faa00e23": 6
|
|
120
|
+
},
|
|
121
|
+
"42161": {
|
|
122
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 42161,
|
|
123
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 42161,
|
|
124
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 42161,
|
|
125
|
+
"0x61a012ca05dbda272441751b0a350f6bbf2996f752862f4eba3fce9c7e8a89e6": 42161,
|
|
126
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30110,
|
|
127
|
+
"0xed0f0a3ae066b02930027c7cc065548bade2974a98f517699d023130faa00e23": 3
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
"10": {
|
|
132
|
+
"name": "Optimism",
|
|
133
|
+
"usdc": "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
|
|
134
|
+
"usdcDecimals": 6,
|
|
135
|
+
"wrappedNative": "0x4200000000000000000000000000000000000006",
|
|
136
|
+
"nativeSymbol": "ETH",
|
|
137
|
+
"wrappedSymbol": "WETH",
|
|
138
|
+
"composer": "0xAB708AEd94a07B9da06D92b4796988ee6eD0D32c",
|
|
139
|
+
"houseReferrer": "0x69d3661ac6935a33D59b8A6964f0523182A5ae7d",
|
|
140
|
+
"stablecoins": [
|
|
141
|
+
"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
|
|
142
|
+
"0x94b008aA00579c1307B0EF2c499aD98a8ce58e58"
|
|
143
|
+
],
|
|
144
|
+
"stargateRailId": "0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404",
|
|
145
|
+
"gasDeliveryShell": "0xe46A542F395eB64d482BCf504c529cdb05D70878",
|
|
146
|
+
"gasPay": {
|
|
147
|
+
"routerV3": "0x34FCCA283211224877F89F814eeA0a3a912fd354",
|
|
148
|
+
"acrossUsdcAdapter": "0x28A4501fBb3d8A72Dc7A49Fbf262910d391659eE",
|
|
149
|
+
"railId": "0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916"
|
|
150
|
+
},
|
|
151
|
+
"targets": {
|
|
152
|
+
"0xb08F28a3575805ee1E3729fc19Ab7E869CBAF563": {
|
|
153
|
+
"role": "swap_shell",
|
|
154
|
+
"selectors": {
|
|
155
|
+
"0xab33b1ec": "swapWithBlob"
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
"0x003d4C95756608Ed4C11C5d0Ad9ca4c4076cAF20": {
|
|
159
|
+
"role": "measured_shell",
|
|
160
|
+
"selectors": {
|
|
161
|
+
"0xe0b7822f": "swapMeasuredWithBlobV1"
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
"0x34FCCA283211224877F89F814eeA0a3a912fd354": {
|
|
165
|
+
"role": "router_v3",
|
|
166
|
+
"selectors": {
|
|
167
|
+
"0x84022178": "crossChainSwap",
|
|
168
|
+
"0xf79eec2e": "crossChainSwapNative",
|
|
169
|
+
"0x9edd28ad": "bridgeToken"
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
"0x4200000000000000000000000000000000000006": {
|
|
173
|
+
"role": "wrapped_native",
|
|
174
|
+
"selectors": {
|
|
175
|
+
"0xd0e30db0": "deposit",
|
|
176
|
+
"0x2e1a7d4d": "withdraw"
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
"0x6f26Bf09B1C792e3228e5467807a900A503c0281": {
|
|
180
|
+
"role": "across_spoke_pool",
|
|
181
|
+
"selectors": {
|
|
182
|
+
"0xad5425c6": "deposit"
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
"0x97CCDBea4632140639aD5eA9b944aa034eb15fD4": {
|
|
186
|
+
"role": "across_periphery_native_only",
|
|
187
|
+
"selectors": {
|
|
188
|
+
"0x609ea081": "depositNative"
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
"lanes": {
|
|
193
|
+
"1": {
|
|
194
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 1,
|
|
195
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 1,
|
|
196
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 1,
|
|
197
|
+
"0x61a012ca05dbda272441751b0a350f6bbf2996f752862f4eba3fce9c7e8a89e6": 1,
|
|
198
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30101,
|
|
199
|
+
"0xed0f0a3ae066b02930027c7cc065548bade2974a98f517699d023130faa00e23": 0
|
|
200
|
+
},
|
|
201
|
+
"56": {
|
|
202
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 56,
|
|
203
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 56,
|
|
204
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 56,
|
|
205
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30102
|
|
206
|
+
},
|
|
207
|
+
"137": {
|
|
208
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 137,
|
|
209
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 137,
|
|
210
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 137,
|
|
211
|
+
"0x61a012ca05dbda272441751b0a350f6bbf2996f752862f4eba3fce9c7e8a89e6": 137,
|
|
212
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30109,
|
|
213
|
+
"0xed0f0a3ae066b02930027c7cc065548bade2974a98f517699d023130faa00e23": 7
|
|
214
|
+
},
|
|
215
|
+
"8453": {
|
|
216
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 8453,
|
|
217
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 8453,
|
|
218
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 8453,
|
|
219
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30184,
|
|
220
|
+
"0xed0f0a3ae066b02930027c7cc065548bade2974a98f517699d023130faa00e23": 6
|
|
221
|
+
},
|
|
222
|
+
"42161": {
|
|
223
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 42161,
|
|
224
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 42161,
|
|
225
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 42161,
|
|
226
|
+
"0x61a012ca05dbda272441751b0a350f6bbf2996f752862f4eba3fce9c7e8a89e6": 42161,
|
|
227
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30110,
|
|
228
|
+
"0xed0f0a3ae066b02930027c7cc065548bade2974a98f517699d023130faa00e23": 3
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
"56": {
|
|
233
|
+
"name": "BNB Chain",
|
|
234
|
+
"usdc": "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",
|
|
235
|
+
"usdcDecimals": 18,
|
|
236
|
+
"wrappedNative": "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
|
|
237
|
+
"nativeSymbol": "BNB",
|
|
238
|
+
"wrappedSymbol": "WBNB",
|
|
239
|
+
"composer": "0xE242F3DeB6B8d9e76e93b0bf5e461B12a722e86E",
|
|
240
|
+
"houseReferrer": "0x69d3661ac6935a33D59b8A6964f0523182A5ae7d",
|
|
241
|
+
"stablecoins": [
|
|
242
|
+
"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",
|
|
243
|
+
"0x55d398326f99059fF775485246999027B3197955"
|
|
244
|
+
],
|
|
245
|
+
"stargateRailId": "0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404",
|
|
246
|
+
"gasDeliveryShell": "0xe648D17e146C736A7296BA72260fB2ed5bb58c99",
|
|
247
|
+
"gasPay": null,
|
|
248
|
+
"targets": {
|
|
249
|
+
"0x48dD089939C9a29211e7De9417e91A141D37F697": {
|
|
250
|
+
"role": "swap_shell",
|
|
251
|
+
"selectors": {
|
|
252
|
+
"0xab33b1ec": "swapWithBlob"
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
"0xC269a4F4dEbD4036597ee830349d824D5bA9ca7E": {
|
|
256
|
+
"role": "measured_shell",
|
|
257
|
+
"selectors": {
|
|
258
|
+
"0xe0b7822f": "swapMeasuredWithBlobV1"
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
"0x02ED7CD8D60768797328B098ce0df2fa99db6f23": {
|
|
262
|
+
"role": "router_v3",
|
|
263
|
+
"selectors": {
|
|
264
|
+
"0x84022178": "crossChainSwap",
|
|
265
|
+
"0xf79eec2e": "crossChainSwapNative",
|
|
266
|
+
"0x9edd28ad": "bridgeToken"
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c": {
|
|
270
|
+
"role": "wrapped_native",
|
|
271
|
+
"selectors": {
|
|
272
|
+
"0xd0e30db0": "deposit",
|
|
273
|
+
"0x2e1a7d4d": "withdraw"
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
"0x4e8E101924eDE233C13e2D8622DC8aED2872d505": {
|
|
277
|
+
"role": "across_spoke_pool",
|
|
278
|
+
"selectors": {
|
|
279
|
+
"0xad5425c6": "deposit"
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
"0x97CCDBea4632140639aD5eA9b944aa034eb15fD4": {
|
|
283
|
+
"role": "across_periphery_native_only",
|
|
284
|
+
"selectors": {
|
|
285
|
+
"0x609ea081": "depositNative"
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
"lanes": {
|
|
290
|
+
"1": {
|
|
291
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 1,
|
|
292
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 1,
|
|
293
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 1,
|
|
294
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30101
|
|
295
|
+
},
|
|
296
|
+
"10": {
|
|
297
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 10,
|
|
298
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 10,
|
|
299
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 10,
|
|
300
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30111
|
|
301
|
+
},
|
|
302
|
+
"137": {
|
|
303
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 137,
|
|
304
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 137,
|
|
305
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 137,
|
|
306
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30109
|
|
307
|
+
},
|
|
308
|
+
"8453": {
|
|
309
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 8453,
|
|
310
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 8453,
|
|
311
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 8453,
|
|
312
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30184
|
|
313
|
+
},
|
|
314
|
+
"42161": {
|
|
315
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 42161,
|
|
316
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 42161,
|
|
317
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 42161,
|
|
318
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30110
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
"137": {
|
|
323
|
+
"name": "Polygon",
|
|
324
|
+
"usdc": "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
|
|
325
|
+
"usdcDecimals": 6,
|
|
326
|
+
"wrappedNative": "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
|
|
327
|
+
"nativeSymbol": "POL",
|
|
328
|
+
"wrappedSymbol": "WPOL",
|
|
329
|
+
"composer": "0x6Cbc5c7AA249EDD719001786b6e0a07D44027693",
|
|
330
|
+
"houseReferrer": "0x69d3661ac6935a33D59b8A6964f0523182A5ae7d",
|
|
331
|
+
"stablecoins": [
|
|
332
|
+
"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
|
|
333
|
+
"0xc2132D05D31c914a87C6611C10748AEb04B58e8F"
|
|
334
|
+
],
|
|
335
|
+
"stargateRailId": "0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404",
|
|
336
|
+
"gasDeliveryShell": "0x02ED7CD8D60768797328B098ce0df2fa99db6f23",
|
|
337
|
+
"gasPay": {
|
|
338
|
+
"routerV3": "0xEa0E8caE2dba07D3BC828f42fd6219fF93ddCe97",
|
|
339
|
+
"acrossUsdcAdapter": "0x25b14009e495D781D2180d3E3B3a86050967dd2A",
|
|
340
|
+
"railId": "0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916"
|
|
341
|
+
},
|
|
342
|
+
"targets": {
|
|
343
|
+
"0x5b4a223D8489a3b97d4EBe8fE93C6A7aC3Ec1AD6": {
|
|
344
|
+
"role": "swap_shell",
|
|
345
|
+
"selectors": {
|
|
346
|
+
"0xab33b1ec": "swapWithBlob"
|
|
347
|
+
}
|
|
348
|
+
},
|
|
349
|
+
"0xA06eE4d57A2E6ea9213Ab4Bce2C055fD09BB43A1": {
|
|
350
|
+
"role": "measured_shell",
|
|
351
|
+
"selectors": {
|
|
352
|
+
"0xe0b7822f": "swapMeasuredWithBlobV1"
|
|
353
|
+
}
|
|
354
|
+
},
|
|
355
|
+
"0xEa0E8caE2dba07D3BC828f42fd6219fF93ddCe97": {
|
|
356
|
+
"role": "router_v3",
|
|
357
|
+
"selectors": {
|
|
358
|
+
"0x84022178": "crossChainSwap",
|
|
359
|
+
"0xf79eec2e": "crossChainSwapNative",
|
|
360
|
+
"0x9edd28ad": "bridgeToken"
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270": {
|
|
364
|
+
"role": "wrapped_native",
|
|
365
|
+
"selectors": {
|
|
366
|
+
"0xd0e30db0": "deposit",
|
|
367
|
+
"0x2e1a7d4d": "withdraw"
|
|
368
|
+
}
|
|
369
|
+
},
|
|
370
|
+
"0x9295ee1d8C5b022Be115A2AD3c30C72E34e7F096": {
|
|
371
|
+
"role": "across_spoke_pool",
|
|
372
|
+
"selectors": {
|
|
373
|
+
"0xad5425c6": "deposit"
|
|
374
|
+
}
|
|
375
|
+
},
|
|
376
|
+
"0x97CCDBea4632140639aD5eA9b944aa034eb15fD4": {
|
|
377
|
+
"role": "across_periphery_native_only",
|
|
378
|
+
"selectors": {
|
|
379
|
+
"0x609ea081": "depositNative"
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
"lanes": {
|
|
384
|
+
"1": {
|
|
385
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 1,
|
|
386
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 1,
|
|
387
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 1,
|
|
388
|
+
"0x61a012ca05dbda272441751b0a350f6bbf2996f752862f4eba3fce9c7e8a89e6": 1,
|
|
389
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30101,
|
|
390
|
+
"0xed0f0a3ae066b02930027c7cc065548bade2974a98f517699d023130faa00e23": 0
|
|
391
|
+
},
|
|
392
|
+
"10": {
|
|
393
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 10,
|
|
394
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 10,
|
|
395
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 10,
|
|
396
|
+
"0x61a012ca05dbda272441751b0a350f6bbf2996f752862f4eba3fce9c7e8a89e6": 10,
|
|
397
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30111,
|
|
398
|
+
"0xed0f0a3ae066b02930027c7cc065548bade2974a98f517699d023130faa00e23": 2
|
|
399
|
+
},
|
|
400
|
+
"56": {
|
|
401
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 56,
|
|
402
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 56,
|
|
403
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 56,
|
|
404
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30102
|
|
405
|
+
},
|
|
406
|
+
"8453": {
|
|
407
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 8453,
|
|
408
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 8453,
|
|
409
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 8453,
|
|
410
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30184,
|
|
411
|
+
"0xed0f0a3ae066b02930027c7cc065548bade2974a98f517699d023130faa00e23": 6
|
|
412
|
+
},
|
|
413
|
+
"42161": {
|
|
414
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 42161,
|
|
415
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 42161,
|
|
416
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 42161,
|
|
417
|
+
"0x61a012ca05dbda272441751b0a350f6bbf2996f752862f4eba3fce9c7e8a89e6": 42161,
|
|
418
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30110,
|
|
419
|
+
"0xed0f0a3ae066b02930027c7cc065548bade2974a98f517699d023130faa00e23": 3
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
},
|
|
423
|
+
"8453": {
|
|
424
|
+
"name": "Base",
|
|
425
|
+
"usdc": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
426
|
+
"usdcDecimals": 6,
|
|
427
|
+
"wrappedNative": "0x4200000000000000000000000000000000000006",
|
|
428
|
+
"nativeSymbol": "ETH",
|
|
429
|
+
"wrappedSymbol": "WETH",
|
|
430
|
+
"composer": "0x58b73b40b5ED797833955397dF989AA2DEdD50A4",
|
|
431
|
+
"houseReferrer": "0x69d3661ac6935a33D59b8A6964f0523182A5ae7d",
|
|
432
|
+
"stablecoins": [
|
|
433
|
+
"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
434
|
+
"0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2"
|
|
435
|
+
],
|
|
436
|
+
"stargateRailId": "0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404",
|
|
437
|
+
"gasDeliveryShell": "0x3A4569133c21013bbBc99a733FB891A7fffafD9a",
|
|
438
|
+
"gasPay": {
|
|
439
|
+
"routerV3": "0x545fef65c37ECEE32309d879ABafaa959E9F114C",
|
|
440
|
+
"acrossUsdcAdapter": "0x1000517094c532f0e4fF0E61fC6cD33daea2E64f",
|
|
441
|
+
"railId": "0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916"
|
|
442
|
+
},
|
|
443
|
+
"targets": {
|
|
444
|
+
"0xb08F28a3575805ee1E3729fc19Ab7E869CBAF563": {
|
|
445
|
+
"role": "swap_shell",
|
|
446
|
+
"selectors": {
|
|
447
|
+
"0xab33b1ec": "swapWithBlob"
|
|
448
|
+
}
|
|
449
|
+
},
|
|
450
|
+
"0x003d4C95756608Ed4C11C5d0Ad9ca4c4076cAF20": {
|
|
451
|
+
"role": "measured_shell",
|
|
452
|
+
"selectors": {
|
|
453
|
+
"0xe0b7822f": "swapMeasuredWithBlobV1"
|
|
454
|
+
}
|
|
455
|
+
},
|
|
456
|
+
"0x545fef65c37ECEE32309d879ABafaa959E9F114C": {
|
|
457
|
+
"role": "router_v3",
|
|
458
|
+
"selectors": {
|
|
459
|
+
"0x84022178": "crossChainSwap",
|
|
460
|
+
"0xf79eec2e": "crossChainSwapNative",
|
|
461
|
+
"0x9edd28ad": "bridgeToken"
|
|
462
|
+
}
|
|
463
|
+
},
|
|
464
|
+
"0x4200000000000000000000000000000000000006": {
|
|
465
|
+
"role": "wrapped_native",
|
|
466
|
+
"selectors": {
|
|
467
|
+
"0xd0e30db0": "deposit",
|
|
468
|
+
"0x2e1a7d4d": "withdraw"
|
|
469
|
+
}
|
|
470
|
+
},
|
|
471
|
+
"0x09aea4b2242abC8bb4BB78D537A67a245A7bEC64": {
|
|
472
|
+
"role": "across_spoke_pool",
|
|
473
|
+
"selectors": {
|
|
474
|
+
"0xad5425c6": "deposit"
|
|
475
|
+
}
|
|
476
|
+
},
|
|
477
|
+
"0x97CCDBea4632140639aD5eA9b944aa034eb15fD4": {
|
|
478
|
+
"role": "across_periphery_native_only",
|
|
479
|
+
"selectors": {
|
|
480
|
+
"0x609ea081": "depositNative"
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
},
|
|
484
|
+
"lanes": {
|
|
485
|
+
"1": {
|
|
486
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 1,
|
|
487
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 1,
|
|
488
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 1,
|
|
489
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30101,
|
|
490
|
+
"0xed0f0a3ae066b02930027c7cc065548bade2974a98f517699d023130faa00e23": 0
|
|
491
|
+
},
|
|
492
|
+
"10": {
|
|
493
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 10,
|
|
494
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 10,
|
|
495
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 10,
|
|
496
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30111,
|
|
497
|
+
"0xed0f0a3ae066b02930027c7cc065548bade2974a98f517699d023130faa00e23": 2
|
|
498
|
+
},
|
|
499
|
+
"56": {
|
|
500
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 56,
|
|
501
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 56,
|
|
502
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 56,
|
|
503
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30102
|
|
504
|
+
},
|
|
505
|
+
"137": {
|
|
506
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 137,
|
|
507
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 137,
|
|
508
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 137,
|
|
509
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30109,
|
|
510
|
+
"0xed0f0a3ae066b02930027c7cc065548bade2974a98f517699d023130faa00e23": 7
|
|
511
|
+
},
|
|
512
|
+
"42161": {
|
|
513
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 42161,
|
|
514
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 42161,
|
|
515
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 42161,
|
|
516
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30110,
|
|
517
|
+
"0xed0f0a3ae066b02930027c7cc065548bade2974a98f517699d023130faa00e23": 3
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
},
|
|
521
|
+
"42161": {
|
|
522
|
+
"name": "Arbitrum",
|
|
523
|
+
"usdc": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
524
|
+
"usdcDecimals": 6,
|
|
525
|
+
"wrappedNative": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
|
|
526
|
+
"nativeSymbol": "ETH",
|
|
527
|
+
"wrappedSymbol": "WETH",
|
|
528
|
+
"composer": "0xe484191bfF3e4DED3520d1D8e0fcf098CAef4cE4",
|
|
529
|
+
"houseReferrer": "0x69d3661ac6935a33D59b8A6964f0523182A5ae7d",
|
|
530
|
+
"stablecoins": [
|
|
531
|
+
"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
532
|
+
"0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"
|
|
533
|
+
],
|
|
534
|
+
"stargateRailId": "0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404",
|
|
535
|
+
"gasDeliveryShell": "0x02ED7CD8D60768797328B098ce0df2fa99db6f23",
|
|
536
|
+
"gasPay": {
|
|
537
|
+
"routerV3": "0xEa0E8caE2dba07D3BC828f42fd6219fF93ddCe97",
|
|
538
|
+
"acrossUsdcAdapter": "0x25b14009e495D781D2180d3E3B3a86050967dd2A",
|
|
539
|
+
"railId": "0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916"
|
|
540
|
+
},
|
|
541
|
+
"targets": {
|
|
542
|
+
"0x4052700f83324Be5710d187b7bbEa9837DfFa8fc": {
|
|
543
|
+
"role": "swap_shell",
|
|
544
|
+
"selectors": {
|
|
545
|
+
"0xab33b1ec": "swapWithBlob"
|
|
546
|
+
}
|
|
547
|
+
},
|
|
548
|
+
"0x78D851D8BC6A9b9739549E7515Bf02D6394E1794": {
|
|
549
|
+
"role": "measured_shell",
|
|
550
|
+
"selectors": {
|
|
551
|
+
"0xe0b7822f": "swapMeasuredWithBlobV1"
|
|
552
|
+
}
|
|
553
|
+
},
|
|
554
|
+
"0xEa0E8caE2dba07D3BC828f42fd6219fF93ddCe97": {
|
|
555
|
+
"role": "router_v3",
|
|
556
|
+
"selectors": {
|
|
557
|
+
"0x84022178": "crossChainSwap",
|
|
558
|
+
"0xf79eec2e": "crossChainSwapNative",
|
|
559
|
+
"0x9edd28ad": "bridgeToken"
|
|
560
|
+
}
|
|
561
|
+
},
|
|
562
|
+
"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1": {
|
|
563
|
+
"role": "wrapped_native",
|
|
564
|
+
"selectors": {
|
|
565
|
+
"0xd0e30db0": "deposit",
|
|
566
|
+
"0x2e1a7d4d": "withdraw"
|
|
567
|
+
}
|
|
568
|
+
},
|
|
569
|
+
"0xe35e9842fceaCA96570B734083f4a58e8F7C5f2A": {
|
|
570
|
+
"role": "across_spoke_pool",
|
|
571
|
+
"selectors": {
|
|
572
|
+
"0xad5425c6": "deposit"
|
|
573
|
+
}
|
|
574
|
+
},
|
|
575
|
+
"0x97CCDBea4632140639aD5eA9b944aa034eb15fD4": {
|
|
576
|
+
"role": "across_periphery_native_only",
|
|
577
|
+
"selectors": {
|
|
578
|
+
"0x609ea081": "depositNative"
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
},
|
|
582
|
+
"lanes": {
|
|
583
|
+
"1": {
|
|
584
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 1,
|
|
585
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 1,
|
|
586
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 1,
|
|
587
|
+
"0x61a012ca05dbda272441751b0a350f6bbf2996f752862f4eba3fce9c7e8a89e6": 1,
|
|
588
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30101,
|
|
589
|
+
"0xed0f0a3ae066b02930027c7cc065548bade2974a98f517699d023130faa00e23": 0
|
|
590
|
+
},
|
|
591
|
+
"10": {
|
|
592
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 10,
|
|
593
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 10,
|
|
594
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 10,
|
|
595
|
+
"0x61a012ca05dbda272441751b0a350f6bbf2996f752862f4eba3fce9c7e8a89e6": 10,
|
|
596
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30111,
|
|
597
|
+
"0xed0f0a3ae066b02930027c7cc065548bade2974a98f517699d023130faa00e23": 2
|
|
598
|
+
},
|
|
599
|
+
"56": {
|
|
600
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 56,
|
|
601
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 56,
|
|
602
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 56,
|
|
603
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30102
|
|
604
|
+
},
|
|
605
|
+
"137": {
|
|
606
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 137,
|
|
607
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 137,
|
|
608
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 137,
|
|
609
|
+
"0x61a012ca05dbda272441751b0a350f6bbf2996f752862f4eba3fce9c7e8a89e6": 137,
|
|
610
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30109,
|
|
611
|
+
"0xed0f0a3ae066b02930027c7cc065548bade2974a98f517699d023130faa00e23": 7
|
|
612
|
+
},
|
|
613
|
+
"8453": {
|
|
614
|
+
"0xf6c86ecb0564cd8d732c9d68c369fbc03a0c351db7419e70be166d26a2ed4916": 8453,
|
|
615
|
+
"0xa28bababc0e2b0c1c28d78d20a75d5ef0afd16dc155828d76a2bf6b97805d328": 8453,
|
|
616
|
+
"0xcadb263249f9536655ea392f5245afe7bf96a0ed7ff0095bb817c6a77c9b8d84": 8453,
|
|
617
|
+
"0xb247d4fab2445d0279df94160c242cb8298d9aea57aa6b6af3c9dfddce2d1404": 30184,
|
|
618
|
+
"0xed0f0a3ae066b02930027c7cc065548bade2974a98f517699d023130faa00e23": 6
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
|
|
625
|
+
var low = (a) => a.toLowerCase();
|
|
626
|
+
var NATIVE = low(ALLOWLIST.nativeSentinel);
|
|
627
|
+
var HANDLER = low(ALLOWLIST.acrossHandler);
|
|
628
|
+
var FACTORY = low(ALLOWLIST.gas.factory);
|
|
629
|
+
var FEE_RECIPIENT = low(ALLOWLIST.gas.feeRecipient);
|
|
630
|
+
var ZERO_ADDRESS = `0x${"0".repeat(40)}`;
|
|
631
|
+
var CHAINS = new Map(
|
|
632
|
+
Object.entries(ALLOWLIST.chains).map(([id, c]) => [
|
|
633
|
+
Number(id),
|
|
634
|
+
{
|
|
635
|
+
usdc: low(c.usdc),
|
|
636
|
+
usdcDecimals: c.usdcDecimals,
|
|
637
|
+
wrappedNative: low(c.wrappedNative),
|
|
638
|
+
symbols: /* @__PURE__ */ new Map([
|
|
639
|
+
["usdc", low(c.usdc)],
|
|
640
|
+
[low(c.nativeSymbol), NATIVE],
|
|
641
|
+
[low(c.wrappedSymbol), low(c.wrappedNative)]
|
|
642
|
+
]),
|
|
643
|
+
composer: low(c.composer),
|
|
644
|
+
houseReferrer: low(c.houseReferrer),
|
|
645
|
+
stablecoins: new Set(c.stablecoins.map(low)),
|
|
646
|
+
stargateRailId: low(c.stargateRailId),
|
|
647
|
+
deliveryShell: low(c.gasDeliveryShell),
|
|
648
|
+
gasPay: c.gasPay === null ? null : { routerV3: low(c.gasPay.routerV3), acrossUsdcAdapter: low(c.gasPay.acrossUsdcAdapter), railId: low(c.gasPay.railId) },
|
|
649
|
+
targets: new Map(Object.entries(c.targets).map(([a, t]) => [low(a), { role: t.role, selectors: new Set(Object.keys(t.selectors)) }])),
|
|
650
|
+
spokePool: Object.entries(c.targets).find(([, t]) => t.role === "across_spoke_pool")?.[0].toLowerCase() ?? null,
|
|
651
|
+
lanes: new Map(Object.entries(c.lanes).map(([to, rails]) => [Number(to), new Map(Object.entries(rails).map(([r, d]) => [low(r), BigInt(d)]))]))
|
|
652
|
+
}
|
|
653
|
+
])
|
|
654
|
+
);
|
|
655
|
+
var MAX_UINT = (1n << 256n) - 1n;
|
|
656
|
+
var HALF_UINT = 1n << 255n;
|
|
657
|
+
var ADDRESS = /^0x[0-9a-fA-F]{40}$/;
|
|
658
|
+
var HEX_DATA = /^0x(?:[0-9a-fA-F]{2})*$/;
|
|
659
|
+
var HEX_QUANTITY = /^0x[0-9a-fA-F]{1,64}$/;
|
|
660
|
+
var BYTES32 = /^0x[0-9a-fA-F]{64}$/;
|
|
661
|
+
var DECIMAL_INT = /^[0-9]{1,78}$/;
|
|
662
|
+
var DECIMAL = /^([0-9]{1,30})(?:\.([0-9]{1,30}))?$/;
|
|
663
|
+
var APPROVE = "0x095ea7b3";
|
|
664
|
+
var SWAP = "0xab33b1ec";
|
|
665
|
+
var MEASURED = "0xe0b7822f";
|
|
666
|
+
var CROSS = "0x84022178";
|
|
667
|
+
var CROSS_NATIVE = "0xf79eec2e";
|
|
668
|
+
var BRIDGE = "0x9edd28ad";
|
|
669
|
+
var DEPOSIT = "0xd0e30db0";
|
|
670
|
+
var WITHDRAW = "0x2e1a7d4d";
|
|
671
|
+
var SPOKE_DEPOSIT = "0xad5425c6";
|
|
672
|
+
var DEPOSIT_NATIVE = "0x609ea081";
|
|
673
|
+
var SAME_CHAIN = /* @__PURE__ */ new Set([SWAP, MEASURED, DEPOSIT, WITHDRAW]);
|
|
674
|
+
var PULLS = {
|
|
675
|
+
[SWAP]: { token: 0, pulled: [2] },
|
|
676
|
+
[MEASURED]: { token: 0, pulled: [9] },
|
|
677
|
+
[CROSS]: { token: 0, pulled: [2, 9] },
|
|
678
|
+
[BRIDGE]: { token: 0, pulled: [1] },
|
|
679
|
+
[SPOKE_DEPOSIT]: { token: 2, pulled: [4] }
|
|
680
|
+
};
|
|
681
|
+
var AMOUNT_IN = { [SWAP]: 2, [MEASURED]: 2, [CROSS]: 2, [CROSS_NATIVE]: 2, [BRIDGE]: 1, [SPOKE_DEPOSIT]: 4, [DEPOSIT_NATIVE]: 4, [WITHDRAW]: 0 };
|
|
682
|
+
var REFERRAL = { [SWAP]: [6, 7], [MEASURED]: [6, 7], [CROSS]: [6, 7], [CROSS_NATIVE]: [6, 7], [BRIDGE]: [7, 8] };
|
|
683
|
+
var NATIVE_TOKEN = { [SWAP]: 0, [MEASURED]: 0, [CROSS]: 0, [CROSS_NATIVE]: 0, [DEPOSIT_NATIVE]: 3 };
|
|
684
|
+
var ERC20_ONLY = /* @__PURE__ */ new Set([CROSS, BRIDGE, SPOKE_DEPOSIT, WITHDRAW]);
|
|
685
|
+
var WETH_AS_ERC20 = { [SWAP]: 8, [MEASURED]: 8 };
|
|
686
|
+
var RAIL_WORD = { [CROSS]: 12, [CROSS_NATIVE]: 12, [BRIDGE]: 2 };
|
|
687
|
+
var MIN_OUT = { [SWAP]: [3], [MEASURED]: [3, 10], [CROSS]: [3, 16], [CROSS_NATIVE]: [3, 16], [BRIDGE]: [6], [SPOKE_DEPOSIT]: [5], [DEPOSIT_NATIVE]: [6] };
|
|
688
|
+
var SWAP_ORDER = [
|
|
689
|
+
["chainId", "uint"],
|
|
690
|
+
["token", "address"],
|
|
691
|
+
["shell", "address"],
|
|
692
|
+
["amount", "uint"],
|
|
693
|
+
["fee", "uint"],
|
|
694
|
+
["feeRecipient", "address"],
|
|
695
|
+
["maxProtocolFeeBps", "uint"],
|
|
696
|
+
["refundTo", "address"],
|
|
697
|
+
["recipient", "address"],
|
|
698
|
+
["minOut", "uint"],
|
|
699
|
+
["deadline", "uint"],
|
|
700
|
+
["quoteId", "bytes32"]
|
|
701
|
+
];
|
|
702
|
+
var ACROSS_ORDER = [
|
|
703
|
+
["chainId", "uint"],
|
|
704
|
+
["token", "address"],
|
|
705
|
+
["router", "address"],
|
|
706
|
+
["railId", "bytes32"],
|
|
707
|
+
["adapter", "address"],
|
|
708
|
+
["dstChainId", "uint"],
|
|
709
|
+
["dstToken", "address"],
|
|
710
|
+
["dstDecimals", "uint8"],
|
|
711
|
+
["handler", "address"],
|
|
712
|
+
["dstShell", "address"],
|
|
713
|
+
["dstWrappedNative", "address"],
|
|
714
|
+
["amount", "uint"],
|
|
715
|
+
["fee", "uint"],
|
|
716
|
+
["feeRecipient", "address"],
|
|
717
|
+
["maxProtocolFeeBps", "uint"],
|
|
718
|
+
["relayFee", "uint"],
|
|
719
|
+
["refundTo", "address"],
|
|
720
|
+
["recipient", "address"],
|
|
721
|
+
["outputAmount", "uint"],
|
|
722
|
+
["minOut", "uint"],
|
|
723
|
+
["messageHash", "bytes32"],
|
|
724
|
+
["deadline", "uint"],
|
|
725
|
+
["quoteId", "bytes32"]
|
|
726
|
+
];
|
|
727
|
+
var AUTH_FIELDS = [
|
|
728
|
+
["from", "address"],
|
|
729
|
+
["to", "address"],
|
|
730
|
+
["value", "uint256"],
|
|
731
|
+
["validAfter", "uint256"],
|
|
732
|
+
["validBefore", "uint256"],
|
|
733
|
+
["nonce", "bytes32"]
|
|
734
|
+
];
|
|
735
|
+
var Refusal = class {
|
|
736
|
+
constructor(rule, message) {
|
|
737
|
+
this.rule = rule;
|
|
738
|
+
this.message = message;
|
|
739
|
+
}
|
|
740
|
+
rule;
|
|
741
|
+
message;
|
|
742
|
+
};
|
|
743
|
+
function fail(rule, message) {
|
|
744
|
+
throw new Refusal(rule, message);
|
|
745
|
+
}
|
|
746
|
+
function guard(run) {
|
|
747
|
+
let current = "P1";
|
|
748
|
+
try {
|
|
749
|
+
run((rule) => {
|
|
750
|
+
current = rule;
|
|
751
|
+
});
|
|
752
|
+
return { ok: true };
|
|
753
|
+
} catch (err) {
|
|
754
|
+
const r = err instanceof Refusal ? err : new Refusal(current, "the answer is malformed");
|
|
755
|
+
return { ok: false, rule: r.rule, message: `${r.rule}: ${r.message}` };
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
var isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
759
|
+
function object(v, rule, what) {
|
|
760
|
+
return isObject(v) ? v : fail(rule, `${what} is missing`);
|
|
761
|
+
}
|
|
762
|
+
function address(v, rule, what) {
|
|
763
|
+
return typeof v === "string" && ADDRESS.test(v) ? low(v) : fail(rule, `${what} is not an address`);
|
|
764
|
+
}
|
|
765
|
+
function integer(v, rule, what) {
|
|
766
|
+
if (typeof v === "number" && Number.isSafeInteger(v) && v >= 0) return BigInt(v);
|
|
767
|
+
if (typeof v === "string" && DECIMAL_INT.test(v)) {
|
|
768
|
+
const n = BigInt(v);
|
|
769
|
+
if (n <= MAX_UINT) return n;
|
|
770
|
+
}
|
|
771
|
+
return fail(rule, `${what} is not an unsigned integer`);
|
|
772
|
+
}
|
|
773
|
+
function quantity(v, rule, what) {
|
|
774
|
+
return typeof v === "string" && HEX_QUANTITY.test(v) ? BigInt(v) : fail(rule, `${what} is not a hex quantity`);
|
|
775
|
+
}
|
|
776
|
+
function bytes32(v, rule, what) {
|
|
777
|
+
return typeof v === "string" && BYTES32.test(v) ? low(v) : fail(rule, `${what} is not 32 bytes`);
|
|
778
|
+
}
|
|
779
|
+
function units(v, decimals, rule, what) {
|
|
780
|
+
const m = typeof v === "string" ? DECIMAL.exec(v) : null;
|
|
781
|
+
const frac = m?.[2] ?? "";
|
|
782
|
+
if (m === null || frac.length > decimals) return fail(rule, `${what} is not a decimal amount`);
|
|
783
|
+
return BigInt(m[1]) * 10n ** BigInt(decimals) + BigInt(frac.padEnd(decimals, "0") || "0");
|
|
784
|
+
}
|
|
785
|
+
function normalDecimal(v, rule, what) {
|
|
786
|
+
const m = typeof v === "string" ? DECIMAL.exec(v) : null;
|
|
787
|
+
if (m === null) return fail(rule, `${what} is not a decimal amount`);
|
|
788
|
+
const frac = (m[2] ?? "").replace(/0+$/, "");
|
|
789
|
+
return `${BigInt(m[1])}${frac === "" ? "" : `.${frac}`}`;
|
|
790
|
+
}
|
|
791
|
+
function word(data, k, rule, what) {
|
|
792
|
+
const w = data.slice(10 + 64 * k, 74 + 64 * k);
|
|
793
|
+
return w.length === 64 ? w : fail(rule, `${what} is missing from the calldata`);
|
|
794
|
+
}
|
|
795
|
+
function wordInt(data, k, rule, what) {
|
|
796
|
+
return BigInt(`0x${word(data, k, rule, what)}`);
|
|
797
|
+
}
|
|
798
|
+
function wordAddress(data, k, rule, what) {
|
|
799
|
+
const w = word(data, k, rule, what);
|
|
800
|
+
return w.startsWith("0".repeat(24)) ? `0x${w.slice(24)}` : fail(rule, `${what} is not an address`);
|
|
801
|
+
}
|
|
802
|
+
function sameChain(v, chainId) {
|
|
803
|
+
return typeof v === "number" && v === chainId || typeof v === "string" && DECIMAL_INT.test(v) && BigInt(v) === BigInt(chainId);
|
|
804
|
+
}
|
|
805
|
+
var keccakHex = (hex) => `0x${bytesToHex(keccak_256(hexToBytes(hex.slice(2))))}`;
|
|
806
|
+
function checkPlanSwap(request, body) {
|
|
807
|
+
return guard((at) => {
|
|
808
|
+
at("P1");
|
|
809
|
+
const fromChainId = request.fromChainId;
|
|
810
|
+
const toChainId = request.toChainId ?? fromChainId;
|
|
811
|
+
const wallet = address(request.wallet, "P1", "wallet");
|
|
812
|
+
const calls = Array.isArray(body.calls) ? body.calls : fail("P1", "calls are missing");
|
|
813
|
+
if (body.blocked === true) {
|
|
814
|
+
if (calls.length > 0) fail("P1", "a blocked plan carries calls");
|
|
815
|
+
return;
|
|
816
|
+
}
|
|
817
|
+
if (calls.length === 0) fail("P1", "the plan has no calls");
|
|
818
|
+
const parsed = calls.map((raw, i) => {
|
|
819
|
+
const c = object(raw, "P1", `call ${i}`);
|
|
820
|
+
if (!sameChain(c.chainId, fromChainId)) fail("P1", `call ${i} is for another chain`);
|
|
821
|
+
if (address(c.from, "P1", `call ${i} from`) !== wallet) fail("P1", `call ${i} is from another wallet`);
|
|
822
|
+
const to = address(c.to, "P1", `call ${i} to`);
|
|
823
|
+
const data = typeof c.data === "string" && HEX_DATA.test(c.data) && c.data.length >= 10 ? low(c.data) : fail("P1", `call ${i} data is malformed`);
|
|
824
|
+
return { to, data, value: quantity(c.value, "P1", `call ${i} value`) };
|
|
825
|
+
});
|
|
826
|
+
const main = parsed[parsed.length - 1];
|
|
827
|
+
const selector = main.data.slice(0, 10);
|
|
828
|
+
at("P2");
|
|
829
|
+
const chain2 = CHAINS.get(fromChainId) ?? fail("P2", "the chain is not on the allowlist");
|
|
830
|
+
const target = chain2.targets.get(main.to) ?? fail("P2", "the main call's target is not on the allowlist");
|
|
831
|
+
if (!target.selectors.has(selector)) fail("P2", "the main call's function is not allowed on its target");
|
|
832
|
+
if (SAME_CHAIN.has(selector) !== (toChainId === fromChainId)) fail("P2", "the main call does not fit the route");
|
|
833
|
+
at("P3");
|
|
834
|
+
const send = object(body.send, "P3", "send");
|
|
835
|
+
if (!sameChain(send.chainId, fromChainId)) fail("P3", "send is on another chain");
|
|
836
|
+
const token2 = address(send.token, "P3", "send.token");
|
|
837
|
+
const sellToken = request.sellToken.trim();
|
|
838
|
+
const pinned = ADDRESS.test(sellToken) ? low(sellToken) : chain2.symbols.get(low(sellToken)) ?? null;
|
|
839
|
+
if (pinned !== null && pinned !== token2) fail("P3", "send.token is not the sell token");
|
|
840
|
+
if (normalDecimal(send.amount, "P3", "send.amount") !== normalDecimal(request.amount, "P3", "amount")) fail("P3", "send.amount is not the requested amount");
|
|
841
|
+
const native = token2 === NATIVE;
|
|
842
|
+
const approves = parsed.slice(0, -1);
|
|
843
|
+
if (approves.length > 2) fail("P3", "more than two calls come before the main call");
|
|
844
|
+
const approved = approves.map((a, i) => {
|
|
845
|
+
if (!a.data.startsWith(APPROVE) || a.data.length !== 138 || a.value !== 0n) fail("P3", `call ${i} is not a plain approve`);
|
|
846
|
+
if (native || a.to !== token2) fail("P3", `call ${i} approves another token`);
|
|
847
|
+
if (wordAddress(a.data, 0, "P3", "spender") !== main.to) fail("P3", `call ${i} approves another spender`);
|
|
848
|
+
const amount2 = wordInt(a.data, 1, "P3", "approve amount");
|
|
849
|
+
if (amount2 >= HALF_UINT) fail("P3", `call ${i} is an unlimited approve`);
|
|
850
|
+
return amount2;
|
|
851
|
+
});
|
|
852
|
+
const last = approved[approved.length - 1];
|
|
853
|
+
if (last === 0n) fail("P3", "the last approve is zero");
|
|
854
|
+
if (approved.length === 2 && approved[0] !== 0n) fail("P3", "only approve(0) may come before the approve");
|
|
855
|
+
at("P4");
|
|
856
|
+
const pulls = PULLS[selector];
|
|
857
|
+
if (pulls === void 0) {
|
|
858
|
+
if (approves.length > 0) fail("P4", "this function takes no approve");
|
|
859
|
+
if (selector === WITHDRAW ? main.to !== token2 : !native) fail("P4", "the main call spends another token");
|
|
860
|
+
} else if (!native) {
|
|
861
|
+
if (wordAddress(main.data, pulls.token, "P4", "token") !== token2) fail("P4", "the main call spends another token");
|
|
862
|
+
const pulled = pulls.pulled.map((k) => wordInt(main.data, k, "P4", "amount")).reduce((a, b) => a > b ? a : b);
|
|
863
|
+
if (last !== void 0 && pulled !== last) fail("P4", "the main call pulls another amount than approved");
|
|
864
|
+
if (pulled > 2n * wordInt(main.data, AMOUNT_IN[selector], "P4", "amountIn")) fail("P4", "the main call pulls more than twice its input");
|
|
865
|
+
}
|
|
866
|
+
if (native && ERC20_ONLY.has(selector)) fail("P4", "a native sell cannot use this function");
|
|
867
|
+
const mode = WETH_AS_ERC20[selector];
|
|
868
|
+
if (mode !== void 0 && native && wordInt(main.data, mode, "P4", "native mode") !== 0n) fail("P4", "the main call spends the wrapped token, not the native coin");
|
|
869
|
+
if ((selector === CROSS || selector === CROSS_NATIVE) && wordInt(main.data, 8, "P4", "native mode") !== 1n) fail("P4", "the router swap is not encoded as the backend encodes it");
|
|
870
|
+
const wrappedWord = NATIVE_TOKEN[selector];
|
|
871
|
+
if (native && wrappedWord !== void 0 && wordAddress(main.data, wrappedWord, "P4", "token") !== chain2.wrappedNative) fail("P4", "the main call spends another token");
|
|
872
|
+
const decimals = native || token2 === chain2.wrappedNative ? 18 : token2 === chain2.usdc ? chain2.usdcDecimals : null;
|
|
873
|
+
const inWord = AMOUNT_IN[selector];
|
|
874
|
+
if (decimals !== null && inWord !== void 0 && wordInt(main.data, inWord, "P4", "amountIn") !== units(request.amount, decimals, "P4", "amount")) fail("P4", "the main call sells another amount than requested");
|
|
875
|
+
for (const k of MIN_OUT[selector] ?? []) if (wordInt(main.data, k, "P4", "minimum") === 0n) fail("P4", "the main call has no minimum");
|
|
876
|
+
at("P5");
|
|
877
|
+
const fees = body.fees === void 0 ? [] : Array.isArray(body.fees) ? body.fees : fail("P5", "fees are malformed");
|
|
878
|
+
let value = native ? units(send.amount, 18, "P5", "send.amount") : 0n;
|
|
879
|
+
const messaging = fees.map((f) => object(f, "P5", "fee")).filter((f) => f.kind === "native_messaging");
|
|
880
|
+
if (messaging.length > 1) fail("P5", "more than one native messaging fee");
|
|
881
|
+
for (const fee of messaging) {
|
|
882
|
+
const railWord = RAIL_WORD[selector];
|
|
883
|
+
if (railWord === void 0 || `0x${word(main.data, railWord, "P5", "railId")}` !== chain2.stargateRailId) fail("P5", "only the Stargate rail takes a native messaging fee");
|
|
884
|
+
value += units(fee.amount, 18, "P5", "fee amount");
|
|
885
|
+
}
|
|
886
|
+
if (main.value !== value) fail("P5", "the main call sends another native value");
|
|
887
|
+
const referral = REFERRAL[selector];
|
|
888
|
+
if (referral !== void 0) {
|
|
889
|
+
const referrer = wordAddress(main.data, referral[0], "P5", "referrer");
|
|
890
|
+
const bps = wordInt(main.data, referral[1], "P5", "referral fee");
|
|
891
|
+
const free = [ZERO_ADDRESS, BigInt(SAME_CHAIN.has(selector) ? ALLOWLIST.referral.sameChainBps : ALLOWLIST.referral.stablecoinBps)];
|
|
892
|
+
const house = [chain2.houseReferrer, BigInt(ALLOWLIST.referral.crossChainBps)];
|
|
893
|
+
const dst2 = CHAINS.get(toChainId);
|
|
894
|
+
const receive = isObject(body.receive) ? body.receive : null;
|
|
895
|
+
const buyToken2 = request.buyToken.trim();
|
|
896
|
+
const tokenOut = typeof receive?.token === "string" && ADDRESS.test(receive.token) ? low(receive.token) : ADDRESS.test(buyToken2) ? low(buyToken2) : dst2?.symbols.get(low(buyToken2)) ?? null;
|
|
897
|
+
const stableIn = chain2.stablecoins.has(token2);
|
|
898
|
+
const allowed = SAME_CHAIN.has(selector) ? [free] : !stableIn ? [house] : tokenOut === null ? [free, house] : [dst2?.stablecoins.has(tokenOut) === true ? free : house];
|
|
899
|
+
if (!allowed.some(([a, b]) => a === referrer && b === bps)) fail("P5", "the referral fee goes to another address or has another size");
|
|
900
|
+
}
|
|
901
|
+
at("P6");
|
|
902
|
+
const recipient = request.recipient === void 0 ? wallet : address(request.recipient, "P6", "recipient");
|
|
903
|
+
const composer = toChainId === fromChainId ? null : CHAINS.get(toChainId)?.composer ?? null;
|
|
904
|
+
const arrives = (a) => a === recipient || a === HANDLER || a === composer;
|
|
905
|
+
const at6 = (k, what) => wordAddress(main.data, k, "P6", what);
|
|
906
|
+
const lane = (railWord, dstWord) => {
|
|
907
|
+
const dstId = chain2.lanes.get(toChainId)?.get(`0x${word(main.data, railWord, "P6", "railId")}`);
|
|
908
|
+
if (dstId === void 0 || wordInt(main.data, dstWord, "P6", "destination") !== dstId) fail("P6", "the transfer goes to another chain");
|
|
909
|
+
};
|
|
910
|
+
const dst = CHAINS.get(toChainId);
|
|
911
|
+
const buyToken = request.buyToken.trim();
|
|
912
|
+
const out = ADDRESS.test(buyToken) ? low(buyToken) : dst?.symbols.get(low(buyToken)) ?? null;
|
|
913
|
+
const outWord = out === null ? null : out === NATIVE ? dst?.wrappedNative ?? null : out;
|
|
914
|
+
const output = (k) => {
|
|
915
|
+
if (outWord !== null && at6(k, "output token") !== outWord) fail("P6", "the main call delivers another token");
|
|
916
|
+
};
|
|
917
|
+
const destination = (k) => {
|
|
918
|
+
if (wordInt(main.data, k, "P6", "destination") !== BigInt(toChainId)) fail("P6", "the transfer goes to another chain");
|
|
919
|
+
};
|
|
920
|
+
switch (selector) {
|
|
921
|
+
case SWAP:
|
|
922
|
+
case MEASURED:
|
|
923
|
+
if (at6(5, "recipient") !== recipient) fail("P6", "the swap pays another recipient");
|
|
924
|
+
output(1);
|
|
925
|
+
if (!native) {
|
|
926
|
+
const flag = wordInt(main.data, 8, "P6", "native output");
|
|
927
|
+
if (out !== null ? flag !== (out === NATIVE ? 0n : 1n) : flag === 0n && at6(1, "output token") !== chain2.wrappedNative) fail("P6", "the main call delivers another token");
|
|
928
|
+
}
|
|
929
|
+
break;
|
|
930
|
+
case CROSS:
|
|
931
|
+
case CROSS_NATIVE:
|
|
932
|
+
if (at6(5, "source recipient") !== main.to) fail("P6", "the source swap pays out of the router");
|
|
933
|
+
if (!arrives(at6(14, "recipient"))) fail("P6", "the transfer pays another recipient");
|
|
934
|
+
if (at6(15, "refund recipient") !== wallet) fail("P6", "refunds go to another address");
|
|
935
|
+
lane(12, 13);
|
|
936
|
+
break;
|
|
937
|
+
case BRIDGE:
|
|
938
|
+
if (!arrives(at6(4, "recipient"))) fail("P6", "the transfer pays another recipient");
|
|
939
|
+
if (at6(5, "refund recipient") !== wallet) fail("P6", "refunds go to another address");
|
|
940
|
+
lane(2, 3);
|
|
941
|
+
break;
|
|
942
|
+
case SPOKE_DEPOSIT:
|
|
943
|
+
if (at6(0, "depositor") !== wallet) fail("P6", "refunds go to another address");
|
|
944
|
+
if (![recipient, HANDLER].includes(at6(1, "recipient"))) fail("P6", "the transfer pays another recipient");
|
|
945
|
+
destination(6);
|
|
946
|
+
output(3);
|
|
947
|
+
break;
|
|
948
|
+
case DEPOSIT_NATIVE:
|
|
949
|
+
if (at6(0, "spoke pool") !== chain2.spokePool) fail("P6", "the deposit goes to another pool");
|
|
950
|
+
if (at6(1, "depositor") !== wallet) fail("P6", "refunds go to another address");
|
|
951
|
+
if (![recipient, HANDLER].includes(at6(2, "recipient"))) fail("P6", "the transfer pays another recipient");
|
|
952
|
+
destination(7);
|
|
953
|
+
output(5);
|
|
954
|
+
break;
|
|
955
|
+
case DEPOSIT:
|
|
956
|
+
case WITHDRAW:
|
|
957
|
+
if (recipient !== wallet) fail("P6", "wrapping pays the wallet, not the recipient");
|
|
958
|
+
if (out !== null && out !== (selector === DEPOSIT ? chain2.wrappedNative : NATIVE)) fail("P6", "the main call delivers another token");
|
|
959
|
+
break;
|
|
960
|
+
default:
|
|
961
|
+
fail("P6", "the main call has no recipient rule");
|
|
962
|
+
}
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
function encodeOrder(order, fields) {
|
|
966
|
+
const keys = Object.keys(order);
|
|
967
|
+
if (keys.length !== fields.length || !fields.every(([name]) => keys.includes(name))) fail("G4", "the order has other fields");
|
|
968
|
+
return fields.map(([name, type]) => {
|
|
969
|
+
const v = order[name];
|
|
970
|
+
if (type === "address") return address(v, "G4", `order.${name}`).slice(2).padStart(64, "0");
|
|
971
|
+
if (type === "bytes32") return bytes32(v, "G4", `order.${name}`).slice(2);
|
|
972
|
+
const n = integer(v, "G4", `order.${name}`);
|
|
973
|
+
if (type === "uint8" && n > 255n) fail("G4", `order.${name} is out of range`);
|
|
974
|
+
return n.toString(16).padStart(64, "0");
|
|
975
|
+
}).join("");
|
|
976
|
+
}
|
|
977
|
+
var toDst = (amount2, from, to) => to >= from ? amount2 * 10n ** BigInt(to - from) : amount2 / 10n ** BigInt(from - to);
|
|
978
|
+
var GAS_SKEW_SEC = 120;
|
|
979
|
+
function checkGetGas(request, body, nowSec = Math.floor(Date.now() / 1e3)) {
|
|
980
|
+
return guard((at) => {
|
|
981
|
+
if (request.offer !== void 0) return;
|
|
982
|
+
at("G1");
|
|
983
|
+
const payChainId = request.payChainId ?? fail("G1", "the request has no pay chain");
|
|
984
|
+
const chainId = request.chainId ?? fail("G1", "the request has no delivery chain");
|
|
985
|
+
const pay = CHAINS.get(payChainId);
|
|
986
|
+
const gasPay = pay?.gasPay ?? fail("G1", "the pay chain is not on the allowlist");
|
|
987
|
+
const usdc = pay.usdc;
|
|
988
|
+
const payDecimals = pay.usdcDecimals;
|
|
989
|
+
const wallet = request.wallet === void 0 ? null : address(request.wallet, "G1", "wallet");
|
|
990
|
+
if (wallet !== null && body.typedData === void 0) fail("G1", "the offer has no authorization to sign");
|
|
991
|
+
const typed = body.typedData === void 0 ? null : object(body.typedData, "G1", "typedData");
|
|
992
|
+
const message = typed === null ? null : object(typed.message, "G1", "typedData.message");
|
|
993
|
+
if (typed !== null && message !== null) {
|
|
994
|
+
if (typed.primaryType !== "ReceiveWithAuthorization") fail("G1", "the authorization is not ReceiveWithAuthorization");
|
|
995
|
+
const types = object(typed.types, "G1", "typedData.types");
|
|
996
|
+
const fields = Array.isArray(types.ReceiveWithAuthorization) ? types.ReceiveWithAuthorization : fail("G1", "the authorization type is missing");
|
|
997
|
+
if (fields.length !== AUTH_FIELDS.length || !fields.every((f, i) => isObject(f) && f.name === AUTH_FIELDS[i]?.[0] && f.type === AUTH_FIELDS[i]?.[1])) fail("G1", "the authorization type has other fields");
|
|
998
|
+
const domain = object(typed.domain, "G1", "typedData.domain");
|
|
999
|
+
if (Object.keys(domain).length !== 4 || domain.name !== "USD Coin" || domain.version !== "2") fail("G1", "the domain is not USD Coin version 2");
|
|
1000
|
+
if (!sameChain(domain.chainId, payChainId)) fail("G1", "the domain is on another chain");
|
|
1001
|
+
if (address(domain.verifyingContract, "G1", "verifyingContract") !== usdc) fail("G1", "the authorization is for another token");
|
|
1002
|
+
if (wallet === null || address(message.from, "G1", "message.from") !== wallet) fail("G1", "the authorization is from another wallet");
|
|
1003
|
+
if (integer(message.validAfter, "G1", "validAfter") !== 0n) fail("G1", "validAfter is not 0");
|
|
1004
|
+
}
|
|
1005
|
+
at("G2");
|
|
1006
|
+
const order = object(body.order, "G2", "order");
|
|
1007
|
+
const amount2 = units(request.amount, payDecimals, "G2", "amount");
|
|
1008
|
+
if (integer(order.amount, "G2", "order.amount") !== amount2) fail("G2", "the order amount is not the requested amount");
|
|
1009
|
+
if (message !== null && integer(message.value, "G2", "message.value") !== amount2) fail("G2", "the authorization moves another amount");
|
|
1010
|
+
const deadline = integer(order.deadline, "G2", "order.deadline");
|
|
1011
|
+
if (message !== null && integer(message.validBefore, "G2", "validBefore") > deadline) fail("G2", "the authorization outlives the order");
|
|
1012
|
+
if (deadline > BigInt(nowSec + (payChainId === chainId && payChainId !== 1 ? 900 : 1200) + GAS_SKEW_SEC)) fail("G2", "the order deadline is too far away");
|
|
1013
|
+
if (integer(order.chainId, "G2", "order.chainId") !== BigInt(payChainId)) fail("G2", "the order is on another chain");
|
|
1014
|
+
if (address(order.token, "G2", "order.token") !== usdc) fail("G2", "the order takes another token");
|
|
1015
|
+
const recipient = address(request.recipient, "G2", "recipient");
|
|
1016
|
+
if (address(order.recipient, "G2", "order.recipient") !== recipient) fail("G2", "the order pays another recipient");
|
|
1017
|
+
const swap = payChainId === chainId;
|
|
1018
|
+
const refundTo = request.refundTo !== void 0 ? address(request.refundTo, "G2", "refundTo") : wallet ?? (swap ? recipient : fail("G2", "the order has no refund address"));
|
|
1019
|
+
if (address(order.refundTo, "G2", "order.refundTo") !== refundTo) fail("G2", "the order refunds another address");
|
|
1020
|
+
const fee = integer(order.fee, "G2", "order.fee");
|
|
1021
|
+
if (fee >= amount2) fail("G2", "the fee takes the whole amount");
|
|
1022
|
+
if (fee !== units(object(body.fee, "G2", "fee").usdc, payDecimals, "G2", "fee.usdc")) fail("G2", "the order fee is not the fee shown");
|
|
1023
|
+
const minOut = integer(order.minOut, "G2", "order.minOut");
|
|
1024
|
+
if (minOut === 0n || minOut !== integer(object(body.receive, "G2", "receive").minimumWei, "G2", "receive.minimumWei")) fail("G2", "the order minimum is not the minimum shown");
|
|
1025
|
+
const dst = CHAINS.get(chainId) ?? fail("G2", "the delivery chain is not on the allowlist");
|
|
1026
|
+
if (!swap) {
|
|
1027
|
+
const relayFee = integer(order.relayFee, "G2", "order.relayFee");
|
|
1028
|
+
if (relayFee * 2n > amount2 - fee) fail("G2", "the relay fee is above half the amount");
|
|
1029
|
+
if (integer(order.outputAmount, "G2", "order.outputAmount") !== toDst(amount2 - fee - relayFee, payDecimals, dst.usdcDecimals)) fail("G2", "the bridged amount is not the amount after fees");
|
|
1030
|
+
}
|
|
1031
|
+
at("G3");
|
|
1032
|
+
if (body.kind !== (swap ? "swap" : "cross_chain")) fail("G3", "the order is of another kind");
|
|
1033
|
+
if (body.payChainId !== payChainId || body.chainId !== chainId) fail("G3", "the offer is for other chains");
|
|
1034
|
+
const spec = swap ? ALLOWLIST.gas.swap : ALLOWLIST.gas.cross_chain;
|
|
1035
|
+
if (address(body.factory, "G3", "factory") !== FACTORY) fail("G3", "the factory is not the pinned one");
|
|
1036
|
+
if (address(body.template, "G3", "template") !== low(spec.template)) fail("G3", "the template is not the pinned one");
|
|
1037
|
+
const pinned = (name, want) => {
|
|
1038
|
+
if (address(order[name], "G3", `order.${name}`) !== want) fail("G3", `order.${name} is not the pinned one`);
|
|
1039
|
+
};
|
|
1040
|
+
pinned("feeRecipient", FEE_RECIPIENT);
|
|
1041
|
+
if (integer(order.maxProtocolFeeBps, "G3", "order.maxProtocolFeeBps") !== 0n) fail("G3", "the order allows a protocol fee");
|
|
1042
|
+
if (swap) pinned("shell", dst.deliveryShell);
|
|
1043
|
+
else {
|
|
1044
|
+
pinned("router", gasPay.routerV3);
|
|
1045
|
+
pinned("adapter", gasPay.acrossUsdcAdapter);
|
|
1046
|
+
pinned("handler", HANDLER);
|
|
1047
|
+
pinned("dstToken", dst.usdc);
|
|
1048
|
+
pinned("dstShell", dst.deliveryShell);
|
|
1049
|
+
pinned("dstWrappedNative", dst.wrappedNative);
|
|
1050
|
+
const railId = bytes32(order.railId, "G3", "order.railId");
|
|
1051
|
+
if (railId !== gasPay.railId || pay.lanes.get(chainId)?.has(railId) !== true) fail("G3", "order.railId is not the pinned one");
|
|
1052
|
+
if (integer(order.dstChainId, "G3", "order.dstChainId") !== BigInt(chainId)) fail("G3", "the order delivers on another chain");
|
|
1053
|
+
if (integer(order.dstDecimals, "G3", "order.dstDecimals") !== BigInt(dst.usdcDecimals)) fail("G3", "order.dstDecimals is not the pinned one");
|
|
1054
|
+
}
|
|
1055
|
+
at("G4");
|
|
1056
|
+
const orderHash = keccakHex(`${low(spec.versionTag)}${encodeOrder(order, swap ? SWAP_ORDER : ACROSS_ORDER)}`);
|
|
1057
|
+
if (bytes32(body.orderHash, "G4", "orderHash") !== orderHash) fail("G4", "orderHash does not match the order");
|
|
1058
|
+
const payTo = `0x${keccakHex(`0xff${FACTORY.slice(2)}${orderHash.slice(2)}${low(spec.initCodeHash).slice(2)}`).slice(26)}`;
|
|
1059
|
+
if (address(body.payTo, "G4", "payTo") !== payTo) fail("G4", "payTo does not match the order");
|
|
1060
|
+
if (message !== null) {
|
|
1061
|
+
if (bytes32(message.nonce, "G4", "message.nonce") !== orderHash) fail("G4", "the authorization nonce is not the order hash");
|
|
1062
|
+
if (address(message.to, "G4", "message.to") !== payTo) fail("G4", "the authorization pays another address");
|
|
1063
|
+
}
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
var PLAN_KEYS = ["requestId", "blocked", "requiresConfirmation", "route", "send", "pullsAtMost", "receive", "fees", "notices", "quotedAt", "validUntil", "calls", "next"];
|
|
1067
|
+
var CALL_KEYS = ["chainId", "from", "to", "data", "value"];
|
|
1068
|
+
var OFFER_KEYS = ["offer", "kind", "payChainId", "chainId", "payTo", "factory", "template", "order", "blob", "hubs", "message", "orderHash", "outcome", "pay", "fee", "receive", "deadline", "refundTo", "typedData", "etaSec", "verify"];
|
|
1069
|
+
var SUBMIT_KEYS = ["requestId", "state", "payTo", "deadline"];
|
|
1070
|
+
var ERROR_KEYS = ["code", "reason", "message", "detail", "retryable", "retryAfterSec", "suggestion", "notices"];
|
|
1071
|
+
var DOMAIN_KEYS = ["name", "version", "chainId", "verifyingContract"];
|
|
1072
|
+
var MESSAGE_KEYS = AUTH_FIELDS.map(([name]) => name);
|
|
1073
|
+
function pick(source, keys) {
|
|
1074
|
+
const out = {};
|
|
1075
|
+
for (const k of keys) if (k in source) out[k] = source[k];
|
|
1076
|
+
return out;
|
|
1077
|
+
}
|
|
1078
|
+
function apiRefusal(body) {
|
|
1079
|
+
if (!isObject(body.error)) return null;
|
|
1080
|
+
return { ...pick(body, ["apiVersion", "requestId"]), error: pick(body.error, ERROR_KEYS) };
|
|
1081
|
+
}
|
|
1082
|
+
function addressRefusal(message) {
|
|
1083
|
+
return { error: { code: "address_not_allowed", message, retryable: false } };
|
|
1084
|
+
}
|
|
1085
|
+
function screenPlanSwap(request, body) {
|
|
1086
|
+
const refusal = apiRefusal(body);
|
|
1087
|
+
if (refusal !== null) return refusal;
|
|
1088
|
+
const result = checkPlanSwap(request, body);
|
|
1089
|
+
if (!result.ok) return addressRefusal(result.message);
|
|
1090
|
+
const out = pick(body, PLAN_KEYS);
|
|
1091
|
+
out.calls = body.calls.map((c) => pick(c, CALL_KEYS));
|
|
1092
|
+
return out;
|
|
1093
|
+
}
|
|
1094
|
+
function screenGetGas(request, body, nowSec) {
|
|
1095
|
+
const refusal = apiRefusal(body);
|
|
1096
|
+
if (refusal !== null) return refusal;
|
|
1097
|
+
const result = checkGetGas(request, body, nowSec);
|
|
1098
|
+
if (!result.ok) return addressRefusal(result.message);
|
|
1099
|
+
if (request.offer !== void 0) return pick(body, SUBMIT_KEYS);
|
|
1100
|
+
const out = pick(body, OFFER_KEYS);
|
|
1101
|
+
if (isObject(body.typedData)) {
|
|
1102
|
+
const t = body.typedData;
|
|
1103
|
+
out.typedData = {
|
|
1104
|
+
domain: pick(t.domain, DOMAIN_KEYS),
|
|
1105
|
+
types: { ReceiveWithAuthorization: t.types.ReceiveWithAuthorization.map((f) => pick(f, ["name", "type"])) },
|
|
1106
|
+
primaryType: t.primaryType,
|
|
1107
|
+
message: pick(t.message, MESSAGE_KEYS)
|
|
1108
|
+
};
|
|
1109
|
+
}
|
|
1110
|
+
return out;
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
var DEFAULT_BASE_URL = "https://api.cleave.fi";
|
|
1114
|
+
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
1115
|
+
var USER_AGENT = `cleave-ai-sdk/${"0.1.1"}`;
|
|
1116
|
+
var CleaveApiError = class extends Error {
|
|
1117
|
+
status;
|
|
1118
|
+
requestId;
|
|
1119
|
+
constructor(message, status, requestId = null, options) {
|
|
1120
|
+
super(message, options);
|
|
1121
|
+
this.name = "CleaveApiError";
|
|
1122
|
+
this.status = status;
|
|
1123
|
+
this.requestId = requestId;
|
|
1124
|
+
}
|
|
1125
|
+
};
|
|
1126
|
+
function untilAborted(signal) {
|
|
1127
|
+
return new Promise((_, reject) => {
|
|
1128
|
+
if (signal.aborted) reject(signal.reason);
|
|
1129
|
+
else signal.addEventListener("abort", () => reject(signal.reason), { once: true });
|
|
1130
|
+
});
|
|
1131
|
+
}
|
|
1132
|
+
function httpError(status) {
|
|
1133
|
+
return { error: { code: "http_error", message: `HTTP ${status}`, retryable: status >= 500 || status === 429 } };
|
|
1134
|
+
}
|
|
1135
|
+
async function callTool(endpoint, input, options, abortSignal) {
|
|
1136
|
+
const base = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
1137
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
1138
|
+
const headers = { "content-type": "application/json", accept: "application/json", "user-agent": USER_AGENT };
|
|
1139
|
+
if (options.apiKey !== void 0 && options.apiKey !== "") headers.authorization = `Bearer ${options.apiKey}`;
|
|
1140
|
+
const doFetch = options.fetch ?? globalThis.fetch;
|
|
1141
|
+
const timeout = AbortSignal.timeout(timeoutMs);
|
|
1142
|
+
const signal = abortSignal === void 0 ? timeout : AbortSignal.any([abortSignal, timeout]);
|
|
1143
|
+
const stopped = untilAborted(signal);
|
|
1144
|
+
stopped.catch(() => void 0);
|
|
1145
|
+
let response;
|
|
1146
|
+
let text;
|
|
1147
|
+
try {
|
|
1148
|
+
response = await Promise.race([doFetch(`${base}/agent/v1/${endpoint}`, { method: "POST", headers, body: JSON.stringify(input), signal }), stopped]);
|
|
1149
|
+
text = await Promise.race([response.text(), stopped]);
|
|
1150
|
+
} catch (err) {
|
|
1151
|
+
const message = abortSignal?.aborted ? "The Cleave API call was aborted" : timeout.aborted ? `Cleave API did not answer within ${timeoutMs} ms` : "Cleave API could not be reached";
|
|
1152
|
+
throw new CleaveApiError(message, 0, null, { cause: err });
|
|
1153
|
+
}
|
|
1154
|
+
const requestId = response.headers.get("x-request-id");
|
|
1155
|
+
let body;
|
|
1156
|
+
try {
|
|
1157
|
+
body = JSON.parse(text);
|
|
1158
|
+
} catch (err) {
|
|
1159
|
+
if (!response.ok) return httpError(response.status);
|
|
1160
|
+
throw new CleaveApiError(`Cleave API answered HTTP ${response.status} without a JSON body`, response.status, requestId, { cause: err });
|
|
1161
|
+
}
|
|
1162
|
+
const isObject2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
1163
|
+
if (!response.ok) return isObject2(body) && isObject2(body.error) ? body : httpError(response.status);
|
|
1164
|
+
if (!isObject2(body)) throw new CleaveApiError(`Cleave API answered HTTP ${response.status} without a JSON object`, response.status, requestId);
|
|
1165
|
+
return body;
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
import { z } from "zod/v4";
|
|
1169
|
+
var CHAIN_IDS = [1, 10, 56, 137, 8453, 42161];
|
|
1170
|
+
var chain = (description) => z.literal(CHAIN_IDS).meta({ type: "integer" }).describe(description);
|
|
1171
|
+
var address2 = (description) => z.string().regex(/^0x[0-9a-fA-F]{40}$/).describe(description);
|
|
1172
|
+
var token = (description) => z.string().min(1).max(64).describe(description);
|
|
1173
|
+
var amount = (description) => z.string().regex(/^[0-9]+(\.[0-9]+)?$/).describe(description);
|
|
1174
|
+
var planSwapInput = z.strictObject({
|
|
1175
|
+
fromChainId: chain("Chain id of the token to sell: 1 Ethereum, 10 Optimism, 56 BNB Chain, 137 Polygon, 8453 Base, 42161 Arbitrum"),
|
|
1176
|
+
toChainId: chain("Chain id of the token to receive; defaults to fromChainId").optional(),
|
|
1177
|
+
sellToken: token("The token to sell: a listed symbol or a contract address"),
|
|
1178
|
+
buyToken: token("The token to receive: a listed symbol or a contract address"),
|
|
1179
|
+
amount: amount('Decimal amount of sellToken in token units, such as "25.5"'),
|
|
1180
|
+
wallet: address2("The wallet that signs and pays"),
|
|
1181
|
+
recipient: address2("Who receives; defaults to wallet").optional(),
|
|
1182
|
+
maxSlippageBps: z.number().int().min(0).max(5e3).describe("Slippage limit in basis points, 0 to 5000").optional()
|
|
1183
|
+
});
|
|
1184
|
+
var trackSwapInput = z.strictObject({
|
|
1185
|
+
chainId: chain("Chain id of the sent transaction").optional(),
|
|
1186
|
+
txHash: z.string().regex(/^0x[0-9a-fA-F]{64}$/).describe("Hash of the sent transaction").optional(),
|
|
1187
|
+
requestId: z.string().min(1).max(79).regex(/^([A-Za-z0-9-]{1,64}|g:[0-9]{1,10}:0x[0-9a-fA-F]{64})$/).describe("The plan's requestId, or for a gas order its requestId alone (g:<payChainId>:<orderHash>)").optional()
|
|
1188
|
+
});
|
|
1189
|
+
var findTokenInput = z.strictObject({
|
|
1190
|
+
chainId: chain("Chain id to search on"),
|
|
1191
|
+
query: z.string().min(1).max(64).describe("A symbol or a contract address")
|
|
1192
|
+
});
|
|
1193
|
+
var getGasInput = z.strictObject({
|
|
1194
|
+
payChainId: chain("Chain id the USDC is paid on (first call)").optional(),
|
|
1195
|
+
chainId: chain("Chain id the native coin is delivered on (first call)").optional(),
|
|
1196
|
+
recipient: address2("Who receives the native coin (first call)").optional(),
|
|
1197
|
+
amount: amount('USDC to pay, as a decimal string such as "5" (first call)').optional(),
|
|
1198
|
+
wallet: address2("The paying wallet; with it, the offer carries the authorization to sign. Required on the second call").optional(),
|
|
1199
|
+
refundTo: address2("Where a refund goes on the pay chain (first call)").optional(),
|
|
1200
|
+
offer: z.string().min(1).max(4096).describe("The offer string from the first call (second call)").optional(),
|
|
1201
|
+
signature: z.string().regex(/^0x[0-9a-fA-F]+$/).describe("The wallet's signature of the offer's typedData (second call)").optional()
|
|
1202
|
+
});
|
|
1203
|
+
|
|
1204
|
+
var DESCRIPTIONS = {
|
|
1205
|
+
planSwap: "Plans a token swap on one chain, a cross-chain swap or bridge, or a native-gas top-up on Ethereum, Arbitrum, Base, BNB Chain, Polygon or Optimism, and returns unsigned transactions for the given wallet to sign. It fits when the user wants to exchange tokens, move them between these chains, or get ETH, BNB or POL for gas. It sends nothing and moves no funds. The answer leads with blocking notices and warnings, then gives the route's outcome kind (an exact amount or one that can vary; with a swap on arrival, the token, else a named fallback; where a transfer can go unfilled, a refund of the bridged token on the source chain hours later), every third-party cost except network gas, the expected time, validUntil and the calls in signing order. A blocking notice returns no calls; a warning, or a recipient other than the wallet, sets requiresConfirmation. Calls sent after validUntil are stale: they can revert or, on some routes, end in a refund hours later. Amounts are decimal strings in token units; tokens are listed symbols or contract addresses; the recipient defaults to the wallet. The token to receive must be on Cleave's token list. For an ambiguous symbol, cleave_find_token lists the candidates; after sending, cleave_track_swap reports progress. A wallet with no gas can get it with cleave_get_gas.",
|
|
1206
|
+
trackSwap: "Reports the status of a swap, bridge or gas top-up that was planned with cleave_plan_swap and then sent, or ordered with cleave_get_gas: its state (for example pending, in flight, delivered, refund pending or refunded), what arrived against the plan and on which chain, and the next action or when to check again. It takes the chain and transaction hash, plus the plan's requestId when known, or for a gas top-up the requestId alone; a transaction to a contract outside Cleave's published list is reported as such. It fits when the user asks whether such a transfer arrived, and before any re-send, because re-sending a plan that is still in flight can pay twice. It reports states only and returns no transactions.",
|
|
1207
|
+
findToken: "Finds a token by symbol or contract address on Ethereum, Arbitrum, Base, BNB Chain, Polygon or Optimism and returns its address, decimals and whether it is on Cleave's token list, with a flag when it resembles a listed token. A symbol shared by several listed tokens returns every candidate by address instead of picking one. An unlisted token is found only by its address and comes back flagged, without a name or symbol. It fits before cleave_plan_swap when the user names a token by symbol and the address is unknown.",
|
|
1208
|
+
getGas: "Gets native gas (ETH, BNB or POL) on Ethereum, Arbitrum, Base, BNB Chain, Polygon or Optimism for a wallet that holds USDC on Ethereum, Arbitrum, Base, Optimism or Polygon but has no gas to send transactions. Called with the paying chain, the receiving chain, the recipient and a USDC amount, it returns an offer: the fee, the minimum native amount, the deadline, the order and one USDC authorization for the wallet to sign; signing costs no gas. Called again with the offer and the signature, it passes the signed order to Cleave's relayer, which executes it through a contract made for that one order, and returns a requestId for cleave_track_swap. On one chain the order swaps the USDC to the native coin for the recipient; from another chain it bridges the USDC and swaps it on arrival, delivering USDC instead if that swap fails. An order not executed by its deadline is refunded to the refund address, or, if paid from another chain and not filled, refunded hours later. When the wallet already holds some gas, cleave_plan_swap plans a swap to the native coin."
|
|
1209
|
+
};
|
|
1210
|
+
var NAMES = " In this package, cleave_plan_swap, cleave_track_swap, cleave_find_token and cleave_get_gas are the tools planSwap, trackSwap, findToken and getGas.";
|
|
1211
|
+
var PLAN_SUFFIX = " Before any wallet signs, show the user the warnings, recipient, amounts and slippage, and get their confirmation. Do not raise slippage above the default 50 bps without the user's consent.";
|
|
1212
|
+
var GAS_SUFFIX = " If a submission fails or times out, the order may still have been accepted: track g:<payChainId>:<orderHash> before signing a new offer.";
|
|
1213
|
+
function planSwap(options = {}) {
|
|
1214
|
+
return tool({
|
|
1215
|
+
title: "Plan a swap, bridge or gas top-up",
|
|
1216
|
+
description: DESCRIPTIONS.planSwap + PLAN_SUFFIX + NAMES,
|
|
1217
|
+
inputSchema: planSwapInput,
|
|
1218
|
+
execute: async (input, { abortSignal }) => screenPlanSwap(input, await callTool("plan_swap", input, options, abortSignal))
|
|
1219
|
+
});
|
|
1220
|
+
}
|
|
1221
|
+
function trackSwap(options = {}) {
|
|
1222
|
+
return tool({
|
|
1223
|
+
title: "Track a planned swap or transfer",
|
|
1224
|
+
description: DESCRIPTIONS.trackSwap + NAMES,
|
|
1225
|
+
inputSchema: trackSwapInput,
|
|
1226
|
+
execute: (input, { abortSignal }) => callTool("track_swap", input, options, abortSignal)
|
|
1227
|
+
});
|
|
1228
|
+
}
|
|
1229
|
+
function findToken(options = {}) {
|
|
1230
|
+
return tool({
|
|
1231
|
+
title: "Find a token's contract address",
|
|
1232
|
+
description: DESCRIPTIONS.findToken + NAMES,
|
|
1233
|
+
inputSchema: findTokenInput,
|
|
1234
|
+
execute: (input, { abortSignal }) => callTool("find_token", input, options, abortSignal)
|
|
1235
|
+
});
|
|
1236
|
+
}
|
|
1237
|
+
function getGas(options = {}) {
|
|
1238
|
+
return tool({
|
|
1239
|
+
title: "Get native gas with USDC",
|
|
1240
|
+
description: DESCRIPTIONS.getGas + GAS_SUFFIX + NAMES,
|
|
1241
|
+
inputSchema: getGasInput,
|
|
1242
|
+
needsApproval: options.getGasApproval === false ? false : (input) => input.signature !== void 0,
|
|
1243
|
+
execute: async (input, { abortSignal }) => screenGetGas(input, await callTool("get_gas", input, options, abortSignal))
|
|
1244
|
+
});
|
|
1245
|
+
}
|
|
1246
|
+
function cleaveTools(options = {}) {
|
|
1247
|
+
return { planSwap: planSwap(options), trackSwap: trackSwap(options), findToken: findToken(options), getGas: getGas(options) };
|
|
1248
|
+
}
|
|
1249
|
+
export {
|
|
1250
|
+
CHAIN_IDS,
|
|
1251
|
+
CleaveApiError,
|
|
1252
|
+
DEFAULT_BASE_URL,
|
|
1253
|
+
DEFAULT_TIMEOUT_MS,
|
|
1254
|
+
checkGetGas,
|
|
1255
|
+
checkPlanSwap,
|
|
1256
|
+
cleaveTools,
|
|
1257
|
+
findToken,
|
|
1258
|
+
getGas,
|
|
1259
|
+
planSwap,
|
|
1260
|
+
screenGetGas,
|
|
1261
|
+
screenPlanSwap,
|
|
1262
|
+
trackSwap
|
|
1263
|
+
};
|