Contract 0xbbc6009feffc27ce705322832cb2068f8c1e0a58 2

 

Contract Overview

Balance:
0 Ether

EtherValue:
$0.00

Token:
Txn Hash Method
Index
From
To
Value
0xa75fd8bcc149b3f362fbe8fa88be39a897cbfd25a591dea08beabb729882f12cMulticall8275482022-09-30 9:25:4852 mins ago0xf7bac63fc7ceacf0589f25454ecf5c2ce904997c IN  0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether0.00020303881.2
0xe81a59c32f96c9951e8a28a8a0ead3a5b8df756b9c507ceb6e7aaebeb3c9a885Multicall8272232022-09-29 23:04:4111 hrs 13 mins ago0x428ab2ba90eba0a4be7af34c9ac451ab061ac010 IN  0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether0.00018175681.2
0x492c84f1d30a185334a71160d89ee00ad387f1d93b805a26a100ce24daa62be7Deposit8272172022-09-29 22:46:1711 hrs 32 mins ago0xa047489a734df0ec795fd564ae1f5db474ab40d3 IN  0xbbc6009feffc27ce705322832cb2068f8c1e0a580.034144811800149 Ether0.0001043351
0xd4468047a2d4d6695dac9bb4929c638306d2c9278883fa80bec1c1a647f7d565Multicall8272152022-09-29 22:44:4111 hrs 33 mins ago0x428ab2ba90eba0a4be7af34c9ac451ab061ac010 IN  0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether0.00021521641.2
0x49c6134392f8a331642e681d90477c0fe8bdbbe9ad938d3ebc75fd02b75d21a5Multicall8270332022-09-29 16:55:0617 hrs 23 mins ago0xf7bac63fc7ceacf0589f25454ecf5c2ce904997c IN  0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether0.00041418721.2
0x7b9d98fe4bccac56b4322487a351dfabcc8a5d4cdd41402f33a42ba7e9a25b43Multicall8266362022-09-29 6:55:391 day 3 hrs ago0xf7bac63fc7ceacf0589f25454ecf5c2ce904997c IN  0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether0.00022194241.2
0x68ac7a47eeaa026967373647ac80f86d7ed7da76a0adaf006be29f6ceb838f01Deposit8265252022-09-29 2:31:341 day 7 hrs ago0x224e69025a2f705c8f31efb6694398f8fd09ac5c IN  0xbbc6009feffc27ce705322832cb2068f8c1e0a580.007 Ether0.0001314051
0x225aa9ef387f148350beed4ec8bc5c0b25cb8a7e5755856d957c66628d831903Speed Up Deposit8265232022-09-29 2:30:131 day 7 hrs ago0x224e69025a2f705c8f31efb6694398f8fd09ac5c IN  0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether0.0001131691
0x1f91e8e872d4db78d9de5cd24c39afcc7e3e98a0f38fb254e4169b817cf45dffDeposit8265192022-09-29 2:21:521 day 7 hrs ago0x224e69025a2f705c8f31efb6694398f8fd09ac5c IN  0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether0.0001236481
0xcc58c802e8a03c2c4ae9d6ae038e3f5daf26071a0e1b8151ae41fd3088534959Multicall8265112022-09-29 2:14:451 day 8 hrs ago0x428ab2ba90eba0a4be7af34c9ac451ab061ac010 IN  0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether0.0002271061.2
0x0c205653df2a236c88b36831307e3c1853126cceb2da45d6127a7c1f256a9222Multicall8264282022-09-28 23:22:401 day 10 hrs ago0x428ab2ba90eba0a4be7af34c9ac451ab061ac010 IN  0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether0.00020313121.2
0x7ba9f749e153361259261f5b879f8ffbb4259f7ad74e7c286d506253f5a373d4Multicall8264222022-09-28 23:06:521 day 11 hrs ago0x428ab2ba90eba0a4be7af34c9ac451ab061ac010 IN  0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether0.00020319481.2
0x632ba18d5e6ed01e4d2435ae672d6690bfd2ad5f34d3b51667ff1a644afc5c18Multicall8263202022-09-28 19:55:191 day 14 hrs ago0xf7bac63fc7ceacf0589f25454ecf5c2ce904997c IN  0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether0.00043000561.2
0xb69c8bb9be1dcf3102053ab47dc91c2f48ffd081d9ec373731a714a917758f81Multicall8262602022-09-28 18:18:401 day 15 hrs ago0x428ab2ba90eba0a4be7af34c9ac451ab061ac010 IN  0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether0.000322531.2
0x671fc2d0110b2c630495c4394a4241040684f22907f2599cffe4833df10a9b54Multicall8261202022-09-28 14:54:571 day 19 hrs ago0xf7bac63fc7ceacf0589f25454ecf5c2ce904997c IN  0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether0.00038495761.2
0x9e7189ef1b61dc071b9cc0837164d02915f64dfa19692bd0d5016ee77067ac3fDeposit8260762022-09-28 14:12:381 day 20 hrs ago0x8125846a06527ecdfc731b21081ac166426fb3ff IN  0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether0.0001264781
0x9922afc59f4d76a2f45fa280a30198f3e4609a5ae83d21c942008aed2b0b324fMulticall8260642022-09-28 14:08:401 day 20 hrs ago0x428ab2ba90eba0a4be7af34c9ac451ab061ac010 IN  0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether0.0002257141.2
0xfaa347560b2f7e4f27ae46952268ec482bd0377293921c85962b730eed58ba7fMulticall8260572022-09-28 14:02:421 day 20 hrs ago0x428ab2ba90eba0a4be7af34c9ac451ab061ac010 IN  0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether0.00020877721.2
0xffb9214f64b0be84cf8a9cffd26c8576535857ddc7a5ad410e9959306f5b4a9aDeposit8256822022-09-28 4:15:512 days 6 hrs ago0xde1d5bd2c0520fbaa844be002a646c657a39f66a IN  0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether0.0001072411
0x380dd5869603efe5d91dfe5c1f6956defc076fc36648127dc978363151f88110Multicall8256802022-09-28 4:12:402 days 6 hrs ago0x428ab2ba90eba0a4be7af34c9ac451ab061ac010 IN  0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether0.00020652481.2
0x46d483aa19c5b72494485f9f7d5f58a28fe24b809bd508069e9d6b2827ee5e29Multicall8256502022-09-28 3:10:392 days 7 hrs ago0x428ab2ba90eba0a4be7af34c9ac451ab061ac010 IN  0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether0.00017865361.2
0x941cd01f1531b86d31392186e6a67b149f98edde6025f2b968f2ae2885d52ac8Multicall8256422022-09-28 2:54:502 days 7 hrs ago0xf7bac63fc7ceacf0589f25454ecf5c2ce904997c IN  0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether0.00027206041.2
0x2f62a27d74335aeabc731cd7c4f160a31220bf10efb176e8f745d2d3d90338daMulticall8254532022-09-27 21:55:072 days 12 hrs ago0xf7bac63fc7ceacf0589f25454ecf5c2ce904997c IN  0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether0.000171871.2
0xc797cb6d2c822a8512dc3ef3f321c8d014facab5ea62400a82927133faf7445cDeposit8253052022-09-27 18:37:512 days 15 hrs ago0x7d4053510c0e2ce0f127cf890fdb84f1a36cdc6d IN  0xbbc6009feffc27ce705322832cb2068f8c1e0a580.0417033 Ether0.0001309331
0x8c6a3db2fc5e7867c1a9785b9bc3aeba35d859892e49daf019050107a249c533Multicall8252262022-09-27 17:34:412 days 16 hrs ago0x428ab2ba90eba0a4be7af34c9ac451ab061ac010 IN  0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether0.00031223281.2
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0xa75fd8bcc149b3f362fbe8fa88be39a897cbfd25a591dea08beabb729882f12c8275482022-09-30 9:25:4852 mins ago 0xbbc6009feffc27ce705322832cb2068f8c1e0a58Null Address: 0x00...dEaD0 Ether
0xa75fd8bcc149b3f362fbe8fa88be39a897cbfd25a591dea08beabb729882f12c8275482022-09-30 9:25:4852 mins ago 0xbbc6009feffc27ce705322832cb2068f8c1e0a58Null Address: 0x00...dEaD0.046066968654994182 Ether
0xa75fd8bcc149b3f362fbe8fa88be39a897cbfd25a591dea08beabb729882f12c8275482022-09-30 9:25:4852 mins ago 0xbbc6009feffc27ce705322832cb2068f8c1e0a58 0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether
0x38879345349ae53ec6805bacdf848e2c4089d1f75a8f2dff8009cc3d0eb5c2f58275352022-09-30 8:56:521 hr 21 mins ago 0xbbc6009feffc27ce705322832cb2068f8c1e0a58Boba Network: L2 Cross Domain Messenger0 Ether
0x38879345349ae53ec6805bacdf848e2c4089d1f75a8f2dff8009cc3d0eb5c2f58275352022-09-30 8:56:521 hr 21 mins ago Boba Network: L2 Cross Domain Messenger 0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether
0xe81a59c32f96c9951e8a28a8a0ead3a5b8df756b9c507ceb6e7aaebeb3c9a8858272232022-09-29 23:04:4111 hrs 13 mins ago 0xbbc6009feffc27ce705322832cb2068f8c1e0a580xa047489a734df0ec795fd564ae1f5db474ab40d30.041724598975213542 Ether
0xe81a59c32f96c9951e8a28a8a0ead3a5b8df756b9c507ceb6e7aaebeb3c9a8858272232022-09-29 23:04:4111 hrs 13 mins ago Null Address: 0x00...dEaD 0xbbc6009feffc27ce705322832cb2068f8c1e0a580.041724598975213542 Ether
0xe81a59c32f96c9951e8a28a8a0ead3a5b8df756b9c507ceb6e7aaebeb3c9a8858272232022-09-29 23:04:4111 hrs 13 mins ago 0xbbc6009feffc27ce705322832cb2068f8c1e0a58Null Address: 0x00...dEaD0 Ether
0xe81a59c32f96c9951e8a28a8a0ead3a5b8df756b9c507ceb6e7aaebeb3c9a8858272232022-09-29 23:04:4111 hrs 13 mins ago 0xbbc6009feffc27ce705322832cb2068f8c1e0a58Null Address: 0x00...dEaD0 Ether
0xe81a59c32f96c9951e8a28a8a0ead3a5b8df756b9c507ceb6e7aaebeb3c9a8858272232022-09-29 23:04:4111 hrs 13 mins ago 0xbbc6009feffc27ce705322832cb2068f8c1e0a58 0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether
0x492c84f1d30a185334a71160d89ee00ad387f1d93b805a26a100ce24daa62be78272172022-09-29 22:46:1711 hrs 32 mins ago 0xbbc6009feffc27ce705322832cb2068f8c1e0a58Null Address: 0x00...dEaD0.034144811800149862 Ether
0xd4468047a2d4d6695dac9bb4929c638306d2c9278883fa80bec1c1a647f7d5658272152022-09-29 22:44:4111 hrs 33 mins ago 0xbbc6009feffc27ce705322832cb2068f8c1e0a580xa047489a734df0ec795fd564ae1f5db474ab40d30.038144811800149862 Ether
0xd4468047a2d4d6695dac9bb4929c638306d2c9278883fa80bec1c1a647f7d5658272152022-09-29 22:44:4111 hrs 33 mins ago Null Address: 0x00...dEaD 0xbbc6009feffc27ce705322832cb2068f8c1e0a580.038144811800149862 Ether
0xd4468047a2d4d6695dac9bb4929c638306d2c9278883fa80bec1c1a647f7d5658272152022-09-29 22:44:4111 hrs 33 mins ago 0xbbc6009feffc27ce705322832cb2068f8c1e0a58Null Address: 0x00...dEaD0 Ether
0xd4468047a2d4d6695dac9bb4929c638306d2c9278883fa80bec1c1a647f7d5658272152022-09-29 22:44:4111 hrs 33 mins ago 0xbbc6009feffc27ce705322832cb2068f8c1e0a58Null Address: 0x00...dEaD0 Ether
0xd4468047a2d4d6695dac9bb4929c638306d2c9278883fa80bec1c1a647f7d5658272152022-09-29 22:44:4111 hrs 33 mins ago 0xbbc6009feffc27ce705322832cb2068f8c1e0a58 0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether
0x49c6134392f8a331642e681d90477c0fe8bdbbe9ad938d3ebc75fd02b75d21a58270332022-09-29 16:55:0617 hrs 23 mins ago 0xbbc6009feffc27ce705322832cb2068f8c1e0a58Null Address: 0x00...dEaD0 Ether
0x49c6134392f8a331642e681d90477c0fe8bdbbe9ad938d3ebc75fd02b75d21a58270332022-09-29 16:55:0617 hrs 23 mins ago 0xbbc6009feffc27ce705322832cb2068f8c1e0a58Null Address: 0x00...dEaD0.004988735447562668 Ether
0x49c6134392f8a331642e681d90477c0fe8bdbbe9ad938d3ebc75fd02b75d21a58270332022-09-29 16:55:0617 hrs 23 mins ago 0xbbc6009feffc27ce705322832cb2068f8c1e0a58 0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether
0x49c6134392f8a331642e681d90477c0fe8bdbbe9ad938d3ebc75fd02b75d21a58270332022-09-29 16:55:0617 hrs 23 mins ago 0xbbc6009feffc27ce705322832cb2068f8c1e0a58Boba Network: L2 Standard Bridge0 Ether
0x49c6134392f8a331642e681d90477c0fe8bdbbe9ad938d3ebc75fd02b75d21a58270332022-09-29 16:55:0617 hrs 23 mins ago 0xbbc6009feffc27ce705322832cb2068f8c1e0a58 0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether
0x467c0beca83c67836ed63b2ba2fdc0ec37bebc5a86f2f73e033a6853e42d1c978270042022-09-29 16:28:4217 hrs 49 mins ago 0xbbc6009feffc27ce705322832cb2068f8c1e0a58Boba Network: L2 Cross Domain Messenger0 Ether
0x467c0beca83c67836ed63b2ba2fdc0ec37bebc5a86f2f73e033a6853e42d1c978270042022-09-29 16:28:4217 hrs 49 mins ago Boba Network: L2 Cross Domain Messenger 0xbbc6009feffc27ce705322832cb2068f8c1e0a580 Ether
0x7b9d98fe4bccac56b4322487a351dfabcc8a5d4cdd41402f33a42ba7e9a25b438266362022-09-29 6:55:391 day 3 hrs ago 0xbbc6009feffc27ce705322832cb2068f8c1e0a58Null Address: 0x00...dEaD0 Ether
0x7b9d98fe4bccac56b4322487a351dfabcc8a5d4cdd41402f33a42ba7e9a25b438266362022-09-29 6:55:391 day 3 hrs ago 0xbbc6009feffc27ce705322832cb2068f8c1e0a58Null Address: 0x00...dEaD0.026974654757016001 Ether
[ Download CSV Export 
Latest 25 Deposits
L2 Txn Hash L1 Deposit Txn Value Token
0xbefc06f25d5af28e3fab4e318fb40901deabbe5ae1315dad05f6d10df8c34ed62022-09-30 8:56:521 hr 21 mins ago0x5e8e4609fd729d17e163c5d3edc21adc3078b3e557f5e4ed085ffb8201d0ae1d0.046066968654994182 Ether (ETH)
0x98cd554743e813df93472b07195896092c07defb11c2a3ac123ccbae5861f9282022-09-29 16:28:4217 hrs 49 mins ago0x7f13cbf19755255e4a37cc0153c866d1bd558d401b68e63214fe6d5767a86e3a0.004988735447562668 Ether (ETH)
0xd96a5b095d878bd912cf37a83a9d0d54809ee57172b83e8f575b3c1d670913622022-09-29 6:27:511 day 3 hrs ago0xcdea8b4dddcff95a829110273a04470bf390e907d3539eba1bff52253f522b674,043.360067733985594218 Boba Token (BOBA)
0x602d56e6bb876826b38f43d8f2934d9843e08b7468d77608b3bdb245830435bd2022-09-29 6:27:511 day 3 hrs ago0xcdea8b4dddcff95a829110273a04470bf390e907d3539eba1bff52253f522b670.026974654757016001 Ether (ETH)
0x741ab449c28f5a6eada889cfa715eaf53042e85ceb8162746d77e9245d303a252022-09-28 19:26:161 day 14 hrs ago0xff1b98c4137d49eefce0b758212807e966cc95bb601b1ed6696f8b327aca205d4.99677089144899635 Boba Token (BOBA)
0x10ef6e9541a2294bdf46f50301fb21ca43af6f5a20103e9431ba7040468a290f2022-09-28 19:26:161 day 14 hrs ago0xff1b98c4137d49eefce0b758212807e966cc95bb601b1ed6696f8b327aca205d0.000999061287296742 Ether (ETH)
0x0ceb18d8aa67731fac5e03207781980ae770be9d5ca0108370e4d1099eccb8242022-09-28 14:26:141 day 19 hrs ago0x762ddf2d74c156bf69f5e0e4cb947a43749f2d4ff120150b520b40fe788893d10.001998122574593739 Ether (ETH)
0x2ca3e28cab232111df097620e11cf636e3c4f15cdb43b81bfced9c777df620962022-09-27 21:25:512 days 12 hrs ago0xc75bcfef8483878510e1c7751464ef0ae3fc983053573eb89a08ab474d97e38c0.052844347730281461 Ether (ETH)
0xe64a43e796f8260c6783b4797867f7dc70a44a8dcf1b6d9dd880f4b290c5a1ad2022-09-27 11:27:012 days 22 hrs ago0xf89cd4603c132ba4378ad7262231281851bcdc12ed3e3dc15e633e52705b40e80.000263486129950066 Ether (ETH)
0x93a420eedacdf148b691e141128dac39bbbbf964bd1825d0d7e7f5a22b07fbe52022-09-26 14:27:113 days 19 hrs ago0x5347b892b7ef32ed4397b77ef09926464ddb468ed551557f161fc42f9e011e2f0.002098028703323316 Ether (ETH)
0x6c88d7e2085867e46c185e6b7cfef2ffeaabae3599212b95fb995fd9332aa5ea2022-09-25 14:49:374 days 19 hrs ago0xff1ac6c1abd1d04b31aa928278dcd916aaf813f995d7445678a8b134d14d40060.004995306436484319 Ether (ETH)
0x8e0d68e8ed89654d5d68c5e48b79d1cc910474a32055b1efc4ce12301d22762f2022-09-25 9:56:145 days 22 mins ago0x31a330c319722e860ed77a0b969c6442e03364d30be3028bc249a662bf3f3e7c0.00499530643648446 Ether (ETH)
0x9f9b0b5ec4396075bb635f244afcfc5f5160430a730dc58df29f4c9af47dbb132022-09-24 12:26:265 days 21 hrs ago0x605356618a6c383e5d869a94def62dc7ad55c50c0107fb0eb7258672ea831abe9,992.45471 USD Coin (USDC)
0x7490de61a1ba2beef8a48807bbd0cc572cd629aba23929b85aef23f65adbc4ef2022-09-22 17:14:567 days 17 hrs ago0xcb0b5d03e03cdd4c7449c60a4be35bd1bcd2aa382494b5c8e793d7c9399633ff9,995.09584760749103 Boba Token (BOBA)
0x93418d62d49a33cad46b03ead5d1080f65798ec7abffbc9d1965f36a1235b92a2022-09-22 17:14:567 days 17 hrs ago0xcb0b5d03e03cdd4c7449c60a4be35bd1bcd2aa382494b5c8e793d7c9399633ff0.001065852439699232 Ether (ETH)
0xd0a9da032f749dcf1ee66005f53406c7faa36e4d6aa509a20b1a980af4e1a5a12022-09-22 12:39:057 days 21 hrs ago0x73bccceb903f107e7e59b122afd6e9ef7a47727489441890e8a989e9a768b12342,526.780582970635311371 Boba Token (BOBA)
0xc0b551f48e18df0bed209c91959d7a7743ee76a4e55fb76ea1fb5c5fb9ddfc042022-09-22 3:24:158 days 6 hrs ago0x3ce715b6b474e7ade0efe56c49f680024c03c3378c3c0144fc8dab511b5be4c93.466117779684728761 Boba Token (BOBA)
0x7fcd2e299018a95c9c39664643c85f6ece7add3112b5357ed24204a522b7d1ed2022-09-19 15:13:2510 days 19 hrs ago0x20f571b3f8142f1d20e8a8ac30ba284b55fbaff9f6b86a805851170a11198bc50.929126997186106059 Ether (ETH)
0x8f7f680637151d1d42ed185779d25aa176fc5b47d8aabe27004dda64b7b3d7f12022-09-12 22:34:0817 days 11 hrs ago0x541516a4b3ae5f660fd36fb0eee67902f24c809a755b8598800681299582cce10.12034308833545749 Ether (ETH)
0x03f39f1532ebc8d21bb0ede52d5b3c563c99be3cc9f06d285ca710c5b4e118562022-09-10 2:21:1320 days 7 hrs ago0x1e8949c5b9594885ab961f7eefe77d91bed51c591aeae057205ee4693bdb832d166.531087403894489428 Boba Token (BOBA)
0xcd82e41bfc80ac465674f5bd24b5b3ea3c3492936067c744750f0a963ca18e792022-09-08 14:09:1221 days 20 hrs ago0x67c71321d45dd3c22cef6cdf8fa63557012a7b691ce8e3bdff433feee31934370.499530643648444138 Ether (ETH)
0xf2784535391f10aff3921517038c8ab5aff28b66f2a5292ca92e55ca2bf877882022-09-08 9:37:5722 days 40 mins ago0x28e6a06989215bc5366fd9960f5a464d26bee941f844393efb217329821d558a0.013245167279837222 Ether (ETH)
0xccab73cc0a4be817ac7f4a08106d0d6859e89f096218b2439faef3b72dd6c2fd2022-09-08 0:59:0822 days 9 hrs ago0x8f1189e228d4628c0e42ff90b5947e61eff8261d19722a2ae6d57e2fa4e292950.004513150114339234 Ether (ETH)
0xcb4fdf085487d27f4322e8c952f071eb3da5a2355b5ef9db5167a0791445f01d2022-09-07 15:58:2522 days 18 hrs ago0x01014397393ce772d120bc95cd00348c6ad26ba8269b64ddbc1726dc4625c90b10.31471852717923175 Boba Token (BOBA)
0x0a67e3e62ea472ea8df68ff3c3f9e0e03469f477808ad856d3b04e9c60201b482022-09-07 2:30:1323 days 7 hrs ago0xe5105d1d36eb252a3a37ae67c1c2655a2134440f734350cc3211715975aee9790.004469770773602399 Ether (ETH)
[ Download CSV Export 
Latest 25 Withdrawals
L2 Txn Hash Value Token Status L1 Withdrawal Txn
0x49c6134392f8a331642e681d90477c0fe8bdbbe9ad938d3ebc75fd02b75d21a52022-09-29 16:55:0617 hrs 23 mins ago386.255197 USD Coin (USDC)Waitingn/a
0x632ba18d5e6ed01e4d2435ae672d6690bfd2ad5f34d3b51667ff1a644afc5c182022-09-28 19:55:191 day 14 hrs ago468.290918 USD Coin (USDC)Waitingn/a
0x671fc2d0110b2c630495c4394a4241040684f22907f2599cffe4833df10a9b542022-09-28 14:54:571 day 19 hrs ago50.829226 USD Coin (USDC)Waitingn/a
0x941cd01f1531b86d31392186e6a67b149f98edde6025f2b968f2ae2885d52ac82022-09-28 2:54:502 days 7 hrs ago0.0417033 Ether (ETH)Waitingn/a
0x2e2b997b03d5c5a9be3350c4a0a7ee725a7a316bb0c83c4c80ef04dfc1b076b42022-09-27 11:54:452 days 22 hrs ago4,962.668825 USD Coin (USDC)Waitingn/a
0x27dc161d900bfd8016bb888152aff0799274ee9b84c32c10974044a7ba11e7372022-09-26 14:57:073 days 19 hrs ago52.001744 USD Coin (USDC)Waitingn/a
0x88aa191e2a00e2c52877ce43c0259222c3e000623ed92ad0afe00f11860348792022-09-26 1:24:554 days 8 hrs ago0.343068605436914829 Ether (ETH)Waitingn/a
0x88aa191e2a00e2c52877ce43c0259222c3e000623ed92ad0afe00f11860348792022-09-26 1:24:554 days 8 hrs ago25,300.635489806664000799 Boba Token (BOBA)Waitingn/a
0xaed5021d4e938b727585734179bdbf163bd13e3ad4164e2c157bdf1aa6ce2f9a2022-09-25 20:25:514 days 13 hrs ago0.301 Ether (ETH)Waitingn/a
0x3b6efee0d8a78dc6ef4e0e2c96119d3babecdba3cdb472dad47dc0892f531ddc2022-09-24 23:54:535 days 10 hrs ago0.10571080023254247 Ether (ETH)Waitingn/a
0x0efc6ecb445d8696205645fd6238b061683fa652a2d6d4118c5c392031e882092022-09-24 17:54:075 days 16 hrs ago9,123.193065317473411559 Boba Token (BOBA)Waitingn/a
0x0efc6ecb445d8696205645fd6238b061683fa652a2d6d4118c5c392031e882092022-09-24 17:54:075 days 16 hrs ago7,159.354435 USD Coin (USDC)Waitingn/a
0x888f1ade590c448d4453e9ef1ea98d3326a12e4a2f033c805dfa3b1c1f51b30c2022-09-24 12:54:195 days 21 hrs ago5,228.156266598098929806 Boba Token (BOBA)Waitingn/a
0x8b556300f19bbeb70dac3a0743874408c022c49edde09b976951b49bd8baa2c92022-09-24 2:27:596 days 7 hrs ago50 USD Coin (USDC)Waitingn/a
0x9d3c9587ecf44f2a1896081fe118bc623ef6ee22ced3beeec41752d459f3ffc22022-09-23 21:51:466 days 12 hrs ago0.149105261112815122 Ether (ETH)Waitingn/a
0x9d3c9587ecf44f2a1896081fe118bc623ef6ee22ced3beeec41752d459f3ffc22022-09-23 21:51:466 days 12 hrs ago11,500.101444761934773998 Boba Token (BOBA)Waitingn/a
0x9d3c9587ecf44f2a1896081fe118bc623ef6ee22ced3beeec41752d459f3ffc22022-09-23 21:51:466 days 12 hrs ago1,357.111078 USD Coin (USDC)Waitingn/a
0x4072624f8517b1ec417e5841359a46bfaa96cb34cbb355507b430e33f880aa1f2022-09-22 22:22:597 days 11 hrs ago2.8 USD Coin (USDC)Relayed0x840d089ef18c3ea013dbdfeabedb87447d36a62d243db6743f321c30bf2eb12c
0x21ff95d4646154239cc7d75f9cf81bdee811caa452babffc9eed5672c3f17b0f2022-09-22 3:53:198 days 6 hrs ago0.04573023536714826 Ether (ETH)Relayed0x7535f1e94546c9d98fef88f998e01462034375a6f35a715a17e0278ef26b0206
0x59d77694724f592360547df477dc566a68f53a88f7618d9273c7634edceb6baa2022-09-21 18:13:138 days 16 hrs ago2,871.703819228426722257 Dai Stableco... (DAI)Relayed0xa248abbbca0767009e71457f222aadd03a40eb7b254aa2f51bfeea1d9dd85825
0x63113497f201d09339c037a114dab40914cb010c12f54351d53300040616d3b92022-09-21 13:33:128 days 20 hrs ago72.009632 USD Coin (USDC)Relayed0xd1ed24f9e1a55dc27e34bde9e36ac17d4ca4a30174f29a105f3a6aceea736bc3
0xdf3bc133ab26bfc783d7258a9ef7fcf9c3dc92b96ecd461ce47cf6be683425c72022-09-21 0:13:299 days 10 hrs ago145.664411593815817233 Boba Token (BOBA)Relayed0x67c819c028d6cc24fe8e53735ec3ab19beba25009db921d558efc4e3b05332e8
0x369661782a0804ba9cecdd31198ec395c63d698c7257395f91f01f6f48201a272022-09-20 19:04:269 days 15 hrs ago0.91 Ether (ETH)Relayed0xa9f6478fe3ea381b529af8ac731d063464ee5baa25055d0b39dc666e09d86f08
0x8d8a03d3f6d0a8a1c929f65bfe4a353395b9c5f88c2bbe7fc24fc9d6f53b17342022-09-20 2:36:1710 days 7 hrs ago0.008165478562645574 Ether (ETH)Relayed0x2dc7482f522d475d99949968e1dd2d9a49f3944e784e0b9ff37abbc9d071617a
0xf5c9d29354c0404b28ea736bfdd658a50a8b69c5c5b9d8835b5b78e0b2f9e8012022-09-19 15:42:5110 days 18 hrs ago15,000 USD Coin (USDC)Relayed0x2ef5ac00bf3fef91af6627e88e4a8fa158231cd189ca4855cfdec2e69b6952c3
[ Download CSV Export 
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.

Contract Source Code Verified (Exact Match)

Contract Name:
Boba_SpokePool

Compiler Version
v0.8.13+commit.abaa5c0e

Optimization Enabled:
Yes with 1000000 runs

Other Settings:
default evmVersion, GNU GPLv3 license
File 1 of 60 : AcrossConfigStore.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

import "@uma/core/contracts/common/implementation/MultiCaller.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

/**
 * @title Allows admin to set and update configuration settings for full contract system. These settings are designed
 * to be consumed by off-chain bots, rather than by other contracts.
 * @dev This contract should not perform any validation on the setting values and should be owned by the governance
 * system of the full contract suite..
 */
contract AcrossConfigStore is Ownable, MultiCaller {
    // General dictionary where admin can associate variables with specific L1 tokens, like the Rate Model and Token
    // Transfer Thresholds.
    mapping(address => string) public l1TokenConfig;

    // General dictionary where admin can store global variables like `MAX_POOL_REBALANCE_LEAF_SIZE` and
    // `MAX_RELAYER_REPAYMENT_LEAF_SIZE` that off-chain agents can query.
    mapping(bytes32 => string) public globalConfig;

    event UpdatedTokenConfig(address indexed key, string value);
    event UpdatedGlobalConfig(bytes32 indexed key, string value);

    /**
     * @notice Updates token config.
     * @param l1Token the l1 token address to update value for.
     * @param value Value to update.
     */
    function updateTokenConfig(address l1Token, string memory value) external onlyOwner {
        l1TokenConfig[l1Token] = value;
        emit UpdatedTokenConfig(l1Token, value);
    }

    /**
     * @notice Updates global config.
     * @param key Key to update.
     * @param value Value to update.
     */
    function updateGlobalConfig(bytes32 key, string calldata value) external onlyOwner {
        globalConfig[key] = value;
        emit UpdatedGlobalConfig(key, value);
    }
}

File 2 of 60 : MultiCaller.sol
// This contract is taken from Uniswaps's multi call implementation (https://github.com/Uniswap/uniswap-v3-periphery/blob/main/contracts/base/Multicall.sol)
// and was modified to be solidity 0.8 compatible. Additionally, the method was restricted to only work with msg.value
// set to 0 to avoid any nasty attack vectors on function calls that use value sent with deposits.
pragma solidity ^0.8.0;

/// @title MultiCaller
/// @notice Enables calling multiple methods in a single call to the contract
contract MultiCaller {
    function multicall(bytes[] calldata data) external payable returns (bytes[] memory results) {
        require(msg.value == 0, "Only multicall with 0 value");
        results = new bytes[](data.length);
        for (uint256 i = 0; i < data.length; i++) {
            (bool success, bytes memory result) = address(this).delegatecall(data[i]);

            if (!success) {
                // Next 5 lines from https://ethereum.stackexchange.com/a/83577
                if (result.length < 68) revert();
                assembly {
                    result := add(result, 0x04)
                }
                revert(abi.decode(result, (string)));
            }

            results[i] = result;
        }
    }
}

File 3 of 60 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

File 4 of 60 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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;
    }
}

File 5 of 60 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @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
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @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");

        (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");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        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

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 6 of 60 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../../../utils/Address.sol";

/**
 * @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 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'
        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) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _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
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 7 of 60 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @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 `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);

    /**
     * @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);
}

File 8 of 60 : PolygonTokenBridger.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

import "./Lockable.sol";
import "./interfaces/WETH9.sol";

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

// Polygon Registry contract that stores their addresses.
interface PolygonRegistry {
    function erc20Predicate() external returns (address);
}

// Polygon ERC20Predicate contract that handles Plasma exits (only used for Matic).
interface PolygonERC20Predicate {
    function startExitWithBurntTokens(bytes calldata data) external;
}

// ERC20s (on polygon) compatible with polygon's bridge have a withdraw method.
interface PolygonIERC20 is IERC20 {
    function withdraw(uint256 amount) external;
}

interface MaticToken {
    function withdraw(uint256 amount) external payable;
}

/**
 * @notice Contract deployed on Ethereum and Polygon to facilitate token transfers from Polygon to the HubPool and back.
 * @dev Because Polygon only allows withdrawals from a particular address to go to that same address on mainnet, we need to
 * have some sort of contract that can guarantee identical addresses on Polygon and Ethereum. This contract is intended
 * to be completely immutable, so it's guaranteed that the contract on each side is  configured identically as long as
 * it is created via create2. create2 is an alternative creation method that uses a different address determination
 * mechanism from normal create.
 * Normal create: address = hash(deployer_address, deployer_nonce)
 * create2:       address = hash(0xFF, sender, salt, bytecode)
 *  This ultimately allows create2 to generate deterministic addresses that don't depend on the transaction count of the
 * sender.
 */
contract PolygonTokenBridger is Lockable {
    using SafeERC20 for PolygonIERC20;
    using SafeERC20 for IERC20;

    // Gas token for Polygon.
    MaticToken public constant maticToken = MaticToken(0x0000000000000000000000000000000000001010);

    // Should be set to HubPool on Ethereum, or unused on Polygon.
    address public immutable destination;

    // Registry that stores L1 polygon addresses.
    PolygonRegistry public immutable l1PolygonRegistry;

    // WETH contract on Ethereum.
    WETH9 public immutable l1Weth;

    // Wrapped Matic on Polygon
    address public immutable l2WrappedMatic;

    // Chain id for the L1 that this contract is deployed on or communicates with.
    // For example: if this contract were meant to facilitate transfers from polygon to mainnet, this value would be
    // the mainnet chainId 1.
    uint256 public immutable l1ChainId;

    // Chain id for the L2 that this contract is deployed on or communicates with.
    // For example: if this contract were meant to facilitate transfers from polygon to mainnet, this value would be
    // the polygon chainId 137.
    uint256 public immutable l2ChainId;

    modifier onlyChainId(uint256 chainId) {
        _requireChainId(chainId);
        _;
    }

    /**
     * @notice Constructs Token Bridger contract.
     * @param _destination Where to send tokens to for this network.
     * @param _l1PolygonRegistry L1 registry that stores updated addresses of polygon contracts. This should always be
     * set to the L1 registry regardless if whether it's deployed on L2 or L1.
     * @param _l1Weth L1 WETH address.
     * @param _l2WrappedMatic L2 address of wrapped matic token.
     * @param _l1ChainId the chain id for the L1 in this environment.
     * @param _l2ChainId the chain id for the L2 in this environment.
     */
    constructor(
        address _destination,
        PolygonRegistry _l1PolygonRegistry,
        WETH9 _l1Weth,
        address _l2WrappedMatic,
        uint256 _l1ChainId,
        uint256 _l2ChainId
    ) {
        destination = _destination;
        l1PolygonRegistry = _l1PolygonRegistry;
        l1Weth = _l1Weth;
        l2WrappedMatic = _l2WrappedMatic;
        l1ChainId = _l1ChainId;
        l2ChainId = _l2ChainId;
    }

    /**
     * @notice Called by Polygon SpokePool to send tokens over bridge to contract with the same address as this.
     * @notice The caller of this function must approve this contract to spend amount of token.
     * @param token Token to bridge.
     * @param amount Amount to bridge.
     */
    function send(PolygonIERC20 token, uint256 amount) public nonReentrant onlyChainId(l2ChainId) {
        token.safeTransferFrom(msg.sender, address(this), amount);

        // In the wMatic case, this unwraps. For other ERC20s, this is the burn/send action.
        token.withdraw(token.balanceOf(address(this)));

        // This takes the token that was withdrawn and calls withdraw on the "native" ERC20.
        if (address(token) == l2WrappedMatic)
            maticToken.withdraw{ value: address(this).balance }(address(this).balance);
    }

    /**
     * @notice Called by someone to send tokens to the destination, which should be set to the HubPool.
     * @param token Token to send to destination.
     */
    function retrieve(IERC20 token) public nonReentrant onlyChainId(l1ChainId) {
        if (address(token) == address(l1Weth)) {
            // For WETH, there is a pre-deposit step to ensure any ETH that has been sent to the contract is captured.
            l1Weth.deposit{ value: address(this).balance }();
        }
        token.safeTransfer(destination, token.balanceOf(address(this)));
    }

    /**
     * @notice Called to initiate an l1 exit (withdrawal) of matic tokens that have been sent over the plasma bridge.
     * @param data the proof data to trigger the exit. Can be generated using the maticjs-plasma package.
     */
    function callExit(bytes memory data) public nonReentrant onlyChainId(l1ChainId) {
        PolygonERC20Predicate erc20Predicate = PolygonERC20Predicate(l1PolygonRegistry.erc20Predicate());
        erc20Predicate.startExitWithBurntTokens(data);
    }

    receive() external payable {
        // This method is empty to avoid any gas expendatures that might cause transfers to fail.
        // Note: the fact that there is _no_ code in this function means that matic can be erroneously transferred in
        // to the contract on the polygon side. These tokens would be locked indefinitely since the receive function
        // cannot be called on the polygon side. While this does have some downsides, the lack of any functionality
        // in this function means that it has no chance of running out of gas on transfers, which is a much more
        // important benefit. This just makes the matic token risk similar to that of ERC20s that are erroneously
        // sent to the contract.
    }

    function _requireChainId(uint256 chainId) internal view {
        require(block.chainid == chainId, "Cannot run method on this chain");
    }
}

File 9 of 60 : Lockable.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

/**
 * @title A contract that provides modifiers to prevent reentrancy to state-changing and view-only methods. This contract
 * is inspired by https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/ReentrancyGuard.sol
 * and https://github.com/balancer-labs/balancer-core/blob/master/contracts/BPool.sol.
 * @dev The reason why we use this local contract instead of importing from uma/contracts is because of the addition
 * of the internal method `functionCallStackOriginatesFromOutsideThisContract` which doesn't exist in the one exported
 * by uma/contracts.
 */
contract Lockable {
    bool internal _notEntered;

    constructor() {
        // Storing an initial non-zero value makes deployment a bit more expensive, but in exchange the refund on every
        // call to nonReentrant will be lower in amount. Since refunds are capped to a percentage of the total
        // transaction's gas, it is best to keep them low in cases like this one, to increase the likelihood of the full
        // refund coming into effect.
        _notEntered = true;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a nonReentrant function from another nonReentrant function is not supported. It is possible to
     * prevent this from happening by making the nonReentrant function external, and making it call a private
     * function that does the actual state modification.
     */
    modifier nonReentrant() {
        _preEntranceCheck();
        _preEntranceSet();
        _;
        _postEntranceReset();
    }

    /**
     * @dev Designed to prevent a view-only method from being re-entered during a call to a nonReentrant() state-changing method.
     */
    modifier nonReentrantView() {
        _preEntranceCheck();
        _;
    }

    /**
     * @dev Returns true if the contract is currently in a non-entered state, meaning that the origination of the call
     * came from outside the contract. This is relevant with fallback/receive methods to see if the call came from ETH
     * being dropped onto the contract externally or due to ETH dropped on the the contract from within a method in this
     * contract, such as unwrapping WETH to ETH within the contract.
     */
    function functionCallStackOriginatesFromOutsideThisContract() internal view returns (bool) {
        return _notEntered;
    }

    // Internal methods are used to avoid copying the require statement's bytecode to every nonReentrant() method.
    // On entry into a function, _preEntranceCheck() should always be called to check if the function is being
    // re-entered. Then, if the function modifies state, it should call _postEntranceSet(), perform its logic, and
    // then call _postEntranceReset().
    // View-only methods can simply call _preEntranceCheck() to make sure that it is not being re-entered.
    function _preEntranceCheck() internal view {
        // On the first call to nonReentrant, _notEntered will be true
        require(_notEntered, "ReentrancyGuard: reentrant call");
    }

    function _preEntranceSet() internal {
        // Any calls to nonReentrant after this point will fail
        _notEntered = false;
    }

    function _postEntranceReset() internal {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _notEntered = true;
    }
}

File 10 of 60 : WETH9.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.0;

interface WETH9 {
    function withdraw(uint256 wad) external;

    function deposit() external payable;

    function balanceOf(address guy) external view returns (uint256 wad);

    function transfer(address guy, uint256 wad) external;
}

File 11 of 60 : PolygonERC20Test.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

import "@uma/core/contracts/common/implementation/ExpandedERC20.sol";
import "../PolygonTokenBridger.sol";

/**
 * @notice Simulated Polygon ERC20 for use in testing PolygonTokenBridger.
 */
contract PolygonERC20Test is ExpandedERC20, PolygonIERC20 {
    constructor() ExpandedERC20("Polygon Test", "POLY_TEST", 18) {} // solhint-disable-line no-empty-blocks

    function withdraw(uint256 amount) public {
        _burn(msg.sender, amount);
    }
}

File 12 of 60 : ExpandedERC20.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "./MultiRole.sol";
import "../interfaces/ExpandedIERC20.sol";

/**
 * @title An ERC20 with permissioned burning and minting. The contract deployer will initially
 * be the owner who is capable of adding new roles.
 */
contract ExpandedERC20 is ExpandedIERC20, ERC20, MultiRole {
    enum Roles {
        // Can set the minter and burner.
        Owner,
        // Addresses that can mint new tokens.
        Minter,
        // Addresses that can burn tokens that address owns.
        Burner
    }

    uint8 _decimals;

    /**
     * @notice Constructs the ExpandedERC20.
     * @param _tokenName The name which describes the new token.
     * @param _tokenSymbol The ticker abbreviation of the name. Ideally < 5 chars.
     * @param _tokenDecimals The number of decimals to define token precision.
     */
    constructor(
        string memory _tokenName,
        string memory _tokenSymbol,
        uint8 _tokenDecimals
    ) ERC20(_tokenName, _tokenSymbol) {
        _decimals = _tokenDecimals;
        _createExclusiveRole(uint256(Roles.Owner), uint256(Roles.Owner), msg.sender);
        _createSharedRole(uint256(Roles.Minter), uint256(Roles.Owner), new address[](0));
        _createSharedRole(uint256(Roles.Burner), uint256(Roles.Owner), new address[](0));
    }

    function decimals() public view virtual override(ERC20) returns (uint8) {
        return _decimals;
    }

    /**
     * @dev Mints `value` tokens to `recipient`, returning true on success.
     * @param recipient address to mint to.
     * @param value amount of tokens to mint.
     * @return True if the mint succeeded, or False.
     */
    function mint(address recipient, uint256 value)
        external
        override
        onlyRoleHolder(uint256(Roles.Minter))
        returns (bool)
    {
        _mint(recipient, value);
        return true;
    }

    /**
     * @dev Burns `value` tokens owned by `msg.sender`.
     * @param value amount of tokens to burn.
     */
    function burn(uint256 value) external override onlyRoleHolder(uint256(Roles.Burner)) {
        _burn(msg.sender, value);
    }

    /**
     * @dev Burns `value` tokens owned by `recipient`.
     * @param recipient address to burn tokens from.
     * @param value amount of tokens to burn.
     * @return True if the burn succeeded, or False.
     */
    function burnFrom(address recipient, uint256 value)
        external
        override
        onlyRoleHolder(uint256(Roles.Burner))
        returns (bool)
    {
        _burn(recipient, value);
        return true;
    }

    /**
     * @notice Add Minter role to account.
     * @dev The caller must have the Owner role.
     * @param account The address to which the Minter role is added.
     */
    function addMinter(address account) external virtual override {
        addMember(uint256(Roles.Minter), account);
    }

    /**
     * @notice Add Burner role to account.
     * @dev The caller must have the Owner role.
     * @param account The address to which the Burner role is added.
     */
    function addBurner(address account) external virtual override {
        addMember(uint256(Roles.Burner), account);
    }

    /**
     * @notice Reset Owner role to account.
     * @dev The caller must have the Owner role.
     * @param account The new holder of the Owner role.
     */
    function resetOwner(address account) external virtual override {
        resetMember(uint256(Roles.Owner), account);
    }
}

File 13 of 60 : ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.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.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * 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}.
     *
     * The default value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * 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 value {ERC20} uses, unless this function is
     * 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, _allowances[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 = _allowances[owner][spender];
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        unchecked {
            _approve(owner, spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `sender` to `recipient`.
     *
     * 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;
        }
        _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;
        _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;
        }
        _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 Spend `amount` form the allowance of `owner` toward `spender`.
     *
     * 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 {}
}

File 14 of 60 : MultiRole.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

library Exclusive {
    struct RoleMembership {
        address member;
    }

    function isMember(RoleMembership storage roleMembership, address memberToCheck) internal view returns (bool) {
        return roleMembership.member == memberToCheck;
    }

    function resetMember(RoleMembership storage roleMembership, address newMember) internal {
        require(newMember != address(0x0), "Cannot set an exclusive role to 0x0");
        roleMembership.member = newMember;
    }

    function getMember(RoleMembership storage roleMembership) internal view returns (address) {
        return roleMembership.member;
    }

    function init(RoleMembership storage roleMembership, address initialMember) internal {
        resetMember(roleMembership, initialMember);
    }
}

library Shared {
    struct RoleMembership {
        mapping(address => bool) members;
    }

    function isMember(RoleMembership storage roleMembership, address memberToCheck) internal view returns (bool) {
        return roleMembership.members[memberToCheck];
    }

    function addMember(RoleMembership storage roleMembership, address memberToAdd) internal {
        require(memberToAdd != address(0x0), "Cannot add 0x0 to a shared role");
        roleMembership.members[memberToAdd] = true;
    }

    function removeMember(RoleMembership storage roleMembership, address memberToRemove) internal {
        roleMembership.members[memberToRemove] = false;
    }

    function init(RoleMembership storage roleMembership, address[] memory initialMembers) internal {
        for (uint256 i = 0; i < initialMembers.length; i++) {
            addMember(roleMembership, initialMembers[i]);
        }
    }
}

/**
 * @title Base class to manage permissions for the derived class.
 */
abstract contract MultiRole {
    using Exclusive for Exclusive.RoleMembership;
    using Shared for Shared.RoleMembership;

    enum RoleType { Invalid, Exclusive, Shared }

    struct Role {
        uint256 managingRole;
        RoleType roleType;
        Exclusive.RoleMembership exclusiveRoleMembership;
        Shared.RoleMembership sharedRoleMembership;
    }

    mapping(uint256 => Role) private roles;

    event ResetExclusiveMember(uint256 indexed roleId, address indexed newMember, address indexed manager);
    event AddedSharedMember(uint256 indexed roleId, address indexed newMember, address indexed manager);
    event RemovedSharedMember(uint256 indexed roleId, address indexed oldMember, address indexed manager);

    /**
     * @notice Reverts unless the caller is a member of the specified roleId.
     */
    modifier onlyRoleHolder(uint256 roleId) {
        require(holdsRole(roleId, msg.sender), "Sender does not hold required role");
        _;
    }

    /**
     * @notice Reverts unless the caller is a member of the manager role for the specified roleId.
     */
    modifier onlyRoleManager(uint256 roleId) {
        require(holdsRole(roles[roleId].managingRole, msg.sender), "Can only be called by a role manager");
        _;
    }

    /**
     * @notice Reverts unless the roleId represents an initialized, exclusive roleId.
     */
    modifier onlyExclusive(uint256 roleId) {
        require(roles[roleId].roleType == RoleType.Exclusive, "Must be called on an initialized Exclusive role");
        _;
    }

    /**
     * @notice Reverts unless the roleId represents an initialized, shared roleId.
     */
    modifier onlyShared(uint256 roleId) {
        require(roles[roleId].roleType == RoleType.Shared, "Must be called on an initialized Shared role");
        _;
    }

    /**
     * @notice Whether `memberToCheck` is a member of roleId.
     * @dev Reverts if roleId does not correspond to an initialized role.
     * @param roleId the Role to check.
     * @param memberToCheck the address to check.
     * @return True if `memberToCheck` is a member of `roleId`.
     */
    function holdsRole(uint256 roleId, address memberToCheck) public view returns (bool) {
        Role storage role = roles[roleId];
        if (role.roleType == RoleType.Exclusive) {
            return role.exclusiveRoleMembership.isMember(memberToCheck);
        } else if (role.roleType == RoleType.Shared) {
            return role.sharedRoleMembership.isMember(memberToCheck);
        }
        revert("Invalid roleId");
    }

    /**
     * @notice Changes the exclusive role holder of `roleId` to `newMember`.
     * @dev Reverts if the caller is not a member of the managing role for `roleId` or if `roleId` is not an
     * initialized, ExclusiveRole.
     * @param roleId the ExclusiveRole membership to modify.
     * @param newMember the new ExclusiveRole member.
     */
    function resetMember(uint256 roleId, address newMember) public onlyExclusive(roleId) onlyRoleManager(roleId) {
        roles[roleId].exclusiveRoleMembership.resetMember(newMember);
        emit ResetExclusiveMember(roleId, newMember, msg.sender);
    }

    /**
     * @notice Gets the current holder of the exclusive role, `roleId`.
     * @dev Reverts if `roleId` does not represent an initialized, exclusive role.
     * @param roleId the ExclusiveRole membership to check.
     * @return the address of the current ExclusiveRole member.
     */
    function getMember(uint256 roleId) public view onlyExclusive(roleId) returns (address) {
        return roles[roleId].exclusiveRoleMembership.getMember();
    }

    /**
     * @notice Adds `newMember` to the shared role, `roleId`.
     * @dev Reverts if `roleId` does not represent an initialized, SharedRole or if the caller is not a member of the
     * managing role for `roleId`.
     * @param roleId the SharedRole membership to modify.
     * @param newMember the new SharedRole member.
     */
    function addMember(uint256 roleId, address newMember) public onlyShared(roleId) onlyRoleManager(roleId) {
        roles[roleId].sharedRoleMembership.addMember(newMember);
        emit AddedSharedMember(roleId, newMember, msg.sender);
    }

    /**
     * @notice Removes `memberToRemove` from the shared role, `roleId`.
     * @dev Reverts if `roleId` does not represent an initialized, SharedRole or if the caller is not a member of the
     * managing role for `roleId`.
     * @param roleId the SharedRole membership to modify.
     * @param memberToRemove the current SharedRole member to remove.
     */
    function removeMember(uint256 roleId, address memberToRemove) public onlyShared(roleId) onlyRoleManager(roleId) {
        roles[roleId].sharedRoleMembership.removeMember(memberToRemove);
        emit RemovedSharedMember(roleId, memberToRemove, msg.sender);
    }

    /**
     * @notice Removes caller from the role, `roleId`.
     * @dev Reverts if the caller is not a member of the role for `roleId` or if `roleId` is not an
     * initialized, SharedRole.
     * @param roleId the SharedRole membership to modify.
     */
    function renounceMembership(uint256 roleId) public onlyShared(roleId) onlyRoleHolder(roleId) {
        roles[roleId].sharedRoleMembership.removeMember(msg.sender);
        emit RemovedSharedMember(roleId, msg.sender, msg.sender);
    }

    /**
     * @notice Reverts if `roleId` is not initialized.
     */
    modifier onlyValidRole(uint256 roleId) {
        require(roles[roleId].roleType != RoleType.Invalid, "Attempted to use an invalid roleId");
        _;
    }

    /**
     * @notice Reverts if `roleId` is initialized.
     */
    modifier onlyInvalidRole(uint256 roleId) {
        require(roles[roleId].roleType == RoleType.Invalid, "Cannot use a pre-existing role");
        _;
    }

    /**
     * @notice Internal method to initialize a shared role, `roleId`, which will be managed by `managingRoleId`.
     * `initialMembers` will be immediately added to the role.
     * @dev Should be called by derived contracts, usually at construction time. Will revert if the role is already
     * initialized.
     */
    function _createSharedRole(
        uint256 roleId,
        uint256 managingRoleId,
        address[] memory initialMembers
    ) internal onlyInvalidRole(roleId) {
        Role storage role = roles[roleId];
        role.roleType = RoleType.Shared;
        role.managingRole = managingRoleId;
        role.sharedRoleMembership.init(initialMembers);
        require(
            roles[managingRoleId].roleType != RoleType.Invalid,
            "Attempted to use an invalid role to manage a shared role"
        );
    }

    /**
     * @notice Internal method to initialize an exclusive role, `roleId`, which will be managed by `managingRoleId`.
     * `initialMember` will be immediately added to the role.
     * @dev Should be called by derived contracts, usually at construction time. Will revert if the role is already
     * initialized.
     */
    function _createExclusiveRole(
        uint256 roleId,
        uint256 managingRoleId,
        address initialMember
    ) internal onlyInvalidRole(roleId) {
        Role storage role = roles[roleId];
        role.roleType = RoleType.Exclusive;
        role.managingRole = managingRoleId;
        role.exclusiveRoleMembership.init(initialMember);
        require(
            roles[managingRoleId].roleType != RoleType.Invalid,
            "Attempted to use an invalid role to manage an exclusive role"
        );
    }
}

File 15 of 60 : ExpandedIERC20.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

/**
 * @title ERC20 interface that includes burn and mint methods.
 */
abstract contract ExpandedIERC20 is IERC20 {
    /**
     * @notice Burns a specific amount of the caller's tokens.
     * @dev Only burns the caller's tokens, so it is safe to leave this method permissionless.
     */
    function burn(uint256 value) external virtual;

    /**
     * @dev Burns `value` tokens owned by `recipient`.
     * @param recipient address to burn tokens from.
     * @param value amount of tokens to burn.
     */
    function burnFrom(address recipient, uint256 value) external virtual returns (bool);

    /**
     * @notice Mints tokens and adds them to the balance of the `to` address.
     * @dev This method should be permissioned to only allow designated parties to mint tokens.
     */
    function mint(address to, uint256 value) external virtual returns (bool);

    function addMinter(address account) external virtual;

    function addBurner(address account) external virtual;

    function resetOwner(address account) external virtual;
}

File 16 of 60 : IERC20Metadata.sol
// 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);
}

File 17 of 60 : Polygon_SpokePool.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.0;

import "./SpokePool.sol";
import "./PolygonTokenBridger.sol";
import "./interfaces/WETH9.sol";
import "./SpokePoolInterface.sol";

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

// IFxMessageProcessor represents interface to process messages.
interface IFxMessageProcessor {
    function processMessageFromRoot(
        uint256 stateId,
        address rootMessageSender,
        bytes calldata data
    ) external;
}

/**
 * @notice Polygon specific SpokePool.
 */
contract Polygon_SpokePool is IFxMessageProcessor, SpokePool {
    using SafeERC20 for PolygonIERC20;

    // Address of FxChild which sends and receives messages to and from L1.
    address public fxChild;

    // Contract deployed on L1 and L2 processes all cross-chain transfers between this contract and the the HubPool.
    // Required because bridging tokens from Polygon to Ethereum has special constraints.
    PolygonTokenBridger public polygonTokenBridger;

    // Internal variable that only flips temporarily to true upon receiving messages from L1. Used to authenticate that
    // the caller is the fxChild AND that the fxChild called processMessageFromRoot
    bool private callValidated = false;

    event PolygonTokensBridged(address indexed token, address indexed receiver, uint256 amount);
    event SetFxChild(address indexed newFxChild);
    event SetPolygonTokenBridger(address indexed polygonTokenBridger);

    // Note: validating calls this way ensures that strange calls coming from the fxChild won't be misinterpreted.
    // Put differently, just checking that msg.sender == fxChild is not sufficient.
    // All calls that have admin privileges must be fired from within the processMessageFromRoot method that's gone
    // through validation where the sender is checked and the root (mainnet) sender is also validated.
    // This modifier sets the callValidated variable so this condition can be checked in _requireAdminSender().
    modifier validateInternalCalls() {
        // Make sure callValidated is set to True only once at beginning of processMessageFromRoot, which prevents
        // processMessageFromRoot from being re-entered.
        require(!callValidated, "callValidated already set");

        // This sets a variable indicating that we're now inside a validated call.
        // Note: this is used by other methods to ensure that this call has been validated by this method and is not
        // spoofed. See
        callValidated = true;

        _;

        // Reset callValidated to false to disallow admin calls after this method exits.
        callValidated = false;
    }

    /**
     * @notice Construct the Polygon SpokePool.
     * @param _polygonTokenBridger Token routing contract that sends tokens from here to HubPool. Changeable by Admin.
     * @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin.
     * @param _hubPool Hub pool address to set. Can be changed by admin.
     * @param _wmaticAddress Replaces wrappedNativeToken for this network since MATIC is the native currency on polygon.
     * @param _fxChild FxChild contract, changeable by Admin.
     * @param timerAddress Timer address to set.
     */
    constructor(
        PolygonTokenBridger _polygonTokenBridger,
        address _crossDomainAdmin,
        address _hubPool,
        address _wmaticAddress, // Note: wmatic is used here since it is the token sent via msg.value on polygon.
        address _fxChild,
        address timerAddress
    ) SpokePool(_crossDomainAdmin, _hubPool, _wmaticAddress, timerAddress) {
        polygonTokenBridger = _polygonTokenBridger;
        fxChild = _fxChild;
    }

    /********************************************************
     *    POLYGON-SPECIFIC CROSS-CHAIN ADMIN FUNCTIONS     *
     ********************************************************/

    /**
     * @notice Change FxChild address. Callable only by admin via processMessageFromRoot.
     * @param newFxChild New FxChild.
     */
    function setFxChild(address newFxChild) public onlyAdmin nonReentrant {
        fxChild = newFxChild;
        emit SetFxChild(newFxChild);
    }

    /**
     * @notice Change polygonTokenBridger address. Callable only by admin via processMessageFromRoot.
     * @param newPolygonTokenBridger New Polygon Token Bridger contract.
     */
    function setPolygonTokenBridger(address payable newPolygonTokenBridger) public onlyAdmin nonReentrant {
        polygonTokenBridger = PolygonTokenBridger(newPolygonTokenBridger);
        emit SetPolygonTokenBridger(address(newPolygonTokenBridger));
    }

    /**
     * @notice Called by FxChild upon receiving L1 message that targets this contract. Performs an additional check
     * that the L1 caller was the expected cross domain admin, and then delegate calls.
     * @notice Polygon bridge only executes this external function on the target Polygon contract when relaying
     * messages from L1, so all functions on this SpokePool are expected to originate via this call.
     * @dev stateId value isn't used because it isn't relevant for this method. It doesn't care what state sync
     * triggered this call.
     * @param rootMessageSender Original L1 sender of data.
     * @param data ABI encoded function call to execute on this contract.
     */
    function processMessageFromRoot(
        uint256, /*stateId*/
        address rootMessageSender,
        bytes calldata data
    ) public validateInternalCalls {
        // Validation logic.
        require(msg.sender == fxChild, "Not from fxChild");
        require(rootMessageSender == crossDomainAdmin, "Not from mainnet admin");

        // This uses delegatecall to take the information in the message and process it as a function call on this contract.
        (bool success, ) = address(this).delegatecall(data);
        require(success, "delegatecall failed");
    }

    /**
     * @notice Allows the caller to trigger the wrapping of any unwrapped matic tokens.
     * @dev Matic sends via L1 -> L2 bridging actions don't call into the contract receiving the tokens, so wrapping
     * must be done via a separate transaction.
     */
    function wrap() public nonReentrant {
        _wrap();
    }

    /**
     * @notice Executes a relayer refund leaf stored as part of a root bundle. Will send the relayer the amount they
     * sent to the recipient plus a relayer fee.
     * @dev this is only overridden to wrap any matic the contract holds before running.
     * @param rootBundleId Unique ID of root bundle containing relayer refund root that this leaf is contained in.
     * @param relayerRefundLeaf Contains all data necessary to reconstruct leaf contained in root bundle and to
     * refund relayer. This data structure is explained in detail in the SpokePoolInterface.
     * @param proof Inclusion proof for this leaf in relayer refund root in root bundle.
     */
    function executeRelayerRefundLeaf(
        uint32 rootBundleId,
        SpokePoolInterface.RelayerRefundLeaf memory relayerRefundLeaf,
        bytes32[] memory proof
    ) public override nonReentrant {
        _wrap();
        _executeRelayerRefundLeaf(rootBundleId, relayerRefundLeaf, proof);
    }

    /**
     * @notice Executes a slow relay leaf stored as part of a root bundle. Will send the full amount remaining in the
     * relay to the recipient, less fees.
     * @dev This function assumes that the relay's destination chain ID is the current chain ID, which prevents
     * the caller from executing a slow relay intended for another chain on this chain. This is only overridden to call
     * wrap before running the function.
     * @param depositor Depositor on origin chain who set this chain as the destination chain.
     * @param recipient Specified recipient on this chain.
     * @param destinationToken Token to send to recipient. Should be mapped to the origin token, origin chain ID
     * and this chain ID via a mapping on the HubPool.
     * @param amount Full size of the deposit.
     * @param originChainId Chain of SpokePool where deposit originated.
     * @param realizedLpFeePct Fee % based on L1 HubPool utilization at deposit quote time. Deterministic based on
     * quote time.
     * @param relayerFeePct Original fee % to keep as relayer set by depositor.
     * @param depositId Unique deposit ID on origin spoke pool.
     * @param rootBundleId Unique ID of root bundle containing slow relay root that this leaf is contained in.
     * @param proof Inclusion proof for this leaf in slow relay root in root bundle.
     */
    function executeSlowRelayLeaf(
        address depositor,
        address recipient,
        address destinationToken,
        uint256 amount,
        uint256 originChainId,
        uint64 realizedLpFeePct,
        uint64 relayerFeePct,
        uint32 depositId,
        uint32 rootBundleId,
        bytes32[] memory proof
    ) public virtual override nonReentrant {
        _wrap();
        _executeSlowRelayLeaf(
            depositor,
            recipient,
            destinationToken,
            amount,
            originChainId,
            chainId(),
            realizedLpFeePct,
            relayerFeePct,
            depositId,
            rootBundleId,
            proof
        );
    }

    /**************************************
     *        INTERNAL FUNCTIONS          *
     **************************************/

    function _bridgeTokensToHubPool(RelayerRefundLeaf memory relayerRefundLeaf) internal override {
        PolygonIERC20(relayerRefundLeaf.l2TokenAddress).safeIncreaseAllowance(
            address(polygonTokenBridger),
            relayerRefundLeaf.amountToReturn
        );

        // Note: WrappedNativeToken is WMATIC on matic, so this tells the tokenbridger that this is an unwrappable native token.
        polygonTokenBridger.send(PolygonIERC20(relayerRefundLeaf.l2TokenAddress), relayerRefundLeaf.amountToReturn);

        emit PolygonTokensBridged(relayerRefundLeaf.l2TokenAddress, address(this), relayerRefundLeaf.amountToReturn);
    }

    function _wrap() internal {
        uint256 balance = address(this).balance;
        if (balance > 0) wrappedNativeToken.deposit{ value: balance }();
    }

    // @dev: This contract will trigger admin functions internally via the `processMessageFromRoot`, which is why
    // the `callValidated` check is made below  and why we use the `validateInternalCalls` modifier on
    // `processMessageFromRoot`. This prevents calling the admin functions from any other method besides
    // `processMessageFromRoot`.
    function _requireAdminSender() internal view override {
        require(callValidated, "Must call processMessageFromRoot");
    }
}

File 18 of 60 : SpokePool.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.0;

import "./MerkleLib.sol";
import "./interfaces/WETH9.sol";
import "./Lockable.sol";
import "./SpokePoolInterface.sol";

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/Address.sol";

import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@uma/core/contracts/common/implementation/Testable.sol";
import "@uma/core/contracts/common/implementation/MultiCaller.sol";

/**
 * @title SpokePool
 * @notice Base contract deployed on source and destination chains enabling depositors to transfer assets from source to
 * destination. Deposit orders are fulfilled by off-chain relayers who also interact with this contract. Deposited
 * tokens are locked on the source chain and relayers send the recipient the desired token currency and amount
 * on the destination chain. Locked source chain tokens are later sent over the canonical token bridge to L1 HubPool.
 * Relayers are refunded with destination tokens out of this contract after another off-chain actor, a "data worker",
 * submits a proof that the relayer correctly submitted a relay on this SpokePool.
 */
abstract contract SpokePool is SpokePoolInterface, Testable, Lockable, MultiCaller {
    using SafeERC20 for IERC20;
    using Address for address;

    // Address of the L1 contract that acts as the owner of this SpokePool. If this contract is deployed on Ethereum,
    // then this address should be set to the same owner as the HubPool and the whole system.
    address public crossDomainAdmin;

    // Address of the L1 contract that will send tokens to and receive tokens from this contract to fund relayer
    // refunds and slow relays.
    address public hubPool;

    // Address of wrappedNativeToken contract for this network. If an origin token matches this, then the caller can
    // optionally instruct this contract to wrap native tokens when depositing (ie ETH->WETH or MATIC->WMATIC).
    WETH9 public immutable wrappedNativeToken;

    // Any deposit quote times greater than or less than this value to the current contract time is blocked. Forces
    // caller to use an approximately "current" realized fee. Defaults to 10 minutes.
    uint32 public depositQuoteTimeBuffer = 600;

    // Count of deposits is used to construct a unique deposit identifier for this spoke pool.
    uint32 public numberOfDeposits;

    // This contract can store as many root bundles as the HubPool chooses to publish here.
    RootBundle[] public rootBundles;

    // Origin token to destination token routings can be turned on or off, which can enable or disable deposits.
    mapping(address => mapping(uint256 => bool)) public enabledDepositRoutes;

    // Each relay is associated with the hash of parameters that uniquely identify the original deposit and a relay
    // attempt for that deposit. The relay itself is just represented as the amount filled so far. The total amount to
    // relay, the fees, and the agents are all parameters included in the hash key.
    mapping(bytes32 => uint256) public relayFills;

    /****************************************
     *                EVENTS                *
     ****************************************/
    event SetXDomainAdmin(address indexed newAdmin);
    event SetHubPool(address indexed newHubPool);
    event EnabledDepositRoute(address indexed originToken, uint256 indexed destinationChainId, bool enabled);
    event SetDepositQuoteTimeBuffer(uint32 newBuffer);
    event FundsDeposited(
        uint256 amount,
        uint256 originChainId,
        uint256 destinationChainId,
        uint64 relayerFeePct,
        uint32 indexed depositId,
        uint32 quoteTimestamp,
        address indexed originToken,
        address recipient,
        address indexed depositor
    );
    event RequestedSpeedUpDeposit(
        uint64 newRelayerFeePct,
        uint32 indexed depositId,
        address indexed depositor,
        bytes depositorSignature
    );
    event FilledRelay(
        uint256 amount,
        uint256 totalFilledAmount,
        uint256 fillAmount,
        uint256 repaymentChainId,
        uint256 originChainId,
        uint256 destinationChainId,
        uint64 relayerFeePct,
        uint64 appliedRelayerFeePct,
        uint64 realizedLpFeePct,
        uint32 depositId,
        address destinationToken,
        address indexed relayer,
        address indexed depositor,
        address recipient,
        bool isSlowRelay
    );
    event RelayedRootBundle(
        uint32 indexed rootBundleId,
        bytes32 indexed relayerRefundRoot,
        bytes32 indexed slowRelayRoot
    );
    event ExecutedRelayerRefundRoot(
        uint256 amountToReturn,
        uint256 indexed chainId,
        uint256[] refundAmounts,
        uint32 indexed rootBundleId,
        uint32 indexed leafId,
        address l2TokenAddress,
        address[] refundAddresses,
        address caller
    );
    event TokensBridged(
        uint256 amountToReturn,
        uint256 indexed chainId,
        uint32 indexed leafId,
        address indexed l2TokenAddress,
        address caller
    );
    event EmergencyDeleteRootBundle(uint256 indexed rootBundleId);

    /**
     * @notice Construct the base SpokePool.
     * @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin.
     * @param _hubPool Hub pool address to set. Can be changed by admin.
     * @param _wrappedNativeTokenAddress wrappedNativeToken address for this network to set.
     * @param timerAddress Timer address to set.
     */
    constructor(
        address _crossDomainAdmin,
        address _hubPool,
        address _wrappedNativeTokenAddress,
        address timerAddress
    ) Testable(timerAddress) {
        _setCrossDomainAdmin(_crossDomainAdmin);
        _setHubPool(_hubPool);
        wrappedNativeToken = WETH9(_wrappedNativeTokenAddress);
    }

    /****************************************
     *               MODIFIERS              *
     ****************************************/

    // Implementing contract needs to override _requireAdminSender() to ensure that admin functions are protected
    // appropriately.
    modifier onlyAdmin() {
        _requireAdminSender();
        _;
    }

    /**************************************
     *          ADMIN FUNCTIONS           *
     **************************************/

    /**
     * @notice Change cross domain admin address. Callable by admin only.
     * @param newCrossDomainAdmin New cross domain admin.
     */
    function setCrossDomainAdmin(address newCrossDomainAdmin) public override onlyAdmin nonReentrant {
        _setCrossDomainAdmin(newCrossDomainAdmin);
    }

    /**
     * @notice Change L1 hub pool address. Callable by admin only.
     * @param newHubPool New hub pool.
     */
    function setHubPool(address newHubPool) public override onlyAdmin nonReentrant {
        _setHubPool(newHubPool);
    }

    /**
     * @notice Enable/Disable an origin token => destination chain ID route for deposits. Callable by admin only.
     * @param originToken Token that depositor can deposit to this contract.
     * @param destinationChainId Chain ID for where depositor wants to receive funds.
     * @param enabled True to enable deposits, False otherwise.
     */
    function setEnableRoute(
        address originToken,
        uint256 destinationChainId,
        bool enabled
    ) public override onlyAdmin nonReentrant {
        enabledDepositRoutes[originToken][destinationChainId] = enabled;
        emit EnabledDepositRoute(originToken, destinationChainId, enabled);
    }

    /**
     * @notice Change allowance for deposit quote time to differ from current block time. Callable by admin only.
     * @param newDepositQuoteTimeBuffer New quote time buffer.
     */
    function setDepositQuoteTimeBuffer(uint32 newDepositQuoteTimeBuffer) public override onlyAdmin nonReentrant {
        depositQuoteTimeBuffer = newDepositQuoteTimeBuffer;
        emit SetDepositQuoteTimeBuffer(newDepositQuoteTimeBuffer);
    }

    /**
     * @notice This method stores a new root bundle in this contract that can be executed to refund relayers, fulfill
     * slow relays, and send funds back to the HubPool on L1. This method can only be called by the admin and is
     * designed to be called as part of a cross-chain message from the HubPool's executeRootBundle method.
     * @param relayerRefundRoot Merkle root containing relayer refund leaves that can be individually executed via
     * executeRelayerRefundLeaf().
     * @param slowRelayRoot Merkle root containing slow relay fulfillment leaves that can be individually executed via
     * executeSlowRelayLeaf().
     */
    function relayRootBundle(bytes32 relayerRefundRoot, bytes32 slowRelayRoot) public override onlyAdmin nonReentrant {
        uint32 rootBundleId = uint32(rootBundles.length);
        RootBundle storage rootBundle = rootBundles.push();
        rootBundle.relayerRefundRoot = relayerRefundRoot;
        rootBundle.slowRelayRoot = slowRelayRoot;
        emit RelayedRootBundle(rootBundleId, relayerRefundRoot, slowRelayRoot);
    }

    /**
     * @notice This method is intended to only be used in emergencies where a bad root bundle has reached the
     * SpokePool.
     * @param rootBundleId Index of the root bundle that needs to be deleted. Note: this is intentionally a uint256
     * to ensure that a small input range doesn't limit which indices this method is able to reach.
     */
    function emergencyDeleteRootBundle(uint256 rootBundleId) public override onlyAdmin nonReentrant {
        delete rootBundles[rootBundleId];
        emit EmergencyDeleteRootBundle(rootBundleId);
    }

    /**************************************
     *         DEPOSITOR FUNCTIONS        *
     **************************************/

    /**
     * @notice Called by user to bridge funds from origin to destination chain. Depositor will effectively lock
     * tokens in this contract and receive a destination token on the destination chain. The origin => destination
     * token mapping is stored on the L1 HubPool.
     * @notice The caller must first approve this contract to spend amount of originToken.
     * @notice The originToken => destinationChainId must be enabled.
     * @notice This method is payable because the caller is able to deposit native token if the originToken is
     * wrappedNativeToken and this function will handle wrapping the native token to wrappedNativeToken.
     * @param recipient Address to receive funds at on destination chain.
     * @param originToken Token to lock into this contract to initiate deposit.
     * @param amount Amount of tokens to deposit. Will be amount of tokens to receive less fees.
     * @param destinationChainId Denotes network where user will receive funds from SpokePool by a relayer.
     * @param relayerFeePct % of deposit amount taken out to incentivize a fast relayer.
     * @param quoteTimestamp Timestamp used by relayers to compute this deposit's realizedLPFeePct which is paid
     * to LP pool on HubPool.
     */
    function deposit(
        address recipient,
        address originToken,
        uint256 amount,
        uint256 destinationChainId,
        uint64 relayerFeePct,
        uint32 quoteTimestamp
    ) public payable override nonReentrant {
        // Check that deposit route is enabled.
        require(enabledDepositRoutes[originToken][destinationChainId], "Disabled route");

        // We limit the relay fees to prevent the user spending all their funds on fees.
        require(relayerFeePct < 0.5e18, "invalid relayer fee");
        // This function assumes that L2 timing cannot be compared accurately and consistently to L1 timing. Therefore,
        // block.timestamp is different from the L1 EVM's. Therefore, the quoteTimestamp must be within a configurable
        // buffer of this contract's block time to allow for this variance.
        // Note also that quoteTimestamp cannot be less than the buffer otherwise the following arithmetic can result
        // in underflow. This isn't a problem as the deposit will revert, but the error might be unexpected for clients.
        require(
            getCurrentTime() >= quoteTimestamp - depositQuoteTimeBuffer &&
                getCurrentTime() <= quoteTimestamp + depositQuoteTimeBuffer,
            "invalid quote time"
        );
        // If the address of the origin token is a wrappedNativeToken contract and there is a msg.value with the
        // transaction then the user is sending ETH. In this case, the ETH should be deposited to wrappedNativeToken.
        if (originToken == address(wrappedNativeToken) && msg.value > 0) {
            require(msg.value == amount, "msg.value must match amount");
            wrappedNativeToken.deposit{ value: msg.value }();
            // Else, it is a normal ERC20. In this case pull the token from the user's wallet as per normal.
            // Note: this includes the case where the L2 user has WETH (already wrapped ETH) and wants to bridge them.
            // In this case the msg.value will be set to 0, indicating a "normal" ERC20 bridging action.
        } else IERC20(originToken).safeTransferFrom(msg.sender, address(this), amount);

        _emitDeposit(
            amount,
            chainId(),
            destinationChainId,
            relayerFeePct,
            numberOfDeposits,
            quoteTimestamp,
            originToken,
            recipient,
            msg.sender
        );

        // Increment count of deposits so that deposit ID for this spoke pool is unique.
        // @dev: Use pre-increment to save gas:
        // i++ --> Load, Store, Add, Store
        // ++i --> Load, Add, Store
        ++numberOfDeposits;
    }

    /**
     * @notice Convenience method that depositor can use to signal to relayer to use updated fee.
     * @notice Relayer should only use events emitted by this function to submit fills with updated fees, otherwise they
     * risk their fills getting disputed for being invalid, for example if the depositor never actually signed the
     * update fee message.
     * @notice This function will revert if the depositor did not sign a message containing the updated fee for the
     * deposit ID stored in this contract. If the deposit ID is for another contract, or the depositor address is
     * incorrect, or the updated fee is incorrect, then the signature will not match and this function will revert.
     * @param depositor Signer of the update fee message who originally submitted the deposit. If the deposit doesn't
     * exist, then the relayer will not be able to fill any relay, so the caller should validate that the depositor
     * did in fact submit a relay.
     * @param newRelayerFeePct New relayer fee that relayers can use.
     * @param depositId Deposit to update fee for that originated in this contract.
     * @param depositorSignature Signed message containing the depositor address, this contract chain ID, the updated
     * relayer fee %, and the deposit ID. This signature is produced by signing a hash of data according to the
     * EIP-1271 standard. See more in the _verifyUpdateRelayerFeeMessage() comments.
     */
    function speedUpDeposit(
        address depositor,
        uint64 newRelayerFeePct,
        uint32 depositId,
        bytes memory depositorSignature
    ) public override nonReentrant {
        require(newRelayerFeePct < 0.5e18, "invalid relayer fee");

        _verifyUpdateRelayerFeeMessage(depositor, chainId(), newRelayerFeePct, depositId, depositorSignature);

        // Assuming the above checks passed, a relayer can take the signature and the updated relayer fee information
        // from the following event to submit a fill with an updated fee %.
        emit RequestedSpeedUpDeposit(newRelayerFeePct, depositId, depositor, depositorSignature);
    }

    /**************************************
     *         RELAYER FUNCTIONS          *
     **************************************/

    /**
     * @notice Called by relayer to fulfill part of a deposit by sending destination tokens to the recipient.
     * Relayer is expected to pass in unique identifying information for deposit that they want to fulfill, and this
     * relay submission will be validated by off-chain data workers who can dispute this relay if any part is invalid.
     * If the relay is valid, then the relayer will be refunded on their desired repayment chain. If relay is invalid,
     * then relayer will not receive any refund.
     * @notice All of the deposit data can be found via on-chain events from the origin SpokePool, except for the
     * realizedLpFeePct which is a function of the HubPool's utilization at the deposit quote time. This fee %
     * is deterministic based on the quote time, so the relayer should just compute it using the canonical algorithm
     * as described in a UMIP linked to the HubPool's identifier.
     * @param depositor Depositor on origin chain who set this chain as the destination chain.
     * @param recipient Specified recipient on this chain.
     * @param destinationToken Token to send to recipient. Should be mapped to the origin token, origin chain ID
     * and this chain ID via a mapping on the HubPool.
     * @param amount Full size of the deposit.
     * @param maxTokensToSend Max amount of tokens to send recipient. If higher than amount, then caller will
     * send recipient the full relay amount.
     * @param repaymentChainId Chain of SpokePool where relayer wants to be refunded after the challenge window has
     * passed.
     * @param originChainId Chain of SpokePool where deposit originated.
     * @param realizedLpFeePct Fee % based on L1 HubPool utilization at deposit quote time. Deterministic based on
     * quote time.
     * @param relayerFeePct Fee % to keep as relayer, specified by depositor.
     * @param depositId Unique deposit ID on origin spoke pool.
     */
    function fillRelay(
        address depositor,
        address recipient,
        address destinationToken,
        uint256 amount,
        uint256 maxTokensToSend,
        uint256 repaymentChainId,
        uint256 originChainId,
        uint64 realizedLpFeePct,
        uint64 relayerFeePct,
        uint32 depositId
    ) public nonReentrant {
        // Each relay attempt is mapped to the hash of data uniquely identifying it, which includes the deposit data
        // such as the origin chain ID and the deposit ID, and the data in a relay attempt such as who the recipient
        // is, which chain and currency the recipient wants to receive funds on, and the relay fees.
        SpokePoolInterface.RelayData memory relayData = SpokePoolInterface.RelayData({
            depositor: depositor,
            recipient: recipient,
            destinationToken: destinationToken,
            amount: amount,
            realizedLpFeePct: realizedLpFeePct,
            relayerFeePct: relayerFeePct,
            depositId: depositId,
            originChainId: originChainId,
            destinationChainId: chainId()
        });
        bytes32 relayHash = _getRelayHash(relayData);

        uint256 fillAmountPreFees = _fillRelay(relayHash, relayData, maxTokensToSend, relayerFeePct, false);

        _emitFillRelay(relayHash, fillAmountPreFees, repaymentChainId, relayerFeePct, relayData, false);
    }

    /**
     * @notice Called by relayer to execute same logic as calling fillRelay except that relayer is using an updated
     * relayer fee %. The fee % must have been emitted in a message cryptographically signed by the depositor.
     * @notice By design, the depositor probably emitted the message with the updated fee by calling speedUpRelay().
     * @param depositor Depositor on origin chain who set this chain as the destination chain.
     * @param recipient Specified recipient on this chain.
     * @param destinationToken Token to send to recipient. Should be mapped to the origin token, origin chain ID
     * and this chain ID via a mapping on the HubPool.
     * @param amount Full size of the deposit.
     * @param maxTokensToSend Max amount of tokens to send recipient. If higher than amount, then caller will
     * send recipient the full relay amount.
     * @param repaymentChainId Chain of SpokePool where relayer wants to be refunded after the challenge window has
     * passed.
     * @param originChainId Chain of SpokePool where deposit originated.
     * @param realizedLpFeePct Fee % based on L1 HubPool utilization at deposit quote time. Deterministic based on
     * quote time.
     * @param relayerFeePct Original fee % to keep as relayer set by depositor.
     * @param newRelayerFeePct New fee % to keep as relayer also specified by depositor.
     * @param depositId Unique deposit ID on origin spoke pool.
     * @param depositorSignature Depositor-signed message containing updated fee %.
     */
    function fillRelayWithUpdatedFee(
        address depositor,
        address recipient,
        address destinationToken,
        uint256 amount,
        uint256 maxTokensToSend,
        uint256 repaymentChainId,
        uint256 originChainId,
        uint64 realizedLpFeePct,
        uint64 relayerFeePct,
        uint64 newRelayerFeePct,
        uint32 depositId,
        bytes memory depositorSignature
    ) public override nonReentrant {
        _verifyUpdateRelayerFeeMessage(depositor, originChainId, newRelayerFeePct, depositId, depositorSignature);

        // Now follow the default fillRelay flow with the updated fee and the original relay hash.
        RelayData memory relayData = RelayData({
            depositor: depositor,
            recipient: recipient,
            destinationToken: destinationToken,
            amount: amount,
            realizedLpFeePct: realizedLpFeePct,
            relayerFeePct: relayerFeePct,
            depositId: depositId,
            originChainId: originChainId,
            destinationChainId: chainId()
        });
        bytes32 relayHash = _getRelayHash(relayData);
        uint256 fillAmountPreFees = _fillRelay(relayHash, relayData, maxTokensToSend, newRelayerFeePct, false);

        _emitFillRelay(relayHash, fillAmountPreFees, repaymentChainId, newRelayerFeePct, relayData, false);
    }

    /**************************************
     *         DATA WORKER FUNCTIONS      *
     **************************************/

    /**
     * @notice Executes a slow relay leaf stored as part of a root bundle. Will send the full amount remaining in the
     * relay to the recipient, less fees.
     * @dev This function assumes that the relay's destination chain ID is the current chain ID, which prevents
     * the caller from executing a slow relay intended for another chain on this chain.
     * @param depositor Depositor on origin chain who set this chain as the destination chain.
     * @param recipient Specified recipient on this chain.
     * @param destinationToken Token to send to recipient. Should be mapped to the origin token, origin chain ID
     * and this chain ID via a mapping on the HubPool.
     * @param amount Full size of the deposit.
     * @param originChainId Chain of SpokePool where deposit originated.
     * @param realizedLpFeePct Fee % based on L1 HubPool utilization at deposit quote time. Deterministic based on
     * quote time.
     * @param relayerFeePct Original fee % to keep as relayer set by depositor.
     * @param depositId Unique deposit ID on origin spoke pool.
     * @param rootBundleId Unique ID of root bundle containing slow relay root that this leaf is contained in.
     * @param proof Inclusion proof for this leaf in slow relay root in root bundle.
     */
    function executeSlowRelayLeaf(
        address depositor,
        address recipient,
        address destinationToken,
        uint256 amount,
        uint256 originChainId,
        uint64 realizedLpFeePct,
        uint64 relayerFeePct,
        uint32 depositId,
        uint32 rootBundleId,
        bytes32[] memory proof
    ) public virtual override nonReentrant {
        _executeSlowRelayLeaf(
            depositor,
            recipient,
            destinationToken,
            amount,
            originChainId,
            chainId(),
            realizedLpFeePct,
            relayerFeePct,
            depositId,
            rootBundleId,
            proof
        );
    }

    /**
     * @notice Executes a relayer refund leaf stored as part of a root bundle. Will send the relayer the amount they
     * sent to the recipient plus a relayer fee.
     * @param rootBundleId Unique ID of root bundle containing relayer refund root that this leaf is contained in.
     * @param relayerRefundLeaf Contains all data necessary to reconstruct leaf contained in root bundle and to
     * refund relayer. This data structure is explained in detail in the SpokePoolInterface.
     * @param proof Inclusion proof for this leaf in relayer refund root in root bundle.
     */
    function executeRelayerRefundLeaf(
        uint32 rootBundleId,
        SpokePoolInterface.RelayerRefundLeaf memory relayerRefundLeaf,
        bytes32[] memory proof
    ) public virtual override nonReentrant {
        _executeRelayerRefundLeaf(rootBundleId, relayerRefundLeaf, proof);
    }

    /**************************************
     *           VIEW FUNCTIONS           *
     **************************************/

    /**
     * @notice Returns chain ID for this network.
     * @dev Some L2s like ZKSync don't support the CHAIN_ID opcode so we allow the implementer to override this.
     */
    function chainId() public view virtual override returns (uint256) {
        return block.chainid;
    }

    /**************************************
     *         INTERNAL FUNCTIONS         *
     **************************************/

    // Verifies inclusion proof of leaf in root, sends relayer their refund, and sends to HubPool any rebalance
    // transfers.
    function _executeRelayerRefundLeaf(
        uint32 rootBundleId,
        SpokePoolInterface.RelayerRefundLeaf memory relayerRefundLeaf,
        bytes32[] memory proof
    ) internal {
        // Check integrity of leaf structure:
        require(relayerRefundLeaf.chainId == chainId(), "Invalid chainId");
        require(relayerRefundLeaf.refundAddresses.length == relayerRefundLeaf.refundAmounts.length, "invalid leaf");

        RootBundle storage rootBundle = rootBundles[rootBundleId];

        // Check that inclusionProof proves that relayerRefundLeaf is contained within the relayer refund root.
        // Note: This should revert if the relayerRefundRoot is uninitialized.
        require(MerkleLib.verifyRelayerRefund(rootBundle.relayerRefundRoot, relayerRefundLeaf, proof), "Bad Proof");

        // Verify the leafId in the leaf has not yet been claimed.
        require(!MerkleLib.isClaimed(rootBundle.claimedBitmap, relayerRefundLeaf.leafId), "Already claimed");

        // Set leaf as claimed in bitmap. This is passed by reference to the storage rootBundle.
        MerkleLib.setClaimed(rootBundle.claimedBitmap, relayerRefundLeaf.leafId);

        // Send each relayer refund address the associated refundAmount for the L2 token address.
        // Note: Even if the L2 token is not enabled on this spoke pool, we should still refund relayers.
        uint256 length = relayerRefundLeaf.refundAmounts.length;
        for (uint256 i = 0; i < length; ) {
            uint256 amount = relayerRefundLeaf.refundAmounts[i];
            if (amount > 0)
                IERC20(relayerRefundLeaf.l2TokenAddress).safeTransfer(relayerRefundLeaf.refundAddresses[i], amount);

            // OK because we assume refund array length won't be > types(uint256).max.
            // Based on the stress test results in /test/gas-analytics/SpokePool.RelayerRefundLeaf.ts, the UMIP should
            // limit the refund count in valid proposals to be ~800 so any RelayerRefundLeaves with > 800 refunds should
            // not make it to this stage.

            unchecked {
                ++i;
            }
        }

        // If leaf's amountToReturn is positive, then send L2 --> L1 message to bridge tokens back via
        // chain-specific bridging method.
        if (relayerRefundLeaf.amountToReturn > 0) {
            _bridgeTokensToHubPool(relayerRefundLeaf);

            emit TokensBridged(
                relayerRefundLeaf.amountToReturn,
                relayerRefundLeaf.chainId,
                relayerRefundLeaf.leafId,
                relayerRefundLeaf.l2TokenAddress,
                msg.sender
            );
        }

        emit ExecutedRelayerRefundRoot(
            relayerRefundLeaf.amountToReturn,
            relayerRefundLeaf.chainId,
            relayerRefundLeaf.refundAmounts,
            rootBundleId,
            relayerRefundLeaf.leafId,
            relayerRefundLeaf.l2TokenAddress,
            relayerRefundLeaf.refundAddresses,
            msg.sender
        );
    }

    // Verifies inclusion proof of leaf in root and sends recipient remainder of relay. Marks relay as filled.
    function _executeSlowRelayLeaf(
        address depositor,
        address recipient,
        address destinationToken,
        uint256 amount,
        uint256 originChainId,
        uint256 destinationChainId,
        uint64 realizedLpFeePct,
        uint64 relayerFeePct,
        uint32 depositId,
        uint32 rootBundleId,
        bytes32[] memory proof
    ) internal {
        RelayData memory relayData = RelayData({
            depositor: depositor,
            recipient: recipient,
            destinationToken: destinationToken,
            amount: amount,
            originChainId: originChainId,
            destinationChainId: destinationChainId,
            realizedLpFeePct: realizedLpFeePct,
            relayerFeePct: relayerFeePct,
            depositId: depositId
        });

        require(
            MerkleLib.verifySlowRelayFulfillment(rootBundles[rootBundleId].slowRelayRoot, relayData, proof),
            "Invalid proof"
        );

        bytes32 relayHash = _getRelayHash(relayData);

        // Note: use relayAmount as the max amount to send, so the relay is always completely filled by the contract's
        // funds in all cases. As this is a slow relay we set the relayerFeePct to 0. This effectively refunds the
        // relayer component of the relayerFee thereby only charging the depositor the LpFee.
        uint256 fillAmountPreFees = _fillRelay(relayHash, relayData, relayData.amount, 0, true);

        // Note: Set repayment chain ID to 0 to indicate that there is no repayment to be made. The off-chain data
        // worker can use repaymentChainId=0 as a signal to ignore such relays for refunds. Also, set the relayerFeePct
        // to 0 as slow relays do not pay the caller of this method (depositor is refunded this fee).
        _emitFillRelay(relayHash, fillAmountPreFees, 0, 0, relayData, true);
    }

    function _setCrossDomainAdmin(address newCrossDomainAdmin) internal {
        require(newCrossDomainAdmin != address(0), "Bad bridge router address");
        crossDomainAdmin = newCrossDomainAdmin;
        emit SetXDomainAdmin(newCrossDomainAdmin);
    }

    function _setHubPool(address newHubPool) internal {
        require(newHubPool != address(0), "Bad hub pool address");
        hubPool = newHubPool;
        emit SetHubPool(newHubPool);
    }

    // Should be overriden by implementing contract depending on how L2 handles sending tokens to L1.
    function _bridgeTokensToHubPool(SpokePoolInterface.RelayerRefundLeaf memory relayerRefundLeaf) internal virtual;

    function _verifyUpdateRelayerFeeMessage(
        address depositor,
        uint256 originChainId,
        uint64 newRelayerFeePct,
        uint32 depositId,
        bytes memory depositorSignature
    ) internal view {
        // A depositor can request to speed up an un-relayed deposit by signing a hash containing the relayer
        // fee % to update to and information uniquely identifying the deposit to relay. This information ensures
        // that this signature cannot be re-used for other deposits. The version string is included as a precaution
        // in case this contract is upgraded.
        // Note: we use encode instead of encodePacked because it is more secure, more in the "warning" section
        // here: https://docs.soliditylang.org/en/v0.8.11/abi-spec.html#non-standard-packed-mode
        bytes32 expectedDepositorMessageHash = keccak256(
            abi.encode("ACROSS-V2-FEE-1.0", newRelayerFeePct, depositId, originChainId)
        );

        // Check the hash corresponding to the https://eth.wiki/json-rpc/API#eth_sign[eth_sign]
        // If the depositor signed a message with a different updated fee (or any other param included in the
        // above keccak156 hash), then this will revert.
        bytes32 ethSignedMessageHash = ECDSA.toEthSignedMessageHash(expectedDepositorMessageHash);

        _verifyDepositorUpdateFeeMessage(depositor, ethSignedMessageHash, depositorSignature);
    }

    // This function is isolated and made virtual to allow different L2's to implement chain specific recovery of
    // signers from signatures because some L2s might not support ecrecover. To be safe, consider always reverting
    // this function for L2s where ecrecover is different from how it works on Ethereum, otherwise there is the
    // potential to forge a signature from the depositor using a different private key than the original depositor's.
    function _verifyDepositorUpdateFeeMessage(
        address depositor,
        bytes32 ethSignedMessageHash,
        bytes memory depositorSignature
    ) internal view virtual {
        // Note: We purposefully do not support EIP-1271 signatures (meaning that multisigs and smart contract wallets
        // like Argent are not supported) because of the possibility that a multisig that signed a message on the origin
        // chain does not have a parallel on this destination chain.
        require(depositor == ECDSA.recover(ethSignedMessageHash, depositorSignature), "invalid signature");
    }

    function _computeAmountPreFees(uint256 amount, uint64 feesPct) private pure returns (uint256) {
        return (1e18 * amount) / (1e18 - feesPct);
    }

    function _computeAmountPostFees(uint256 amount, uint64 feesPct) private pure returns (uint256) {
        return (amount * (1e18 - feesPct)) / 1e18;
    }

    function _getRelayHash(SpokePoolInterface.RelayData memory relayData) private pure returns (bytes32) {
        return keccak256(abi.encode(relayData));
    }

    // Unwraps ETH and does a transfer to a recipient address. If the recipient is a smart contract then sends wrappedNativeToken.
    function _unwrapwrappedNativeTokenTo(address payable to, uint256 amount) internal {
        if (address(to).isContract()) {
            IERC20(address(wrappedNativeToken)).safeTransfer(to, amount);
        } else {
            wrappedNativeToken.withdraw(amount);
            to.transfer(amount);
        }
    }

    /**
     * @notice Caller specifies the max amount of tokens to send to user. Based on this amount and the amount of the
     * relay remaining (as stored in the relayFills mapping), pull the amount of tokens from the caller
     * and send to the recipient.
     * @dev relayFills keeps track of pre-fee fill amounts as a convenience to relayers who want to specify round
     * numbers for the maxTokensToSend parameter or convenient numbers like 100 (i.e. relayers who will fully
     * fill any relay up to 100 tokens, and partial fill with 100 tokens for larger relays).
     * @dev Caller must approve this contract to transfer up to maxTokensToSend of the relayData.destinationToken.
     * The amount to be sent might end up less if there is insufficient relay amount remaining to be sent.
     */
    function _fillRelay(
        bytes32 relayHash,
        RelayData memory relayData,
        uint256 maxTokensToSend,
        uint64 updatableRelayerFeePct,
        bool useContractFunds
    ) internal returns (uint256 fillAmountPreFees) {
        // We limit the relay fees to prevent the user spending all their funds on fees. Note that 0.5e18 (i.e. 50%)
        // fees are just magic numbers. The important point is to prevent the total fee from being 100%, otherwise
        // computing the amount pre fees runs into divide-by-0 issues.
        require(updatableRelayerFeePct < 0.5e18 && relayData.realizedLpFeePct < 0.5e18, "invalid fees");

        // Check that the relay has not already been completely filled. Note that the relays mapping will point to
        // the amount filled so far for a particular relayHash, so this will start at 0 and increment with each fill.
        require(relayFills[relayHash] < relayData.amount, "relay filled");

        // Stores the equivalent amount to be sent by the relayer before fees have been taken out.
        if (maxTokensToSend == 0) return 0;

        // Derive the amount of the relay filled if the caller wants to send exactly maxTokensToSend tokens to
        // the recipient. For example, if the user wants to send 10 tokens to the recipient, the full relay amount
        // is 100, and the fee %'s total 5%, then this computation would return ~10.5, meaning that to fill 10.5/100
        // of the full relay size, the caller would need to send 10 tokens to the user.
        fillAmountPreFees = _computeAmountPreFees(
            maxTokensToSend,
            (relayData.realizedLpFeePct + updatableRelayerFeePct)
        );
        // If user's specified max amount to send is greater than the amount of the relay remaining pre-fees,
        // we'll pull exactly enough tokens to complete the relay.
        uint256 amountToSend = maxTokensToSend;
        uint256 amountRemainingInRelay = relayData.amount - relayFills[relayHash];
        if (amountRemainingInRelay < fillAmountPreFees) {
            fillAmountPreFees = amountRemainingInRelay;

            // The user will fulfill the remainder of the relay, so we need to compute exactly how many tokens post-fees
            // that they need to send to the recipient. Note that if the relayer is filled using contract funds then
            // this is a slow relay.
            amountToSend = _computeAmountPostFees(
                fillAmountPreFees,
                relayData.realizedLpFeePct + updatableRelayerFeePct
            );
        }

        // relayFills keeps track of pre-fee fill amounts as a convenience to relayers who want to specify round
        // numbers for the maxTokensToSend parameter or convenient numbers like 100 (i.e. relayers who will fully
        // fill any relay up to 100 tokens, and partial fill with 100 tokens for larger relays).
        relayFills[relayHash] += fillAmountPreFees;

        // If relay token is wrappedNativeToken then unwrap and send native token.
        if (relayData.destinationToken == address(wrappedNativeToken)) {
            // Note: useContractFunds is True if we want to send funds to the recipient directly out of this contract,
            // otherwise we expect the caller to send funds to the recipient. If useContractFunds is True and the
            // recipient wants wrappedNativeToken, then we can assume that wrappedNativeToken is already in the
            // contract, otherwise we'll need the user to send wrappedNativeToken to this contract. Regardless, we'll
            // need to unwrap it to native token before sending to the user.
            if (!useContractFunds)
                IERC20(relayData.destinationToken).safeTransferFrom(msg.sender, address(this), amountToSend);
            _unwrapwrappedNativeTokenTo(payable(relayData.recipient), amountToSend);
            // Else, this is a normal ERC20 token. Send to recipient.
        } else {
            // Note: Similar to note above, send token directly from the contract to the user in the slow relay case.
            if (!useContractFunds)
                IERC20(relayData.destinationToken).safeTransferFrom(msg.sender, relayData.recipient, amountToSend);
            else IERC20(relayData.destinationToken).safeTransfer(relayData.recipient, amountToSend);
        }
    }

    // The following internal methods emit events with many params to overcome solidity stack too deep issues.
    function _emitFillRelay(
        bytes32 relayHash,
        uint256 fillAmount,
        uint256 repaymentChainId,
        uint64 appliedRelayerFeePct,
        RelayData memory relayData,
        bool isSlowRelay
    ) internal {
        emit FilledRelay(
            relayData.amount,
            relayFills[relayHash],
            fillAmount,
            repaymentChainId,
            relayData.originChainId,
            relayData.destinationChainId,
            relayData.relayerFeePct,
            appliedRelayerFeePct,
            relayData.realizedLpFeePct,
            relayData.depositId,
            relayData.destinationToken,
            msg.sender,
            relayData.depositor,
            relayData.recipient,
            isSlowRelay
        );
    }

    function _emitDeposit(
        uint256 amount,
        uint256 originChainId,
        uint256 destinationChainId,
        uint64 relayerFeePct,
        uint32 depositId,
        uint32 quoteTimestamp,
        address originToken,
        address recipient,
        address depositor
    ) internal {
        emit FundsDeposited(
            amount,
            originChainId,
            destinationChainId,
            relayerFeePct,
            depositId,
            quoteTimestamp,
            originToken,
            recipient,
            depositor
        );
    }

    // Implementing contract needs to override this to ensure that only the appropriate cross chain admin can execute
    // certain admin functions. For L2 contracts, the cross chain admin refers to some L1 address or contract, and for
    // L1, this would just be the same admin of the HubPool.
    function _requireAdminSender() internal virtual;

    // Added to enable the this contract to receive native token (ETH). Used when unwrapping wrappedNativeToken.
    receive() external payable {}
}

File 19 of 60 : SpokePoolInterface.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.0;

/**
 * @notice Contains common data structures and functions used by all SpokePool implementations.
 */
interface SpokePoolInterface {
    // This leaf is meant to be decoded in the SpokePool to pay out successful relayers.
    struct RelayerRefundLeaf {
        // This is the amount to return to the HubPool. This occurs when there is a PoolRebalanceLeaf netSendAmount that
        // is negative. This is just the negative of this value.
        uint256 amountToReturn;
        // Used to verify that this is being executed on the correct destination chainId.
        uint256 chainId;
        // This array designates how much each of those addresses should be refunded.
        uint256[] refundAmounts;
        // Used as the index in the bitmap to track whether this leaf has been executed or not.
        uint32 leafId;
        // The associated L2TokenAddress that these claims apply to.
        address l2TokenAddress;
        // Must be same length as refundAmounts and designates each address that must be refunded.
        address[] refundAddresses;
    }

    // This struct represents the data to fully specify a relay. If any portion of this data differs, the relay is
    // considered to be completely distinct. Only one relay for a particular depositId, chainId pair should be
    // considered valid and repaid. This data is hashed and inserted into the slow relay merkle root so that an off
    // chain validator can choose when to refund slow relayers.
    struct RelayData {
        // The address that made the deposit on the origin chain.
        address depositor;
        // The recipient address on the destination chain.
        address recipient;
        // The corresponding token address on the destination chain.
        address destinationToken;
        // The total relay amount before fees are taken out.
        uint256 amount;
        // Origin chain id.
        uint256 originChainId;
        // Destination chain id.
        uint256 destinationChainId;
        // The LP Fee percentage computed by the relayer based on the deposit's quote timestamp
        // and the HubPool's utilization.
        uint64 realizedLpFeePct;
        // The relayer fee percentage specified in the deposit.
        uint64 relayerFeePct;
        // The id uniquely identifying this deposit on the origin chain.
        uint32 depositId;
    }

    // Stores collection of merkle roots that can be published to this contract from the HubPool, which are referenced
    // by "data workers" via inclusion proofs to execute leaves in the roots.
    struct RootBundle {
        // Merkle root of slow relays that were not fully filled and whose recipient is still owed funds from the LP pool.
        bytes32 slowRelayRoot;
        // Merkle root of relayer refunds for successful relays.
        bytes32 relayerRefundRoot;
        // This is a 2D bitmap tracking which leaves in the relayer refund root have been claimed, with max size of
        // 256x(2^248) leaves per root.
        mapping(uint256 => uint256) claimedBitmap;
    }

    function setCrossDomainAdmin(address newCrossDomainAdmin) external;

    function setHubPool(address newHubPool) external;

    function setEnableRoute(
        address originToken,
        uint256 destinationChainId,
        bool enable
    ) external;

    function setDepositQuoteTimeBuffer(uint32 buffer) external;

    function relayRootBundle(bytes32 relayerRefundRoot, bytes32 slowRelayRoot) external;

    function emergencyDeleteRootBundle(uint256 rootBundleId) external;

    function deposit(
        address recipient,
        address originToken,
        uint256 amount,
        uint256 destinationChainId,
        uint64 relayerFeePct,
        uint32 quoteTimestamp
    ) external payable;

    function speedUpDeposit(
        address depositor,
        uint64 newRelayerFeePct,
        uint32 depositId,
        bytes memory depositorSignature
    ) external;

    function fillRelay(
        address depositor,
        address recipient,
        address destinationToken,
        uint256 amount,
        uint256 maxTokensToSend,
        uint256 repaymentChainId,
        uint256 originChainId,
        uint64 realizedLpFeePct,
        uint64 relayerFeePct,
        uint32 depositId
    ) external;

    function fillRelayWithUpdatedFee(
        address depositor,
        address recipient,
        address destinationToken,
        uint256 amount,
        uint256 maxTokensToSend,
        uint256 repaymentChainId,
        uint256 originChainId,
        uint64 realizedLpFeePct,
        uint64 relayerFeePct,
        uint64 newRelayerFeePct,
        uint32 depositId,
        bytes memory depositorSignature
    ) external;

    function executeSlowRelayLeaf(
        address depositor,
        address recipient,
        address destinationToken,
        uint256 amount,
        uint256 originChainId,
        uint64 realizedLpFeePct,
        uint64 relayerFeePct,
        uint32 depositId,
        uint32 rootBundleId,
        bytes32[] memory proof
    ) external;

    function executeRelayerRefundLeaf(
        uint32 rootBundleId,
        SpokePoolInterface.RelayerRefundLeaf memory relayerRefundLeaf,
        bytes32[] memory proof
    ) external;

    function chainId() external view returns (uint256);
}

File 20 of 60 : MerkleLib.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.0;

import "./SpokePoolInterface.sol";
import "./HubPoolInterface.sol";

import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";

/**
 * @notice Library to help with merkle roots, proofs, and claims.
 */
library MerkleLib {
    /**
     * @notice Verifies that a repayment is contained within a merkle root.
     * @param root the merkle root.
     * @param rebalance the rebalance struct.
     * @param proof the merkle proof.
     * @return bool to signal if the pool rebalance proof correctly shows inclusion of the rebalance within the tree.
     */
    function verifyPoolRebalance(
        bytes32 root,
        HubPoolInterface.PoolRebalanceLeaf memory rebalance,
        bytes32[] memory proof
    ) internal pure returns (bool) {
        return MerkleProof.verify(proof, root, keccak256(abi.encode(rebalance)));
    }

    /**
     * @notice Verifies that a relayer refund is contained within a merkle root.
     * @param root the merkle root.
     * @param refund the refund struct.
     * @param proof the merkle proof.
     * @return bool to signal if the relayer refund proof correctly shows inclusion of the refund within the tree.
     */
    function verifyRelayerRefund(
        bytes32 root,
        SpokePoolInterface.RelayerRefundLeaf memory refund,
        bytes32[] memory proof
    ) internal pure returns (bool) {
        return MerkleProof.verify(proof, root, keccak256(abi.encode(refund)));
    }

    /**
     * @notice Verifies that a distribution is contained within a merkle root.
     * @param root the merkle root.
     * @param slowRelayFulfillment the relayData fulfillment struct.
     * @param proof the merkle proof.
     * @return bool to signal if the slow relay's proof correctly shows inclusion of the slow relay within the tree.
     */
    function verifySlowRelayFulfillment(
        bytes32 root,
        SpokePoolInterface.RelayData memory slowRelayFulfillment,
        bytes32[] memory proof
    ) internal pure returns (bool) {
        return MerkleProof.verify(proof, root, keccak256(abi.encode(slowRelayFulfillment)));
    }

    // The following functions are primarily copied from
    // https://github.com/Uniswap/merkle-distributor/blob/master/contracts/MerkleDistributor.sol with minor changes.

    /**
     * @notice Tests whether a claim is contained within a claimedBitMap mapping.
     * @param claimedBitMap a simple uint256 mapping in storage used as a bitmap.
     * @param index the index to check in the bitmap.
     * @return bool indicating if the index within the claimedBitMap has been marked as claimed.
     */
    function isClaimed(mapping(uint256 => uint256) storage claimedBitMap, uint256 index) internal view returns (bool) {
        uint256 claimedWordIndex = index / 256;
        uint256 claimedBitIndex = index % 256;
        uint256 claimedWord = claimedBitMap[claimedWordIndex];
        uint256 mask = (1 << claimedBitIndex);
        return claimedWord & mask == mask;
    }

    /**
     * @notice Marks an index in a claimedBitMap as claimed.
     * @param claimedBitMap a simple uint256 mapping in storage used as a bitmap.
     * @param index the index to mark in the bitmap.
     */
    function setClaimed(mapping(uint256 => uint256) storage claimedBitMap, uint256 index) internal {
        uint256 claimedWordIndex = index / 256;
        uint256 claimedBitIndex = index % 256;
        claimedBitMap[claimedWordIndex] = claimedBitMap[claimedWordIndex] | (1 << claimedBitIndex);
    }

    /**
     * @notice Tests whether a claim is contained within a 1D claimedBitMap mapping.
     * @param claimedBitMap a simple uint256 value, encoding a 1D bitmap.
     * @param index the index to check in the bitmap. Uint8 type enforces that index can't be > 255.
     * @return bool indicating if the index within the claimedBitMap has been marked as claimed.
     */
    function isClaimed1D(uint256 claimedBitMap, uint8 index) internal pure returns (bool) {
        uint256 mask = (1 << index);
        return claimedBitMap & mask == mask;
    }

    /**
     * @notice Marks an index in a claimedBitMap as claimed.
     * @param claimedBitMap a simple uint256 mapping in storage used as a bitmap. Uint8 type enforces that index
     * can't be > 255.
     * @param index the index to mark in the bitmap.
     * @return uint256 representing the modified input claimedBitMap with the index set to true.
     */
    function setClaimed1D(uint256 claimedBitMap, uint8 index) internal pure returns (uint256) {
        return claimedBitMap | (1 << index % 256);
    }
}

File 21 of 60 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        } else if (error == RecoverError.InvalidSignatureV) {
            revert("ECDSA: invalid signature 'v' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        // Check the signature length
        // - case 65: r,s,v signature (standard)
        // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else if (signature.length == 64) {
            bytes32 r;
            bytes32 vs;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                vs := mload(add(signature, 0x40))
            }
            return tryRecover(hash, r, vs);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
        uint8 v = uint8((uint256(vs) >> 255) + 27);
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }
        if (v != 27 && v != 28) {
            return (address(0), RecoverError.InvalidSignatureV);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}

File 22 of 60 : Testable.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

import "./Timer.sol";

/**
 * @title Base class that provides time overrides, but only if being run in test mode.
 */
abstract contract Testable {
    // If the contract is being run in production, then `timerAddress` will be the 0x0 address.
    // Note: this variable should be set on construction and never modified.
    address public timerAddress;

    /**
     * @notice Constructs the Testable contract. Called by child contracts.
     * @param _timerAddress Contract that stores the current time in a testing environment.
     * Must be set to 0x0 for production environments that use live time.
     */
    constructor(address _timerAddress) {
        timerAddress = _timerAddress;
    }

    /**
     * @notice Reverts if not running in test mode.
     */
    modifier onlyIfTest {
        require(timerAddress != address(0x0));
        _;
    }

    /**
     * @notice Sets the current time.
     * @dev Will revert if not running in test mode.
     * @param time timestamp to set current Testable time to.
     */
    function setCurrentTime(uint256 time) external onlyIfTest {
        Timer(timerAddress).setCurrentTime(time);
    }

    /**
     * @notice Gets the current time. Will return the last time set in `setCurrentTime` if running in test mode.
     * Otherwise, it will return the block timestamp.
     * @return uint for the current Testable timestamp.
     */
    function getCurrentTime() public view virtual returns (uint256) {
        if (timerAddress != address(0x0)) {
            return Timer(timerAddress).getCurrentTime();
        } else {
            return block.timestamp; // solhint-disable-line not-rely-on-time
        }
    }
}

File 23 of 60 : HubPoolInterface.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.0;

import "./interfaces/AdapterInterface.sol";

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

/**
 * @notice Concise list of functions in HubPool implementation.
 */
interface HubPoolInterface {
    // This leaf is meant to be decoded in the HubPool to rebalance tokens between HubPool and SpokePool.
    struct PoolRebalanceLeaf {
        // This is used to know which chain to send cross-chain transactions to (and which SpokePool to send to).
        uint256 chainId;
        // Total LP fee amount per token in this bundle, encompassing all associated bundled relays.
        uint256[] bundleLpFees;
        // Represents the amount to push to or pull from the SpokePool. If +, the pool pays the SpokePool. If negative
        // the SpokePool pays the HubPool. There can be arbitrarily complex rebalancing rules defined offchain. This
        // number is only nonzero when the rules indicate that a rebalancing action should occur. When a rebalance does
        // occur, runningBalances must be set to zero for this token and netSendAmounts should be set to the previous
        // runningBalances + relays - deposits in this bundle. If non-zero then it must be set on the SpokePool's
        // RelayerRefundLeaf amountToReturn as -1 * this value to show if funds are being sent from or to the SpokePool.
        int256[] netSendAmounts;
        // This is only here to be emitted in an event to track a running unpaid balance between the L2 pool and the L1
        // pool. A positive number indicates that the HubPool owes the SpokePool funds. A negative number indicates that
        // the SpokePool owes the HubPool funds. See the comment above for the dynamics of this and netSendAmounts.
        int256[] runningBalances;
        // Used by data worker to mark which leaves should relay roots to SpokePools, and to otherwise organize leaves.
        // For example, each leaf should contain all the rebalance information for a single chain, but in the case where
        // the list of l1Tokens is very large such that they all can't fit into a single leaf that can be executed under
        // the block gas limit, then the data worker can use this groupIndex to organize them. Any leaves with
        // a groupIndex equal to 0 will relay roots to the SpokePool, so the data worker should ensure that only one
        // leaf for a specific chainId should have a groupIndex equal to 0.
        uint256 groupIndex;
        // Used as the index in the bitmap to track whether this leaf has been executed or not.
        uint8 leafId;
        // The bundleLpFees, netSendAmounts, and runningBalances are required to be the same length. They are parallel
        // arrays for the given chainId and should be ordered by the l1Tokens field. All whitelisted tokens with nonzero
        // relays on this chain in this bundle in the order of whitelisting.
        address[] l1Tokens;
    }

    // A data worker can optimistically store several merkle roots on this contract by staking a bond and calling
    // proposeRootBundle. By staking a bond, the data worker is alleging that the merkle roots all contain valid leaves
    // that can be executed later to:
    // - Send funds from this contract to a SpokePool or vice versa
    // - Send funds from a SpokePool to Relayer as a refund for a relayed deposit
    // - Send funds from a SpokePool to a deposit recipient to fulfill a "slow" relay
    // Anyone can dispute this struct if the merkle roots contain invalid leaves before the
    // challengePeriodEndTimestamp. Once the expiration timestamp is passed, executeRootBundle to execute a leaf
    // from the poolRebalanceRoot on this contract and it will simultaneously publish the relayerRefundRoot and
    // slowRelayRoot to a SpokePool. The latter two roots, once published to the SpokePool, contain
    // leaves that can be executed on the SpokePool to pay relayers or recipients.
    struct RootBundle {
        // Contains leaves instructing this contract to send funds to SpokePools.
        bytes32 poolRebalanceRoot;
        // Relayer refund merkle root to be published to a SpokePool.
        bytes32 relayerRefundRoot;
        // Slow relay merkle root to be published to a SpokePool.
        bytes32 slowRelayRoot;
        // This is a 1D bitmap, with max size of 256 elements, limiting us to 256 chainsIds.
        uint256 claimedBitMap;
        // Proposer of this root bundle.
        address proposer;
        // Number of pool rebalance leaves to execute in the poolRebalanceRoot. After this number
        // of leaves are executed, a new root bundle can be proposed
        uint8 unclaimedPoolRebalanceLeafCount;
        // When root bundle challenge period passes and this root bundle becomes executable.
        uint32 challengePeriodEndTimestamp;
    }

    // Each whitelisted L1 token has an associated pooledToken struct that contains all information used to track the
    // cumulative LP positions and if this token is enabled for deposits.
    struct PooledToken {
        // LP token given to LPs of a specific L1 token.
        address lpToken;
        // True if accepting new LP's.
        bool isEnabled;
        // Timestamp of last LP fee update.
        uint32 lastLpFeeUpdate;
        // Number of LP funds sent via pool rebalances to SpokePools and are expected to be sent
        // back later.
        int256 utilizedReserves;
        // Number of LP funds held in contract less utilized reserves.
        uint256 liquidReserves;
        // Number of LP funds reserved to pay out to LPs as fees.
        uint256 undistributedLpFees;
    }

    // Helper contracts to facilitate cross chain actions between HubPool and SpokePool for a specific network.
    struct CrossChainContract {
        address adapter;
        address spokePool;
    }

    function setPaused(bool pause) external;

    function emergencyDeleteProposal() external;

    function relaySpokePoolAdminFunction(uint256 chainId, bytes memory functionData) external;

    function setProtocolFeeCapture(address newProtocolFeeCaptureAddress, uint256 newProtocolFeeCapturePct) external;

    function setBond(IERC20 newBondToken, uint256 newBondAmount) external;

    function setLiveness(uint32 newLiveness) external;

    function setIdentifier(bytes32 newIdentifier) external;

    function setCrossChainContracts(
        uint256 l2ChainId,
        address adapter,
        address spokePool
    ) external;

    function enableL1TokenForLiquidityProvision(address l1Token) external;

    function disableL1TokenForLiquidityProvision(address l1Token) external;

    function addLiquidity(address l1Token, uint256 l1TokenAmount) external payable;

    function removeLiquidity(
        address l1Token,
        uint256 lpTokenAmount,
        bool sendEth
    ) external;

    function exchangeRateCurrent(address l1Token) external returns (uint256);

    function liquidityUtilizationCurrent(address l1Token) external returns (uint256);

    function liquidityUtilizationPostRelay(address l1Token, uint256 relayedAmount) external returns (uint256);

    function sync(address l1Token) external;

    function proposeRootBundle(
        uint256[] memory bundleEvaluationBlockNumbers,
        uint8 poolRebalanceLeafCount,
        bytes32 poolRebalanceRoot,
        bytes32 relayerRefundRoot,
        bytes32 slowRelayRoot
    ) external;

    function executeRootBundle(
        uint256 chainId,
        uint256 groupIndex,
        uint256[] memory bundleLpFees,
        int256[] memory netSendAmounts,
        int256[] memory runningBalances,
        uint8 leafId,
        address[] memory l1Tokens,
        bytes32[] memory proof
    ) external;

    function disputeRootBundle() external;

    function claimProtocolFeesCaptured(address l1Token) external;

    function setPoolRebalanceRoute(
        uint256 destinationChainId,
        address l1Token,
        address destinationToken
    ) external;

    function setDepositRoute(
        uint256 originChainId,
        uint256 destinationChainId,
        address originToken,
        bool depositsEnabled
    ) external;

    function poolRebalanceRoute(uint256 destinationChainId, address l1Token)
        external
        view
        returns (address destinationToken);

    function loadEthForL2Calls() external payable;
}

File 24 of 60 : MerkleProof.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/MerkleProof.sol)

pragma solidity ^0.8.0;

/**
 * @dev These functions deal with verification of Merkle Trees proofs.
 *
 * The proofs can be generated using the JavaScript library
 * https://github.com/miguelmota/merkletreejs[merkletreejs].
 * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled.
 *
 * See `test/utils/cryptography/MerkleProof.test.js` for some examples.
 */
library MerkleProof {
    /**
     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
     * defined by `root`. For this, a `proof` must be provided, containing
     * sibling hashes on the branch from the leaf to the root of the tree. Each
     * pair of leaves and each pair of pre-images are assumed to be sorted.
     */
    function verify(
        bytes32[] memory proof,
        bytes32 root,
        bytes32 leaf
    ) internal pure returns (bool) {
        return processProof(proof, leaf) == root;
    }

    /**
     * @dev Returns the rebuilt hash obtained by traversing a Merklee tree up
     * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
     * hash matches the root of the tree. When processing the proof, the pairs
     * of leafs & pre-images are assumed to be sorted.
     *
     * _Available since v4.4._
     */
    function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            bytes32 proofElement = proof[i];
            if (computedHash <= proofElement) {
                // Hash(current computed hash + current element of the proof)
                computedHash = _efficientHash(computedHash, proofElement);
            } else {
                // Hash(current element of the proof + current computed hash)
                computedHash = _efficientHash(proofElement, computedHash);
            }
        }
        return computedHash;
    }

    function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
        assembly {
            mstore(0x00, a)
            mstore(0x20, b)
            value := keccak256(0x00, 0x40)
        }
    }
}

File 25 of 60 : AdapterInterface.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

/**
 * @notice Sends cross chain messages and tokens to contracts on a specific L2 network.
 */

interface AdapterInterface {
    event MessageRelayed(address target, bytes message);

    event TokensRelayed(address l1Token, address l2Token, uint256 amount, address to);

    function relayMessage(address target, bytes calldata message) external payable;

    function relayTokens(
        address l1Token,
        address l2Token,
        uint256 amount,
        address to
    ) external payable;
}

File 26 of 60 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }
}

File 27 of 60 : Timer.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

/**
 * @title Universal store of current contract time for testing environments.
 */
contract Timer {
    uint256 private currentTime;

    constructor() {
        currentTime = block.timestamp; // solhint-disable-line not-rely-on-time
    }

    /**
     * @notice Sets the current time.
     * @dev Will revert if not running in test mode.
     * @param time timestamp to set `currentTime` to.
     */
    function setCurrentTime(uint256 time) external {
        currentTime = time;
    }

    /**
     * @notice Gets the currentTime variable set in the Timer.
     * @return uint256 for the current Testable timestamp.
     */
    function getCurrentTime() public view returns (uint256) {
        return currentTime;
    }
}

File 28 of 60 : MockSpokePool.sol
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

import "../SpokePool.sol";
import "../SpokePoolInterface.sol";

/**
 * @title MockSpokePool
 * @notice Implements abstract contract for testing.
 */
contract MockSpokePool is SpokePool {
    uint256 private chainId_;

    // solhint-disable-next-line no-empty-blocks
    constructor(
        address _crossDomainAdmin,
        address _hubPool,
        address _wethAddress,
        address timerAddress
    ) SpokePool(_crossDomainAdmin, _hubPool, _wethAddress, timerAddress) {} // solhint-disable-line no-empty-blocks

    // solhint-disable-next-line no-empty-blocks
    function _bridgeTokensToHubPool(RelayerRefundLeaf memory relayerRefundLeaf) internal override {}

    function _requireAdminSender() internal override {} // solhint-disable-line no-empty-blocks

    function chainId() public view override(SpokePool) returns (uint256) {
        // If chainId_ is set then return it, else do nothing and return the parent chainId().
        return chainId_ == 0 ? super.chainId() : chainId_;
    }

    function setChainId(uint256 _chainId) public {
        chainId_ = _chainId;
    }
}

File 29 of 60 : Ethereum_SpokePool.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.0;

import "./SpokePool.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

/**
 * @notice Ethereum L1 specific SpokePool. Used on Ethereum L1 to facilitate L2->L1 transfers.
 */
contract Ethereum_SpokePool is SpokePool, Ownable {
    /**
     * @notice Construct the Ethereum SpokePool.
     * @param _hubPool Hub pool address to set. Can be changed by admin.
     * @param _wethAddress Weth address for this network to set.
     * @param timerAddress Timer address to set.
     */
    constructor(
        address _hubPool,
        address _wethAddress,
        address timerAddress
    ) SpokePool(msg.sender, _hubPool, _wethAddress, timerAddress) {}

    /**************************************
     *          INTERNAL FUNCTIONS           *
     **************************************/

    function _bridgeTokensToHubPool(RelayerRefundLeaf memory relayerRefundLeaf) internal override {
        IERC20(relayerRefundLeaf.l2TokenAddress).transfer(hubPool, relayerRefundLeaf.amountToReturn);
    }

    // Admin is simply owner which should be same account that owns the HubPool deployed on this network. A core
    // assumption of this contract system is that the HubPool is deployed on Ethereum.
    function _requireAdminSender() internal override onlyOwner {}
}

File 30 of 60 : Ovm_SpokePool.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.0;

import "./SpokePool.sol";
import "./interfaces/WETH9.sol";

import "@eth-optimism/contracts/libraries/bridge/CrossDomainEnabled.sol";
import "@eth-optimism/contracts/libraries/constants/Lib_PredeployAddresses.sol";
import "@eth-optimism/contracts/L2/messaging/IL2ERC20Bridge.sol";

/**
 * @notice OVM specific SpokePool. Uses OVM cross-domain-enabled logic to implement admin only access to functions. * Optimism and Boba each implement this spoke pool and set their chain specific contract addresses for l2Eth and l2Weth.
 */
contract Ovm_SpokePool is CrossDomainEnabled, SpokePool {
    // "l1Gas" parameter used in call to bridge tokens from this contract back to L1 via IL2ERC20Bridge. Currently
    // unused by bridge but included for future compatibility.
    uint32 public l1Gas = 5_000_000;

    // ETH is an ERC20 on OVM.
    address public immutable l2Eth;

    // Stores alternative token bridges to use for L2 tokens that don't go over the standard bridge. This is needed
    // to support non-standard ERC20 tokens on Optimism, such as DIA and SNX which both use custom bridges.
    mapping(address => address) public tokenBridges;

    event OptimismTokensBridged(address indexed l2Token, address target, uint256 numberOfTokensBridged, uint256 l1Gas);
    event SetL1Gas(uint32 indexed newL1Gas);
    event SetL2TokenBridge(address indexed l2Token, address indexed tokenBridge);

    /**
     * @notice Construct the OVM SpokePool.
     * @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin.
     * @param _hubPool Hub pool address to set. Can be changed by admin.
     * @param timerAddress Timer address to set.
     */
    constructor(
        address _crossDomainAdmin,
        address _hubPool,
        address _l2Eth,
        address _wrappedNativeToken,
        address timerAddress
    )
        CrossDomainEnabled(Lib_PredeployAddresses.L2_CROSS_DOMAIN_MESSENGER)
        SpokePool(_crossDomainAdmin, _hubPool, _wrappedNativeToken, timerAddress)
    {
        l2Eth = _l2Eth;
    }

    /*******************************************
     *    OPTIMISM-SPECIFIC ADMIN FUNCTIONS    *
     *******************************************/

    /**
     * @notice Change L1 gas limit. Callable only by admin.
     * @param newl1Gas New L1 gas limit to set.
     */
    function setL1GasLimit(uint32 newl1Gas) public onlyAdmin nonReentrant {
        l1Gas = newl1Gas;
        emit SetL1Gas(newl1Gas);
    }

    /**
     * @notice Set bridge contract for L2 token used to withdraw back to L1.
     * @dev If this mapping isn't set for an L2 token, then the standard bridge will be used to bridge this token.
     * @param tokenBridge Address of token bridge
     */
    function setTokenBridge(address l2Token, address tokenBridge) public onlyAdmin nonReentrant {
        tokenBridges[l2Token] = tokenBridge;
        emit SetL2TokenBridge(l2Token, tokenBridge);
    }

    /**************************************
     *         DATA WORKER FUNCTIONS      *
     **************************************/

    /**
     * @notice Wraps any ETH into WETH before executing base function. This is necessary because SpokePool receives
     * ETH over the canonical token bridge instead of WETH.
     * @inheritdoc SpokePool
     */
    function executeSlowRelayLeaf(
        address depositor,
        address recipient,
        address destinationToken,
        uint256 totalRelayAmount,
        uint256 originChainId,
        uint64 realizedLpFeePct,
        uint64 relayerFeePct,
        uint32 depositId,
        uint32 rootBundleId,
        bytes32[] memory proof
    ) public override(SpokePool) nonReentrant {
        if (destinationToken == address(wrappedNativeToken)) _depositEthToWeth();

        _executeSlowRelayLeaf(
            depositor,
            recipient,
            destinationToken,
            totalRelayAmount,
            originChainId,
            chainId(),
            realizedLpFeePct,
            relayerFeePct,
            depositId,
            rootBundleId,
            proof
        );
    }

    /**
     * @notice Wraps any ETH into WETH before executing base function. This is necessary because SpokePool receives
     * ETH over the canonical token bridge instead of WETH.
     * @inheritdoc SpokePool
     */
    function executeRelayerRefundLeaf(
        uint32 rootBundleId,
        SpokePoolInterface.RelayerRefundLeaf memory relayerRefundLeaf,
        bytes32[] memory proof
    ) public override(SpokePool) nonReentrant {
        if (relayerRefundLeaf.l2TokenAddress == address(wrappedNativeToken)) _depositEthToWeth();

        _executeRelayerRefundLeaf(rootBundleId, relayerRefundLeaf, proof);
    }

    /**************************************
     *        INTERNAL FUNCTIONS          *
     **************************************/

    // Wrap any ETH owned by this contract so we can send expected L2 token to recipient. This is necessary because
    // this SpokePool will receive ETH from the canonical token bridge instead of WETH. Its not sufficient to execute
    // this logic inside a fallback method that executes when this contract receives ETH because ETH is an ERC20
    // on the OVM.
    function _depositEthToWeth() internal {
        if (address(this).balance > 0) wrappedNativeToken.deposit{ value: address(this).balance }();
    }

    function _bridgeTokensToHubPool(RelayerRefundLeaf memory relayerRefundLeaf) internal override {
        // If the token being bridged is WETH then we need to first unwrap it to ETH and then send ETH over the
        // canonical bridge. On Optimism, this is address 0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000.
        if (relayerRefundLeaf.l2TokenAddress == address(wrappedNativeToken)) {
            WETH9(relayerRefundLeaf.l2TokenAddress).withdraw(relayerRefundLeaf.amountToReturn); // Unwrap into ETH.
            relayerRefundLeaf.l2TokenAddress = l2Eth; // Set the l2TokenAddress to ETH.
        }
        IL2ERC20Bridge(
            tokenBridges[relayerRefundLeaf.l2TokenAddress] == address(0)
                ? Lib_PredeployAddresses.L2_STANDARD_BRIDGE
                : tokenBridges[relayerRefundLeaf.l2TokenAddress]
        ).withdrawTo(
                relayerRefundLeaf.l2TokenAddress, // _l2Token. Address of the L2 token to bridge over.
                hubPool, // _to. Withdraw, over the bridge, to the l1 pool contract.
                relayerRefundLeaf.amountToReturn, // _amount.
                l1Gas, // _l1Gas. Unused, but included for potential forward compatibility considerations
                "" // _data. We don't need to send any data for the bridging action.
            );

        emit OptimismTokensBridged(relayerRefundLeaf.l2TokenAddress, hubPool, relayerRefundLeaf.amountToReturn, l1Gas);
    }

    // Apply OVM-specific transformation to cross domain admin address on L1.
    function _requireAdminSender() internal override onlyFromCrossDomainAccount(crossDomainAdmin) {}
}

File 31 of 60 : CrossDomainEnabled.sol
// SPDX-License-Identifier: MIT
pragma solidity >0.5.0 <0.9.0;

/* Interface Imports */
import { ICrossDomainMessenger } from "./ICrossDomainMessenger.sol";

/**
 * @title CrossDomainEnabled
 * @dev Helper contract for contracts performing cross-domain communications
 *
 * Compiler used: defined by inheriting contract
 */
contract CrossDomainEnabled {
    /*************
     * Variables *
     *************/

    // Messenger contract used to send and recieve messages from the other domain.
    address public messenger;

    /***************
     * Constructor *
     ***************/

    /**
     * @param _messenger Address of the CrossDomainMessenger on the current layer.
     */
    constructor(address _messenger) {
        messenger = _messenger;
    }

    /**********************
     * Function Modifiers *
     **********************/

    /**
     * Enforces that the modified function is only callable by a specific cross-domain account.
     * @param _sourceDomainAccount The only account on the originating domain which is
     *  authenticated to call this function.
     */
    modifier onlyFromCrossDomainAccount(address _sourceDomainAccount) {
        require(
            msg.sender == address(getCrossDomainMessenger()),
            "OVM_XCHAIN: messenger contract unauthenticated"
        );

        require(
            getCrossDomainMessenger().xDomainMessageSender() == _sourceDomainAccount,
            "OVM_XCHAIN: wrong sender of cross-domain message"
        );

        _;
    }

    /**********************
     * Internal Functions *
     **********************/

    /**
     * Gets the messenger, usually from storage. This function is exposed in case a child contract
     * needs to override.
     * @return The address of the cross-domain messenger contract which should be used.
     */
    function getCrossDomainMessenger() internal virtual returns (ICrossDomainMessenger) {
        return ICrossDomainMessenger(messenger);
    }

    /**q
     * Sends a message to an account on another domain
     * @param _crossDomainTarget The intended recipient on the destination domain
     * @param _message The data to send to the target (usually calldata to a function with
     *  `onlyFromCrossDomainAccount()`)
     * @param _gasLimit The gasLimit for the receipt of the message on the target domain.
     */
    function sendCrossDomainMessage(
        address _crossDomainTarget,
        uint32 _gasLimit,
        bytes memory _message
    ) internal {
        // slither-disable-next-line reentrancy-events, reentrancy-benign
        getCrossDomainMessenger().sendMessage(_crossDomainTarget, _message, _gasLimit);
    }
}

File 32 of 60 : Lib_PredeployAddresses.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

/**
 * @title Lib_PredeployAddresses
 */
library Lib_PredeployAddresses {
    address internal constant L2_TO_L1_MESSAGE_PASSER = 0x4200000000000000000000000000000000000000;
    address internal constant L1_MESSAGE_SENDER = 0x4200000000000000000000000000000000000001;
    address internal constant DEPLOYER_WHITELIST = 0x4200000000000000000000000000000000000002;
    address payable internal constant OVM_ETH = payable(0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000);
    address internal constant L2_CROSS_DOMAIN_MESSENGER =
        0x4200000000000000000000000000000000000007;
    address internal constant LIB_ADDRESS_MANAGER = 0x4200000000000000000000000000000000000008;
    address internal constant PROXY_EOA = 0x4200000000000000000000000000000000000009;
    address internal constant L2_STANDARD_BRIDGE = 0x4200000000000000000000000000000000000010;
    address internal constant SEQUENCER_FEE_WALLET = 0x4200000000000000000000000000000000000011;
    address internal constant L2_STANDARD_TOKEN_FACTORY =
        0x4200000000000000000000000000000000000012;
    address internal constant L1_BLOCK_NUMBER = 0x4200000000000000000000000000000000000013;
}

File 33 of 60 : IL2ERC20Bridge.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

/**
 * @title IL2ERC20Bridge
 */
interface IL2ERC20Bridge {
    /**********
     * Events *
     **********/

    event WithdrawalInitiated(
        address indexed _l1Token,
        address indexed _l2Token,
        address indexed _from,
        address _to,
        uint256 _amount,
        bytes _data
    );

    event DepositFinalized(
        address indexed _l1Token,
        address indexed _l2Token,
        address indexed _from,
        address _to,
        uint256 _amount,
        bytes _data
    );

    event DepositFailed(
        address indexed _l1Token,
        address indexed _l2Token,
        address indexed _from,
        address _to,
        uint256 _amount,
        bytes _data
    );

    /********************
     * Public Functions *
     ********************/

    /**
     * @dev get the address of the corresponding L1 bridge contract.
     * @return Address of the corresponding L1 bridge contract.
     */
    function l1TokenBridge() external returns (address);

    /**
     * @dev initiate a withdraw of some tokens to the caller's account on L1
     * @param _l2Token Address of L2 token where withdrawal was initiated.
     * @param _amount Amount of the token to withdraw.
     * param _l1Gas Unused, but included for potential forward compatibility considerations.
     * @param _data Optional data to forward to L1. This data is provided
     *        solely as a convenience for external contracts. Aside from enforcing a maximum
     *        length, these contracts provide no guarantees about its content.
     */
    function withdraw(
        address _l2Token,
        uint256 _amount,
        uint32 _l1Gas,
        bytes calldata _data
    ) external;

    /**
     * @dev initiate a withdraw of some token to a recipient's account on L1.
     * @param _l2Token Address of L2 token where withdrawal is initiated.
     * @param _to L1 adress to credit the withdrawal to.
     * @param _amount Amount of the token to withdraw.
     * param _l1Gas Unused, but included for potential forward compatibility considerations.
     * @param _data Optional data to forward to L1. This data is provided
     *        solely as a convenience for external contracts. Aside from enforcing a maximum
     *        length, these contracts provide no guarantees about its content.
     */
    function withdrawTo(
        address _l2Token,
        address _to,
        uint256 _amount,
        uint32 _l1Gas,
        bytes calldata _data
    ) external;

    /*************************
     * Cross-chain Functions *
     *************************/

    /**
     * @dev Complete a deposit from L1 to L2, and credits funds to the recipient's balance of this
     * L2 token. This call will fail if it did not originate from a corresponding deposit in
     * L1StandardTokenBridge.
     * @param _l1Token Address for the l1 token this is called with
     * @param _l2Token Address for the l2 token this is called with
     * @param _from Account to pull the deposit from on L2.
     * @param _to Address to receive the withdrawal at
     * @param _amount Amount of the token to withdraw
     * @param _data Data provider by the sender on L1. This data is provided
     *        solely as a convenience for external contracts. Aside from enforcing a maximum
     *        length, these contracts provide no guarantees about its content.
     */
    function finalizeDeposit(
        address _l1Token,
        address _l2Token,
        address _from,
        address _to,
        uint256 _amount,
        bytes calldata _data
    ) external;
}

File 34 of 60 : ICrossDomainMessenger.sol
// SPDX-License-Identifier: MIT
pragma solidity >0.5.0 <0.9.0;

/**
 * @title ICrossDomainMessenger
 */
interface ICrossDomainMessenger {
    /**********
     * Events *
     **********/

    event SentMessage(
        address indexed target,
        address sender,
        bytes message,
        uint256 messageNonce,
        uint256 gasLimit
    );
    event RelayedMessage(bytes32 indexed msgHash);
    event FailedRelayedMessage(bytes32 indexed msgHash);

    /*************
     * Variables *
     *************/

    function xDomainMessageSender() external view returns (address);

    /********************
     * Public Functions *
     ********************/

    /**
     * Sends a cross domain message to the target messenger.
     * @param _target Target contract address.
     * @param _message Message to send to the target.
     * @param _gasLimit Gas limit for the provided message.
     */
    function sendMessage(
        address _target,
        bytes calldata _message,
        uint32 _gasLimit
    ) external;
}

File 35 of 60 : Optimism_SpokePool.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.0;
import "@eth-optimism/contracts/libraries/constants/Lib_PredeployAddresses.sol";

import "./Ovm_SpokePool.sol";

/**
 * @notice Optimism Spoke pool.
 */
contract Optimism_SpokePool is Ovm_SpokePool {
    /**
     * @notice Construct the OVM Optimism SpokePool.
     * @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin.
     * @param _hubPool Hub pool address to set. Can be changed by admin.
     * @param timerAddress Timer address to set.
     */
    constructor(
        address _crossDomainAdmin,
        address _hubPool,
        address timerAddress
    )
        Ovm_SpokePool(
            _crossDomainAdmin,
            _hubPool,
            Lib_PredeployAddresses.OVM_ETH,
            0x4200000000000000000000000000000000000006,
            timerAddress
        )
    {}
}

File 36 of 60 : CrossDomainEnabled.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/* Interface Imports */
import { ICrossDomainMessenger } from "@eth-optimism/contracts/libraries/bridge/ICrossDomainMessenger.sol";

/**
 * @title CrossDomainEnabled
 * @dev Helper contract for contracts performing cross-domain communications between L1 and Optimism.
 * @dev This modifies the eth-optimism/CrossDomainEnabled contract only by changing state variables to be
 * immutable for use in contracts like the Optimism_Adapter which use delegateCall().
 */
contract CrossDomainEnabled {
    // Messenger contract used to send and recieve messages from the other domain.
    address public immutable messenger;

    /**
     * @param _messenger Address of the CrossDomainMessenger on the current layer.
     */
    constructor(address _messenger) {
        messenger = _messenger;
    }

    /**
     * Enforces that the modified function is only callable by a specific cross-domain account.
     * @param _sourceDomainAccount The only account on the originating domain which is
     *  authenticated to call this function.
     */
    modifier onlyFromCrossDomainAccount(address _sourceDomainAccount) {
        require(msg.sender == address(getCrossDomainMessenger()), "invalid cross domain messenger");

        require(
            getCrossDomainMessenger().xDomainMessageSender() == _sourceDomainAccount,
            "invalid cross domain sender"
        );

        _;
    }

    /**
     * Gets the messenger, usually from storage. This function is exposed in case a child contract
     * needs to override.
     * @return The address of the cross-domain messenger contract which should be used.
     */
    function getCrossDomainMessenger() internal virtual returns (ICrossDomainMessenger) {
        return ICrossDomainMessenger(messenger);
    }

    /**
     * Sends a message to an account on another domain
     * @param _crossDomainTarget The intended recipient on the destination domain
     * @param _message The data to send to the target (usually calldata to a function with
     *  onlyFromCrossDomainAccount())
     * @param _gasLimit The gasLimit for the receipt of the message on the target domain.
     */
    function sendCrossDomainMessage(
        address _crossDomainTarget,
        uint32 _gasLimit,
        bytes calldata _message
    ) internal {
        // slither-disable-next-line reentrancy-events, reentrancy-benign
        getCrossDomainMessenger().sendMessage(_crossDomainTarget, _message, _gasLimit);
    }
}

File 37 of 60 : Optimism_Adapter.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

import "../interfaces/AdapterInterface.sol";
import "../interfaces/WETH9.sol";

// @dev Use local modified CrossDomainEnabled contract instead of one exported by eth-optimism because we need
// this contract's state variables to be `immutable` because of the delegateCall call.
import "./CrossDomainEnabled.sol";
import "@eth-optimism/contracts/L1/messaging/IL1StandardBridge.sol";

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

/**
 * @notice Contract containing logic to send messages from L1 to Optimism.
 * @dev Public functions calling external contracts do not guard against reentrancy because they are expected to be
 * called via delegatecall, which will execute this contract's logic within the context of the originating contract.
 * For example, the HubPool will delegatecall these functions, therefore its only necessary that the HubPool's methods
 * that call this contract's logic guard against reentrancy.
 */

// solhint-disable-next-line contract-name-camelcase
contract Optimism_Adapter is CrossDomainEnabled, AdapterInterface {
    using SafeERC20 for IERC20;
    uint32 public immutable l2GasLimit = 2_000_000;

    WETH9 public immutable l1Weth;

    IL1StandardBridge public immutable l1StandardBridge;

    // Optimism has the ability to support "custom" bridges. These bridges are not supported by the canonical bridge
    // and so we need to store the address of the custom token and the associated bridge. In the event we want to
    // support a new token that is not supported by Optimism, we can add a new custom bridge for it and re-deploy the
    // adapter. A full list of custom optimism tokens and their associated bridges can be found here:
    // https://github.com/ethereum-optimism/ethereum-optimism.github.io/blob/master/optimism.tokenlist.json
    address public immutable dai = 0x6B175474E89094C44Da98b954EedeAC495271d0F;
    address public immutable daiOptimismBridge = 0x10E6593CDda8c58a1d0f14C5164B376352a55f2F;
    address public immutable snx = 0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F;
    address public immutable snxOptimismBridge = 0xCd9D4988C0AE61887B075bA77f08cbFAd2b65068;

    /**
     * @notice Constructs new Adapter.
     * @param _l1Weth WETH address on L1.
     * @param _crossDomainMessenger XDomainMessenger Optimism system contract.
     * @param _l1StandardBridge Standard bridge contract.
     */
    constructor(
        WETH9 _l1Weth,
        address _crossDomainMessenger,
        IL1StandardBridge _l1StandardBridge
    ) CrossDomainEnabled(_crossDomainMessenger) {
        l1Weth = _l1Weth;
        l1StandardBridge = _l1StandardBridge;
    }

    /**
     * @notice Send cross-chain message to target on Optimism.
     * @param target Contract on Optimism that will receive message.
     * @param message Data to send to target.
     */
    function relayMessage(address target, bytes calldata message) external payable override {
        sendCrossDomainMessage(target, uint32(l2GasLimit), message);
        emit MessageRelayed(target, message);
    }

    /**
     * @notice Bridge tokens to Optimism.
     * @param l1Token L1 token to deposit.
     * @param l2Token L2 token to receive.
     * @param amount Amount of L1 tokens to deposit and L2 tokens to receive.
     * @param to Bridge recipient.
     */
    function relayTokens(
        address l1Token,
        address l2Token,
        uint256 amount,
        address to
    ) external payable override {
        // If the l1Token is weth then unwrap it to ETH then send the ETH to the standard bridge.
        if (l1Token == address(l1Weth)) {
            l1Weth.withdraw(amount);
            l1StandardBridge.depositETHTo{ value: amount }(to, l2GasLimit, "");
        } else {
            IL1StandardBridge _l1StandardBridge = l1StandardBridge;

            // Check if the L1 token requires a custom bridge. If so, use that bridge over the standard bridge.
            if (l1Token == dai) _l1StandardBridge = IL1StandardBridge(daiOptimismBridge); // 1. DAI
            if (l1Token == snx) _l1StandardBridge = IL1StandardBridge(snxOptimismBridge); // 2. SNX

            IERC20(l1Token).safeIncreaseAllowance(address(_l1StandardBridge), amount);
            _l1StandardBridge.depositERC20To(l1Token, l2Token, to, amount, l2GasLimit, "");
        }
        emit TokensRelayed(l1Token, l2Token, amount, to);
    }
}

File 38 of 60 : IL1StandardBridge.sol
// SPDX-License-Identifier: MIT
pragma solidity >0.5.0 <0.9.0;

import "./IL1ERC20Bridge.sol";

/**
 * @title IL1StandardBridge
 */
interface IL1StandardBridge is IL1ERC20Bridge {
    /**********
     * Events *
     **********/
    event ETHDepositInitiated(
        address indexed _from,
        address indexed _to,
        uint256 _amount,
        bytes _data
    );

    event ETHWithdrawalFinalized(
        address indexed _from,
        address indexed _to,
        uint256 _amount,
        bytes _data
    );

    /********************
     * Public Functions *
     ********************/

    /**
     * @dev Deposit an amount of the ETH to the caller's balance on L2.
     * @param _l2Gas Gas limit required to complete the deposit on L2.
     * @param _data Optional data to forward to L2. This data is provided
     *        solely as a convenience for external contracts. Aside from enforcing a maximum
     *        length, these contracts provide no guarantees about its content.
     */
    function depositETH(uint32 _l2Gas, bytes calldata _data) external payable;

    /**
     * @dev Deposit an amount of ETH to a recipient's balance on L2.
     * @param _to L2 address to credit the withdrawal to.
     * @param _l2Gas Gas limit required to complete the deposit on L2.
     * @param _data Optional data to forward to L2. This data is provided
     *        solely as a convenience for external contracts. Aside from enforcing a maximum
     *        length, these contracts provide no guarantees about its content.
     */
    function depositETHTo(
        address _to,
        uint32 _l2Gas,
        bytes calldata _data
    ) external payable;

    /*************************
     * Cross-chain Functions *
     *************************/

    /**
     * @dev Complete a withdrawal from L2 to L1, and credit funds to the recipient's balance of the
     * L1 ETH token. Since only the xDomainMessenger can call this function, it will never be called
     * before the withdrawal is finalized.
     * @param _from L2 address initiating the transfer.
     * @param _to L1 address to credit the withdrawal to.
     * @param _amount Amount of the ERC20 to deposit.
     * @param _data Optional data to forward to L2. This data is provided
     *        solely as a convenience for external contracts. Aside from enforcing a maximum
     *        length, these contracts provide no guarantees about its content.
     */
    function finalizeETHWithdrawal(
        address _from,
        address _to,
        uint256 _amount,
        bytes calldata _data
    ) external;
}

File 39 of 60 : IL1ERC20Bridge.sol
// SPDX-License-Identifier: MIT
pragma solidity >0.5.0 <0.9.0;

/**
 * @title IL1ERC20Bridge
 */
interface IL1ERC20Bridge {
    /**********
     * Events *
     **********/

    event ERC20DepositInitiated(
        address indexed _l1Token,
        address indexed _l2Token,
        address indexed _from,
        address _to,
        uint256 _amount,
        bytes _data
    );

    event ERC20WithdrawalFinalized(
        address indexed _l1Token,
        address indexed _l2Token,
        address indexed _from,
        address _to,
        uint256 _amount,
        bytes _data
    );

    /********************
     * Public Functions *
     ********************/

    /**
     * @dev get the address of the corresponding L2 bridge contract.
     * @return Address of the corresponding L2 bridge contract.
     */
    function l2TokenBridge() external returns (address);

    /**
     * @dev deposit an amount of the ERC20 to the caller's balance on L2.
     * @param _l1Token Address of the L1 ERC20 we are depositing
     * @param _l2Token Address of the L1 respective L2 ERC20
     * @param _amount Amount of the ERC20 to deposit
     * @param _l2Gas Gas limit required to complete the deposit on L2.
     * @param _data Optional data to forward to L2. This data is provided
     *        solely as a convenience for external contracts. Aside from enforcing a maximum
     *        length, these contracts provide no guarantees about its content.
     */
    function depositERC20(
        address _l1Token,
        address _l2Token,
        uint256 _amount,
        uint32 _l2Gas,
        bytes calldata _data
    ) external;

    /**
     * @dev deposit an amount of ERC20 to a recipient's balance on L2.
     * @param _l1Token Address of the L1 ERC20 we are depositing
     * @param _l2Token Address of the L1 respective L2 ERC20
     * @param _to L2 address to credit the withdrawal to.
     * @param _amount Amount of the ERC20 to deposit.
     * @param _l2Gas Gas limit required to complete the deposit on L2.
     * @param _data Optional data to forward to L2. This data is provided
     *        solely as a convenience for external contracts. Aside from enforcing a maximum
     *        length, these contracts provide no guarantees about its content.
     */
    function depositERC20To(
        address _l1Token,
        address _l2Token,
        address _to,
        uint256 _amount,
        uint32 _l2Gas,
        bytes calldata _data
    ) external;

    /*************************
     * Cross-chain Functions *
     *************************/

    /**
     * @dev Complete a withdrawal from L2 to L1, and credit funds to the recipient's balance of the
     * L1 ERC20 token.
     * This call will fail if the initialized withdrawal from L2 has not been finalized.
     *
     * @param _l1Token Address of L1 token to finalizeWithdrawal for.
     * @param _l2Token Address of L2 token where withdrawal was initiated.
     * @param _from L2 address initiating the transfer.
     * @param _to L1 address to credit the withdrawal to.
     * @param _amount Amount of the ERC20 to deposit.
     * @param _data Data provided by the sender on L2. This data is provided
     *   solely as a convenience for external contracts. Aside from enforcing a maximum
     *   length, these contracts provide no guarantees about its content.
     */
    function finalizeERC20Withdrawal(
        address _l1Token,
        address _l2Token,
        address _from,
        address _to,
        uint256 _amount,
        bytes calldata _data
    ) external;
}

File 40 of 60 : Boba_Adapter.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

import "../interfaces/AdapterInterface.sol";
import "../interfaces/WETH9.sol";

// @dev Use local modified CrossDomainEnabled contract instead of one exported by eth-optimism because we need
// this contract's state variables to be `immutable` because of the delegateCall call.
import "./CrossDomainEnabled.sol";
import "@eth-optimism/contracts/L1/messaging/IL1StandardBridge.sol";

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

/**
 * @notice Contract containing logic to send messages from L1 to Boba. This is a modified version of the Optimism adapter
 * that excludes the custom bridging logic.
 * @dev Public functions calling external contracts do not guard against reentrancy because they are expected to be
 * called via delegatecall, which will execute this contract's logic within the context of the originating contract.
 * For example, the HubPool will delegatecall these functions, therefore its only necessary that the HubPool's methods
 * that call this contract's logic guard against reentrancy.
 */

// solhint-disable-next-line contract-name-camelcase
contract Boba_Adapter is CrossDomainEnabled, AdapterInterface {
    using SafeERC20 for IERC20;
    uint32 public immutable l2GasLimit = 2_000_000;

    WETH9 public immutable l1Weth;

    IL1StandardBridge public immutable l1StandardBridge;

    /**
     * @notice Constructs new Adapter.
     * @param _l1Weth WETH address on L1.
     * @param _crossDomainMessenger XDomainMessenger Boba system contract.
     * @param _l1StandardBridge Standard bridge contract.
     */
    constructor(
        WETH9 _l1Weth,
        address _crossDomainMessenger,
        IL1StandardBridge _l1StandardBridge
    ) CrossDomainEnabled(_crossDomainMessenger) {
        l1Weth = _l1Weth;
        l1StandardBridge = _l1StandardBridge;
    }

    /**
     * @notice Send cross-chain message to target on Boba.
     * @param target Contract on Boba that will receive message.
     * @param message Data to send to target.
     */
    function relayMessage(address target, bytes calldata message) external payable override {
        sendCrossDomainMessage(target, uint32(l2GasLimit), message);
        emit MessageRelayed(target, message);
    }

    /**
     * @notice Bridge tokens to Boba.
     * @param l1Token L1 token to deposit.
     * @param l2Token L2 token to receive.
     * @param amount Amount of L1 tokens to deposit and L2 tokens to receive.
     * @param to Bridge recipient.
     */
    function relayTokens(
        address l1Token,
        address l2Token,
        uint256 amount,
        address to
    ) external payable override {
        // If the l1Token is weth then unwrap it to ETH then send the ETH to the standard bridge.
        if (l1Token == address(l1Weth)) {
            l1Weth.withdraw(amount);
            l1StandardBridge.depositETHTo{ value: amount }(to, l2GasLimit, "");
        } else {
            IL1StandardBridge _l1StandardBridge = l1StandardBridge;

            IERC20(l1Token).safeIncreaseAllowance(address(_l1StandardBridge), amount);
            _l1StandardBridge.depositERC20To(l1Token, l2Token, to, amount, l2GasLimit, "");
        }
        emit TokensRelayed(l1Token, l2Token, amount, to);
    }
}

File 41 of 60 : Polygon_Adapter.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

import "../interfaces/AdapterInterface.sol";
import "../interfaces/WETH9.sol";

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

interface IRootChainManager {
    function depositEtherFor(address user) external payable;

    function depositFor(
        address user,
        address rootToken,
        bytes calldata depositData
    ) external;
}

interface IFxStateSender {
    function sendMessageToChild(address _receiver, bytes calldata _data) external;
}

interface DepositManager {
    function depositERC20ForUser(
        address token,
        address user,
        uint256 amount
    ) external;
}

/**
 * @notice Sends cross chain messages Polygon L2 network.
 * @dev Public functions calling external contracts do not guard against reentrancy because they are expected to be
 * called via delegatecall, which will execute this contract's logic within the context of the originating contract.
 * For example, the HubPool will delegatecall these functions, therefore its only necessary that the HubPool's methods
 * that call this contract's logic guard against reentrancy.
 */

// solhint-disable-next-line contract-name-camelcase
contract Polygon_Adapter is AdapterInterface {
    using SafeERC20 for IERC20;
    IRootChainManager public immutable rootChainManager;
    IFxStateSender public immutable fxStateSender;
    DepositManager public immutable depositManager;
    address public immutable erc20Predicate;
    address public immutable l1Matic;
    WETH9 public immutable l1Weth;

    /**
     * @notice Constructs new Adapter.
     * @param _rootChainManager RootChainManager Polygon system contract to deposit tokens over the PoS bridge.
     * @param _fxStateSender FxStateSender Polygon system contract to send arbitrary messages to L2.
     * @param _depositManager DepositManager Polygon system contract to deposit tokens over the Plasma bridge (Matic).
     * @param _erc20Predicate ERC20Predicate Polygon system contract to approve when depositing to the PoS bridge.
     * @param _l1Matic matic address on l1.
     * @param _l1Weth WETH address on L1.
     */
    constructor(
        IRootChainManager _rootChainManager,
        IFxStateSender _fxStateSender,
        DepositManager _depositManager,
        address _erc20Predicate,
        address _l1Matic,
        WETH9 _l1Weth
    ) {
        rootChainManager = _rootChainManager;
        fxStateSender = _fxStateSender;
        depositManager = _depositManager;
        erc20Predicate = _erc20Predicate;
        l1Matic = _l1Matic;
        l1Weth = _l1Weth;
    }

    /**
     * @notice Send cross-chain message to target on Polygon.
     * @param target Contract on Polygon that will receive message.
     * @param message Data to send to target.
     */

    function relayMessage(address target, bytes calldata message) external payable override {
        fxStateSender.sendMessageToChild(target, message);
        emit MessageRelayed(target, message);
    }

    /**
     * @notice Bridge tokens to Polygon.
     * @param l1Token L1 token to deposit.
     * @param l2Token L2 token to receive.
     * @param amount Amount of L1 tokens to deposit and L2 tokens to receive.
     * @param to Bridge recipient.
     */
    function relayTokens(
        address l1Token,
        address l2Token,
        uint256 amount,
        address to
    ) external payable override {
        // If the l1Token is weth then unwrap it to ETH then send the ETH to the standard bridge.
        if (l1Token == address(l1Weth)) {
            l1Weth.withdraw(amount);
            rootChainManager.depositEtherFor{ value: amount }(to);
        } else if (l1Token == l1Matic) {
            IERC20(l1Token).safeIncreaseAllowance(address(depositManager), amount);
            depositManager.depositERC20ForUser(l1Token, to, amount);
        } else {
            IERC20(l1Token).safeIncreaseAllowance(erc20Predicate, amount);
            rootChainManager.depositFor(to, l1Token, abi.encode(amount));
        }
        emit TokensRelayed(l1Token, l2Token, amount, to);
    }
}

File 42 of 60 : Mock_Adapter.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

import "../interfaces/AdapterInterface.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

/**
 * @notice Contract used for testing communication between HubPool and Adapter.
 */

// solhint-disable-next-line contract-name-camelcase
contract Mock_Adapter is AdapterInterface {
    event RelayMessageCalled(address target, bytes message, address caller);

    event RelayTokensCalled(address l1Token, address l2Token, uint256 amount, address to, address caller);

    Mock_Bridge public immutable bridge;

    constructor() {
        bridge = new Mock_Bridge();
    }

    function relayMessage(address target, bytes calldata message) external payable override {
        bridge.bridgeMessage(target, message);
        emit RelayMessageCalled(target, message, msg.sender);
    }

    function relayTokens(
        address l1Token,
        address l2Token,
        uint256 amount,
        address to
    ) external payable override {
        IERC20(l1Token).approve(address(bridge), amount);
        bridge.bridgeTokens(l1Token, amount);
        emit RelayTokensCalled(l1Token, l2Token, amount, to, msg.sender);
    }
}

// This contract is intended to "act like" a simple version of an L2 bridge.
// It's primarily meant to better reflect how a true L2 bridge interaction might work to give better gas estimates.

// solhint-disable-next-line contract-name-camelcase
contract Mock_Bridge {
    event BridgedTokens(address token, uint256 amount);
    event BridgedMessage(address target, bytes message);

    mapping(address => uint256) public deposits;

    function bridgeTokens(address token, uint256 amount) public {
        IERC20(token).transferFrom(msg.sender, address(this), amount);
        deposits[token] += amount;
        emit BridgedTokens(token, amount);
    }

    function bridgeMessage(address target, bytes calldata message) public {
        emit BridgedMessage(target, message);
    }
}

File 43 of 60 : Ethereum_Adapter.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

import "../interfaces/AdapterInterface.sol";

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

/**
 * @notice Contract containing logic to send messages from L1 to Ethereum SpokePool.
 * @notice This contract should always be deployed on the same chain as the HubPool, as it acts as a pass-through
 * contract between HubPool and SpokePool on the same chain. Its named "Ethereum_Adapter" because a core assumption
 * is that the HubPool will be deployed on Ethereum, so this adapter will be used to communicate between HubPool
 * and the Ethereum_SpokePool.
 * @dev Public functions calling external contracts do not guard against reentrancy because they are expected to be
 * called via delegatecall, which will execute this contract's logic within the context of the originating contract.
 * For example, the HubPool will delegatecall these functions, therefore its only necessary that the HubPool's methods
 * that call this contract's logic guard against reentrancy.
 */

// solhint-disable-next-line contract-name-camelcase
contract Ethereum_Adapter is AdapterInterface {
    using SafeERC20 for IERC20;

    /**
     * @notice Send message to target on Ethereum.
     * @notice This function, and contract overall, is not useful in practice except that the HubPool
     * expects to interact with the SpokePool via an Adapter, so when communicating to the Ethereum_SpokePool, it must
     * send messages via this pass-through contract.
     * @param target Contract that will receive message.
     * @param message Data to send to target.
     */
    function relayMessage(address target, bytes calldata message) external payable override {
        _executeCall(target, message);
        emit MessageRelayed(target, message);
    }

    /**
     * @notice Send tokens to target.
     * @param l1Token L1 token to send.
     * @param l2Token Unused parameter in this contract.
     * @param amount Amount of L1 tokens to send.
     * @param to recipient.
     */
    function relayTokens(
        address l1Token,
        address l2Token, // l2Token is unused for ethereum since we are assuming that the HubPool is only deployed
        // on this network.
        uint256 amount,
        address to
    ) external payable override {
        IERC20(l1Token).safeTransfer(to, amount);
        emit TokensRelayed(l1Token, l2Token, amount, to);
    }

    // Note: this snippet of code is copied from Governor.sol. Source: https://github.com/UMAprotocol/protocol/blob/5b37ea818a28479c01e458389a83c3e736306b17/packages/core/contracts/oracle/implementation/Governor.sol#L190-L207
    function _executeCall(address to, bytes memory data) private {
        // Note: this snippet of code is copied from Governor.sol and modified to not include any "value" field.

        bool success;

        // solhint-disable-next-line no-inline-assembly
        assembly {
            let inputData := add(data, 0x20)
            let inputDataSize := mload(data)
            // Hardcode value to be 0 for relayed governance calls in order to avoid addressing complexity of bridging
            // value cross-chain.
            success := call(gas(), to, 0, inputData, inputDataSize, 0, 0)
        }
        require(success, "execute call failed");
    }
}

File 44 of 60 : Arbitrum_Adapter.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

import "../interfaces/AdapterInterface.sol";

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

interface ArbitrumL1InboxLike {
    function createRetryableTicket(
        address destAddr,
        uint256 arbTxCallValue,
        uint256 maxSubmissionCost,
        address submissionRefundAddress,
        address valueRefundAddress,
        uint256 maxGas,
        uint256 gasPriceBid,
        bytes calldata data
    ) external payable returns (uint256);
}

interface ArbitrumL1ERC20GatewayLike {
    function outboundTransfer(
        address _token,
        address _to,
        uint256 _amount,
        uint256 _maxGas,
        uint256 _gasPriceBid,
        bytes calldata _data
    ) external payable returns (bytes memory);

    function getGateway(address _token) external view returns (address);
}

/**
 * @notice Contract containing logic to send messages from L1 to Arbitrum.
 * @dev Public functions calling external contracts do not guard against reentrancy because they are expected to be
 * called via delegatecall, which will execute this contract's logic within the context of the originating contract.
 * For example, the HubPool will delegatecall these functions, therefore its only necessary that the HubPool's methods
 * that call this contract's logic guard against reentrancy.
 */

// solhint-disable-next-line contract-name-camelcase
contract Arbitrum_Adapter is AdapterInterface {
    using SafeERC20 for IERC20;

    // Amount of ETH allocated to pay for the base submission fee. The base submission fee is a parameter unique to
    // retryable transactions; the user is charged the base submission fee to cover the storage costs of keeping their
    // ticket’s calldata in the retry buffer. (current base submission fee is queryable via
    // ArbRetryableTx.getSubmissionPrice). ArbRetryableTicket precompile interface exists at L2 address
    // 0x000000000000000000000000000000000000006E.
    uint256 public immutable l2MaxSubmissionCost = 0.01e18;

    // L2 Gas price bid for immediate L2 execution attempt (queryable via standard eth*gasPrice RPC)
    uint256 public immutable l2GasPrice = 5e9; // 5 gWei

    // Gas limit for immediate L2 execution attempt (can be estimated via NodeInterface.estimateRetryableTicket).
    // NodeInterface precompile interface exists at L2 address 0x00000000000000000000000000000000000000C8
    uint32 public immutable l2GasLimit = 2_000_000;

    // This address on L2 receives extra ETH that is left over after relaying a message via the inbox.
    address public immutable l2RefundL2Address;

    ArbitrumL1InboxLike public immutable l1Inbox;

    ArbitrumL1ERC20GatewayLike public immutable l1ERC20GatewayRouter;

    /**
     * @notice Constructs new Adapter.
     * @param _l1ArbitrumInbox Inbox helper contract to send messages to Arbitrum.
     * @param _l1ERC20GatewayRouter ERC20 gateway router contract to send tokens to Arbitrum.
     */
    constructor(ArbitrumL1InboxLike _l1ArbitrumInbox, ArbitrumL1ERC20GatewayLike _l1ERC20GatewayRouter) {
        l1Inbox = _l1ArbitrumInbox;
        l1ERC20GatewayRouter = _l1ERC20GatewayRouter;

        l2RefundL2Address = msg.sender;
    }

    /**
     * @notice Send cross-chain message to target on Arbitrum.
     * @notice This contract must hold at least getL1CallValue() amount of ETH to send a message via the Inbox
     * successfully, or the message will get stuck.
     * @param target Contract on Arbitrum that will receive message.
     * @param message Data to send to target.
     */
    function relayMessage(address target, bytes memory message) external payable override {
        uint256 requiredL1CallValue = _contractHasSufficientEthBalance();

        l1Inbox.createRetryableTicket{ value: requiredL1CallValue }(
            target, // destAddr destination L2 contract address
            0, // l2CallValue call value for retryable L2 message
            l2MaxSubmissionCost, // maxSubmissionCost Max gas deducted from user's L2 balance to cover base fee
            l2RefundL2Address, // excessFeeRefundAddress maxgas * gasprice - execution cost gets credited here on L2
            l2RefundL2Address, // callValueRefundAddress l2Callvalue gets credited here on L2 if retryable txn times out or gets cancelled
            l2GasLimit, // maxGas Max gas deducted from user's L2 balance to cover L2 execution
            l2GasPrice, // gasPriceBid price bid for L2 execution
            message // data ABI encoded data of L2 message
        );

        emit MessageRelayed(target, message);
    }

    /**
     * @notice Bridge tokens to Arbitrum.
     * @notice This contract must hold at least getL1CallValue() amount of ETH to send a message via the Inbox
     * successfully, or the message will get stuck.
     * @param l1Token L1 token to deposit.
     * @param l2Token L2 token to receive.
     * @param amount Amount of L1 tokens to deposit and L2 tokens to receive.
     * @param to Bridge recipient.
     */
    function relayTokens(
        address l1Token,
        address l2Token, // l2Token is unused for Arbitrum.
        uint256 amount,
        address to
    ) external payable override {
        uint256 requiredL1CallValue = _contractHasSufficientEthBalance();

        // Approve the gateway, not the router, to spend the hub pool's balance. The gateway, which is different
        // per L1 token, will temporarily escrow the tokens to be bridged and pull them from this contract.
        address erc20Gateway = l1ERC20GatewayRouter.getGateway(l1Token);
        IERC20(l1Token).safeIncreaseAllowance(erc20Gateway, amount);

        // `outboundTransfer` expects that the caller includes a bytes message as the last param that includes the
        // maxSubmissionCost to use when creating an L2 retryable ticket: https://github.com/OffchainLabs/arbitrum/blob/e98d14873dd77513b569771f47b5e05b72402c5e/packages/arb-bridge-peripherals/contracts/tokenbridge/ethereum/gateway/L1GatewayRouter.sol#L232
        bytes memory data = abi.encode(l2MaxSubmissionCost, "");

        // Note: outboundTransfer() will ultimately create a retryable ticket and set this contract's address as the
        // refund address. This means that the excess ETH to pay for the L2 transaction will be sent to the aliased
        // contract address on L2 and lost.
        l1ERC20GatewayRouter.outboundTransfer{ value: requiredL1CallValue }(
            l1Token,
            to,
            amount,
            l2GasLimit,
            l2GasPrice,
            data
        );

        emit TokensRelayed(l1Token, l2Token, amount, to);
    }

    /**
     * @notice Returns required amount of ETH to send a message via the Inbox.
     * @return amount of ETH that this contract needs to hold in order for relayMessage to succeed.
     */
    function getL1CallValue() public pure returns (uint256) {
        return l2MaxSubmissionCost + l2GasPrice * l2GasLimit;
    }

    function _contractHasSufficientEthBalance() internal view returns (uint256 requiredL1CallValue) {
        requiredL1CallValue = getL1CallValue();
        require(address(this).balance >= requiredL1CallValue, "Insufficient ETH balance");
    }
}

File 45 of 60 : MerkleLibTest.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.0;

import "../MerkleLib.sol";
import "../HubPoolInterface.sol";
import "../SpokePoolInterface.sol";

/**
 * @notice Contract to test the MerkleLib.
 */
contract MerkleLibTest {
    mapping(uint256 => uint256) public claimedBitMap;

    uint256 public claimedBitMap1D;

    function verifyPoolRebalance(
        bytes32 root,
        HubPoolInterface.PoolRebalanceLeaf memory rebalance,
        bytes32[] memory proof
    ) public pure returns (bool) {
        return MerkleLib.verifyPoolRebalance(root, rebalance, proof);
    }

    function verifyRelayerRefund(
        bytes32 root,
        SpokePoolInterface.RelayerRefundLeaf memory refund,
        bytes32[] memory proof
    ) public pure returns (bool) {
        return MerkleLib.verifyRelayerRefund(root, refund, proof);
    }

    function verifySlowRelayFulfillment(
        bytes32 root,
        SpokePoolInterface.RelayData memory slowRelayFulfillment,
        bytes32[] memory proof
    ) public pure returns (bool) {
        return MerkleLib.verifySlowRelayFulfillment(root, slowRelayFulfillment, proof);
    }

    function isClaimed(uint256 index) public view returns (bool) {
        return MerkleLib.isClaimed(claimedBitMap, index);
    }

    function setClaimed(uint256 index) public {
        MerkleLib.setClaimed(claimedBitMap, index);
    }

    function isClaimed1D(uint8 index) public view returns (bool) {
        return MerkleLib.isClaimed1D(claimedBitMap1D, index);
    }

    function setClaimed1D(uint8 index) public {
        claimedBitMap1D = MerkleLib.setClaimed1D(claimedBitMap1D, index);
    }
}

File 46 of 60 : Boba_SpokePool.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.0;

import "./Ovm_SpokePool.sol";

/**
 * @notice Boba Spoke pool. Note that the l2ETH and l2WETH are the opposite as that in Optimism.
 */
contract Boba_SpokePool is Ovm_SpokePool {
    /**
     * @notice Construct the OVM Boba SpokePool.
     * @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin.
     * @param _hubPool Hub pool address to set. Can be changed by admin.
     * @param timerAddress Timer address to set.
     */
    constructor(
        address _crossDomainAdmin,
        address _hubPool,
        address timerAddress
    )
        Ovm_SpokePool(
            _crossDomainAdmin,
            _hubPool,
            0x4200000000000000000000000000000000000006,
            0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000,
            timerAddress
        )
    {}
}

File 47 of 60 : Arbitrum_SpokePool.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.0;

import "./SpokePool.sol";

interface StandardBridgeLike {
    function outboundTransfer(
        address _l1Token,
        address _to,
        uint256 _amount,
        bytes calldata _data
    ) external payable returns (bytes memory);
}

/**
 * @notice AVM specific SpokePool. Uses AVM cross-domain-enabled logic to implement admin only access to functions.
 */
contract Arbitrum_SpokePool is SpokePool {
    // Address of the Arbitrum L2 token gateway to send funds to L1.
    address public l2GatewayRouter;

    // Admin controlled mapping of arbitrum tokens to L1 counterpart. L1 counterpart addresses
    // are necessary params used when bridging tokens to L1.
    mapping(address => address) public whitelistedTokens;

    event ArbitrumTokensBridged(address indexed l1Token, address target, uint256 numberOfTokensBridged);
    event SetL2GatewayRouter(address indexed newL2GatewayRouter);
    event WhitelistedTokens(address indexed l2Token, address indexed l1Token);

    /**
     * @notice Construct the AVM SpokePool.
     * @param _l2GatewayRouter Address of L2 token gateway. Can be reset by admin.
     * @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin.
     * @param _hubPool Hub pool address to set. Can be changed by admin.
     * @param _wethAddress Weth address for this network to set.
     * @param timerAddress Timer address to set.
     */
    constructor(
        address _l2GatewayRouter,
        address _crossDomainAdmin,
        address _hubPool,
        address _wethAddress,
        address timerAddress
    ) SpokePool(_crossDomainAdmin, _hubPool, _wethAddress, timerAddress) {
        _setL2GatewayRouter(_l2GatewayRouter);
    }

    modifier onlyFromCrossDomainAdmin() {
        require(msg.sender == _applyL1ToL2Alias(crossDomainAdmin), "ONLY_COUNTERPART_GATEWAY");
        _;
    }

    /********************************************************
     *    ARBITRUM-SPECIFIC CROSS-CHAIN ADMIN FUNCTIONS     *
     ********************************************************/

    /**
     * @notice Change L2 gateway router. Callable only by admin.
     * @param newL2GatewayRouter New L2 gateway router.
     */
    function setL2GatewayRouter(address newL2GatewayRouter) public onlyAdmin nonReentrant {
        _setL2GatewayRouter(newL2GatewayRouter);
    }

    /**
     * @notice Add L2 -> L1 token mapping. Callable only by admin.
     * @param l2Token Arbitrum token.
     * @param l1Token Ethereum version of l2Token.
     */
    function whitelistToken(address l2Token, address l1Token) public onlyAdmin nonReentrant {
        _whitelistToken(l2Token, l1Token);
    }

    /**************************************
     *        INTERNAL FUNCTIONS          *
     **************************************/

    function _bridgeTokensToHubPool(RelayerRefundLeaf memory relayerRefundLeaf) internal override {
        // Check that the Ethereum counterpart of the L2 token is stored on this contract.
        address ethereumTokenToBridge = whitelistedTokens[relayerRefundLeaf.l2TokenAddress];
        require(ethereumTokenToBridge != address(0), "Uninitialized mainnet token");
        StandardBridgeLike(l2GatewayRouter).outboundTransfer(
            ethereumTokenToBridge, // _l1Token. Address of the L1 token to bridge over.
            hubPool, // _to. Withdraw, over the bridge, to the l1 hub pool contract.
            relayerRefundLeaf.amountToReturn, // _amount.
            "" // _data. We don't need to send any data for the bridging action.
        );
        emit ArbitrumTokensBridged(address(0), hubPool, relayerRefundLeaf.amountToReturn);
    }

    function _setL2GatewayRouter(address _l2GatewayRouter) internal {
        l2GatewayRouter = _l2GatewayRouter;
        emit SetL2GatewayRouter(l2GatewayRouter);
    }

    function _whitelistToken(address _l2Token, address _l1Token) internal {
        whitelistedTokens[_l2Token] = _l1Token;
        emit WhitelistedTokens(_l2Token, _l1Token);
    }

    // L1 addresses are transformed during l1->l2 calls.
    // See https://developer.offchainlabs.com/docs/l1_l2_messages#address-aliasing for more information.
    // This cannot be pulled directly from Arbitrum contracts because their contracts are not 0.8.X compatible and
    // this operation takes advantage of overflows, whose behavior changed in 0.8.0.
    function _applyL1ToL2Alias(address l1Address) internal pure returns (address l2Address) {
        // Allows overflows as explained above.
        unchecked {
            l2Address = address(uint160(l1Address) + uint160(0x1111000000000000000000000000000000001111));
        }
    }

    // Apply AVM-specific transformation to cross domain admin address on L1.
    function _requireAdminSender() internal override onlyFromCrossDomainAdmin {}
}

File 48 of 60 : PolygonMocks.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract RootChainManagerMock {
    function depositEtherFor(address user) external payable {} // solhint-disable-line no-empty-blocks

    function depositFor(
        address user,
        address rootToken,
        bytes calldata depositData
    ) external {} // solhint-disable-line no-empty-blocks
}

contract FxStateSenderMock {
    // solhint-disable-next-line no-empty-blocks
    function sendMessageToChild(address _receiver, bytes calldata _data) external {}
}

contract DepositManagerMock {
    function depositERC20ForUser(
        address token,
        address user,
        uint256 amount // solhint-disable-next-line no-empty-blocks
    ) external {} // solhint-disable-line no-empty-blocks
}

contract PolygonRegistryMock {
    // solhint-disable-next-line no-empty-blocks
    function erc20Predicate() external returns (address predicate) {}
}

contract PolygonERC20PredicateMock {
    // solhint-disable-next-line no-empty-blocks
    function startExitWithBurntTokens(bytes calldata data) external {}
}

contract PolygonERC20Mock is ERC20 {
    // solhint-disable-next-line no-empty-blocks
    constructor() ERC20("Test ERC20", "TEST") {}

    // solhint-disable-next-line no-empty-blocks
    function withdraw(uint256 amount) external {}
}

File 49 of 60 : OptimisticOracleInterface.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

/**
 * @title Financial contract facing Oracle interface.
 * @dev Interface used by financial contracts to interact with the Oracle. Voters will use a different interface.
 */
abstract contract OptimisticOracleInterface {
    // Struct representing the state of a price request.
    enum State {
        Invalid, // Never requested.
        Requested, // Requested, no other actions taken.
        Proposed, // Proposed, but not expired or disputed yet.
        Expired, // Proposed, not disputed, past liveness.
        Disputed, // Disputed, but no DVM price returned yet.
        Resolved, // Disputed and DVM price is available.
        Settled // Final price has been set in the contract (can get here from Expired or Resolved).
    }

    // Struct representing a price request.
    struct Request {
        address proposer; // Address of the proposer.
        address disputer; // Address of the disputer.
        IERC20 currency; // ERC20 token used to pay rewards and fees.
        bool settled; // True if the request is settled.
        bool refundOnDispute; // True if the requester should be refunded their reward on dispute.
        int256 proposedPrice; // Price that the proposer submitted.
        int256 resolvedPrice; // Price resolved once the request is settled.
        uint256 expirationTime; // Time at which the request auto-settles without a dispute.
        uint256 reward; // Amount of the currency to pay to the proposer on settlement.
        uint256 finalFee; // Final fee to pay to the Store upon request to the DVM.
        uint256 bond; // Bond that the proposer and disputer must pay on top of the final fee.
        uint256 customLiveness; // Custom liveness value set by the requester.
    }

    // This value must be <= the Voting contract's `ancillaryBytesLimit` value otherwise it is possible
    // that a price can be requested to this contract successfully, but cannot be disputed because the DVM refuses
    // to accept a price request made with ancillary data length over a certain size.
    uint256 public constant ancillaryBytesLimit = 8192;

    /**
     * @notice Requests a new price.
     * @param identifier price identifier being requested.
     * @param timestamp timestamp of the price being requested.
     * @param ancillaryData ancillary data representing additional args being passed with the price request.
     * @param currency ERC20 token used for payment of rewards and fees. Must be approved for use with the DVM.
     * @param reward reward offered to a successful proposer. Will be pulled from the caller. Note: this can be 0,
     *               which could make sense if the contract requests and proposes the value in the same call or
     *               provides its own reward system.
     * @return totalBond default bond (final fee) + final fee that the proposer and disputer will be required to pay.
     * This can be changed with a subsequent call to setBond().
     */
    function requestPrice(
        bytes32 identifier,
        uint256 timestamp,
        bytes memory ancillaryData,
        IERC20 currency,
        uint256 reward
    ) external virtual returns (uint256 totalBond);

    /**
     * @notice Set the proposal bond associated with a price request.
     * @param identifier price identifier to identify the existing request.
     * @param timestamp timestamp to identify the existing request.
     * @param ancillaryData ancillary data of the price being requested.
     * @param bond custom bond amount to set.
     * @return totalBond new bond + final fee that the proposer and disputer will be required to pay. This can be
     * changed again with a subsequent call to setBond().
     */
    function setBond(
        bytes32 identifier,
        uint256 timestamp,
        bytes memory ancillaryData,
        uint256 bond
    ) external virtual returns (uint256 totalBond);

    /**
     * @notice Sets the request to refund the reward if the proposal is disputed. This can help to "hedge" the caller
     * in the event of a dispute-caused delay. Note: in the event of a dispute, the winner still receives the other's
     * bond, so there is still profit to be made even if the reward is refunded.
     * @param identifier price identifier to identify the existing request.
     * @param timestamp timestamp to identify the existing request.
     * @param ancillaryData ancillary data of the price being requested.
     */
    function setRefundOnDispute(
        bytes32 identifier,
        uint256 timestamp,
        bytes memory ancillaryData
    ) external virtual;

    /**
     * @notice Sets a custom liveness value for the request. Liveness is the amount of time a proposal must wait before
     * being auto-resolved.
     * @param identifier price identifier to identify the existing request.
     * @param timestamp timestamp to identify the existing request.
     * @param ancillaryData ancillary data of the price being requested.
     * @param customLiveness new custom liveness.
     */
    function setCustomLiveness(
        bytes32 identifier,
        uint256 timestamp,
        bytes memory ancillaryData,
        uint256 customLiveness
    ) external virtual;

    /**
     * @notice Proposes a price value on another address' behalf. Note: this address will receive any rewards that come
     * from this proposal. However, any bonds are pulled from the caller.
     * @param proposer address to set as the proposer.
     * @param requester sender of the initial price request.
     * @param identifier price identifier to identify the existing request.
     * @param timestamp timestamp to identify the existing request.
     * @param ancillaryData ancillary data of the price being requested.
     * @param proposedPrice price being proposed.
     * @return totalBond the amount that's pulled from the caller's wallet as a bond. The bond will be returned to
     * the proposer once settled if the proposal is correct.
     */
    function proposePriceFor(
        address proposer,
        address requester,
        bytes32 identifier,
        uint256 timestamp,
        bytes memory ancillaryData,
        int256 proposedPrice
    ) public virtual returns (uint256 totalBond);

    /**
     * @notice Proposes a price value for an existing price request.
     * @param requester sender of the initial price request.
     * @param identifier price identifier to identify the existing request.
     * @param timestamp timestamp to identify the existing request.
     * @param ancillaryData ancillary data of the price being requested.
     * @param proposedPrice price being proposed.
     * @return totalBond the amount that's pulled from the proposer's wallet as a bond. The bond will be returned to
     * the proposer once settled if the proposal is correct.
     */
    function proposePrice(
        address requester,
        bytes32 identifier,
        uint256 timestamp,
        bytes memory ancillaryData,
        int256 proposedPrice
    ) external virtual returns (uint256 totalBond);

    /**
     * @notice Disputes a price request with an active proposal on another address' behalf. Note: this address will
     * receive any rewards that come from this dispute. However, any bonds are pulled from the caller.
     * @param disputer address to set as the disputer.
     * @param requester sender of the initial price request.
     * @param identifier price identifier to identify the existing request.
     * @param timestamp timestamp to identify the existing request.
     * @param ancillaryData ancillary data of the price being requested.
     * @return totalBond the amount that's pulled from the caller's wallet as a bond. The bond will be returned to
     * the disputer once settled if the dispute was value (the proposal was incorrect).
     */
    function disputePriceFor(
        address disputer,
        address requester,
        bytes32 identifier,
        uint256 timestamp,
        bytes memory ancillaryData
    ) public virtual returns (uint256 totalBond);

    /**
     * @notice Disputes a price value for an existing price request with an active proposal.
     * @param requester sender of the initial price request.
     * @param identifier price identifier to identify the existing request.
     * @param timestamp timestamp to identify the existing request.
     * @param ancillaryData ancillary data of the price being requested.
     * @return totalBond the amount that's pulled from the disputer's wallet as a bond. The bond will be returned to
     * the disputer once settled if the dispute was valid (the proposal was incorrect).
     */
    function disputePrice(
        address requester,
        bytes32 identifier,
        uint256 timestamp,
        bytes memory ancillaryData
    ) external virtual returns (uint256 totalBond);

    /**
     * @notice Retrieves a price that was previously requested by a caller. Reverts if the request is not settled
     * or settleable. Note: this method is not view so that this call may actually settle the price request if it
     * hasn't been settled.
     * @param identifier price identifier to identify the existing request.
     * @param timestamp timestamp to identify the existing request.
     * @param ancillaryData ancillary data of the price being requested.
     * @return resolved price.
     */
    function settleAndGetPrice(
        bytes32 identifier,
        uint256 timestamp,
        bytes memory ancillaryData
    ) external virtual returns (int256);

    /**
     * @notice Attempts to settle an outstanding price request. Will revert if it isn't settleable.
     * @param requester sender of the initial price request.
     * @param identifier price identifier to identify the existing request.
     * @param timestamp timestamp to identify the existing request.
     * @param ancillaryData ancillary data of the price being requested.
     * @return payout the amount that the "winner" (proposer or disputer) receives on settlement. This amount includes
     * the returned bonds as well as additional rewards.
     */
    function settle(
        address requester,
        bytes32 identifier,
        uint256 timestamp,
        bytes memory ancillaryData
    ) external virtual returns (uint256 payout);

    /**
     * @notice Gets the current data structure containing all information about a price request.
     * @param requester sender of the initial price request.
     * @param identifier price identifier to identify the existing request.
     * @param timestamp timestamp to identify the existing request.
     * @param ancillaryData ancillary data of the price being requested.
     * @return the Request data structure.
     */
    function getRequest(
        address requester,
        bytes32 identifier,
        uint256 timestamp,
        bytes memory ancillaryData
    ) public view virtual returns (Request memory);

    /**
     * @notice Returns the state of a price request.
     * @param requester sender of the initial price request.
     * @param identifier price identifier to identify the existing request.
     * @param timestamp timestamp to identify the existing request.
     * @param ancillaryData ancillary data of the price being requested.
     * @return the State enum value.
     */
    function getState(
        address requester,
        bytes32 identifier,
        uint256 timestamp,
        bytes memory ancillaryData
    ) public view virtual returns (State);

    /**
     * @notice Checks if a given request has resolved or been settled (i.e the optimistic oracle has a price).
     * @param requester sender of the initial price request.
     * @param identifier price identifier to identify the existing request.
     * @param timestamp timestamp to identify the existing request.
     * @param ancillaryData ancillary data of the price being requested.
     * @return true if price has resolved or settled, false otherwise.
     */
    function hasPrice(
        address requester,
        bytes32 identifier,
        uint256 timestamp,
        bytes memory ancillaryData
    ) public view virtual returns (bool);

    function stampAncillaryData(bytes memory ancillaryData, address requester)
        public
        view
        virtual
        returns (bytes memory);
}

File 50 of 60 : SkinnyOptimisticOracleInterface.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../interfaces/OptimisticOracleInterface.sol";

/**
 * @title Interface for the gas-cost-reduced version of the OptimisticOracle.
 * @notice Differences from normal OptimisticOracle:
 * - refundOnDispute: flag is removed, by default there are no refunds on disputes.
 * - customizing request parameters: In the OptimisticOracle, parameters like `bond` and `customLiveness` can be reset
 *   after a request is already made via `requestPrice`. In the SkinnyOptimisticOracle, these parameters can only be
 *   set in `requestPrice`, which has an expanded input set.
 * - settleAndGetPrice: Replaced by `settle`, which can only be called once per settleable request. The resolved price
 *   can be fetched via the `Settle` event or the return value of `settle`.
 * - general changes to interface: Functions that interact with existing requests all require the parameters of the
 *   request to modify to be passed as input. These parameters must match with the existing request parameters or the
 *   function will revert. This change reflects the internal refactor to store hashed request parameters instead of the
 *   full request struct.
 * @dev Interface used by financial contracts to interact with the Oracle. Voters will use a different interface.
 */
abstract contract SkinnyOptimisticOracleInterface {
    // Struct representing a price request. Note that this differs from the OptimisticOracleInterface's Request struct
    // in that refundOnDispute is removed.
    struct Request {
        address proposer; // Address of the proposer.
        address disputer; // Address of the disputer.
        IERC20 currency; // ERC20 token used to pay rewards and fees.
        bool settled; // True if the request is settled.
        int256 proposedPrice; // Price that the proposer submitted.
        int256 resolvedPrice; // Price resolved once the request is settled.
        uint256 expirationTime; // Time at which the request auto-settles without a dispute.
        uint256 reward; // Amount of the currency to pay to the proposer on settlement.
        uint256 finalFee; // Final fee to pay to the Store upon request to the DVM.
        uint256 bond; // Bond that the proposer and disputer must pay on top of the final fee.
        uint256 customLiveness; // Custom liveness value set by the requester.
    }

    // This value must be <= the Voting contract's `ancillaryBytesLimit` value otherwise it is possible
    // that a price can be requested to this contract successfully, but cannot be disputed because the DVM refuses
    // to accept a price request made with ancillary data length over a certain size.
    uint256 public constant ancillaryBytesLimit = 8192;

    /**
     * @notice Requests a new price.
     * @param identifier price identifier being requested.
     * @param timestamp timestamp of the price being requested.
     * @param ancillaryData ancillary data representing additional args being passed with the price request.
     * @param currency ERC20 token used for payment of rewards and fees. Must be approved for use with the DVM.
     * @param reward reward offered to a successful proposer. Will be pulled from the caller. Note: this can be 0,
     *               which could make sense if the contract requests and proposes the value in the same call or
     *               provides its own reward system.
     * @param bond custom proposal bond to set for request. If set to 0, defaults to the final fee.
     * @param customLiveness custom proposal liveness to set for request.
     * @return totalBond default bond + final fee that the proposer and disputer will be required to pay.
     */
    function requestPrice(
        bytes32 identifier,
        uint32 timestamp,
        bytes memory ancillaryData,
        IERC20 currency,
        uint256 reward,
        uint256 bond,
        uint256 customLiveness
    ) external virtual returns (uint256 totalBond);

    /**
     * @notice Proposes a price value on another address' behalf. Note: this address will receive any rewards that come
     * from this proposal. However, any bonds are pulled from the caller.
     * @param requester sender of the initial price request.
     * @param identifier price identifier to identify the existing request.
     * @param timestamp timestamp to identify the existing request.
     * @param ancillaryData ancillary data of the price being requested.
     * @param request price request parameters whose hash must match the request that the caller wants to
     * propose a price for.
     * @param proposer address to set as the proposer.
     * @param proposedPrice price being proposed.
     * @return totalBond the amount that's pulled from the caller's wallet as a bond. The bond will be returned to
     * the proposer once settled if the proposal is correct.
     */
    function proposePriceFor(
        address requester,
        bytes32 identifier,
        uint32 timestamp,
        bytes memory ancillaryData,
        Request memory request,
        address proposer,
        int256 proposedPrice
    ) public virtual returns (uint256 totalBond);

    /**
     * @notice Proposes a price value where caller is the proposer.
     * @param requester sender of the initial price request.
     * @param identifier price identifier to identify the existing request.
     * @param timestamp timestamp to identify the existing request.
     * @param ancillaryData ancillary data of the price being requested.
     * @param request price request parameters whose hash must match the request that the caller wants to
     * propose a price for.
     * @param proposedPrice price being proposed.
     * @return totalBond the amount that's pulled from the caller's wallet as a bond. The bond will be returned to
     * the proposer once settled if the proposal is correct.
     */
    function proposePrice(
        address requester,
        bytes32 identifier,
        uint32 timestamp,
        bytes memory ancillaryData,
        Request memory request,
        int256 proposedPrice
    ) external virtual returns (uint256 totalBond);

    /**
     * @notice Combines logic of requestPrice and proposePrice while taking advantage of gas savings from not having to
     * overwrite Request params that a normal requestPrice() => proposePrice() flow would entail. Note: The proposer
     * will receive any rewards that come from this proposal. However, any bonds are pulled from the caller.
     * @dev The caller is the requester, but the proposer can be customized.
     * @param identifier price identifier to identify the existing request.
     * @param timestamp timestamp to identify the existing request.
     * @param ancillaryData ancillary data of the price being requested.
     * @param currency ERC20 token used for payment of rewards and fees. Must be approved for use with the DVM.
     * @param reward reward offered to a successful proposer. Will be pulled from the caller. Note: this can be 0,
     *               which could make sense if the contract requests and proposes the value in the same call or
     *               provides its own reward system.
     * @param bond custom proposal bond to set for request. If set to 0, defaults to the final fee.
     * @param customLiveness custom proposal liveness to set for request.
     * @param proposer address to set as the proposer.
     * @param proposedPrice price being proposed.
     * @return totalBond the amount that's pulled from the caller's wallet as a bond. The bond will be returned to
     * the proposer once settled if the proposal is correct.
     */
    function requestAndProposePriceFor(
        bytes32 identifier,
        uint32 timestamp,
        bytes memory ancillaryData,
        IERC20 currency,
        uint256 reward,
        uint256 bond,
        uint256 customLiveness,
        address proposer,
        int256 proposedPrice
    ) external virtual returns (uint256 totalBond);

    /**
     * @notice Disputes a price request with an active proposal on another address' behalf. Note: this address will
     * receive any rewards that come from this dispute. However, any bonds are pulled from the caller.
     * @param identifier price identifier to identify the existing request.
     * @param timestamp timestamp to identify the existing request.
     * @param ancillaryData ancillary data of the price being requested.
     * @param request price request parameters whose hash must match the request that the caller wants to
     * dispute.
     * @param disputer address to set as the disputer.
     * @param requester sender of the initial price request.
     * @return totalBond the amount that's pulled from the caller's wallet as a bond. The bond will be returned to
     * the disputer once settled if the dispute was valid (the proposal was incorrect).
     */
    function disputePriceFor(
        bytes32 identifier,
        uint32 timestamp,
        bytes memory ancillaryData,
        Request memory request,
        address disputer,
        address requester
    ) public virtual returns (uint256 totalBond);

    /**
     * @notice Disputes a price request with an active proposal where caller is the disputer.
     * @param requester sender of the initial price request.
     * @param identifier price identifier to identify the existing request.
     * @param timestamp timestamp to identify the existing request.
     * @param ancillaryData ancillary data of the price being requested.
     * @param request price request parameters whose hash must match the request that the caller wants to
     * dispute.
     * @return totalBond the amount that's pulled from the caller's wallet as a bond. The bond will be returned to
     * the disputer once settled if the dispute was valid (the proposal was incorrect).
     */
    function disputePrice(
        address requester,
        bytes32 identifier,
        uint32 timestamp,
        bytes memory ancillaryData,
        Request memory request
    ) external virtual returns (uint256 totalBond);

    /**
     * @notice Attempts to settle an outstanding price request. Will revert if it isn't settleable.
     * @param requester sender of the initial price request.
     * @param identifier price identifier to identify the existing request.
     * @param timestamp timestamp to identify the existing request.
     * @param ancillaryData ancillary data of the price being requested.
     * @param request price request parameters whose hash must match the request that the caller wants to
     * settle.
     * @return payout the amount that the "winner" (proposer or disputer) receives on settlement. This amount includes
     * the returned bonds as well as additional rewards.
     * @return resolvedPrice the price that the request settled to.
     */
    function settle(
        address requester,
        bytes32 identifier,
        uint32 timestamp,
        bytes memory ancillaryData,
        Request memory request
    ) external virtual returns (uint256 payout, int256 resolvedPrice);

    /**
     * @notice Computes the current state of a price request. See the State enum for more details.
     * @param requester sender of the initial price request.
     * @param identifier price identifier to identify the existing request.
     * @param timestamp timestamp to identify the existing request.
     * @param ancillaryData ancillary data of the price being requested.
     * @param request price request parameters.
     * @return the State.
     */
    function getState(
        address requester,
        bytes32 identifier,
        uint32 timestamp,
        bytes memory ancillaryData,
        Request memory request
    ) external virtual returns (OptimisticOracleInterface.State);

    /**
     * @notice Checks if a given request has resolved, expired or been settled (i.e the optimistic oracle has a price).
     * @param requester sender of the initial price request.
     * @param identifier price identifier to identify the existing request.
     * @param timestamp timestamp to identify the existing request.
     * @param ancillaryData ancillary data of the price being requested.
     * @param request price request parameters. The hash of these parameters must match with the request hash that is
     * associated with the price request unique ID {requester, identifier, timestamp, ancillaryData}, or this method
     * will revert.
     * @return boolean indicating true if price exists and false if not.
     */
    function hasPrice(
        address requester,
        bytes32 identifier,
        uint32 timestamp,
        bytes memory ancillaryData,
        Request memory request
    ) public virtual returns (bool);

    /**
     * @notice Generates stamped ancillary data in the format that it would be used in the case of a price dispute.
     * @param ancillaryData ancillary data of the price being requested.
     * @param requester sender of the initial price request.
     * @return the stamped ancillary bytes.
     */
    function stampAncillaryData(bytes memory ancillaryData, address requester)
        public
        pure
        virtual
        returns (bytes memory);
}

File 51 of 60 : StoreInterface.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../../common/implementation/FixedPoint.sol";

/**
 * @title Interface that allows financial contracts to pay oracle fees for their use of the system.
 */
interface StoreInterface {
    /**
     * @notice Pays Oracle fees in ETH to the store.
     * @dev To be used by contracts whose margin currency is ETH.
     */
    function payOracleFees() external payable;

    /**
     * @notice Pays oracle fees in the margin currency, erc20Address, to the store.
     * @dev To be used if the margin currency is an ERC20 token rather than ETH.
     * @param erc20Address address of the ERC20 token used to pay the fee.
     * @param amount number of tokens to transfer. An approval for at least this amount must exist.
     */
    function payOracleFeesErc20(address erc20Address, FixedPoint.Unsigned calldata amount) external;

    /**
     * @notice Computes the regular oracle fees that a contract should pay for a period.
     * @param startTime defines the beginning time from which the fee is paid.
     * @param endTime end time until which the fee is paid.
     * @param pfc "profit from corruption", or the maximum amount of margin currency that a
     * token sponsor could extract from the contract through corrupting the price feed in their favor.
     * @return regularFee amount owed for the duration from start to end time for the given pfc.
     * @return latePenalty for paying the fee after the deadline.
     */
    function computeRegularFee(
        uint256 startTime,
        uint256 endTime,
        FixedPoint.Unsigned calldata pfc
    ) external view returns (FixedPoint.Unsigned memory regularFee, FixedPoint.Unsigned memory latePenalty);

    /**
     * @notice Computes the final oracle fees that a contract should pay at settlement.
     * @param currency token used to pay the final fee.
     * @return finalFee amount due.
     */
    function computeFinalFee(address currency) external view returns (FixedPoint.Unsigned memory);
}

File 52 of 60 : FixedPoint.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/utils/math/SignedSafeMath.sol";

/**
 * @title Library for fixed point arithmetic on uints
 */
library FixedPoint {
    using SafeMath for uint256;
    using SignedSafeMath for int256;

    // Supports 18 decimals. E.g., 1e18 represents "1", 5e17 represents "0.5".
    // For unsigned values:
    //   This can represent a value up to (2^256 - 1)/10^18 = ~10^59. 10^59 will be stored internally as uint256 10^77.
    uint256 private constant FP_SCALING_FACTOR = 10**18;

    // --------------------------------------- UNSIGNED -----------------------------------------------------------------------------
    struct Unsigned {
        uint256 rawValue;
    }

    /**
     * @notice Constructs an `Unsigned` from an unscaled uint, e.g., `b=5` gets stored internally as `5*(10**18)`.
     * @param a uint to convert into a FixedPoint.
     * @return the converted FixedPoint.
     */
    function fromUnscaledUint(uint256 a) internal pure returns (Unsigned memory) {
        return Unsigned(a.mul(FP_SCALING_FACTOR));
    }

    /**
     * @notice Whether `a` is equal to `b`.
     * @param a a FixedPoint.
     * @param b a uint256.
     * @return True if equal, or False.
     */
    function isEqual(Unsigned memory a, uint256 b) internal pure returns (bool) {
        return a.rawValue == fromUnscaledUint(b).rawValue;
    }

    /**
     * @notice Whether `a` is equal to `b`.
     * @param a a FixedPoint.
     * @param b a FixedPoint.
     * @return True if equal, or False.
     */
    function isEqual(Unsigned memory a, Unsigned memory b) internal pure returns (bool) {
        return a.rawValue == b.rawValue;
    }

    /**
     * @notice Whether `a` is greater than `b`.
     * @param a a FixedPoint.
     * @param b a FixedPoint.
     * @return True if `a > b`, or False.
     */
    function isGreaterThan(Unsigned memory a, Unsigned memory b) internal pure returns (bool) {
        return a.rawValue > b.rawValue;
    }

    /**
     * @notice Whether `a` is greater than `b`.
     * @param a a FixedPoint.
     * @param b a uint256.
     * @return True if `a > b`, or False.
     */
    function isGreaterThan(Unsigned memory a, uint256 b) internal pure returns (bool) {
        return a.rawValue > fromUnscaledUint(b).rawValue;
    }

    /**
     * @notice Whether `a` is greater than `b`.
     * @param a a uint256.
     * @param b a FixedPoint.
     * @return True if `a > b`, or False.
     */
    function isGreaterThan(uint256 a, Unsigned memory b) internal pure returns (bool) {
        return fromUnscaledUint(a).rawValue > b.rawValue;
    }

    /**
     * @notice Whether `a` is greater than or equal to `b`.
     * @param a a FixedPoint.
     * @param b a FixedPoint.
     * @return True if `a >= b`, or False.
     */
    function isGreaterThanOrEqual(Unsigned memory a, Unsigned memory b) internal pure returns (bool) {
        return a.rawValue >= b.rawValue;
    }

    /**
     * @notice Whether `a` is greater than or equal to `b`.
     * @param a a FixedPoint.
     * @param b a uint256.
     * @return True if `a >= b`, or False.
     */
    function isGreaterThanOrEqual(Unsigned memory a, uint256 b) internal pure returns (bool) {
        return a.rawValue >= fromUnscaledUint(b).rawValue;
    }

    /**
     * @notice Whether `a` is greater than or equal to `b`.
     * @param a a uint256.
     * @param b a FixedPoint.
     * @return True if `a >= b`, or False.
     */
    function isGreaterThanOrEqual(uint256 a, Unsigned memory b) internal pure returns (bool) {
        return fromUnscaledUint(a).rawValue >= b.rawValue;
    }

    /**
     * @notice Whether `a` is less than `b`.
     * @param a a FixedPoint.
     * @param b a FixedPoint.
     * @return True if `a < b`, or False.
     */
    function isLessThan(Unsigned memory a, Unsigned memory b) internal pure returns (bool) {
        return a.rawValue < b.rawValue;
    }

    /**
     * @notice Whether `a` is less than `b`.
     * @param a a FixedPoint.
     * @param b a uint256.
     * @return True if `a < b`, or False.
     */
    function isLessThan(Unsigned memory a, uint256 b) internal pure returns (bool) {
        return a.rawValue < fromUnscaledUint(b).rawValue;
    }

    /**
     * @notice Whether `a` is less than `b`.
     * @param a a uint256.
     * @param b a FixedPoint.
     * @return True if `a < b`, or False.
     */
    function isLessThan(uint256 a, Unsigned memory b) internal pure returns (bool) {
        return fromUnscaledUint(a).rawValue < b.rawValue;
    }

    /**
     * @notice Whether `a` is less than or equal to `b`.
     * @param a a FixedPoint.
     * @param b a FixedPoint.
     * @return True if `a <= b`, or False.
     */
    function isLessThanOrEqual(Unsigned memory a, Unsigned memory b) internal pure returns (bool) {
        return a.rawValue <= b.rawValue;
    }

    /**
     * @notice Whether `a` is less than or equal to `b`.
     * @param a a FixedPoint.
     * @param b a uint256.
     * @return True if `a <= b`, or False.
     */
    function isLessThanOrEqual(Unsigned memory a, uint256 b) internal pure returns (bool) {
        return a.rawValue <= fromUnscaledUint(b).rawValue;
    }

    /**
     * @notice Whether `a` is less than or equal to `b`.
     * @param a a uint256.
     * @param b a FixedPoint.
     * @return True if `a <= b`, or False.
     */
    function isLessThanOrEqual(uint256 a, Unsigned memory b) internal pure returns (bool) {
        return fromUnscaledUint(a).rawValue <= b.rawValue;
    }

    /**
     * @notice The minimum of `a` and `b`.
     * @param a a FixedPoint.
     * @param b a FixedPoint.
     * @return the minimum of `a` and `b`.
     */
    function min(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) {
        return a.rawValue < b.rawValue ? a : b;
    }

    /**
     * @notice The maximum of `a` and `b`.
     * @param a a FixedPoint.
     * @param b a FixedPoint.
     * @return the maximum of `a` and `b`.
     */
    function max(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) {
        return a.rawValue > b.rawValue ? a : b;
    }

    /**
     * @notice Adds two `Unsigned`s, reverting on overflow.
     * @param a a FixedPoint.
     * @param b a FixedPoint.
     * @return the sum of `a` and `b`.
     */
    function add(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) {
        return Unsigned(a.rawValue.add(b.rawValue));
    }

    /**
     * @notice Adds an `Unsigned` to an unscaled uint, reverting on overflow.
     * @param a a FixedPoint.
     * @param b a uint256.
     * @return the sum of `a` and `b`.
     */
    function add(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory) {
        return add(a, fromUnscaledUint(b));
    }

    /**
     * @notice Subtracts two `Unsigned`s, reverting on overflow.
     * @param a a FixedPoint.
     * @param b a FixedPoint.
     * @return the difference of `a` and `b`.
     */
    function sub(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) {
        return Unsigned(a.rawValue.sub(b.rawValue));
    }

    /**
     * @notice Subtracts an unscaled uint256 from an `Unsigned`, reverting on overflow.
     * @param a a FixedPoint.
     * @param b a uint256.
     * @return the difference of `a` and `b`.
     */
    function sub(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory) {
        return sub(a, fromUnscaledUint(b));
    }

    /**
     * @notice Subtracts an `Unsigned` from an unscaled uint256, reverting on overflow.
     * @param a a uint256.
     * @param b a FixedPoint.
     * @return the difference of `a` and `b`.
     */
    function sub(uint256 a, Unsigned memory b) internal pure returns (Unsigned memory) {
        return sub(fromUnscaledUint(a), b);
    }

    /**
     * @notice Multiplies two `Unsigned`s, reverting on overflow.
     * @dev This will "floor" the product.
     * @param a a FixedPoint.
     * @param b a FixedPoint.
     * @return the product of `a` and `b`.
     */
    function mul(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) {
        // There are two caveats with this computation:
        // 1. Max output for the represented number is ~10^41, otherwise an intermediate value overflows. 10^41 is
        // stored internally as a uint256 ~10^59.
        // 2. Results that can't be represented exactly are truncated not rounded. E.g., 1.4 * 2e-18 = 2.8e-18, which
        // would round to 3, but this computation produces the result 2.
        // No need to use SafeMath because FP_SCALING_FACTOR != 0.
        return Unsigned(a.rawValue.mul(b.rawValue) / FP_SCALING_FACTOR);
    }

    /**
     * @notice Multiplies an `Unsigned` and an unscaled uint256, reverting on overflow.
     * @dev This will "floor" the product.
     * @param a a FixedPoint.
     * @param b a uint256.
     * @return the product of `a` and `b`.
     */
    function mul(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory) {
        return Unsigned(a.rawValue.mul(b));
    }

    /**
     * @notice Multiplies two `Unsigned`s and "ceil's" the product, reverting on overflow.
     * @param a a FixedPoint.
     * @param b a FixedPoint.
     * @return the product of `a` and `b`.
     */
    function mulCeil(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) {
        uint256 mulRaw = a.rawValue.mul(b.rawValue);
        uint256 mulFloor = mulRaw / FP_SCALING_FACTOR;
        uint256 mod = mulRaw.mod(FP_SCALING_FACTOR);
        if (mod != 0) {
            return Unsigned(mulFloor.add(1));
        } else {
            return Unsigned(mulFloor);
        }
    }

    /**
     * @notice Multiplies an `Unsigned` and an unscaled uint256 and "ceil's" the product, reverting on overflow.
     * @param a a FixedPoint.
     * @param b a FixedPoint.
     * @return the product of `a` and `b`.
     */
    function mulCeil(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory) {
        // Since b is an uint, there is no risk of truncation and we can just mul it normally
        return Unsigned(a.rawValue.mul(b));
    }

    /**
     * @notice Divides one `Unsigned` by an `Unsigned`, reverting on overflow or division by 0.
     * @dev This will "floor" the quotient.
     * @param a a FixedPoint numerator.
     * @param b a FixedPoint denominator.
     * @return the quotient of `a` divided by `b`.
     */
    function div(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) {
        // There are two caveats with this computation:
        // 1. Max value for the number dividend `a` represents is ~10^41, otherwise an intermediate value overflows.
        // 10^41 is stored internally as a uint256 10^59.
        // 2. Results that can't be represented exactly are truncated not rounded. E.g., 2 / 3 = 0.6 repeating, which
        // would round to 0.666666666666666667, but this computation produces the result 0.666666666666666666.
        return Unsigned(a.rawValue.mul(FP_SCALING_FACTOR).div(b.rawValue));
    }

    /**
     * @notice Divides one `Unsigned` by an unscaled uint256, reverting on overflow or division by 0.
     * @dev This will "floor" the quotient.
     * @param a a FixedPoint numerator.
     * @param b a uint256 denominator.
     * @return the quotient of `a` divided by `b`.
     */
    function div(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory) {
        return Unsigned(a.rawValue.div(b));
    }

    /**
     * @notice Divides one unscaled uint256 by an `Unsigned`, reverting on overflow or division by 0.
     * @dev This will "floor" the quotient.
     * @param a a uint256 numerator.
     * @param b a FixedPoint denominator.
     * @return the quotient of `a` divided by `b`.
     */
    function div(uint256 a, Unsigned memory b) internal pure returns (Unsigned memory) {
        return div(fromUnscaledUint(a), b);
    }

    /**
     * @notice Divides one `Unsigned` by an `Unsigned` and "ceil's" the quotient, reverting on overflow or division by 0.
     * @param a a FixedPoint numerator.
     * @param b a FixedPoint denominator.
     * @return the quotient of `a` divided by `b`.
     */
    function divCeil(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) {
        uint256 aScaled = a.rawValue.mul(FP_SCALING_FACTOR);
        uint256 divFloor = aScaled.div(b.rawValue);
        uint256 mod = aScaled.mod(b.rawValue);
        if (mod != 0) {
            return Unsigned(divFloor.add(1));
        } else {
            return Unsigned(divFloor);
        }
    }

    /**
     * @notice Divides one `Unsigned` by an unscaled uint256 and "ceil's" the quotient, reverting on overflow or division by 0.
     * @param a a FixedPoint numerator.
     * @param b a uint256 denominator.
     * @return the quotient of `a` divided by `b`.
     */
    function divCeil(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory) {
        // Because it is possible that a quotient gets truncated, we can't just call "Unsigned(a.rawValue.div(b))"
        // similarly to mulCeil with a uint256 as the second parameter. Therefore we need to convert b into an Unsigned.
        // This creates the possibility of overflow if b is very large.
        return divCeil(a, fromUnscaledUint(b));
    }

    /**
     * @notice Raises an `Unsigned` to the power of an unscaled uint256, reverting on overflow. E.g., `b=2` squares `a`.
     * @dev This will "floor" the result.
     * @param a a FixedPoint numerator.
     * @param b a uint256 denominator.
     * @return output is `a` to the power of `b`.
     */
    function pow(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory output) {
        output = fromUnscaledUint(1);
        for (uint256 i = 0; i < b; i = i.add(1)) {
            output = mul(output, a);
        }
    }

    // ------------------------------------------------- SIGNED -------------------------------------------------------------
    // Supports 18 decimals. E.g., 1e18 represents "1", 5e17 represents "0.5".
    // For signed values:
    //   This can represent a value up (or down) to +-(2^255 - 1)/10^18 = ~10^58. 10^58 will be stored internally as int256 10^76.
    int256 private constant SFP_SCALING_FACTOR = 10**18;

    struct Signed {
        int256 rawValue;
    }

    function fromSigned(Signed memory a) internal pure returns (Unsigned memory) {
        require(a.rawValue >= 0, "Negative value provided");
        return Unsigned(uint256(a.rawValue));
    }

    function fromUnsigned(Unsigned memory a) internal pure returns (Signed memory) {
        require(a.rawValue <= uint256(type(int256).max), "Unsigned too large");
        return Signed(int256(a.rawValue));
    }

    /**
     * @notice Constructs a `Signed` from an unscaled int, e.g., `b=5` gets stored internally as `5*(10**18)`.
     * @param a int to convert into a FixedPoint.Signed.
     * @return the converted FixedPoint.Signed.
     */
    function fromUnscaledInt(int256 a) internal pure returns (Signed memory) {
        return Signed(a.mul(SFP_SCALING_FACTOR));
    }

    /**
     * @notice Whether `a` is equal to `b`.
     * @param a a FixedPoint.Signed.
     * @param b a int256.
     * @return True if equal, or False.
     */
    function isEqual(Signed memory a, int256 b) internal pure returns (bool) {
        return a.rawValue == fromUnscaledInt(b).rawValue;
    }

    /**
     * @notice Whether `a` is equal to `b`.
     * @param a a FixedPoint.Signed.
     * @param b a FixedPoint.Signed.
     * @return True if equal, or False.
     */
    function isEqual(Signed memory a, Signed memory b) internal pure returns (bool) {
        return a.rawValue == b.rawValue;
    }

    /**
     * @notice Whether `a` is greater than `b`.
     * @param a a FixedPoint.Signed.
     * @param b a FixedPoint.Signed.
     * @return True if `a > b`, or False.
     */
    function isGreaterThan(Signed memory a, Signed memory b) internal pure returns (bool) {
        return a.rawValue > b.rawValue;
    }

    /**
     * @notice Whether `a` is greater than `b`.
     * @param a a FixedPoint.Signed.
     * @param b an int256.
     * @return True if `a > b`, or False.
     */
    function isGreaterThan(Signed memory a, int256 b) internal pure returns (bool) {
        return a.rawValue > fromUnscaledInt(b).rawValue;
    }

    /**
     * @notice Whether `a` is greater than `b`.
     * @param a an int256.
     * @param b a FixedPoint.Signed.
     * @return True if `a > b`, or False.
     */
    function isGreaterThan(int256 a, Signed memory b) internal pure returns (bool) {
        return fromUnscaledInt(a).rawValue > b.rawValue;
    }

    /**
     * @notice Whether `a` is greater than or equal to `b`.
     * @param a a FixedPoint.Signed.
     * @param b a FixedPoint.Signed.
     * @return True if `a >= b`, or False.
     */
    function isGreaterThanOrEqual(Signed memory a, Signed memory b) internal pure returns (bool) {
        return a.rawValue >= b.rawValue;
    }

    /**
     * @notice Whether `a` is greater than or equal to `b`.
     * @param a a FixedPoint.Signed.
     * @param b an int256.
     * @return True if `a >= b`, or False.
     */
    function isGreaterThanOrEqual(Signed memory a, int256 b) internal pure returns (bool) {
        return a.rawValue >= fromUnscaledInt(b).rawValue;
    }

    /**
     * @notice Whether `a` is greater than or equal to `b`.
     * @param a an int256.
     * @param b a FixedPoint.Signed.
     * @return True if `a >= b`, or False.
     */
    function isGreaterThanOrEqual(int256 a, Signed memory b) internal pure returns (bool) {
        return fromUnscaledInt(a).rawValue >= b.rawValue;
    }

    /**
     * @notice Whether `a` is less than `b`.
     * @param a a FixedPoint.Signed.
     * @param b a FixedPoint.Signed.
     * @return True if `a < b`, or False.
     */
    function isLessThan(Signed memory a, Signed memory b) internal pure returns (bool) {
        return a.rawValue < b.rawValue;
    }

    /**
     * @notice Whether `a` is less than `b`.
     * @param a a FixedPoint.Signed.
     * @param b an int256.
     * @return True if `a < b`, or False.
     */
    function isLessThan(Signed memory a, int256 b) internal pure returns (bool) {
        return a.rawValue < fromUnscaledInt(b).rawValue;
    }

    /**
     * @notice Whether `a` is less than `b`.
     * @param a an int256.
     * @param b a FixedPoint.Signed.
     * @return True if `a < b`, or False.
     */
    function isLessThan(int256 a, Signed memory b) internal pure returns (bool) {
        return fromUnscaledInt(a).rawValue < b.rawValue;
    }

    /**
     * @notice Whether `a` is less than or equal to `b`.
     * @param a a FixedPoint.Signed.
     * @param b a FixedPoint.Signed.
     * @return True if `a <= b`, or False.
     */
    function isLessThanOrEqual(Signed memory a, Signed memory b) internal pure returns (bool) {
        return a.rawValue <= b.rawValue;
    }

    /**
     * @notice Whether `a` is less than or equal to `b`.
     * @param a a FixedPoint.Signed.
     * @param b an int256.
     * @return True if `a <= b`, or False.
     */
    function isLessThanOrEqual(Signed memory a, int256 b) internal pure returns (bool) {
        return a.rawValue <= fromUnscaledInt(b).rawValue;
    }

    /**
     * @notice Whether `a` is less than or equal to `b`.
     * @param a an int256.
     * @param b a FixedPoint.Signed.
     * @return True if `a <= b`, or False.
     */
    function isLessThanOrEqual(int256 a, Signed memory b) internal pure returns (bool) {
        return fromUnscaledInt(a).rawValue <= b.rawValue;
    }

    /**
     * @notice The minimum of `a` and `b`.
     * @param a a FixedPoint.Signed.
     * @param b a FixedPoint.Signed.
     * @return the minimum of `a` and `b`.
     */
    function min(Signed memory a, Signed memory b) internal pure returns (Signed memory) {
        return a.rawValue < b.rawValue ? a : b;
    }

    /**
     * @notice The maximum of `a` and `b`.
     * @param a a FixedPoint.Signed.
     * @param b a FixedPoint.Signed.
     * @return the maximum of `a` and `b`.
     */
    function max(Signed memory a, Signed memory b) internal pure returns (Signed memory) {
        return a.rawValue > b.rawValue ? a : b;
    }

    /**
     * @notice Adds two `Signed`s, reverting on overflow.
     * @param a a FixedPoint.Signed.
     * @param b a FixedPoint.Signed.
     * @return the sum of `a` and `b`.
     */
    function add(Signed memory a, Signed memory b) internal pure returns (Signed memory) {
        return Signed(a.rawValue.add(b.rawValue));
    }

    /**
     * @notice Adds an `Signed` to an unscaled int, reverting on overflow.
     * @param a a FixedPoint.Signed.
     * @param b an int256.
     * @return the sum of `a` and `b`.
     */
    function add(Signed memory a, int256 b) internal pure returns (Signed memory) {
        return add(a, fromUnscaledInt(b));
    }

    /**
     * @notice Subtracts two `Signed`s, reverting on overflow.
     * @param a a FixedPoint.Signed.
     * @param b a FixedPoint.Signed.
     * @return the difference of `a` and `b`.
     */
    function sub(Signed memory a, Signed memory b) internal pure returns (Signed memory) {
        return Signed(a.rawValue.sub(b.rawValue));
    }

    /**
     * @notice Subtracts an unscaled int256 from an `Signed`, reverting on overflow.
     * @param a a FixedPoint.Signed.
     * @param b an int256.
     * @return the difference of `a` and `b`.
     */
    function sub(Signed memory a, int256 b) internal pure returns (Signed memory) {
        return sub(a, fromUnscaledInt(b));
    }

    /**
     * @notice Subtracts an `Signed` from an unscaled int256, reverting on overflow.
     * @param a an int256.
     * @param b a FixedPoint.Signed.
     * @return the difference of `a` and `b`.
     */
    function sub(int256 a, Signed memory b) internal pure returns (Signed memory) {
        return sub(fromUnscaledInt(a), b);
    }

    /**
     * @notice Multiplies two `Signed`s, reverting on overflow.
     * @dev This will "floor" the product.
     * @param a a FixedPoint.Signed.
     * @param b a FixedPoint.Signed.
     * @return the product of `a` and `b`.
     */
    function mul(Signed memory a, Signed memory b) internal pure returns (Signed memory) {
        // There are two caveats with this computation:
        // 1. Max output for the represented number is ~10^41, otherwise an intermediate value overflows. 10^41 is
        // stored internally as an int256 ~10^59.
        // 2. Results that can't be represented exactly are truncated not rounded. E.g., 1.4 * 2e-18 = 2.8e-18, which
        // would round to 3, but this computation produces the result 2.
        // No need to use SafeMath because SFP_SCALING_FACTOR != 0.
        return Signed(a.rawValue.mul(b.rawValue) / SFP_SCALING_FACTOR);
    }

    /**
     * @notice Multiplies an `Signed` and an unscaled int256, reverting on overflow.
     * @dev This will "floor" the product.
     * @param a a FixedPoint.Signed.
     * @param b an int256.
     * @return the product of `a` and `b`.
     */
    function mul(Signed memory a, int256 b) internal pure returns (Signed memory) {
        return Signed(a.rawValue.mul(b));
    }

    /**
     * @notice Multiplies two `Signed`s and "ceil's" the product, reverting on overflow.
     * @param a a FixedPoint.Signed.
     * @param b a FixedPoint.Signed.
     * @return the product of `a` and `b`.
     */
    function mulAwayFromZero(Signed memory a, Signed memory b) internal pure returns (Signed memory) {
        int256 mulRaw = a.rawValue.mul(b.rawValue);
        int256 mulTowardsZero = mulRaw / SFP_SCALING_FACTOR;
        // Manual mod because SignedSafeMath doesn't support it.
        int256 mod = mulRaw % SFP_SCALING_FACTOR;
        if (mod != 0) {
            bool isResultPositive = isLessThan(a, 0) == isLessThan(b, 0);
            int256 valueToAdd = isResultPositive ? int256(1) : int256(-1);
            return Signed(mulTowardsZero.add(valueToAdd));
        } else {
            return Signed(mulTowardsZero);
        }
    }

    /**
     * @notice Multiplies an `Signed` and an unscaled int256 and "ceil's" the product, reverting on overflow.
     * @param a a FixedPoint.Signed.
     * @param b a FixedPoint.Signed.
     * @return the product of `a` and `b`.
     */
    function mulAwayFromZero(Signed memory a, int256 b) internal pure returns (Signed memory) {
        // Since b is an int, there is no risk of truncation and we can just mul it normally
        return Signed(a.rawValue.mul(b));
    }

    /**
     * @notice Divides one `Signed` by an `Signed`, reverting on overflow or division by 0.
     * @dev This will "floor" the quotient.
     * @param a a FixedPoint numerator.
     * @param b a FixedPoint denominator.
     * @return the quotient of `a` divided by `b`.
     */
    function div(Signed memory a, Signed memory b) internal pure returns (Signed memory) {
        // There are two caveats with this computation:
        // 1. Max value for the number dividend `a` represents is ~10^41, otherwise an intermediate value overflows.
        // 10^41 is stored internally as an int256 10^59.
        // 2. Results that can't be represented exactly are truncated not rounded. E.g., 2 / 3 = 0.6 repeating, which
        // would round to 0.666666666666666667, but this computation produces the result 0.666666666666666666.
        return Signed(a.rawValue.mul(SFP_SCALING_FACTOR).div(b.rawValue));
    }

    /**
     * @notice Divides one `Signed` by an unscaled int256, reverting on overflow or division by 0.
     * @dev This will "floor" the quotient.
     * @param a a FixedPoint numerator.
     * @param b an int256 denominator.
     * @return the quotient of `a` divided by `b`.
     */
    function div(Signed memory a, int256 b) internal pure returns (Signed memory) {
        return Signed(a.rawValue.div(b));
    }

    /**
     * @notice Divides one unscaled int256 by an `Signed`, reverting on overflow or division by 0.
     * @dev This will "floor" the quotient.
     * @param a an int256 numerator.
     * @param b a FixedPoint denominator.
     * @return the quotient of `a` divided by `b`.
     */
    function div(int256 a, Signed memory b) internal pure returns (Signed memory) {
        return div(fromUnscaledInt(a), b);
    }

    /**
     * @notice Divides one `Signed` by an `Signed` and "ceil's" the quotient, reverting on overflow or division by 0.
     * @param a a FixedPoint numerator.
     * @param b a FixedPoint denominator.
     * @return the quotient of `a` divided by `b`.
     */
    function divAwayFromZero(Signed memory a, Signed memory b) internal pure returns (Signed memory) {
        int256 aScaled = a.rawValue.mul(SFP_SCALING_FACTOR);
        int256 divTowardsZero = aScaled.div(b.rawValue);
        // Manual mod because SignedSafeMath doesn't support it.
        int256 mod = aScaled % b.rawValue;
        if (mod != 0) {
            bool isResultPositive = isLessThan(a, 0) == isLessThan(b, 0);
            int256 valueToAdd = isResultPositive ? int256(1) : int256(-1);
            return Signed(divTowardsZero.add(valueToAdd));
        } else {
            return Signed(divTowardsZero);
        }
    }

    /**
     * @notice Divides one `Signed` by an unscaled int256 and "ceil's" the quotient, reverting on overflow or division by 0.
     * @param a a FixedPoint numerator.
     * @param b an int256 denominator.
     * @return the quotient of `a` divided by `b`.
     */
    function divAwayFromZero(Signed memory a, int256 b) internal pure returns (Signed memory) {
        // Because it is possible that a quotient gets truncated, we can't just call "Signed(a.rawValue.div(b))"
        // similarly to mulCeil with an int256 as the second parameter. Therefore we need to convert b into an Signed.
        // This creates the possibility of overflow if b is very large.
        return divAwayFromZero(a, fromUnscaledInt(b));
    }

    /**
     * @notice Raises an `Signed` to the power of an unscaled uint256, reverting on overflow. E.g., `b=2` squares `a`.
     * @dev This will "floor" the result.
     * @param a a FixedPoint.Signed.
     * @param b a uint256 (negative exponents are not allowed).
     * @return output is `a` to the power of `b`.
     */
    function pow(Signed memory a, uint256 b) internal pure returns (Signed memory output) {
        output = fromUnscaledInt(1);
        for (uint256 i = 0; i < b; i = i.add(1)) {
            output = mul(output, a);
        }
    }
}

File 53 of 60 : SafeMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // 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 (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @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) {
        return a + b;
    }

    /**
     * @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 a - b;
    }

    /**
     * @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) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting 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 a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting 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) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * 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) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

File 54 of 60 : SignedSafeMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/SignedSafeMath.sol)

pragma solidity ^0.8.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SignedSafeMath` is no longer needed starting with Solidity 0.8. The compiler
 * now has built in overflow checking.
 */
library SignedSafeMath {
    /**
     * @dev Returns the multiplication of two signed integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(int256 a, int256 b) internal pure returns (int256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two signed integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(int256 a, int256 b) internal pure returns (int256) {
        return a / b;
    }

    /**
     * @dev Returns the subtraction of two signed integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(int256 a, int256 b) internal pure returns (int256) {
        return a - b;
    }

    /**
     * @dev Returns the addition of two signed integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(int256 a, int256 b) internal pure returns (int256) {
        return a + b;
    }
}

File 55 of 60 : LpTokenFactory.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.0;

import "./interfaces/LpTokenFactoryInterface.sol";

import "@uma/core/contracts/common/implementation/ExpandedERC20.sol";

/**
 * @notice Factory to create new LP ERC20 tokens that represent a liquidity provider's position. HubPool is the
 * intended client of this contract.
 */
contract LpTokenFactory is LpTokenFactoryInterface {
    /**
     * @notice Deploys new LP token for L1 token. Sets caller as minter and burner of token.
     * @param l1Token L1 token to name in LP token name.
     * @return address of new LP token.
     */
    function createLpToken(address l1Token) public returns (address) {
        ExpandedERC20 lpToken = new ExpandedERC20(
            _concatenate("Across V2 ", IERC20Metadata(l1Token).name(), " LP Token"), // LP Token Name
            _concatenate("Av2-", IERC20Metadata(l1Token).symbol(), "-LP"), // LP Token Symbol
            IERC20Metadata(l1Token).decimals() // LP Token Decimals
        );

        lpToken.addMinter(msg.sender); // Set the caller as the LP Token's minter.
        lpToken.addBurner(msg.sender); // Set the caller as the LP Token's burner.
        lpToken.resetOwner(msg.sender); // Set the caller as the LP Token's owner.

        return address(lpToken);
    }

    function _concatenate(
        string memory a,
        string memory b,
        string memory c
    ) internal pure returns (string memory) {
        return string(abi.encodePacked(a, b, c));
    }
}

File 56 of 60 : LpTokenFactoryInterface.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

interface LpTokenFactoryInterface {
    function createLpToken(address l1Token) external returns (address);
}

File 57 of 60 : FinderInterface.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

/**
 * @title Provides addresses of the live contracts implementing certain interfaces.
 * @dev Examples are the Oracle or Store interfaces.
 */
interface FinderInterface {
    /**
     * @notice Updates the address of the contract that implements `interfaceName`.
     * @param interfaceName bytes32 encoding of the interface name that is either changed or registered.
     * @param implementationAddress address of the deployed contract that implements the interface.
     */
    function changeImplementationAddress(bytes32 interfaceName, address implementationAddress) external;

    /**
     * @notice Gets the address of the contract that implements the given `interfaceName`.
     * @param interfaceName queried interface.
     * @return implementationAddress address of the deployed contract that implements the interface.
     */
    function getImplementationAddress(bytes32 interfaceName) external view returns (address);
}

File 58 of 60 : IdentifierWhitelistInterface.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

/**
 * @title Interface for whitelists of supported identifiers that the oracle can provide prices for.
 */
interface IdentifierWhitelistInterface {
    /**
     * @notice Adds the provided identifier as a supported identifier.
     * @dev Price requests using this identifier will succeed after this call.
     * @param identifier bytes32 encoding of the string identifier. Eg: BTC/USD.
     */
    function addSupportedIdentifier(bytes32 identifier) external;

    /**
     * @notice Removes the identifier from the whitelist.
     * @dev Price requests using this identifier will no longer succeed after this call.
     * @param identifier bytes32 encoding of the string identifier. Eg: BTC/USD.
     */
    function removeSupportedIdentifier(bytes32 identifier) external;

    /**
     * @notice Checks whether an identifier is on the whitelist.
     * @param identifier bytes32 encoding of the string identifier. Eg: BTC/USD.
     * @return bool if the identifier is supported (or not).
     */
    function isIdentifierSupported(bytes32 identifier) external view returns (bool);
}

File 59 of 60 : AddressWhitelistInterface.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

interface AddressWhitelistInterface {
    function addToWhitelist(address newElement) external;

    function removeFromWhitelist(address newElement) external;

    function isOnWhitelist(address newElement) external view returns (bool);

    function getWhitelist() external view returns (address[] memory);
}

File 60 of 60 : Constants.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

/**
 * @title Stores common interface names used throughout the DVM by registration in the Finder.
 */
library OracleInterfaces {
    bytes32 public constant Oracle = "Oracle";
    bytes32 public constant IdentifierWhitelist = "IdentifierWhitelist";
    bytes32 public constant Store = "Store";
    bytes32 public constant FinancialContractsAdmin = "FinancialContractsAdmin";
    bytes32 public constant Registry = "Registry";
    bytes32 public constant CollateralWhitelist = "CollateralWhitelist";
    bytes32 public constant OptimisticOracle = "OptimisticOracle";
    bytes32 public constant Bridge = "Bridge";
    bytes32 public constant GenericHandler = "GenericHandler";
    bytes32 public constant SkinnyOptimisticOracle = "SkinnyOptimisticOracle";
    bytes32 public constant ChildMessenger = "ChildMessenger";
    bytes32 public constant OracleHub = "OracleHub";
    bytes32 public constant OracleSpoke = "OracleSpoke";
}

/**
 * @title Commonly re-used values for contracts associated with the OptimisticOracle.
 */
library OptimisticOracleConstraints {
    // Any price request submitted to the OptimisticOracle must contain ancillary data no larger than this value.
    // This value must be <= the Voting contract's `ancillaryBytesLimit` constant value otherwise it is possible
    // that a price can be requested to the OptimisticOracle successfully, but cannot be resolved by the DVM which
    // refuses to accept a price request made with ancillary data length over a certain size.
    uint256 public constant ancillaryBytesLimit = 8192;
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 1000000
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  },
  "metadata": {
    "useLiteralContent": true
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_crossDomainAdmin","type":"address"},{"internalType":"address","name":"_hubPool","type":"address"},{"internalType":"address","name":"timerAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"rootBundleId","type":"uint256"}],"name":"EmergencyDeleteRootBundle","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"originToken","type":"address"},{"indexed":true,"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"EnabledDepositRoute","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amountToReturn","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"chainId","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"refundAmounts","type":"uint256[]"},{"indexed":true,"internalType":"uint32","name":"rootBundleId","type":"uint32"},{"indexed":true,"internalType":"uint32","name":"leafId","type":"uint32"},{"indexed":false,"internalType":"address","name":"l2TokenAddress","type":"address"},{"indexed":false,"internalType":"address[]","name":"refundAddresses","type":"address[]"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"ExecutedRelayerRefundRoot","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalFilledAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fillAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"repaymentChainId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"originChainId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"relayerFeePct","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"appliedRelayerFeePct","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"realizedLpFeePct","type":"uint64"},{"indexed":false,"internalType":"uint32","name":"depositId","type":"uint32"},{"indexed":false,"internalType":"address","name":"destinationToken","type":"address"},{"indexed":true,"internalType":"address","name":"relayer","type":"address"},{"indexed":true,"internalType":"address","name":"depositor","type":"address"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"bool","name":"isSlowRelay","type":"bool"}],"name":"FilledRelay","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"originChainId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"relayerFeePct","type":"uint64"},{"indexed":true,"internalType":"uint32","name":"depositId","type":"uint32"},{"indexed":false,"internalType":"uint32","name":"quoteTimestamp","type":"uint32"},{"indexed":true,"internalType":"address","name":"originToken","type":"address"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":true,"internalType":"address","name":"depositor","type":"address"}],"name":"FundsDeposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"l2Token","type":"address"},{"indexed":false,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"uint256","name":"numberOfTokensBridged","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"l1Gas","type":"uint256"}],"name":"OptimismTokensBridged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"rootBundleId","type":"uint32"},{"indexed":true,"internalType":"bytes32","name":"relayerRefundRoot","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"slowRelayRoot","type":"bytes32"}],"name":"RelayedRootBundle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"newRelayerFeePct","type":"uint64"},{"indexed":true,"internalType":"uint32","name":"depositId","type":"uint32"},{"indexed":true,"internalType":"address","name":"depositor","type":"address"},{"indexed":false,"internalType":"bytes","name":"depositorSignature","type":"bytes"}],"name":"RequestedSpeedUpDeposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"newBuffer","type":"uint32"}],"name":"SetDepositQuoteTimeBuffer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newHubPool","type":"address"}],"name":"SetHubPool","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"newL1Gas","type":"uint32"}],"name":"SetL1Gas","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"l2Token","type":"address"},{"indexed":true,"internalType":"address","name":"tokenBridge","type":"address"}],"name":"SetL2TokenBridge","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newAdmin","type":"address"}],"name":"SetXDomainAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amountToReturn","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"chainId","type":"uint256"},{"indexed":true,"internalType":"uint32","name":"leafId","type":"uint32"},{"indexed":true,"internalType":"address","name":"l2TokenAddress","type":"address"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"TokensBridged","type":"event"},{"inputs":[],"name":"chainId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"crossDomainAdmin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"originToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"internalType":"uint64","name":"relayerFeePct","type":"uint64"},{"internalType":"uint32","name":"quoteTimestamp","type":"uint32"}],"name":"deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"depositQuoteTimeBuffer","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"rootBundleId","type":"uint256"}],"name":"emergencyDeleteRootBundle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"enabledDepositRoutes","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"rootBundleId","type":"uint32"},{"components":[{"internalType":"uint256","name":"amountToReturn","type":"uint256"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"uint256[]","name":"refundAmounts","type":"uint256[]"},{"internalType":"uint32","name":"leafId","type":"uint32"},{"internalType":"address","name":"l2TokenAddress","type":"address"},{"internalType":"address[]","name":"refundAddresses","type":"address[]"}],"internalType":"struct SpokePoolInterface.RelayerRefundLeaf","name":"relayerRefundLeaf","type":"tuple"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"executeRelayerRefundLeaf","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"depositor","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"destinationToken","type":"address"},{"internalType":"uint256","name":"totalRelayAmount","type":"uint256"},{"internalType":"uint256","name":"originChainId","type":"uint256"},{"internalType":"uint64","name":"realizedLpFeePct","type":"uint64"},{"internalType":"uint64","name":"relayerFeePct","type":"uint64"},{"internalType":"uint32","name":"depositId","type":"uint32"},{"internalType":"uint32","name":"rootBundleId","type":"uint32"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"executeSlowRelayLeaf","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"depositor","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"destinationToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"maxTokensToSend","type":"uint256"},{"internalType":"uint256","name":"repaymentChainId","type":"uint256"},{"internalType":"uint256","name":"originChainId","type":"uint256"},{"internalType":"uint64","name":"realizedLpFeePct","type":"uint64"},{"internalType":"uint64","name":"relayerFeePct","type":"uint64"},{"internalType":"uint32","name":"depositId","type":"uint32"}],"name":"fillRelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"depositor","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"destinationToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"maxTokensToSend","type":"uint256"},{"internalType":"uint256","name":"repaymentChainId","type":"uint256"},{"internalType":"uint256","name":"originChainId","type":"uint256"},{"internalType":"uint64","name":"realizedLpFeePct","type":"uint64"},{"internalType":"uint64","name":"relayerFeePct","type":"uint64"},{"internalType":"uint64","name":"newRelayerFeePct","type":"uint64"},{"internalType":"uint32","name":"depositId","type":"uint32"},{"internalType":"bytes","name":"depositorSignature","type":"bytes"}],"name":"fillRelayWithUpdatedFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getCurrentTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hubPool","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"l1Gas","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"l2Eth","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"messenger","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"numberOfDeposits","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"relayFills","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"relayerRefundRoot","type":"bytes32"},{"internalType":"bytes32","name":"slowRelayRoot","type":"bytes32"}],"name":"relayRootBundle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"rootBundles","outputs":[{"internalType":"bytes32","name":"slowRelayRoot","type":"bytes32"},{"internalType":"bytes32","name":"relayerRefundRoot","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newCrossDomainAdmin","type":"address"}],"name":"setCrossDomainAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"time","type":"uint256"}],"name":"setCurrentTime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"newDepositQuoteTimeBuffer","type":"uint32"}],"name":"setDepositQuoteTimeBuffer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"originToken","type":"address"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"internalType":"bool","name":"enabled","type":"bool"}],"name":"setEnableRoute","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newHubPool","type":"address"}],"name":"setHubPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"newl1Gas","type":"uint32"}],"name":"setL1GasLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"l2Token","type":"address"},{"internalType":"address","name":"tokenBridge","type":"address"}],"name":"setTokenBridge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"depositor","type":"address"},{"internalType":"uint64","name":"newRelayerFeePct","type":"uint64"},{"internalType":"uint32","name":"depositId","type":"uint32"},{"internalType":"bytes","name":"depositorSignature","type":"bytes"}],"name":"speedUpDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"timerAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenBridges","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"wrappedNativeToken","outputs":[{"internalType":"contract WETH9","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

60c060405260038054604b60a31b63ffffffff60a01b199091161790556007805463ffffffff1916624c4b401790553480156200003b57600080fd5b5060405162004c9738038062004c978339810160408190526200005e9162000277565b600080546001600160a01b031916734200000000000000000000000000000000000007179055600180546001600160a81b0319166001600160a01b03831617600160a01b179055828273420000000000000000000000000000000000000673deaddeaddeaddeaddeaddeaddeaddeaddead00008484848383620000e18462000112565b620000ec83620001b8565b506001600160a01b039081166080529490941660a05250620002c1975050505050505050565b6001600160a01b0381166200016e5760405162461bcd60e51b815260206004820152601960248201527f4261642062726964676520726f7574657220616464726573730000000000000060448201526064015b60405180910390fd5b600280546001600160a01b0319166001600160a01b0383169081179091556040517fa9e8c42c9e7fca7f62755189a16b2f5314d43d8fb24e91ba54e6d65f9314e84990600090a250565b6001600160a01b038116620002105760405162461bcd60e51b815260206004820152601460248201527f4261642068756220706f6f6c2061646472657373000000000000000000000000604482015260640162000165565b600380546001600160a01b0319166001600160a01b0383169081179091556040517f1f17a88f67b0f49060a34bec1a4723a563620e6aa265eb640b5046dcee0759a090600090a250565b80516001600160a01b03811681146200027257600080fd5b919050565b6000806000606084860312156200028d57600080fd5b62000298846200025a565b9250620002a8602085016200025a565b9150620002b8604085016200025a565b90509250925092565b60805160a05161496a6200032d600039600081816106250152612dd201526000818161021c0152818161080001528181610ee801528181610fb10152818161168601528181611e330152818161269b01528181612cd9015281816131420152613198015261496a6000f3fe6080604052600436106101dc5760003560e01c8063766e070311610102578063de7eba7811610095578063ee2a53f811610064578063ee2a53f814610647578063f06850f61461067c578063fbbba9ac146106a9578063ffc351a3146106c957600080fd5b8063de7eba78146105a6578063e1904402146105c6578063e282d5b9146105f3578063e32292111461061357600080fd5b8063a1244c67116100d1578063a1244c67146104ea578063ac9650d814610523578063b27a430014610543578063be3576ee1461058657600080fd5b8063766e07031461047a57806389a153cc146104975780638a7860ce146104b75780639a8a0592146104d757600080fd5b80632752042e1161017a578063493a4f8411610149578063493a4f84146103985780635249fef1146103b85780635285e0581461040357806357f6dcb81461043057600080fd5b80632752042e1461031557806329cb924d146103355780633cb747bf14610358578063492289781461038557600080fd5b80631c39c38d116101b65780631c39c38d146102885780631dfb2d02146102b557806322f8e566146102d5578063272751c7146102f557600080fd5b80630eaac9f0146101e857806317fcb39b1461020a5780631b3d55591461026857600080fd5b366101e357005b600080fd5b3480156101f457600080fd5b50610208610203366004613a20565b6106e9565b005b34801561021657600080fd5b5061023e7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b34801561027457600080fd5b50610208610283366004613c02565b6107c9565b34801561029457600080fd5b5060015461023e9073ffffffffffffffffffffffffffffffffffffffff1681565b3480156102c157600080fd5b506102086102d0366004613cfe565b6108b1565b3480156102e157600080fd5b506102086102f0366004613d1b565b61093b565b34801561030157600080fd5b50610208610310366004613d42565b6109e4565b34801561032157600080fd5b50610208610330366004613a20565b610af6565b34801561034157600080fd5b5061034a610bf7565b60405190815260200161025f565b34801561036457600080fd5b5060005461023e9073ffffffffffffffffffffffffffffffffffffffff1681565b610208610393366004613d9c565b610cb3565b3480156103a457600080fd5b506102086103b3366004613e06565b61112a565b3480156103c457600080fd5b506103f36103d3366004613e28565b600560209081526000928352604080842090915290825290205460ff1681565b604051901515815260200161025f565b34801561040f57600080fd5b5060025461023e9073ffffffffffffffffffffffffffffffffffffffff1681565b34801561043c57600080fd5b506003546104659074010000000000000000000000000000000000000000900463ffffffff1681565b60405163ffffffff909116815260200161025f565b34801561048657600080fd5b506007546104659063ffffffff1681565b3480156104a357600080fd5b506102086104b2366004613e54565b611245565b3480156104c357600080fd5b506102086104d2366004613d1b565b6113a1565b3480156104e357600080fd5b504661034a565b3480156104f657600080fd5b50600354610465907801000000000000000000000000000000000000000000000000900463ffffffff1681565b610536610531366004613ef8565b611475565b60405161025f9190613fe3565b34801561054f57600080fd5b5061023e61055e366004613cfe565b60086020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b34801561059257600080fd5b506102086105a1366004614063565b61164f565b3480156105b257600080fd5b506102086105c1366004613cfe565b611736565b3480156105d257600080fd5b5060035461023e9073ffffffffffffffffffffffffffffffffffffffff1681565b3480156105ff57600080fd5b5061020861060e3660046141c7565b61177c565b34801561061f57600080fd5b5061023e7f000000000000000000000000000000000000000000000000000000000000000081565b34801561065357600080fd5b50610667610662366004613d1b565b6118da565b6040805192835260208301919091520161025f565b34801561068857600080fd5b5061034a610697366004613d1b565b60066020526000908152604090205481565b3480156106b557600080fd5b506102086106c4366004614238565b611908565b3480156106d557600080fd5b506102086106e4366004614271565b611a01565b6106f1611b6c565b6106f9611da5565b610726600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff169055565b600780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000001663ffffffff83169081179091556040517fe486a5c4bd7b36eabbfe274c99b39130277417be8d2209b4dae04c4fba64ee3a90600090a26107c6600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055565b50565b6107d1611da5565b6107fe600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff169055565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16826080015173ffffffffffffffffffffffffffffffffffffffff160361085d5761085d611e2b565b610868838383611e99565b6108ac600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055565b505050565b6108b9611b6c565b6108c1611da5565b6108ee600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff169055565b6108f781612245565b6107c6600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055565b60015473ffffffffffffffffffffffffffffffffffffffff1661095d57600080fd5b6001546040517f22f8e5660000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff909116906322f8e56690602401600060405180830381600087803b1580156109c957600080fd5b505af11580156109dd573d6000803e3d6000fd5b5050505050565b6109ec611b6c565b6109f4611da5565b610a21600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff169055565b73ffffffffffffffffffffffffffffffffffffffff8316600081815260056020908152604080832086845282529182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001685151590811790915591519182528492917f0a21fdd43d0ad0c62689ee7230a47309a050755bcc52eba00310add65297692a910160405180910390a36108ac600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055565b610afe611b6c565b610b06611da5565b610b33600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff169055565b600380547fffffffffffffffff00000000ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000063ffffffff8416908102919091179091556040519081527f0e55dd180fa793d9036c804d0a116e6a7617a48e72cee1f83d92793a793fcc039060200160405180910390a16107c6600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055565b60015460009073ffffffffffffffffffffffffffffffffffffffff1615610cae57600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166329cb924d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ca9919061434f565b905090565b504290565b610cbb611da5565b610ce8600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff169055565b73ffffffffffffffffffffffffffffffffffffffff8516600090815260056020908152604080832086845290915290205460ff16610d87576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f44697361626c656420726f75746500000000000000000000000000000000000060448201526064015b60405180910390fd5b6706f05b59d3b200008267ffffffffffffffff1610610e02576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f696e76616c69642072656c6179657220666565000000000000000000000000006044820152606401610d7e565b600354610e2d9074010000000000000000000000000000000000000000900463ffffffff1682614397565b63ffffffff16610e3b610bf7565b10158015610e805750600354610e6f9074010000000000000000000000000000000000000000900463ffffffff16826143bc565b63ffffffff16610e7d610bf7565b11155b610ee6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f696e76616c69642071756f74652074696d6500000000000000000000000000006044820152606401610d7e565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16148015610f415750600034115b1561103557833414610faf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f6d73672e76616c7565206d757374206d6174636820616d6f756e7400000000006044820152606401610d7e565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561101757600080fd5b505af115801561102b573d6000803e3d6000fd5b5050505050611057565b61105773ffffffffffffffffffffffffffffffffffffffff8616333087612331565b61108e8446600354869086907801000000000000000000000000000000000000000000000000900463ffffffff16868b8d3361240d565b600380546018906110c0907801000000000000000000000000000000000000000000000000900463ffffffff166143e4565b91906101000a81548163ffffffff021916908363ffffffff160217905550611122600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055565b505050505050565b611132611b6c565b61113a611da5565b611167600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff169055565b600480546001810182556000918252600381027f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19c81018590557f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b01838155604051919290918491869163ffffffff8616917fc86ba04c55bc5eb2f2876b91c438849a296dbec7b08751c3074d92e04f0a77af91a45050611241600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055565b5050565b61124d611da5565b61127a600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff169055565b60006040518061012001604052808c73ffffffffffffffffffffffffffffffffffffffff1681526020018b73ffffffffffffffffffffffffffffffffffffffff1681526020018a73ffffffffffffffffffffffffffffffffffffffff1681526020018981526020018681526020016112ef4690565b81526020018567ffffffffffffffff1681526020018467ffffffffffffffff1681526020018363ffffffff168152509050600061132b8261249e565b9050600061133d82848b8860006124ce565b905061134e82828a8887600061277b565b505050611395600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055565b50505050505050505050565b6113a9611b6c565b6113b1611da5565b6113de600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff169055565b600481815481106113f1576113f1614407565b60009182526020822060039091020181815560010181905560405182917f3569b846531b754c99cb80df3f49cd72fa6fe106aaee5ab8e0caf35a9d7ce88d91a26107c6600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055565b606034156114df576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f4f6e6c79206d756c746963616c6c207769746820302076616c756500000000006044820152606401610d7e565b8167ffffffffffffffff8111156114f8576114f8613a3b565b60405190808252806020026020018201604052801561152b57816020015b60608152602001906001900390816115165790505b50905060005b82811015611648576000803086868581811061154f5761154f614407565b90506020028101906115619190614436565b60405161156f92919061449b565b600060405180830381855af49150503d80600081146115aa576040519150601f19603f3d011682016040523d82523d6000602084013e6115af565b606091505b509150915081611615576044815110156115c857600080fd5b600481019050808060200190518101906115e291906144ab565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d7e9190614519565b8084848151811061162857611628614407565b6020026020010181905250505080806116409061452c565b915050611531565b5092915050565b611657611da5565b611684600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff169055565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff16036116df576116df611e2b565b6116f28a8a8a8a8a468b8b8b8b8b6128bd565b611395600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055565b61173e611b6c565b611746611da5565b611773600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff169055565b6108f781612a3c565b611784611da5565b6117b1600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff169055565b6706f05b59d3b200008367ffffffffffffffff161061182c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f696e76616c69642072656c6179657220666565000000000000000000000000006044820152606401610d7e565b6118398446858585612b28565b8373ffffffffffffffffffffffffffffffffffffffff168263ffffffff167fb9de16bf376724405019a10ef4fedac57fecd292bf86c08d81d7c42d394d5d378584604051611888929190614564565b60405180910390a36118d4600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055565b50505050565b600481815481106118ea57600080fd5b60009182526020909120600390910201805460019091015490915082565b611910611b6c565b611918611da5565b611945600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff169055565b73ffffffffffffffffffffffffffffffffffffffff82811660008181526008602052604080822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169486169485179055517ff3dc137d2246f9b8abd0bb821e185ba01122c9b3ea3745ffca6208037674d6709190a3611241600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055565b611a09611da5565b611a36600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff169055565b611a438c87858585612b28565b60006040518061012001604052808e73ffffffffffffffffffffffffffffffffffffffff1681526020018d73ffffffffffffffffffffffffffffffffffffffff1681526020018c73ffffffffffffffffffffffffffffffffffffffff1681526020018b8152602001888152602001611ab84690565b81526020018767ffffffffffffffff1681526020018667ffffffffffffffff1681526020018463ffffffff1681525090506000611af48261249e565b90506000611b0682848d8960006124ce565b9050611b1782828c8987600061277b565b505050611b5e600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055565b505050505050505050505050565b60025473ffffffffffffffffffffffffffffffffffffffff16611ba460005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611c5e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f4f564d5f58434841494e3a206d657373656e67657220636f6e7472616374207560448201527f6e61757468656e746963617465640000000000000000000000000000000000006064820152608401610d7e565b8073ffffffffffffffffffffffffffffffffffffffff16611c9460005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff16636e296e456040518163ffffffff1660e01b8152600401602060405180830381865afa158015611cde573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d029190614587565b73ffffffffffffffffffffffffffffffffffffffff16146107c6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f4f564d5f58434841494e3a2077726f6e672073656e646572206f662063726f7360448201527f732d646f6d61696e206d657373616765000000000000000000000000000000006064820152608401610d7e565b60015474010000000000000000000000000000000000000000900460ff16611e29576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610d7e565b565b4715611e29577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d0e30db0476040518263ffffffff1660e01b81526004016000604051808303818588803b1580156109c957600080fd5b46826020015114611f06576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f496e76616c696420636861696e496400000000000000000000000000000000006044820152606401610d7e565b8160400151518260a001515114611f79576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f696e76616c6964206c65616600000000000000000000000000000000000000006044820152606401610d7e565b600060048463ffffffff1681548110611f9457611f94614407565b90600052602060002090600302019050611fb381600101548484612bc5565b612019576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600960248201527f4261642050726f6f6600000000000000000000000000000000000000000000006044820152606401610d7e565b61203081600201846060015163ffffffff16612c02565b15612097576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f416c726561647920636c61696d656400000000000000000000000000000000006044820152606401610d7e565b6120ae81600201846060015163ffffffff16612c43565b60408301515160005b8181101561213f576000856040015182815181106120d7576120d7614407565b602002602001015190506000811115612136576121368660a00151838151811061210357612103614407565b602002602001015182886080015173ffffffffffffffffffffffffffffffffffffffff16612c819092919063ffffffff16565b506001016120b7565b508351156121d85761215084612cd7565b836080015173ffffffffffffffffffffffffffffffffffffffff16846060015163ffffffff1685602001517f828fc203220356df8f072a91681caee7d5c75095e2a95e80ed5a14b384697f718760000151336040516121cf92919091825273ffffffffffffffffffffffffffffffffffffffff16602082015260400190565b60405180910390a45b836060015163ffffffff168563ffffffff1685602001517ff8bd640004bcec1b89657020f561d0b070cbdf662d0b158db9dccb0a8301bfab8760000151886040015189608001518a60a0015133604051612236959493929190614625565b60405180910390a45050505050565b73ffffffffffffffffffffffffffffffffffffffff81166122c2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f4261642068756220706f6f6c20616464726573730000000000000000000000006044820152606401610d7e565b600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040517f1f17a88f67b0f49060a34bec1a4723a563620e6aa265eb640b5046dcee0759a090600090a250565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526118d49085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152612f9c565b604080518a8152602081018a905290810188905267ffffffffffffffff8716606082015263ffffffff858116608083015273ffffffffffffffffffffffffffffffffffffffff84811660a084015280841692908616918816907f4a4fc49abd237bfd7f4ac82d6c7a284c69daaea5154430cff04ad7482c6c42549060c00160405180910390a4505050505050505050565b6000816040516020016124b19190614683565b604051602081830303815290604052805190602001209050919050565b60006706f05b59d3b200008367ffffffffffffffff1610801561250657506706f05b59d3b200008560c0015167ffffffffffffffff16105b61256c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f696e76616c6964206665657300000000000000000000000000000000000000006044820152606401610d7e565b6060850151600087815260066020526040902054106125e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f72656c61792066696c6c656400000000000000000000000000000000000000006044820152606401610d7e565b836000036125f757506000612772565b61261084848760c0015161260b919061472a565b6130a8565b60008781526006602052604081205460608801519293508692612633919061474d565b90508281101561265c5780925061265983868960c00151612654919061472a565b6130e2565b91505b6000888152600660205260408120805485929061267a908490614764565b9091555050604087015173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000811691160361270257836126ef5760408701516126ef9073ffffffffffffffffffffffffffffffffffffffff16333085612331565b6126fd87602001518361310b565b61276f565b8361273c576126fd338860200151848a6040015173ffffffffffffffffffffffffffffffffffffffff16612331909392919063ffffffff16565b61276f876020015183896040015173ffffffffffffffffffffffffffffffffffffffff16612c819092919063ffffffff16565b50505b95945050505050565b816000015173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f56450a30040c51955338a4a9fbafcf94f7ca4b75f4cd83c2f5e29ef77fbe0a3a8460600151600660008b815260200190815260200160002054898988608001518960a001518a60e001518c8c60c001518d61010001518e604001518f602001518f6040516128ad9d9c9b9a999897969594939291909c8d5260208d019b909b5260408c019990995260608b019790975260808a019590955260a089019390935267ffffffffffffffff91821660c0890152811660e08801521661010086015263ffffffff1661012085015273ffffffffffffffffffffffffffffffffffffffff9081166101408501521661016083015215156101808201526101a00190565b60405180910390a3505050505050565b60006040518061012001604052808d73ffffffffffffffffffffffffffffffffffffffff1681526020018c73ffffffffffffffffffffffffffffffffffffffff1681526020018b73ffffffffffffffffffffffffffffffffffffffff1681526020018a81526020018981526020018881526020018767ffffffffffffffff1681526020018667ffffffffffffffff1681526020018563ffffffff16815250905061299260048463ffffffff168154811061297957612979614407565b906000526020600020906003020160000154828461324c565b6129f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600d60248201527f496e76616c69642070726f6f66000000000000000000000000000000000000006044820152606401610d7e565b6000612a038261249e565b90506000612a1a82848560600151600060016124ce565b9050612a2c828260008087600161277b565b5050505050505050505050505050565b73ffffffffffffffffffffffffffffffffffffffff8116612ab9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4261642062726964676520726f757465722061646472657373000000000000006044820152606401610d7e565b600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040517fa9e8c42c9e7fca7f62755189a16b2f5314d43d8fb24e91ba54e6d65f9314e84990600090a250565b60408051608060208201819052601160a08301527f4143524f53532d56322d4645452d312e3000000000000000000000000000000060c083015267ffffffffffffffff86169282019290925263ffffffff8416606082015290810185905260009060e0016040516020818303038152906040528051906020012090506000612baf82613264565b9050612bbc87828561329f565b50505050505050565b6000612bf8828585604051602001612bdd919061477c565b6040516020818303038152906040528051906020012061333d565b90505b9392505050565b600080612c1161010084614846565b90506000612c216101008561485a565b6000928352602095909552506040902054600190931b92831690921492915050565b6000612c5161010083614846565b90506000612c616101008461485a565b600092835260209490945250604090208054600190931b90921790915550565b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526108ac9084907fa9059cbb000000000000000000000000000000000000000000000000000000009060640161238b565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16816080015173ffffffffffffffffffffffffffffffffffffffff1603612df957608081015181516040517f2e1a7d4d00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90921691632e1a7d4d91612d8a9160040190815260200190565b600060405180830381600087803b158015612da457600080fd5b505af1158015612db8573d6000803e3d6000fd5b50505073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000166080830152505b608081015173ffffffffffffffffffffffffffffffffffffffff9081166000908152600860205260409020541615612e5d57608081015173ffffffffffffffffffffffffffffffffffffffff90811660009081526008602052604090205416612e73565b7342000000000000000000000000000000000000105b608082015160035483516007546040517fa3a7954800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff94851660048201529284166024840152604483019190915263ffffffff16606482015260a06084820152600060a482015291169063a3a795489060c401600060405180830381600087803b158015612f1257600080fd5b505af1158015612f26573d6000803e3d6000fd5b50505050608081015160035482516007546040805173ffffffffffffffffffffffffffffffffffffffff9485168152602081019390935263ffffffff909116908201529116907f46b77e3c29797b94890fd3438da74f697480742358a3e26b9d13a227f1ac0ac99060600160405180910390a250565b6000612ffe826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166133539092919063ffffffff16565b8051909150156108ac578080602001905181019061301c919061486e565b6108ac576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610d7e565b60006130bc82670de0b6b3a764000061488b565b67ffffffffffffffff166130d884670de0b6b3a76400006148ac565b612bfb9190614846565b6000670de0b6b3a76400006130f7838261488b565b6130d89067ffffffffffffffff16856148ac565b73ffffffffffffffffffffffffffffffffffffffff82163b156131695761124173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168383612c81565b6040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018290527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1690632e1a7d4d90602401600060405180830381600087803b1580156131f157600080fd5b505af1158015613205573d6000803e3d6000fd5b505060405173ffffffffffffffffffffffffffffffffffffffff8516925083156108fc02915083906000818181858888f193505050501580156108ac573d6000803e3d6000fd5b6000612bf8828585604051602001612bdd9190614683565b6040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c016124b1565b6132a98282613362565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146108ac576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f696e76616c6964207369676e61747572650000000000000000000000000000006044820152606401610d7e565b60008261334a8584613386565b14949350505050565b6060612bf884846000856133f2565b60008060006133718585613588565b9150915061337e816135f6565b509392505050565b600081815b845181101561337e5760008582815181106133a8576133a8614407565b602002602001015190508083116133ce57600083815260208290526040902092506133df565b600081815260208490526040902092505b50806133ea8161452c565b91505061338b565b606082471015613484576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610d7e565b73ffffffffffffffffffffffffffffffffffffffff85163b613502576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610d7e565b6000808673ffffffffffffffffffffffffffffffffffffffff16858760405161352b91906148e9565b60006040518083038185875af1925050503d8060008114613568576040519150601f19603f3d011682016040523d82523d6000602084013e61356d565b606091505b509150915061357d82828661384a565b979650505050505050565b60008082516041036135be5760208301516040840151606085015160001a6135b28782858561389d565b945094505050506135ef565b82516040036135e757602083015160408401516135dc8683836139b5565b9350935050506135ef565b506000905060025b9250929050565b600081600481111561360a5761360a614905565b036136125750565b600181600481111561362657613626614905565b0361368d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610d7e565b60028160048111156136a1576136a1614905565b03613708576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610d7e565b600381600481111561371c5761371c614905565b036137a9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152608401610d7e565b60048160048111156137bd576137bd614905565b036107c6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152608401610d7e565b60608315613859575081612bfb565b8251156138695782518084602001fd5b816040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d7e9190614519565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156138d457506000905060036139ac565b8460ff16601b141580156138ec57508460ff16601c14155b156138fd57506000905060046139ac565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015613951573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff81166139a5576000600192509250506139ac565b9150600090505b94509492505050565b6000807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8316816139eb60ff86901c601b614764565b90506139f98782888561389d565b935093505050935093915050565b803563ffffffff81168114613a1b57600080fd5b919050565b600060208284031215613a3257600080fd5b612bfb82613a07565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405160c0810167ffffffffffffffff81118282101715613a8d57613a8d613a3b565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715613ada57613ada613a3b565b604052919050565b600067ffffffffffffffff821115613afc57613afc613a3b565b5060051b60200190565b600082601f830112613b1757600080fd5b81356020613b2c613b2783613ae2565b613a93565b82815260059290921b84018101918181019086841115613b4b57600080fd5b8286015b84811015613b665780358352918301918301613b4f565b509695505050505050565b73ffffffffffffffffffffffffffffffffffffffff811681146107c657600080fd5b8035613a1b81613b71565b600082601f830112613baf57600080fd5b81356020613bbf613b2783613ae2565b82815260059290921b84018101918181019086841115613bde57600080fd5b8286015b84811015613b66578035613bf581613b71565b8352918301918301613be2565b600080600060608486031215613c1757600080fd5b613c2084613a07565b9250602084013567ffffffffffffffff80821115613c3d57600080fd5b9085019060c08288031215613c5157600080fd5b613c59613a6a565b8235815260208301356020820152604083013582811115613c7957600080fd5b613c8589828601613b06565b604083015250613c9760608401613a07565b6060820152613ca860808401613b93565b608082015260a083013582811115613cbf57600080fd5b613ccb89828601613b9e565b60a08301525093506040860135915080821115613ce757600080fd5b50613cf486828701613b06565b9150509250925092565b600060208284031215613d1057600080fd5b8135612bfb81613b71565b600060208284031215613d2d57600080fd5b5035919050565b80151581146107c657600080fd5b600080600060608486031215613d5757600080fd5b8335613d6281613b71565b9250602084013591506040840135613d7981613d34565b809150509250925092565b803567ffffffffffffffff81168114613a1b57600080fd5b60008060008060008060c08789031215613db557600080fd5b8635613dc081613b71565b95506020870135613dd081613b71565b94506040870135935060608701359250613dec60808801613d84565b9150613dfa60a08801613a07565b90509295509295509295565b60008060408385031215613e1957600080fd5b50508035926020909101359150565b60008060408385031215613e3b57600080fd5b8235613e4681613b71565b946020939093013593505050565b6000806000806000806000806000806101408b8d031215613e7457600080fd5b8a35613e7f81613b71565b995060208b0135613e8f81613b71565b985060408b0135613e9f81613b71565b975060608b0135965060808b0135955060a08b0135945060c08b01359350613ec960e08c01613d84565b9250613ed86101008c01613d84565b9150613ee76101208c01613a07565b90509295989b9194979a5092959850565b60008060208385031215613f0b57600080fd5b823567ffffffffffffffff80821115613f2357600080fd5b818501915085601f830112613f3757600080fd5b813581811115613f4657600080fd5b8660208260051b8501011115613f5b57600080fd5b60209290920196919550909350505050565b60005b83811015613f88578181015183820152602001613f70565b838111156118d45750506000910152565b60008151808452613fb1816020860160208601613f6d565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015614056577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0888603018452614044858351613f99565b9450928501929085019060010161400a565b5092979650505050505050565b6000806000806000806000806000806101408b8d03121561408357600080fd5b8a3561408e81613b71565b995060208b013561409e81613b71565b985060408b01356140ae81613b71565b975060608b0135965060808b013595506140ca60a08c01613d84565b94506140d860c08c01613d84565b93506140e660e08c01613a07565b92506140f56101008c01613a07565b91506101208b013567ffffffffffffffff81111561411257600080fd5b61411e8d828e01613b06565b9150509295989b9194979a5092959850565b600067ffffffffffffffff82111561414a5761414a613a3b565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f83011261418757600080fd5b8135614195613b2782614130565b8181528460208386010111156141aa57600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080608085870312156141dd57600080fd5b84356141e881613b71565b93506141f660208601613d84565b925061420460408601613a07565b9150606085013567ffffffffffffffff81111561422057600080fd5b61422c87828801614176565b91505092959194509250565b6000806040838503121561424b57600080fd5b823561425681613b71565b9150602083013561426681613b71565b809150509250929050565b6000806000806000806000806000806000806101808d8f03121561429457600080fd5b61429d8d613b93565b9b506142ab60208e01613b93565b9a506142b960408e01613b93565b995060608d0135985060808d0135975060a08d0135965060c08d013595506142e360e08e01613d84565b94506142f26101008e01613d84565b93506143016101208e01613d84565b92506143106101408e01613a07565b915067ffffffffffffffff6101608e0135111561432c57600080fd5b61433d8e6101608f01358f01614176565b90509295989b509295989b509295989b565b60006020828403121561436157600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600063ffffffff838116908316818110156143b4576143b4614368565b039392505050565b600063ffffffff8083168185168083038211156143db576143db614368565b01949350505050565b600063ffffffff8083168181036143fd576143fd614368565b6001019392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261446b57600080fd5b83018035915067ffffffffffffffff82111561448657600080fd5b6020019150368190038213156135ef57600080fd5b8183823760009101908152919050565b6000602082840312156144bd57600080fd5b815167ffffffffffffffff8111156144d457600080fd5b8201601f810184136144e557600080fd5b80516144f3613b2782614130565b81815285602083850101111561450857600080fd5b612772826020830160208601613f6d565b602081526000612bfb6020830184613f99565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361455d5761455d614368565b5060010190565b67ffffffffffffffff83168152604060208201526000612bf86040830184613f99565b60006020828403121561459957600080fd5b8151612bfb81613b71565b600081518084526020808501945080840160005b838110156145d4578151875295820195908201906001016145b8565b509495945050505050565b600081518084526020808501945080840160005b838110156145d457815173ffffffffffffffffffffffffffffffffffffffff16875295820195908201906001016145f3565b85815260a06020820152600061463e60a08301876145a4565b73ffffffffffffffffffffffffffffffffffffffff8087166040850152838203606085015261466d82876145df565b9250808516608085015250509695505050505050565b815173ffffffffffffffffffffffffffffffffffffffff90811682526020808401518216908301526040808401519182169083015261012082019050606083015160608301526080830151608083015260a083015160a083015260c08301516146f860c084018267ffffffffffffffff169052565b5060e083015161471460e084018267ffffffffffffffff169052565b506101009283015163ffffffff16919092015290565b600067ffffffffffffffff8083168185168083038211156143db576143db614368565b60008282101561475f5761475f614368565b500390565b6000821982111561477757614777614368565b500190565b6020815281516020820152602082015160408201526000604083015160c060608401526147ac60e08401826145a4565b905063ffffffff606085015116608084015273ffffffffffffffffffffffffffffffffffffffff60808501511660a084015260a08401517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08483030160c085015261277282826145df565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60008261485557614855614817565b500490565b60008261486957614869614817565b500690565b60006020828403121561488057600080fd5b8151612bfb81613d34565b600067ffffffffffffffff838116908316818110156143b4576143b4614368565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156148e4576148e4614368565b500290565b600082516148fb818460208701613f6d565b9190910192915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fdfea2646970667358221220eb7c71015621a3f0e8435e96b853ec4cb7e61d884a87ee1833c41a0d61e5854664736f6c634300080d0033000000000000000000000000c186fa914353c44b2e33ebe05f21846f1048beda000000000000000000000000c186fa914353c44b2e33ebe05f21846f1048beda0000000000000000000000000000000000000000000000000000000000000000

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

000000000000000000000000c186fa914353c44b2e33ebe05f21846f1048beda000000000000000000000000c186fa914353c44b2e33ebe05f21846f1048beda0000000000000000000000000000000000000000000000000000000000000000

-----Decoded View---------------
Arg [0] : _crossDomainAdmin (address): 0xc186fa914353c44b2e33ebe05f21846f1048beda
Arg [1] : _hubPool (address): 0xc186fa914353c44b2e33ebe05f21846f1048beda
Arg [2] : timerAddress (address): 0x0000000000000000000000000000000000000000

-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 000000000000000000000000c186fa914353c44b2e33ebe05f21846f1048beda
Arg [1] : 000000000000000000000000c186fa914353c44b2e33ebe05f21846f1048beda
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000000


Deployed ByteCode Sourcemap

210:678:34:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2430:139:41;;;;;;;;;;-1:-1:-1;2430:139:41;;;;;:::i;:::-;;:::i;:::-;;2098:41:44;;;;;;;;;;;;;;;;;;562:42:60;550:55;;;532:74;;520:2;505:18;2098:41:44;;;;;;;;4464:401:41;;;;;;;;;;-1:-1:-1;4464:401:41;;;;;:::i;:::-;;:::i;391:27:22:-;;;;;;;;;;-1:-1:-1;391:27:22;;;;;;;;7074:121:44;;;;;;;;;;-1:-1:-1;7074:121:44;;;;;:::i;:::-;;:::i;1097:115:22:-;;;;;;;;;;-1:-1:-1;1097:115:22;;;;;:::i;:::-;;:::i;7566:319:44:-;;;;;;;;;;-1:-1:-1;7566:319:44;;;;;:::i;:::-;;:::i;8090:245::-;;;;;;;;;;-1:-1:-1;8090:245:44;;;;;:::i;:::-;;:::i;1457:276:22:-;;;;;;;;;;;;;:::i;:::-;;;6186:25:60;;;6174:2;6159:18;1457:276:22;6040:177:60;500:24:3;;;;;;;;;;-1:-1:-1;500:24:3;;;;;;;;11438:2725:44;;;;;;:::i;:::-;;:::i;9006:433::-;;;;;;;;;;-1:-1:-1;9006:433:44;;;;;:::i;:::-;;:::i;2785:72::-;;;;;;;;;;-1:-1:-1;2785:72:44;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;7908:14:60;;7901:22;7883:41;;7871:2;7856:18;2785:72:44;7743:187:60;1649:31:44;;;;;;;;;;-1:-1:-1;1649:31:44;;;;;;;;2352:42;;;;;;;;;;-1:-1:-1;2352:42:44;;;;;;;;;;;;;;8208:10:60;8196:23;;;8178:42;;8166:2;8151:18;2352:42:44;8034:192:60;849:31:41;;;;;;;;;;-1:-1:-1;849:31:41;;;;;;;;18440:1438:44;;;;;;;;;;-1:-1:-1;18440:1438:44;;;;;:::i;:::-;;:::i;9813:202::-;;;;;;;;;;-1:-1:-1;9813:202:44;;;;;:::i;:::-;;:::i;26228:105::-;;;;;;;;;;-1:-1:-1;26312:13:44;26228:105;;2499:30;;;;;;;;;;-1:-1:-1;2499:30:44;;;;;;;;;;;528:710:20;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;1186:47:41:-;;;;;;;;;;-1:-1:-1;1186:47:41;;;;;:::i;:::-;;;;;;;;;;;;;;;;3412:818;;;;;;;;;;-1:-1:-1;3412:818:41;;;;;:::i;:::-;;:::i;6783:157:44:-;;;;;;;;;;-1:-1:-1;6783:157:44;;;;;:::i;:::-;;:::i;1836:22::-;;;;;;;;;;-1:-1:-1;1836:22:44;;;;;;;;15649:678;;;;;;;;;;-1:-1:-1;15649:678:44;;;;;:::i;:::-;;:::i;921:30:41:-;;;;;;;;;;;;;;;2631:31:44;;;;;;;;;;-1:-1:-1;2631:31:44;;;;;:::i;:::-;;:::i;:::-;;;;14036:25:60;;;14092:2;14077:18;;14070:34;;;;14009:18;2631:31:44;13862:248:60;3188:45:44;;;;;;;;;;-1:-1:-1;3188:45:44;;;;;:::i;:::-;;;;;;;;;;;;;;2840:200:41;;;;;;;;;;-1:-1:-1;2840:200:41;;;;;:::i;:::-;;:::i;21446:1383:44:-;;;;;;;;;;-1:-1:-1;21446:1383:44;;;;;:::i;:::-;;:::i;2430:139:41:-;6444:21:44;:19;:21::i;:::-;1567:19:37::1;:17;:19::i;:::-;1596:17;3259:11:::0;:19;;;;;;3149:136;1596:17:::1;2511:5:41::2;:16:::0;;;::::2;;::::0;::::2;::::0;;::::2;::::0;;;2543:18:::2;::::0;::::2;::::0;-1:-1:-1;;2543:18:41::2;1634:20:37::1;3486:4:::0;3472:18;;;;;;;;3291:206;1634:20:::1;2430:139:41::0;:::o;4464:401::-;1567:19:37;:17;:19::i;:::-;1596:17;3259:11;:19;;;;;;3149:136;1596:17;4739:18:41::1;4695:63;;:17;:32;;;:63;;::::0;4691:88:::1;;4760:19;:17;:19::i;:::-;4792:65;4818:12;4832:17;4851:5;4792:25;:65::i;:::-;1634:20:37::0;3486:4;3472:18;;;;;;;;3291:206;1634:20;4464:401:41;;;:::o;7074:121:44:-;6444:21;:19;:21::i;:::-;1567:19:37::1;:17;:19::i;:::-;1596:17;3259:11:::0;:19;;;;;;3149:136;1596:17:::1;7164:23:44::2;7176:10;7164:11;:23::i;:::-;1634:20:37::1;3486:4:::0;3472:18;;;;;;;;3291:206;1097:115:22;875:12;;:28;:12;867:37;;;;;;1171:12:::1;::::0;1165:40:::1;::::0;;;;::::1;::::0;::::1;6186:25:60::0;;;1171:12:22::1;::::0;;::::1;::::0;1165:34:::1;::::0;6159:18:60;;1165:40:22::1;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;1097:115:::0;:::o;7566:319:44:-;6444:21;:19;:21::i;:::-;1567:19:37::1;:17;:19::i;:::-;1596:17;3259:11:::0;:19;;;;;;3149:136;1596:17:::1;7737:33:44::2;::::0;::::2;;::::0;;;:20:::2;:33;::::0;;;;;;;:53;;;;;;;;;:63;;;::::2;::::0;::::2;;::::0;;::::2;::::0;;;7816:61;;7883:41:60;;;7737:53:44;;:33;7816:61:::2;::::0;7856:18:60;7816:61:44::2;;;;;;;1634:20:37::1;3486:4:::0;3472:18;;;;;;;;3291:206;8090:245:44;6444:21;:19;:21::i;:::-;1567:19:37::1;:17;:19::i;:::-;1596:17;3259:11:::0;:19;;;;;;3149:136;1596:17:::1;8209:22:44::2;:50:::0;;;::::2;::::0;::::2;::::0;::::2;::::0;;::::2;::::0;;;::::2;::::0;;;8275:52:::2;::::0;8178:42:60;;;8275:52:44::2;::::0;8166:2:60;8151:18;8275:52:44::2;;;;;;;1634:20:37::1;3486:4:::0;3472:18;;;;;;;;3291:206;1457:276:22;1535:12;;1512:7;;1535:28;:12;:28;1531:196;;1592:12;;;;;;;;;;;1586:34;;;:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;1579:43;;1457:276;:::o;1531:196::-;-1:-1:-1;1660:15:22;;1457:276::o;11438:2725:44:-;1567:19:37;:17;:19::i;:::-;1596:17;3259:11;:19;;;;;;3149:136;1596:17;11750:33:44::1;::::0;::::1;;::::0;;;:20:::1;:33;::::0;;;;;;;:53;;;;;;;;;::::1;;11742:80;;;::::0;::::1;::::0;;16202:2:60;11742:80:44::1;::::0;::::1;16184:21:60::0;16241:2;16221:18;;;16214:30;16280:16;16260:18;;;16253:44;16314:18;;11742:80:44::1;;;;;;;;;11949:6;11933:13;:22;;;11925:54;;;::::0;::::1;::::0;;16545:2:60;11925:54:44::1;::::0;::::1;16527:21:60::0;16584:2;16564:18;;;16557:30;16623:21;16603:18;;;16596:49;16662:18;;11925:54:44::1;16343:343:60::0;11925:54:44::1;12608:22;::::0;12591:39:::1;::::0;12608:22;;::::1;;;12591:14:::0;:39:::1;:::i;:::-;12571:59;;:16;:14;:16::i;:::-;:59;;:139;;;;-1:-1:-1::0;12688:22:44::1;::::0;12671:39:::1;::::0;12688:22;;::::1;;;12671:14:::0;:39:::1;:::i;:::-;12651:59;;:16;:14;:16::i;:::-;:59;;12571:139;12549:207;;;::::0;::::1;::::0;;17541:2:60;12549:207:44::1;::::0;::::1;17523:21:60::0;17580:2;17560:18;;;17553:30;17619:20;17599:18;;;17592:48;17657:18;;12549:207:44::1;17339:342:60::0;12549:207:44::1;13027:18;13004:42;;:11;:42;;;:59;;;;;13062:1;13050:9;:13;13004:59;13000:627;;;13101:6;13088:9;:19;13080:59;;;::::0;::::1;::::0;;17888:2:60;13080:59:44::1;::::0;::::1;17870:21:60::0;17927:2;17907:18;;;17900:30;17966:29;17946:18;;;17939:57;18013:18;;13080:59:44::1;17686:351:60::0;13080:59:44::1;13154:18;:26;;;13189:9;13154:48;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;13000:627;;;13556:71;:36;::::0;::::1;13593:10;13613:4;13620:6:::0;13556:36:::1;:71::i;:::-;13640:264;13667:6:::0;26312:13;13773:16:::1;::::0;13712:18;;13745:13;;13773:16;;::::1;;;13804:14:::0;13833:11;13859:9;13883:10:::1;13640:12;:264::i;:::-;14139:16;14137:18:::0;;14139:16:::1;::::0;14137:18:::1;::::0;;;::::1;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;1634:20:37::0;3486:4;3472:18;;;;;;;;3291:206;1634:20;11438:2725:44;;;;;;:::o;9006:433::-;6444:21;:19;:21::i;:::-;1567:19:37::1;:17;:19::i;:::-;1596:17;3259:11:::0;:19;;;;;;3149:136;1596:17:::1;9160:11:44::2;:18:::0;;9222::::2;::::0;::::2;::::0;;-1:-1:-1;9222:18:44;;;::::2;::::0;::::2;9251:28:::0;;;:48;;;9222:18;::::2;9310:40:::0;;;9366:65:::2;::::0;9160:18;;9222;;9310:40;;9251:48;;9366:65:::2;::::0;::::2;::::0;::::2;::::0;::::2;9120:319;;1634:20:37::1;3486:4:::0;3472:18;;;;;;;;3291:206;1634:20:::1;9006:433:44::0;;:::o;18440:1438::-;1567:19:37;:17;:19::i;:::-;1596:17;3259:11;:19;;;;;;3149:136;1596:17;19144:45:44::1;19192:403;;;;;;;;19247:9;19192:403;;;;;;19282:9;19192:403;;;;;;19324:16;19192:403;;;;;;19363:6;19192:403;;;;19526:13;19192:403;;;;19574:9;26312:13:::0;;26228:105;19574:9:::1;19192:403;;;;19402:16;19192:403;;;;;;19448:13;19192:403;;;;;;19487:9;19192:403;;;;::::0;19144:451:::1;;19606:17;19626:24;19640:9;19626:13;:24::i;:::-;19606:44;;19663:25;19691:71;19702:9;19713;19724:15;19741:13;19756:5;19691:10;:71::i;:::-;19663:99;;19775:95;19790:9;19801:17;19820:16;19838:13;19853:9;19864:5;19775:14;:95::i;:::-;18795:1083;;;1634:20:37::0;3486:4;3472:18;;;;;;;;3291:206;1634:20;18440:1438:44;;;;;;;;;;:::o;9813:202::-;6444:21;:19;:21::i;:::-;1567:19:37::1;:17;:19::i;:::-;1596:17;3259:11:::0;:19;;;;;;3149:136;1596:17:::1;9927:11:44::2;9939:12;9927:25;;;;;;;;:::i;:::-;;::::0;;;::::2;::::0;;::::2;::::0;;::::2;;9920:32:::0;;;::::2;;::::0;;;9968:39:::2;::::0;9994:12;;9968:39:::2;::::0;::::2;1634:20:37::1;3486:4:::0;3472:18;;;;;;;;3291:206;528:710:20;596:22;638:9;:14;630:54;;;;;;;18639:2:60;630:54:20;;;18621:21:60;18678:2;18658:18;;;18651:30;18717:29;18697:18;;;18690:57;18764:18;;630:54:20;18437:351:60;630:54:20;716:4;704:24;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;694:34;;743:9;738:494;758:15;;;738:494;;;795:12;;840:4;859;;864:1;859:7;;;;;;;:::i;:::-;;;;;;;;;;;;:::i;:::-;832:35;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;794:73;;;;887:7;882:306;;1014:2;998:6;:13;:18;994:32;;;1018:8;;;994:32;1097:4;1089:6;1085:17;1075:27;;1155:6;1144:28;;;;;;;;;;;;:::i;:::-;1137:36;;;;;;;;;;;:::i;882:306::-;1215:6;1202:7;1210:1;1202:10;;;;;;;;:::i;:::-;;;;;;:19;;;;780:452;;775:3;;;;;:::i;:::-;;;;738:494;;;;528:710;;;;:::o;3412:818:41:-;1567:19:37;:17;:19::i;:::-;1596:17;3259:11;:19;;;;;;3149:136;1596:17;3845:18:41::1;3817:47;;:16;:47;;::::0;3813:72:::1;;3866:19;:17;:19::i;:::-;3898:324;3934:9:::0;3958;3982:16;4013;4044:13;26312::44;4096:16:41::1;4127:13;4155:9;4179:12;4206:5;3898:21;:324::i;:::-;1634:20:37::0;3486:4;3472:18;;;;;;;;3291:206;6783:157:44;6444:21;:19;:21::i;:::-;1567:19:37::1;:17;:19::i;:::-;1596:17;3259:11:::0;:19;;;;;;3149:136;1596:17:::1;6891:41:44::2;6912:19;6891:20;:41::i;15649:678::-:0;1567:19:37;:17;:19::i;:::-;1596:17;3259:11;:19;;;;;;3149:136;1596:17;15878:6:44::1;15859:16;:25;;;15851:57;;;::::0;::::1;::::0;;16545:2:60;15851:57:44::1;::::0;::::1;16527:21:60::0;16584:2;16564:18;;;16557:30;16623:21;16603:18;;;16596:49;16662:18;;15851:57:44::1;16343:343:60::0;15851:57:44::1;15921:101;15952:9:::0;26312:13;15974:16:::1;15992:9;16003:18;15921:30;:101::i;:::-;16289:9;16236:83;;16278:9;16236:83;;;16260:16;16300:18;16236:83;;;;;;;:::i;:::-;;;;;;;;1634:20:37::0;3486:4;3472:18;;;;;;;;3291:206;1634:20;15649:678:44;;;;:::o;2631:31::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;2631:31:44;:::o;2840:200:41:-;6444:21:44;:19;:21::i;:::-;1567:19:37::1;:17;:19::i;:::-;1596:17;3259:11:::0;:19;;;;;;3149:136;1596:17:::1;2943:21:41::2;::::0;;::::2;;::::0;;;:12:::2;:21;::::0;;;;;:35;;;::::2;::::0;;::::2;::::0;;::::2;::::0;;2994:38;::::2;::::0;2943:21;2994:38:::2;1634:20:37::1;3486:4:::0;3472:18;;;;;;;;3291:206;21446:1383:44;1567:19:37;:17;:19::i;:::-;1596:17;3259:11;:19;;;;;;3149:136;1596:17;21911:105:44::1;21942:9;21953:13;21968:16;21986:9;21997:18;21911:30;:105::i;:::-;22129:26;22158:384;;;;;;;;22194:9;22158:384;;;;;;22229:9;22158:384;;;;;;22271:16;22158:384;;;;;;22310:6;22158:384;;;;22473:13;22158:384;;;;22521:9;26312:13:::0;;26228:105;22521:9:::1;22158:384;;;;22349:16;22158:384;;;;;;22395:13;22158:384;;;;;;22434:9;22158:384;;;;::::0;22129:413:::1;;22553:17;22573:24;22587:9;22573:13;:24::i;:::-;22553:44;;22608:25;22636:74;22647:9;22658;22669:15;22686:16;22704:5;22636:10;:74::i;:::-;22608:102;;22723:98;22738:9;22749:17;22768:16;22786;22804:9;22815:5;22723:14;:98::i;:::-;21900:929;;;1634:20:37::0;3486:4;3472:18;;;;;;;;3291:206;1634:20;21446:1383:44;;;;;;;;;;;;:::o;7073:96:41:-;7149:16;;;;1221:25:3;1898:21;1960:9;;;;1837:140;1221:25;1199:48;;:10;:48;;;1178:141;;;;;;;21343:2:60;1178:141:3;;;21325:21:60;21382:2;21362:18;;;21355:30;21421:34;21401:18;;;21394:62;21492:16;21472:18;;;21465:44;21526:19;;1178:141:3;21141:410:60;1178:141:3;1403:20;1351:72;;:25;1898:21;1960:9;;;;1837:140;1351:25;:46;;;:48;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;:72;;;1330:167;;;;;;;22014:2:60;1330:167:3;;;21996:21:60;22053:2;22033:18;;;22026:30;22092:34;22072:18;;;22065:62;22163:18;22143;;;22136:46;22199:19;;1330:167:3;21812:412:60;2957:186:37;3089:11;;;;;;;3081:55;;;;;;;22431:2:60;3081:55:37;;;22413:21:60;22470:2;22450:18;;;22443:30;22509:33;22489:18;;;22482:61;22560:18;;3081:55:37;22229:355:60;3081:55:37;2957:186::o;5381:148:41:-;5434:21;:25;5430:91;;5461:18;:26;;;5496:21;5461:60;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;26611:3076:44;26312:13;26863:17;:25;;;:38;26855:66;;;;;;;22791:2:60;26855:66:44;;;22773:21:60;22830:2;22810:18;;;22803:30;22869:17;22849:18;;;22842:45;22904:18;;26855:66:44;22589:339:60;26855:66:44;26984:17;:31;;;:38;26940:17;:33;;;:40;:82;26932:107;;;;;;;23135:2:60;26932:107:44;;;23117:21:60;23174:2;23154:18;;;23147:30;23213:14;23193:18;;;23186:42;23245:18;;26932:107:44;22933:336:60;26932:107:44;27052:29;27084:11;27096:12;27084:25;;;;;;;;;;:::i;:::-;;;;;;;;;;;27052:57;;27323:85;27353:10;:28;;;27383:17;27402:5;27323:29;:85::i;:::-;27315:107;;;;;;;23476:2:60;27315:107:44;;;23458:21:60;23515:1;23495:18;;;23488:29;23553:11;23533:18;;;23526:39;23582:18;;27315:107:44;23274:332:60;27315:107:44;27512:71;27532:10;:24;;27558:17;:24;;;27512:71;;:19;:71::i;:::-;27511:72;27503:100;;;;;;;23813:2:60;27503:100:44;;;23795:21:60;23852:2;23832:18;;;23825:30;23891:17;23871:18;;;23864:45;23926:18;;27503:100:44;23611:339:60;27503:100:44;27714:72;27735:10;:24;;27761:17;:24;;;27714:72;;:20;:72::i;:::-;28022:31;;;;:38;28005:14;28071:698;28095:6;28091:1;:10;28071:698;;;28120:14;28137:17;:31;;;28169:1;28137:34;;;;;;;;:::i;:::-;;;;;;;28120:51;;28199:1;28190:6;:10;28186:132;;;28219:99;28273:17;:33;;;28307:1;28273:36;;;;;;;;:::i;:::-;;;;;;;28311:6;28226:17;:32;;;28219:53;;;;:99;;;;;:::i;:::-;-1:-1:-1;28739:3:44;;28071:698;;;-1:-1:-1;28933:32:44;;:36;28929:378;;28986:41;29009:17;28986:22;:41::i;:::-;29219:17;:32;;;29049:246;;29176:17;:24;;;29049:246;;29132:17;:25;;;29049:246;29081:17;:32;;;29270:10;29049:246;;;;;;24129:25:60;;;24202:42;24190:55;24185:2;24170:18;;24163:83;24117:2;24102:18;;23955:297;29049:246:44;;;;;;;;28929:378;29524:17;:24;;;29324:355;;29497:12;29324:355;;29411:17;:25;;;29324:355;29364:17;:32;;;29451:17;:31;;;29563:17;:32;;;29610:17;:33;;;29658:10;29324:355;;;;;;;;;;:::i;:::-;;;;;;;;26797:2890;;26611:3076;;;:::o;31989:195::-;32058:24;;;32050:57;;;;;;;26153:2:60;32050:57:44;;;26135:21:60;26192:2;26172:18;;;26165:30;26231:22;26211:18;;;26204:50;26271:18;;32050:57:44;25951:344:60;32050:57:44;32118:7;:20;;;;;;;;;;;;;32154:22;;;;-1:-1:-1;;32154:22:44;31989:195;:::o;912:241:10:-;1077:68;;26512:42:60;26581:15;;;1077:68:10;;;26563:34:60;26633:15;;26613:18;;;26606:43;26665:18;;;26658:34;;;1050:96:10;;1070:5;;1100:27;;26475:18:60;;1077:68:10;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1050:19;:96::i;42060:594:44:-;42384:262;;;26986:25:60;;;27042:2;27027:18;;27020:34;;;27070:18;;;27063:34;;;27145:18;27133:31;;27128:2;27113:18;;27106:59;42384:262:44;27202:23:60;;;27196:3;27181:19;;27174:52;42384:262:44;27263:55:60;;;27257:3;27242:19;;27235:84;42384:262:44;;;;;;;;;;;;;26973:3:60;26958:19;42384:262:44;;;;;;;42060:594;;;;;;;;;:::o;35287:159::-;35379:7;35427:9;35416:21;;;;;;;;:::i;:::-;;;;;;;;;;;;;35406:32;;;;;;35399:39;;35287:159;;;:::o;36733:4407::-;36949:25;37326:6;37301:22;:31;;;:70;;;;;37365:6;37336:9;:26;;;:35;;;37301:70;37293:95;;;;;;;28601:2:60;37293:95:44;;;28583:21:60;28640:2;28620:18;;;28613:30;28679:14;28659:18;;;28652:42;28711:18;;37293:95:44;28399:336:60;37293:95:44;37668:16;;;;37644:21;;;;:10;:21;;;;;;:40;37636:65;;;;;;;28942:2:60;37636:65:44;;;28924:21:60;28981:2;28961:18;;;28954:30;29020:14;29000:18;;;28993:42;29052:18;;37636:65:44;28740:336:60;37636:65:44;37818:15;37837:1;37818:20;37814:34;;-1:-1:-1;37847:1:44;37840:8;;37814:34;38316:130;38352:15;38412:22;38383:9;:26;;;:51;;;;:::i;:::-;38316:21;:130::i;:::-;38636:20;38737:21;;;:10;:21;;;;;;38718:16;;;;38296:150;;-1:-1:-1;38659:15:44;;38718:40;;38737:21;38718:40;:::i;:::-;38685:73;;38798:17;38773:22;:42;38769:570;;;38852:22;38832:42;;39184:143;39225:17;39290:22;39261:9;:26;;;:51;;;;:::i;:::-;39184:22;:143::i;:::-;39169:158;;38769:570;39678:21;;;;:10;:21;;;;;:42;;39703:17;;39678:21;:42;;39703:17;;39678:42;:::i;:::-;;;;-1:-1:-1;;39821:26:44;;;;:57;39859:18;39821:57;;;;;39817:1316;;40445:16;40440:132;;40487:26;;;;40480:92;;:51;;40532:10;40552:4;40559:12;40480:51;:92::i;:::-;40587:71;40623:9;:19;;;40645:12;40587:27;:71::i;:::-;39817:1316;;;40886:16;40881:240;;40921:98;40973:10;40985:9;:19;;;41006:12;40928:9;:26;;;40921:51;;;;:98;;;;;;:::i;40881:240::-;41039:82;41087:9;:19;;;41108:12;41046:9;:26;;;41039:47;;;;:82;;;;;:::i;:::-;36976:4164;;36733:4407;;;;;;;;:::o;41260:792::-;41954:9;:19;;;41510:534;;41929:10;41510:534;;;41536:9;:16;;;41567:10;:21;41578:9;41567:21;;;;;;;;;;;;41603:10;41628:16;41659:9;:23;;;41697:9;:28;;;41740:9;:23;;;41778:20;41813:9;:26;;;41854:9;:19;;;41888:9;:26;;;41988:9;:19;;;42022:11;41510:534;;;;;;;;;;;;;;;;;30057:25:60;;;30113:2;30098:18;;30091:34;;;;30156:2;30141:18;;30134:34;;;;30199:2;30184:18;;30177:34;;;;30242:3;30227:19;;30220:35;;;;30286:3;30271:19;;30264:35;;;;30318:18;30373:15;;;30367:3;30352:19;;30345:44;30426:15;;30420:3;30405:19;;30398:44;30479:15;30473:3;30458:19;;30451:44;30544:10;30532:23;30526:3;30511:19;;30504:52;30606:42;30593:56;;;30587:3;30572:19;;30565:85;4728:54;30702:3;30687:19;;4716:67;7717:13;7710:21;30756:3;30741:19;;7698:34;30044:3;30029:19;;29585:1182;41510:534:44;;;;;;;;41260:792;;;;;;:::o;29807:1907::-;30205:26;30234:393;;;;;;;;30270:9;30234:393;;;;;;30305:9;30234:393;;;;;;30347:16;30234:393;;;;;;30386:6;30234:393;;;;30422:13;30234:393;;;;30470:18;30234:393;;;;30521:16;30234:393;;;;;;30567:13;30234:393;;;;;;30606:9;30234:393;;;;;30205:422;;30662:95;30699:11;30711:12;30699:25;;;;;;;;;;:::i;:::-;;;;;;;;;;;:39;;;30740:9;30751:5;30662:36;:95::i;:::-;30640:158;;;;;;;30974:2:60;30640:158:44;;;30956:21:60;31013:2;30993:18;;;30986:30;31052:15;31032:18;;;31025:43;31085:18;;30640:158:44;30772:337:60;30640:158:44;30811:17;30831:24;30845:9;30831:13;:24::i;:::-;30811:44;;31199:25;31227:59;31238:9;31249;31260;:16;;;31278:1;31281:4;31227:10;:59::i;:::-;31199:87;;31639:67;31654:9;31665:17;31684:1;31687;31690:9;31701:4;31639:14;:67::i;:::-;30194:1520;;;29807:1907;;;;;;;;;;;:::o;31722:259::-;31809:33;;;31801:71;;;;;;;31316:2:60;31801:71:44;;;31298:21:60;31355:2;31335:18;;;31328:30;31394:27;31374:18;;;31367:55;31439:18;;31801:71:44;31114:349:60;31801:71:44;31883:16;:38;;;;;;;;;;;;;31937:36;;;;-1:-1:-1;;31937:36:44;31722:259;:::o;32415:1459::-;33314:75;;;31750:3:60;33314:75:44;;;31732:22:60;;;31791:2;31770:19;;;31763:31;31831:19;31810;;;31803:48;31937:18;31925:31;;31903:20;;;31896:61;;;;32005:10;31993:23;;-1:-1:-1;31973:18:60;;31966:51;32033:18;;;32026:34;;;33251:36:44;;31868:19:60;;33314:75:44;;;;;;;;;;;;33290:110;;;;;;33251:149;;33679:28;33710:58;33739:28;33710;:58::i;:::-;33679:89;;33781:85;33814:9;33825:20;33847:18;33781:32;:85::i;:::-;32639:1235;;32415:1459;;;;;:::o;1233:264:39:-;1405:4;1428:62;1447:5;1454:4;1481:6;1470:18;;;;;;;;:::i;:::-;;;;;;;;;;;;;1460:29;;;;;;1428:18;:62::i;:::-;1421:69;;1233:264;;;;;;:::o;2661:369::-;2769:4;;2812:11;2820:3;2812:5;:11;:::i;:::-;2785:38;-1:-1:-1;2833:23:39;2859:11;2867:3;2859:5;:11;:::i;:::-;2880:19;2902:31;;;;;;;;-1:-1:-1;2902:31:39;;;;2959:1;:20;;;2997:18;;;:26;;;;2661:369;-1:-1:-1;;2661:369:39:o;3248:297::-;3353:24;3380:11;3388:3;3380:5;:11;:::i;:::-;3353:38;-1:-1:-1;3401:23:39;3427:11;3435:3;3427:5;:11;:::i;:::-;3482:31;;;;;;;;;-1:-1:-1;3482:31:39;;;;;3517:1;:20;;;3482:56;;;3448:90;;;-1:-1:-1;3248:297:39:o;701:205:10:-;840:58;;33650:42:60;33638:55;;840:58:10;;;33620:74:60;33710:18;;;33703:34;;;813:86:10;;833:5;;863:23;;33593:18:60;;840:58:10;33446:297:60;5537:1449:41;5906:18;5862:63;;:17;:32;;;:63;;;5858:287;;5948:32;;;;5991;;5942:82;;;;;:48;;;;;;;:82;;;;6186:25:60;;;6174:2;6159:18;;6040:177;5942:82:41;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;6059:40:41;6094:5;6059:40;:32;;;:40;-1:-1:-1;5858:287:41;6197:32;;;;6184:60;:46;;;6242:1;6184:46;;;:12;:46;;;;;;;:60;:187;;6338:32;;;;6325:46;;;;;;;;:12;:46;;;;;;;6184:187;;;864:42:5;6184:187:41;6412:32;;;;6516:7;;6602:32;;6665:5;;6155:700;;;;;:238;34120:15:60;;;6155:700:41;;;34102:34:60;6516:7:41;;;34152:18:60;;;34145:43;34204:18;;;34197:34;;;;6665:5:41;;34247:18:60;;;34240:51;34328:3;34307:19;;;34300:32;-1:-1:-1;34348:19:60;;;34341:30;6155:238:41;;;;;34388:19:60;;6155:700:41;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;6895:32:41;;;;6929:7;;6938:32;;6972:5;;6873:105;;;;6929:7;;;34619:74:60;;34724:2;34709:18;;34702:34;;;;6972:5:41;;;;34752:18:60;;;34745:51;6873:105:41;;;;;34607:2:60;34592:18;6873:105:41;;;;;;;5537:1449;:::o;3207:706:10:-;3626:23;3652:69;3680:4;3652:69;;;;;;;;;;;;;;;;;3660:5;3652:27;;;;:69;;;;;:::i;:::-;3735:17;;3626:95;;-1:-1:-1;3735:21:10;3731:176;;3830:10;3819:30;;;;;;;;;;;;:::i;:::-;3811:85;;;;;;;35259:2:60;3811:85:10;;;35241:21:60;35298:2;35278:18;;;35271:30;35337:34;35317:18;;;35310:62;35408:12;35388:18;;;35381:40;35438:19;;3811:85:10;35057:406:60;34962:154:44;35047:7;35093:14;35100:7;35093:4;:14;:::i;:::-;35074:34;;35075:13;35082:6;35075:4;:13;:::i;:::-;35074:34;;;;:::i;35124:155::-;35210:7;35267:4;35248:14;35255:7;35267:4;35248:14;:::i;:::-;35238:25;;;;:6;:25;:::i;35586:319::-;35683:22;;;1465:19:11;:23;35679:219:44;;35724:60;:48;35739:18;35724:48;35773:2;35777:6;35724:48;:60::i;35679:219::-;35817:35;;;;;;;;6186:25:60;;;35817:18:44;:27;;;;;6159:18:60;;35817:35:44;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;35867:19:44;;:11;;;;-1:-1:-1;35867:19:44;;;;;-1:-1:-1;35879:6:44;;35867:19;;;;35879:6;35867:11;:19;;;;;;;;;;;;;;;;;;;1858:291:39;2043:4;2066:76;2085:5;2092:4;2119:20;2108:32;;;;;;;;:::i;8012:265:14:-;8211:58;;36177:66:60;8211:58:14;;;36165:79:60;36260:12;;;36253:28;;;8081:7:14;;36297:12:60;;8211:58:14;35935:380:60;34345:609:44;34869:55;34883:20;34905:18;34869:13;:55::i;:::-;34856:68;;:9;:68;;;34848:98;;;;;;;36522:2:60;34848:98:44;;;36504:21:60;36561:2;36541:18;;;36534:30;36600:19;36580:18;;;36573:47;36637:18;;34848:98:44;36320:341:60;862:184:15;983:4;1035;1006:25;1019:5;1026:4;1006:12;:25::i;:::-;:33;;862:184;-1:-1:-1;;;;862:184:15:o;3861:223:11:-;3994:12;4025:52;4047:6;4055:4;4061:1;4064:12;4025:21;:52::i;4308:227:14:-;4386:7;4406:17;4425:18;4447:27;4458:4;4464:9;4447:10;:27::i;:::-;4405:69;;;;4484:18;4496:5;4484:11;:18::i;:::-;-1:-1:-1;4519:9:14;4308:227;-1:-1:-1;;;4308:227:14:o;1398:662:15:-;1481:7;1523:4;1481:7;1537:488;1561:5;:12;1557:1;:16;1537:488;;;1594:20;1617:5;1623:1;1617:8;;;;;;;;:::i;:::-;;;;;;;1594:31;;1659:12;1643;:28;1639:376;;2134:13;2182:15;;;2217:4;2210:15;;;2263:4;2247:21;;1769:57;;1639:376;;;2134:13;2182:15;;;2217:4;2210:15;;;2263:4;2247:21;;1943:57;;1639:376;-1:-1:-1;1575:3:15;;;;:::i;:::-;;;;1537:488;;4948:499:11;5113:12;5170:5;5145:21;:30;;5137:81;;;;;;;36868:2:60;5137:81:11;;;36850:21:60;36907:2;36887:18;;;36880:30;36946:34;36926:18;;;36919:62;37017:8;36997:18;;;36990:36;37043:19;;5137:81:11;36666:402:60;5137:81:11;1465:19;;;;5228:60;;;;;;;37275:2:60;5228:60:11;;;37257:21:60;37314:2;37294:18;;;37287:30;37353:31;37333:18;;;37326:59;37402:18;;5228:60:11;37073:353:60;5228:60:11;5300:12;5314:23;5341:6;:11;;5360:5;5367:4;5341:31;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5299:73;;;;5389:51;5406:7;5415:10;5427:12;5389:16;:51::i;:::-;5382:58;4948:499;-1:-1:-1;;;;;;;4948:499:11:o;2243:1279:14:-;2324:7;2333:12;2554:9;:16;2574:2;2554:22;2550:966;;2843:4;2828:20;;2822:27;2892:4;2877:20;;2871:27;2949:4;2934:20;;2928:27;2592:9;2920:36;2990:25;3001:4;2920:36;2822:27;2871;2990:10;:25::i;:::-;2983:32;;;;;;;;;2550:966;3036:9;:16;3056:2;3036:22;3032:484;;3305:4;3290:20;;3284:27;3355:4;3340:20;;3334:27;3395:23;3406:4;3284:27;3334;3395:10;:23::i;:::-;3388:30;;;;;;;;3032:484;-1:-1:-1;3465:1:14;;-1:-1:-1;3469:35:14;3032:484;2243:1279;;;;;:::o;548:631::-;625:20;616:5;:29;;;;;;;;:::i;:::-;;612:561;;548:631;:::o;612:561::-;721:29;712:5;:38;;;;;;;;:::i;:::-;;708:465;;766:34;;;;;38101:2:60;766:34:14;;;38083:21:60;38140:2;38120:18;;;38113:30;38179:26;38159:18;;;38152:54;38223:18;;766:34:14;37899:348:60;708:465:14;830:35;821:5;:44;;;;;;;;:::i;:::-;;817:356;;881:41;;;;;38454:2:60;881:41:14;;;38436:21:60;38493:2;38473:18;;;38466:30;38532:33;38512:18;;;38505:61;38583:18;;881:41:14;38252:355:60;817:356:14;952:30;943:5;:39;;;;;;;;:::i;:::-;;939:234;;998:44;;;;;38814:2:60;998:44:14;;;38796:21:60;38853:2;38833:18;;;38826:30;38892:34;38872:18;;;38865:62;38963:4;38943:18;;;38936:32;38985:19;;998:44:14;38612:398:60;939:234:14;1072:30;1063:5;:39;;;;;;;;:::i;:::-;;1059:114;;1118:44;;;;;39217:2:60;1118:44:14;;;39199:21:60;39256:2;39236:18;;;39229:30;39295:34;39275:18;;;39268:62;39366:4;39346:18;;;39339:32;39388:19;;1118:44:14;39015:398:60;7561:692:11;7707:12;7735:7;7731:516;;;-1:-1:-1;7765:10:11;7758:17;;7731:516;7876:17;;:21;7872:365;;8070:10;8064:17;8130:15;8117:10;8113:2;8109:19;8102:44;7872:365;8209:12;8202:20;;;;;;;;;;;:::i;5716:1603:14:-;5842:7;;6766:66;6753:79;;6749:161;;;-1:-1:-1;6864:1:14;;-1:-1:-1;6868:30:14;6848:51;;6749:161;6923:1;:7;;6928:2;6923:7;;:18;;;;;6934:1;:7;;6939:2;6934:7;;6923:18;6919:100;;;-1:-1:-1;6973:1:14;;-1:-1:-1;6977:30:14;6957:51;;6919:100;7130:24;;;7113:14;7130:24;;;;;;;;;39645:25:60;;;39718:4;39706:17;;39686:18;;;39679:45;;;;39740:18;;;39733:34;;;39783:18;;;39776:34;;;7130:24:14;;39617:19:60;;7130:24:14;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;7130:24:14;;;;;;-1:-1:-1;;7168:20:14;;;7164:101;;7220:1;7224:29;7204:50;;;;;;;7164:101;7283:6;-1:-1:-1;7291:20:14;;-1:-1:-1;5716:1603:14;;;;;;;;:::o;4789:336::-;4899:7;;4957:66;4944:80;;4899:7;5050:25;5066:3;5051:18;;;5073:2;5050:25;:::i;:::-;5034:42;;5093:25;5104:4;5110:1;5113;5116;5093:10;:25::i;:::-;5086:32;;;;;;4789:336;;;;;;:::o;14:163:60:-;81:20;;141:10;130:22;;120:33;;110:61;;167:1;164;157:12;110:61;14:163;;;:::o;182:184::-;240:6;293:2;281:9;272:7;268:23;264:32;261:52;;;309:1;306;299:12;261:52;332:28;350:9;332:28;:::i;617:184::-;669:77;666:1;659:88;766:4;763:1;756:15;790:4;787:1;780:15;806:253;878:2;872:9;920:4;908:17;;955:18;940:34;;976:22;;;937:62;934:88;;;1002:18;;:::i;:::-;1038:2;1031:22;806:253;:::o;1064:334::-;1135:2;1129:9;1191:2;1181:13;;1196:66;1177:86;1165:99;;1294:18;1279:34;;1315:22;;;1276:62;1273:88;;;1341:18;;:::i;:::-;1377:2;1370:22;1064:334;;-1:-1:-1;1064:334:60:o;1403:183::-;1463:4;1496:18;1488:6;1485:30;1482:56;;;1518:18;;:::i;:::-;-1:-1:-1;1563:1:60;1559:14;1575:4;1555:25;;1403:183::o;1591:662::-;1645:5;1698:3;1691:4;1683:6;1679:17;1675:27;1665:55;;1716:1;1713;1706:12;1665:55;1752:6;1739:20;1778:4;1802:60;1818:43;1858:2;1818:43;:::i;:::-;1802:60;:::i;:::-;1896:15;;;1982:1;1978:10;;;;1966:23;;1962:32;;;1927:12;;;;2006:15;;;2003:35;;;2034:1;2031;2024:12;2003:35;2070:2;2062:6;2058:15;2082:142;2098:6;2093:3;2090:15;2082:142;;;2164:17;;2152:30;;2202:12;;;;2115;;2082:142;;;-1:-1:-1;2242:5:60;1591:662;-1:-1:-1;;;;;;1591:662:60:o;2258:154::-;2344:42;2337:5;2333:54;2326:5;2323:65;2313:93;;2402:1;2399;2392:12;2417:134;2485:20;;2514:31;2485:20;2514:31;:::i;2556:737::-;2610:5;2663:3;2656:4;2648:6;2644:17;2640:27;2630:55;;2681:1;2678;2671:12;2630:55;2717:6;2704:20;2743:4;2767:60;2783:43;2823:2;2783:43;:::i;2767:60::-;2861:15;;;2947:1;2943:10;;;;2931:23;;2927:32;;;2892:12;;;;2971:15;;;2968:35;;;2999:1;2996;2989:12;2968:35;3035:2;3027:6;3023:15;3047:217;3063:6;3058:3;3055:15;3047:217;;;3143:3;3130:17;3160:31;3185:5;3160:31;:::i;:::-;3204:18;;3242:12;;;;3080;;3047:217;;3298:1359;3434:6;3442;3450;3503:2;3491:9;3482:7;3478:23;3474:32;3471:52;;;3519:1;3516;3509:12;3471:52;3542:28;3560:9;3542:28;:::i;:::-;3532:38;;3621:2;3610:9;3606:18;3593:32;3644:18;3685:2;3677:6;3674:14;3671:34;;;3701:1;3698;3691:12;3671:34;3724:22;;;;3780:4;3762:16;;;3758:27;3755:47;;;3798:1;3795;3788:12;3755:47;3824:22;;:::i;:::-;3882:2;3869:16;3862:5;3855:31;3939:2;3935;3931:11;3918:25;3913:2;3906:5;3902:14;3895:49;3990:2;3986;3982:11;3969:25;4019:2;4009:8;4006:16;4003:36;;;4035:1;4032;4025:12;4003:36;4071:56;4119:7;4108:8;4104:2;4100:17;4071:56;:::i;:::-;4066:2;4059:5;4055:14;4048:80;;4160:30;4186:2;4182;4178:11;4160:30;:::i;:::-;4155:2;4148:5;4144:14;4137:54;4224:32;4251:3;4247:2;4243:12;4224:32;:::i;:::-;4218:3;4211:5;4207:15;4200:57;4303:3;4299:2;4295:12;4282:26;4333:2;4323:8;4320:16;4317:36;;;4349:1;4346;4339:12;4317:36;4386:56;4434:7;4423:8;4419:2;4415:17;4386:56;:::i;:::-;4380:3;4369:15;;4362:81;-1:-1:-1;4373:5:60;-1:-1:-1;4520:2:60;4505:18;;4492:32;;-1:-1:-1;4536:16:60;;;4533:36;;;4565:1;4562;4555:12;4533:36;;4588:63;4643:7;4632:8;4621:9;4617:24;4588:63;:::i;:::-;4578:73;;;3298:1359;;;;;:::o;5025:247::-;5084:6;5137:2;5125:9;5116:7;5112:23;5108:32;5105:52;;;5153:1;5150;5143:12;5105:52;5192:9;5179:23;5211:31;5236:5;5211:31;:::i;5277:180::-;5336:6;5389:2;5377:9;5368:7;5364:23;5360:32;5357:52;;;5405:1;5402;5395:12;5357:52;-1:-1:-1;5428:23:60;;5277:180;-1:-1:-1;5277:180:60:o;5462:118::-;5548:5;5541:13;5534:21;5527:5;5524:32;5514:60;;5570:1;5567;5560:12;5585:450;5659:6;5667;5675;5728:2;5716:9;5707:7;5703:23;5699:32;5696:52;;;5744:1;5741;5734:12;5696:52;5783:9;5770:23;5802:31;5827:5;5802:31;:::i;:::-;5852:5;-1:-1:-1;5904:2:60;5889:18;;5876:32;;-1:-1:-1;5960:2:60;5945:18;;5932:32;5973:30;5932:32;5973:30;:::i;:::-;6022:7;6012:17;;;5585:450;;;;;:::o;6222:171::-;6289:20;;6349:18;6338:30;;6328:41;;6318:69;;6383:1;6380;6373:12;6398:671;6500:6;6508;6516;6524;6532;6540;6593:3;6581:9;6572:7;6568:23;6564:33;6561:53;;;6610:1;6607;6600:12;6561:53;6649:9;6636:23;6668:31;6693:5;6668:31;:::i;:::-;6718:5;-1:-1:-1;6775:2:60;6760:18;;6747:32;6788:33;6747:32;6788:33;:::i;:::-;6840:7;-1:-1:-1;6894:2:60;6879:18;;6866:32;;-1:-1:-1;6945:2:60;6930:18;;6917:32;;-1:-1:-1;6968:38:60;7001:3;6986:19;;6968:38;:::i;:::-;6958:48;;7025:38;7058:3;7047:9;7043:19;7025:38;:::i;:::-;7015:48;;6398:671;;;;;;;;:::o;7074:248::-;7142:6;7150;7203:2;7191:9;7182:7;7178:23;7174:32;7171:52;;;7219:1;7216;7209:12;7171:52;-1:-1:-1;;7242:23:60;;;7312:2;7297:18;;;7284:32;;-1:-1:-1;7074:248:60:o;7327:315::-;7395:6;7403;7456:2;7444:9;7435:7;7431:23;7427:32;7424:52;;;7472:1;7469;7462:12;7424:52;7511:9;7498:23;7530:31;7555:5;7530:31;:::i;:::-;7580:5;7632:2;7617:18;;;;7604:32;;-1:-1:-1;;;7327:315:60:o;8231:1024::-;8368:6;8376;8384;8392;8400;8408;8416;8424;8432;8440;8493:3;8481:9;8472:7;8468:23;8464:33;8461:53;;;8510:1;8507;8500:12;8461:53;8549:9;8536:23;8568:31;8593:5;8568:31;:::i;:::-;8618:5;-1:-1:-1;8675:2:60;8660:18;;8647:32;8688:33;8647:32;8688:33;:::i;:::-;8740:7;-1:-1:-1;8799:2:60;8784:18;;8771:32;8812:33;8771:32;8812:33;:::i;:::-;8864:7;-1:-1:-1;8918:2:60;8903:18;;8890:32;;-1:-1:-1;8969:3:60;8954:19;;8941:33;;-1:-1:-1;9021:3:60;9006:19;;8993:33;;-1:-1:-1;9073:3:60;9058:19;;9045:33;;-1:-1:-1;9097:38:60;9130:3;9115:19;;9097:38;:::i;:::-;9087:48;;9154:38;9187:3;9176:9;9172:19;9154:38;:::i;:::-;9144:48;;9211:38;9244:3;9233:9;9229:19;9211:38;:::i;:::-;9201:48;;8231:1024;;;;;;;;;;;;;:::o;9260:626::-;9357:6;9365;9418:2;9406:9;9397:7;9393:23;9389:32;9386:52;;;9434:1;9431;9424:12;9386:52;9474:9;9461:23;9503:18;9544:2;9536:6;9533:14;9530:34;;;9560:1;9557;9550:12;9530:34;9598:6;9587:9;9583:22;9573:32;;9643:7;9636:4;9632:2;9628:13;9624:27;9614:55;;9665:1;9662;9655:12;9614:55;9705:2;9692:16;9731:2;9723:6;9720:14;9717:34;;;9747:1;9744;9737:12;9717:34;9800:7;9795:2;9785:6;9782:1;9778:14;9774:2;9770:23;9766:32;9763:45;9760:65;;;9821:1;9818;9811:12;9760:65;9852:2;9844:11;;;;;9874:6;;-1:-1:-1;9260:626:60;;-1:-1:-1;;;;9260:626:60:o;9891:258::-;9963:1;9973:113;9987:6;9984:1;9981:13;9973:113;;;10063:11;;;10057:18;10044:11;;;10037:39;10009:2;10002:10;9973:113;;;10104:6;10101:1;10098:13;10095:48;;;-1:-1:-1;;10139:1:60;10121:16;;10114:27;9891:258::o;10154:316::-;10195:3;10233:5;10227:12;10260:6;10255:3;10248:19;10276:63;10332:6;10325:4;10320:3;10316:14;10309:4;10302:5;10298:16;10276:63;:::i;:::-;10384:2;10372:15;10389:66;10368:88;10359:98;;;;10459:4;10355:109;;10154:316;-1:-1:-1;;10154:316:60:o;10475:859::-;10635:4;10664:2;10704;10693:9;10689:18;10734:2;10723:9;10716:21;10757:6;10792;10786:13;10823:6;10815;10808:22;10861:2;10850:9;10846:18;10839:25;;10923:2;10913:6;10910:1;10906:14;10895:9;10891:30;10887:39;10873:53;;10961:2;10953:6;10949:15;10982:1;10992:313;11006:6;11003:1;11000:13;10992:313;;;11095:66;11083:9;11075:6;11071:22;11067:95;11062:3;11055:108;11186:39;11218:6;11209;11203:13;11186:39;:::i;:::-;11176:49;-1:-1:-1;11283:12:60;;;;11248:15;;;;11028:1;11021:9;10992:313;;;-1:-1:-1;11322:6:60;;10475:859;-1:-1:-1;;;;;;;10475:859:60:o;11339:1196::-;11500:6;11508;11516;11524;11532;11540;11548;11556;11564;11572;11625:3;11613:9;11604:7;11600:23;11596:33;11593:53;;;11642:1;11639;11632:12;11593:53;11681:9;11668:23;11700:31;11725:5;11700:31;:::i;:::-;11750:5;-1:-1:-1;11807:2:60;11792:18;;11779:32;11820:33;11779:32;11820:33;:::i;:::-;11872:7;-1:-1:-1;11931:2:60;11916:18;;11903:32;11944:33;11903:32;11944:33;:::i;:::-;11996:7;-1:-1:-1;12050:2:60;12035:18;;12022:32;;-1:-1:-1;12101:3:60;12086:19;;12073:33;;-1:-1:-1;12125:38:60;12158:3;12143:19;;12125:38;:::i;:::-;12115:48;;12182:38;12215:3;12204:9;12200:19;12182:38;:::i;:::-;12172:48;;12239:38;12272:3;12261:9;12257:19;12239:38;:::i;:::-;12229:48;;12296:38;12329:3;12318:9;12314:19;12296:38;:::i;:::-;12286:48;;12385:3;12374:9;12370:19;12357:33;12413:18;12405:6;12402:30;12399:50;;;12445:1;12442;12435:12;12399:50;12468:61;12521:7;12512:6;12501:9;12497:22;12468:61;:::i;:::-;12458:71;;;11339:1196;;;;;;;;;;;;;:::o;12540:245::-;12588:4;12621:18;12613:6;12610:30;12607:56;;;12643:18;;:::i;:::-;-1:-1:-1;12700:2:60;12688:15;12705:66;12684:88;12774:4;12680:99;;12540:245::o;12790:462::-;12832:5;12885:3;12878:4;12870:6;12866:17;12862:27;12852:55;;12903:1;12900;12893:12;12852:55;12939:6;12926:20;12970:48;12986:31;13014:2;12986:31;:::i;12970:48::-;13043:2;13034:7;13027:19;13089:3;13082:4;13077:2;13069:6;13065:15;13061:26;13058:35;13055:55;;;13106:1;13103;13096:12;13055:55;13171:2;13164:4;13156:6;13152:17;13145:4;13136:7;13132:18;13119:55;13219:1;13194:16;;;13212:4;13190:27;13183:38;;;;13198:7;12790:462;-1:-1:-1;;;12790:462:60:o;13257:600::-;13350:6;13358;13366;13374;13427:3;13415:9;13406:7;13402:23;13398:33;13395:53;;;13444:1;13441;13434:12;13395:53;13483:9;13470:23;13502:31;13527:5;13502:31;:::i;:::-;13552:5;-1:-1:-1;13576:37:60;13609:2;13594:18;;13576:37;:::i;:::-;13566:47;;13632:37;13665:2;13654:9;13650:18;13632:37;:::i;:::-;13622:47;;13720:2;13709:9;13705:18;13692:32;13747:18;13739:6;13736:30;13733:50;;;13779:1;13776;13769:12;13733:50;13802:49;13843:7;13834:6;13823:9;13819:22;13802:49;:::i;:::-;13792:59;;;13257:600;;;;;;;:::o;14300:388::-;14368:6;14376;14429:2;14417:9;14408:7;14404:23;14400:32;14397:52;;;14445:1;14442;14435:12;14397:52;14484:9;14471:23;14503:31;14528:5;14503:31;:::i;:::-;14553:5;-1:-1:-1;14610:2:60;14595:18;;14582:32;14623:33;14582:32;14623:33;:::i;:::-;14675:7;14665:17;;;14300:388;;;;;:::o;14693:1113::-;14856:6;14864;14872;14880;14888;14896;14904;14912;14920;14928;14936:7;14945;14999:3;14987:9;14978:7;14974:23;14970:33;14967:53;;;15016:1;15013;15006:12;14967:53;15039:29;15058:9;15039:29;:::i;:::-;15029:39;;15087:38;15121:2;15110:9;15106:18;15087:38;:::i;:::-;15077:48;;15144:38;15178:2;15167:9;15163:18;15144:38;:::i;:::-;15134:48;;15229:2;15218:9;15214:18;15201:32;15191:42;;15280:3;15269:9;15265:19;15252:33;15242:43;;15332:3;15321:9;15317:19;15304:33;15294:43;;15384:3;15373:9;15369:19;15356:33;15346:43;;15408:38;15441:3;15430:9;15426:19;15408:38;:::i;:::-;15398:48;;15465:38;15498:3;15487:9;15483:19;15465:38;:::i;:::-;15455:48;;15522:38;15555:3;15544:9;15540:19;15522:38;:::i;:::-;15512:48;;15580:38;15613:3;15602:9;15598:19;15580:38;:::i;:::-;15569:49;;15668:18;15661:3;15650:9;15646:19;15633:33;15630:57;15627:77;;;15700:1;15697;15690:12;15627:77;15724:76;15792:7;15784:3;15773:9;15769:19;15756:33;15745:9;15741:49;15724:76;:::i;:::-;15713:87;;14693:1113;;;;;;;;;;;;;;:::o;15811:184::-;15881:6;15934:2;15922:9;15913:7;15909:23;15905:32;15902:52;;;15950:1;15947;15940:12;15902:52;-1:-1:-1;15973:16:60;;15811:184;-1:-1:-1;15811:184:60:o;16691:::-;16743:77;16740:1;16733:88;16840:4;16837:1;16830:15;16864:4;16861:1;16854:15;16880:221;16919:4;16948:10;17008;;;;16978;;17030:12;;;17027:38;;;17045:18;;:::i;:::-;17082:13;;16880:221;-1:-1:-1;;;16880:221:60:o;17106:228::-;17145:3;17173:10;17210:2;17207:1;17203:10;17240:2;17237:1;17233:10;17271:3;17267:2;17263:12;17258:3;17255:21;17252:47;;;17279:18;;:::i;:::-;17315:13;;17106:228;-1:-1:-1;;;;17106:228:60:o;18042:201::-;18080:3;18108:10;18153:2;18146:5;18142:14;18180:2;18171:7;18168:15;18165:41;;18186:18;;:::i;:::-;18235:1;18222:15;;18042:201;-1:-1:-1;;;18042:201:60:o;18248:184::-;18300:77;18297:1;18290:88;18397:4;18394:1;18387:15;18421:4;18418:1;18411:15;18793:580;18870:4;18876:6;18936:11;18923:25;19026:66;19015:8;18999:14;18995:29;18991:102;18971:18;18967:127;18957:155;;19108:1;19105;19098:12;18957:155;19135:33;;19187:20;;;-1:-1:-1;19230:18:60;19219:30;;19216:50;;;19262:1;19259;19252:12;19216:50;19295:4;19283:17;;-1:-1:-1;19326:14:60;19322:27;;;19312:38;;19309:58;;;19363:1;19360;19353:12;19378:271;19561:6;19553;19548:3;19535:33;19517:3;19587:16;;19612:13;;;19587:16;19378:271;-1:-1:-1;19378:271:60:o;19654:635::-;19734:6;19787:2;19775:9;19766:7;19762:23;19758:32;19755:52;;;19803:1;19800;19793:12;19755:52;19836:9;19830:16;19869:18;19861:6;19858:30;19855:50;;;19901:1;19898;19891:12;19855:50;19924:22;;19977:4;19969:13;;19965:27;-1:-1:-1;19955:55:60;;20006:1;20003;19996:12;19955:55;20035:2;20029:9;20060:48;20076:31;20104:2;20076:31;:::i;20060:48::-;20131:2;20124:5;20117:17;20171:7;20166:2;20161;20157;20153:11;20149:20;20146:33;20143:53;;;20192:1;20189;20182:12;20143:53;20205:54;20256:2;20251;20244:5;20240:14;20235:2;20231;20227:11;20205:54;:::i;20294:219::-;20443:2;20432:9;20425:21;20406:4;20463:44;20503:2;20492:9;20488:18;20480:6;20463:44;:::i;20518:195::-;20557:3;20588:66;20581:5;20578:77;20575:103;;20658:18;;:::i;:::-;-1:-1:-1;20705:1:60;20694:13;;20518:195::o;20825:311::-;21010:18;21002:6;20998:31;20987:9;20980:50;21066:2;21061;21050:9;21046:18;21039:30;20961:4;21086:44;21126:2;21115:9;21111:18;21103:6;21086:44;:::i;21556:251::-;21626:6;21679:2;21667:9;21658:7;21654:23;21650:32;21647:52;;;21695:1;21692;21685:12;21647:52;21727:9;21721:16;21746:31;21771:5;21746:31;:::i;24257:435::-;24310:3;24348:5;24342:12;24375:6;24370:3;24363:19;24401:4;24430:2;24425:3;24421:12;24414:19;;24467:2;24460:5;24456:14;24488:1;24498:169;24512:6;24509:1;24506:13;24498:169;;;24573:13;;24561:26;;24607:12;;;;24642:15;;;;24534:1;24527:9;24498:169;;;-1:-1:-1;24683:3:60;;24257:435;-1:-1:-1;;;;;24257:435:60:o;24697:484::-;24750:3;24788:5;24782:12;24815:6;24810:3;24803:19;24841:4;24870:2;24865:3;24861:12;24854:19;;24907:2;24900:5;24896:14;24928:1;24938:218;24952:6;24949:1;24946:13;24938:218;;;25017:13;;25032:42;25013:62;25001:75;;25096:12;;;;25131:15;;;;24974:1;24967:9;24938:218;;25186:760;25527:6;25516:9;25509:25;25570:3;25565:2;25554:9;25550:18;25543:31;25490:4;25597:57;25649:3;25638:9;25634:19;25626:6;25597:57;:::i;:::-;25673:42;25763:2;25755:6;25751:15;25746:2;25735:9;25731:18;25724:43;25815:9;25807:6;25803:22;25798:2;25787:9;25783:18;25776:50;25843:44;25880:6;25872;25843:44;:::i;:::-;25835:52;;25936:2;25928:6;25924:15;25918:3;25907:9;25903:19;25896:44;;;25186:760;;;;;;;;:::o;27330:1064::-;27614:13;;27541:42;27610:22;;;27592:41;;27693:4;27681:17;;;27675:24;27671:33;;27649:20;;;27642:63;27752:4;27740:17;;;27734:24;4728:54;;;27800:20;;;4716:67;27518:3;27503:19;;;27767:54;27877:4;27869:6;27865:17;27859:24;27852:4;27841:9;27837:20;27830:54;27940:4;27932:6;27928:17;27922:24;27915:4;27904:9;27900:20;27893:54;28003:4;27995:6;27991:17;27985:24;27978:4;27967:9;27963:20;27956:54;28059:4;28051:6;28047:17;28041:24;28074:55;28123:4;28112:9;28108:20;28092:14;20794:18;20783:30;20771:43;;20718:102;28074:55;;28178:4;28170:6;28166:17;28160:24;28193:55;28242:4;28231:9;28227:20;28211:14;20794:18;20783:30;20771:43;;20718:102;28193:55;-1:-1:-1;28267:6:60;28310:15;;;28304:22;8011:10;8000:22;28369:18;;;;7988:35;27330:1064;:::o;29081:236::-;29120:3;29148:18;29193:2;29190:1;29186:10;29223:2;29220:1;29216:10;29254:3;29250:2;29246:12;29241:3;29238:21;29235:47;;;29262:18;;:::i;29322:125::-;29362:4;29390:1;29387;29384:8;29381:34;;;29395:18;;:::i;:::-;-1:-1:-1;29432:9:60;;29322:125::o;29452:128::-;29492:3;29523:1;29519:6;29516:1;29513:13;29510:39;;;29529:18;;:::i;:::-;-1:-1:-1;29565:9:60;;29452:128::o;32071:939::-;32270:2;32259:9;32252:21;32315:6;32309:13;32304:2;32293:9;32289:18;32282:41;32377:2;32369:6;32365:15;32359:22;32354:2;32343:9;32339:18;32332:50;32233:4;32429:2;32421:6;32417:15;32411:22;32469:4;32464:2;32453:9;32449:18;32442:32;32497:63;32555:3;32544:9;32540:19;32526:12;32497:63;:::i;:::-;32483:77;;32625:10;32619:2;32611:6;32607:15;32601:22;32597:39;32591:3;32580:9;32576:19;32569:68;32703:42;32696:3;32688:6;32684:16;32678:23;32674:72;32668:3;32657:9;32653:19;32646:101;32796:3;32788:6;32784:16;32778:23;32867:66;32855:9;32847:6;32843:22;32839:95;32832:4;32821:9;32817:20;32810:125;32952:52;32997:6;32981:14;32952:52;:::i;33015:184::-;33067:77;33064:1;33057:88;33164:4;33161:1;33154:15;33188:4;33185:1;33178:15;33204:120;33244:1;33270;33260:35;;33275:18;;:::i;:::-;-1:-1:-1;33309:9:60;;33204:120::o;33329:112::-;33361:1;33387;33377:35;;33392:18;;:::i;:::-;-1:-1:-1;33426:9:60;;33329:112::o;34807:245::-;34874:6;34927:2;34915:9;34906:7;34902:23;34898:32;34895:52;;;34943:1;34940;34933:12;34895:52;34975:9;34969:16;34994:28;35016:5;34994:28;:::i;35468:229::-;35507:4;35536:18;35604:10;;;;35574;;35626:12;;;35623:38;;;35641:18;;:::i;35702:228::-;35742:7;35868:1;35800:66;35796:74;35793:1;35790:81;35785:1;35778:9;35771:17;35767:105;35764:131;;;35875:18;;:::i;:::-;-1:-1:-1;35915:9:60;;35702:228::o;37431:274::-;37560:3;37598:6;37592:13;37614:53;37660:6;37655:3;37648:4;37640:6;37636:17;37614:53;:::i;:::-;37683:16;;;;;37431:274;-1:-1:-1;;37431:274:60:o;37710:184::-;37762:77;37759:1;37752:88;37859:4;37856:1;37849:15;37883:4;37880:1;37873:15

Swarm Source

ipfs://eb7c71015621a3f0e8435e96b853ec4cb7e61d884a87ee1833c41a0d61e58546
Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.