Address Contract Verified
Address
0xA9dE06f306805b4902dD7267f2DD73122078c09e
Balance
0 ETH
Nonce
1
Code Size
12432 bytes
Creator
0x82F4D928...4d44 at tx 0x1ea6ebc1...adc401
Indexed Transactions
0
Contract Bytecode
12432 bytes
0x6080604052600436101561001b575b361561001957600080fd5b005b6000803560e01c80621d35671461246757806306fdde031461238a578063095ea7b3146123635780630f1f9cfc1461231e578063116191b6146122d957806316f0115b146122b0578063180f6cc21461228157806318160ddd14612263578063189a5fdd146121ed5780631a98b2e0146120a557806322282f031461207d57806323b872dd1461204457806325c7e35b14611bc8578063313ce56714611bac5780633390ba941461188e578063395093511461183d5780634437152a146117bf5780634916065814611417578063529dca32146112195780636c87babd146111d45780636fad06f51461118f57806370a082311461115757806385f2aef2146111125780638a53aaac146110cd57806394bf804d14610e9357806395d89b4114610da4578063997f35eb14610d5f578063a457c2d714610cba578063a846ffef14610c75578063a9059cbb14610c43578063b44a272214610bfe578063b7edaaf614610aa3578063b9631114146108d2578063c8e769821461089e578063d7f895de146107b2578063dd62ed3e14610763578063e049f5cb14610539578063f2f4eb26146104f4578063f67bae7e146104b25763facea41e146101de575061000e565b60031960a0368201126104ae576004356001600160401b0381116104aa5761020a90369060040161270a565b91906102146126de565b9061021d6126f4565b926064359461022a612737565b94604051958661023f89848960208501612968565b0393610253601f19958681018a5289612601565b8961025c612761565b92346103e5575b505060018060a01b0380936102828b838b169a338c036103d557612f05565b169788156103c3578a937f0000000000000000000000004f4495243837681061c4743b74b3eedf548d56a516803b156103bf5787858761030882966102e9966102f96040519a8b998a988997631c92115f60e01b8952606060048a015260648901916128a9565b9084878303016024880152612688565b91848303016044850152612688565b03925af180156103b457610398575b5050916103566103779260008051602061301b8339815191529461034a60405194859260208085015260408401916128a9565b03908101835282612601565b60405191829187835260026020840152606060408401526060830190612688565b0390a360014614610386575080f35b6103929060065461298a565b60065580f35b6103a4909492946125bd565b6103b057918638610317565b8680fd5b6040513d84823e3d90fd5b8480fd5b604051638aa3a72f60e01b8152600490fd5b6103e0823383612c2d565b612f05565b6001600160a01b037f0000000000000000000000002d5d7d31f671f86c782533cc367f14109a08271281169190823b156104a65785928a8986948f94610476610457966104668c6040519b8c9a8b998a99630c93e3bb60e01b8b523060048c015260a060248c015260a48b01916128a9565b91888303016044890152612688565b908c868303016064870152612688565b91166084830152039134905af180156103b4571561026357610497906125bd565b6104a2578938610263565b8980fd5b8380fd5b8280fd5b5080fd5b50346104f15760203660031901126104f15760209060ff906040906001600160a01b036104dd6126c8565b168152600984522054166040519015158152f35b80fd5b50346104f157806003193601126104f1576040517f0000000000000000000000007a7e4ef924803b956ca97a415c86cd9f905510986001600160a01b03168152602090f35b50346104f15760803660031901126104f157600435906105576126de565b916105606126f4565b90803384526020946009865260ff604086205416156107515785926105858333612f05565b6001600160a01b037f00000000000000000000000035fa164735182de50811e8e2e824cfb9b6118ac28116949092831685146106f75750507f000000000000000000000000d2f14da508641cd340d1fcfc9cbc2522df23dcda169185604051809263095ea7b360e01b8252818881610601888a600484016129aa565b03925af180156106ec576106bf575b5061271060643581038181116106ab579185879492610633610652979584612997565b0491604051968795869485936336cd320560e11b8552600485016129c5565b03925af191821561069f579161066d575b505b604051908152f35b90508181813d8311610698575b6106848183612601565b81010312610693575138610663565b600080fd5b503d61067a565b604051903d90823e3d90fd5b634e487b7160e01b86526011600452602486fd5b6106de90863d88116106e5575b6106d68183612601565b810190612891565b5038610610565b503d6106cc565b6040513d87823e3d90fd5b929150949261071d948460405180978195829463a9059cbb60e01b8452600484016129aa565b03925af190811561069f5750610734575b50610665565b61074a90833d85116106e5576106d68183612601565b503861072e565b6040516348f5c3ed60e01b8152600490fd5b50346104f15760403660031901126104f15761077d6126c8565b60406107876126de565b9260018060a01b03809316815260016020522091166000526020526020604060002054604051908152f35b50346104f157806003193601126104f1577f0000000000000000000000007a7e4ef924803b956ca97a415c86cd9f905510986001600160a01b038082163303610751576020602491604051928380926370a0823160e01b82523060048301527f00000000000000000000000035fa164735182de50811e8e2e824cfb9b6118ac2165afa92831561069f5792610868575b5061066561086160209361085b6002546006549061298a565b9061286e565b80926129e6565b91506020823d602011610896575b8161088360209383612601565b8101031261069357905190610665610842565b3d9150610876565b50346104f157806003193601126104f1576108ce6108ba612761565b604051918291602083526020830190612688565b0390f35b5060c03660031901126104f1576108e76125ac565b6108ef6126de565b6108f76126f4565b9160643592610904612737565b60a43561091181856128e0565b3410610a91576001600160a01b03948086169433869003610a81575b6109378883612f05565b8685169687156103c35761ffff6109a6928b83610965986109738e6040519b8c9160209e8f9c8d8501612968565b03601f1981018c528b612601565b604051988997889687966312d729bd60e21b8852169b8c600488015230602488015260e0604488015260e4870190612688565b93606486015260848501528960a48501521660c4830152039134907f00000000000000000000000027428dd2d3dd32a4d7f7c497eaaa23130d894911165af18015610a7657610a38575b5060008051602061301b833981519152916103776001926040519083820152828152610a1b816125e6565b604051938493898552840152606060408401526060830190612688565b8281813d8311610a6f575b610a4d8183612601565b810103126103b057516001600160401b03811603610a6b57386109f0565b8580fd5b503d610a43565b6040513d89823e3d90fd5b610a8c883384612c2d565b61092d565b6040516306807deb60e41b8152600490fd5b50346104f1576003199060c0368301126104f157610abf6125ac565b90610ac86126de565b92610ad16126f4565b90608435928315158094036106935760a435906001600160401b0382116104f1575092610b3660409593610b7b93610b1061ffff97369060040161270a565b939092610b288a519b8c926064359160208501612968565b03601f1981018b528a612601565b610b678851998a98899863040a7bb160e41b8a5216600489015230602489015260a0604489015260a4880190612688565b9360648701528584030160848601526128a9565b03817f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6756001600160a01b03165afa8015610bf257602091600091610bc25750604051908152f35b610be4915060403d604011610beb575b610bdc8183612601565b8101906128ca565b5038610663565b503d610bd2565b6040513d6000823e3d90fd5b50346104f157806003193601126104f1576040517f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b03168152602090f35b50346104f15760403660031901126104f157610c6a610c606126c8565b6024359033612cc5565b602060405160018152f35b50346104f157806003193601126104f1576040517f00000000000000000000000035fa164735182de50811e8e2e824cfb9b6118ac26001600160a01b03168152602090f35b50346104f15760403660031901126104f157610cd46126c8565b60406024359233815260016020522060018060a01b03821660005260205260406000205491808310610d0c57610c6a92039033612a77565b60405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608490fd5b50346104f157806003193601126104f1576040517f0000000000000000000000002d5d7d31f671f86c782533cc367f14109a0827126001600160a01b03168152602090f35b50346104f157806003193601126104f15760405160045460018082169180821c916000918415610e89575b6020948585108114610e75578487528693929186908215610e55575050600114610e15575b50610e0192500383612601565b6108ce604051928284938452830190612688565b849150600460005281600020906000915b858310610e3d575050610e01935082010185610df4565b80548389018501528794508693909201918101610e26565b60ff191685820152610e0195151560051b8501019250879150610df49050565b634e487b7160e01b84526022600452602484fd5b92607f1692610dcf565b5060403660031901126104f157610ea86126de565b6040516370a0823160e01b8082523060048301526020936001600160a01b037f00000000000000000000000035fa164735182de50811e8e2e824cfb9b6118ac28116949192918685602481895afa9485156110c25787918791869761108d575b5083161461101b5760405163f340fa0160e01b81527f000000000000000000000000f5404a7d29319c8aeaedbe22df895fac1d48191483166004820152918290602490829034907f000000000000000000000000308861a430be4cce5502d0a12724771fc6daf216165af1801561101057908691610fe7575b50905b60246040518096819382523060048301525afa90811561069f5790610fb8575b610fae925061286e565b61066581336129e6565b508282813d8311610fe0575b610fce8183612601565b8101031261069357610fae9151610fa4565b503d610fc4565b813d8311611009575b610ffa8183612601565b81010312610693578438610f81565b503d610ff0565b6040513d85823e3d90fd5b50503461107b576040516323b872dd60e01b8152858180611043600435303360048501612968565b038186895af18015611010579086929161105e575b50610f84565b61107490833d85116106e5576106d68183612601565b5038611058565b6040516350d012f960e11b8152600490fd5b92839197508092503d83116110bb575b6110a78183612601565b810103126106935785828892519690610f08565b503d61109d565b6040513d86823e3d90fd5b50346104f157806003193601126104f1576040517f000000000000000000000000d2f14da508641cd340d1fcfc9cbc2522df23dcda6001600160a01b03168152602090f35b50346104f157806003193601126104f1576040517f000000000000000000000000f5404a7d29319c8aeaedbe22df895fac1d4819146001600160a01b03168152602090f35b50346104f15760203660031901126104f1576020906040906001600160a01b0361117f6126c8565b1681528083522054604051908152f35b50346104f157806003193601126104f1576040517f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6756001600160a01b03168152602090f35b50346104f157806003193601126104f1576040517f000000000000000000000000308861a430be4cce5502d0a12724771fc6daf2166001600160a01b03168152602090f35b5060a03660031901126104f1576001600160401b036004358181116104aa5761124690369060040161266a565b602491602435928184116103bf57366023850112156103bf57836004013593828511611403578460051b916024602080976040519061128783880183612601565b81520193830101933685116113ff5760248301935b8585106113d9578888886064359061ffff8216809203610693576084358085526007845260ff6040862054166113c75784526007835260408420805460ff191660011790556001600160a01b03927f00000000000000000000000027428dd2d3dd32a4d7f7c497eaaa23130d894911841633036113b557836044351630036113a3576001816113886113468583600080516020612ffb833981519152968a98518301019101612845565b989196169561135589886129e6565b6040519784890152838852611369886125e6565b6040519485948a86528501526060604085015216956060830190612688565b0390a360014614611397575080f35b6103929060065461286e565b6040516309aa97f760e31b8152600490fd5b6040516381316de160e01b8152600490fd5b60405163bed444bb60e01b8152600490fd5b84358281116104a25788916113f4839286369189010161266a565b81520194019361129c565b8780fd5b634e487b7160e01b86526041600452602486fd5b50346104f1576003196080368201126104ae576024906001600160401b0382358181116103bf5761144c90369060040161270a565b9190926044358281116103b05761146790369060040161270a565b9590926064359081116113ff5761148290369060040161270a565b91909661149036848a612624565b9487865196888c60808760209b8c809601206114ea60018060a01b039c6114d9604051998a9889978897635f6970c360e01b895260043560048a015288015260848701916128a9565b908482030160448501528a8a6128a9565b90606483015203918a7f0000000000000000000000004f4495243837681061c4743b74b3eedf548d56a5165af19081156117b4578b91611797575b501561178557611536913691612624565b8051899291602a9182811480159190611763575b50801561172a575b6116e2579190600280935b8285106115f657505050505082309116036115e4578560609181010312610a6b57600080516020612ffb8339815191529161138860029261159d8861274d565b6113698260406115ae878d0161274d565b9b01359a16976115be8b8a6129e6565b6115d66040519a8b92888085015260408401916128a9565b03601f1981018a5289612601565b60405163063ce8cd60e31b8152600490fd5b909192939481518610156117155788868301015160f81c60618110158061170a575b1561167a5760ff90811660561901908111611665575b6029908782039182116116525760ff1690841b1b881617946001019392919061155d565b634e487b7160e01b8f526011600452868ffd5b85634e487b7160e01b60005260116004526000fd5b6041811015806116ff575b156116b05760ff908116603619019081111561162e5785634e487b7160e01b60005260116004526000fd5b6030811015806116f4575b156116e257602f190160ff81111561162e5785634e487b7160e01b60005260116004526000fd5b604051636fa478cf60e11b8152600490fd5b5060398111156116bb565b506046811115611685565b506066811115611618565b84634e487b7160e01b60005260326004526000fd5b508051600110156117505760218101516001600160f81b031916600f60fb1b1415611552565b634e487b7160e01b8b526032600452828bfd5b90501561175057808701516001600160f81b031916600360fc1b14153861154a565b604051631403112d60e21b8152600490fd5b6117ae9150873d89116106e5576106d68183612601565b38611525565b6040513d8d823e3d90fd5b50346104f15760203660031901126104f1576117d96126c8565b600854906001600160a01b039081831661182b57817f0000000000000000000000007a7e4ef924803b956ca97a415c86cd9f90551098163303610751576001600160a01b031990921691161760085580f35b604051636532af8360e11b8152600490fd5b50346104f15760403660031901126104f157610c6a90604061185d6126c8565b9133815260016020522060018060a01b03821660005260205261188760243560406000205461298a565b9033612a77565b50346104f15760a03660031901126104f1576118a86126c8565b90602435906118b56126f4565b926001600160a01b03606435818116929083810361069357928282163303611b9c575b15611b94575b604051635006ca9360e11b81526020957f0000000000000000000000007a7e4ef924803b956ca97a415c86cd9f9055109891848316908881600481855afa908115611b89578891611b5c575b508060021b808410611b4a578015611b345761194c6119579185048093612997565b60011b809587612cc5565b813b156113ff57879160a4839260405194859384926377b1a79960e01b84528b8d16600485015260248401526001604484015261016d6064840152606460848401525af18015610a7657611b20575b509186976119b96119c29893869561286e565b97888093612f05565b7f00000000000000000000000035fa164735182de50811e8e2e824cfb9b6118ac2841694168414611afb5750507f000000000000000000000000d2f14da508641cd340d1fcfc9cbc2522df23dcda169085604051809263095ea7b360e01b8252818781611a338b89600484016129aa565b03925af180156110c257611ade575b506127106084358103818111611aca5791611a83949391611a64889488612997565b04846040518097819582946336cd320560e11b84528b600485016129c5565b03925af190811561069f5750908391611aa1575b5050604051908152f35b813d8311611ac3575b611ab48183612601565b81010312610693578138611a97565b503d611aaa565b634e487b7160e01b85526011600452602485fd5b611af490863d88116106e5576106d68183612601565b5038611a42565b915091849361071d9560405180978195829463a9059cbb60e01b8452600484016129aa565b611b2a87916125bd565b610a6b57386119a6565b634e487b7160e01b600052601260045260246000fd5b604051633626d99d60e11b8152600490fd5b90508881813d8311611b82575b611b738183612601565b8101031261069357513861192a565b503d611b69565b6040513d8a823e3d90fd5b3392506118de565b611ba7863384612c2d565b6118d8565b50346104f157806003193601126104f157602060405160128152f35b5060e03660031901126104f157611bdd6125ac565b611be56126de565b90611bee6126f4565b611bf6612737565b60a4356001600160a01b0381169190829003610a6b576001600160401b039360c4358581116113ff57611c2d90369060040161270a565b93909281611f6157886040611c98611c55611c638c84519283918d6064359160208501612968565b03601f198101835282612601565b611cb18351948593849363040a7bb160e41b855261ffff8b16600486015230602486015260a0604486015260a4850190612688565b9060648401526003198382030160848401528a8a6128a9565b03817f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6756001600160a01b03165afa908115611f56578a91611f36575b503410611f25575b6001600160a01b0388163303611f13575b611d1260643589612f05565b6001600160a01b038616156103c357604051963060601b8060208a015260348901526028885287606081011090606089011117611eff57908893929160608801604052611d8288611d6a6064358a8d60808501612968565b03607f19810160608b0152605f190160608a01612601565b7f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6756001600160a01b03163b156103bf57611e009561ffff94611e2693604051988997889762c5803160e81b8952169b8c600489015260c060248901526060611ded60c48a0183612688565b8981036003190160448b01529101612688565b6001600160a01b03909416606487015260848601528483036003190160a48601526128a9565b0381347f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6756001600160a01b03165af180156106ec57611eda575b50611ebe60008051602061301b8339815191529160405193602085015260208452611e8a846125e6565b60405191829160643583528760208401526060604084015260018060a01b03169560018060a01b0316946060830190612688565b0390a360014614611ecc5780f35b61039260643560065461298a565b60008051602061301b8339815191529194611ef7611ebe926125bd565b949150611e60565b634e487b7160e01b89526041600452602489fd5b611f20606435338a612c2d565b611d06565b60405162976f7560e21b8152600490fd5b611f4f915060403d604011610beb57610bdc8183612601565b5038611ced565b6040513d8c823e3d90fd5b611fcf6040611fb5611c55611f838c84519283918d6064359160208501612968565b825163040a7bb160e41b815261ffff8816600482015230602482015260a06044820152938492839260a4840190612688565b600160648401528281036003190160848401528a8a6128a9565b03817f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6756001600160a01b03165afa908115611f56578a91612024575b50341015611cf55760405162976f7560e21b8152600490fd5b61203d915060403d604011610beb57610bdc8183612601565b503861200b565b50346104f15760603660031901126104f157610c6a6120616126c8565b6120696126de565b60443591612078833383612c2d565b612cc5565b50346104f15760403660031901126104f157602061066561209c6125ac565b602435906128e0565b50346104f15760031960c0368201126104ae576001600160401b036024358181116104a6576120d890369060040161270a565b604435838111610a6b576120f090369060040161270a565b6064358581116113ff5761210890369060040161270a565b6084359687116121e95761216c97610b6761217c9561213a61213060209b369060040161270a565b9690953691612624565b8a8151910120956040519b8c9a8b9a631876eed960e01b8c5260043560048d015260c060248d015260c48c01916128a9565b91848a84030160448b01526128a9565b60a48035908301520381857f0000000000000000000000004f4495243837681061c4743b74b3eedf548d56a56001600160a01b03165af19081156103b45782916121ca575b50156117855780f35b6121e3915060203d6020116106e5576106d68183612601565b386121c1565b8880fd5b50346104f15760403660031901126104f1576122076126c8565b602435908115158092036104aa576001600160a01b03907f000000000000000000000000f5404a7d29319c8aeaedbe22df895fac1d48191482163303610751571682526009602052604082209060ff8019835416911617905580f35b50346104f157806003193601126104f1576020600254604051908152f35b50346104f15760203660031901126104f15760ff60406020926004358152600784522054166040519015158152f35b50346104f157806003193601126104f1576008546040516001600160a01b039091168152602090f35b50346104f157806003193601126104f1576040517f0000000000000000000000004f4495243837681061c4743b74b3eedf548d56a56001600160a01b03168152602090f35b50346104f157806003193601126104f1576040517f00000000000000000000000027428dd2d3dd32a4d7f7c497eaaa23130d8949116001600160a01b03168152602090f35b50346104f15760403660031901126104f157610c6a6123806126c8565b6024359033612a77565b50346104f157806003193601126104f15760405190806003549160018360011c926001851694851561245d575b6020958686108114612449578588528794939291879082156124275750506001146123eb575b5050610e0192500383612601565b90859250600382528282205b85831061240f575050610e01935082010138806123dd565b805483890185015287945086939092019181016123f7565b9250935050610e0194915060ff191682840152151560051b82010138806123dd565b634e487b7160e01b83526022600452602483fd5b93607f16936123b7565b50346104f15760803660031901126104f1576124816125ac565b6001600160401b03906024358281116104a6576124a290369060040161266a565b91604435818116036104a6576064359081116104a6576124c690369060040161266a565b6001600160a01b0392337f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd67585160361259a5780516020918201516001600160601b031991828216919060148110612585575b5050905060601c300361257357848161138861254c8583600080516020612ffb833981519152968a98518301019101612845565b989196169561255b89886129e6565b61ffff604051981684890152838852611369886125e6565b6040516347cec4bb60e11b8152600490fd5b8391925060140360031b1b1616803880612518565b60405163a667bffb60e01b8152600490fd5b6004359061ffff8216820361069357565b6001600160401b0381116125d057604052565b634e487b7160e01b600052604160045260246000fd5b604081019081106001600160401b038211176125d057604052565b601f909101601f19168101906001600160401b038211908210176125d057604052565b9192916001600160401b0382116125d0576040519161264d601f8201601f191660200184612601565b829481845281830111610693578281602093846000960137010152565b9080601f830112156106935781602061268593359101612624565b90565b919082519283825260005b8481106126b4575050826000602080949584010152601f8019910116010190565b602081830181015184830182015201612693565b600435906001600160a01b038216820361069357565b602435906001600160a01b038216820361069357565b604435906001600160a01b038216820361069357565b9181601f84011215610693578235916001600160401b038311610693576020838186019501011161069357565b608435906001600160a01b038216820361069357565b35906001600160a01b038216820361069357565b6040519060006005549060018260011c9060018416938415612827575b602094858410811461281357838852879493929181156127f357506001146127b1575b50506127af92500383612601565b565b90939150600560005281600020936000915b8183106127db5750506127af935082010138806127a1565b855488840185015294850194879450918301916127c3565b9150506127af94925060ff191682840152151560051b82010138806127a1565b634e487b7160e01b85526022600452602485fd5b91607f169161277e565b51906001600160a01b038216820361069357565b908160609103126106935761285981612831565b91604061286860208401612831565b92015190565b9190820391821161287b57565b634e487b7160e01b600052601160045260246000fd5b90816020910312610693575180151581036106935790565b908060209392818452848401376000828201840152601f01601f1916010190565b9190826040910312610693576020825192015190565b6040805163c23ee3c360e01b815261ffff909216600483015260006024830152604482019290925290816064817f00000000000000000000000027428dd2d3dd32a4d7f7c497eaaa23130d8949116001600160a01b03165afa908115610bf25760009161294b575090565b612964915060403d604011610beb57610bdc8183612601565b5090565b6001600160a01b03918216815291166020820152604081019190915260600190565b9190820180921161287b57565b8181029291811591840414171561287b57565b6001600160a01b039091168152602081019190915260400190565b90815260208101919091526001600160a01b03909116604082015260600190565b6001600160a01b0316908115612a325760008051602061303b833981519152602082612a1660009460025461298a565b60025584845283825260408420818154019055604051908152a3565b60405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606490fd5b6001600160a01b039182169291907f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe888216841480612c21575b612bab575b16908115612b5a578215612b0a5760207f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925918360005260018252604060002085600052825280604060002055604051908152a3565b60405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608490fd5b60405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608490fd5b818116827f0000000000000000000000007a7e4ef924803b956ca97a415c86cd9f90551098168114159081612bf4575b5015612ab5575b6040516352249a3160e01b8152600490fd5b9050827f000000000000000000000000f5404a7d29319c8aeaedbe22df895fac1d48191416141538612bdb565b50816008541615612ab0565b9060018060a01b0380831660005260016020526040600020908216600052602052604060002054926000198403612c65575b50505050565b808410612c8057612c77930391612a77565b38808080612c5f565b60405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606490fd5b9160018060a01b0380808060085416941694848614612e9c575b16928314612e37575b508115612de4578215612d9357600082815280602052604081205491808310612d3f576040828260008051602061303b833981519152958760209652828652038282205586815220818154019055604051908152a3565b60405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608490fd5b60405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608490fd5b60405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608490fd5b807f0000000000000000000000007a7e4ef924803b956ca97a415c86cd9f90551098168414159081612e6f575b50612be25738612ce8565b90507f000000000000000000000000f5404a7d29319c8aeaedbe22df895fac1d4819141683141538612e64565b908116827f0000000000000000000000007a7e4ef924803b956ca97a415c86cd9f90551098168114159081612ed8575b50612be2578190612cdf565b9050827f000000000000000000000000f5404a7d29319c8aeaedbe22df895fac1d48191416141538612ecc565b6001600160a01b03168015612fab57600091818352826020526040832054818110612f5b578160008051602061303b833981519152926020928587528684520360408620558060025403600255604051908152a3565b60405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608490fd5b60405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608490fdfe51fa6b13f6daaeb242e226abef2a9ff882bc8f2559829aa56db5baddc7a494b4910681e1ddfdfd81641e12c78e640eb5928c78b55a791eeec551d2c3bd1581e2ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220966e6e94a76058f4554d61af556fa9269758d1be1180653f2fc5b3598155422064736f6c63430008190033
Verified Source Code Full Match
Compiler: v0.8.25+commit.b61c2a91
EVM: paris
Optimization: Yes (1 runs)
ETHx.sol 497 lines
// SPDX-License-Identifier: Unlicensed
pragma solidity 0.8.25;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {ISwapHandler} from "./interfaces/ISwapHandler.sol";
import {ICore} from "./interfaces/ICore.sol";
import {Bridge} from "./base/Bridge.sol";
/// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| \\\
/**
* @title Interface for the eETH Zapper Functionality
* @dev Defines functions for depositing ETH and receiving eETH, and withdrawing eETH to get back ETH.
*/
interface IEETHZapper {
/**
* @notice Deposits ETH and mints an equivalent amount of eETH tokens.
* @dev Allows a user to deposit ETH and receive eETH in return, with an option to specify a referrer.
* @param _referrer The address that referred the user, potentially earning rewards.
* @return The amount of eETH tokens minted to the caller's account.
*/
function deposit(address _referrer)
external
payable
returns (uint256);
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Converts eETH shares into eETH amount.
* @dev Calculates the value of the provided eETH shares.
* @param _shares The amount of eETH shares.
* @return The value of the provided eETH shares.
*/
function amountForShare(uint256 _shares)
external
view
returns (uint256);
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
}
/// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| \\\
/*
* @title ETHx Contract
*
* @notice Represents the ETHx token, an ERC20 token with bridging and burning capabilities.
*
* Co-Founders:
* - Simran Dhillon: [email protected]
* - Hardev Dhillon: [email protected]
* - Dayana Plaz: [email protected]
*
* Official Links:
* - Twitter: https://twitter.com/alixa_io
* - Telegram: https://t.me/alixa_io
* - Website: https://alixa.io
*
* Disclaimer:
* This contract aligns with the principles of the Fair Crypto Foundation, promoting self-custody, transparency, consensus-based
* trust, and permissionless value exchange. There are no administrative access keys, underscoring our commitment to decentralisation.
* Engaging with this contract involves technical and legal risks. Users must conduct their own due diligence and ensure compliance
* with local laws and regulations. The software is provided "AS-IS," without warranties, and the co-founders and developers disclaim
* all liability for any vulnerabilities, exploits, errors, or breaches that may occur. By using this contract, users accept all associated
* risks and this disclaimer. The co-founders, developers, or related parties will not bear liability for any consequences of non-compliance.
*
* Redistribution and Use:
* Redistribution, modification, or repurposing of this contract, in whole or in part, is strictly prohibited without express written
* approval from all co-founders. Approval requests must be sent to the official email addresses of the co-founders, ensuring responses
* are received directly from these addresses. Proposals for redistribution, modification, or repurposing must include a detailed explanation
* of the intended changes or uses and the reasons behind them. The co-founders reserve the right to request additional information or
* clarification as necessary. Approval is at the sole discretion of the co-founders and may be subject to conditions to uphold the
* project’s integrity and the values of the Fair Crypto Foundation. Failure to obtain express written approval prior to any redistribution,
* modification, or repurposing will result in a breach of these terms and immediate legal action.
*
* Copyright and License:
* Copyright © 2024 Alixa (Simran Dhillon, Hardev Dhillon, Dayana Plaz). All rights reserved.
* This software is provided 'as is' and may be used by the recipient. No permission is granted for redistribution,
* modification, or repurposing of this contract. Any use beyond the scope defined herein may be subject to legal action.
*/
contract ETHx is Bridge {
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/// ---------------------------------------------------------- VARIABLES ------------------------------------------------------------ \\\
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Address representing the pool, set once and immutable thereafter.
* @dev This variable holds the address of the pool.
*/
address public pool;
/**
* @notice Address representing the team, set at deployment and immutable.
* @dev This variable holds the address of the team.
*/
address public immutable team;
/**
* @notice Address of the core contract, set at deployment and immutable.
* @dev This variable holds the address of the core contract.
*/
address public immutable core;
/**
* @notice Address of the Nonfungible Position Manager, used for managing liquidity positions.
* @dev This variable holds the address of the Nonfungible Position Manager.
*/
address public immutable nonfungiblePositionManager;
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/// ----------------------------------------------------------- MAPPING ------------------------------------------------------------- \\\
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Mapping of privileged sellers.
* @dev This mapping holds the addresses of privileged sellers, typically future protocols.
*/
mapping (address seller => bool allowed) public privilegedSellers;
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/// ---------------------------------------------------------- INTERFACES ----------------------------------------------------------- \\\
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Interface for interacting with the eETH token, providing ERC20 functionalities.
* @dev This variable holds the interface for interacting with the eETH token.
*/
IERC20 public immutable EETH;
/**
* @notice Interface for interacting with the eETH Zapper, facilitating ETH to eETH conversions and vice versa.
* @dev This variable holds the interface for interacting with the eETH Zapper.
*/
IEETHZapper public immutable eethZapper;
/**
* @notice Interface for interacting with the SwapHandler contract, facilitating eETH to ETH swaps.
* @dev This variable holds the interface for interacting with the SwapHandler contract.
*/
ISwapHandler public immutable swapHandler;
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/// ------------------------------------------------------------ ERRORS ------------------------------------------------------------- \\\
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Error for unauthorised callers.
* @dev Triggered when a function is called by an unauthorised address.
*/
error InvalidCaller();
/**
* @notice Error for unauthorised pool interactions.
* @dev Triggered when an unauthorised address attempts to interact with the pool.
*/
error PoolRestriction();
/**
* @notice Error for failed ETH transfers.
* @dev Triggered when an ETH transfer fails.
*/
error ETHTransferFailed();
/**
* @notice Error for attempting to reset an already set contract address.
* @dev Triggered when there's an attempt to reset an already set contract address.
*/
error ContractAlreadySet();
/**
* @notice Error for unsupported single asset operations.
* @dev Triggered when an operation is attempted with a multiple asset.
*/
error SingleAssetSupport();
/**
* @notice Error for when the bond count is below the minimum required.
* @dev Triggered when an operation involves a bond count less than the minimum allowed.
*/
error LessThenMinBondCount();
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/// ---------------------------------------------------------- CONSTRUCTOR ---------------------------------------------------------- \\\
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Initialises the ETHx contract.
* @dev Sets up token with bridging and liquidity provider functionalities.
* @param _EETH eETH token address.
* @param _eethZapper eETH Zapper address.
* @param _swapHandler SwapHandler contract address.
* @param _team Team address.
* @param _core Core contract address.
* @param _gateway Bridge token gateway address.
* @param _gasService Bridge token gas service address.
* @param _endpoint Bridge token endpoint address.
* @param _wormholeRelayer Bridge token wormhole relayer address.
* @param _nonfungiblePositionManager Non-fungible position manager address.
*/
constructor(
address _EETH,
address _eethZapper,
address _swapHandler,
address _team,
address _core,
address _gateway,
address _gasService,
address _endpoint,
address _wormholeRelayer,
address _nonfungiblePositionManager
)
payable
Bridge(
"ETHx",
"ETHx",
_gateway,
_gasService,
_endpoint,
_wormholeRelayer
)
{
EETH = IERC20(_EETH);
eethZapper = IEETHZapper(_eethZapper);
swapHandler = ISwapHandler(_swapHandler);
team = _team;
core = _core;
privilegedSellers[_team] = true;
privilegedSellers[_core] = true;
nonfungiblePositionManager = _nonfungiblePositionManager;
}
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/// ----------------------------------------------------- EXTERNAL FUNCTIONS -------------------------------------------------------- \\\
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Enables the contract to receive ETH directly.
* @dev Allows the contract to receive ETH.
*/
receive() external payable{}
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Transfers eETH and mints equivalent ETHx tokens to the user.
* @dev Allows users to deposit eETH or ETH and receive ETHx.
* @param _amount The amount of eETH to transfer.
* @param _token The token address to transfer.
* @return The amount of ETHx minted.
*/
function mint(uint256 _amount, address _token)
external
payable
returns (uint256)
{
uint256 initialBalance = EETH.balanceOf(address(this));
if (_token != address(EETH)) {
_amount = eethZapper.deposit{value: msg.value}(team);
} else {
if (msg.value > 0) {
revert SingleAssetSupport();
}
EETH.transferFrom(
msg.sender,
address(this),
_amount
);
}
_amount = EETH.balanceOf(address(this)) - initialBalance;
_mint(msg.sender, _amount);
return _amount;
}
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Burns ETHx tokens and exchanges for another token.
* @dev Burns ETHx and returns equivalent value in specified token.
* @param _user User from whom ETHx will be burned.
* @param _amount Amount of ETHx to burn.
* @param _desiredOutToken Desired output token (eETH or ETH).
* @param _recipient Recipient of output tokens.
* @param _slippage Allowed slippage for swap (basis points).
* @return Amount of output token sent to recipient.
*/
function burn(
address _user,
uint256 _amount,
address _desiredOutToken,
address _recipient,
uint256 _slippage
) external returns (uint256) {
if (msg.sender != _user)
_spendAllowance(
_user,
msg.sender,
_amount
);
if (_recipient == address(0)) {
_recipient = msg.sender;
}
uint256 baseCost = ICore(core).BASE_COST();
if (_amount < baseCost << 2) {
revert LessThenMinBondCount();
}
uint256 bondCount = _amount / (baseCost << 2);
uint256 amountToPurchase = baseCost * bondCount;
amountToPurchase = amountToPurchase << 1;
_transfer(_user, core, amountToPurchase);
ICore(core).purchaseETHBond(
_recipient,
bondCount,
ICore.Token.ethx,
365,
100
);
_amount = _amount - amountToPurchase;
_burn(_user, _amount);
if (_desiredOutToken != address(EETH)) {
EETH.approve(address(swapHandler), _amount);
swapHandler.swap(_amount, (_amount * (10000 - _slippage)) / 10000, _recipient);
} else {
EETH.transfer(
_recipient,
_amount
);
}
return _amount;
}
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Burns ETHx tokens for privileged sellers.
* @dev Restricted to future protocol addresses.
* @param _amount Amount of ETHx to burn.
* @param _desiredOutToken Desired output token.
* @param _recipient Recipient of converted tokens.
* @param _slippage Allowed slippage for swap (basis points).
* @return Amount of tokens returned to recipient.
*/
function burnPrivilege(
uint256 _amount,
address _desiredOutToken,
address _recipient,
uint256 _slippage
) external returns (uint256) {
if (!privilegedSellers[msg.sender])
revert InvalidCaller();
_burn(msg.sender, _amount);
if (_desiredOutToken != address(EETH)) {
EETH.approve(address(swapHandler), _amount);
_amount = swapHandler.swap(_amount, (_amount * (10000 - _slippage)) / 10000, _recipient);
} else {
EETH.transfer(
_recipient,
_amount
);
}
return _amount;
}
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Utilises positive rebasing to mint excess eETH as ETHx.
* @dev Mints excess eETH as ETHx to Core contract.
* @return excessEETH_ Amount of excess eETH minted as ETHx.
*/
function utilisePositiveRebasing() external returns (uint256 excessEETH_) {
if (msg.sender != core) {
revert InvalidCaller();
}
uint256 eethBalance = EETH.balanceOf(address(this));
uint256 ETHxSupply = totalSupply() + totalBridgedAmount;
excessEETH_ = eethBalance - ETHxSupply;
_mint(core, excessEETH_);
}
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Sets the pool's address.
* @dev Can only be set once by the liquidity provider.
* @param _pool Pool address to set.
*/
function setPool(address _pool) external {
if (pool != address(0)) {
revert ContractAlreadySet();
}
if (msg.sender != core) {
revert InvalidCaller();
}
pool = _pool;
}
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Adds or removes a privileged seller.
* @dev Allows team to add or remove a privileged seller.
* @param _futureProtocol Address to add or remove as privileged seller.
* @param enable True to add, false to remove.
*/
function setPrivilegedSeller(address _futureProtocol, bool enable) external {
if (msg.sender != team) {
revert InvalidCaller();
}
privilegedSellers[_futureProtocol] = enable;
}
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/// ----------------------------------------------------- INTERNAL FUNCTIONS -------------------------------------------------------- \\\
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Overrides internal transfer function with restrictions.
* @dev Adds pool-related transfer restrictions.
* @param _sender Sender address.
* @param _recipient Recipient address.
* @param _amount Transfer amount.
*/
function _transfer(
address _sender,
address _recipient,
uint256 _amount
)
internal
virtual
override
{
address _pool = pool;
if (_recipient == _pool)
if (_sender != core && _sender != team) {
revert PoolRestriction();
}
if (_sender == _pool)
if (_recipient != core && _recipient != team) {
revert PoolRestriction();
}
super._transfer(
_sender,
_recipient,
_amount
);
}
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Overrides internal approve function with restrictions.
* @dev Adds restrictions for nonfungible position manager approvals.
* @param _owner Token owner address.
* @param _spender Address to approve.
* @param _amount Approval amount.
*/
function _approve(
address _owner,
address _spender,
uint256 _amount
)
internal
virtual
override
{
if (_spender == nonfungiblePositionManager && pool == address(0))
if (_owner != core && _owner != team) {
revert PoolRestriction();
}
super._approve(
_owner,
_spender,
_amount
);
}
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Safely sends ETH.
* @dev Uses low-level call to send ETH.
* @param _to Recipient address.
* @param _amount Amount of ETH to send.
*/
function _sendViaCall(address payable _to, uint256 _amount) internal {
(bool sent, ) = _to.call{value: _amount} ("");
if (!sent) {
revert ETHTransferFailed();
}
}
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
}
Bridge.sol 551 lines
// SPDX-License-Identifier: Unlicensed
pragma solidity 0.8.25;
import {StringToAddress, AddressToString} from "@axelar-network/axelar-gmp-sdk-solidity/contracts/utils/AddressString.sol";
import {IAxelarGasService} from "@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarGasService.sol";
import {AxelarExecutable} from "@axelar-network/axelar-gmp-sdk-solidity/contracts/executable/AxelarExecutable.sol";
import {ILayerZeroEndpoint} from "@layerzerolabs/lz-evm-sdk-v1-0.7/contracts/interfaces/ILayerZeroEndpoint.sol";
import {IWormholeRelayer} from "../interfaces/IWormholeRelayer.sol";
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {IBridgeToken} from "../interfaces/IBridgeToken.sol";
/// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| \\\
/*
* @title Bridge Contract
*
* @notice This contract facilitates cross-chain token bridging, utilising LayerZero, Axelar, and Wormhole protocols for interoperable token transfers.
*
* Co-Founders:
* - Simran Dhillon: [email protected]
* - Hardev Dhillon: [email protected]
* - Dayana Plaz: [email protected]
*
* Official Links:
* - Twitter: https://twitter.com/alixa_io
* - Telegram: https://t.me/alixa_io
* - Website: https://alixa.io
*
* Disclaimer:
* This contract aligns with the principles of the Fair Crypto Foundation, promoting self-custody, transparency, consensus-based
* trust, and permissionless value exchange. There are no administrative access keys, underscoring our commitment to decentralisation.
* Engaging with this contract involves technical and legal risks. Users must conduct their own due diligence and ensure compliance
* with local laws and regulations. The software is provided "AS-IS," without warranties, and the co-founders and developers disclaim
* all liability for any vulnerabilities, exploits, errors, or breaches that may occur. By using this contract, users accept all associated
* risks and this disclaimer. The co-founders, developers, or related parties will not bear liability for any consequences of non-compliance.
*
* Redistribution and Use:
* Redistribution, modification, or repurposing of this contract, in whole or in part, is strictly prohibited without express written
* approval from all co-founders. Approval requests must be sent to the official email addresses of the co-founders, ensuring responses
* are received directly from these addresses. Proposals for redistribution, modification, or repurposing must include a detailed explanation
* of the intended changes or uses and the reasons behind them. The co-founders reserve the right to request additional information or
* clarification as necessary. Approval is at the sole discretion of the co-founders and may be subject to conditions to uphold the
* project’s integrity and the values of the Fair Crypto Foundation. Failure to obtain express written approval prior to any redistribution,
* modification, or repurposing will result in a breach of these terms and immediate legal action.
*
* Copyright and License:
* Copyright © 2024 Alixa (Simran Dhillon, Hardev Dhillon, Dayana Plaz). All rights reserved.
* This software is provided 'as is' and may be used by the recipient. No permission is granted for redistribution,
* modification, or repurposing of this contract. Any use beyond the scope defined herein may be subject to legal action.
*/
abstract contract Bridge is
AxelarExecutable,
IBridgeToken,
ERC20
{
/// -------------------------------------------------------------------------------------------------------------------------------- \\\
/// ----------------------------------------------------------- LIBRARIES ---------------------------------------------------------- \\\
/// -------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Converts string to address format.
* @dev Attaches StringToAddress library functions to string type for address conversions.
*/
using StringToAddress for string;
/**
* @notice Converts address to string format.
* @dev Attaches AddressToString library functions to address type for string conversions.
*/
using AddressToString for address;
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/// ---------------------------------------------------------- VARIABLES ------------------------------------------------------------ \\\
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Address of this token in string format.
* @dev Used for identifying this contract's address across various bridging protocols.
*/
string public addressThis;
/**
* @notice Total amount of tokens bridged across all chains.
* @dev Tracks the cumulative number of tokens bridged across all supported chains.
*/
uint256 totalBridgedAmount;
/**
* @notice Interface for LayerZero endpoint.
* @dev Used for interacting with LayerZero for cross-chain token transfers.
*/
ILayerZeroEndpoint public immutable ENDPOINT;
/**
* @notice Interface for Axelar gas service.
* @dev Used for estimating and paying gas fees for Axelar's cross-chain operations.
*/
IAxelarGasService public immutable GAS_SERVICE;
/**
* @notice Interface for Wormhole relayer.
* @dev Facilitates cross-chain transfers using the Wormhole protocol.
*/
IWormholeRelayer public immutable WORMHOLE_RELAYER;
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/// ----------------------------------------------------------- MAPPING ------------------------------------------------------------- \\\
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Mapping to prevent replay attacks.
* @dev Stores processed delivery hashes to prevent duplicate processing of messages.
*/
mapping (bytes32 => bool) public seenDeliveryVaaHashes;
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/// ----------------------------------------------------------- MODIFIER ------------------------------------------------------------ \\\
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Ensures that a Wormhole message is processed only once.
* @dev Checks if the provided _deliveryHash has been seen before to prevent replay attacks.
* @param _deliveryHash Unique hash representing the delivery message from the Wormhole relayer.
*/
modifier replayProtect(bytes32 _deliveryHash) {
if (seenDeliveryVaaHashes[_deliveryHash]) {
revert WormholeMessageAlreadyProcessed();
}
seenDeliveryVaaHashes[_deliveryHash] = true;
_;
}
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/// ---------------------------------------------------------- CONSTRUCTOR ---------------------------------------------------------- \\\
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Initialises a new Bridge contract instance.
* @dev Sets up essential external contracts and services for bridge operations.
* @param _name The name of the bridge token.
* @param _symbol The symbol of the bridge token.
* @param _gateway The address of the Axelar gateway contract.
* @param _gasService The address of the Axelar gas service contract.
* @param _endpoint The address of the LayerZero endpoint contract.
* @param _wormholeRelayer The address of the Wormhole relayer contract.
*/
constructor(
string memory _name,
string memory _symbol,
address _gateway,
address _gasService,
address _endpoint,
address _wormholeRelayer
) ERC20(_name, _symbol) AxelarExecutable(_gateway) {
GAS_SERVICE = IAxelarGasService(_gasService);
ENDPOINT = ILayerZeroEndpoint(_endpoint);
WORMHOLE_RELAYER = IWormholeRelayer(_wormholeRelayer);
addressThis = address(this).toString();
}
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/// ----------------------------------------------------- EXTERNAL FUNCTIONS -------------------------------------------------------- \\\
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Handles the receipt of ALX tokens sent via the LayerZero bridge.
* @dev Mints ALX tokens for the recipient after a successful cross-chain transfer.
* @param _srcChainId The source chain's identifier in the LayerZero network.
* @param _srcAddress Encoded source address from which the tokens were sent.
* @param _payload Encoded data comprising sender's and recipient's addresses and token amount.
*/
function lzReceive(
uint16 _srcChainId,
bytes memory _srcAddress,
uint64,
bytes memory _payload
) external override {
if (address(ENDPOINT) != msg.sender) {
revert NotVerifiedCaller();
}
if (address(this) != address(uint160(bytes20(_srcAddress)))) {
revert InvalidLayerZeroSourceAddress();
}
(address _from, address _to, uint256 _amount) = abi.decode(
_payload,
(address, address, uint256)
);
_mint(_to, _amount);
emit BridgeReceive(
_to,
_amount,
BridgeId.LayerZero,
abi.encode(_srcChainId),
_from
);
if (block.chainid == 1) {
totalBridgedAmount -= _amount;
}
}
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Handles incoming token transfers via the Wormhole bridge.
* @dev Extracts transfer details from payload, mints tokens to the recipient, and updates state.
* @param _payload Encoded information including recipient's address and token amount.
* @param _sourceAddress The originating address from the source chain.
* @param _srcChainId Identifier of the source chain.
* @param _deliveryHash Unique hash for replay protection and verification.
*/
function receiveWormholeMessages(
bytes memory _payload,
bytes[] memory,
bytes32 _sourceAddress,
uint16 _srcChainId,
bytes32 _deliveryHash
)
external
payable
override
replayProtect(_deliveryHash)
{
if (msg.sender != address(WORMHOLE_RELAYER)) {
revert OnlyRelayerAllowed();
}
if (address(this) != address(uint160(uint256(_sourceAddress)))) {
revert InvalidWormholeSourceAddress();
}
(address _from, address _to, uint256 _amount) = abi.decode(
_payload,
(address, address, uint256)
);
_mint(_to, _amount);
emit BridgeReceive(
_to,
_amount,
BridgeId.Wormhole,
abi.encode(_srcChainId),
_from
);
if (block.chainid == 1) {
totalBridgedAmount -= _amount;
}
}
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/// ------------------------------------------------------ PUBLIC FUNCTIONS --------------------------------------------------------- \\\
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Bridges tokens to a specified chain using the LayerZero protocol.
* @dev Burns tokens from sender, constructs payload, and initiates bridge operation.
* @param _dstChainId The ID of the destination chain within the LayerZero network.
* @param _from The address initiating the token bridge on the source chain.
* @param _to The address on the destination chain to receive the tokens.
* @param _amount The number of tokens to bridge.
* @param _feeRefundAddress The address to receive refunds for any excess fee paid.
* @param _zroPaymentAddress Address holding ZRO tokens to cover fees, if applicable.
* @param _adapterParams Parameters for the LayerZero adapter.
*/
function bridgeViaLayerZero(
uint16 _dstChainId,
address _from,
address _to,
uint256 _amount,
address payable _feeRefundAddress,
address _zroPaymentAddress,
bytes calldata _adapterParams
)
public
payable
override
{
if (_zroPaymentAddress == address(0)) {
if (msg.value < estimateGasForLayerZero(
_dstChainId,
_from,
_to,
_amount,
false,
_adapterParams
)
)
{
revert InsufficientFee();
}
}
else {
if (msg.value < estimateGasForLayerZero(
_dstChainId,
_from,
_to,
_amount,
true,
_adapterParams
)
)
{
revert InsufficientFee();
}
}
if (msg.sender != _from)
_spendAllowance(
_from,
msg.sender,
_amount
);
_burn(_from, _amount);
if (_to == address(0)) {
revert InvalidToAddress();
}
ENDPOINT.send{value: msg.value} (
_dstChainId,
abi.encodePacked(address(this),address(this)),
abi.encode(
_from,
_to,
_amount
),
_feeRefundAddress,
_zroPaymentAddress,
_adapterParams
);
emit BridgeTransfer(
_from,
_amount,
BridgeId.LayerZero,
abi.encode(_dstChainId),
_to
);
if (block.chainid == 1) {
totalBridgedAmount += _amount;
}
}
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Bridges tokens to a specified chain using the Axelar network.
* @dev Encodes transaction details, invokes Axelar gateway, and burns bridged tokens.
* @param _destinationChain The identifier of the destination chain within the Axelar network.
* @param _from The address sending the tokens on the source chain.
* @param _to The intended recipient address on the destination chain.
* @param _amount The number of tokens to be bridged.
* @param _feeRefundAddress The address to which any excess ETH should be refunded.
*/
function bridgeViaAxelar(
string calldata _destinationChain,
address _from,
address _to,
uint256 _amount,
address payable _feeRefundAddress
)
public
payable
override
{
bytes memory payload = abi.encode(_from, _to, _amount);
string memory _ALXAddress = addressThis;
if (msg.value != 0) {
GAS_SERVICE.payNativeGasForContractCall{value: msg.value} (
address(this),
_destinationChain,
_ALXAddress,
payload,
_feeRefundAddress
);
}
if (_from != msg.sender)
_spendAllowance(
_from,
msg.sender,
_amount
);
_burn(_from, _amount);
if (_to == address(0)) {
revert InvalidToAddress();
}
gateway.callContract(
_destinationChain,
_ALXAddress,
payload
);
emit BridgeTransfer(
_from,
_amount,
BridgeId.Axelar,
abi.encode(_destinationChain),
_to
);
if (block.chainid == 1) {
totalBridgedAmount += _amount;
}
}
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Bridges tokens to a specified chain using the Wormhole network.
* @dev Estimates gas fee, burns tokens from sender, and initiates bridge process via Wormhole relayer.
* @param _targetChain The identifier of the destination chain within the Wormhole network.
* @param _from The address initiating the token bridge on the source chain.
* @param _to The intended recipient address on the target chain.
* @param _amount The quantity of tokens to be bridged.
* @param _feeRefundAddress The address to which any excess fees should be refunded.
* @param _gasLimit The gas limit for processing the transaction on the destination chain.
*/
function bridgeViaWormhole(
uint16 _targetChain,
address _from,
address _to,
uint256 _amount,
address payable _feeRefundAddress,
uint256 _gasLimit
)
public
payable
override
{
uint256 cost = estimateGasForWormhole(_targetChain, _gasLimit);
if (msg.value < cost) {
revert InsufficientFeeForWormhole();
}
if (msg.sender != _from)
_spendAllowance(
_from,
msg.sender,
_amount
);
_burn(_from, _amount);
if (_to == address(0)) {
revert InvalidToAddress();
}
WORMHOLE_RELAYER.sendPayloadToEvm{value: msg.value} (
_targetChain,
address(this),
abi.encode(_from, _to, _amount),
0,
_gasLimit,
_targetChain,
_feeRefundAddress
);
emit BridgeTransfer(
_from,
_amount,
BridgeId.Wormhole,
abi.encode(_targetChain),
_to
);
if (block.chainid == 1) {
totalBridgedAmount += _amount;
}
}
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Estimates the bridging fee on LayerZero for token transfer.
* @dev Invokes the `estimateFees` function from LayerZero's endpoint contract.
* @param _dstChainId The destination chain ID on LayerZero.
* @param _from The address sending tokens on the source chain.
* @param _to The address receiving tokens on the destination chain.
* @param _amount The amount of tokens being bridged.
* @param _payInZRO Indicates if the fee will be paid in ZRO token.
* @param _adapterParam Adapter-specific parameters that may affect fee calculation.
* @return nativeFee_ The estimated fee for the bridging operation in the native chain token.
*/
function estimateGasForLayerZero(
uint16 _dstChainId,
address _from,
address _to,
uint256 _amount,
bool _payInZRO,
bytes calldata _adapterParam
)
public
override
view
returns (uint256 nativeFee_)
{
(nativeFee_, ) = ENDPOINT.estimateFees(
_dstChainId,
address(this),
abi.encode(_from, _to, _amount),
_payInZRO,
_adapterParam
);
}
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Estimates the bridging fee using the Wormhole network for a specific transaction.
* @dev Calls the `quoteEVMDeliveryPrice` function on the Wormhole relayer contract.
* @param _targetChain The ID of the target chain within the Wormhole network.
* @param _gasLimit The gas limit specified for the transaction on the destination chain.
* @return cost_ The estimated cost for using Wormhole to bridge the transaction.
*/
function estimateGasForWormhole(uint16 _targetChain, uint256 _gasLimit)
public
override
view
returns (uint256 cost_)
{
(cost_, ) = WORMHOLE_RELAYER.quoteEVMDeliveryPrice(
_targetChain,
0,
_gasLimit
);
}
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/// ------------------------------------------------------ INTERNAL FUNCTION -------------------------------------------------------- \\\
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
/**
* @notice Processes the minting of tokens based on a cross-chain transaction.
* @dev Decodes the payload, validates the source address, and mints tokens to the recipient.
* @param _sourceChain Identifies the blockchain from which the cross-chain request originated.
* @param _sourceAddress The address on the source chain that initiated the mint request.
* @param _payload Encoded data containing the details of the mint operation.
*/
function _execute(
string calldata _sourceChain,
string calldata _sourceAddress,
bytes calldata _payload
) internal override {
if (_sourceAddress.toAddress() != address(this)) {
revert InvalidSourceAddress();
}
(address _from, address _to, uint256 _amount) = abi.decode(
_payload,
(address, address, uint256)
);
_mint(_to, _amount);
emit BridgeReceive(
_to,
_amount,
BridgeId.Axelar,
abi.encode(_sourceChain),
_from
);
if (block.chainid == 1) {
totalBridgedAmount -= _amount;
}
}
/// --------------------------------------------------------------------------------------------------------------------------------- \\\
}
ICore.sol 298 lines
// SPDX-License-Identifier: Unlicensed pragma solidity 0.8.25; /* * @title ICore Interface * * @notice Defines the core functionalities of the Alixa protocol, allowing interaction with bond and staking mechanisms. * * Co-Founders: * - Simran Dhillon: [email protected] * - Hardev Dhillon: [email protected] * - Dayana Plaz: [email protected] * * Official Links: * - Twitter: https://twitter.com/alixa_io * - Telegram: https://t.me/alixa_io * - Website: https://alixa.io * * Disclaimer: * This interface aligns with the principles of the Fair Crypto Foundation, promoting self-custody, transparency, consensus-based * trust, and permissionless value exchange. There are no administrative access keys, underscoring our commitment to decentralisation. * Engaging with this interface involves technical and legal risks. Users must conduct their own due diligence and ensure compliance * with local laws and regulations. The software is provided "AS-IS," without warranties, and the co-founders and developers disclaim * all liability for any vulnerabilities, exploits, errors, or breaches that may occur. By using this interface, users accept all associated * risks and this disclaimer. The co-founders, developers, or related parties will not bear liability for any consequences of non-compliance. * * Redistribution and Use: * Redistribution, modification, or repurposing of this interface, in whole or in part, is strictly prohibited without express written * approval from all co-founders. Approval requests must be sent to the official email addresses of the co-founders, ensuring responses * are received directly from these addresses. Proposals for redistribution, modification, or repurposing must include a detailed explanation * of the intended changes or uses and the reasons behind them. The co-founders reserve the right to request additional information or * clarification as necessary. Approval is at the sole discretion of the co-founders and may be subject to conditions to uphold the * project’s integrity and the values of the Fair Crypto Foundation. Failure to obtain express written approval prior to any redistribution, * modification, or repurposing will result in a breach of these terms and immediate legal action. * * Copyright and License: * Copyright © 2024 Alixa (Simran Dhillon, Hardev Dhillon, Dayana Plaz). All rights reserved. * This software is provided 'as is' and may be used by the recipient. No permission is granted for redistribution, * modification, or repurposing of this interface. Any use beyond the scope defined herein may be subject to legal action. */ interface ICore { /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /// ------------------------------------------------------------- ENUM -------------------------------------------------------------- \\\ /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Supported token types in the Alixa ecosystem. * @dev Defines eETH, ETHx, and ETH as valid token types. */ enum Token { eeth, ethx, eth } /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /// ----------------------------------------------------- EXTERNAL FUNCTIONS -------------------------------------------------------- \\\ /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Updates the current cycle. * @dev Calculates and updates the cycle based on protocol parameters. * @return Current cycle number. */ function calculateCycle() external returns (uint256); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Initiates ALX token unbonding process. * @dev Starts unbonding for specified bond ID. * @param _bondID Bond identifier. * @param _restake If true, restakes rewards. */ function unbondingALX(uint256 _bondID, bool _restake) external; /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Provides ALX tokens for liquidity. * @dev Adds specified ALX amount to liquidity pool. * @param ALXAmount Amount of ALX tokens to provide. */ function provideAssetsForLiquidity(uint256 ALXAmount) external; /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Reactivates an existing bond. * @dev Reactivates bond using specified ETHx amount. * @param _bondID Bond identifier. * @param _ETHxAmount Amount of ETHx for reactivation. */ function reactivate(uint256 _bondID, uint256 _ETHxAmount) external; /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Claims ETHx rewards for a bond. * @dev Processes ETHx reward claims for specified bond. * @param _bondID Bond identifier. * @param _restake If true, restakes rewards. */ function claimETHxRewards(uint256 _bondID, bool _restake) external; /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Checks liquidity provision trigger status. * @dev Returns current status of liquidity provision trigger. * @return True if triggered, false otherwise. */ function isTriggered() external view returns (bool); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Retrieves base cost for transactions. * @dev Returns fixed base cost value. * @return Base cost value. */ function BASE_COST() external pure returns (uint256); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Gets current cycle number. * @dev Returns cycle number without state modification. * @return Current cycle number. */ function getCurrentCycle() external view returns (uint256); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Calculates required token amounts for bonds. * @dev Determines token amount based on bond parameters. * @param _bondPower Bond power level. * @param _bondCount Number of bonds. * @param _isETHBond True if ETH bond, false otherwise. * @return tokenRequired_ Required token amount. */ function getTokenAmounts( uint256 _bondPower, uint256 _bondCount, bool _isETHBond ) external view returns (uint256 tokenRequired_); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Retrieves pending ALX rewards for a bond. * @dev Calculates pending ALX rewards for specified bond. * @param _bondID Bond identifier. * @return reward_ Pending ALX reward amount. */ function pendingALX(uint256 _bondID) external view returns (uint256 reward_); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Checks bond existence for a user. * @dev Verifies if specified bond exists for given user. * @param _user User address. * @param _bondID Bond identifier. * @return exists_ True if bond exists, false otherwise. */ function isExist(address _user, uint256 _bondID) external view returns (bool exists_); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Transfers bond ownership. * @dev Processes bond transfer to new owner. * @param _bondIDs Array of bond IDs to transfer. * @param _recipient New owner's address. * @param _restake If true, restakes rewards. */ function transferBond( uint256[] calldata _bondIDs, address _recipient, bool _restake ) external; /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Allows bond sniping. * @dev Processes bond sniping between users. * @param _user Bond owner's address. * @param _bondIDUser ID of bond to snipe. * @param _bondIDSniper Sniper's bond ID. * @param _restake If true, restakes rewards. */ function snipe( address _user, uint256 _bondIDUser, uint256 _bondIDSniper, bool _restake ) external; /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Calculates pending ETHx rewards for a bond. * @dev Computes various components of ETHx rewards. * @param _user User address. * @param _bondID Bond identifier. * @return pendingAmount_ Base pending ETHx amount. * @return pendingBonus_ Pending bonus amount. * @return totalPending_ Total pending rewards. */ function pendingETHx(address _user, uint256 _bondID) external view returns ( uint256 pendingAmount_, uint256 pendingBonus_, uint256 totalPending_ ); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Purchases bond with ALX tokens. * @dev Processes ALX bond purchase. * @param _user Purchaser's address. * @param _bondCount Number of bonds to purchase. * @param _daysCount Bond duration in days. * @param _bondPower Bond power level. */ function purchaseALXBond( address _user, uint256 _bondCount, uint256 _daysCount, uint256 _bondPower ) external; /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Purchases bond with airdropped ALX tokens. * @dev Processes bond purchase using airdropped ALX. * @param _user Purchaser's address. * @param _bondCount Number of bonds to purchase. * @param _daysCount Bond duration in days. * @param _bondPower Bond power level. * @param _requiredALXAmount Required ALX amount for purchase. */ function purchaseBondWithAirdroppedALX( address _user, uint256 _bondCount, uint256 _daysCount, uint256 _bondPower, uint256 _requiredALXAmount ) external payable; /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Purchases ETH bond. * @dev Processes ETH or ETH-based token bond purchase. * @param _user Purchaser's address. * @param _bondCount Number of bonds to purchase. * @param _token Token type used for purchase. * @param _daysCount Bond duration in days. * @param _bondPower Bond power level. */ function purchaseETHBond( address _user, uint256 _bondCount, Token _token, uint256 _daysCount, uint256 _bondPower ) external payable; /// --------------------------------------------------------------------------------------------------------------------------------- \\\ }
IBridgeToken.sol 293 lines
// SPDX-License-Identifier: Unlicensed pragma solidity 0.8.25; /* * @title IBridge Interface * * @notice Interface defining the functions and events for token bridging operations. * * Co-Founders: * - Simran Dhillon: [email protected] * - Hardev Dhillon: [email protected] * - Dayana Plaz: [email protected] * * Official Links: * - Twitter: https://twitter.com/alixa_io * - Telegram: https://t.me/alixa_io * - Website: https://alixa.io * * Disclaimer: * This interface aligns with the principles of the Fair Crypto Foundation, promoting self-custody, transparency, consensus-based * trust, and permissionless value exchange. There are no administrative access keys, underscoring our commitment to decentralisation. * Engaging with this interface involves technical and legal risks. Users must conduct their own due diligence and ensure compliance * with local laws and regulations. The software is provided "AS-IS," without warranties, and the co-founders and developers disclaim * all liability for any vulnerabilities, exploits, errors, or breaches that may occur. By using this interface, users accept all associated * risks and this disclaimer. The co-founders, developers, or related parties will not bear liability for any consequences of non-compliance. * * Redistribution and Use: * Redistribution, modification, or repurposing of this interface, in whole or in part, is strictly prohibited without express written * approval from all co-founders. Approval requests must be sent to the official email addresses of the co-founders, ensuring responses * are received directly from these addresses. Proposals for redistribution, modification, or repurposing must include a detailed explanation * of the intended changes or uses and the reasons behind them. The co-founders reserve the right to request additional information or * clarification as necessary. Approval is at the sole discretion of the co-founders and may be subject to conditions to uphold the * project’s integrity and the values of the Fair Crypto Foundation. Failure to obtain express written approval prior to any redistribution, * modification, or repurposing will result in a breach of these terms and immediate legal action. * * Copyright and License: * Copyright © 2024 Alixa (Simran Dhillon, Hardev Dhillon, Dayana Plaz). All rights reserved. * This software is provided 'as is' and may be used by the recipient. No permission is granted for redistribution, * modification, or repurposing of this interface. Any use beyond the scope defined herein may be subject to legal action. */ interface IBridgeToken { /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /// ------------------------------------------------------------- ENUM -------------------------------------------------------------- \\\ /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Enumerates the types of bridges supported. * @dev Defines different bridge protocols for cross-chain operations. */ enum BridgeId { LayerZero, Wormhole, Axelar } /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /// ------------------------------------------------------------ EVENTS ------------------------------------------------------------- \\\ /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Emitted when tokens are received through a bridge. * @param to Recipient address on the destination chain. * @param amount Amount of tokens received. * @param bridgeId Identifier of the bridge protocol used. * @param fromChainId Identifier of the source chain. * @param from Sender address on the source chain. */ event BridgeReceive( address indexed to, uint256 amount, BridgeId bridgeId, bytes fromChainId, address indexed from ); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Emitted when tokens are sent to another chain via a bridge. * @param from Sender address on the source chain. * @param amount Amount of tokens transferred. * @param bridgeId Bridge protocol used for the transfer. * @param toChainId Destination chain identifier. * @param to Recipient address on the destination chain. */ event BridgeTransfer( address indexed from, uint256 amount, BridgeId bridgeId, bytes toChainId, address indexed to ); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /// ------------------------------------------------------------ ERRORS ------------------------------------------------------------- \\\ /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Error for when the provided fee is insufficient. * @dev Ensures adequate fees for bridging to prevent transaction failures. */ error InsufficientFee(); /** * @notice Error for when the recipient address is invalid. * @dev Validates recipient address to prevent sending to invalid addresses. */ error InvalidToAddress(); /** * @notice Error for when a non-verified caller attempts an operation. * @dev Prevents unauthorised access to bridge functions. */ error NotVerifiedCaller(); /** * @notice Error indicating that the operation is restricted to the relayer. * @dev Ensures only the designated relayer can perform certain operations. */ error OnlyRelayerAllowed(); /** * @notice Error for when the source address is invalid. * @dev Validates source address to prevent security risks or incorrect attributions. */ error InvalidSourceAddress(); /** * @notice Error for when the fee for Wormhole bridging is insufficient. * @dev Ensures adequate fees specifically for Wormhole bridging. */ error InsufficientFeeForWormhole(); /** * @notice Error for when the Wormhole source address is invalid. * @dev Validates source address in Wormhole bridging for transfer integrity. */ error InvalidWormholeSourceAddress(); /** * @notice Error for when the LayerZero source address is invalid. * @dev Validates source address in LayerZero bridging for secure transfers. */ error InvalidLayerZeroSourceAddress(); /** * @notice Error for when a Wormhole message is replayed. * @dev Prevents replay attacks in Wormhole bridging operations. */ error WormholeMessageAlreadyProcessed(); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /// ----------------------------------------------------- EXTERNAL FUNCTIONS -------------------------------------------------------- \\\ /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Receives tokens via LayerZero. * @dev Handles incoming LayerZero bridging operations. * @param _srcChainId Source chain ID on LayerZero network. * @param _srcAddress Source address of the ALX token sender. * @param _payload Encoded data with recipient address and amount. */ function lzReceive( uint16 _srcChainId, bytes memory _srcAddress, uint64, bytes memory _payload ) external; /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Receives tokens via Wormhole. * @dev Handles incoming Wormhole bridging operations. * @param _payload Encoded data with user address and amount. * @param _sourceAddress Caller's address on source chain in bytes32. * @param _srcChainId Source chain ID. * @param _deliveryHash Hash for verifying relay calls. */ function receiveWormholeMessages( bytes memory _payload, bytes[] memory, bytes32 _sourceAddress, uint16 _srcChainId, bytes32 _deliveryHash ) external payable; /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Bridges tokens to another chain via LayerZero. * @dev Facilitates LayerZero token transfer, handling locking and messaging. * @param _dstChainId Target chain ID on LayerZero. * @param _from Sender's address on source chain. * @param _to Recipient's address on destination chain. * @param _amount Amount of tokens to bridge. * @param _feeRefundAddress Address for excess fee refunds. * @param _zroPaymentAddress ZRO token holder address for fees. * @param _adapterParams Additional parameters for custom functionalities. */ function bridgeViaLayerZero( uint16 _dstChainId, address _from, address _to, uint256 _amount, address payable _feeRefundAddress, address _zroPaymentAddress, bytes calldata _adapterParams ) external payable; /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Bridges tokens to another chain via Axelar. * @dev Facilitates Axelar token transfer, handling locking and messaging. * @param _destinationChain Target chain ID on Axelar. * @param _from Sender's address on source chain. * @param _to Recipient's address on destination chain. * @param _amount Amount of tokens to bridge. * @param _feeRefundAddress Address for excess fee refunds. */ function bridgeViaAxelar( string calldata _destinationChain, address _from, address _to, uint256 _amount, address payable _feeRefundAddress ) external payable; /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Bridges tokens to another chain via Wormhole. * @dev Facilitates Wormhole token transfer, handling locking and messaging. * @param _targetChain Target chain ID on Wormhole. * @param _from Sender's address on source chain. * @param _to Recipient's address on destination chain. * @param _amount Amount of tokens to bridge. * @param _feeRefundAddress Address for excess fee refunds. * @param _gasLimit Gas limit for the transaction on destination chain. */ function bridgeViaWormhole( uint16 _targetChain, address _from, address _to, uint256 _amount, address payable _feeRefundAddress, uint256 _gasLimit ) external payable; /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Estimates the gas required for LayerZero bridging. * @dev Provides gas fee estimate for LayerZero bridging. * @param _dstChainId Destination chain ID on LayerZero. * @param _from Sender's address on source chain. * @param _to Recipient's address on destination chain. * @param _amount Amount of tokens to bridge. * @param _payInZRO True if fee is paid in ZRO tokens, false for native tokens. * @param _adapterParam Parameters for adapter services. * @return nativeFee_ Estimated fee in native tokens of destination chain. */ function estimateGasForLayerZero( uint16 _dstChainId, address _from, address _to, uint256 _amount, bool _payInZRO, bytes calldata _adapterParam ) external view returns (uint256 nativeFee_); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Estimates the gas required for Wormhole bridging. * @dev Provides gas fee estimate for Wormhole bridging. * @param _targetChain Destination chain ID on Wormhole. * @param _gasLimit Gas limit for the transaction on destination chain. * @return cost_ Estimated fee in native tokens of source chain. */ function estimateGasForWormhole(uint16 _targetChain, uint256 _gasLimit) external view returns (uint256 cost_); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ }
ISwapHandler.sol 64 lines
// SPDX-License-Identifier: Unlicensed pragma solidity 0.8.25; /* * @title ISwapHandler Interface * * @notice Interface for SwapHandler contract. * @dev Used when interacting with SwapHandler contract to swap eETH to ETH. * * Co-Founders: * - Simran Dhillon: [email protected] * - Hardev Dhillon: [email protected] * - Dayana Plaz: [email protected] * * Official Links: * - Twitter: https://twitter.com/alixa_io * - Telegram: https://t.me/alixa_io * - Website: https://alixa.io * * Disclaimer: * This contract aligns with the principles of the Fair Crypto Foundation, promoting self-custody, transparency, consensus-based * trust, and permissionless value exchange. There are no administrative access keys, underscoring our commitment to decentralisation. * Engaging with this contract involves technical and legal risks. Users must conduct their own due diligence and ensure compliance * with local laws and regulations. The software is provided "AS-IS," without warranties, and the co-founders and developers disclaim * all liability for any vulnerabilities, exploits, errors, or breaches that may occur. By using this contract, users accept all associated * risks and this disclaimer. The co-founders, developers, or related parties will not bear liability for any consequences of non-compliance. * * Redistribution and Use: * Redistribution, modification, or repurposing of this contract, in whole or in part, is strictly prohibited without express written * approval from all co-founders. Approval requests must be sent to the official email addresses of the co-founders, ensuring responses * are received directly from these addresses. Proposals for redistribution, modification, or repurposing must include a detailed explanation * of the intended changes or uses and the reasons behind them. The co-founders reserve the right to request additional information or * clarification as necessary. Approval is at the sole discretion of the co-founders and may be subject to conditions to uphold the * project’s integrity and the values of the Fair Crypto Foundation. Failure to obtain express written approval prior to any redistribution, * modification, or repurposing will result in a breach of these terms and immediate legal action. * * Copyright and License: * Copyright © 2024 Alixa (Simran Dhillon, Hardev Dhillon, Dayana Plaz). All rights reserved. * This software is provided 'as is' and may be used by the recipient. No permission is granted for redistribution, * modification, or repurposing of this contract. Any use beyond the scope defined herein may be subject to legal action. */ interface ISwapHandler { /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /// ------------------------------------------------------ EXTERNAL FUNCTION -------------------------------------------------------- \\\ /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Swaps eETH to ETH. * @dev Executes the swap using the SwapHandler contract logic. * @param _amountIn Amount of eETH to swap. * @param _minAmountOut Minimum ETH to receive, for slippage control. * @param _receiver Address to receive the swapped ETH. * @return Amount of ETH received after the swap. */ function swap( uint256 _amountIn, uint256 _minAmountOut, address _receiver ) external returns (uint256); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ }
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
IWormholeRelayer.sol 904 lines
// SPDX-License-Identifier: Unlicensed pragma solidity 0.8.25; /* * @title IWormholeRelayerBase Interface * * @notice Defines the base interface for the Wormhole Relayer, facilitating cross-chain communication and message relaying. * * Co-Founders: * - Simran Dhillon: [email protected] * - Hardev Dhillon: [email protected] * - Dayana Plaz: [email protected] * * Official Links: * - Twitter: https://twitter.com/alixa_io * - Telegram: https://t.me/alixa_io * - Website: https://alixa.io * * Disclaimer: * This interface aligns with the principles of the Fair Crypto Foundation, promoting self-custody, transparency, consensus-based * trust, and permissionless value exchange. There are no administrative access keys, underscoring our commitment to decentralisation. * Engaging with this interface involves technical and legal risks. Users must conduct their own due diligence and ensure compliance * with local laws and regulations. The software is provided "AS-IS," without warranties, and the co-founders and developers disclaim * all liability for any vulnerabilities, exploits, errors, or breaches that may occur. By using this interface, users accept all associated * risks and this disclaimer. The co-founders, developers, or related parties will not bear liability for any consequences of non-compliance. * * Redistribution and Use: * Redistribution, modification, or repurposing of this interface, in whole or in part, is strictly prohibited without express written * approval from all co-founders. Approval requests must be sent to the official email addresses of the co-founders, ensuring responses * are received directly from these addresses. Proposals for redistribution, modification, or repurposing must include a detailed explanation * of the intended changes or uses and the reasons behind them. The co-founders reserve the right to request additional information or * clarification as necessary. Approval is at the sole discretion of the co-founders and may be subject to conditions to uphold the * project’s integrity and the values of the Fair Crypto Foundation. Failure to obtain express written approval prior to any redistribution, * modification, or repurposing will result in a breach of these terms and immediate legal action. * * Copyright and License: * Copyright © 2024 Alixa (Simran Dhillon, Hardev Dhillon, Dayana Plaz). All rights reserved. * This software is provided 'as is' and may be used by the recipient. No permission is granted for redistribution, * modification, or repurposing of this interface. Any use beyond the scope defined herein may be subject to legal action. */ /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /// ---------------------------------------------------------- STRUCTURE ------------------------------------------------------------ \\\ /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice VaaKey identifies a wormhole message. * @custom:member chainId Wormhole chain ID of the chain where this VAA was emitted from. * @custom:member emitterAddress Address of the emitter of the VAA, in Wormhole bytes32 format. * @custom:member sequence Sequence number of the VAA. */ struct VaaKey { uint16 chainId; bytes32 emitterAddress; uint64 sequence; } /// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| \\\ /** * @title IWormholeRelayerBase * @notice Interface for basic Wormhole Relayer operations. */ interface IWormholeRelayerBase { /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /// ------------------------------------------------------------ EVENT -------------------------------------------------------------- \\\ /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Emitted when a Send operation is executed. * @param sequence The sequence of the send event. * @param deliveryQuote The delivery quote for the send operation. * @param paymentForExtraReceiverValue The payment value for the additional receiver. */ event SendEvent( uint64 indexed sequence, uint256 deliveryQuote, uint256 paymentForExtraReceiverValue ); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /// ------------------------------------------------------ EXTERNAL FUNCTION -------------------------------------------------------- \\\ /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Fetches the registered Wormhole Relayer contract for a given chain ID. * @param chainId The chain ID to fetch the relayer contract for. * @return The address of the registered Wormhole Relayer contract for the given chain ID. */ function getRegisteredWormholeRelayerContract(uint16 chainId) external view returns (bytes32); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ } /// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| \\\ /** * @title IWormholeRelayerSend * @notice The interface to request deliveries. */ interface IWormholeRelayerSend is IWormholeRelayerBase { /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /// ----------------------------------------------------- EXTERNAL FUNCTIONS -------------------------------------------------------- \\\ /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Publishes an instruction for the default delivery provider * to relay a payload to the address `targetAddress` on chain `targetChain` * with gas limit `gasLimit` and `msg.value` equal to `receiverValue` * * `targetAddress` must implement the IWormholeReceiver interface. * * This function must be called with `msg.value` equal to `quoteEVMDeliveryPrice(targetChain, receiverValue, gasLimit)`. * * Any refunds (from leftover gas) will be paid to the delivery provider. In order to receive the refunds, use the `sendPayloadToEvm` function * with `refundChain` and `refundAddress` as parameters. * * @param targetChain in Wormhole Chain ID format. * @param targetAddress address to call on targetChain (that implements IWormholeReceiver). * @param payload arbitrary bytes to pass in as parameter in call to `targetAddress`. * @param receiverValue msg.value that delivery provider should pass in for call to `targetAddress` (in targetChain currency units). * @param gasLimit gas limit with which to call `targetAddress`. * @return sequence sequence number of published VAA containing delivery instructions. */ function sendPayloadToEvm( uint16 targetChain, address targetAddress, bytes memory payload, uint256 receiverValue, uint256 gasLimit ) external payable returns (uint64 sequence); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Publishes an instruction for the default delivery provider. * to relay a payload to the address `targetAddress` on chain `targetChain` * with gas limit `gasLimit` and `msg.value` equal to `receiverValue`. * * Any refunds (from leftover gas) will be sent to `refundAddress` on chain `refundChain` * `targetAddress` must implement the IWormholeReceiver interface. * * This function must be called with `msg.value` equal to `quoteEVMDeliveryPrice(targetChain, receiverValue, gasLimit)`. * * @param targetChain in Wormhole Chain ID format. * @param targetAddress address to call on targetChain (that implements IWormholeReceiver). * @param payload arbitrary bytes to pass in as parameter in call to `targetAddress`. * @param receiverValue msg.value that delivery provider should pass in for call to `targetAddress` (in targetChain currency units). * @param gasLimit gas limit with which to call `targetAddress`. Any units of gas unused will be refunded according to the * `targetChainRefundPerGasUnused` rate quoted by the delivery provider. * @param refundChain The chain to deliver any refund to, in Wormhole Chain ID format. * @param refundAddress The address on `refundChain` to deliver any refund to. * @return sequence sequence number of published VAA containing delivery instructions. */ function sendPayloadToEvm( uint16 targetChain, address targetAddress, bytes memory payload, uint256 receiverValue, uint256 gasLimit, uint16 refundChain, address refundAddress ) external payable returns (uint64 sequence); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Publishes an instruction for the default delivery provider * to relay a payload and VAAs specified by `vaaKeys` to the address `targetAddress` on chain `targetChain` * with gas limit `gasLimit` and `msg.value` equal to `receiverValue` * * `targetAddress` must implement the IWormholeReceiver interface * * This function must be called with `msg.value` equal to `quoteEVMDeliveryPrice(targetChain, receiverValue, gasLimit)` * * Any refunds (from leftover gas) will be paid to the delivery provider. In order to receive the refunds, use the `sendVaasToEvm` function * with `refundChain` and `refundAddress` as parameters * * @param targetChain in Wormhole Chain ID format * @param targetAddress address to call on targetChain (that implements IWormholeReceiver) * @param payload arbitrary bytes to pass in as parameter in call to `targetAddress` * @param receiverValue msg.value that delivery provider should pass in for call to `targetAddress` (in targetChain currency units) * @param gasLimit gas limit with which to call `targetAddress`. * @param vaaKeys Additional VAAs to pass in as parameter in call to `targetAddress` * @return sequence sequence number of published VAA containing delivery instructions */ function sendVaasToEvm( uint16 targetChain, address targetAddress, bytes memory payload, uint256 receiverValue, uint256 gasLimit, VaaKey[] memory vaaKeys ) external payable returns (uint64 sequence); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Publishes an instruction for the default delivery provider * to relay a payload and VAAs specified by `vaaKeys` to the address `targetAddress` on chain `targetChain` * with gas limit `gasLimit` and `msg.value` equal to `receiverValue` * * Any refunds (from leftover gas) will be sent to `refundAddress` on chain `refundChain` * `targetAddress` must implement the IWormholeReceiver interface * * This function must be called with `msg.value` equal to `quoteEVMDeliveryPrice(targetChain, receiverValue, gasLimit)` * * @param targetChain in Wormhole Chain ID format * @param targetAddress address to call on targetChain (that implements IWormholeReceiver) * @param payload arbitrary bytes to pass in as parameter in call to `targetAddress` * @param receiverValue msg.value that delivery provider should pass in for call to `targetAddress` (in targetChain currency units) * @param gasLimit gas limit with which to call `targetAddress`. Any units of gas unused will be refunded according to the * `targetChainRefundPerGasUnused` rate quoted by the delivery provider * @param vaaKeys Additional VAAs to pass in as parameter in call to `targetAddress` * @param refundChain The chain to deliver any refund to, in Wormhole Chain ID format * @param refundAddress The address on `refundChain` to deliver any refund to * @return sequence sequence number of published VAA containing delivery instructions */ function sendVaasToEvm( uint16 targetChain, address targetAddress, bytes memory payload, uint256 receiverValue, uint256 gasLimit, VaaKey[] memory vaaKeys, uint16 refundChain, address refundAddress ) external payable returns (uint64 sequence); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Publishes an instruction for the delivery provider at `deliveryProviderAddress` * to relay a payload and VAAs specified by `vaaKeys` to the address `targetAddress` on chain `targetChain` * with gas limit `gasLimit` and `msg.value` equal to * receiverValue + (arbitrary amount that is paid for by paymentForExtraReceiverValue of this chain's wei) in targetChain wei. * * Any refunds (from leftover gas) will be sent to `refundAddress` on chain `refundChain` * `targetAddress` must implement the IWormholeReceiver interface * * This function must be called with `msg.value` equal to * quoteEVMDeliveryPrice(targetChain, receiverValue, gasLimit, deliveryProviderAddress) + paymentForExtraReceiverValue * * @param targetChain in Wormhole Chain ID format * @param targetAddress address to call on targetChain (that implements IWormholeReceiver) * @param payload arbitrary bytes to pass in as parameter in call to `targetAddress` * @param receiverValue msg.value that delivery provider should pass in for call to `targetAddress` (in targetChain currency units) * @param paymentForExtraReceiverValue amount (in current chain currency units) to spend on extra receiverValue * (in addition to the `receiverValue` specified) * @param gasLimit gas limit with which to call `targetAddress`. Any units of gas unused will be refunded according to the * `targetChainRefundPerGasUnused` rate quoted by the delivery provider * @param refundChain The chain to deliver any refund to, in Wormhole Chain ID format * @param refundAddress The address on `refundChain` to deliver any refund to * @param deliveryProviderAddress The address of the desired delivery provider's implementation of IDeliveryProvider * @param vaaKeys Additional VAAs to pass in as parameter in call to `targetAddress` * @param consistencyLevel Consistency level with which to publish the delivery instructions - see * https://book.wormhole.com/wormhole/3_coreLayerContracts.html?highlight=consistency#consistency-levels * @return sequence sequence number of published VAA containing delivery instructions */ function sendToEvm( uint16 targetChain, address targetAddress, bytes memory payload, uint256 receiverValue, uint256 paymentForExtraReceiverValue, uint256 gasLimit, uint16 refundChain, address refundAddress, address deliveryProviderAddress, VaaKey[] memory vaaKeys, uint8 consistencyLevel ) external payable returns (uint64 sequence); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Publishes an instruction for the delivery provider at `deliveryProviderAddress` * to relay a payload and VAAs specified by `vaaKeys` to the address `targetAddress` on chain `targetChain` * with `msg.value` equal to * receiverValue + (arbitrary amount that is paid for by paymentForExtraReceiverValue of this chain's wei) in targetChain wei. * * Any refunds (from leftover gas) will be sent to `refundAddress` on chain `refundChain` * `targetAddress` must implement the IWormholeReceiver interface * * This function must be called with `msg.value` equal to * quoteDeliveryPrice(targetChain, receiverValue, encodedExecutionParameters, deliveryProviderAddress) + paymentForExtraReceiverValue * * @param targetChain in Wormhole Chain ID format * @param targetAddress address to call on targetChain (that implements IWormholeReceiver), in Wormhole bytes32 format * @param payload arbitrary bytes to pass in as parameter in call to `targetAddress` * @param receiverValue msg.value that delivery provider should pass in for call to `targetAddress` (in targetChain currency units) * @param paymentForExtraReceiverValue amount (in current chain currency units) to spend on extra receiverValue * (in addition to the `receiverValue` specified) * @param encodedExecutionParameters encoded information on how to execute delivery that may impact pricing * e.g. for version EVM_V1, this is a struct that encodes the `gasLimit` with which to call `targetAddress` * @param refundChain The chain to deliver any refund to, in Wormhole Chain ID format * @param refundAddress The address on `refundChain` to deliver any refund to, in Wormhole bytes32 format * @param deliveryProviderAddress The address of the desired delivery provider's implementation of IDeliveryProvider * @param vaaKeys Additional VAAs to pass in as parameter in call to `targetAddress` * @param consistencyLevel Consistency level with which to publish the delivery instructions - see * https://book.wormhole.com/wormhole/3_coreLayerContracts.html?highlight=consistency#consistency-levels * @return sequence sequence number of published VAA containing delivery instructions */ function send( uint16 targetChain, bytes32 targetAddress, bytes memory payload, uint256 receiverValue, uint256 paymentForExtraReceiverValue, bytes memory encodedExecutionParameters, uint16 refundChain, bytes32 refundAddress, address deliveryProviderAddress, VaaKey[] memory vaaKeys, uint8 consistencyLevel ) external payable returns (uint64 sequence); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Performs the same function as a `send`, except: * 1) Can only be used during a delivery (i.e. in execution of `receiveWormholeMessages`) * 2) Is paid for (along with any other calls to forward) by (any msg.value passed in) + (refund leftover from current delivery) * 3) Only executes after `receiveWormholeMessages` is completed (and thus does not return a sequence number) * * The refund from the delivery currently in progress will not be sent to the user; it will instead * be paid to the delivery provider to perform the instruction specified here * * Publishes an instruction for the same delivery provider (or default, if the same one doesn't support the new target chain) * to relay a payload to the address `targetAddress` on chain `targetChain` * with gas limit `gasLimit` and with `msg.value` equal to `receiverValue` * * The following equation must be satisfied (sum_f indicates summing over all forwards requested in `receiveWormholeMessages`): * (refund amount from current execution of receiveWormholeMessages) + sum_f [msg.value_f] * >= sum_f [quoteEVMDeliveryPrice(targetChain_f, receiverValue_f, gasLimit_f)] * * The difference between the two sides of the above inequality will be added to `paymentForExtraReceiverValue` of the first forward requested * * Any refunds (from leftover gas) from this forward will be paid to the same refundChain and refundAddress specified for the current delivery. * * @param targetChain in Wormhole Chain ID format * @param targetAddress address to call on targetChain (that implements IWormholeReceiver), in Wormhole bytes32 format * @param payload arbitrary bytes to pass in as parameter in call to `targetAddress` * @param receiverValue msg.value that delivery provider should pass in for call to `targetAddress` (in targetChain currency units) * @param gasLimit gas limit with which to call `targetAddress`. */ function forwardPayloadToEvm( uint16 targetChain, address targetAddress, bytes memory payload, uint256 receiverValue, uint256 gasLimit ) external payable; /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Performs the same function as a `send`, except: * 1) Can only be used during a delivery (i.e. in execution of `receiveWormholeMessages`) * 2) Is paid for (along with any other calls to forward) by (any msg.value passed in) + (refund leftover from current delivery) * 3) Only executes after `receiveWormholeMessages` is completed (and thus does not return a sequence number) * * The refund from the delivery currently in progress will not be sent to the user; it will instead * be paid to the delivery provider to perform the instruction specified here * * Publishes an instruction for the same delivery provider (or default, if the same one doesn't support the new target chain) * to relay a payload and VAAs specified by `vaaKeys` to the address `targetAddress` on chain `targetChain` * with gas limit `gasLimit` and with `msg.value` equal to `receiverValue` * * The following equation must be satisfied (sum_f indicates summing over all forwards requested in `receiveWormholeMessages`): * (refund amount from current execution of receiveWormholeMessages) + sum_f [msg.value_f] * >= sum_f [quoteEVMDeliveryPrice(targetChain_f, receiverValue_f, gasLimit_f)] * * The difference between the two sides of the above inequality will be added to `paymentForExtraReceiverValue` of the first forward requested * * Any refunds (from leftover gas) from this forward will be paid to the same refundChain and refundAddress specified for the current delivery. * * @param targetChain in Wormhole Chain ID format * @param targetAddress address to call on targetChain (that implements IWormholeReceiver), in Wormhole bytes32 format * @param payload arbitrary bytes to pass in as parameter in call to `targetAddress` * @param receiverValue msg.value that delivery provider should pass in for call to `targetAddress` (in targetChain currency units) * @param gasLimit gas limit with which to call `targetAddress`. * @param vaaKeys Additional VAAs to pass in as parameter in call to `targetAddress` */ function forwardVaasToEvm( uint16 targetChain, address targetAddress, bytes memory payload, uint256 receiverValue, uint256 gasLimit, VaaKey[] memory vaaKeys ) external payable; /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Performs the same function as a `send`, except: * 1) Can only be used during a delivery (i.e. in execution of `receiveWormholeMessages`) * 2) Is paid for (along with any other calls to forward) by (any msg.value passed in) + (refund leftover from current delivery) * 3) Only executes after `receiveWormholeMessages` is completed (and thus does not return a sequence number) * * The refund from the delivery currently in progress will not be sent to the user; it will instead * be paid to the delivery provider to perform the instruction specified here * * Publishes an instruction for the delivery provider at `deliveryProviderAddress` * to relay a payload and VAAs specified by `vaaKeys` to the address `targetAddress` on chain `targetChain` * with gas limit `gasLimit` and with `msg.value` equal to * receiverValue + (arbitrary amount that is paid for by paymentForExtraReceiverValue of this chain's wei) in targetChain wei. * * Any refunds (from leftover gas) will be sent to `refundAddress` on chain `refundChain` * `targetAddress` must implement the IWormholeReceiver interface * * The following equation must be satisfied (sum_f indicates summing over all forwards requested in `receiveWormholeMessages`): * (refund amount from current execution of receiveWormholeMessages) + sum_f [msg.value_f] * >= sum_f [quoteEVMDeliveryPrice(targetChain_f, receiverValue_f, gasLimit_f, deliveryProviderAddress_f) + paymentForExtraReceiverValue_f] * * The difference between the two sides of the above inequality will be added to `paymentForExtraReceiverValue` of the first forward requested * * @param targetChain in Wormhole Chain ID format * @param targetAddress address to call on targetChain (that implements IWormholeReceiver), in Wormhole bytes32 format * @param payload arbitrary bytes to pass in as parameter in call to `targetAddress` * @param receiverValue msg.value that delivery provider should pass in for call to `targetAddress` (in targetChain currency units) * @param paymentForExtraReceiverValue amount (in current chain currency units) to spend on extra receiverValue * (in addition to the `receiverValue` specified) * @param gasLimit gas limit with which to call `targetAddress`. Any units of gas unused will be refunded according to the * `targetChainRefundPerGasUnused` rate quoted by the delivery provider * @param refundChain The chain to deliver any refund to, in Wormhole Chain ID format * @param refundAddress The address on `refundChain` to deliver any refund to, in Wormhole bytes32 format * @param deliveryProviderAddress The address of the desired delivery provider's implementation of IDeliveryProvider * @param vaaKeys Additional VAAs to pass in as parameter in call to `targetAddress` * @param consistencyLevel Consistency level with which to publish the delivery instructions - see * https://book.wormhole.com/wormhole/3_coreLayerContracts.html?highlight=consistency#consistency-levels */ function forwardToEvm( uint16 targetChain, address targetAddress, bytes memory payload, uint256 receiverValue, uint256 paymentForExtraReceiverValue, uint256 gasLimit, uint16 refundChain, address refundAddress, address deliveryProviderAddress, VaaKey[] memory vaaKeys, uint8 consistencyLevel ) external payable; /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Performs the same function as a `send`, except: * 1) Can only be used during a delivery (i.e. in execution of `receiveWormholeMessages`) * 2) Is paid for (along with any other calls to forward) by (any msg.value passed in) + (refund leftover from current delivery) * 3) Only executes after `receiveWormholeMessages` is completed (and thus does not return a sequence number) * * The refund from the delivery currently in progress will not be sent to the user; it will instead * be paid to the delivery provider to perform the instruction specified here * * Publishes an instruction for the delivery provider at `deliveryProviderAddress` * to relay a payload and VAAs specified by `vaaKeys` to the address `targetAddress` on chain `targetChain` * with `msg.value` equal to * receiverValue + (arbitrary amount that is paid for by paymentForExtraReceiverValue of this chain's wei) in targetChain wei. * * Any refunds (from leftover gas) will be sent to `refundAddress` on chain `refundChain` * `targetAddress` must implement the IWormholeReceiver interface * * The following equation must be satisfied (sum_f indicates summing over all forwards requested in `receiveWormholeMessages`): * (refund amount from current execution of receiveWormholeMessages) + sum_f [msg.value_f] * >= sum_f [quoteDeliveryPrice(targetChain_f, receiverValue_f, encodedExecutionParameters_f, deliveryProviderAddress_f) + paymentForExtraReceiverValue_f] * * The difference between the two sides of the above inequality will be added to `paymentForExtraReceiverValue` of the first forward requested * * @param targetChain in Wormhole Chain ID format * @param targetAddress address to call on targetChain (that implements IWormholeReceiver), in Wormhole bytes32 format * @param payload arbitrary bytes to pass in as parameter in call to `targetAddress` * @param receiverValue msg.value that delivery provider should pass in for call to `targetAddress` (in targetChain currency units) * @param paymentForExtraReceiverValue amount (in current chain currency units) to spend on extra receiverValue * (in addition to the `receiverValue` specified) * @param encodedExecutionParameters encoded information on how to execute delivery that may impact pricing * e.g. for version EVM_V1, this is a struct that encodes the `gasLimit` with which to call `targetAddress` * @param refundChain The chain to deliver any refund to, in Wormhole Chain ID format * @param refundAddress The address on `refundChain` to deliver any refund to, in Wormhole bytes32 format * @param deliveryProviderAddress The address of the desired delivery provider's implementation of IDeliveryProvider * @param vaaKeys Additional VAAs to pass in as parameter in call to `targetAddress` * @param consistencyLevel Consistency level with which to publish the delivery instructions - see * https://book.wormhole.com/wormhole/3_coreLayerContracts.html?highlight=consistency#consistency-levels */ function forward( uint16 targetChain, bytes32 targetAddress, bytes memory payload, uint256 receiverValue, uint256 paymentForExtraReceiverValue, bytes memory encodedExecutionParameters, uint16 refundChain, bytes32 refundAddress, address deliveryProviderAddress, VaaKey[] memory vaaKeys, uint8 consistencyLevel ) external payable; /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Requests a previously published delivery instruction to be redelivered * (e.g. with a different delivery provider) * * This function must be called with `msg.value` equal to * quoteEVMDeliveryPrice(targetChain, newReceiverValue, newGasLimit, newDeliveryProviderAddress) * * @notice *** This will only be able to succeed if the following is true ** * - newGasLimit >= gas limit of the old instruction * - newReceiverValue >= receiver value of the old instruction * - newDeliveryProvider's `targetChainRefundPerGasUnused` >= old relay provider's `targetChainRefundPerGasUnused` * * @param deliveryVaaKey VaaKey identifying the wormhole message containing the * previously published delivery instructions * @param targetChain The target chain that the original delivery targeted. Must match targetChain from original delivery instructions * @param newReceiverValue new msg.value that delivery provider should pass in for call to `targetAddress` (in targetChain currency units) * @param newGasLimit gas limit with which to call `targetAddress`. Any units of gas unused will be refunded according to the * `targetChainRefundPerGasUnused` rate quoted by the delivery provider, to the refund chain and address specified in the original request * @param newDeliveryProviderAddress The address of the desired delivery provider's implementation of IDeliveryProvider * @return sequence sequence number of published VAA containing redelivery instructions * * @notice *** This will only be able to succeed if the following is true ** * - newGasLimit >= gas limit of the old instruction * - newReceiverValue >= receiver value of the old instruction * - newDeliveryProvider's `targetChainRefundPerGasUnused` >= old relay provider's `targetChainRefundPerGasUnused` */ function resendToEvm( VaaKey memory deliveryVaaKey, uint16 targetChain, uint256 newReceiverValue, uint256 newGasLimit, address newDeliveryProviderAddress ) external payable returns (uint64 sequence); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Requests a previously published delivery instruction to be redelivered * * * This function must be called with `msg.value` equal to * quoteDeliveryPrice(targetChain, newReceiverValue, newEncodedExecutionParameters, newDeliveryProviderAddress) * * @param deliveryVaaKey VaaKey identifying the wormhole message containing the * previously published delivery instructions * @param targetChain The target chain that the original delivery targeted. Must match targetChain from original delivery instructions * @param newReceiverValue new msg.value that delivery provider should pass in for call to `targetAddress` (in targetChain currency units) * @param newEncodedExecutionParameters new encoded information on how to execute delivery that may impact pricing * e.g. for version EVM_V1, this is a struct that encodes the `gasLimit` with which to call `targetAddress` * @param newDeliveryProviderAddress The address of the desired delivery provider's implementation of IDeliveryProvider * @return sequence sequence number of published VAA containing redelivery instructions * * @notice *** This will only be able to succeed if the following is true ** * - (For EVM_V1) newGasLimit >= gas limit of the old instruction * - newReceiverValue >= receiver value of the old instruction * - (For EVM_V1) newDeliveryProvider's `targetChainRefundPerGasUnused` >= old relay provider's `targetChainRefundPerGasUnused` */ function resend( VaaKey memory deliveryVaaKey, uint16 targetChain, uint256 newReceiverValue, bytes memory newEncodedExecutionParameters, address newDeliveryProviderAddress ) external payable returns (uint64 sequence); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Returns the price to request a relay to chain `targetChain`, using the default delivery provider * * @param targetChain in Wormhole Chain ID format * @param receiverValue msg.value that delivery provider should pass in for call to `targetAddress` (in targetChain currency units) * @param gasLimit gas limit with which to call `targetAddress`. * @return nativePriceQuote Price, in units of current chain currency, that the delivery provider charges to perform the relay * @return targetChainRefundPerGasUnused amount of target chain currency that will be refunded per unit of gas unused, * if a refundAddress is specified */ function quoteEVMDeliveryPrice( uint16 targetChain, uint256 receiverValue, uint256 gasLimit ) external view returns (uint256 nativePriceQuote, uint256 targetChainRefundPerGasUnused); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Returns the price to request a relay to chain `targetChain`, using delivery provider `deliveryProviderAddress` * * @param targetChain in Wormhole Chain ID format * @param receiverValue msg.value that delivery provider should pass in for call to `targetAddress` (in targetChain currency units) * @param gasLimit gas limit with which to call `targetAddress`. * @param deliveryProviderAddress The address of the desired delivery provider's implementation of IDeliveryProvider * @return nativePriceQuote Price, in units of current chain currency, that the delivery provider charges to perform the relay * @return targetChainRefundPerGasUnused amount of target chain currency that will be refunded per unit of gas unused, * if a refundAddress is specified */ function quoteEVMDeliveryPrice( uint16 targetChain, uint256 receiverValue, uint256 gasLimit, address deliveryProviderAddress ) external view returns (uint256 nativePriceQuote, uint256 targetChainRefundPerGasUnused); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Returns the price to request a relay to chain `targetChain`, using delivery provider `deliveryProviderAddress` * * @param targetChain in Wormhole Chain ID format * @param receiverValue msg.value that delivery provider should pass in for call to `targetAddress` (in targetChain currency units) * @param encodedExecutionParameters encoded information on how to execute delivery that may impact pricing * e.g. for version EVM_V1, this is a struct that encodes the `gasLimit` with which to call `targetAddress` * @param deliveryProviderAddress The address of the desired delivery provider's implementation of IDeliveryProvider * @return nativePriceQuote Price, in units of current chain currency, that the delivery provider charges to perform the relay * @return encodedExecutionInfo encoded information on how the delivery will be executed * e.g. for version EVM_V1, this is a struct that encodes the `gasLimit` and `targetChainRefundPerGasUnused` * (which is the amount of target chain currency that will be refunded per unit of gas unused, * if a refundAddress is specified) */ function quoteDeliveryPrice( uint16 targetChain, uint256 receiverValue, bytes memory encodedExecutionParameters, address deliveryProviderAddress ) external view returns (uint256 nativePriceQuote, bytes memory encodedExecutionInfo); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Returns the (extra) amount of target chain currency that `targetAddress` * will be called with, if the `paymentForExtraReceiverValue` field is set to `currentChainAmount` * * @param targetChain in Wormhole Chain ID format * @param currentChainAmount The value that `paymentForExtraReceiverValue` will be set to * @param deliveryProviderAddress The address of the desired delivery provider's implementation of IDeliveryProvider * @return targetChainAmount The amount such that if `targetAddress` will be called with `msg.value` equal to * receiverValue + targetChainAmount */ function quoteNativeForChain( uint16 targetChain, uint256 currentChainAmount, address deliveryProviderAddress ) external view returns (uint256 targetChainAmount); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Returns the address of the current default delivery provider * @return deliveryProvider The address of (the default delivery provider)'s contract on this source * chain. This must be a contract that implements IDeliveryProvider. */ function getDefaultDeliveryProvider() external view returns (address deliveryProvider); } /// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| \\\ /** * @title IWormholeRelayerDelivery * @notice The interface to execute deliveries. Only relevant for Delivery Providers */ interface IWormholeRelayerDelivery is IWormholeRelayerBase { /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /// ------------------------------------------------------------- ENUM -------------------------------------------------------------- \\\ /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Represents the possible statuses of a delivery. */ enum DeliveryStatus { SUCCESS, RECEIVER_FAILURE, FORWARD_REQUEST_FAILURE, FORWARD_REQUEST_SUCCESS } /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice Represents the possible statuses of a refund after a delivery attempt. */ enum RefundStatus { REFUND_SENT, REFUND_FAIL, CROSS_CHAIN_REFUND_SENT, CROSS_CHAIN_REFUND_FAIL_PROVIDER_NOT_SUPPORTED, CROSS_CHAIN_REFUND_FAIL_NOT_ENOUGH } /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /// ------------------------------------------------------------- EVENT ------------------------------------------------------------- \\\ /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @custom:member recipientContract - The target contract address * @custom:member sourceChain - The chain which this delivery was requested from (in wormhole * ChainID format) * @custom:member sequence - The wormhole sequence number of the delivery VAA on the source chain * corresponding to this delivery request * @custom:member deliveryVaaHash - The hash of the delivery VAA corresponding to this delivery * request * @custom:member gasUsed - The amount of gas that was used to call your target contract * @custom:member status: * - RECEIVER_FAILURE, if the target contract reverts * - SUCCESS, if the target contract doesn't revert and no forwards were requested * - FORWARD_REQUEST_FAILURE, if the target contract doesn't revert, forwards were requested, * but provided/leftover funds were not sufficient to cover them all * - FORWARD_REQUEST_SUCCESS, if the target contract doesn't revert and all forwards are covered * @custom:member additionalStatusInfo: * - If status is SUCCESS or FORWARD_REQUEST_SUCCESS, then this is empty. * - If status is RECEIVER_FAILURE, this is `RETURNDATA_TRUNCATION_THRESHOLD` bytes of the * return data (i.e. potentially truncated revert reason information). * - If status is FORWARD_REQUEST_FAILURE, this is also the revert data - the reason the forward failed. * This will be either an encoded Cancelled, DeliveryProviderReverted, or DeliveryProviderPaymentFailed error * @custom:member refundStatus - Result of the refund. REFUND_SUCCESS or REFUND_FAIL are for * refunds where targetChain=refundChain; the others are for targetChain!=refundChain, * where a cross chain refund is necessary * @custom:member overridesInfo: * - If not an override: empty bytes array * - Otherwise: An encoded `DeliveryOverride` */ event Delivery( address indexed recipientContract, uint16 indexed sourceChain, uint64 indexed sequence, bytes32 deliveryVaaHash, DeliveryStatus status, uint256 gasUsed, RefundStatus refundStatus, bytes additionalStatusInfo, bytes overridesInfo ); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /// ------------------------------------------------------ EXTERNAL FUNCTION -------------------------------------------------------- \\\ /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * @notice The delivery provider calls `deliver` to relay messages as described by one delivery instruction * * The delivery provider must pass in the specified (by VaaKeys[]) signed wormhole messages (VAAs) from the source chain * as well as the signed wormhole message with the delivery instructions (the delivery VAA) * * The messages will be relayed to the target address (with the specified gas limit and receiver value) iff the following checks are met: * - the delivery VAA has a valid signature * - the delivery VAA's emitter is one of these WormholeRelayer contracts * - the delivery provider passed in at least enough of this chain's currency as msg.value (enough meaning the maximum possible refund) * - the instruction's target chain is this chain * - the relayed signed VAAs match the descriptions in container.messages (the VAA hashes match, or the emitter address, sequence number pair matches, depending on the description given) * * @param encodedVMs - An array of signed wormhole messages (all from the same source chain * transaction) * @param encodedDeliveryVAA - Signed wormhole message from the source chain's WormholeRelayer * contract with payload being the encoded delivery instruction container * @param relayerRefundAddress - The address to which any refunds to the delivery provider * should be sent * @param deliveryOverrides - Optional overrides field which must be either an empty bytes array or * an encoded DeliveryOverride struct */ function deliver( bytes[] memory encodedVMs, bytes memory encodedDeliveryVAA, address payable relayerRefundAddress, bytes memory deliveryOverrides ) external payable; } /// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| \\\ /** * @title IWormholeRelayer * @notice Interface for the primary Wormhole Relayer which aggregates the functionalities of the Delivery and Send interfaces. */ interface IWormholeRelayer is IWormholeRelayerDelivery, IWormholeRelayerSend {} uint256 constant RETURNDATA_TRUNCATION_THRESHOLD = 132; /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * Errors related to conversion and validation of EVM addresses. */ error NotAnEvmAddress(bytes32); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * Errors related to unauthorised access or usage. */ error RequesterNotWormholeRelayer(); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * Errors for when there are issues with the overrides provided. */ error InvalidOverrideGasLimit(); error InvalidOverrideReceiverValue(); error InvalidOverrideRefundPerGasUnused(); /// --------------------------------------------------------------------------------------------------------------------------------- \\\ /** * Errors related to the state and progress of the WormholeRelayer's ope... // [truncated — 52379 bytes total]
ERC20.sol 365 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/
function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(address from, address to, uint256 amount) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
// Overflow not possible: amount <= accountBalance <= totalSupply.
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
}
IERC20.sol 78 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
IERC20Metadata.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
AddressString.sol 45 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
library StringToAddress {
error InvalidAddressString();
function toAddress(string memory addressString) internal pure returns (address) {
bytes memory stringBytes = bytes(addressString);
uint160 addressNumber = 0;
uint8 stringByte;
if (stringBytes.length != 42 || stringBytes[0] != '0' || stringBytes[1] != 'x') revert InvalidAddressString();
for (uint256 i = 2; i < 42; ++i) {
stringByte = uint8(stringBytes[i]);
if ((stringByte >= 97) && (stringByte <= 102)) stringByte -= 87;
else if ((stringByte >= 65) && (stringByte <= 70)) stringByte -= 55;
else if ((stringByte >= 48) && (stringByte <= 57)) stringByte -= 48;
else revert InvalidAddressString();
addressNumber |= uint160(uint256(stringByte) << ((41 - i) << 2));
}
return address(addressNumber);
}
}
library AddressToString {
function toString(address addr) internal pure returns (string memory) {
bytes memory addressBytes = abi.encodePacked(addr);
uint256 length = addressBytes.length;
bytes memory characters = '0123456789abcdef';
bytes memory stringBytes = new bytes(2 + addressBytes.length * 2);
stringBytes[0] = '0';
stringBytes[1] = 'x';
for (uint256 i; i < length; ++i) {
stringBytes[2 + i * 2] = characters[uint8(addressBytes[i] >> 4)];
stringBytes[3 + i * 2] = characters[uint8(addressBytes[i] & 0x0f)];
}
return string(stringBytes);
}
}
ILayerZeroEndpoint.sol 112 lines
// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.5.0;
import "./ILayerZeroUserApplicationConfig.sol";
interface ILayerZeroEndpoint is ILayerZeroUserApplicationConfig {
// @notice send a LayerZero message to the specified address at a LayerZero endpoint.
// @param _dstChainId - the destination chain identifier
// @param _destination - the address on destination chain (in bytes). address length/format may vary by chains
// @param _payload - a custom bytes payload to send to the destination contract
// @param _refundAddress - if the source transaction is cheaper than the amount of value passed, refund the additional amount to this address
// @param _zroPaymentAddress - the address of the ZRO token holder who would pay for the transaction
// @param _adapterParams - parameters for custom functionality. e.g. receive airdropped native gas from the relayer on destination
function send(
uint16 _dstChainId,
bytes calldata _destination,
bytes calldata _payload,
address payable _refundAddress,
address _zroPaymentAddress,
bytes calldata _adapterParams
) external payable;
// @notice used by the messaging library to publish verified payload
// @param _srcChainId - the source chain identifier
// @param _srcAddress - the source contract (as bytes) at the source chain
// @param _dstAddress - the address on destination chain
// @param _nonce - the unbound message ordering nonce
// @param _gasLimit - the gas limit for external contract execution
// @param _payload - verified payload to send to the destination contract
function receivePayload(
uint16 _srcChainId,
bytes calldata _srcAddress,
address _dstAddress,
uint64 _nonce,
uint _gasLimit,
bytes calldata _payload
) external;
// @notice get the inboundNonce of a receiver from a source chain which could be EVM or non-EVM chain
// @param _srcChainId - the source chain identifier
// @param _srcAddress - the source chain contract address
function getInboundNonce(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (uint64);
// @notice get the outboundNonce from this source chain which, consequently, is always an EVM
// @param _srcAddress - the source chain contract address
function getOutboundNonce(uint16 _dstChainId, address _srcAddress) external view returns (uint64);
// @notice gets a quote in source native gas, for the amount that send() requires to pay for message delivery
// @param _dstChainId - the destination chain identifier
// @param _userApplication - the user app address on this EVM chain
// @param _payload - the custom message to send over LayerZero
// @param _payInZRO - if false, user app pays the protocol fee in native token
// @param _adapterParam - parameters for the adapter service, e.g. send some dust native token to dstChain
function estimateFees(
uint16 _dstChainId,
address _userApplication,
bytes calldata _payload,
bool _payInZRO,
bytes calldata _adapterParam
) external view returns (uint nativeFee, uint zroFee);
// @notice get this Endpoint's immutable source identifier
function getChainId() external view returns (uint16);
// @notice the interface to retry failed message on this Endpoint destination
// @param _srcChainId - the source chain identifier
// @param _srcAddress - the source chain contract address
// @param _payload - the payload to be retried
function retryPayload(uint16 _srcChainId, bytes calldata _srcAddress, bytes calldata _payload) external;
// @notice query if any STORED payload (message blocking) at the endpoint.
// @param _srcChainId - the source chain identifier
// @param _srcAddress - the source chain contract address
function hasStoredPayload(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool);
// @notice query if the _libraryAddress is valid for sending msgs.
// @param _userApplication - the user app address on this EVM chain
function getSendLibraryAddress(address _userApplication) external view returns (address);
// @notice query if the _libraryAddress is valid for receiving msgs.
// @param _userApplication - the user app address on this EVM chain
function getReceiveLibraryAddress(address _userApplication) external view returns (address);
// @notice query if the non-reentrancy guard for send() is on
// @return true if the guard is on. false otherwise
function isSendingPayload() external view returns (bool);
// @notice query if the non-reentrancy guard for receive() is on
// @return true if the guard is on. false otherwise
function isReceivingPayload() external view returns (bool);
// @notice get the configuration of the LayerZero messaging library of the specified version
// @param _version - messaging library version
// @param _chainId - the chainId for the pending config change
// @param _userApplication - the contract address of the user application
// @param _configType - type of configuration. every messaging library has its own convention.
function getConfig(
uint16 _version,
uint16 _chainId,
address _userApplication,
uint _configType
) external view returns (bytes memory);
// @notice get the send() LayerZero messaging library version
// @param _userApplication - the contract address of the user application
function getSendVersion(address _userApplication) external view returns (uint16);
// @notice get the lzReceive() LayerZero messaging library version
// @param _userApplication - the contract address of the user application
function getReceiveVersion(address _userApplication) external view returns (uint16);
}
IAxelarGateway.sol 196 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IAxelarGateway {
/**********\
|* Errors *|
\**********/
error NotSelf();
error NotProxy();
error InvalidCodeHash();
error SetupFailed();
error InvalidAuthModule();
error InvalidTokenDeployer();
error InvalidAmount();
error InvalidChainId();
error InvalidCommands();
error TokenDoesNotExist(string symbol);
error TokenAlreadyExists(string symbol);
error TokenDeployFailed(string symbol);
error TokenContractDoesNotExist(address token);
error BurnFailed(string symbol);
error MintFailed(string symbol);
error InvalidSetMintLimitsParams();
error ExceedMintLimit(string symbol);
/**********\
|* Events *|
\**********/
event TokenSent(
address indexed sender,
string destinationChain,
string destinationAddress,
string symbol,
uint256 amount
);
event ContractCall(
address indexed sender,
string destinationChain,
string destinationContractAddress,
bytes32 indexed payloadHash,
bytes payload
);
event ContractCallWithToken(
address indexed sender,
string destinationChain,
string destinationContractAddress,
bytes32 indexed payloadHash,
bytes payload,
string symbol,
uint256 amount
);
event Executed(bytes32 indexed commandId);
event TokenDeployed(string symbol, address tokenAddresses);
event ContractCallApproved(
bytes32 indexed commandId,
string sourceChain,
string sourceAddress,
address indexed contractAddress,
bytes32 indexed payloadHash,
bytes32 sourceTxHash,
uint256 sourceEventIndex
);
event ContractCallApprovedWithMint(
bytes32 indexed commandId,
string sourceChain,
string sourceAddress,
address indexed contractAddress,
bytes32 indexed payloadHash,
string symbol,
uint256 amount,
bytes32 sourceTxHash,
uint256 sourceEventIndex
);
event TokenMintLimitUpdated(string symbol, uint256 limit);
event OperatorshipTransferred(bytes newOperatorsData);
event Upgraded(address indexed implementation);
/********************\
|* Public Functions *|
\********************/
function sendToken(
string calldata destinationChain,
string calldata destinationAddress,
string calldata symbol,
uint256 amount
) external;
function callContract(
string calldata destinationChain,
string calldata contractAddress,
bytes calldata payload
) external;
function callContractWithToken(
string calldata destinationChain,
string calldata contractAddress,
bytes calldata payload,
string calldata symbol,
uint256 amount
) external;
function isContractCallApproved(
bytes32 commandId,
string calldata sourceChain,
string calldata sourceAddress,
address contractAddress,
bytes32 payloadHash
) external view returns (bool);
function isContractCallAndMintApproved(
bytes32 commandId,
string calldata sourceChain,
string calldata sourceAddress,
address contractAddress,
bytes32 payloadHash,
string calldata symbol,
uint256 amount
) external view returns (bool);
function validateContractCall(
bytes32 commandId,
string calldata sourceChain,
string calldata sourceAddress,
bytes32 payloadHash
) external returns (bool);
function validateContractCallAndMint(
bytes32 commandId,
string calldata sourceChain,
string calldata sourceAddress,
bytes32 payloadHash,
string calldata symbol,
uint256 amount
) external returns (bool);
/***********\
|* Getters *|
\***********/
function authModule() external view returns (address);
function tokenDeployer() external view returns (address);
function tokenMintLimit(string memory symbol) external view returns (uint256);
function tokenMintAmount(string memory symbol) external view returns (uint256);
function allTokensFrozen() external view returns (bool);
function implementation() external view returns (address);
function tokenAddresses(string memory symbol) external view returns (address);
function tokenFrozen(string memory symbol) external view returns (bool);
function isCommandExecuted(bytes32 commandId) external view returns (bool);
function adminEpoch() external view returns (uint256);
function adminThreshold(uint256 epoch) external view returns (uint256);
function admins(uint256 epoch) external view returns (address[] memory);
/*******************\
|* Admin Functions *|
\*******************/
function setTokenMintLimits(string[] calldata symbols, uint256[] calldata limits) external;
function upgrade(
address newImplementation,
bytes32 newImplementationCodeHash,
bytes calldata setupParams
) external;
/**********************\
|* External Functions *|
\**********************/
function setup(bytes calldata params) external;
function execute(bytes calldata input) external;
}
AxelarExecutable.sol 68 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { IAxelarGateway } from '../interfaces/IAxelarGateway.sol';
import { IAxelarExecutable } from '../interfaces/IAxelarExecutable.sol';
contract AxelarExecutable is IAxelarExecutable {
IAxelarGateway public immutable gateway;
constructor(address gateway_) {
if (gateway_ == address(0)) revert InvalidAddress();
gateway = IAxelarGateway(gateway_);
}
function execute(
bytes32 commandId,
string calldata sourceChain,
string calldata sourceAddress,
bytes calldata payload
) external {
bytes32 payloadHash = keccak256(payload);
if (!gateway.validateContractCall(commandId, sourceChain, sourceAddress, payloadHash))
revert NotApprovedByGateway();
_execute(sourceChain, sourceAddress, payload);
}
function executeWithToken(
bytes32 commandId,
string calldata sourceChain,
string calldata sourceAddress,
bytes calldata payload,
string calldata tokenSymbol,
uint256 amount
) external {
bytes32 payloadHash = keccak256(payload);
if (
!gateway.validateContractCallAndMint(
commandId,
sourceChain,
sourceAddress,
payloadHash,
tokenSymbol,
amount
)
) revert NotApprovedByGateway();
_executeWithToken(sourceChain, sourceAddress, payload, tokenSymbol, amount);
}
function _execute(
string calldata sourceChain,
string calldata sourceAddress,
bytes calldata payload
) internal virtual {}
function _executeWithToken(
string calldata sourceChain,
string calldata sourceAddress,
bytes calldata payload,
string calldata tokenSymbol,
uint256 amount
) internal virtual {}
}
IAxelarExecutable.sol 28 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { IAxelarGateway } from './IAxelarGateway.sol';
interface IAxelarExecutable {
error InvalidAddress();
error NotApprovedByGateway();
function gateway() external view returns (IAxelarGateway);
function execute(
bytes32 commandId,
string calldata sourceChain,
string calldata sourceAddress,
bytes calldata payload
) external;
function executeWithToken(
bytes32 commandId,
string calldata sourceChain,
string calldata sourceAddress,
bytes calldata payload,
string calldata tokenSymbol,
uint256 amount
) external;
}
IAxelarGasService.sol 211 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// This should be owned by the microservice that is paying for gas.
interface IAxelarGasService {
error NothingReceived();
error InvalidAddress();
error NotCollector();
error InvalidAmounts();
event GasPaidForContractCall(
address indexed sourceAddress,
string destinationChain,
string destinationAddress,
bytes32 indexed payloadHash,
address gasToken,
uint256 gasFeeAmount,
address refundAddress
);
event GasPaidForContractCallWithToken(
address indexed sourceAddress,
string destinationChain,
string destinationAddress,
bytes32 indexed payloadHash,
string symbol,
uint256 amount,
address gasToken,
uint256 gasFeeAmount,
address refundAddress
);
event NativeGasPaidForContractCall(
address indexed sourceAddress,
string destinationChain,
string destinationAddress,
bytes32 indexed payloadHash,
uint256 gasFeeAmount,
address refundAddress
);
event NativeGasPaidForContractCallWithToken(
address indexed sourceAddress,
string destinationChain,
string destinationAddress,
bytes32 indexed payloadHash,
string symbol,
uint256 amount,
uint256 gasFeeAmount,
address refundAddress
);
event GasPaidForExpressCallWithToken(
address indexed sourceAddress,
string destinationChain,
string destinationAddress,
bytes32 indexed payloadHash,
string symbol,
uint256 amount,
address gasToken,
uint256 gasFeeAmount,
address refundAddress
);
event NativeGasPaidForExpressCallWithToken(
address indexed sourceAddress,
string destinationChain,
string destinationAddress,
bytes32 indexed payloadHash,
string symbol,
uint256 amount,
uint256 gasFeeAmount,
address refundAddress
);
event GasAdded(
bytes32 indexed txHash,
uint256 indexed logIndex,
address gasToken,
uint256 gasFeeAmount,
address refundAddress
);
event NativeGasAdded(bytes32 indexed txHash, uint256 indexed logIndex, uint256 gasFeeAmount, address refundAddress);
event ExpressGasAdded(
bytes32 indexed txHash,
uint256 indexed logIndex,
address gasToken,
uint256 gasFeeAmount,
address refundAddress
);
event NativeExpressGasAdded(
bytes32 indexed txHash,
uint256 indexed logIndex,
uint256 gasFeeAmount,
address refundAddress
);
// This is called on the source chain before calling the gateway to execute a remote contract.
function payGasForContractCall(
address sender,
string calldata destinationChain,
string calldata destinationAddress,
bytes calldata payload,
address gasToken,
uint256 gasFeeAmount,
address refundAddress
) external;
// This is called on the source chain before calling the gateway to execute a remote contract.
function payGasForContractCallWithToken(
address sender,
string calldata destinationChain,
string calldata destinationAddress,
bytes calldata payload,
string calldata symbol,
uint256 amount,
address gasToken,
uint256 gasFeeAmount,
address refundAddress
) external;
// This is called on the source chain before calling the gateway to execute a remote contract.
function payNativeGasForContractCall(
address sender,
string calldata destinationChain,
string calldata destinationAddress,
bytes calldata payload,
address refundAddress
) external payable;
// This is called on the source chain before calling the gateway to execute a remote contract.
function payNativeGasForContractCallWithToken(
address sender,
string calldata destinationChain,
string calldata destinationAddress,
bytes calldata payload,
string calldata symbol,
uint256 amount,
address refundAddress
) external payable;
// This is called on the source chain before calling the gateway to execute a remote contract.
function payGasForExpressCallWithToken(
address sender,
string calldata destinationChain,
string calldata destinationAddress,
bytes calldata payload,
string calldata symbol,
uint256 amount,
address gasToken,
uint256 gasFeeAmount,
address refundAddress
) external;
// This is called on the source chain before calling the gateway to execute a remote contract.
function payNativeGasForExpressCallWithToken(
address sender,
string calldata destinationChain,
string calldata destinationAddress,
bytes calldata payload,
string calldata symbol,
uint256 amount,
address refundAddress
) external payable;
function addGas(
bytes32 txHash,
uint256 txIndex,
address gasToken,
uint256 gasFeeAmount,
address refundAddress
) external;
function addNativeGas(
bytes32 txHash,
uint256 logIndex,
address refundAddress
) external payable;
function addExpressGas(
bytes32 txHash,
uint256 txIndex,
address gasToken,
uint256 gasFeeAmount,
address refundAddress
) external;
function addNativeExpressGas(
bytes32 txHash,
uint256 logIndex,
address refundAddress
) external payable;
function collectFees(
address payable receiver,
address[] calldata tokens,
uint256[] calldata amounts
) external;
function refund(
address payable receiver,
address token,
uint256 amount
) external;
function gasCollector() external returns (address);
}
ILayerZeroUserApplicationConfig.sol 25 lines
// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.5.0;
interface ILayerZeroUserApplicationConfig {
// @notice set the configuration of the LayerZero messaging library of the specified version
// @param _version - messaging library version
// @param _chainId - the chainId for the pending config change
// @param _configType - type of configuration. every messaging library has its own convention.
// @param _config - configuration in the bytes. can encode arbitrary content.
function setConfig(uint16 _version, uint16 _chainId, uint _configType, bytes calldata _config) external;
// @notice set the send() LayerZero messaging library version to _version
// @param _version - new messaging library version
function setSendVersion(uint16 _version) external;
// @notice set the lzReceive() LayerZero messaging library version to _version
// @param _version - new messaging library version
function setReceiveVersion(uint16 _version) external;
// @notice Only when the UA needs to resume the message flow in blocking mode and clear the stored payload
// @param _srcChainId - the chainId of the source chain
// @param _srcAddress - the contract address of the source contract at the source chain
function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress) external;
}
Read Contract
EETH 0xa846ffef → address
ENDPOINT 0x6fad06f5 → address
GAS_SERVICE 0x997f35eb → address
WORMHOLE_RELAYER 0x0f1f9cfc → address
addressThis 0xc8e76982 → string
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
core 0xf2f4eb26 → address
decimals 0x313ce567 → uint8
eethZapper 0x6c87babd → address
estimateGasForLayerZero 0xb7edaaf6 → uint256
estimateGasForWormhole 0x22282f03 → uint256
gateway 0x116191b6 → address
name 0x06fdde03 → string
nonfungiblePositionManager 0xb44a2722 → address
pool 0x16f0115b → address
privilegedSellers 0xf67bae7e → bool
seenDeliveryVaaHashes 0x180f6cc2 → bool
swapHandler 0x8a53aaac → address
symbol 0x95d89b41 → string
team 0x85f2aef2 → address
totalSupply 0x18160ddd → uint256
Write Contract 18 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address spender
uint256 amount
returns: bool
bridgeViaAxelar 0xfacea41e
string _destinationChain
address _from
address _to
uint256 _amount
address _feeRefundAddress
bridgeViaLayerZero 0x25c7e35b
uint16 _dstChainId
address _from
address _to
uint256 _amount
address _feeRefundAddress
address _zroPaymentAddress
bytes _adapterParams
bridgeViaWormhole 0xb9631114
uint16 _targetChain
address _from
address _to
uint256 _amount
address _feeRefundAddress
uint256 _gasLimit
burn 0x3390ba94
address _user
uint256 _amount
address _desiredOutToken
address _recipient
uint256 _slippage
returns: uint256
burnPrivilege 0xe049f5cb
uint256 _amount
address _desiredOutToken
address _recipient
uint256 _slippage
returns: uint256
decreaseAllowance 0xa457c2d7
address spender
uint256 subtractedValue
returns: bool
execute 0x49160658
bytes32 commandId
string sourceChain
string sourceAddress
bytes payload
executeWithToken 0x1a98b2e0
bytes32 commandId
string sourceChain
string sourceAddress
bytes payload
string tokenSymbol
uint256 amount
increaseAllowance 0x39509351
address spender
uint256 addedValue
returns: bool
lzReceive 0x001d3567
uint16 _srcChainId
bytes _srcAddress
uint64
bytes _payload
mint 0x94bf804d
uint256 _amount
address _token
returns: uint256
receiveWormholeMessages 0x529dca32
bytes _payload
bytes[]
bytes32 _sourceAddress
uint16 _srcChainId
bytes32 _deliveryHash
setPool 0x4437152a
address _pool
setPrivilegedSeller 0x189a5fdd
address _futureProtocol
bool enable
transfer 0xa9059cbb
address to
uint256 amount
returns: bool
transferFrom 0x23b872dd
address from
address to
uint256 amount
returns: bool
utilisePositiveRebasing 0xd7f895de
No parameters
returns: uint256
Recent Transactions
No transactions found for this address