@yaswap/evm-contracts 2.0.0

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.
@@ -0,0 +1,449 @@
1
+ {
2
+ "_format": "hh-sol-artifact-1",
3
+ "contractName": "Multicall3",
4
+ "sourceName": "contracts/utils/Multicall.sol",
5
+ "abi": [
6
+ {
7
+ "inputs": [
8
+ {
9
+ "components": [
10
+ {
11
+ "internalType": "address",
12
+ "name": "target",
13
+ "type": "address"
14
+ },
15
+ {
16
+ "internalType": "bytes",
17
+ "name": "callData",
18
+ "type": "bytes"
19
+ }
20
+ ],
21
+ "internalType": "struct Multicall3.Call[]",
22
+ "name": "calls",
23
+ "type": "tuple[]"
24
+ }
25
+ ],
26
+ "name": "aggregate",
27
+ "outputs": [
28
+ {
29
+ "internalType": "uint256",
30
+ "name": "blockNumber",
31
+ "type": "uint256"
32
+ },
33
+ {
34
+ "internalType": "bytes[]",
35
+ "name": "returnData",
36
+ "type": "bytes[]"
37
+ }
38
+ ],
39
+ "stateMutability": "payable",
40
+ "type": "function"
41
+ },
42
+ {
43
+ "inputs": [
44
+ {
45
+ "components": [
46
+ {
47
+ "internalType": "address",
48
+ "name": "target",
49
+ "type": "address"
50
+ },
51
+ {
52
+ "internalType": "bool",
53
+ "name": "allowFailure",
54
+ "type": "bool"
55
+ },
56
+ {
57
+ "internalType": "bytes",
58
+ "name": "callData",
59
+ "type": "bytes"
60
+ }
61
+ ],
62
+ "internalType": "struct Multicall3.Call3[]",
63
+ "name": "calls",
64
+ "type": "tuple[]"
65
+ }
66
+ ],
67
+ "name": "aggregate3",
68
+ "outputs": [
69
+ {
70
+ "components": [
71
+ {
72
+ "internalType": "bool",
73
+ "name": "success",
74
+ "type": "bool"
75
+ },
76
+ {
77
+ "internalType": "bytes",
78
+ "name": "returnData",
79
+ "type": "bytes"
80
+ }
81
+ ],
82
+ "internalType": "struct Multicall3.Result[]",
83
+ "name": "returnData",
84
+ "type": "tuple[]"
85
+ }
86
+ ],
87
+ "stateMutability": "payable",
88
+ "type": "function"
89
+ },
90
+ {
91
+ "inputs": [
92
+ {
93
+ "components": [
94
+ {
95
+ "internalType": "address",
96
+ "name": "target",
97
+ "type": "address"
98
+ },
99
+ {
100
+ "internalType": "bool",
101
+ "name": "allowFailure",
102
+ "type": "bool"
103
+ },
104
+ {
105
+ "internalType": "uint256",
106
+ "name": "value",
107
+ "type": "uint256"
108
+ },
109
+ {
110
+ "internalType": "bytes",
111
+ "name": "callData",
112
+ "type": "bytes"
113
+ }
114
+ ],
115
+ "internalType": "struct Multicall3.Call3Value[]",
116
+ "name": "calls",
117
+ "type": "tuple[]"
118
+ }
119
+ ],
120
+ "name": "aggregate3Value",
121
+ "outputs": [
122
+ {
123
+ "components": [
124
+ {
125
+ "internalType": "bool",
126
+ "name": "success",
127
+ "type": "bool"
128
+ },
129
+ {
130
+ "internalType": "bytes",
131
+ "name": "returnData",
132
+ "type": "bytes"
133
+ }
134
+ ],
135
+ "internalType": "struct Multicall3.Result[]",
136
+ "name": "returnData",
137
+ "type": "tuple[]"
138
+ }
139
+ ],
140
+ "stateMutability": "payable",
141
+ "type": "function"
142
+ },
143
+ {
144
+ "inputs": [
145
+ {
146
+ "components": [
147
+ {
148
+ "internalType": "address",
149
+ "name": "target",
150
+ "type": "address"
151
+ },
152
+ {
153
+ "internalType": "bytes",
154
+ "name": "callData",
155
+ "type": "bytes"
156
+ }
157
+ ],
158
+ "internalType": "struct Multicall3.Call[]",
159
+ "name": "calls",
160
+ "type": "tuple[]"
161
+ }
162
+ ],
163
+ "name": "blockAndAggregate",
164
+ "outputs": [
165
+ {
166
+ "internalType": "uint256",
167
+ "name": "blockNumber",
168
+ "type": "uint256"
169
+ },
170
+ {
171
+ "internalType": "bytes32",
172
+ "name": "blockHash",
173
+ "type": "bytes32"
174
+ },
175
+ {
176
+ "components": [
177
+ {
178
+ "internalType": "bool",
179
+ "name": "success",
180
+ "type": "bool"
181
+ },
182
+ {
183
+ "internalType": "bytes",
184
+ "name": "returnData",
185
+ "type": "bytes"
186
+ }
187
+ ],
188
+ "internalType": "struct Multicall3.Result[]",
189
+ "name": "returnData",
190
+ "type": "tuple[]"
191
+ }
192
+ ],
193
+ "stateMutability": "payable",
194
+ "type": "function"
195
+ },
196
+ {
197
+ "inputs": [],
198
+ "name": "getBasefee",
199
+ "outputs": [
200
+ {
201
+ "internalType": "uint256",
202
+ "name": "basefee",
203
+ "type": "uint256"
204
+ }
205
+ ],
206
+ "stateMutability": "view",
207
+ "type": "function"
208
+ },
209
+ {
210
+ "inputs": [
211
+ {
212
+ "internalType": "uint256",
213
+ "name": "blockNumber",
214
+ "type": "uint256"
215
+ }
216
+ ],
217
+ "name": "getBlockHash",
218
+ "outputs": [
219
+ {
220
+ "internalType": "bytes32",
221
+ "name": "blockHash",
222
+ "type": "bytes32"
223
+ }
224
+ ],
225
+ "stateMutability": "view",
226
+ "type": "function"
227
+ },
228
+ {
229
+ "inputs": [],
230
+ "name": "getBlockNumber",
231
+ "outputs": [
232
+ {
233
+ "internalType": "uint256",
234
+ "name": "blockNumber",
235
+ "type": "uint256"
236
+ }
237
+ ],
238
+ "stateMutability": "view",
239
+ "type": "function"
240
+ },
241
+ {
242
+ "inputs": [],
243
+ "name": "getChainId",
244
+ "outputs": [
245
+ {
246
+ "internalType": "uint256",
247
+ "name": "chainid",
248
+ "type": "uint256"
249
+ }
250
+ ],
251
+ "stateMutability": "view",
252
+ "type": "function"
253
+ },
254
+ {
255
+ "inputs": [],
256
+ "name": "getCurrentBlockCoinbase",
257
+ "outputs": [
258
+ {
259
+ "internalType": "address",
260
+ "name": "coinbase",
261
+ "type": "address"
262
+ }
263
+ ],
264
+ "stateMutability": "view",
265
+ "type": "function"
266
+ },
267
+ {
268
+ "inputs": [],
269
+ "name": "getCurrentBlockDifficulty",
270
+ "outputs": [
271
+ {
272
+ "internalType": "uint256",
273
+ "name": "difficulty",
274
+ "type": "uint256"
275
+ }
276
+ ],
277
+ "stateMutability": "view",
278
+ "type": "function"
279
+ },
280
+ {
281
+ "inputs": [],
282
+ "name": "getCurrentBlockGasLimit",
283
+ "outputs": [
284
+ {
285
+ "internalType": "uint256",
286
+ "name": "gaslimit",
287
+ "type": "uint256"
288
+ }
289
+ ],
290
+ "stateMutability": "view",
291
+ "type": "function"
292
+ },
293
+ {
294
+ "inputs": [],
295
+ "name": "getCurrentBlockTimestamp",
296
+ "outputs": [
297
+ {
298
+ "internalType": "uint256",
299
+ "name": "timestamp",
300
+ "type": "uint256"
301
+ }
302
+ ],
303
+ "stateMutability": "view",
304
+ "type": "function"
305
+ },
306
+ {
307
+ "inputs": [
308
+ {
309
+ "internalType": "address",
310
+ "name": "addr",
311
+ "type": "address"
312
+ }
313
+ ],
314
+ "name": "getEthBalance",
315
+ "outputs": [
316
+ {
317
+ "internalType": "uint256",
318
+ "name": "balance",
319
+ "type": "uint256"
320
+ }
321
+ ],
322
+ "stateMutability": "view",
323
+ "type": "function"
324
+ },
325
+ {
326
+ "inputs": [],
327
+ "name": "getLastBlockHash",
328
+ "outputs": [
329
+ {
330
+ "internalType": "bytes32",
331
+ "name": "blockHash",
332
+ "type": "bytes32"
333
+ }
334
+ ],
335
+ "stateMutability": "view",
336
+ "type": "function"
337
+ },
338
+ {
339
+ "inputs": [
340
+ {
341
+ "internalType": "bool",
342
+ "name": "requireSuccess",
343
+ "type": "bool"
344
+ },
345
+ {
346
+ "components": [
347
+ {
348
+ "internalType": "address",
349
+ "name": "target",
350
+ "type": "address"
351
+ },
352
+ {
353
+ "internalType": "bytes",
354
+ "name": "callData",
355
+ "type": "bytes"
356
+ }
357
+ ],
358
+ "internalType": "struct Multicall3.Call[]",
359
+ "name": "calls",
360
+ "type": "tuple[]"
361
+ }
362
+ ],
363
+ "name": "tryAggregate",
364
+ "outputs": [
365
+ {
366
+ "components": [
367
+ {
368
+ "internalType": "bool",
369
+ "name": "success",
370
+ "type": "bool"
371
+ },
372
+ {
373
+ "internalType": "bytes",
374
+ "name": "returnData",
375
+ "type": "bytes"
376
+ }
377
+ ],
378
+ "internalType": "struct Multicall3.Result[]",
379
+ "name": "returnData",
380
+ "type": "tuple[]"
381
+ }
382
+ ],
383
+ "stateMutability": "payable",
384
+ "type": "function"
385
+ },
386
+ {
387
+ "inputs": [
388
+ {
389
+ "internalType": "bool",
390
+ "name": "requireSuccess",
391
+ "type": "bool"
392
+ },
393
+ {
394
+ "components": [
395
+ {
396
+ "internalType": "address",
397
+ "name": "target",
398
+ "type": "address"
399
+ },
400
+ {
401
+ "internalType": "bytes",
402
+ "name": "callData",
403
+ "type": "bytes"
404
+ }
405
+ ],
406
+ "internalType": "struct Multicall3.Call[]",
407
+ "name": "calls",
408
+ "type": "tuple[]"
409
+ }
410
+ ],
411
+ "name": "tryBlockAndAggregate",
412
+ "outputs": [
413
+ {
414
+ "internalType": "uint256",
415
+ "name": "blockNumber",
416
+ "type": "uint256"
417
+ },
418
+ {
419
+ "internalType": "bytes32",
420
+ "name": "blockHash",
421
+ "type": "bytes32"
422
+ },
423
+ {
424
+ "components": [
425
+ {
426
+ "internalType": "bool",
427
+ "name": "success",
428
+ "type": "bool"
429
+ },
430
+ {
431
+ "internalType": "bytes",
432
+ "name": "returnData",
433
+ "type": "bytes"
434
+ }
435
+ ],
436
+ "internalType": "struct Multicall3.Result[]",
437
+ "name": "returnData",
438
+ "type": "tuple[]"
439
+ }
440
+ ],
441
+ "stateMutability": "payable",
442
+ "type": "function"
443
+ }
444
+ ],
445
+ "bytecode": "0x608060405234801561001057600080fd5b50610cc5806100206000396000f3fe6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e1461022f578063bce38bd71461024a578063c3077fa91461025d578063ee82ac5e1461027057600080fd5b80634d2301cc146101ce57806372425d9d146101f657806382ad56cb1461020957806386d516e81461021c57600080fd5b80633408e470116100c65780633408e47014610173578063399542e9146101865780633e64a696146101a857806342cbb15c146101bb57600080fd5b80630f28c97d146100f8578063174dea711461011a578063252dba421461013a57806327e86d6e1461015b575b600080fd5b34801561010457600080fd5b50425b6040519081526020015b60405180910390f35b61012d6101283660046109a4565b61028f565b6040516101119190610aa1565b61014d6101483660046109a4565b610483565b604051610111929190610abb565b34801561016757600080fd5b50436000190140610107565b34801561017f57600080fd5b5046610107565b610199610194366004610b25565b6105fd565b60405161011193929190610b7f565b3480156101b457600080fd5b5048610107565b3480156101c757600080fd5b5043610107565b3480156101da57600080fd5b506101076101e9366004610ba7565b6001600160a01b03163190565b34801561020257600080fd5b5044610107565b61012d6102173660046109a4565b610618565b34801561022857600080fd5b5045610107565b34801561023b57600080fd5b50604051418152602001610111565b61012d610258366004610b25565b6107a0565b61019961026b3660046109a4565b610939565b34801561027c57600080fd5b5061010761028b366004610bd0565b4090565b60606000828067ffffffffffffffff8111156102ad576102ad610be9565b6040519080825280602002602001820160405280156102f357816020015b6040805180820190915260008152606060208201528152602001906001900390816102cb5790505b5092503660005b8281101561042557600085828151811061031657610316610bff565b6020026020010151905087878381811061033257610332610bff565b90506020028101906103449190610c15565b60408101359586019590935061035d6020850185610ba7565b6001600160a01b0316816103746060870187610c35565b604051610382929190610c7c565b60006040518083038185875af1925050503d80600081146103bf576040519150601f19603f3d011682016040523d82523d6000602084013e6103c4565b606091505b50602080850191909152901515808452908501351761041b5762461bcd60e51b600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b50506001016102fa565b5082341461047a5760405162461bcd60e51b815260206004820152601a60248201527f4d756c746963616c6c333a2076616c7565206d69736d6174636800000000000060448201526064015b60405180910390fd5b50505092915050565b436060828067ffffffffffffffff8111156104a0576104a0610be9565b6040519080825280602002602001820160405280156104d357816020015b60608152602001906001900390816104be5790505b5091503660005b828110156105f35760008787838181106104f6576104f6610bff565b90506020028101906105089190610c8c565b92506105176020840184610ba7565b6001600160a01b031661052d6020850185610c35565b60405161053b929190610c7c565b6000604051808303816000865af19150503d8060008114610578576040519150601f19603f3d011682016040523d82523d6000602084013e61057d565b606091505b5086848151811061059057610590610bff565b60209081029190910101529050806105ea5760405162461bcd60e51b815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c65640000000000000000006044820152606401610471565b506001016104da565b5050509250929050565b438040606061060d8686866107a0565b905093509350939050565b6060818067ffffffffffffffff81111561063457610634610be9565b60405190808252806020026020018201604052801561067a57816020015b6040805180820190915260008152606060208201528152602001906001900390816106525790505b5091503660005b8281101561047a57600084828151811061069d5761069d610bff565b602002602001015190508686838181106106b9576106b9610bff565b90506020028101906106cb9190610ca2565b92506106da6020840184610ba7565b6001600160a01b03166106f06040850185610c35565b6040516106fe929190610c7c565b6000604051808303816000865af19150503d806000811461073b576040519150601f19603f3d011682016040523d82523d6000602084013e610740565b606091505b5060208084019190915290151580835290840135176107975762461bcd60e51b600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b50600101610681565b6060818067ffffffffffffffff8111156107bc576107bc610be9565b60405190808252806020026020018201604052801561080257816020015b6040805180820190915260008152606060208201528152602001906001900390816107da5790505b5091503660005b8281101561092f57600084828151811061082557610825610bff565b6020026020010151905086868381811061084157610841610bff565b90506020028101906108539190610c8c565b92506108626020840184610ba7565b6001600160a01b03166108786020850185610c35565b604051610886929190610c7c565b6000604051808303816000865af19150503d80600081146108c3576040519150601f19603f3d011682016040523d82523d6000602084013e6108c8565b606091505b5060208301521515815287156109265780516109265760405162461bcd60e51b815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c65640000000000000000006044820152606401610471565b50600101610809565b5050509392505050565b600080606061094a600186866105fd565b919790965090945092505050565b60008083601f84011261096a57600080fd5b50813567ffffffffffffffff81111561098257600080fd5b6020830191508360208260051b850101111561099d57600080fd5b9250929050565b600080602083850312156109b757600080fd5b823567ffffffffffffffff8111156109ce57600080fd5b6109da85828601610958565b90969095509350505050565b6000815180845260005b81811015610a0c576020818501810151868301820152016109f0565b81811115610a1e576000602083870101525b50601f01601f19169290920160200192915050565b600082825180855260208086019550808260051b84010181860160005b84811015610a9457858303601f1901895281518051151584528401516040858501819052610a80818601836109e6565b9a86019a9450505090830190600101610a50565b5090979650505050505050565b602081526000610ab46020830184610a33565b9392505050565b600060408201848352602060408185015281855180845260608601915060608160051b870101935082870160005b82811015610b1757605f19888703018452610b058683516109e6565b95509284019290840190600101610ae9565b509398975050505050505050565b600080600060408486031215610b3a57600080fd5b83358015158114610b4a57600080fd5b9250602084013567ffffffffffffffff811115610b6657600080fd5b610b7286828701610958565b9497909650939450505050565b838152826020820152606060408201526000610b9e6060830184610a33565b95945050505050565b600060208284031215610bb957600080fd5b81356001600160a01b0381168114610ab457600080fd5b600060208284031215610be257600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b60008235607e19833603018112610c2b57600080fd5b9190910192915050565b6000808335601e19843603018112610c4c57600080fd5b83018035915067ffffffffffffffff821115610c6757600080fd5b60200191503681900382131561099d57600080fd5b8183823760009101908152919050565b60008235603e19833603018112610c2b57600080fd5b60008235605e19833603018112610c2b57600080fdfea164736f6c634300080b000a",
446
+ "deployedBytecode": "0x6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e1461022f578063bce38bd71461024a578063c3077fa91461025d578063ee82ac5e1461027057600080fd5b80634d2301cc146101ce57806372425d9d146101f657806382ad56cb1461020957806386d516e81461021c57600080fd5b80633408e470116100c65780633408e47014610173578063399542e9146101865780633e64a696146101a857806342cbb15c146101bb57600080fd5b80630f28c97d146100f8578063174dea711461011a578063252dba421461013a57806327e86d6e1461015b575b600080fd5b34801561010457600080fd5b50425b6040519081526020015b60405180910390f35b61012d6101283660046109a4565b61028f565b6040516101119190610aa1565b61014d6101483660046109a4565b610483565b604051610111929190610abb565b34801561016757600080fd5b50436000190140610107565b34801561017f57600080fd5b5046610107565b610199610194366004610b25565b6105fd565b60405161011193929190610b7f565b3480156101b457600080fd5b5048610107565b3480156101c757600080fd5b5043610107565b3480156101da57600080fd5b506101076101e9366004610ba7565b6001600160a01b03163190565b34801561020257600080fd5b5044610107565b61012d6102173660046109a4565b610618565b34801561022857600080fd5b5045610107565b34801561023b57600080fd5b50604051418152602001610111565b61012d610258366004610b25565b6107a0565b61019961026b3660046109a4565b610939565b34801561027c57600080fd5b5061010761028b366004610bd0565b4090565b60606000828067ffffffffffffffff8111156102ad576102ad610be9565b6040519080825280602002602001820160405280156102f357816020015b6040805180820190915260008152606060208201528152602001906001900390816102cb5790505b5092503660005b8281101561042557600085828151811061031657610316610bff565b6020026020010151905087878381811061033257610332610bff565b90506020028101906103449190610c15565b60408101359586019590935061035d6020850185610ba7565b6001600160a01b0316816103746060870187610c35565b604051610382929190610c7c565b60006040518083038185875af1925050503d80600081146103bf576040519150601f19603f3d011682016040523d82523d6000602084013e6103c4565b606091505b50602080850191909152901515808452908501351761041b5762461bcd60e51b600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b50506001016102fa565b5082341461047a5760405162461bcd60e51b815260206004820152601a60248201527f4d756c746963616c6c333a2076616c7565206d69736d6174636800000000000060448201526064015b60405180910390fd5b50505092915050565b436060828067ffffffffffffffff8111156104a0576104a0610be9565b6040519080825280602002602001820160405280156104d357816020015b60608152602001906001900390816104be5790505b5091503660005b828110156105f35760008787838181106104f6576104f6610bff565b90506020028101906105089190610c8c565b92506105176020840184610ba7565b6001600160a01b031661052d6020850185610c35565b60405161053b929190610c7c565b6000604051808303816000865af19150503d8060008114610578576040519150601f19603f3d011682016040523d82523d6000602084013e61057d565b606091505b5086848151811061059057610590610bff565b60209081029190910101529050806105ea5760405162461bcd60e51b815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c65640000000000000000006044820152606401610471565b506001016104da565b5050509250929050565b438040606061060d8686866107a0565b905093509350939050565b6060818067ffffffffffffffff81111561063457610634610be9565b60405190808252806020026020018201604052801561067a57816020015b6040805180820190915260008152606060208201528152602001906001900390816106525790505b5091503660005b8281101561047a57600084828151811061069d5761069d610bff565b602002602001015190508686838181106106b9576106b9610bff565b90506020028101906106cb9190610ca2565b92506106da6020840184610ba7565b6001600160a01b03166106f06040850185610c35565b6040516106fe929190610c7c565b6000604051808303816000865af19150503d806000811461073b576040519150601f19603f3d011682016040523d82523d6000602084013e610740565b606091505b5060208084019190915290151580835290840135176107975762461bcd60e51b600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b50600101610681565b6060818067ffffffffffffffff8111156107bc576107bc610be9565b60405190808252806020026020018201604052801561080257816020015b6040805180820190915260008152606060208201528152602001906001900390816107da5790505b5091503660005b8281101561092f57600084828151811061082557610825610bff565b6020026020010151905086868381811061084157610841610bff565b90506020028101906108539190610c8c565b92506108626020840184610ba7565b6001600160a01b03166108786020850185610c35565b604051610886929190610c7c565b6000604051808303816000865af19150503d80600081146108c3576040519150601f19603f3d011682016040523d82523d6000602084013e6108c8565b606091505b5060208301521515815287156109265780516109265760405162461bcd60e51b815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c65640000000000000000006044820152606401610471565b50600101610809565b5050509392505050565b600080606061094a600186866105fd565b919790965090945092505050565b60008083601f84011261096a57600080fd5b50813567ffffffffffffffff81111561098257600080fd5b6020830191508360208260051b850101111561099d57600080fd5b9250929050565b600080602083850312156109b757600080fd5b823567ffffffffffffffff8111156109ce57600080fd5b6109da85828601610958565b90969095509350505050565b6000815180845260005b81811015610a0c576020818501810151868301820152016109f0565b81811115610a1e576000602083870101525b50601f01601f19169290920160200192915050565b600082825180855260208086019550808260051b84010181860160005b84811015610a9457858303601f1901895281518051151584528401516040858501819052610a80818601836109e6565b9a86019a9450505090830190600101610a50565b5090979650505050505050565b602081526000610ab46020830184610a33565b9392505050565b600060408201848352602060408185015281855180845260608601915060608160051b870101935082870160005b82811015610b1757605f19888703018452610b058683516109e6565b95509284019290840190600101610ae9565b509398975050505050505050565b600080600060408486031215610b3a57600080fd5b83358015158114610b4a57600080fd5b9250602084013567ffffffffffffffff811115610b6657600080fd5b610b7286828701610958565b9497909650939450505050565b838152826020820152606060408201526000610b9e6060830184610a33565b95945050505050565b600060208284031215610bb957600080fd5b81356001600160a01b0381168114610ab457600080fd5b600060208284031215610be257600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b60008235607e19833603018112610c2b57600080fd5b9190910192915050565b6000808335601e19843603018112610c4c57600080fd5b83018035915067ffffffffffffffff821115610c6757600080fd5b60200191503681900382131561099d57600080fd5b8183823760009101908152919050565b60008235603e19833603018112610c2b57600080fd5b60008235605e19833603018112610c2b57600080fdfea164736f6c634300080b000a",
447
+ "linkReferences": {},
448
+ "deployedLinkReferences": {}
449
+ }
@@ -0,0 +1,59 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity 0.8.11;
3
+
4
+ /// @title ILiqualityHTLC
5
+ interface ILiqualityHTLC {
6
+ struct HTLCData {
7
+ uint256 amount;
8
+ uint256 expiration;
9
+ bytes32 secretHash;
10
+ address tokenAddress;
11
+ address refundAddress;
12
+ address recipientAddress;
13
+ }
14
+
15
+ /// @notice Emitted when a successful HTLC was created
16
+ event Initiate(bytes32 id, HTLCData htlc);
17
+
18
+ /// @notice Emitted when a successful Refund was performed
19
+ event Refund(bytes32 indexed id);
20
+
21
+ /// @notice Emitted when a successful Claim was performed
22
+ event Claim(bytes32 indexed id, bytes32 secret);
23
+
24
+ /// @notice Initiates a HTLC based on the input parameters.
25
+ function initiate(HTLCData calldata htlc) external payable returns (bytes32);
26
+
27
+ /// @notice Claims an existing HTLC for the provided `id` using the `secret`.
28
+ /// @param id htlc id
29
+ /// @param secret the secret used to create the `secretHash`
30
+ function claim(bytes32 id, bytes32 secret) external;
31
+
32
+ /// @notice Refunds an existing HTLC for the provided `id`. The refunded amount goes to the `refundAddress`
33
+ /// @param id htlc id
34
+ function refund(bytes32 id) external;
35
+
36
+ /// @notice Emitted when the sha256 of the provided secret during claim does not match the secret hash
37
+ error LiqualityHTLC__WrongSecret();
38
+
39
+ /// @notice Emitted when the provided expiration is smaller than the current block timestmap
40
+ error LiqualityHTLC__InvalidExpiration();
41
+
42
+ /// @notice Emitted when the amount is 0
43
+ error LiqualityHTLC__InvalidSwapAmount();
44
+
45
+ /// @notice Emitted when initiating Ether HTLC and the amount does not match the msg.value
46
+ error LiqualityHTLC__InvalidMsgValue();
47
+
48
+ /// @notice Emitted when the generated id already exists
49
+ error LiqualityHTLC__SwapAlreadyExists();
50
+
51
+ /// @notice Emitted when the generated swap does not exists
52
+ error LiqualityHTLC__SwapDoesNotExist();
53
+
54
+ /// @notice Emitted when there is an attempt for refund when the swap is not expired
55
+ error LiqualityHTLC__SwapNotExpired();
56
+
57
+ /// @notice Emitted when the msg.sender does not match the provided `refundAddress`
58
+ error LiqualityHTLC__InvalidSender();
59
+ }
@@ -0,0 +1,11 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity >=0.8.11;
4
+
5
+ library LibTransfer {
6
+ function transferEth(address to, uint256 value) internal {
7
+ // solhint-disable-next-line
8
+ (bool success, ) = to.call{ value: value }('');
9
+ require(success, 'transfer failed');
10
+ }
11
+ }
@@ -0,0 +1,104 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity 0.8.11;
3
+
4
+ import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
5
+
6
+ import './ILiqualityHTLC.sol';
7
+ import './LibTransfer.sol';
8
+
9
+ /// @title LiqualityHTLC
10
+ /// @notice HTLC contract to support Liquality's cross-chain swaps.
11
+ contract LiqualityHTLC is ILiqualityHTLC {
12
+ using SafeERC20 for IERC20;
13
+
14
+ mapping(bytes32 => HTLCData) public htlcs;
15
+
16
+ /// @inheritdoc ILiqualityHTLC
17
+ function initiate(HTLCData calldata htlc) external payable returns (bytes32 id) {
18
+ if (htlc.expiration < block.timestamp) {
19
+ revert LiqualityHTLC__InvalidExpiration();
20
+ }
21
+
22
+ if (htlc.amount == 0) {
23
+ revert LiqualityHTLC__InvalidSwapAmount();
24
+ }
25
+
26
+ // handle Ether swaps
27
+ if (htlc.tokenAddress == address(0x0)) {
28
+ if (htlc.amount != msg.value) {
29
+ revert LiqualityHTLC__InvalidMsgValue();
30
+ }
31
+ }
32
+ // handle ERC20 swaps
33
+ else {
34
+ // protection against permanantly locking ETH when using ERC20 tokens
35
+ if (msg.value > 0) {
36
+ revert LiqualityHTLC__InvalidMsgValue();
37
+ }
38
+ IERC20(htlc.tokenAddress).safeTransferFrom(msg.sender, address(this), htlc.amount);
39
+ }
40
+
41
+ id = sha256(abi.encode(htlc.refundAddress, block.timestamp, htlc.amount, htlc.expiration, htlc.secretHash, htlc.recipientAddress));
42
+
43
+ if (htlcs[id].expiration != 0) {
44
+ revert LiqualityHTLC__SwapAlreadyExists();
45
+ }
46
+
47
+ htlcs[id] = htlc;
48
+ emit Initiate(id, htlc);
49
+ }
50
+
51
+ /// @inheritdoc ILiqualityHTLC
52
+ function claim(bytes32 id, bytes32 secret) external {
53
+ HTLCData memory h = htlcs[id];
54
+
55
+ if (h.expiration == 0) {
56
+ revert LiqualityHTLC__SwapDoesNotExist();
57
+ }
58
+
59
+ if (sha256(abi.encodePacked(secret)) != h.secretHash) {
60
+ revert LiqualityHTLC__WrongSecret();
61
+ }
62
+
63
+ // free some storage for gas refund
64
+ delete htlcs[id];
65
+
66
+ emit Claim(id, secret);
67
+
68
+ // handle Ether claims
69
+ if (h.tokenAddress == address(0x0)) {
70
+ LibTransfer.transferEth(h.recipientAddress, h.amount);
71
+ }
72
+ // handle ERC20 claims
73
+ else {
74
+ IERC20(h.tokenAddress).safeTransfer(h.recipientAddress, h.amount);
75
+ }
76
+ }
77
+
78
+ /// @inheritdoc ILiqualityHTLC
79
+ function refund(bytes32 id) external {
80
+ HTLCData memory h = htlcs[id];
81
+
82
+ if (h.expiration == 0) {
83
+ revert LiqualityHTLC__SwapDoesNotExist();
84
+ }
85
+
86
+ if (block.timestamp <= h.expiration) {
87
+ revert LiqualityHTLC__SwapNotExpired();
88
+ }
89
+
90
+ // free some storage for gas refund
91
+ delete htlcs[id];
92
+
93
+ emit Refund(id);
94
+
95
+ // handle Ether refunds
96
+ if (h.tokenAddress == address(0x0)) {
97
+ LibTransfer.transferEth(h.refundAddress, h.amount);
98
+ }
99
+ // handle ERC20 refunds
100
+ else {
101
+ IERC20(h.tokenAddress).safeTransfer(h.refundAddress, h.amount);
102
+ }
103
+ }
104
+ }
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity 0.8.11;
3
+ import '@openzeppelin/contracts/token/ERC1155/ERC1155.sol';
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity 0.8.11;
3
+ import '@openzeppelin/contracts/token/ERC721/ERC721.sol';
@@ -0,0 +1,12 @@
1
+ import '@openzeppelin/contracts/token/ERC20/ERC20.sol';
2
+
3
+ // SPDX-License-Identifier: MIT
4
+ pragma solidity 0.8.11;
5
+
6
+ contract TestERC20 is ERC20 {
7
+ constructor() ERC20('Test', 'TT') {}
8
+
9
+ function mint(address account, uint256 amount) external {
10
+ _mint(account, amount);
11
+ }
12
+ }