@tokenlon/v6-sdk 0.0.1-canary.2c7f0fd
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/cjs/constants.js +279 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/env.js +19 -0
- package/dist/cjs/env.js.map +1 -0
- package/dist/cjs/index.js +21 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/sdk.js +59 -0
- package/dist/cjs/sdk.js.map +1 -0
- package/dist/cjs/serviceHost.js +23 -0
- package/dist/cjs/serviceHost.js.map +1 -0
- package/dist/cjs/swap/index.js +365 -0
- package/dist/cjs/swap/index.js.map +1 -0
- package/dist/cjs/swap/type.js +3 -0
- package/dist/cjs/swap/type.js.map +1 -0
- package/dist/cjs/type.js +3 -0
- package/dist/cjs/type.js.map +1 -0
- package/dist/cjs/utils/promise/withTimeout.js +35 -0
- package/dist/cjs/utils/promise/withTimeout.js.map +1 -0
- package/dist/cjs/utils/rpc.js +62 -0
- package/dist/cjs/utils/rpc.js.map +1 -0
- package/dist/cjs/version.js +5 -0
- package/dist/cjs/version.js.map +1 -0
- package/dist/esm/constants.js +276 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/env.js +16 -0
- package/dist/esm/env.js.map +1 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/sdk.js +57 -0
- package/dist/esm/sdk.js.map +1 -0
- package/dist/esm/serviceHost.js +21 -0
- package/dist/esm/serviceHost.js.map +1 -0
- package/dist/esm/swap/index.js +364 -0
- package/dist/esm/swap/index.js.map +1 -0
- package/dist/esm/swap/type.js +3 -0
- package/dist/esm/swap/type.js.map +1 -0
- package/dist/esm/type.js +2 -0
- package/dist/esm/type.js.map +1 -0
- package/dist/esm/utils/promise/withTimeout.js +31 -0
- package/dist/esm/utils/promise/withTimeout.js.map +1 -0
- package/dist/esm/utils/rpc.js +58 -0
- package/dist/esm/utils/rpc.js.map +1 -0
- package/dist/esm/version.js +2 -0
- package/dist/esm/version.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/constants.d.ts +393 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/env.d.ts +7 -0
- package/dist/types/env.d.ts.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/sdk.d.ts +28 -0
- package/dist/types/sdk.d.ts.map +1 -0
- package/dist/types/serviceHost.d.ts +8 -0
- package/dist/types/serviceHost.d.ts.map +1 -0
- package/dist/types/swap/index.d.ts +84 -0
- package/dist/types/swap/index.d.ts.map +1 -0
- package/dist/types/swap/type.d.ts +126 -0
- package/dist/types/swap/type.d.ts.map +1 -0
- package/dist/types/type.d.ts +3 -0
- package/dist/types/type.d.ts.map +1 -0
- package/dist/types/utils/promise/withTimeout.d.ts +8 -0
- package/dist/types/utils/promise/withTimeout.d.ts.map +1 -0
- package/dist/types/utils/rpc.d.ts +40 -0
- package/dist/types/utils/rpc.d.ts.map +1 -0
- package/dist/types/version.d.ts +2 -0
- package/dist/types/version.d.ts.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
export declare const nullAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
2
|
+
export declare const wethAddress: Record<number, `0x${string}`>;
|
|
3
|
+
export declare const allowanceTargetAddress: Record<number, `0x${string}`>;
|
|
4
|
+
export declare const genericSwapAddress: Record<number, `0x${string}`>;
|
|
5
|
+
export declare const SupportedChains: readonly [1, 5];
|
|
6
|
+
export declare const ALL_SUPPORTED_CHAINS: ({
|
|
7
|
+
readonly id: 1;
|
|
8
|
+
readonly network: "homestead";
|
|
9
|
+
readonly name: "Ethereum";
|
|
10
|
+
readonly nativeCurrency: {
|
|
11
|
+
readonly name: "Ether";
|
|
12
|
+
readonly symbol: "ETH";
|
|
13
|
+
readonly decimals: 18;
|
|
14
|
+
};
|
|
15
|
+
readonly rpcUrls: {
|
|
16
|
+
readonly alchemy: {
|
|
17
|
+
readonly http: readonly ["https://eth-mainnet.g.alchemy.com/v2"];
|
|
18
|
+
readonly webSocket: readonly ["wss://eth-mainnet.g.alchemy.com/v2"];
|
|
19
|
+
};
|
|
20
|
+
readonly infura: {
|
|
21
|
+
readonly http: readonly ["https://mainnet.infura.io/v3"];
|
|
22
|
+
readonly webSocket: readonly ["wss://mainnet.infura.io/ws/v3"];
|
|
23
|
+
};
|
|
24
|
+
readonly default: {
|
|
25
|
+
readonly http: readonly ["https://cloudflare-eth.com"];
|
|
26
|
+
};
|
|
27
|
+
readonly public: {
|
|
28
|
+
readonly http: readonly ["https://cloudflare-eth.com"];
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
readonly blockExplorers: {
|
|
32
|
+
readonly etherscan: {
|
|
33
|
+
readonly name: "Etherscan";
|
|
34
|
+
readonly url: "https://etherscan.io";
|
|
35
|
+
};
|
|
36
|
+
readonly default: {
|
|
37
|
+
readonly name: "Etherscan";
|
|
38
|
+
readonly url: "https://etherscan.io";
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
readonly contracts: {
|
|
42
|
+
readonly ensRegistry: {
|
|
43
|
+
readonly address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
|
|
44
|
+
};
|
|
45
|
+
readonly ensUniversalResolver: {
|
|
46
|
+
readonly address: "0xc0497E381f536Be9ce14B0dD3817cBcAe57d2F62";
|
|
47
|
+
readonly blockCreated: 16966585;
|
|
48
|
+
};
|
|
49
|
+
readonly multicall3: {
|
|
50
|
+
readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
|
|
51
|
+
readonly blockCreated: 14353601;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
} | {
|
|
55
|
+
readonly id: 5;
|
|
56
|
+
readonly network: "goerli";
|
|
57
|
+
readonly name: "Goerli";
|
|
58
|
+
readonly nativeCurrency: {
|
|
59
|
+
readonly name: "Goerli Ether";
|
|
60
|
+
readonly symbol: "ETH";
|
|
61
|
+
readonly decimals: 18;
|
|
62
|
+
};
|
|
63
|
+
readonly rpcUrls: {
|
|
64
|
+
readonly alchemy: {
|
|
65
|
+
readonly http: readonly ["https://eth-goerli.g.alchemy.com/v2"];
|
|
66
|
+
readonly webSocket: readonly ["wss://eth-goerli.g.alchemy.com/v2"];
|
|
67
|
+
};
|
|
68
|
+
readonly infura: {
|
|
69
|
+
readonly http: readonly ["https://goerli.infura.io/v3"];
|
|
70
|
+
readonly webSocket: readonly ["wss://goerli.infura.io/ws/v3"];
|
|
71
|
+
};
|
|
72
|
+
readonly default: {
|
|
73
|
+
readonly http: readonly ["https://rpc.ankr.com/eth_goerli"];
|
|
74
|
+
};
|
|
75
|
+
readonly public: {
|
|
76
|
+
readonly http: readonly ["https://rpc.ankr.com/eth_goerli"];
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
readonly blockExplorers: {
|
|
80
|
+
readonly etherscan: {
|
|
81
|
+
readonly name: "Etherscan";
|
|
82
|
+
readonly url: "https://goerli.etherscan.io";
|
|
83
|
+
};
|
|
84
|
+
readonly default: {
|
|
85
|
+
readonly name: "Etherscan";
|
|
86
|
+
readonly url: "https://goerli.etherscan.io";
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
readonly contracts: {
|
|
90
|
+
readonly ensRegistry: {
|
|
91
|
+
readonly address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
|
|
92
|
+
};
|
|
93
|
+
readonly ensUniversalResolver: {
|
|
94
|
+
readonly address: "0x56522D00C410a43BFfDF00a9A569489297385790";
|
|
95
|
+
readonly blockCreated: 8765204;
|
|
96
|
+
};
|
|
97
|
+
readonly multicall3: {
|
|
98
|
+
readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
|
|
99
|
+
readonly blockCreated: 6507670;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
readonly testnet: true;
|
|
103
|
+
})[];
|
|
104
|
+
export declare const GENERIC_SWAP_ABI: readonly [{
|
|
105
|
+
readonly inputs: readonly [{
|
|
106
|
+
readonly internalType: "address";
|
|
107
|
+
readonly name: "_uniswapPermit2";
|
|
108
|
+
readonly type: "address";
|
|
109
|
+
}, {
|
|
110
|
+
readonly internalType: "address";
|
|
111
|
+
readonly name: "_allowanceTarget";
|
|
112
|
+
readonly type: "address";
|
|
113
|
+
}];
|
|
114
|
+
readonly stateMutability: "nonpayable";
|
|
115
|
+
readonly type: "constructor";
|
|
116
|
+
}, {
|
|
117
|
+
readonly inputs: readonly [];
|
|
118
|
+
readonly name: "AlreadyFilled";
|
|
119
|
+
readonly type: "error";
|
|
120
|
+
}, {
|
|
121
|
+
readonly inputs: readonly [];
|
|
122
|
+
readonly name: "InsufficientOutput";
|
|
123
|
+
readonly type: "error";
|
|
124
|
+
}, {
|
|
125
|
+
readonly inputs: readonly [];
|
|
126
|
+
readonly name: "InvalidMsgValue";
|
|
127
|
+
readonly type: "error";
|
|
128
|
+
}, {
|
|
129
|
+
readonly inputs: readonly [];
|
|
130
|
+
readonly name: "InvalidSignature";
|
|
131
|
+
readonly type: "error";
|
|
132
|
+
}, {
|
|
133
|
+
readonly anonymous: false;
|
|
134
|
+
readonly inputs: readonly [{
|
|
135
|
+
readonly indexed: true;
|
|
136
|
+
readonly internalType: "bytes32";
|
|
137
|
+
readonly name: "swapHash";
|
|
138
|
+
readonly type: "bytes32";
|
|
139
|
+
}, {
|
|
140
|
+
readonly indexed: true;
|
|
141
|
+
readonly internalType: "address";
|
|
142
|
+
readonly name: "maker";
|
|
143
|
+
readonly type: "address";
|
|
144
|
+
}, {
|
|
145
|
+
readonly indexed: true;
|
|
146
|
+
readonly internalType: "address";
|
|
147
|
+
readonly name: "taker";
|
|
148
|
+
readonly type: "address";
|
|
149
|
+
}, {
|
|
150
|
+
readonly indexed: false;
|
|
151
|
+
readonly internalType: "address";
|
|
152
|
+
readonly name: "recipient";
|
|
153
|
+
readonly type: "address";
|
|
154
|
+
}, {
|
|
155
|
+
readonly indexed: false;
|
|
156
|
+
readonly internalType: "address";
|
|
157
|
+
readonly name: "inputToken";
|
|
158
|
+
readonly type: "address";
|
|
159
|
+
}, {
|
|
160
|
+
readonly indexed: false;
|
|
161
|
+
readonly internalType: "uint256";
|
|
162
|
+
readonly name: "inputAmount";
|
|
163
|
+
readonly type: "uint256";
|
|
164
|
+
}, {
|
|
165
|
+
readonly indexed: false;
|
|
166
|
+
readonly internalType: "address";
|
|
167
|
+
readonly name: "outputToken";
|
|
168
|
+
readonly type: "address";
|
|
169
|
+
}, {
|
|
170
|
+
readonly indexed: false;
|
|
171
|
+
readonly internalType: "uint256";
|
|
172
|
+
readonly name: "outputAmount";
|
|
173
|
+
readonly type: "uint256";
|
|
174
|
+
}];
|
|
175
|
+
readonly name: "Swap";
|
|
176
|
+
readonly type: "event";
|
|
177
|
+
}, {
|
|
178
|
+
readonly inputs: readonly [];
|
|
179
|
+
readonly name: "EIP191_HEADER";
|
|
180
|
+
readonly outputs: readonly [{
|
|
181
|
+
readonly internalType: "string";
|
|
182
|
+
readonly name: "";
|
|
183
|
+
readonly type: "string";
|
|
184
|
+
}];
|
|
185
|
+
readonly stateMutability: "view";
|
|
186
|
+
readonly type: "function";
|
|
187
|
+
}, {
|
|
188
|
+
readonly inputs: readonly [];
|
|
189
|
+
readonly name: "EIP712_DOMAIN_NAME";
|
|
190
|
+
readonly outputs: readonly [{
|
|
191
|
+
readonly internalType: "string";
|
|
192
|
+
readonly name: "";
|
|
193
|
+
readonly type: "string";
|
|
194
|
+
}];
|
|
195
|
+
readonly stateMutability: "view";
|
|
196
|
+
readonly type: "function";
|
|
197
|
+
}, {
|
|
198
|
+
readonly inputs: readonly [];
|
|
199
|
+
readonly name: "EIP712_DOMAIN_SEPARATOR";
|
|
200
|
+
readonly outputs: readonly [{
|
|
201
|
+
readonly internalType: "bytes32";
|
|
202
|
+
readonly name: "";
|
|
203
|
+
readonly type: "bytes32";
|
|
204
|
+
}];
|
|
205
|
+
readonly stateMutability: "view";
|
|
206
|
+
readonly type: "function";
|
|
207
|
+
}, {
|
|
208
|
+
readonly inputs: readonly [];
|
|
209
|
+
readonly name: "EIP712_DOMAIN_VERSION";
|
|
210
|
+
readonly outputs: readonly [{
|
|
211
|
+
readonly internalType: "string";
|
|
212
|
+
readonly name: "";
|
|
213
|
+
readonly type: "string";
|
|
214
|
+
}];
|
|
215
|
+
readonly stateMutability: "view";
|
|
216
|
+
readonly type: "function";
|
|
217
|
+
}, {
|
|
218
|
+
readonly inputs: readonly [];
|
|
219
|
+
readonly name: "allowanceTarget";
|
|
220
|
+
readonly outputs: readonly [{
|
|
221
|
+
readonly internalType: "address";
|
|
222
|
+
readonly name: "";
|
|
223
|
+
readonly type: "address";
|
|
224
|
+
}];
|
|
225
|
+
readonly stateMutability: "view";
|
|
226
|
+
readonly type: "function";
|
|
227
|
+
}, {
|
|
228
|
+
readonly inputs: readonly [];
|
|
229
|
+
readonly name: "originalChainId";
|
|
230
|
+
readonly outputs: readonly [{
|
|
231
|
+
readonly internalType: "uint256";
|
|
232
|
+
readonly name: "";
|
|
233
|
+
readonly type: "uint256";
|
|
234
|
+
}];
|
|
235
|
+
readonly stateMutability: "view";
|
|
236
|
+
readonly type: "function";
|
|
237
|
+
}, {
|
|
238
|
+
readonly inputs: readonly [{
|
|
239
|
+
readonly components: readonly [{
|
|
240
|
+
readonly internalType: "address payable";
|
|
241
|
+
readonly name: "maker";
|
|
242
|
+
readonly type: "address";
|
|
243
|
+
}, {
|
|
244
|
+
readonly internalType: "address";
|
|
245
|
+
readonly name: "takerToken";
|
|
246
|
+
readonly type: "address";
|
|
247
|
+
}, {
|
|
248
|
+
readonly internalType: "uint256";
|
|
249
|
+
readonly name: "takerTokenAmount";
|
|
250
|
+
readonly type: "uint256";
|
|
251
|
+
}, {
|
|
252
|
+
readonly internalType: "address";
|
|
253
|
+
readonly name: "makerToken";
|
|
254
|
+
readonly type: "address";
|
|
255
|
+
}, {
|
|
256
|
+
readonly internalType: "uint256";
|
|
257
|
+
readonly name: "makerTokenAmount";
|
|
258
|
+
readonly type: "uint256";
|
|
259
|
+
}, {
|
|
260
|
+
readonly internalType: "uint256";
|
|
261
|
+
readonly name: "minMakerTokenAmount";
|
|
262
|
+
readonly type: "uint256";
|
|
263
|
+
}, {
|
|
264
|
+
readonly internalType: "uint256";
|
|
265
|
+
readonly name: "expiry";
|
|
266
|
+
readonly type: "uint256";
|
|
267
|
+
}, {
|
|
268
|
+
readonly internalType: "uint256";
|
|
269
|
+
readonly name: "salt";
|
|
270
|
+
readonly type: "uint256";
|
|
271
|
+
}, {
|
|
272
|
+
readonly internalType: "address payable";
|
|
273
|
+
readonly name: "recipient";
|
|
274
|
+
readonly type: "address";
|
|
275
|
+
}, {
|
|
276
|
+
readonly internalType: "bytes";
|
|
277
|
+
readonly name: "strategyData";
|
|
278
|
+
readonly type: "bytes";
|
|
279
|
+
}];
|
|
280
|
+
readonly internalType: "struct GenericSwapData";
|
|
281
|
+
readonly name: "swapData";
|
|
282
|
+
readonly type: "tuple";
|
|
283
|
+
}, {
|
|
284
|
+
readonly internalType: "bytes";
|
|
285
|
+
readonly name: "takerTokenPermit";
|
|
286
|
+
readonly type: "bytes";
|
|
287
|
+
}];
|
|
288
|
+
readonly name: "executeSwap";
|
|
289
|
+
readonly outputs: readonly [{
|
|
290
|
+
readonly internalType: "uint256";
|
|
291
|
+
readonly name: "returnAmount";
|
|
292
|
+
readonly type: "uint256";
|
|
293
|
+
}];
|
|
294
|
+
readonly stateMutability: "payable";
|
|
295
|
+
readonly type: "function";
|
|
296
|
+
}, {
|
|
297
|
+
readonly inputs: readonly [{
|
|
298
|
+
readonly components: readonly [{
|
|
299
|
+
readonly internalType: "address payable";
|
|
300
|
+
readonly name: "maker";
|
|
301
|
+
readonly type: "address";
|
|
302
|
+
}, {
|
|
303
|
+
readonly internalType: "address";
|
|
304
|
+
readonly name: "takerToken";
|
|
305
|
+
readonly type: "address";
|
|
306
|
+
}, {
|
|
307
|
+
readonly internalType: "uint256";
|
|
308
|
+
readonly name: "takerTokenAmount";
|
|
309
|
+
readonly type: "uint256";
|
|
310
|
+
}, {
|
|
311
|
+
readonly internalType: "address";
|
|
312
|
+
readonly name: "makerToken";
|
|
313
|
+
readonly type: "address";
|
|
314
|
+
}, {
|
|
315
|
+
readonly internalType: "uint256";
|
|
316
|
+
readonly name: "makerTokenAmount";
|
|
317
|
+
readonly type: "uint256";
|
|
318
|
+
}, {
|
|
319
|
+
readonly internalType: "uint256";
|
|
320
|
+
readonly name: "minMakerTokenAmount";
|
|
321
|
+
readonly type: "uint256";
|
|
322
|
+
}, {
|
|
323
|
+
readonly internalType: "uint256";
|
|
324
|
+
readonly name: "expiry";
|
|
325
|
+
readonly type: "uint256";
|
|
326
|
+
}, {
|
|
327
|
+
readonly internalType: "uint256";
|
|
328
|
+
readonly name: "salt";
|
|
329
|
+
readonly type: "uint256";
|
|
330
|
+
}, {
|
|
331
|
+
readonly internalType: "address payable";
|
|
332
|
+
readonly name: "recipient";
|
|
333
|
+
readonly type: "address";
|
|
334
|
+
}, {
|
|
335
|
+
readonly internalType: "bytes";
|
|
336
|
+
readonly name: "strategyData";
|
|
337
|
+
readonly type: "bytes";
|
|
338
|
+
}];
|
|
339
|
+
readonly internalType: "struct GenericSwapData";
|
|
340
|
+
readonly name: "swapData";
|
|
341
|
+
readonly type: "tuple";
|
|
342
|
+
}, {
|
|
343
|
+
readonly internalType: "bytes";
|
|
344
|
+
readonly name: "takerTokenPermit";
|
|
345
|
+
readonly type: "bytes";
|
|
346
|
+
}, {
|
|
347
|
+
readonly internalType: "address";
|
|
348
|
+
readonly name: "taker";
|
|
349
|
+
readonly type: "address";
|
|
350
|
+
}, {
|
|
351
|
+
readonly internalType: "bytes";
|
|
352
|
+
readonly name: "takerSig";
|
|
353
|
+
readonly type: "bytes";
|
|
354
|
+
}];
|
|
355
|
+
readonly name: "executeSwap";
|
|
356
|
+
readonly outputs: readonly [{
|
|
357
|
+
readonly internalType: "uint256";
|
|
358
|
+
readonly name: "returnAmount";
|
|
359
|
+
readonly type: "uint256";
|
|
360
|
+
}];
|
|
361
|
+
readonly stateMutability: "payable";
|
|
362
|
+
readonly type: "function";
|
|
363
|
+
}, {
|
|
364
|
+
readonly inputs: readonly [];
|
|
365
|
+
readonly name: "originalEIP712DomainSeparator";
|
|
366
|
+
readonly outputs: readonly [{
|
|
367
|
+
readonly internalType: "bytes32";
|
|
368
|
+
readonly name: "";
|
|
369
|
+
readonly type: "bytes32";
|
|
370
|
+
}];
|
|
371
|
+
readonly stateMutability: "view";
|
|
372
|
+
readonly type: "function";
|
|
373
|
+
}, {
|
|
374
|
+
readonly inputs: readonly [];
|
|
375
|
+
readonly name: "permit2";
|
|
376
|
+
readonly outputs: readonly [{
|
|
377
|
+
readonly internalType: "address";
|
|
378
|
+
readonly name: "";
|
|
379
|
+
readonly type: "address";
|
|
380
|
+
}];
|
|
381
|
+
readonly stateMutability: "view";
|
|
382
|
+
readonly type: "function";
|
|
383
|
+
}, {
|
|
384
|
+
readonly stateMutability: "payable";
|
|
385
|
+
readonly type: "receive";
|
|
386
|
+
}];
|
|
387
|
+
export declare const EIP712_TYPES: {
|
|
388
|
+
GenericSwapData: {
|
|
389
|
+
name: string;
|
|
390
|
+
type: string;
|
|
391
|
+
}[];
|
|
392
|
+
};
|
|
393
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,8CAAwD,CAAA;AAChF,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,MAAM,EAAE,CAGrD,CAAA;AAGD,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,MAAM,EAAE,CAEhE,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,MAAM,EAAE,CAG5D,CAAA;AAED,eAAO,MAAM,eAAe,iBAAmC,CAAA;AAE/D,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAoB,CAAA;AAErD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuNnB,CAAA;AAEV,eAAO,MAAM,YAAY;;;;;CA2CxB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/env.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,GAAG,YAAY,GAAG,SAAS,GAAG,aAAa,CAAA;AAE1D,qBAAa,MAAM;IACjB,MAAM,CAAC,GAAG,EAAE,GAAG,CAAgB;IAC/B,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG;IAGtB,MAAM,CAAC,SAAS;CAGjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type Env } from './env.js';
|
|
2
|
+
import { Swap } from './swap/index.js';
|
|
3
|
+
import { type SupportedChain } from './type.js';
|
|
4
|
+
import { JsonRpcProvider } from 'ethers';
|
|
5
|
+
import { type PublicClient, type WalletClient, custom } from 'viem';
|
|
6
|
+
export type TokenlonSDKConfig = {
|
|
7
|
+
fetch?: typeof fetch;
|
|
8
|
+
env: Env;
|
|
9
|
+
chain: SupportedChain;
|
|
10
|
+
client?: PublicClient;
|
|
11
|
+
provider: Parameters<typeof custom>[0];
|
|
12
|
+
rpcUrl: string;
|
|
13
|
+
};
|
|
14
|
+
interface TokenlonSDKRoot {
|
|
15
|
+
config: TokenlonSDKConfig;
|
|
16
|
+
provider: JsonRpcProvider;
|
|
17
|
+
swap: Swap;
|
|
18
|
+
}
|
|
19
|
+
export declare class TokenlonSDK implements TokenlonSDKRoot {
|
|
20
|
+
config: TokenlonSDKConfig;
|
|
21
|
+
readonly swap: Swap;
|
|
22
|
+
readonly provider: JsonRpcProvider;
|
|
23
|
+
readonly publicClient: PublicClient;
|
|
24
|
+
readonly walletClient: WalletClient;
|
|
25
|
+
constructor(config: TokenlonSDKConfig);
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=sdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,UAAU,CAAA;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACtC,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,YAAY,EAGjB,MAAM,EAEP,MAAM,MAAM,CAAA;AAEb,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,CAAC,EAAE,OAAO,KAAK,CAAA;IACpB,GAAG,EAAE,GAAG,CAAA;IACR,KAAK,EAAE,cAAc,CAAA;IACrB,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,QAAQ,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;IACtC,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,UAAU,eAAe;IACvB,MAAM,EAAE,iBAAiB,CAAA;IAEzB,QAAQ,EAAE,eAAe,CAAA;IAGzB,IAAI,EAAE,IAAI,CAAA;CAGX;AAED,qBAAa,WAAY,YAAW,eAAe;IAM9B,MAAM,EAAE,iBAAiB;IAL5C,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;IACnB,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAA;IAClC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAA;IACnC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAA;gBAEhB,MAAM,EAAE,iBAAiB;CAkB7C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type SupportedChain } from './type.js';
|
|
2
|
+
export type ServiceHost = {
|
|
3
|
+
default: string;
|
|
4
|
+
staging?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const httpServiceHost: Record<SupportedChain, ServiceHost>;
|
|
7
|
+
export declare const jsonRpcServiceHost: Record<SupportedChain, ServiceHost>;
|
|
8
|
+
//# sourceMappingURL=serviceHost.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serviceHost.d.ts","sourceRoot":"","sources":["../../src/serviceHost.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAA;AAG/C,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,cAAc,EAAE,WAAW,CAQ/D,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,cAAc,EAAE,WAAW,CAQlE,CAAA"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { type Env } from '../env.js';
|
|
2
|
+
import { type ListDTO, type ListItem, type MarketRate, type MarketRateDTO, type Order, type QuoteDTO, type StatusDTO, type SubmitDTO, type SwapConfig, type SwapData } from './type.js';
|
|
3
|
+
import { JsonRpcProvider } from 'ethers';
|
|
4
|
+
import { type Address, type PublicClient, type TransactionRequest, type WalletClient } from 'viem';
|
|
5
|
+
export declare const ERC20_TRANSFER_GAS = 65000n;
|
|
6
|
+
export declare class Swap {
|
|
7
|
+
chainId: number;
|
|
8
|
+
fetch: typeof fetch;
|
|
9
|
+
env: Env;
|
|
10
|
+
publicClient: PublicClient;
|
|
11
|
+
walletClient: WalletClient;
|
|
12
|
+
provider: JsonRpcProvider;
|
|
13
|
+
constructor(config: SwapConfig, client: {
|
|
14
|
+
publicClient: PublicClient;
|
|
15
|
+
walletClient: WalletClient;
|
|
16
|
+
provider: JsonRpcProvider;
|
|
17
|
+
});
|
|
18
|
+
private host;
|
|
19
|
+
private rebuildStrategyData;
|
|
20
|
+
protected calculateFee: (gasFee: bigint, protocolFee: bigint, chargeTokenDecimals: number) => bigint;
|
|
21
|
+
prepareOrder: ({ order, slippage, gasFee, sendByRelayer, }: {
|
|
22
|
+
order: Order;
|
|
23
|
+
slippage: number | `${number}`;
|
|
24
|
+
gasFee?: bigint;
|
|
25
|
+
sendByRelayer?: boolean;
|
|
26
|
+
}) => {
|
|
27
|
+
swapData: SwapData;
|
|
28
|
+
protocolFee: bigint;
|
|
29
|
+
gasFee: bigint | undefined;
|
|
30
|
+
fee: bigint;
|
|
31
|
+
recipient: `0x${string}`;
|
|
32
|
+
operations: readonly {
|
|
33
|
+
dest: `0x${string}`;
|
|
34
|
+
inputToken: `0x${string}`;
|
|
35
|
+
inputRatio: bigint;
|
|
36
|
+
dataOffset: bigint;
|
|
37
|
+
value: bigint;
|
|
38
|
+
data: `0x${string}`;
|
|
39
|
+
}[];
|
|
40
|
+
strategyData: `0x${string}`;
|
|
41
|
+
value: bigint;
|
|
42
|
+
};
|
|
43
|
+
getMarketRate: (dto: MarketRateDTO) => Promise<MarketRate>;
|
|
44
|
+
quote: (dto: QuoteDTO) => Promise<Order>;
|
|
45
|
+
getTokenPermitData: (swapData: SwapData) => `0x${string}`;
|
|
46
|
+
estimate: ({ account, order, slippage, }: {
|
|
47
|
+
account: Address;
|
|
48
|
+
order: Order;
|
|
49
|
+
slippage: number | `${number}`;
|
|
50
|
+
}) => Promise<bigint>;
|
|
51
|
+
sign: (params: {
|
|
52
|
+
account: Address;
|
|
53
|
+
swapData: SwapData;
|
|
54
|
+
takerTokenPermit: `0x${string}`;
|
|
55
|
+
value: bigint;
|
|
56
|
+
txOverride?: Partial<TransactionRequest>;
|
|
57
|
+
}) => Promise<{
|
|
58
|
+
rawTx: never;
|
|
59
|
+
txHash: `0x${string}`;
|
|
60
|
+
}>;
|
|
61
|
+
signWithReceipt: (params: {
|
|
62
|
+
account: Address;
|
|
63
|
+
swapData: SwapData;
|
|
64
|
+
takerTokenPermit: `0x${string}`;
|
|
65
|
+
value: bigint;
|
|
66
|
+
}) => Promise<import("viem").TransactionReceipt>;
|
|
67
|
+
signTypedData: (swapData: SwapData, account: Address) => Promise<`0x${string}`>;
|
|
68
|
+
signRelayer: ({ account, sig, swapData, value, txOverride, }: {
|
|
69
|
+
account: Address;
|
|
70
|
+
sig: `0x${string}`;
|
|
71
|
+
swapData: SwapData;
|
|
72
|
+
value: bigint;
|
|
73
|
+
txOverride?: TransactionRequest;
|
|
74
|
+
}) => Promise<{
|
|
75
|
+
txHash: string;
|
|
76
|
+
rawTx: never;
|
|
77
|
+
}>;
|
|
78
|
+
submit: (dto: SubmitDTO) => Promise<any>;
|
|
79
|
+
list: (dto: ListDTO) => Promise<ListItem>;
|
|
80
|
+
status: (dto: StatusDTO) => Promise<{
|
|
81
|
+
status: string;
|
|
82
|
+
}>;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/swap/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,WAAW,CAAA;AAOpC,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,KAAK,EACV,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,QAAQ,EACd,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EAYlB,MAAM,MAAM,CAAA;AAKb,eAAO,MAAM,kBAAkB,SAAU,CAAA;AAEzC,qBAAa,IAAI;IACf,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,OAAO,KAAK,CAAQ;IAC3B,GAAG,EAAE,GAAG,CAAA;IACR,YAAY,EAAE,YAAY,CAAA;IAC1B,YAAY,EAAE,YAAY,CAAA;IAC1B,QAAQ,EAAE,eAAe,CAAA;gBAGvB,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE;QACN,YAAY,EAAE,YAAY,CAAA;QAC1B,YAAY,EAAE,YAAY,CAAA;QAC1B,QAAQ,EAAE,eAAe,CAAA;KAC1B;IAUH,OAAO,CAAC,IAAI,CAYX;IAED,OAAO,CAAC,mBAAmB,CA+B1B;IAED,SAAS,CAAC,YAAY,WACZ,MAAM,eACD,MAAM,uBACE,MAAM,YAW5B;IAEM,YAAY;eAMV,KAAK;kBACF,MAAM,GAAG,GAAG,MAAM,EAAE;iBACrB,MAAM;wBACC,OAAO;;;;;;;;;;;;;;;;;MAoDxB;IAEM,aAAa,QAAe,aAAa,KAAG,QAAQ,UAAU,CAAC,CAQrE;IAEM,KAAK,QAAe,QAAQ,KAAG,QAAQ,KAAK,CAAC,CAgBnD;IAED,kBAAkB,aAAc,QAAQ,mBAcvC;IAEM,QAAQ;iBAKJ,OAAO;eACT,KAAK;kBACF,MAAM,GAAG,GAAG,MAAM,EAAE;0BAiB/B;IAEM,IAAI,WAAkB;QAC3B,OAAO,EAAE,OAAO,CAAA;QAChB,QAAQ,EAAE,QAAQ,CAAA;QAClB,gBAAgB,EAAE,KAAK,MAAM,EAAE,CAAA;QAC/B,KAAK,EAAE,MAAM,CAAA;QACb,UAAU,CAAC,EAAE,QAAQ,kBAAkB,CAAC,CAAA;KACzC;;;OAuCA;IAEM,eAAe,WAAkB;QACtC,OAAO,EAAE,OAAO,CAAA;QAChB,QAAQ,EAAE,QAAQ,CAAA;QAClB,gBAAgB,EAAE,KAAK,MAAM,EAAE,CAAA;QAC/B,KAAK,EAAE,MAAM,CAAA;KACd,gDAMA;IAEM,aAAa,aAAoB,QAAQ,WAAW,OAAO,4BAmBjE;IAEM,WAAW;iBAOP,OAAO;aACX,KAAK,MAAM,EAAE;kBACR,QAAQ;eACX,MAAM;qBACA,kBAAkB;;;;OA0BhC;IAEM,MAAM,QAAe,SAAS,kBASpC;IAEM,IAAI,QAAe,OAAO,KAAG,QAAQ,QAAQ,CAAC,CAOpD;IAGM,MAAM,QAAe,SAAS,KAAG,QAAQ;QAAE,QAAQ,MAAM,CAAA;KAAE,CAAC,CAOlE;CACF"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { type Env } from '../env.js';
|
|
2
|
+
import { type Address } from 'viem';
|
|
3
|
+
export type SwapConfig = {
|
|
4
|
+
fetch?: typeof fetch;
|
|
5
|
+
env: Env;
|
|
6
|
+
chain: number;
|
|
7
|
+
};
|
|
8
|
+
export type QuoteDTO = {
|
|
9
|
+
/**
|
|
10
|
+
* [optional] user address to quote
|
|
11
|
+
*/
|
|
12
|
+
userAddress?: Address | '';
|
|
13
|
+
/**
|
|
14
|
+
* from token address
|
|
15
|
+
*/
|
|
16
|
+
fromToken: Address;
|
|
17
|
+
/**
|
|
18
|
+
* to token address
|
|
19
|
+
*/
|
|
20
|
+
toToken: Address;
|
|
21
|
+
/**
|
|
22
|
+
* amount to swap
|
|
23
|
+
* the amount is in the unit of `fromToken`, and with decimals
|
|
24
|
+
* for example, if `fromToken` is `ETH`, then `amount` is 1.1, meaning 1.1 ETH
|
|
25
|
+
*/
|
|
26
|
+
amount: `${number}`;
|
|
27
|
+
};
|
|
28
|
+
export type MarketRateDTO = {
|
|
29
|
+
baseAddress: Address;
|
|
30
|
+
quoteAddress: Address;
|
|
31
|
+
};
|
|
32
|
+
export type MarketRate = {
|
|
33
|
+
marketName: string;
|
|
34
|
+
price: `${number}`;
|
|
35
|
+
};
|
|
36
|
+
export type SubmitDTO = SubmitBySelfDTO | SubmitByRelayerDTO;
|
|
37
|
+
export type SubmitBaseDTO = {
|
|
38
|
+
uniqueId: string;
|
|
39
|
+
slippage: `${number}` | number;
|
|
40
|
+
fee: {
|
|
41
|
+
gasFee: string;
|
|
42
|
+
protocolFee: string;
|
|
43
|
+
};
|
|
44
|
+
minAmountOut: bigint;
|
|
45
|
+
permit: string;
|
|
46
|
+
strategyData: `0x${string}`;
|
|
47
|
+
};
|
|
48
|
+
export type SubmitBySelfDTO = SubmitBaseDTO & {
|
|
49
|
+
txHash: string;
|
|
50
|
+
rawTx: string;
|
|
51
|
+
};
|
|
52
|
+
export type SubmitByRelayerDTO = SubmitBaseDTO & {
|
|
53
|
+
orderSignature: string;
|
|
54
|
+
};
|
|
55
|
+
export type ListDTO = {
|
|
56
|
+
account: Address;
|
|
57
|
+
};
|
|
58
|
+
export type StatusDTO = {
|
|
59
|
+
uniqueId: string;
|
|
60
|
+
} | {
|
|
61
|
+
txHash: string;
|
|
62
|
+
} | {
|
|
63
|
+
orderHash: string;
|
|
64
|
+
};
|
|
65
|
+
export type Order = {
|
|
66
|
+
uniqueId: string;
|
|
67
|
+
taker: Address;
|
|
68
|
+
fromAddress: Address;
|
|
69
|
+
toAddress: Address;
|
|
70
|
+
amountIn: `${number}`;
|
|
71
|
+
amountOut: `${number}`;
|
|
72
|
+
rate: `${number}`;
|
|
73
|
+
feeFactor: number;
|
|
74
|
+
routes: any[];
|
|
75
|
+
swapData: {
|
|
76
|
+
maker: Address;
|
|
77
|
+
takerToken: Address;
|
|
78
|
+
takerTokenAmount: string;
|
|
79
|
+
makerToken: Address;
|
|
80
|
+
makerTokenAmount: string;
|
|
81
|
+
minMakerTokenAmount: 0 | string;
|
|
82
|
+
expiry: number;
|
|
83
|
+
salt: string;
|
|
84
|
+
recipient: Address;
|
|
85
|
+
strategyData: `0x${string}`;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
export type ListItem = {
|
|
89
|
+
id: number;
|
|
90
|
+
userAddress: Address;
|
|
91
|
+
recipient: Address;
|
|
92
|
+
fromTokenAddress: Address;
|
|
93
|
+
toTokenAddress: Address;
|
|
94
|
+
rate: `${number}`;
|
|
95
|
+
amountIn: `${number}`;
|
|
96
|
+
amountOut: `${number}`;
|
|
97
|
+
minAmountOut: `${number}`;
|
|
98
|
+
orderHash: string;
|
|
99
|
+
uniqueId: string;
|
|
100
|
+
expiryInMillis: number;
|
|
101
|
+
status: string;
|
|
102
|
+
orderSignature: string;
|
|
103
|
+
rawTx: string;
|
|
104
|
+
txHash: string;
|
|
105
|
+
feeFactor: number;
|
|
106
|
+
gasFee: string;
|
|
107
|
+
salt: string;
|
|
108
|
+
strategyData: string;
|
|
109
|
+
permit: string;
|
|
110
|
+
txData: string;
|
|
111
|
+
createdAt: string;
|
|
112
|
+
updatedAt: string;
|
|
113
|
+
};
|
|
114
|
+
export type SwapData = {
|
|
115
|
+
maker: Address;
|
|
116
|
+
takerToken: Address;
|
|
117
|
+
takerTokenAmount: bigint;
|
|
118
|
+
makerToken: Address;
|
|
119
|
+
makerTokenAmount: bigint;
|
|
120
|
+
minMakerTokenAmount: bigint;
|
|
121
|
+
expiry: bigint;
|
|
122
|
+
salt: bigint;
|
|
123
|
+
recipient: Address;
|
|
124
|
+
strategyData: `0x${string}`;
|
|
125
|
+
};
|
|
126
|
+
//# sourceMappingURL=type.d.ts.map
|