Address Contract Partially Verified
Address
0x4C278Bf25B7daE52e2179DD76Ff9fB45d18a1510
Balance
0 ETH
Nonce
1
Code Size
21435 bytes
Creator
0xfBeFd916...478E at tx 0xd7de5443...e37f23
Indexed Transactions
0
Contract Bytecode
21435 bytes
0x608060405234801561001057600080fd5b50600436106103425760003560e01c80636e5d6bea116101b8578063be3b625b11610104578063db6fff8c116100a2578063f2c54fe81161007c578063f2c54fe814610ee1578063f2fde38b14610f0d578063f3b8379114610f33578063f3f5141514610f5057610342565b8063db6fff8c14610e81578063e77772fe14610ead578063ec47de2a14610eb557610342565b8063cd596583116100de578063cd59658314610c4b578063d0342acd14610c53578063d522cfd714610c81578063d740548114610dbd57610342565b8063be3b625b14610b59578063c2173d4314610b61578063c534576114610b8757610342565b80639a4a439511610171578063a4c0ed361161014b578063a4c0ed3614610a4e578063ab3a25d914610ad1578063ad58bdd114610afd578063ae813e9f14610b3357610342565b80639a4a4395146109d75780639cb7595a146109f4578063a4b1c24314610a2857610342565b80636e5d6bea1461088b5780637610722f146108b15780637837cf91146108d7578063867f7a4d14610903578063871c0760146109c75780638da5cb5b146109cf57610342565b80632803212f116102925780633e6968b611610230578063593399821161020a57806359339982146107e257806361c04f84146107ff57806364696f971461082557806369ffa08a1461085d57610342565b80633e6968b61461078f57806340f8dd8614610797578063437764df146107bd57610342565b80632d70061f1161026c5780632d70061f146106f35780632f73a9f814610735578063392e53cd1461075b5780633a50bc871461076357610342565b80632803212f1461058e5780632ae87cdd146105ba5780632c3500a6146106a057610342565b806310775238116102ff578063194153d3116102d9578063194153d3146104e657806321d3ccb81461050c57806326aa101f14610532578063272255bb1461055857610342565b8063107752381461044a578063125e4cfb1461048a57806316ef1913146104c057610342565b806301e4f53a1461034757806301fcc1d314610375578063032f693f146103a15780630950d515146103d95780630b26cf66146103f65780630b71a4a71461041c575b600080fd5b6103736004803603604081101561035d57600080fd5b506001600160a01b038135169060200135610f76565b005b6103736004803603604081101561038b57600080fd5b506001600160a01b038135169060200135610fb5565b6103c7600480360360208110156103b757600080fd5b50356001600160a01b0316611054565b60408051918252519081900360200190f35b610373600480360360208110156103ef57600080fd5b50356110ac565b6103736004803603602081101561040c57600080fd5b50356001600160a01b0316611155565b6103736004803603604081101561043257600080fd5b506001600160a01b0381358116916020013516611169565b6104766004803603604081101561046057600080fd5b506001600160a01b0381351690602001356112a5565b604080519115158252519081900360200190f35b610373600480360360608110156104a057600080fd5b506001600160a01b03813581169160208101359091169060400135611318565b6103c7600480360360208110156104d657600080fd5b50356001600160a01b0316611352565b6103c7600480360360208110156104fc57600080fd5b50356001600160a01b03166113af565b6103736004803603602081101561052257600080fd5b50356001600160a01b031661140a565b6104766004803603602081101561054857600080fd5b50356001600160a01b031661141f565b6103736004803603606081101561056e57600080fd5b506001600160a01b03813581169160208101359091169060400135611432565b610373600480360360408110156105a457600080fd5b506001600160a01b038135169060200135611455565b610373600480360360c08110156105d057600080fd5b6001600160a01b038235169190810190604081016020820135600160201b8111156105fa57600080fd5b82018360208201111561060c57600080fd5b803590602001918460018302840111600160201b8311171561062d57600080fd5b919390929091602081019035600160201b81111561064a57600080fd5b82018360208201111561065c57600080fd5b803590602001918460018302840111600160201b8311171561067d57600080fd5b919350915060ff813516906001600160a01b036020820135169060400135611524565b61047660048036036101408110156106b757600080fd5b506001600160a01b0381358116916020810135821691604082019160a081019160e0820135916101008101358216916101209091013516611556565b6107196004803603602081101561070957600080fd5b50356001600160a01b031661172c565b604080516001600160a01b039092168252519081900360200190f35b6103736004803603602081101561074b57600080fd5b50356001600160a01b0316611792565b61047661179a565b6104766004803603604081101561077957600080fd5b506001600160a01b0381351690602001356117eb565b6103c7611841565b6103c7600480360360208110156107ad57600080fd5b50356001600160a01b031661184a565b6107c56118a9565b604080516001600160e01b03199092168252519081900360200190f35b610476600480360360208110156107f857600080fd5b50356118b4565b6107196004803603602081101561081557600080fd5b50356001600160a01b0316611907565b6103736004803603606081101561083b57600080fd5b506001600160a01b038135811691602081013582169160409091013516611970565b6103736004803603604081101561087357600080fd5b506001600160a01b0381358116916020013516611a66565b610373600480360360208110156108a157600080fd5b50356001600160a01b0316611b0e565b6103c7600480360360208110156108c757600080fd5b50356001600160a01b0316611b1f565b610373600480360360408110156108ed57600080fd5b506001600160a01b038135169060200135611b79565b6103736004803603608081101561091957600080fd5b6001600160a01b03823581169260208101359091169160408201359190810190608081016060820135600160201b81111561095357600080fd5b82018360208201111561096557600080fd5b803590602001918460018302840111600160201b8311171561098657600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550611c51945050505050565b610719611c7b565b610719611cd2565b610373600480360360208110156109ed57600080fd5b5035611d29565b6109fc611f17565b6040805167ffffffffffffffff9485168152928416602084015292168183015290519081900360600190f35b6103c760048036036020811015610a3e57600080fd5b50356001600160a01b0316611f22565b61047660048036036060811015610a6457600080fd5b6001600160a01b0382351691602081013591810190606081016040820135600160201b811115610a9357600080fd5b820183602082011115610aa557600080fd5b803590602001918460018302840111600160201b83111715610ac657600080fd5b509092509050611f76565b6103c760048036036040811015610ae757600080fd5b506001600160a01b038135169060200135611fe4565b61037360048036036060811015610b1357600080fd5b506001600160a01b0381358116916020810135909116906040013561204a565b61047660048036036020811015610b4957600080fd5b50356001600160a01b0316612058565b6103c76120b1565b61047660048036036020811015610b7757600080fd5b50356001600160a01b03166120ff565b61037360048036036080811015610b9d57600080fd5b6001600160a01b03823581169260208101359091169160408201359190810190608081016060820135600160201b811115610bd757600080fd5b820183602082011115610be957600080fd5b803590602001918460018302840111600160201b83111715610c0a57600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092955061212c945050505050565b610719612173565b61037360048036036040811015610c6957600080fd5b506001600160a01b03813581169160200135166121ca565b610373600480360360e0811015610c9757600080fd5b6001600160a01b038235169190810190604081016020820135600160201b811115610cc157600080fd5b820183602082011115610cd357600080fd5b803590602001918460018302840111600160201b83111715610cf457600080fd5b919390929091602081019035600160201b811115610d1157600080fd5b820183602082011115610d2357600080fd5b803590602001918460018302840111600160201b83111715610d4457600080fd5b9193909260ff833516926001600160a01b03602082013516926040820135929091608081019060600135600160201b811115610d7f57600080fd5b820183602082011115610d9157600080fd5b803590602001918460018302840111600160201b83111715610db257600080fd5b5090925090506123ac565b61037360048036036080811015610dd357600080fd5b6001600160a01b03823581169260208101359091169160408201359190810190608081016060820135600160201b811115610e0d57600080fd5b820183602082011115610e1f57600080fd5b803590602001918460018302840111600160201b83111715610e4057600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550612422945050505050565b61037360048036036040811015610e9757600080fd5b506001600160a01b03813516906020013561242e565b6107196124cb565b61037360048036036040811015610ecb57600080fd5b506001600160a01b038135169060200135612522565b6103c760048036036040811015610ef757600080fd5b506001600160a01b0381351690602001356125c3565b61037360048036036020811015610f2357600080fd5b50356001600160a01b031661262c565b61037360048036036020811015610f4957600080fd5b503561263d565b6103c760048036036020811015610f6657600080fd5b50356001600160a01b031661264e565b610fb18233836000805b506040519080825280601f01601f191660200182016040528015610fab576020820181803683370190505b506126a4565b5050565b610fbd612805565b610fc68261141f565b610fcf57600080fd5b801580610fee5750600081118015610fee5750610feb8261184a565b81105b610ff757600080fd5b60408051700caf0cac6eae8d2dedc9ac2f0a0cae4a8f607b1b60208083019190915260609490941b6001600160601b0319166031820152815180820360250181526045909101825280519084012060009081529283905290912055565b60408051670dac2f0a0cae4a8f60c31b6020808301919091526001600160601b0319606085901b1660288301528251601c818403018152603c909201835281519181019190912060009081529081905220545b919050565b6110b461282c565b6110bd816118b4565b156110c757600080fd5b60006110d2826128d6565b905060006110df8361292f565b905060006110ec8461298c565b90506110f7846129db565b611102838383612a34565b604080516001600160a01b03808616825284166020820152808201839052905185917f07b5483b8e4bd8ea240a474d5117738350e7d431e3668c48a97910b0b397796a919081900360600190a250505050565b61115d612805565b61116681612a55565b50565b611171612805565b61117a8161141f565b1561118457600080fd5b600061118f82611907565b6001600160a01b0316146111a257600080fd5b60006111ad8361172c565b6001600160a01b0316146111c057600080fd5b604080516340c10f1960e01b81523060048201526001602482015290516001600160a01b038316916340c10f199160448083019260209291908290030181600087803b15801561120f57600080fd5b505af1158015611223573d6000803e3d6000fd5b505050506040513d602081101561123957600080fd5b505060408051630852cd8d60e31b81526001600482015290516001600160a01b038316916342966c6891602480830192600092919082900301818387803b15801561128357600080fd5b505af1158015611297573d6000803e3d6000fd5b50505050610fb18282612ad1565b6000806112c3836112bd866112b8611841565b611fe4565b90612bcc565b905060006112d1600061264e565b1180156112e65750806112e38561264e565b10155b80156112fa57506112f684611054565b8311155b801561130e575061130a84611f22565b8310155b9150505b92915050565b61132061282c565b600061132b8461172c565b90506113368161141f565b61133f57600080fd5b61134c8160008585612c2d565b50505050565b60408051700caf0cac6eae8d2dedc9ac2f0a0cae4a8f607b1b60208083019190915260609390931b6001600160601b0319166031820152815180820360250181526045909101825280519083012060009081529182905290205490565b604080516e6d65646961746f7242616c616e636560881b60208083019190915260609390931b6001600160601b031916602f820152815180820360230181526043909101825280519083012060009081529182905290205490565b33301461141657600080fd5b61116681612cb8565b60008061142b83611f22565b1192915050565b61143a61282c565b61144383612d34565b6114508360018484612c2d565b505050565b61145d612805565b6114668261141f565b61146f57600080fd5b61147882611054565b811180611483575080155b61148c57600080fd5b604080516919185a5b1e531a5b5a5d60b21b6020808301919091526001600160601b0319606086901b16602a8301528251601e818403018152603e83018085528151918301919091206000908152918290529083902084905583905290516001600160a01b038416917fca0b3dabefdbd8c72c0a9cf4a6e9d107da897abf036ef3f3f3b010cdd25941599190819003605e0190a25050565b61152c61282c565b600061153c898989898989612df0565b905061154b8160008585612c2d565b505050505050505050565b60408051600481526024810182526020810180516001600160e01b03166337ef410160e11b1781529151815160009384936060933093919290918291908083835b602083106115b65780518252601f199092019160209182019101611597565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114611618576040519150601f19603f3d011682016040523d82523d6000602084013e61161d565b606091505b5091509150811580611659575080516020148015611659575080806020019051602081101561164b57600080fd5b50516001600160a01b031633145b8061166357503330145b61166c57600080fd5b61167461179a565b1561167e57600080fd5b6116878a612a55565b6116908961313e565b6116c460008960038060200260405190810160405280929190826003602002808284376000920191909152506131a8915050565b6040805180820182526116f391600091908a9060029083908390808284376000920191909152506132fc915050565b6116fc866133eb565b6117058561344c565b61170e84612cb8565b611716613514565b61171e61179a565b9a9950505050505050505050565b604080516f686f6d65546f6b656e4164647265737360801b60208083019190915260609390931b6001600160601b03191660308201528151808203602401815260449091018252805190830120600090815260029092529020546001600160a01b031690565b611416612805565b7f0a6f646cd611241d8073675e00d1a1ff700fbf1b53fcf473de56d1e6e4b714ba60005260046020527f078d888f9b66f3f8bfa10909e31f1e16240db73449f0500afdbbe3a70da457cc5460ff1690565b600080611803836112bd866117fe611841565b6125c3565b90506000611811600061184a565b1180156118265750806118238561184a565b10155b801561130e575061183684611352565b909211159392505050565b62015180420490565b6040805172195e1958dd5d1a5bdb91185a5b1e531a5b5a5d606a1b60208083019190915260609390931b6001600160601b0319166033820152815180820360270181526047909101825280519083012060009081529182905290205490565b6358a8b61360e11b90565b604080516b1b595cdcd859d9519a5e195960a21b602080830191909152602c80830185905283518084039091018152604c909201835281519181019190912060009081526004909152205460ff16919050565b6040805172666f726569676e546f6b656e4164647265737360681b60208083019190915260609390931b6001600160601b03191660338201528151808203602701815260479091018252805190830120600090815260029092529020546001600160a01b031690565b306001600160a01b0316636fde82026040518163ffffffff1660e01b815260040160206040518083038186803b1580156119a957600080fd5b505afa1580156119bd573d6000803e3d6000fd5b505050506040513d60208110156119d357600080fd5b50516001600160a01b031633146119e957600080fd5b826001600160a01b03166369ffa08a83836040518363ffffffff1660e01b815260040180836001600160a01b03168152602001826001600160a01b0316815260200192505050600060405180830381600087803b158015611a4957600080fd5b505af1158015611a5d573d6000803e3d6000fd5b50505050505050565b306001600160a01b0316636fde82026040518163ffffffff1660e01b815260040160206040518083038186803b158015611a9f57600080fd5b505afa158015611ab3573d6000803e3d6000fd5b505050506040513d6020811015611ac957600080fd5b50516001600160a01b03163314611adf57600080fd5b6001600160a01b0382161580611afb5750611af98261141f565b155b611b0457600080fd5b610fb1828261356b565b611b16612805565b6111668161313e565b600080611b2b83611054565b90506000611b388461264e565b90506000611b48856112b8611841565b90506000818311611b5a576000611b5e565b8183035b9050808410611b6d5780611b6f565b835b9695505050505050565b611b81612805565b611b8a8261141f565b611b9357600080fd5b611b9c82611352565b811180611ba7575080155b611bb057600080fd5b6040805172195e1958dd5d1a5bdb91185a5b1e531a5b5a5d606a1b6020808301919091526001600160601b0319606086901b16603383015282516027818403018152604783018085528151918301919091206000908152918290529083902084905583905290516001600160a01b038416917f4c177b42dbe934b3abbc0208c11a42e46589983431616f1710ab19969c5ed62e919081900360670190a25050565b611c5961282c565b611c6284612d34565b611c6f8460018585612c2d565b61134c838584846135a5565b7f98aa806e31e94a687a31c65769cb99670064dd7f5a87526da075c5fb4eab988060005260026020527f0c1206883be66049a02d4937078367c00b3d71dd1a9465df969363c6ddeac96d546001600160a01b031690565b7f02016836a56b71f0d02689e69e326f4f4c1b9057164ef592671cf0d37c8040c060005260026020527fb7802e97e87ef2842a6cce7da7ffaeaedaa2f61a6a7870b23d9d01fc9b73712e546001600160a01b031690565b611d31612173565b6001600160a01b031663cb08a10c826040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015611d7457600080fd5b505afa158015611d88573d6000803e3d6000fd5b505050506040513d6020811015611d9e57600080fd5b505115611daa57600080fd5b30611db3612173565b6001600160a01b0316633f9a8e7e836040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015611df657600080fd5b505afa158015611e0a573d6000803e3d6000fd5b505050506040513d6020811015611e2057600080fd5b50516001600160a01b031614611e3557600080fd5b611e3d611c7b565b6001600160a01b0316611e4e612173565b6001600160a01b0316634a610b04836040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015611e9157600080fd5b505afa158015611ea5573d6000803e3d6000fd5b505050506040513d6020811015611ebb57600080fd5b50516001600160a01b031614611ed057600080fd5b6040805160248082018490528251808303909101815260449091019091526020810180516001600160e01b0316630950d51560e01b9081179091529061134c816001613712565b600260016000909192565b60408051670dad2dca0cae4a8f60c31b60208083019190915260609390931b6001600160601b03191660288201528151808203601c018152603c909101825280519083012060009081529182905290205490565b6000611f8061381d565b611fd8576040805160008152602081019091528560148410611fc857506078356014841115611fc8576040519150601460643503808352806098602085013782016020016040525b611fd53388838986613842565b50505b5060015b949350505050565b604080516f746f74616c5370656e7450657244617960801b60208083019190915260609490941b6001600160601b031916603082015260448082019390935281518082039093018352606401815281519183019190912060009081529182905290205490565b611450838383600080610f80565b604080516861636b4465706c6f7960b81b60208083019190915260609390931b6001600160601b03191660298201528151808203601d018152603d90910182528051908301206000908152600490925290205460ff1690565b7f2dfd6c9f781bb6bbb5369c114e949b69ebb440ef3d4dd6b2836225eb1dc3a2be60009081526020527f2de0d2cdc19d356cb53b5984f91bfd3b31fe0c678a0d190a6db39274bb34753f5490565b600061210a8261141f565b80156113125750600061211c83611907565b6001600160a01b03161492915050565b61213461282c565b600061213f8561172c565b905061214a8161141f565b61215357600080fd5b6121608160008686612c2d565b61216c848285856135a5565b5050505050565b7f811bbb11e8899da471f0e69a3ed55090fc90215227fc5fb1cb0d6e962ea7b74f60005260026020527fb4ed64697d3ef8518241966f7c6f28b0d72f20f51198717d198d2d55076c593d546001600160a01b031690565b306001600160a01b0316636fde82026040518163ffffffff1660e01b815260040160206040518083038186803b15801561220357600080fd5b505afa158015612217573d6000803e3d6000fd5b505050506040513d602081101561222d57600080fd5b50516001600160a01b0316331461224357600080fd5b806001600160a01b03811661225757600080fd5b612260836120ff565b61226957600080fd5b6000836001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156122b857600080fd5b505afa1580156122cc573d6000803e3d6000fd5b505050506040513d60208110156122e257600080fd5b5051905060006122f1856113af565b90508082116122ff57600080fd5b808203600061230d87611b1f565b90506000811161231c57600080fd5b80821115612328578091505b61233a87612334611841565b84613907565b600061234588613985565b9050606061238360008a8a8786846040519080825280601f01601f19166020018201604052801561237d576020820181803683370190505b50613b53565b90506000612392826001613712565b90506123a0818b8b886141bf565b50505050505050505050565b6123b461282c565b60006123c48b8b8b8b8b8b612df0565b90506123d38160008787612c2d565b61241585828686868080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506135a592505050565b5050505050505050505050565b61134c848484846126a4565b612436612805565b61243f8261141f565b61244857600080fd5b80158061246e575061245982611f22565b8111801561246e575061246b8261264e565b81105b61247757600080fd5b60408051670dac2f0a0cae4a8f60c31b60208083019190915260609490941b6001600160601b03191660288201528151808203601c018152603c909101825280519084012060009081529283905290912055565b7f269c5905f777ee6391c7a361d17039a7d62f52ba9fffeb98c5ade342705731a360005260026020527f15c764a0cd4bb3d72a49abedd3d6793c3b93c0d57f43174a348b443be86f79c1546001600160a01b031690565b61252a612805565b6125338261141f565b61253c57600080fd5b60008111801561255357506125508261264e565b81105b8015612566575061256382611054565b81105b61256f57600080fd5b60408051670dad2dca0cae4a8f60c31b60208083019190915260609490941b6001600160601b03191660288201528151808203601c018152603c909101825280519084012060009081529283905290912055565b6040805172746f74616c457865637574656450657244617960681b60208083019190915260609490941b6001600160601b031916603382015260478082019390935281518082039093018352606701815281519183019190912060009081529182905290205490565b612634612805565b6111668161344c565b612645612805565b611166816133eb565b604080516919185a5b1e531a5b5a5d60b21b60208083019190915260609390931b6001600160601b031916602a8201528151808203601e018152603e909101825280519083012060009081529182905290205490565b6126ac61381d565b156126b657600080fd5b6000846001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561270557600080fd5b505afa158015612719573d6000803e3d6000fd5b505050506040513d602081101561272f57600080fd5b5051905061273d600161422f565b6127526001600160a01b038616333086614253565b61275c600061422f565b60006127e182876001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156127af57600080fd5b505afa1580156127c3573d6000803e3d6000fd5b505050506040513d60208110156127d957600080fd5b5051906142ad565b9050838111156127f057600080fd5b6127fd8633878487613842565b505050505050565b61280d611cd2565b6001600160a01b0316336001600160a01b03161461282a57600080fd5b565b6000612836612173565b9050336001600160a01b0382161461284d57600080fd5b612855611c7b565b6001600160a01b0316816001600160a01b031663d67bdd256040518163ffffffff1660e01b815260040160206040518083038186803b15801561289757600080fd5b505afa1580156128ab573d6000803e3d6000fd5b505050506040513d60208110156128c157600080fd5b50516001600160a01b03161461116657600080fd5b604080516b36b2b9b9b0b3b2aa37b5b2b760a11b602080830191909152602c80830185905283518084039091018152604c90920183528151918101919091206000908152600290915220546001600160a01b0316919050565b604080516f1b595cdcd859d9549958da5c1a595b9d60821b602080830191909152603080830185905283518084039091018152605090920183528151918101919091206000908152600290915220546001600160a01b0316919050565b604080516b6d65737361676556616c756560a01b602080830191909152602c80830185905283518084039091018152604c90920183528151918101919091206000908152908190522054919050565b604080516b1b595cdcd859d9519a5e195960a21b602080830191909152602c8083019490945282518083039094018452604c9091018252825192810192909220600090815260049092529020805460ff19166001179055565b6114506000612a4285611907565b6001600160a01b031614848484856142ef565b612a5e81614463565b612a6757600080fd5b7f811bbb11e8899da471f0e69a3ed55090fc90215227fc5fb1cb0d6e962ea7b74f60005260026020527fb4ed64697d3ef8518241966f7c6f28b0d72f20f51198717d198d2d55076c593d80546001600160a01b0319166001600160a01b0392909216919091179055565b604080516f686f6d65546f6b656e4164647265737360801b6020808301919091526001600160601b0319606086811b82166030850152845160248186030181526044850186528051908401206000908152600280855286822080546001600160a01b03808b166001600160a01b0319928316811790935572666f726569676e546f6b656e4164647265737360681b60648a0152948a901b90951660778801528751606b818903018152608b909701808952875197870197909720835294529485208054909216908716908117909155909290917f78d063210f4fb6b4cc932390bb8045fa2465e51349590182dab8b9e84c57a6ee9190a35050565b600082820183811015612c26576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b612c3784826117eb565b612c4057600080fd5b612c5284612c4c611841565b8361449c565b612c5f83858484856142ef565b612c6761451d565b826001600160a01b0316856001600160a01b03167f9afd47907e25028cdaca89d193518c302bbb128617d5a992c5abd45815526593846040518082815260200191505060405180910390a450505050565b612cc181614463565b612cca57600080fd5b7f269c5905f777ee6391c7a361d17039a7d62f52ba9fffeb98c5ade342705731a360005260026020527f15c764a0cd4bb3d72a49abedd3d6793c3b93c0d57f43174a348b443be86f79c180546001600160a01b0319166001600160a01b0392909216919091179055565b604080516861636b4465706c6f7960b81b6020808301919091526001600160601b0319606085901b1660298301528251601d818403018152603d909201835281519181019190912060009081526004909152205460ff1661116657604080516861636b4465706c6f7960b81b6020808301919091526001600160601b0319606085901b1660298301528251601d818403018152603d90920183528151918101919091206000908152600490915220805460ff1916600117905550565b600080612dfc8861172c565b90506001600160a01b0381166130a357606087878080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8b0181900481028201810190925289815293945060609392508991508890819084018382808284376000920191909152505084519293505050151580612e91575060008151115b612e9a57600080fd5b8151612ea857809150612eb1565b8051612eb15750805b612eba82614590565b9150612ec46124cb565b6001600160a01b031663a39d6acf838388612edd612173565b6001600160a01b0316631544298e6040518163ffffffff1660e01b815260040160206040518083038186803b158015612f1557600080fd5b505afa158015612f29573d6000803e3d6000fd5b505050506040513d6020811015612f3f57600080fd5b50516040516001600160e01b031960e087901b16815260ff831660448201526064810182905260806004820190815285516084830152855190918291602482019160a40190602089019080838360005b83811015612fa7578181015183820152602001612f8f565b50505050905090810190601f168015612fd45780820380516001836020036101000a031916815260200191505b50838103825286518152865160209182019188019080838360005b83811015613007578181015183820152602001612fef565b50505050905090810190601f1680156130345780820380516001836020036101000a031916815260200191505b509650505050505050602060405180830381600087803b15801561305757600080fd5b505af115801561306b573d6000803e3d6000fd5b505050506040513d602081101561308157600080fd5b5051925061308f8a84612ad1565b61309c838660ff16614645565b5050613133565b6130ac8161141f565b613133578260ff16816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156130ed57600080fd5b505afa158015613101573d6000803e3d6000fd5b505050506040513d602081101561311757600080fd5b505160ff161461312657600080fd5b613133818460ff16614645565b979650505050505050565b7f98aa806e31e94a687a31c65769cb99670064dd7f5a87526da075c5fb4eab988060005260026020527f0c1206883be66049a02d4937078367c00b3d71dd1a9465df969363c6ddeac96d80546001600160a01b0319166001600160a01b0392909216919091179055565b6040810151158015906131c2575060408101516020820151115b80156131d2575060208101518151115b6131db57600080fd5b8051604080516919185a5b1e531a5b5a5d60b21b602082810191909152606086901b6001600160601b031916602a83018190528351808403601e018152603e8401855280519083012060009081528083528481209590955581860151670dac2f0a0cae4a8f60c31b605e850152606684018290528451605a818603018152607a8501865280519084012086528583528486205583860151670dad2dca0cae4a8f60c31b609a85015260a28401919091528351609681850301815260b690930184528251928201929092208452839052908220556001600160a01b038316907fca0b3dabefdbd8c72c0a9cf4a6e9d107da897abf036ef3f3f3b010cdd25941599083905b60200201516040518082815260200191505060405180910390a25050565b805160208201511061330d57600080fd5b80516040805172195e1958dd5d1a5bdb91185a5b1e531a5b5a5d606a1b602082810191909152606086901b6001600160601b031916603383018190528351808403602701815260478401855280519083012060009081528083528481209590955581860151700caf0cac6eae8d2dedc9ac2f0a0cae4a8f607b1b606785015260788401919091528351606c818503018152608c90930184528251928201929092208452839052908220556001600160a01b038316907f4c177b42dbe934b3abbc0208c11a42e46589983431616f1710ab19969c5ed62e9083906132de565b6133f36147c9565b8111156133ff57600080fd5b7f2dfd6c9f781bb6bbb5369c114e949b69ebb440ef3d4dd6b2836225eb1dc3a2be60009081526020527f2de0d2cdc19d356cb53b5984f91bfd3b31fe0c678a0d190a6db39274bb34753f55565b6001600160a01b03811661345f57600080fd5b7f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0613488611cd2565b604080516001600160a01b03928316815291841660208301528051918290030190a17f02016836a56b71f0d02689e69e326f4f4c1b9057164ef592671cf0d37c8040c060005260026020527fb7802e97e87ef2842a6cce7da7ffaeaedaa2f61a6a7870b23d9d01fc9b73712e80546001600160a01b0319166001600160a01b0392909216919091179055565b7f0a6f646cd611241d8073675e00d1a1ff700fbf1b53fcf473de56d1e6e4b714ba60005260046020527f078d888f9b66f3f8bfa10909e31f1e16240db73449f0500afdbbe3a70da457cc805460ff19166001179055565b806001600160a01b03811661357f57600080fd5b6001600160a01b03831661359b576135968261480b565b611450565b6114508383614816565b6135ae84614463565b1561134c57836001600160a01b031663db7af85460e01b84848460405160240180846001600160a01b0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561361d578181015183820152602001613605565b50505050905090810190601f16801561364a5780820380516001836020036101000a031916815260200191505b5060408051601f198184030181529181526020820180516001600160e01b03166001600160e01b031990991698909817885251815191979096508695509350915081905083835b602083106136b05780518252601f199092019160209182019101613691565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114611a5d576040519150601f19603f3d011682016040523d82523d6000602084013e611a5d565b600061371c612173565b6001600160a01b031663dc8601b3613732611c7b565b8561373b6120b1565b6040518463ffffffff1660e01b815260040180846001600160a01b0316815260200180602001838152602001828103825284818151815260200191508051906020019080838360005b8381101561379c578181015183820152602001613784565b50505050905090810190601f1680156137c95780820380516001836020036101000a031916815260200191505b50945050505050602060405180830381600087803b1580156137ea57600080fd5b505af11580156137fe573d6000803e3d6000fd5b505050506040513d602081101561381457600080fd5b50519392505050565b7f6168652c307c1e813ca11cfb3a601f1cf3b22452021a5052d8b05f1f1f8a3e925490565b6001600160a01b03831615801590613873575061385d611c7b565b6001600160a01b0316836001600160a01b031614155b61387c57600080fd5b600061388786613985565b90506138928661141f565b6138a3576138a3868260ff16614645565b6138ad86846112a5565b6138b657600080fd5b6138c8866138c2611841565b85613907565b60606138e06138d688611907565b8887878688613b53565b905060006138ef826001613712565b90506138fd818989886141bf565b5050505050505050565b613915816112bd8585611fe4565b600080858560405160200180806f746f74616c5370656e7450657244617960801b815250601001836001600160a01b031660601b81526014018281526020019250505060405160208183030381529060405280519060200120815260200190815260200160002081905550505050565b60408051600481526024810182526020810180516001600160e01b031663313ce56760e01b1781529151815160009384936060936001600160a01b03881693919290918291908083835b602083106139ee5780518252601f1990920191602091820191016139cf565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114613a4e576040519150601f19603f3d011682016040523d82523d6000602084013e613a53565b606091505b509150915081613b345760408051600481526024810182526020810180516001600160e01b0316632e0f262560e01b178152915181516001600160a01b0388169382918083835b60208310613ab95780518252601f199092019160209182019101613a9a565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114613b19576040519150601f19603f3d011682016040523d82523d6000602084013e613b1e565b606091505b50909250905081613b34576000925050506110a7565b808060200190516020811015613b4957600080fd5b5051949350505050565b606060008083511180613b7857506000356001600160e01b03191663d740548160e01b145b90506001600160a01b03881661402557613b9e87613b99876112bd8b6113af565b6148a3565b613ba787612058565b15613ce45780613c0557604080516001600160a01b03808a1660248301528816604482015260648082018890528251808303909101815260849091019091526020810180516001600160e01b031663125e4cfb60e01b179052613cdc565b63c534576160e01b8787878660405160240180856001600160a01b03168152602001846001600160a01b0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015613c75578181015183820152602001613c5d565b50505050905090810190601f168015613ca25780820380516001836020036101000a031916815260200191505b5060408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909916989098179097525050505050505b915050611b6f565b6060613cef886148fe565b90506060613cfc89614ac4565b9050600082511180613d0f575060008151115b613d1857600080fd5b82613e6b57632ae87cdd60e01b898383898c8c60405160240180876001600160a01b0316815260200180602001806020018660ff168152602001856001600160a01b03168152602001848152602001838103835288818151815260200191508051906020019080838360005b83811015613d9c578181015183820152602001613d84565b50505050905090810190601f168015613dc95780820380516001836020036101000a031916815260200191505b50838103825287518152875160209182019189019080838360005b83811015613dfc578181015183820152602001613de4565b50505050905090810190601f168015613e295780820380516001836020036101000a031916815260200191505b5060408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909c169b909b17909a525061401b975050505050505050565b63d522cfd760e01b898383898c8c8b60405160240180886001600160a01b0316815260200180602001806020018760ff168152602001866001600160a01b031681526020018581526020018060200184810384528a818151815260200191508051906020019080838360005b83811015613eef578181015183820152602001613ed7565b50505050905090810190601f168015613f1c5780820380516001836020036101000a031916815260200191505b5084810383528951815289516020918201918b019080838360005b83811015613f4f578181015183820152602001613f37565b50505050905090810190601f168015613f7c5780820380516001836020036101000a031916815260200191505b50848103825285518152855160209182019187019080838360005b83811015613faf578181015183820152602001613f97565b50505050905090810190601f168015613fdc5780820380516001836020036101000a031916815260200191505b5060408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909e169d909d17909c5250505050505050505050505b9350505050611b6f565b866001600160a01b03166342966c68866040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561406b57600080fd5b505af115801561407f573d6000803e3d6000fd5b50505050806140dc57604080516001600160a01b03808b1660248301528816604482015260648082018890528251808303909101815260849091019091526020810180516001600160e01b031663272255bb60e01b1790526141b3565b63867f7a4d60e01b8887878660405160240180856001600160a01b03168152602001846001600160a01b0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561414c578181015183820152602001614134565b50505050905090810190601f1680156141795780820380516001836020036101000a031916815260200191505b5060408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909916989098179097525050505050505b98975050505050505050565b6141c98484614bf7565b6141d38483614c63565b6141dd8482614cd3565b83826001600160a01b0316846001600160a01b03167f59a9a8027b9c87b961e254899821c9a276b5efc35d1f7409ea4f291470f1629a846040518082815260200191505060405180910390a450505050565b7f6168652c307c1e813ca11cfb3a601f1cf3b22452021a5052d8b05f1f1f8a3e9255565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b17905261134c908590614d22565b6000612c2683836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250614dd3565b84156143da576000614300856113af565b90506001600160a01b038516730ae055097c6d159879521c384f1d2123d1f195e614801561432d57508281105b156143b257604080516340c10f1960e01b8152306004820152828503602482015290516001600160a01b038716916340c10f199160448083019260209291908290030181600087803b15801561438257600080fd5b505af1158015614396573d6000803e3d6000fd5b505050506040513d60208110156143ac57600080fd5b50839150505b6143c085613b9983856142ad565b6143d46001600160a01b0386168585614e6a565b5061216c565b6143e384614ebc565b6001600160a01b03166340c10f1984846040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561443957600080fd5b505af115801561444d573d6000803e3d6000fd5b505050506040513d6020811015611a5d57600080fd5b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590611fdc575050151592915050565b6144aa816112bd85856125c3565b6000808585604051602001808072746f74616c457865637574656450657244617960681b815250601301836001600160a01b031660601b81526014018281526020019250505060405160208183030381529060405280519060200120815260200190815260200160002081905550505050565b6000614527612173565b6001600160a01b031663669f618b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561455f57600080fd5b505afa158015614573573d6000803e3d6000fd5b505050506040513d602081101561458957600080fd5b5051905090565b606080827f206f6e204d61696e6e65740000000000000000000000000000000000000000006040516020018083805190602001908083835b602083106145e75780518252601f1990920191602091820191016145c8565b51815160209384036101000a60001901801990921691161790529201938452506040805180850381529390910190525093517f000000000000000000000000000000000000000000000000000000000000000b018452509192915050565b600060128210156147395781601203600a0a9050600061466f826146696000611f22565b90614ebf565b90506000614681836146696000611054565b9050600061469384614669600061264e565b905060006146a5856146696000611352565b905060006146b786614669600061184a565b9050846146ed57600194508484116146ed57606493506064915083831115806146e05750818111155b156146ed57506127109150815b614711886040518060600160405280868152602001878152602001888152506131a8565b61472f886040518060400160405280848152602001858152506132fc565b5050505050611450565b60128203600a0a90506147928360405180606001604052806147658561475f600061264e565b90614f01565b81526020016147788561475f6000611054565b815260200161478b8561475f6000611f22565b90526131a8565b6114508360405180604001604052806147af8561475f600061184a565b81526020016147c28561475f6000611352565b90526132fc565b60006147d3612173565b6001600160a01b031663e5789d036040518163ffffffff1660e01b815260040160206040518083038186803b15801561455f57600080fd5b47610fb18282614f5a565b604080516370a0823160e01b8152306004820152905183916000916001600160a01b038416916370a08231916024808301926020929190829003018186803b15801561486157600080fd5b505afa158015614875573d6000803e3d6000fd5b505050506040513d602081101561488b57600080fd5b5051905061134c6001600160a01b0383168483614e6a565b604080516e6d65646961746f7242616c616e636560881b60208083019190915260609490941b6001600160601b031916602f820152815180820360230181526043909101825280519084012060009081529283905290912055565b60408051600481526024810182526020810180516001600160e01b03166306fdde0360e01b1781529151815160609360009385936001600160a01b03881693919290918291908083835b602083106149675780518252601f199092019160209182019101614948565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d80600081146149c7576040519150601f19603f3d011682016040523d82523d6000602084013e6149cc565b606091505b509150915081614abb5760408051600481526024810182526020810180516001600160e01b03166351fa6fbf60e11b178152915181516001600160a01b0388169382918083835b60208310614a325780518252601f199092019160209182019101614a13565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114614a92576040519150601f19603f3d011682016040523d82523d6000602084013e614a97565b606091505b50909250905081614abb5760405180602001604052806000815250925050506110a7565b611fdc81614fbf565b60408051600481526024810182526020810180516001600160e01b03166395d89b4160e01b1781529151815160609360009385936001600160a01b03881693919290918291908083835b60208310614b2d5780518252601f199092019160209182019101614b0e565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114614b8d576040519150601f19603f3d011682016040523d82523d6000602084013e614b92565b606091505b509150915081614abb5760408051600481526024810182526020810180516001600160e01b0316631eedf1af60e31b178152915181516001600160a01b03881693829180838360208310614a325780518252601f199092019160209182019101614a13565b604080516b36b2b9b9b0b3b2aa37b5b2b760a11b602080830191909152602c8083019590955282518083039095018552604c90910182528351938101939093206000908152600290935290912080546001600160a01b0319166001600160a01b03909216919091179055565b604080516f1b595cdcd859d9549958da5c1a595b9d60821b60208083019190915260308083019590955282518083039095018552605090910182528351938101939093206000908152600290935290912080546001600160a01b0319166001600160a01b03909216919091179055565b604080516b6d65737361676556616c756560a01b602080830191909152602c8083019590955282518083039095018552604c909101825283519381019390932060009081529283905290912055565b6060614d77826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661511b9092919063ffffffff16565b80519091501561145057808060200190516020811015614d9657600080fd5b50516114505760405162461bcd60e51b815260040180806020018281038252602a81526020018061535c602a913960400191505060405180910390fd5b60008184841115614e625760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015614e27578181015183820152602001614e0f565b50505050905090810190601f168015614e545780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052611450908490614d22565b90565b6000612c2683836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061512a565b600082614f1057506000611312565b82820282848281614f1d57fe5b0414612c265760405162461bcd60e51b815260040180806020018281038252602181526020018061533b6021913960400191505060405180910390fd5b6040516001600160a01b0383169082156108fc029083906000818181858888f19350505050610fb1578082604051614f91906152fc565b6001600160a01b039091168152604051908190036020019082f090508015801561134c573d6000803e3d6000fd5b606060208251111561509557818060200190516020811015614fe057600080fd5b8101908080516040519392919084600160201b821115614fff57600080fd5b90830190602082018581111561501457600080fd5b8251600160201b81118282018810171561502d57600080fd5b82525081516020918201929091019080838360005b8381101561505a578181015183820152602001615042565b50505050905090810190601f1680156150875780820380516001836020036101000a031916815260200191505b5060405250505090506110a7565b8151602014156151065760008280602001905160208110156150b657600080fd5b50516040805160208082528183019092529192506060919060208201818036833701905050905060008260208301525b82156150fb5760089290921b916001016150e6565b815291506110a79050565b506040805160208101909152600081526110a7565b6060611fdc848460008561518f565b600081836151795760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315614e27578181015183820152602001614e0f565b50600083858161518557fe5b0495945050505050565b606061519a85614463565b6151eb576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b6020831061522a5780518252601f19909201916020918201910161520b565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461528c576040519150601f19603f3d011682016040523d82523d6000602084013e615291565b606091505b509150915081156152a5579150611fdc9050565b8051156152b55780518082602001fd5b60405162461bcd60e51b8152602060048201818152865160248401528651879391928392604401919085019080838360008315614e27578181015183820152602001614e0f565b6032806153098339019056fe60806040526040516032380380603283398181016040526020811015602357600080fd5b50516001600160a01b038116fffe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a264697066735822122027ce8c249a9dfb8133163b136517e818196a5de2f30c251fea8633923b59cecf64736f6c63430007050033
Verified Source Code Partial Match
Compiler: v0.7.5+commit.eb77ed08
EVM: istanbul
Optimization: Yes (200 runs)
ForeignOmnibridge.sol 2692 lines
pragma solidity 0.7.5;
/**
* @title EternalStorage
* @dev This contract holds all the necessary state variables to carry out the storage of any contract.
*/
contract EternalStorage {
mapping(bytes32 => uint256) internal uintStorage;
mapping(bytes32 => string) internal stringStorage;
mapping(bytes32 => address) internal addressStorage;
mapping(bytes32 => bytes) internal bytesStorage;
mapping(bytes32 => bool) internal boolStorage;
mapping(bytes32 => int256) internal intStorage;
}
// SPDX-License-Identifier: MIT
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @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 `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, 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 `sender` to `recipient` 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 sender, address recipient, uint256 amount) external returns (bool);
/**
* @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);
}
contract Sacrifice {
constructor(address payable _recipient) payable {
selfdestruct(_recipient);
}
}
interface IUpgradeabilityOwnerStorage {
function upgradeabilityOwner() external view returns (address);
}
interface IERC677 is IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value, bytes data);
function transferAndCall(
address to,
uint256 value,
bytes calldata data
) external returns (bool);
function increaseAllowance(address spender, uint256 addedValue) external returns (bool);
function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool);
}
/**
* @title Ownable
* @dev This contract has an owner address providing basic authorization control
*/
contract Ownable is EternalStorage {
bytes4 internal constant UPGRADEABILITY_OWNER = 0x6fde8202; // upgradeabilityOwner()
/**
* @dev Event to show ownership has been transferred
* @param previousOwner representing the address of the previous owner
* @param newOwner representing the address of the new owner
*/
event OwnershipTransferred(address previousOwner, address newOwner);
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_onlyOwner();
_;
}
/**
* @dev Internal function for reducing onlyOwner modifier bytecode overhead.
*/
function _onlyOwner() internal view {
require(msg.sender == owner());
}
/**
* @dev Throws if called through proxy by any account other than contract itself or an upgradeability owner.
*/
modifier onlyRelevantSender() {
(bool isProxy, bytes memory returnData) = address(this).call(abi.encodeWithSelector(UPGRADEABILITY_OWNER));
require(
!isProxy || // covers usage without calling through storage proxy
(returnData.length == 32 && msg.sender == abi.decode(returnData, (address))) || // covers usage through regular proxy calls
msg.sender == address(this) // covers calls through upgradeAndCall proxy method
);
_;
}
bytes32 internal constant OWNER = 0x02016836a56b71f0d02689e69e326f4f4c1b9057164ef592671cf0d37c8040c0; // keccak256(abi.encodePacked("owner"))
/**
* @dev Tells the address of the owner
* @return the address of the owner
*/
function owner() public view returns (address) {
return addressStorage[OWNER];
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner the address to transfer ownership to.
*/
function transferOwnership(address newOwner) external onlyOwner {
_setOwner(newOwner);
}
/**
* @dev Sets a new owner address
*/
function _setOwner(address newOwner) internal {
require(newOwner != address(0));
emit OwnershipTransferred(owner(), newOwner);
addressStorage[OWNER] = newOwner;
}
}
interface VersionableBridge {
function getBridgeInterfacesVersion()
external
pure
returns (
uint64 major,
uint64 minor,
uint64 patch
);
function getBridgeMode() external pure returns (bytes4);
}
interface IAMB {
event UserRequestForAffirmation(bytes32 indexed messageId, bytes encodedData);
event UserRequestForSignature(bytes32 indexed messageId, bytes encodedData);
event AffirmationCompleted(
address indexed sender,
address indexed executor,
bytes32 indexed messageId,
bool status
);
event RelayedMessage(address indexed sender, address indexed executor, bytes32 indexed messageId, bool status);
function messageSender() external view returns (address);
function maxGasPerTx() external view returns (uint256);
function transactionHash() external view returns (bytes32);
function messageId() external view returns (bytes32);
function messageSourceChainId() external view returns (bytes32);
function messageCallStatus(bytes32 _messageId) external view returns (bool);
function failedMessageDataHash(bytes32 _messageId) external view returns (bytes32);
function failedMessageReceiver(bytes32 _messageId) external view returns (address);
function failedMessageSender(bytes32 _messageId) external view returns (address);
function requireToPassMessage(
address _contract,
bytes calldata _data,
uint256 _gas
) external returns (bytes32);
function requireToConfirmMessage(
address _contract,
bytes calldata _data,
uint256 _gas
) external returns (bytes32);
function sourceChainId() external view returns (uint256);
function destinationChainId() external view returns (uint256);
}
/**
* @title AddressHelper
* @dev Helper methods for Address type.
*/
library AddressHelper {
/**
* @dev Try to send native tokens to the address. If it fails, it will force the transfer by creating a selfdestruct contract
* @param _receiver address that will receive the native tokens
* @param _value the amount of native tokens to send
*/
function safeSendValue(address payable _receiver, uint256 _value) internal {
if (!(_receiver).send(_value)) {
new Sacrifice{ value: _value }(_receiver);
}
}
}
interface IERC20Receiver {
function onTokenBridged(
address token,
uint256 value,
bytes calldata data
) external;
}
interface IERC20Metadata {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
}
contract Upgradeable {
// Avoid using onlyUpgradeabilityOwner name to prevent issues with implementation from proxy contract
modifier onlyIfUpgradeabilityOwner() {
require(msg.sender == IUpgradeabilityOwnerStorage(address(this)).upgradeabilityOwner());
_;
}
}
contract Initializable is EternalStorage {
bytes32 internal constant INITIALIZED = 0x0a6f646cd611241d8073675e00d1a1ff700fbf1b53fcf473de56d1e6e4b714ba; // keccak256(abi.encodePacked("isInitialized"))
function setInitialize() internal {
boolStorage[INITIALIZED] = true;
}
function isInitialized() public view returns (bool) {
return boolStorage[INITIALIZED];
}
}
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
// solhint-disable-next-line max-line-length
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) { // Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
/**
* @title Claimable
* @dev Implementation of the claiming utils that can be useful for withdrawing accidentally sent tokens that are not used in bridge operations.
*/
contract Claimable {
using SafeERC20 for IERC20;
/**
* Throws if a given address is equal to address(0)
*/
modifier validAddress(address _to) {
require(_to != address(0));
_;
}
/**
* @dev Withdraws the erc20 tokens or native coins from this contract.
* Caller should additionally check that the claimed token is not a part of bridge operations (i.e. that token != erc20token()).
* @param _token address of the claimed token or address(0) for native coins.
* @param _to address of the tokens/coins receiver.
*/
function claimValues(address _token, address _to) internal validAddress(_to) {
if (_token == address(0)) {
claimNativeCoins(_to);
} else {
claimErc20Tokens(_token, _to);
}
}
/**
* @dev Internal function for withdrawing all native coins from the contract.
* @param _to address of the coins receiver.
*/
function claimNativeCoins(address _to) internal {
uint256 value = address(this).balance;
AddressHelper.safeSendValue(payable(_to), value);
}
/**
* @dev Internal function for withdrawing all tokens of ssome particular ERC20 contract from this contract.
* @param _token address of the claimed ERC20 token.
* @param _to address of the tokens receiver.
*/
function claimErc20Tokens(address _token, address _to) internal {
IERC20 token = IERC20(_token);
uint256 balance = token.balanceOf(address(this));
token.safeTransfer(_to, balance);
}
}
/**
* @title BridgedTokensRegistry
* @dev Functionality for keeping track of registered bridged token pairs.
*/
contract BridgedTokensRegistry is EternalStorage {
event NewTokenRegistered(address indexed nativeToken, address indexed bridgedToken);
/**
* @dev Retrieves address of the bridged token contract associated with a specific native token contract on the other side.
* @param _nativeToken address of the native token contract on the other side.
* @return address of the deployed bridged token contract.
*/
function bridgedTokenAddress(address _nativeToken) public view returns (address) {
return addressStorage[keccak256(abi.encodePacked("homeTokenAddress", _nativeToken))];
}
/**
* @dev Retrieves address of the native token contract associated with a specific bridged token contract.
* @param _bridgedToken address of the created bridged token contract on this side.
* @return address of the native token contract on the other side of the bridge.
*/
function nativeTokenAddress(address _bridgedToken) public view returns (address) {
return addressStorage[keccak256(abi.encodePacked("foreignTokenAddress", _bridgedToken))];
}
/**
* @dev Internal function for updating a pair of addresses for the bridged token.
* @param _nativeToken address of the native token contract on the other side.
* @param _bridgedToken address of the created bridged token contract on this side.
*/
function _setTokenAddressPair(address _nativeToken, address _bridgedToken) internal {
addressStorage[keccak256(abi.encodePacked("homeTokenAddress", _nativeToken))] = _bridgedToken;
addressStorage[keccak256(abi.encodePacked("foreignTokenAddress", _bridgedToken))] = _nativeToken;
emit NewTokenRegistered(_nativeToken, _bridgedToken);
}
}
/**
* @title NativeTokensRegistry
* @dev Functionality for keeping track of registered native tokens.
*/
contract NativeTokensRegistry is EternalStorage {
/**
* @dev Checks if for a given native token, the deployment of its bridged alternative was already acknowledged.
* @param _token address of native token contract.
* @return true, if bridged token was already deployed.
*/
function isBridgedTokenDeployAcknowledged(address _token) public view returns (bool) {
return boolStorage[keccak256(abi.encodePacked("ackDeploy", _token))];
}
/**
* @dev Acknowledges the deployment of bridged token contract on the other side.
* @param _token address of native token contract.
*/
function _ackBridgedTokenDeploy(address _token) internal {
if (!boolStorage[keccak256(abi.encodePacked("ackDeploy", _token))]) {
boolStorage[keccak256(abi.encodePacked("ackDeploy", _token))] = true;
}
}
}
/**
* @title MediatorBalanceStorage
* @dev Functionality for storing expected mediator balance for native tokens.
*/
contract MediatorBalanceStorage is EternalStorage {
/**
* @dev Tells the expected token balance of the contract.
* @param _token address of token contract.
* @return the current tracked token balance of the contract.
*/
function mediatorBalance(address _token) public view returns (uint256) {
return uintStorage[keccak256(abi.encodePacked("mediatorBalance", _token))];
}
/**
* @dev Updates expected token balance of the contract.
* @param _token address of token contract.
* @param _balance the new token balance of the contract.
*/
function _setMediatorBalance(address _token, uint256 _balance) internal {
uintStorage[keccak256(abi.encodePacked("mediatorBalance", _token))] = _balance;
}
}
/**
* @title Bytes
* @dev Helper methods to transform bytes to other solidity types.
*/
library Bytes {
/**
* @dev Truncate bytes array if its size is more than 20 bytes.
* NOTE: This function does not perform any checks on the received parameter.
* Make sure that the _bytes argument has a correct length, not less than 20 bytes.
* A case when _bytes has length less than 20 will lead to the undefined behaviour,
* since assembly will read data from memory that is not related to the _bytes argument.
* @param _bytes to be converted to address type
* @return addr address included in the firsts 20 bytes of the bytes array in parameter.
*/
function bytesToAddress(bytes memory _bytes) internal pure returns (address addr) {
assembly {
addr := mload(add(_bytes, 20))
}
}
}
contract ReentrancyGuard {
function lock() internal view returns (bool res) {
assembly {
// Even though this is not the same as boolStorage[keccak256(abi.encodePacked("lock"))],
// since solidity mapping introduces another level of addressing, such slot change is safe
// for temporary variables which are cleared at the end of the call execution.
res := sload(0x6168652c307c1e813ca11cfb3a601f1cf3b22452021a5052d8b05f1f1f8a3e92) // keccak256(abi.encodePacked("lock"))
}
}
function setLock(bool _lock) internal {
assembly {
// Even though this is not the same as boolStorage[keccak256(abi.encodePacked("lock"))],
// since solidity mapping introduces another level of addressing, such slot change is safe
// for temporary variables which are cleared at the end of the call execution.
sstore(0x6168652c307c1e813ca11cfb3a601f1cf3b22452021a5052d8b05f1f1f8a3e92, _lock) // keccak256(abi.encodePacked("lock"))
}
}
}
/**
* @title BasicAMBMediator
* @dev Basic storage and methods needed by mediators to interact with AMB bridge.
*/
abstract contract BasicAMBMediator is Ownable {
bytes32 internal constant BRIDGE_CONTRACT = 0x811bbb11e8899da471f0e69a3ed55090fc90215227fc5fb1cb0d6e962ea7b74f; // keccak256(abi.encodePacked("bridgeContract"))
bytes32 internal constant MEDIATOR_CONTRACT = 0x98aa806e31e94a687a31c65769cb99670064dd7f5a87526da075c5fb4eab9880; // keccak256(abi.encodePacked("mediatorContract"))
/**
* @dev Throws if caller on the other side is not an associated mediator.
*/
modifier onlyMediator {
_onlyMediator();
_;
}
/**
* @dev Internal function for reducing onlyMediator modifier bytecode overhead.
*/
function _onlyMediator() internal view {
IAMB bridge = bridgeContract();
require(msg.sender == address(bridge));
require(bridge.messageSender() == mediatorContractOnOtherSide());
}
/**
* @dev Sets the AMB bridge contract address. Only the owner can call this method.
* @param _bridgeContract the address of the bridge contract.
*/
function setBridgeContract(address _bridgeContract) external onlyOwner {
_setBridgeContract(_bridgeContract);
}
/**
* @dev Sets the mediator contract address from the other network. Only the owner can call this method.
* @param _mediatorContract the address of the mediator contract.
*/
function setMediatorContractOnOtherSide(address _mediatorContract) external onlyOwner {
_setMediatorContractOnOtherSide(_mediatorContract);
}
/**
* @dev Get the AMB interface for the bridge contract address
* @return AMB interface for the bridge contract address
*/
function bridgeContract() public view returns (IAMB) {
return IAMB(addressStorage[BRIDGE_CONTRACT]);
}
/**
* @dev Tells the mediator contract address from the other network.
* @return the address of the mediator contract.
*/
function mediatorContractOnOtherSide() public view virtual returns (address) {
return addressStorage[MEDIATOR_CONTRACT];
}
/**
* @dev Stores a valid AMB bridge contract address.
* @param _bridgeContract the address of the bridge contract.
*/
function _setBridgeContract(address _bridgeContract) internal {
require(Address.isContract(_bridgeContract));
addressStorage[BRIDGE_CONTRACT] = _bridgeContract;
}
/**
* @dev Stores the mediator contract address from the other network.
* @param _mediatorContract the address of the mediator contract.
*/
function _setMediatorContractOnOtherSide(address _mediatorContract) internal {
addressStorage[MEDIATOR_CONTRACT] = _mediatorContract;
}
/**
* @dev Tells the id of the message originated on the other network.
* @return the id of the message originated on the other network.
*/
function messageId() internal view returns (bytes32) {
return bridgeContract().messageId();
}
/**
* @dev Tells the maximum gas limit that a message can use on its execution by the AMB bridge on the other network.
* @return the maximum gas limit value.
*/
function maxGasPerTx() internal view returns (uint256) {
return bridgeContract().maxGasPerTx();
}
function _passMessage(bytes memory _data, bool _useOracleLane) internal virtual returns (bytes32);
}
/**
* @title TokensRelayer
* @dev Functionality for bridging multiple tokens to the other side of the bridge.
*/
abstract contract TokensRelayer is BasicAMBMediator, ReentrancyGuard {
using SafeMath for uint256;
using SafeERC20 for IERC677;
/**
* @dev ERC677 transfer callback function.
* @param _from address of tokens sender.
* @param _value amount of transferred tokens.
* @param _data additional transfer data, can be used for passing alternative receiver address.
*/
function onTokenTransfer(
address _from,
uint256 _value,
bytes calldata _data
) external returns (bool) {
if (!lock()) {
bytes memory data = new bytes(0);
address receiver = _from;
if (_data.length >= 20) {
assembly {
receiver := calldataload(120)
}
if (_data.length > 20) {
assembly {
data := mload(0x40)
let size := sub(calldataload(100), 20)
mstore(data, size)
calldatacopy(add(data, 32), 152, size)
mstore(0x40, add(add(data, 32), size))
}
}
}
bridgeSpecificActionsOnTokenTransfer(msg.sender, _from, receiver, _value, data);
}
return true;
}
/**
* @dev Initiate the bridge operation for some amount of tokens from msg.sender.
* The user should first call Approve method of the ERC677 token.
* @param token bridged token contract address.
* @param _receiver address that will receive the native tokens on the other network.
* @param _value amount of tokens to be transferred to the other network.
*/
function relayTokens(
IERC677 token,
address _receiver,
uint256 _value
) external {
_relayTokens(token, _receiver, _value, new bytes(0));
}
/**
* @dev Initiate the bridge operation for some amount of tokens from msg.sender to msg.sender on the other side.
* The user should first call Approve method of the ERC677 token.
* @param token bridged token contract address.
* @param _value amount of tokens to be transferred to the other network.
*/
function relayTokens(IERC677 token, uint256 _value) external {
_relayTokens(token, msg.sender, _value, new bytes(0));
}
/**
* @dev Initiate the bridge operation for some amount of tokens from msg.sender.
* The user should first call Approve method of the ERC677 token.
* @param token bridged token contract address.
* @param _receiver address that will receive the native tokens on the other network.
* @param _value amount of tokens to be transferred to the other network.
* @param _data additional transfer data to be used on the other side.
*/
function relayTokensAndCall(
IERC677 token,
address _receiver,
uint256 _value,
bytes memory _data
) external {
_relayTokens(token, _receiver, _value, _data);
}
/**
* @dev Validates that the token amount is inside the limits, calls transferFrom to transfer the tokens to the contract
* and invokes the method to burn/lock the tokens and unlock/mint the tokens on the other network.
* The user should first call Approve method of the ERC677 token.
* @param token bridge token contract address.
* @param _receiver address that will receive the native tokens on the other network.
* @param _value amount of tokens to be transferred to the other network.
* @param _data additional transfer data to be used on the other side.
*/
function _relayTokens(
IERC677 token,
address _receiver,
uint256 _value,
bytes memory _data
) internal {
// This lock is to prevent calling passMessage twice if a ERC677 token is used.
// When transferFrom is called, after the transfer, the ERC677 token will call onTokenTransfer from this contract
// which will call passMessage.
require(!lock());
uint256 balanceBefore = token.balanceOf(address(this));
setLock(true);
token.safeTransferFrom(msg.sender, address(this), _value);
setLock(false);
uint256 balanceDiff = token.balanceOf(address(this)).sub(balanceBefore);
require(balanceDiff <= _value);
bridgeSpecificActionsOnTokenTransfer(address(token), msg.sender, _receiver, balanceDiff, _data);
}
function bridgeSpecificActionsOnTokenTransfer(
address _token,
address _from,
address _receiver,
uint256 _value,
bytes memory _data
) internal virtual;
}
/**
* @title OmnibridgeInfo
* @dev Functionality for versioning Omnibridge mediator.
*/
contract OmnibridgeInfo is VersionableBridge {
event TokensBridgingInitiated(
address indexed token,
address indexed sender,
uint256 value,
bytes32 indexed messageId
);
event TokensBridged(address indexed token, address indexed recipient, uint256 value, bytes32 indexed messageId);
/**
* @dev Tells the bridge interface version that this contract supports.
* @return major value of the version
* @return minor value of the version
* @return patch value of the version
*/
function getBridgeInterfacesVersion()
external
pure
override
returns (
uint64 major,
uint64 minor,
uint64 patch
)
{
return (2, 1, 0);
}
/**
* @dev Tells the bridge mode that this contract supports.
* @return _data 4 bytes representing the bridge mode
*/
function getBridgeMode() external pure override returns (bytes4 _data) {
return 0xb1516c26; // bytes4(keccak256(abi.encodePacked("multi-erc-to-erc-amb")))
}
}
/**
* @title TokensBridgeLimits
* @dev Functionality for keeping track of bridgin limits for multiple tokens.
*/
contract TokensBridgeLimits is EternalStorage, Ownable {
using SafeMath for uint256;
// token == 0x00..00 represents default limits (assuming decimals == 18) for all newly created tokens
event DailyLimitChanged(address indexed token, uint256 newLimit);
event ExecutionDailyLimitChanged(address indexed token, uint256 newLimit);
/**
* @dev Checks if specified token was already bridged at least once.
* @param _token address of the token contract.
* @return true, if token address is address(0) or token was already bridged.
*/
function isTokenRegistered(address _token) public view returns (bool) {
return minPerTx(_token) > 0;
}
/**
* @dev Retrieves the total spent amount for particular token during specific day.
* @param _token address of the token contract.
* @param _day day number for which spent amount if requested.
* @return amount of tokens sent through the bridge to the other side.
*/
function totalSpentPerDay(address _token, uint256 _day) public view returns (uint256) {
return uintStorage[keccak256(abi.encodePacked("totalSpentPerDay", _token, _day))];
}
/**
* @dev Retrieves the total executed amount for particular token during specific day.
* @param _token address of the token contract.
* @param _day day number for which spent amount if requested.
* @return amount of tokens received from the bridge from the other side.
*/
function totalExecutedPerDay(address _token, uint256 _day) public view returns (uint256) {
return uintStorage[keccak256(abi.encodePacked("totalExecutedPerDay", _token, _day))];
}
/**
* @dev Retrieves current daily limit for a particular token contract.
* @param _token address of the token contract.
* @return daily limit on tokens that can be sent through the bridge per day.
*/
function dailyLimit(address _token) public view returns (uint256) {
return uintStorage[keccak256(abi.encodePacked("dailyLimit", _token))];
}
/**
* @dev Retrieves current execution daily limit for a particular token contract.
* @param _token address of the token contract.
* @return daily limit on tokens that can be received from the bridge on the other side per day.
*/
function executionDailyLimit(address _token) public view returns (uint256) {
return uintStorage[keccak256(abi.encodePacked("executionDailyLimit", _token))];
}
/**
* @dev Retrieves current maximum amount of tokens per one transfer for a particular token contract.
* @param _token address of the token contract.
* @return maximum amount on tokens that can be sent through the bridge in one transfer.
*/
function maxPerTx(address _token) public view returns (uint256) {
return uintStorage[keccak256(abi.encodePacked("maxPerTx", _token))];
}
/**
* @dev Retrieves current maximum execution amount of tokens per one transfer for a particular token contract.
* @param _token address of the token contract.
* @return maximum amount on tokens that can received from the bridge on the other side in one transaction.
*/
function executionMaxPerTx(address _token) public view returns (uint256) {
return uintStorage[keccak256(abi.encodePacked("executionMaxPerTx", _token))];
}
/**
* @dev Retrieves current minimum amount of tokens per one transfer for a particular token contract.
* @param _token address of the token contract.
* @return minimum amount on tokens that can be sent through the bridge in one transfer.
*/
function minPerTx(address _token) public view returns (uint256) {
return uintStorage[keccak256(abi.encodePacked("minPerTx", _token))];
}
/**
* @dev Checks that bridged amount of tokens conforms to the configured limits.
* @param _token address of the token contract.
* @param _amount amount of bridge tokens.
* @return true, if specified amount can be bridged.
*/
function withinLimit(address _token, uint256 _amount) public view returns (bool) {
uint256 nextLimit = totalSpentPerDay(_token, getCurrentDay()).add(_amount);
return
dailyLimit(address(0)) > 0 &&
dailyLimit(_token) >= nextLimit &&
_amount <= maxPerTx(_token) &&
_amount >= minPerTx(_token);
}
/**
* @dev Checks that bridged amount of tokens conforms to the configured execution limits.
* @param _token address of the token contract.
* @param _amount amount of bridge tokens.
* @return true, if specified amount can be processed and executed.
*/
function withinExecutionLimit(address _token, uint256 _amount) public view returns (bool) {
uint256 nextLimit = totalExecutedPerDay(_token, getCurrentDay()).add(_amount);
return
executionDailyLimit(address(0)) > 0 &&
executionDailyLimit(_token) >= nextLimit &&
_amount <= executionMaxPerTx(_token);
}
/**
* @dev Returns current day number.
* @return day number.
*/
function getCurrentDay() public view returns (uint256) {
// solhint-disable-next-line not-rely-on-time
return block.timestamp / 1 days;
}
/**
* @dev Updates daily limit for the particular token. Only owner can call this method.
* @param _token address of the token contract, or address(0) for configuring the efault limit.
* @param _dailyLimit daily allowed amount of bridged tokens, should be greater than maxPerTx.
* 0 value is also allowed, will stop the bridge operations in outgoing direction.
*/
function setDailyLimit(address _token, uint256 _dailyLimit) external onlyOwner {
require(isTokenRegistered(_token));
require(_dailyLimit > maxPerTx(_token) || _dailyLimit == 0);
uintStorage[keccak256(abi.encodePacked("dailyLimit", _token))] = _dailyLimit;
emit DailyLimitChanged(_token, _dailyLimit);
}
/**
* @dev Updates execution daily limit for the particular token. Only owner can call this method.
* @param _token address of the token contract, or address(0) for configuring the default limit.
* @param _dailyLimit daily allowed amount of executed tokens, should be greater than executionMaxPerTx.
* 0 value is also allowed, will stop the bridge operations in incoming direction.
*/
function setExecutionDailyLimit(address _token, uint256 _dailyLimit) external onlyOwner {
require(isTokenRegistered(_token));
require(_dailyLimit > executionMaxPerTx(_token) || _dailyLimit == 0);
uintStorage[keccak256(abi.encodePacked("executionDailyLimit", _token))] = _dailyLimit;
emit ExecutionDailyLimitChanged(_token, _dailyLimit);
}
/**
* @dev Updates execution maximum per transaction for the particular token. Only owner can call this method.
* @param _token address of the token contract, or address(0) for configuring the default limit.
* @param _maxPerTx maximum amount of executed tokens per one transaction, should be less than executionDailyLimit.
* 0 value is also allowed, wi...
// [truncated — 105085 bytes total]
Read Contract
bridgeContract 0xcd596583 → address
bridgedTokenAddress 0x2d70061f → address
dailyLimit 0xf3f51415 → uint256
executionDailyLimit 0x40f8dd86 → uint256
executionMaxPerTx 0x16ef1913 → uint256
getBridgeInterfacesVersion 0x9cb7595a → uint64, uint64, uint64
getBridgeMode 0x437764df → bytes4
getCurrentDay 0x3e6968b6 → uint256
isBridgedTokenDeployAcknowledged 0xae813e9f → bool
isInitialized 0x392e53cd → bool
isRegisteredAsNativeToken 0xc2173d43 → bool
isTokenRegistered 0x26aa101f → bool
maxAvailablePerTx 0x7610722f → uint256
maxPerTx 0x032f693f → uint256
mediatorBalance 0x194153d3 → uint256
mediatorContractOnOtherSide 0x871c0760 → address
messageFixed 0x59339982 → bool
minPerTx 0xa4b1c243 → uint256
nativeTokenAddress 0x61c04f84 → address
owner 0x8da5cb5b → address
requestGasLimit 0xbe3b625b → uint256
tokenFactory 0xe77772fe → address
totalExecutedPerDay 0xf2c54fe8 → uint256
totalSpentPerDay 0xab3a25d9 → uint256
withinExecutionLimit 0x3a50bc87 → bool
withinLimit 0x10775238 → bool
Write Contract 28 functions
These functions modify contract state and require a wallet transaction to execute.
claimTokens 0x69ffa08a
address _token
address _to
claimTokensFromTokenContract 0x64696f97
address _bridgedToken
address _token
address _to
deployAndHandleBridgedTokens 0x2ae87cdd
address _token
string _name
string _symbol
uint8 _decimals
address _recipient
uint256 _value
deployAndHandleBridgedTokensAndCall 0xd522cfd7
address _token
string _name
string _symbol
uint8 _decimals
address _recipient
uint256 _value
bytes _data
fixFailedMessage 0x0950d515
bytes32 _messageId
fixMediatorBalance 0xd0342acd
address _token
address _receiver
handleBridgedTokens 0x125e4cfb
address _token
address _recipient
uint256 _value
handleBridgedTokensAndCall 0xc5345761
address _token
address _recipient
uint256 _value
bytes _data
handleNativeTokens 0x272255bb
address _token
address _recipient
uint256 _value
handleNativeTokensAndCall 0x867f7a4d
address _token
address _recipient
uint256 _value
bytes _data
initialize 0x2c3500a6
address _bridgeContract
address _mediatorContract
uint256[3] _dailyLimitMaxPerTxMinPerTxArray
uint256[2] _executionDailyLimitExecutionMaxPerTxArray
uint256 _requestGasLimit
address _owner
address _tokenFactory
returns: bool
onTokenTransfer 0xa4c0ed36
address _from
uint256 _value
bytes _data
returns: bool
relayTokens 0x01e4f53a
address token
uint256 _value
relayTokens 0xad58bdd1
address token
address _receiver
uint256 _value
relayTokensAndCall 0xd7405481
address token
address _receiver
uint256 _value
bytes _data
requestFailedMessageFix 0x9a4a4395
bytes32 _messageId
setBridgeContract 0x0b26cf66
address _bridgeContract
setCustomTokenAddressPair 0x0b71a4a7
address _nativeToken
address _bridgedToken
setDailyLimit 0x2803212f
address _token
uint256 _dailyLimit
setExecutionDailyLimit 0x7837cf91
address _token
uint256 _dailyLimit
setExecutionMaxPerTx 0x01fcc1d3
address _token
uint256 _maxPerTx
setMaxPerTx 0xdb6fff8c
address _token
uint256 _maxPerTx
setMediatorContractOnOtherSide 0x6e5d6bea
address _mediatorContract
setMinPerTx 0xec47de2a
address _token
uint256 _minPerTx
setRequestGasLimit 0xf3b83791
uint256 _gasLimit
setTokenFactory 0x2f73a9f8
address _tokenFactory
transferOwnership 0xf2fde38b
address newOwner
upgradeToReverseMode 0x21d3ccb8
address _tokenFactory
Token Balances (1)
View Transfers →Recent Transactions
No transactions found for this address