ETH Price: $2,401.49 (+7.11%)
Gas: 1.66 Gwei

Transaction Decoder

Block:
16322729 at Jan-03-2023 12:39:35 AM +UTC
Transaction Fee:
0.022917011542722456 ETH $55.04
Gas Used:
1,496,732 Gas / 15.311366058 Gwei

Emitted Events:

60 Dai.Transfer( src=[Receiver] TransparentUpgradeableProxy, dst=0x96032fcD94bf017431675ae3dcB032Ca17Fb1f90, wad=10000000000000000000000 )
61 Dai.Transfer( src=[Receiver] TransparentUpgradeableProxy, dst=0x96032fcD94bf017431675ae3dcB032Ca17Fb1f90, wad=10000000000000000000000 )
62 WETH9.Deposit( dst=ERC4626Bridge, wad=1669181000000000000 )
63 WETH9.Transfer( src=ERC4626Bridge, dst=EulerERC4626, wad=1669181000000000000 )
64 EulerERC4626.Transfer( from=0x0000000000000000000000000000000000000000, to=ERC4626Bridge, amount=1655146345611228071 )
65 EulerERC4626.Deposit( caller=ERC4626Bridge, owner=ERC4626Bridge, assets=1669181000000000000, shares=1655146345611228071 )
66 WETH9.Approval( src=EulerERC4626, guy=Euler, wad=1669181000000000000 )
67 Euler.RequestDeposit( account=EulerERC4626, amount=1669181000000000000 )
68 WETH9.Transfer( src=EulerERC4626, dst=Euler, wad=1669181000000000000 )
69 Euler.Deposit( underlying=WETH9, account=EulerERC4626, amount=1633189236825691462 )
70 Proxy.0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef( 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x0000000000000000000000003c66b18f67ca6c1a71f829e2f6a0c987f97462d0, 00000000000000000000000000000000000000000000000016aa40f537fc9546 )
71 Euler.AssetStatus( underlying=WETH9, totalBalances=40935051062105668070117, totalBorrows=31889237402279570558078, reserveBalance=268707020263670454385, poolSize=9947928754718056300674, interestAccumulator=1045672172799170240294003159, interestRate=1184165275315930416, timestamp=1672706375 )
72 EulerERC4626.Transfer( from=ERC4626Bridge, to=[Receiver] TransparentUpgradeableProxy, amount=1655146345611228071 )
73 TransparentUpgradeableProxy.0x692cf5822a02f5edf084dc7249b3a06293621e069f11975ed70908ed10ed2e2c( 0x692cf5822a02f5edf084dc7249b3a06293621e069f11975ed70908ed10ed2e2c, 0x000000000000000000000000000000000000000050000000000000000000000a, 0x00000000000000000000000000000000000000000000000000000000000340e0, 000000000000000000000000000000000000000000000000172a1f469ad4d000, 00000000000000000000000000000000000000000000000016f842d4fd7173a7, 0000000000000000000000000000000000000000000000000000000000000000, 0000000000000000000000000000000000000000000000000000000000000001, 00000000000000000000000000000000000000000000000000000000000000a0, 0000000000000000000000000000000000000000000000000000000000000000 )
74 TransparentUpgradeableProxy.0x14054a15b39bfd65ec00fc6d15c7e5f9cbc1dc6f452cbefa359b4da61ad89fb6( 0x14054a15b39bfd65ec00fc6d15c7e5f9cbc1dc6f452cbefa359b4da61ad89fb6, 0x0000000000000000000000000000000000000000000000000000000000001a07, 0000000000000000000000000000000000000000000000000000000000000040, 000000000000000000000000a173bddf4953c1e8be2ca0695cfc07502ff3b1e7, 0000000000000000000000000000000000000000000000000000000000000001, 06819a246d9e605db4a1daa516e411f4a358f057793f9f6c9c64d2cb2d0c3bbf )
75 Dai.Transfer( src=[Receiver] TransparentUpgradeableProxy, dst=AztecFeeDistributor, wad=22027000000000000000 )

Account State Difference:

  Address   Before After State Difference Code
(bloXroute: Regulated Builder)
2.135655717132016384 Eth2.137900815132016384 Eth0.002245098
0x27182842...777E025d3
0x3c66B18F...7f97462d0
0x4cf32670...1e4d64927
(Aztec: Aztec Fee Distributor)
73.438957287015805483 Eth73.499637287015805483 Eth0.06068
0x6B175474...495271d0F
0x967359E9...e12C2332a 0.060926193342456178 Eth0.199598193342456178 Eth0.138672
0xA173BDdF...02Ff3B1e7
4.178700145419961299 Eth
Nonce: 13637
4.155783133877238843 Eth
Nonce: 13638
0.022917011542722456
0xABc30E83...5c909e7fA
0xC02aaA39...83C756Cc2 3,800,056.141773542109035999 Eth3,800,057.810954542109035999 Eth1.669181
0xFF1F2B4A...351680455
(Aztec: Connect)
4,365.806901058096189728 Eth4,363.938368058096189728 Eth1.868533

Execution Trace

TransparentUpgradeableProxy.f81cccbe( )
  • RollupProcessorV2.processRollup( 0x0000000000000000000000000000000000000000000000000000000000001A0700000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000D280002D67AA6341731FC42DC7F7BF358A9C2E0C5E66D176ECBE63454531A45D0206D910E882C439C1CE6B8F90E43D0695CD4E5775EFA3F238AAA75466B62481CF30162019ED373A28D4D80942B6B6A4AAB06419E944E3F31C31A1FFDFA3F20A18118423B0A6F87989F34EAC4BA66DFE115EE530FDB942E14BDD25D4C2CA6E238D1CB109A6B9F990F28DD2EAE41E25731DA622AA1238CB056FCA9F114C8967285CE0F012B2223A9D936FC3374B1DB03601431EEB98C6D438EB1EABF60FB07BB588345306D71A43999BA731A9C72F37C26740AC2B8D9065D821EF566098F2A8F031C137256205F41EAD53CEA25B45DF8DE8A5C786EDCFFEEA898A2A19E3FDBC094E9FA5000000000000000000000000000000000000000050000000000000000000000A0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000172A1F469AD4D0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000D7942374F8800000000000000000000000000000000000000000000000000131AF9FCBC38780000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000025CE3A0CD941A3749237A96DBFD6733AFFC252B7345318B62F9124DFB78037450000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000198342186EF1B02C76ABE5DA2C2C0417CAF1DEAF4544C6FC4C491743CA48F6770000000000000000000000004CF32670A53657596E641DFCC6D40F01E4D649270000000000000000000000000000000000000000000000000000000000000020000000E400006D6C061AA5CA8B901756BCEAFFB8C992C62FD6FBAA7E4E30D3C2C487C74383D1FF5BCE00000000000000000000000000000000000000000000000000000000000000001801815FEAF8C76B94A7FD2471EB367A38499D3392B94313412C8C0AF12D6CE52153106995955F6F7855A513995D8B0588C66E9C51D9F26DE60DCBDE5C4C8E52061DDF1FC666B0F1E90889397B2B8C2290AD82EFFF1A5FE4E1EDFEC02E37F396DE00000000000000000000000000000000000000000000000000000000000000002952CA166A56FAB23F21C23AEA668E9ADE126293297D2A0ADF69F302F1BAAB860D45874FAB3F3DEDF6EDE75941CB397721B5AF2D3A9B836BD89C8FC59300A6F7060BE3820A49318F7BAE1763124E44E1A2574B92ED171F08AB7CB1FA08FA9F6BE900000000000000000000000000000000000000000000000000000000000000001A59DC555DCEEE5CA7E007AD0737012BB05C66EBB633B86BB1CAE99228E73A152EC672213D811C8F81A7E0AE998FD29E852D862089BDCA76DC08699B5B5C41D206273D860C64C457FAA2A3B2DEAF98C91257E7430C286948D70B68F55AD15C770F00000000000000000000000000000000000000000000000000000000000000001939B547B8E899B03B8EF89D987D853B39A222FA29904771C1D980381A6195F116E5A86E4EBE2EA4799CD617F229E6D6A768C9009416AFD0F5C5C16B26A1C35B062227550146B29DABB0768AE6C57BF96A76C7850FCFE409ED04A12D99D71EC8E900000000000000000000000000000000000000000000000000000000000000002B1A6C8F750F0DF40E2952E1B4A14EF672B964A5DFD6EAFD7D4A1B21BA8A953624E490916057E6CD481ECEE3F19F1CA0B66FC5173966839D6E030EE661D5972A0622A637ABD9E268F8FE3564618A5F578FB2466674EDD63E05E2E4761A44CDCAAA00000000000000000000000000000000000000000000000000000000000000002FF4B7591BD81A7D1B84011FEF94E255C0AD436A544FFF64824C265DC8056D9C2A7EBE89EE7B39B16B0CFE5856E9FF0D43718C559356508A628C9CBDCEC73926060D41D498104B63F2D0035BF688CD2BF242C1AD940FDB848AA13B9A0093AF0FB800000000000000000000000000000000000000000000000000000000000000002A0EA4E1853F163DD6B375C0EA2B1B7D00418A0F5697663E0116EB9D53A2D3BA2CB71E379725BB620BB4EF52BE33BC9A2C0DDFAB940688FE3D22BC51C8B2B1D406249F2B8F0351535C7BFAF698DAB406FF941AB08824D8E750061916C413BB7A750000000000000000000000000000000000000000000000000000000000000000202F23C9D66AA64E2BB70E8C62F12D9C9401380CD8DF1B6D09B3024921C034F0111DAD1C1FF5037A7837D8F691733B691BCE32F6411A9E8D7663F53D0E626B5B060CB8BB939A9825D3C77B9772D1F293BFAF5D3561F6532C1AE9A0CE9363DB3A9600000000000000000000000000000000000000000000000000000000000000000E0EF815112EF78779208531D03E3F16FBAA103F60CC489935D292C76AA80B9B1E277E35513FA1C0E99159F361874882832B11CCDFFB6A73A4E4DE387F896DED062A01C2B5D8959ED6875340CDDF64FDE437E1366CF5A99101F604FD6583EAF61000000000000000000000000000000000000000000000000000000000000000000B9580285D22A725CA9A42381435874933516E4D53A5D310015E9EDF7B2F8F941F9ED721091CBED5E08605F04651FA69D4275E3D85BC9D6C266261ECDF96D136062D299D78495CE67FDE747462E5925B26BF0E620B3F5EB29AD1321BCCA55BDA650000000000000000000000000000000000000000000000000000000000000000129393EF87C03E28499FD1E45901D981A8D31407E26C3DD1E675CF437D96125F181103F895FD34763CF597234DD6384CBAFDDB131D9546D35166D41C699E48B3060D22DB0BEFE02D795A2A82C78066E943016DF20677D90980162E222439E5E1FD000000000000000000000000000000000000000000000000000000000000000003947893627373BAEDB671A704CCD5BB080E3EF8CB725922B86BDE3CBBC12E03254232660B2D4EB1DD7BEE1253B9D80D0FFEE13331392014F09452C9A88E9C75062495E8E5AD007DEEFB6A024E49FA9480835F1ED81E7C17653F87C9F7F2904972000000000000000000000000000000000000000000000000000000000000000006B91658CD8EABB13E4ED76220CFC2BA097E8503791140770E4F5D39F66A65B603D3297660ACF0657AADFAF5662AB1BA33561FD6B3B45480BCA250BB17DD5839061CFC2CEDC3AE71B0E4CD01941EDDF72AC1E38B81EB2423D44DFFD8CFFBD2888B00000000000000000000000000000000000000000000000000000000000000000159E23AC0BCD11BDFF64012C2BC51BE1947990FB8F7E9D722664AE063E58A4104EC3B7BB7F304CC1DE5254AA239AA48093A4C50FEB82FC19DDA35768861ECA3060E1CA6D399A64798D2BC78E5E5CA1C0C64DFF8F14F517028575930B574F92D3E00000000000000000000000000000000000000000000000000000000000000001BD37F6D59E8E6C468FE7482B76F3822E64604325D98EFC7DD8E3CC2675EC5651F3D9F13E59C55504DDBBA93C61E0BEAD75AA529415E5C8564784208E022BB030608B3B616130FD88E4EBAF914855E31346B4A389852CF85D3ABC38F1E6E60F8DA000000000000000000000000000000000000000000000000000000000000000013D2174BF378669149F5FAF369914451D1660ADB9A0898D3A909439E72D5D1A822D23667F87E31B85CA22009AECCE3E4499CCD64E3EC411E607CA333F03367F0060AF4B6AFDB8CB8AC5F6909C1CF0150E363FEC6D1E78E48C655996AAFA87659580000000000000000000000000000000000000000000000000000000000000000043FCE2839E9343AD0BB7F2644D92F7C4EECBAE7426188FB125659C1B1230D1B1A422033FC055912C624C3662C89F9DFA33C5D2B7A5D0B200C8C592D9B15B87206263F56E33CA390773B44A40A7C86B44DF450546B3B2DC3C5748F463EF391AF1900000000000000000000000000000000000000000000000000000000000000000FAFFDAD577B3F25D51DC640B12C95F5E290C2442030C1222F6667E0D7B16C76112742F28124AFC82631D4064F657E31F19D75CD4F79FA0AFE0F33840F54D5F0060B8D89CC07FFCC7E0B4B14FE2CF3417BE31AB0300757C4B8A7134A0DE75FC4FD000000000000000000000000000000000000000000000000000000000000000026CC08503B0B257F77664C365C5411B268954EE657CAE3EF9666D594E414924318F1C2ED6DC3C9F1322542545F35109BC22BA6676BD24B93069D3BCDCEC6B37D062B1B889F4D90BF7E06F3D509C01F6460785E72BF8D57AA756E74407351ACC14700000000000000000000000000000000000000000000000000000000000000001759C561F45F5747B911D02B2334A92EBDEABCDC2253046768C33DC077BF9EEF2B7C356DAB95D02838357E053883AAE9E80413BD5CED4D9319053D30D99238DB062C512060D15D4881DEC9E1731CD8B5481CD4F2CF7A3AE5BA871144C76EF8EBBC000000000000000000000000000000000000000000000000000000000000000010060F02F36A59D8EBC11F83065E8F76C5A8F726E554A7B6F0133E223182921911320D88F9455459E464CADF5D24FE4FF276627B9FD5F66F4185D90FBB2B786C0629872D7A4D30F2A2CBFA30B7AE3BC6B152E5949A4A09A5607248A79810C8BC6800000000000000000000000000000000000000000000000000000000000000001991F35489D6AD8933DB56BA3FB63A5A0AC49BC8C16180B9550ADC97DD0D19FF08B106F45954CF499267FAA31F6CEB12A2CC989517D25E17EA534A8223B4E6ED060E6B2C58520747602D80978809EA4C76F209FEB4B86A89E07E7C2E22B9D201C70000000000000000000000000000000000000000000000000000000000000000229C11FEF18D10AB612EC9AE0E74DB827AAA15602F62ECE126C4C35FE0381CA01C5E0DFC3D56C28765FB592EBB97666F54D22583DAD4D0D946354BCCCF566BBE061FAA62534FF68FDF26C2B48AC3FEA64D4955A5D0DD0BF6F8CF99530EEE89389200000000000000000000000000000000000000000000000000000000000000002EDD3617D1892A9F5D45868DBEA491F0120A583CF9336FEB12DE241E3177640B2A1737AC2FF0456130D86D492B35B330827C949B544A9809878E273FCCA737EA062126410469CDAD7EE4BDDA0E296CEBC96AEC03742BD5705AF2A57A5AE0CC2A2F000000000000000000000000000000000000000000000000000000000000000023AF82F3169050C247D17B63395E6CFFA1561CFF7F23E5A4E1E04483F7EFE97A0B870B703010CABC5D7D5E67DD5EB030BA869CD8F7CF467BA9B944D8EDDA47E10628DF73AB0B7649AE94EFB96F1DD75B50EB1D761008C54D9D577E37DD8B9EF78F000000000000000000000000000000000000000000000000000000000000000016D61BA710D68389350546AEF8DE3C760269062B519800FCBD872FBC50050CCE09F9E1F1E50ED14B923784E3152E9962ABBBB3B64C1AEE4D5C5790BFEE0C6AD206072FD846508AD6FE621D4A3DBF5016C3651DF9957F8B769BE446E8A8ED1239DA0000000000000000000000000000000000000000000000000000000000000000079E679DAF32C05FA7183F2552E93327DE4655C11FCE98A2C6880C6C1FE08BB722B1E4024F84AEFB02D691286383F0FCF413D0E0863F071AD76F4ED1A0D4FAFD06262648D68ACB8CD2CFB44BFFC42230870F22EEFF42CEF91E572BDA88606F42AC000000000000000000000000000000000000000000000000000000000000000008275F8563D4F6B683422352385A1810153E273B1E457EF6CCA192412C6DE7950766C656663B8DCE04C05CFAA4C53C612A81EC76FC7045F53CE3F31DC94A4C760000000006104865FD903CB1682A3C1EBF32F01CB77C8566AD5EA15A89785EB1E5D7DEC5E500000000000000000000000000000000000000000000000000000000000000002FA8AE78D187D9FC62DB14A951CB8AACDB57FC0687C4D4C567D6DD8C3DD26AA0135033BA24BFB2ED05556F4118C21D0338D4CA76736FC987F2D2621FC4F4F6640611BAF4C8B44FDE349BC2E4013C9378C0837D8D48E22CCAB85A128287498B13A200000000000000000000000000000000000000000000000000000000000000001757581E42CC376E9CCC56E69DE6DA0CE59DDF2F7A9AE80666E12D401BF65E1B1739377358BC325774E394F1F9A4AA60621B375DE02C88F2D838DF364491CA60062D5FAE3F0381EEC44D1493EA6D3726CF6BB07C242BF0E334F827D418EBFC561D0000000000000000000000000000000000000000000000000000000000000000071D1041C0F146B7CE225FBD2DCC1DC9F8754322206FC944AA4F46EC5069966D1AA292314F2BBE1A1699F31BCA1B2FB7B01DC8B3E7FD8068DB60B2A6314C0BB3060B5A5F4899D29D68E002D593CFA3788028EC6C0C6E016597D3DAE8B8646E85EB00000000000000000000000000000000000000000000000000000000000000002FDEBBE2C966CFB5CF4037021B99DE1914217FA1561FA3E7435C2FE0B35BD0ED1F4C3F06BCC948547189D014A27DF36D7B8A7FE2BA40D43F8BAEB79484323BA0060A42E6E8D067FF6AE2E252EAFB1E6F6BB39B6BD205B71EFE5DFBBB85D648A20B00000000000000000000000000000000000000000000000000000000000000000345431C9A673F864FC71105D95C796B7A43958FE4DE5092DA2E544E92BF2B4F29EB6DC6CD541672D5B641F5E6C1BF45EFA17FF3213A65FB94EF124118675DD906132FB831AEFDCF3F30319A433DAD50D77AF614F2DD40D4A7FA4A3ACCB50CD95900000000000000000000000000000000000000000000000000000000000000000544FE13036F6C7FEB37F3001B796845DDE66532514EFBCF73EF53A3E197E98123B64DF7DC19EA2FC860B216CA66331963F732542B2D6251AD0324229101EC15060C3F20D6D135B42F10BCCB5C1ED8C2BDD89E86D2D82E3B656C91FA86AE28ADC80000000000000000000000000000000000000000000000000000000000000000148A4801D4DF8CC87BB826C39A9C3AA6A9553F3CF1197818707DC7D34ABF693C04EC12F9BBF204BD7C029F089E98423357BEFE00684015FB495504D86F61A21F0604F1AD22986A88E6E680D94125C95C83A35E9663D28DD86004F17E6F1E1B941C000000000000000000000000000000000000000000000000000000000000000014F851596693DEE7B044BF13CE64E3B5BD6D1FC333E36EA3C01217B72E4EBE832CFA9417F8EEDD92DCD3476AD2703A1F8FE32B851D1E1761F1215A397B8CBA03061DE95D0A6895D83148BA8C8199F38149ABD2A7ADC25B2160677D39087BC0F9E200000000000000000000000000000000000000000000000000000000000000002716430E204FFFB9B273DD32A2075674E8163BA24909813FE0AD40B7C34E0D8E149B51F9D542325407916727CCA47042DF4B19809684C15454E004314455F0A5061E8B2E1D358F5E4D02367A54919D309F1C9EB2236C250FC61790CC66629D50290000000000000000000000000000000000000000000000000000000000000000101021CFB16318FA661C4F009530EAD0C5D3667E508541D376972D3AECF2E08E0BE01C22AAF34BFE7350E7461D2AEB74FD3DC68C47FBFEB948E94653B622B73406049FCA113C440A3AC8DE392E335CA23825B671CE78488B9E3810C0B52D49F7840000000000000000000000000000000000000000000000000000000000000000143731DCC50C3526565269225BF4A4D7C0955FD83CA6A504EFE7DDA246F67363197184C4EFB1D1B82E2A7587AC97375306149A34CB159C09F7CB0F8CDEB90F9106225A292CDA8C0B3E2A3F9888CC479D850DDEE11B79D4EE94CDCB253A6F22F568000000000000000000000000000000000000000000000000000000000000000005856C56B7BBBDBF5B2B9E3998E054AC0F48BC74B30D1D1024A60F6F8EA365C8213ED065047C43B582B7BAFF02F531C420E6D621FDC9545EAF03E17E2CB0C41F0308EBD9489D10280ACD9BF13E7DC9D57867795068FF4A945411E0160C499782AE029AF66C10F0519CBB79CE93A746CBE8D4A83A02571FCE6AAB36E10F817925EA15ED026E49BCD6AF4190999E56D99E9AA40B237A79960FDEEE9812E3B1E9F04B26F02DF57CC26A5C9B2A1F0FBE1FFD91D8D88ECB1D548029F0878D8D506693B60125BB9A9D50A0A0BB6EFD6E487BC4E681A77037CA6F3E7AB17C56720455BF31A32C342B35595E5769A59892A3A2366BDF73A8C315D1FDCE0F3C35CB5E4247A21B19AF483A227CB0BD8CBF4601F70AA8C1D8FEC213842051B47372CC88BFDC4E7505737B698C99862605128200489537488BD66B8C45D8FCD52C915F1197413D93000000000000000000000000000000000000000000000000006E193DA596E000A8515527652FF795574CB9DC3F506BA336D261D200000000011BBEFE67BF9601F3E79CA27D17EE1874D341BE6A740DA7B04D66A890A63B1E6706C5B45D06390EC4B1D47FB0ADC13F5BCEC4D2F6B593F4D6A118FCCD69A240D215CCC4A340BD291370B8DBF04BCA09A88345BDC2AC032B2804D59B365138DE721BAB4539358FDB27C7F66A753D64DEEC7B9B4F4E26C89920A21824FD5CDA890900000000000000000000000000000000000000000000000001F4E5A872E1E0004705B87381DD674BEC556D657D7FA911C5CD2D64000000000202EF9F8D5E2C73EF0C448E00C551ECCB011FDC88C6711C86AFD0BCE1B77D8E69163E69C58F3602E2B45476A8B30D35F63942993186CD88ED1B97F6420327EE4402E4DA53E964A08E660BE24F5816E687F2E3C28AD244144EE10285730322C1F20954B3C4DE28DD2896296358D5A3CBF612CB9F990B20DDB4BD4368453191F6E000000000000000000000000000000000000000000000021E19E0C9BAB240000096032FCD94BF017431675AE3DCB032CA17FB1F900000000104173F033E97D076F545087CCA85E3AEEFB8FDCE357FD5FCA89FB22F6B6ECA80642A2870F8E41227FFDC93002C36A1A3A06D9701E5D8C40D3BC565609C45334EE618AFC89B129C80D51B93269BEACF47FFB099677C00D12315B9AA93F753C5012A26297F1F70151AF97B30797E4C43AD5DAA199E434F73FB5C55554EE3DDA352E00126DFB68940A8ECA669961B9AC0887EE6D01AEF57B30A76CA04AB61BE00C1692220447EA72B73F5AD8E62F7C44AD384BEB25DAC6763DD3BB8B9AC5FAAD7A5417E22E0C6BA947E98665162771ED63EBC4A37105B75A259461BCB1D7AB650BB22FD0604E4B56817AA0B771C8B541175192C79F47524D060C69D956A9E161EA59F9B00000000000000000000000000000000000000000000000000049E57D63540006C37761F288B9AEDDE6F9DE3526D1A60909746EA000000000323FE6743B610249E54CEF7913BF364FE5C484717D71AF746C261334E2A3AC8281C2BAD0F8A490BD60B8D73BA9FBD84ACDB65BF8EC12641DBDEDF508B1F658E2E2A35587512E8A3925674744994EE505EF82ED115E0034AF0FF8906F24FC4D218133EE8400955360ED3AECEF02D9D31474B07EC17A709D6DE5EDAE61FD953791E022509E6583B7079F895A9C1B22D1D0451C967EC2612525FEE89202E50B33602242C01FE720AEB192511F4BFB0F02CA478ED1D4BDC7B8E060CEA7CDB8C87484DA12FBC4F6614E6BF66AF042199798601BD05AF2118E49844FFD4598307486898AB277201C8F4D715200DF27DB5E2F7105BBAA2C6CC663C3C76F1AA4F1D15863FE700000000000000000000000000000000000000000000021E19E0C9BAB240000096032FCD94BF017431675AE3DCB032CA17FB1F90000000010108F49A126A78F45ABB28E3F6257A0F41E6254E9431A6E71938BFF404FB60DEF905DFE9C77672BE60B0B78F5290E15A13F72CF5C686DEAFBD44487A0DEEDCCF5E2F2EAA194AB6293024E7B131D36BB3097E57DC8AFDCB57C06A2C181725F6DAA906C5B83FA51E501EE18E820E4DA59EBF2EEA66023FE66BB168C2B4702D33F599000000000000000000000000000000000000000000000000000A9F639FE0E00099F88ED13C8B90406DF960D1024C782169C9F7A200000000031A435AD334F5191EAAB49777CC1248A15D12AEC36721EBD166D22F861F8F3F2D29A9DD73F9114AA8ED06D9EC2414F97D791C930B94B677D1D0B2A8A38013B7E2015635586BEFF3B1FBD3A0FEFE15AB3F3E5E0188C9DF4E86AD04B4AC9358A3050EBE708442339A647BBFF844AE4F51FCFC9735C6F502938C2F1622EF4ED1086C0316BBE7E8E64F36092C5466BC5F08ECEB9FC71625F0049E90653A3407126F58F6239146D12915E52198F15320705A0552675ACDA73727C2C5B3B6A1AC6F66EB22134730609C76B8ED0ADAF5A6C174EA376D6A8599AE69DD49F5E0194D443B8D7A25BE59C1936EFB205BB9934DC59B8AE4315A77CE20451B51959B1BA30933B11A041E2FC862655AE149CCD8771A42288A7B1C406C7F343DBDC37BD4A53619B5628006A9124B1C47E1DE0F5E08B3F76E844022FDA280A49C2CC62DD0C9BB2CCC467F1F48511D9F91D9481FE63C9C225F9132A1593E744AFDBD64CD69DE5B70ABDD5E1B5163E1167DC7D6B575453C0E2EA6EE8CD6FCE56F4E203464EEE42CEBA3492A01223A00309C158CB88CB4222FCAE0011B381D9B1598FF800E3AEF40DCE9C9ABD105BD532C756E37EEE5AD73CC9A313B52F04DD1D44B9D1BD1B4AAD9A08A33190B0A1404408B503F7EBF957A744FF5810B677DE6B50F890C6F8CB3BD238B51F842006FFC0CD8EA275C84C8CD3D5D8AEA830784CC34CC63619CA29F77F368DBC36B00000000000000000000000000000000000000000000000001950265606500000BE4EB0E89ABED9F52D94F1550C22A16008CC463000000000123826B061D72B91DE5DC8B56D405A74100C52C86C6FD42C0F2BD672B9C8F665905DDBAD02395742A2FFBCE43F4AA81157191A3174DEC922EBFE8CEA1928CE19C2EB23F723FF3D9A5062FCD1EA2CB7E0D7AFCF1F29984577158A79F3D57BFFDC20F4C4F43BD6F6EFD386FF4570B804EFE8D6F18A4B6B9B748C992EA6585D3D6A2000000000000000000000000000000000000000000000000456715E89B47E000555F9B20716739EB6B3F99FC614D85B36DA64ADE00000000011A28A3B0FF3410C41A21A01BC3C696FFACC0F2E295A42D659D87129E9A924B272D7994830FE9997985EA79324579224E5ADE491450FE717E31C5FCE5DFE17C8505254F881486EC3DF3045E1C8EB77B0BDB7F770B32C66351D040E926C8CBADC80D5BD59A07D2315095BD0E5A1461E6989C94DE925B8D51FACE49DAB7C9B7E2F70000000000000000000000000000000000000000000000002B07428342FE8000C3FED190BF671AD5D92CD94932B1A2E17D047F2F0000000003243146511591626722CE80E027E14E8DD6E295C7E1C5308D4853A1AC239FD60C18FBBC9E9B36EF2613EB727A5E2C8A5B94F977BBB0D8A0360F55F3B6E542FCC229A7A2E10532D15C1ABB081C7635DC446C8973E852797446ADB253289F65CA1E08A3269A7FB8222348535B36D37AC50B74EC0F7DFA9720CE03DBE3DE4B551B2300000000030682C54432FEB142DBB180914958AC2AAC299F69089D5D631F0BCF2A2F3A5C730F79470259BD3A50FA73389E74278765B3317278383AC255DB60FB1F0B59C79B1CA7A57ED629716C75F9293BE758449189169B48DC382D09A39FE77224110AD024171FFD8FFC0B30D43FE10490AF8F066A14838FB990735BE70D9BE5AFC8F1D6030BA268AB721A5867D9503F1EAD799F4860A65BEB21CED08DD5DE2710458C387D15627F62863C80C5C94B25DC75851E61D2FA19F4AF0ED779949E75FC9D33FFE62D3D6454BD6EB1C2C8D85C32EE2578C480E5AD40633B86314638011CE84B38CC011F07E206D5010BB018B222ECDE004BBF9AC01DB10CCF5068C57570226A8C9101242A5D86A1E04CAD9717C41013DAB835EF06BB360AB3C7F4112D31F5CD871E571389419C549C6EA10F28A2E08671C4D8976A620DE1C68494FDBD07CBB67AF29B1138A735B970D20174040F319A489821F83E0078D0902620B74D46652B28AC870D350925E818D1EA88D67D1FF023D8164C4C0696835B0DEBF6462848DA0EC22200000000000000000000000000000000000000000000000000A1B832E62D0000AAF6CEA72797328191A0EEA3E9350976DE6323F000000000010AFF3CB3679D35D4B4EBDFD692193968C91FB8CDA639BFE99BF50AF0C34F77D4236D76C2BB39BFCB02E7553F5D445DEBD5FF7E14466AFA5F9387B2ADAC264A1A00B91617B719ADB7EBD18E15D92B75C53C493762AAAC3F4996C34DD5ABD526071286BD35D8C9851FA55F908373C421008D5EA99C89285432D7D711A8CBE4123900000000000000000000000000000000000000000000000000A1B832E62D00003B7B5BB8D173DB6C30A7659E588F1B59F14061800000000003128951255D9E572315579423ACA979776E636067748D4B0953CFD8E908B130392C853A530FC731962A8E171117D520230121596250BF6E1E49D534766CEADC7F21701E95A19BDE58456EBEC0FA663CF47433862D5AB1BD08BB0F3E6FD5275C3D257A581F25105F3E1985D88D05136FB940557B1839864AE1E51320D234E12D6501106643EAEA2BD6C1C10965136D18889EB2F530212D300BA2BAB389CA164A8509276B19187992337F1F46889C56C78FAA6174ED28FF43AD22C0F5EFEC5DB67B6E0BC0DAF56C7822A9D983FFD10A5B76CC80456354446E6E1382D8765CF3BC3F2F082F1F7EB431AE819746F82212558F8FE8D084D2D68BD27F6A202480DBC7D23500000000000000000000000000000000000000000000000000A1B832E62D0000E214FA4D0DCAED2878A15B5B607892758E37F7E900000000032CAC4661790128EAA64FA5F4627D8350797DF675A91D86D367F99DC9431030F60CFAF620549ADD43E30508F7C0C13EA7E867C203C45AA165BF42140C2C8B34A2131BE2D7FF20850403132523EF18CE262D701AB6E0CBAD8512A32A463F30CAD02722375CF7096FB55BF787E73DFAD73EF742FEF3B59BD962CD52941BEF0A2C23030D490FA7F38E9A1DB29478611BC01B16941DCD508B7BF7677EDA192A0F7855F11964E805AC1D5533C99042CF536F64B7B2FA5412954BEE8F7EAE57388EFF2BBF0A05F45083B6A3509264BADBDBEF5E4BFE3247D2CCBB270EF39E2E40592E67960666C8EBB463E8C4471C883F29478B1F2444642BC46904DF2D5ADDE8CBA52B3001013278C3B746CE05941EDCBDD4D4BFF4D60D2ACE2617FF51A95F25BBCCF8FC980BC57658AF445EE3FC381BCF2B5052A37873A2C8B1F21AEFA1D0AE0569C336270B87116A38FAA4AB0A6D6F26781622AC632F38B1BB6F464FDE7D9C63CD106FAC1940B84F3A3EA5F2FC73714ADE4C62A5E77092C282751646B5D393B268E2B22E00000000000000000000000000000000000000000000000000B37BAC1E0D8000AAF6CEA72797328191A0EEA3E9350976DE6323F000000000031BB89497629121A58A0DAF1CB0866019A2D0F19BA00727949E6F4EB268D2528E24DFA1B068E7E3BE994A3D614092424EEC2FB9A99624B0669AE2B331D41F4358155789EF99D8ED33B66638D4028F59B3561839194E1F2F05791315CCB4D705F503AA9BD241FD9C46BA5B22F816F4CC332A3F44C2375E4D566B82224FDA2CBA45010A66E8A76A41CDDBB4CF6E55603046AFB0E30579AFC3BB472CA7A030B04CF55E2607D35E18C07E5471A9C9779600CB502866F931E2550FF941DB936BE6A88F362E60443AC50898F9C6917EF299C14724FC8301E3E18E789AA7E74770D820BF322619C7718F5368A1BF61B7AD87E2D7F86299D4192E71C75D1316F4AD1CA8723E00000000000000000000000000000000000000000000000000B37BAC1E0D8000E214FA4D0DCAED2878A15B5B607892758E37F7E900000000030F54AA35B7F0728B3B203A2895A8F54DC47F3D800B63E4BA1C053160E87B84DE1492B50FBF9AA0F6A9A4B6EFE21BC7B843BB9890F414CEC13932AC36363980E2107C3CBF37D50C5B4B7C952491B5189E3855DD1FC30BA10DEB4C0AF3A0872C8706FF08D0D117A510244EFD82BBE85E29E7A985C178F8339EF44A061D6FA47B9901119ABEB3D8B205D93FCFB0BF7C4139AED1195C32D4634816B583609441E22A8F267E4DE478B53C1A16840C18EC2B8D88935F5FE9F87B2BD9A1CEEE6F42DD93A21BC4208AAB73CFA47080E96BEDADE267E0D13BA3EAF05D6689AEAB0062B5C59D1942CE4CE38EB6EE273B33707DF1D9925C1EE8FA18F36475BE3018C3EFA64B4B00000000000000000000000000000000000000000000000000A1B832E62D000051B971BCA3430E31FB80E0549BB801EE704E187B000000000329A6EDD2615DAFB6EE9145EACA27F328A846BE215DDC4B247E677C8670DA4EF10DDCCC254157D25D2E359FFA9C5FEDCA596FD75F359A1D7305BFB9AFD6DD174D1F7201EC7A0A400A8483B576F1511AB23163D774312DE045D22CF9721A4C97C72710A0DB8F58C7CC50A2E8853CA82F38E24FC16C85CD870B74FD6AE7BE59359D010B79995E9265406A0B6B73BF4B2325F5A4B86FE71F6F544E5E72DF991905CD6F2953DF78A2F9B8ECD750A585190063263261A735E553BB402722CC5E96DAA06901E5897DD5BE8867E93F702ACE96DE8577E6A457EABFB86B865A9F045A2D84502B3D53A0B0A71D2BE88BAA510439540A4BAB3FD15CE4DB430E9503938DAAAA3B00000000000000000000000000000000000000000000000000B37BAC1E0D80003B7B5BB8D173DB6C30A7659E588F1B59F14061800000000002140E062A75E73F81B1A01CB77018D98DDB0FF4759D552E73563DE00732A878112025FDC70D35E61310B99B05E0BB9BBD91B433DF25EF2C8A96BC2887DE65083E1A4D6A82A0A8E5CF484412240CA4C37CC2195EC5B8ED672E3842C583590343ED0BC8E53DEABC026F52FE0BA8DE660040B930C35B40DBEAE29C6A3ED71E9DD60700000000000000000000000000000000000000000000000001ECA973044B0000967359E9076C48D3ABCC02606FD4D07E12C2332A00000000011B3DF4AA4531410D7E2FB221AB2E789B29B3060E1076389DB312CFE5374F1DF5303FE7AB90D1796C333CBD4936DBF1EB8BB26DBCCCED696882E5443F9BEEF73C08B432270318939D8F7540084429F30E5B6CA9084E4CB4B20701B14F8AB4023E14E244F079588EE477A9E10B31D61033A0566978ECC29C10FD6CA129B2A8310400000000000000000000000000000000000000000000000000A1B832E62D000012227588E1CF33D2C52DCA2B811E3DA7E06C042C000000000318FD85E02936D07A403106EF67BE5FA6386B8261DD029696A0B62BC26187FEA304F4C44DF1AB86CCD2C2F1F7B58BE56E891AF6206F870E93BAC43C09C4A2E07A00AFDBA2DBF3B4CB32C917B7C2E2923FDD1D5EC5DC5F01173E3D52B615F9C7C90FCD34257DD5A1C8CB9B0143DC2B4FEEE8E6D3B6A72E6BED50CF8CE2844948BA012CBD861E24184C358714F8841F63078F94B48CC2E4A9786F1ACF6BC505AAB2B2257E1D4354BCB35BE3CE7CD202DA49164FE27FE32885FF9A7896E973D0CC80841A52AE877458835137B4F8C9A9B1802015005CF1D7F1A0F44EAA61B4BB4E71FE0E184FE1C6458F0EE241C4BB3B675F0410E08572AE96B1F2FECD5EE05B31AA5300000000000000000000000000000000000000000000000000A1B832E62D00008C2F6445F33240015E97A3900417972519DB24E900000000050B340A48216FDE448F5811393FCF78E0D8F5C0E8B979FF8673B4F1E2C2CC31F11EAD686EC5FA7CD2DA3474CC8F53C8FAB51B8D1D9032065336AD87B94D055AF71418B75E415CA8A0798093961B2C672D42832CEB71CC3DB899E441B9B71CBDDB1BA02DB784B594ED7508057074B23AF31910E9A03B4853185BFAFD23B4B5CC7B05107B2349016CCA571A1BF1E5EA760DC85628C06173CF00256A396E29FEFB4DB50906C9A50151EAE54CFC2ED22256FF9EFA4447A586CB98D5700533A64545B15B25FC1DF45DC5BAD309BDBAD312924880AB35C9C6710CE0D7C65A93B62423488C0D373E33FEA6CF86320AB4503B2A53CB92E0FA8B07228EE1480DC3F6DDB9A92E0510E3BE4948AD76A3DDD5DEA95348679ED0BB5EF685ABF9DD93F47D2F253BEA19055BDF90E660C353D03895E5BF82F7E0D684374CF32B2E1C9864F9F23B676CAC2E66579DA71D73F3CE186CC0143AEF65983550A432CDDBE2D03B28B60EC449DC20E027FD24E64A45E33BBEE9304493797DD7E043307DC055FC4939D4E07931E505090C69708183BF9C41244EDE6DD5D980979D6E128E6B9BF4CFF28E7AF6A0A45D303D817E535F53242CBA87EF9947F60E86B6DADAEC28D338F0471AEEB8D0B3EA1FD8FF0A484D573111DF7B0DF139023676BA9CFE31C8F083F504CF2C1982EB85057CF2D7246B9853A3E769CDFB244799C0DC79B43D0A1466BACDF803BFA23054052D1908555632373D55A374FFB1EBF10366735A43321B24A3227A2601629009AF1EC9DA601EC2DDF85A413B10DD23576728B7FBFDC776BDEAC808B193CDC24253114F12A443C2253BC11DBCDE972EA2B179E818BEE05D569B765E68D190ACD8B4108C83DD1957286D132A764F09C78DC6B11AFAED3765C6332631C37C61D0611D0524F3B9C27687508994622B9EB23957B3CE647D9B42E8230816BFC48924E9583214D07CB313D08A7044A793B3C94A0F3D2D8D99183846433B11160CE0877A13131AADFE20423EE986EDB15D96AC961C96BAD5CA0946821E3772F8216F542261D917B27D6DA3EAEB2E269BF03EF5214105D8FAACB5DAEFD56CA8451D4280D3442A050359DE378184DDDC09F2E4A45E9DD9CDB877CF1C7352DFDB0A999B3C8E4B693028918DA0FA050F0B308F2EEF863265E22BD91B2B0775BDA0EB867920E23825DD2694FBB0FDAA2FC714CD1FD08CB268C0E763DBA219A87ECD5FB15A4739D25BF2150D1F9AA19168CA4355C7F4C473E38B12B2571B3F1C189CA186C2AE0C084A8F0528CE922BB7B8E29BEEFF2AF9C556F92A0DD1FF285328B861D1B730CED761177F2E484B99006BC38E42923AC2F9D0994F040E1A759C7F12D8DAF0634AD10AA1710CB92DEBD7E204428F3BC43FF3422353EB30774EC06F7F5F0C7D66A0ACC4E0B108118DDC7B59A7A8FAF9AB81C59B152BB8C9171EDA9662B8E7CC1285225267D00509EEDB4096C8948A1E1B698020F63EEFE34FBCC3C881E6C504D24F98547322311587753E23D8B227AB95EFB9D4FFDD9ED88C14E088C8204B1536FD1F1CC2582C2D05C2F1DCA24E445FB79332F36F94B5FAE9525FEB355CAA048D8413F82112891B0359E8660AE1678555F8D05CADDD13F495B99EE4073FD5F6A74B59F2255D410000000005049BB2DD9DED38FAB9CBB32FCE8568FD9AC5D3FC32632B4197DC81AC1429337D0D53541B4E93BCBF6D9281053DDF90B0C43A2A8E888A595C640A60E14432C3AF20AF83E4E06367BCA3CD78020F48A97F2DE683C68619BC4BCC19998A6CC8BD5E106FBA4BC87EAF9706D82EF20144543C8C6D8406E97A31CD35779564F6B77FE405130C1D7DF0B2839DA511572C2736A16EF335710F7445102DE84B5290E9B86960243605C5C16827065F46AF5B61430F18E2C1770B985EB680257844887FEF16E32F9D9ABD8BD512F22ABF5A9ABF07277C0BE2D35E8932E61ECC36C1AE581939DF1D884818AE42111D0C474E5BE7B46F42C5FFC5C202638337155FF159000F66F0051FC7E2433D606BA068C6B4FC58B1BCCAF99CF4AD57188D79F70563B2BD5CF22F1C2F411DA1E80696B4068F8C3CEA0D9009385767C5A6D1973927326E9CC255AF07A9B22A8BC183B8C96C9A717E0BE8C2B43A1D23C3F81D4AE194600AA65B07D70422C1FD19CBE9E8A6E87E178C2466A2E292DECF003CE6EA6598BC62FEABD0660512CB4456C49098A6DF869D576B4C22EBD19B3F2EC9B98465DBCC98156459DDF82AA1ADB37A9244FF6C93111A15AC3823D412E83006CA1F53E8021C59FBB57A2F2012D1302ED0D791AB46C66956823D7C6269B33608E9265BAA5810E8BEDAB95E27397B0104742C462EC95B035FDAD1B6D59D27108D66ABFEB8FB7D3F474A55E705243D87082DE81EDCB137DC4BB19D7FAB80C871E989975D30CC5436DB365BBEF2167DC7A0BC0530B44A6D29937FA7663E7EE868B200161763F578FDA2631ED7EE17650FA1901E8A50AD78AF4BBA78BB5C90BCE53C0037FBC904F95C6DD5C63BAC278B79A1E9D07B2A669E17B62490C319D84639239F48F104B2E802466D6CB2230507595231E838CFB3232B505CCB75D0B3BE7BCDD789BF3B1842E36367D7A48C0413058DD63E587C4BEC562A4373CA1DC291DAFF8F479B18A583F896FC6490E0BE2B178C607A8FA397F886252ADB0617D577FE4CDA261AD137D06C3443B4D3DE76009BD5A7E8C22B816E65F050041A378ECF98D6BF2EA9A781E387779023E8B5950511A50ABCA671F4BD1FEB0973AB531A3259F1A5D7F91A36E2ED54D5E64616ACA820B7D78BDEF5BF6DA390F88001928365D2F88D387F30EA74DC343819DEAC3C94079BAA1B99DBFF492B74701CF59E136B3A3A3910F2183D0664ADE9577955FAC02C8E003F7335B8382DE35855383F072E9EEED7B751094F283D7B02D5839C7299052C4719A9C11599E72AE1057C46096630CFBFAA248AE10700CEAECDB18EDBF6AF03033462D132DEFF70C90E9AFB7B4013B5BCE4264F20A8ED9D79594A5FCD51641289589B45844E27ED0ECDB100055BEDC0C92B4A1F9CB65381CDD352EFCCCCC700966AA949AF4CA4D7EA29FE1F05C32A824EF3D9FA3242252D5AF2B8280D5C6E05166D7D691900A958FD26F4C62E44755930A283EC9C120E019081842C252575E90C28C9928ADE32189DEFED75D9DD5CD6B5E033BD323F7DFA0A93DFCCBE176D3D2C70176E138E990AF0B480CFAAD0E24608D4F0C28684E3DC1376A8813A864C102E86DE65220223F648E16DE762765E09B5E1411CA052823C6D00C0ED521052900529753BB0CE3B745A5528E9ECD66B8AB20B9CE8AEC18239C9E6DCBAF8CF7F034918CBF28C512CA39DC04D4693D42CBFA4CAB8693A68A319B514FE342F04757C5E2FB48FD0222E2BB239AADF8F5088006FD9544BE0BD1135D80419ABC584B8E3092C5F1788DDA98490E3FF974864C7208C8D9930AC994F28434CE2A57509383B80050A27B313C9FFCD77A43AE89AAB7F2E9C3CACA4E5A40995FAD2F5C7A02A3AFE100AFC3FE2D348B358E0B45B9C270C79232DDFCAE7AAC2E088A1B5F5AE5B6C028F02E10E11C2713C5179C7AAA854EACBC5D68052EC788D53DC104001B431D456F6109F08875D36C79398B8A0B4D72267379FA170374875C5DA90EF369B8838C26D05026BBAB99BE31B025C8213056EECD4D44AD17394406A31526797344BBF7E33D40C51E74CC9F4C58FAC6C24C0AAE972732F088E9C8642D37654A4EA1931E25C3213213C05B1843D00587C59B121E75FDD363B86EAD3DE480DF8B37DF39F61C97606E9E241567F03F75D3C415D5933E0EBD5D661C3B058229517FC1EE9EE1165F40524C0CF0DA217897F8A4A28ABA48B97146CD77D52BE8260A23075B5635C26E8D8139C096219A4D6F4AC061C6F474E1B62AA5AD17C5107965C1E639DD535BEDC250974AE169B132765A6716470F22E546B85F9C822831B5975D037C16CCE3E78C11980C060B5249F4E58A5F280B4C524E1C011E68090BFF1FCA7132C45BC3D88590103E5507A066A80AEFDD56F12AAC3016FFED5640A33BF7AD254FD54127C22A0A112D6231920AF3DD8234F1663C673FA9A50106F03F57174E2BA6D2966BF092471065545E67932C2E2D500180065C99C427FB6A70768EC89A482E7D979ABB744AD2E9FE8F3247142CE1698601B8738E8BAAE1C02FCEC325F03E9C299FBF03D0E9800000000000000000000000000000000000000000000000045656A72343C800030154CA0C486F1242955DF6EF1F0221F10FE7E26000000000312EE0511806EDC4415A3E1AFBA664D6F4ADE237B315B0DE9D47DA43C2AD58BF727F153BF96AF2E8BF8398427AB4E6488561CDCCECC6DBF92EB75E78CF03589561AF182DAE50E10E3B96D3A7636812F88D61E457DE6A6ABEBC2998C885A4937F11BB8D448AF6799DC442DC54CEABC63F886703E5AB7A0C8A0DEF844CD6F98A92D0525F9C7A2DC8A05FF58244FB9380AE3E6FC0CC80FCEE062FB0AB740BF331AE2D525D6B4B8C76753E624E8D669BF669C11BD480F576563C41B2F441A86DD6485B91A3094666A7C007A8EA64D3DC72D75DF3C0D05512E902047CFFC55D97A58D3E20E487AB689CF28AAE8881BDDE97676D22B94752794CB73FFA7C300885AC7EF6D012EC2182F53FF3CDF2DE4A27FCB49BBE26164EE17EEB5B35140406820AEDEA3C50E86260AB6173D19B44556B65C3CA300A9CC9108044F07C37714BB446AE8BC2422A37F844D96C2035D723FE9ABF0C139E1BF4C2A80E7E47572B69175271395FB2ACFF4D43A44F9510B02C83BCBD67A01B641FB6B299C5CF27ACAF60F4822334100000000000000000000000000000000000000000000000000B37BAC1E0D800051B971BCA3430E31FB80E0549BB801EE704E187B00000000012F0F52F23FFE1E6CF531F5F696320080282DEAE4979788AC7CB38E376FF75E1A2A5F83ABB9B3714BFF4454543C3841C0DED3FFD15C026E922AB59496197F2F3E068B5B1EDEF966F16BEAAAA98DDFFE64BF91DBA6E398FB8975D7E009ED04BFA50201326E38872BAF915F7AD352732E107263DC339EBECE730C72B7D39249261100000000000000000000000000000000000000000000000000B37BAC1E0D800012227588E1CF33D2C52DCA2B811E3DA7E06C042C000000000113E8F62BBAF8A2E1274D2314FD44B8B718E7F495D261B5CE76D19FC228631A06042F51B732B41C0ACCB7EC31341E1EA0E3043F3EEF3D8FC3977A855BAF5F1B0B2112CE800478FEF91367DD11252164D7C4252F3CFBFCA65C0A6C67D8CFCAB5AF182CABBC86C4035C6528D9A1B1825B112A96BDD59A0903F489F6D58D05452F0500000000000000000000000000000000000000000000000000B37BAC1E0D80008C2F6445F33240015E97A3900417972519DB24E900000000030F785C090F968EAF0F01730BE62F107436D19934C9FD3785AF662A1367A517CD180B1B6DD363078194443E4158376553AC41810F3114B4161FAE404442A05C872AF9901719D768F06626B82FA8F48FD144182E63A58575714B21152DAFCA63E205132BF0903281F638EAC452A588E331344925502E7E78751B40A6993D7806090116AE0C24BFE8AE99FE1C174FC48EC8CCE0CD8F1E545007B227F4922A680A38A2263AEE5F618838ED9E25CFE930263EB3D2661645415801AF2FCC3991F8D9F8A2047256863B50369CD7B174B324E3CEE65F53ED3C5649EC77BF68D8298A2687252542459B698EEF8A2BFFCB42308355607116FD133B3800201E64D5B18712CC6200000000000000000000000000000000000000000000000045656A72343C80007D80960ACC9B35ECF6B1D9146F7A60732B2109190000000001077CAF8DDEF9842DD2C551689DAECC059CF3D0CE08468C0DB865F6A17FB1D34A08399EE7ACF519DF3DA0FA7921D016C5CA573AC152EE0816049A3FEE0063A36319481672D88E5B39DBDEF6D5A3891260588D60A5C604B5E6C0E4C4165A339BCF18EC6F3FED855B15E50E2DF53466F67EB720BB287D22A211A3B1BCAAA16549BF00000000000000000000000000000000000000000000000000A1B832E62D00003774980BC1D24E486C9024D51EB78CCCB55431FF000000000413D884668C429DAC784583640E1FD6F82B4DDF80B0A4437DDF1D29A91737557C299FA21CD876228412A7F92D871DF21687FD26EF00009237C010FA0428281FBE27D860C2F0CF0126DB3A27C4C8EAEEC81CD68961983D0364AC010C6BE4E7C5AD1A668FFD9E5CB26D6259B52E96F272FAB3C5E224C94001A81B38FE9ED52E1F590106C93E07293B4CF315C4A4E8E2E0762F668EFCC07C61C374C48A1E5DB2CC9A3522B44AB64D14B16BAC0F83E36791D16F4CA7B0AE7609ACFC49F64F9F548053C20595718955FFF0F157EAE1A9BF816940664A62EF458BCA33C2C40A7402AC3DD10DF3C4C4E10D2CA357BACA97721A45D6CA1F3107FAE281E43AC3E19076D3352F00000000000000000000000000000000000000000000000000025844398D400002221BFF009F87104BF5FE2A8B5C2DB4D8107F1800000000030BEC931BC8B728D44F7EA523B68F0726F7812BE4C56C273D55B0BB3EF4C4E78B2D845A8C1936B0392E55FA4B5A14678CE61A2705D0928F36EBAD17DAE2B8BC2801D7C21C03687914DD8C2F325AB4279E61C7D483C8B94667B3B468C555C7BEC02434724A9999F9CD73C0D20227954AFFB81313D26F992FB08C4AA1E3077E79E2032D7E4A0C76CB67A2C0383110B67F3CEC3CBB96DC8C6CCB52C165D16E20B0979B1B7AA88BE7B7E12B945F49C6827526024E883DB7EA7B25D29F4C7406AB894734289DDCFAD6C8F58ECDE1B479EA5DAA286FA5210831F43AFB4E0150B0CBDC15DE0A9087DE75FB302332BCF4DF97550962FE6F4B164659A7EB06E36E1839330D33010A9749946ECCEBA27858665230C1437759369C67C51217B7F00A1013EFE2D1AB0A13628CE1CF157E130A4FD662D3ED425BFE21A306B9FF3BC5BC2878E6A3582227B117219FDD9248AE0D92DF493BB00550C65C8D62D57DFE5997E6CF0FF91C3E11FCC12F85484FB1D9346A63FAAAE3775538AC6A34E9BC179D2230C51F504B5A00000000000000000000000000000000000000000000000000B37BAC1E0D80003774980BC1D24E486C9024D51EB78CCCB55431FF00000000010B314BBEDAAE625715B645158D0072C90E527D9B20416230CFE44D79E80ACD3824B4D1C3639C98482EA8BD365F38CB7D2CEDC076E4E80C46A542927039A3AA450AC739FD1A46CBBDF5545F0F171D2209733FB92EEB3967C5981E00DA6A4961BE28D434DBA4D888E0FA126CD4CA9F88ADBB7139A0C44917760944831F66E3B38D00000000000000000000000000000000000000000000000045656A72343C80005BC7E9895BD55C2D88DE7FCC2D3B8D63A12FADC5000000000000000001265DB9739F38D7EEECEA22549AEA6E530251B0903E3503F947F48F70317E900A2B3E8660C3830BED3174C049887864CB5E2D7F234F6C84518DF554B5EA54201F043374D667E5E8E1BBCF6CBE744BD76338F42B932A3B8DDCE79D83D7F8C4B4EE28883DD589C5F1A247CD5B491B926DFDBA9F42831869FDEC40467EA13DAB56AB00000000000000000000000000000000000000000000000000A1B832E62D0000C5353BD4CFFE9E94FD10FD4E67F70316782F7590000000000306D7B7DAE397739516DD3E37F5102A4D20D8CC804086D7281368FF5AF682F62D19C18CA70944CC5AE9F17613608EFBE30BC6F4A2BFA259522D142FF0496BEB490707456C5305A79B91C2D0DD11B15E907326FF5311755C68C32A21C8DA6D25CD16163063B13B64288770173B24EEB91A65DB14EAF4FD4DC3A2AB55EA2664871C050F3A27B3914249F81E7F30F65C7D71D13C16DAB7673184228A2828F6B72645CF1F3EDE2F02C905858B5BBE287BB2C93D3C9753637A9512B7362847B1C809E7710A8702DF3914709CAC5A562A35270607E9F3A59B08AE6DF60E61CF6C48490721194127326FD5FEDF240B37F827B9B921D7FA6306B63DB7435D4D3F0CB192E5DB0121750A7637D2157CB4BC01FB152284034272D378581367538E787E3193D600B41877F678231F79D27214A5E862827D7FF2FD236E3E78BE251FD79D7F6BBB5BE70C231C4E6345C61310CCE930754B1EFE35C120303A35E8629DCD098C195CCD2511F8242C0853C02D4EE267D7C3BDF7239C67E8B785BE1BF4089208B813D7A75300000000000000000000000000000000000000000000000045656A72343C80008C9555D210C9019F952B0CCF57F8E65D542281F200000000040481E829FC959905951393786558B24838CBF105F6409E5F2E92B44DA971C92A14DFDFDBF46C188AD1696C68788C4EA4D759D102B7407BCA9A4E6A4EFCE5B14D15D48B818233B20A1D5931FB6F1CBBEACBAFD8E6407B85D938BC4D0760B8FA050A028A02A52A913B16FD99F2B46F33CA0398A0B4C6B6E19EB0872C0807071E3001295DBE4AC19169DF645D7579206DE899771859CDA36D3CC766633E9A3ABBC76A0A04AAE1222907AD2DFBC0A23F7A0E7D974A9FCEA81D980518615423946529230485918E7B6E513C8466C0A9342C68F329D9CE34AC2E617A5BE79B98D6501F192B2B4E347BAED98884334897CC97C3197CE06CBDFA72932ACA60FEFE28644503000000000000000000000000000000000000000000000000042C28AD522B4000A35C484E148F782E97DE734DD65AC59947D42E0F000000000104F1404F4B5F209E51449C5886C9BA799456201CADF2B2DFF2DB5428583B63D80CBFA504567BD4E7C79316A21B5DE406C1308F83000A992021E1CD9C5B1AF7B12375332C166679EE821CC1F7A55ACE3C5A60A489E0A07CE4FD57F5BEBE99624902CAB55477D18AE745230507822F5CAB1CBB152BB8F1C22378EFFFCA3ECBE4BD00000000000000000000000000000000000000000000000000B37BAC1E0D8000C5353BD4CFFE9E94FD10FD4E67F70316782F759000000000012FDB045781C7F2471391F6993CC1666F220F597075B7D4CCAE32219412535A661BAB652AF85E9E66DFCFA0EF2174DB1D284128212ABD57B1E0E061DFE299CE7B1C622CF223D87C61A257B1B076766982D04627E6099AD276927F4014A0B59DC91C4F96C16C613F90247BAEDE56B43790EF3CB87DFB9A70A15EDE81E4882D748900000000000000000000000000000000000000000000000000A1B832E62D000085E9906E4AD8ADDEB9E4C19E3AB280F2EED671E00000000003016604F83AFD01ACF3BDDF2B23122A8915E2D2724EEF9B332A29C721AB3BD6DF07F67C4B9305B47967C343E59704F0FCB33CF5C0F16671B8990E9509DD7E3671137ED3582FD29FCDEE9518A4E15936727C73606DBE587DD4DC14AB58359F4A7527D328C2924292508D3DA21EEF1CAE71EF319CDD6DD28AD7C2C45402D2DBC059011A8D6F7C54A87D99AD62CF0F93400CEB98C7C692FD0783D79310D43CCA0D22FA0A0A48A6AD50352B74DB8725A99C282FA3EB2846AB186E73516A4B2EEDC6F9122B0738EF7E5B6C52FD63D1BF015B9C2147F60238DFB90A04A78C3B09D1832B0F1C42110146CA4FFC58C863285E3189B07FAB8A5F5B573D94728669ED9A4560B10000000000000000000000000000000000000000000000000005666E940F000091B4210B7A1CBC503B192A130B10DBE8C4929C7600000000012075A8207201137F1C9E59E168BD772C87A3F877EC1999482C76B1A3C5363AA40F77ACAB889D431544D2CBA2F6E39A55774B23E00C5F98F7019128AF68ABF48E291DB2BCBEEB12CDF5117C51BE698B5DF46B5FA7A22CB3B08B435A0366A261740930BF0430B70E70559F964F80D5E9AF44E8EC3B2A4A036A6A9BA65433B1018600000000000000000000000000000000000000000000000045656A72343C800071D45C20E17B4CFA988294150C234D6568B12C92000000000105AE5D2E30155218BFCE29351AA2EB8D52E28C69BE5FE69502842EA6DE461BB920F97BD22F23C8699E6D7B8C35320DCA09F29E993E4509D60DE659A4247F39460CF65C03E7022D7D7F53D69ECEF65A1CCC023470B1DB257FE843103C3906F1DF014EFEE56EA6DDC5DA7C03156526ADC1517927CEFF1A664762B07F55A5CADF7D00000000000000000000000000000000000000000000000000A1B832E62D00004D7F20D72A32AF1632771C91C85B9F2CA3ED87F900000000011D5E860F47D69CC6B5C854BE9F48ED09C3D685FB511D515ABAD848A5859E254F2057D2BD86230B397CC54F14AFEAA806DE5171AC9897272818A5E3F1952CA82A05A05AB4C34691AAE1EAFB423240E62B9A32A956EE8FE63CBAA0D9ADADD83C50254F2F98A01DA4A702301CE2AD12AF342BC27A1BFAA73561337A77F605F43E98000000000000000000000000000000000000000000000000002C1FEC981C4000B7B1BA671434E10DF9DAEF5D24054939C1BF79D100000000031C466FAA99CBCB29FF12B19B04736DE54804111351127ABD8213BEF829177C23020D4793574B0070F08E1AFAD0BF2399D79E54E34D1923891219FB3263F68C2C1C134E300E6922E2E0EE5EC11AE8BBC2F1EC5490AFF03C44BB667F7B0FD8851A0D72CF21F4D1C8CE8AFE3D8916B090A65A7EBAC77BAE08C70E0EDF500B9084CE010EE257774107CEC3675B652F972E9DF2AE0BEA7D2ED6AC6A26EAA745E84EDD2409F400EADD0457610B1CB3C0AF277C5159F652BA323F91DF04421C6E77D3E65A0C01E0300187812C198816147B711E27356A5F597A4BA845266F5C824FAA30962F0C78084481B0A69A8224C7949B1DC4A2EF03D2F7FAB2F7D670CC1394B28E9900000000000000000000000000000000000000000000000045656A72343C80002B6ACACB9A48264CE9ACA0C9752BD7CC9CB31A8C00000000030473DC16C9003AF56673F2EF9BF2D37FECCC500AA6C46078C35C241E632DF17C296290B209D30A429AEDBEDA643A0F3E901BE6C95396D242C806086107AA68FA0979E11060E5DBF5E46E6B6472D91157F4DF67200FF28E4B760B83422C2545580910549F0B47A2B31DACA1288C2612176F8D68C924F4C1FAEC14AB3E58765366052354D1F3FDB549931335B3E1CC7BC6E01CD304ECE9A62C70F49BF6C15036B10A25D3C552E6031D54AFDA3178B05E2EF6F5DC674114FB05B8396784A46BA14A39138FC3848C26437C21B9931908CA2DD9FF188D653AF668C7D69C74FDA32F4290305F923A22B63A47DEFD74D4C1325861983A73423FF1FE4EE4CC030E113731020107264D8BCF6E9109BA913FF73CCFBF7ADE2715601894E2E79677FD57D06B0DC6186A48ABE0CC3492AC5939CC00EA22327E112F3CF77E25BB51A2E5FBF5EB6DC506930D8F84B24D9C14093FEE9C8FCAD103A148DC0A96FA1B2B96CB6FC21F25B60DBE9B8006D9C62EFDCD0748FDAA270062D60958EE0416F3721E81E0F74C497200000000000000000000000000000000000000000000000000B37BAC1E0D800085E9906E4AD8ADDEB9E4C19E3AB280F2EED671E000000000041687287F36F40D0579B539F79B54496AB2A086C6A99E5C8D8B5423B5B7165AF81687287F36F40D0579B539F79B54496AB2A086C6A99E5C8D8B5423B5B7165AF800000000000000000000000000000000000000000000000000000000000000000B24BCE58D3BFE652BA869807B44BD221C8D9B3256063207A7AAF56E9682DF66040179030FA4926148881DEF010DAF578C74A0D8C83D5DBB0C87CE4BB84114A70E0179030FA4926148881DEF010DAF578C74A0D8C83D5DBB0C87CE4BB84114A70E00000000000000000000000000000000000000000000000000000000000000002F70308BE50EAEEF0E3A25AEE84A064646F2C99AD81A1E95AC87652BB541B77404032FCC3148C053CA4178827F76C3BCC012E64C99C8214AA41776CBFA0078F197032FCC3148C053CA4178827F76C3BCC012E64C99C8214AA41776CBFA0078F197000000000000000000000000000000000000000000000000000000000000000014C2EDB28B8DCB174422822526EA3F54F9692DFE51C46136383E30BADB360126040C18141FD81099D415A7D8DCEB8B17883C51D841E28CE3E1537B16A36A2BBF7B0C18141FD81099D415A7D8DCEB8B17883C51D841E28CE3E1537B16A36A2BBF7B000000000000000000000000000000000000000000000000000000000000000008AC0FDB1697A5072B7E07815D47B32D5CCA3FBD5913202ED221C93FBBEC570A0411D6FF7B21E16B4B92485191E33663B75D4BDE1047194173126ECCC7B56D360A11D6FF7B21E16B4B92485191E33663B75D4BDE1047194173126ECCC7B56D360A00000000000000000000000000000000000000000000000000000000000000001B7A83317C4FDA149F6D1CABF388280E202C31F2BE2BBDE7940F0DCD3AF3B84E0412128F6D584EB959FFCBBF83342FA208D5D17484A92F39A8F7A5403018B89BB312128F6D584EB959FFCBBF83342FA208D5D17484A92F39A8F7A5403018B89BB3000000000000000000000000000000000000000000000000000000000000000017FBCD04423682E3FEC706CAADC900F1975D0C68D778D105CE2FBEDD0DFD5FEE042D22B55604BBADEB575A94A03B2AA046721C572EF07D4057CA07D15A854C470B2D22B55604BBADEB575A94A03B2AA046721C572EF07D4057CA07D15A854C470B00000000000000000000000000000000000000000000000000000000000000001382CFAFFF83B278B9A01834BAF91FF32B3CBF8705BAB33E951D7A4FFECEE47304264381CA96F2CD94E72327BBC2179C2E262AB79E39C91C0B532D77DB72DFD656264381CA96F2CD94E72327BBC2179C2E262AB79E39C91C0B532D77DB72DFD656000000000000000000000000000000000000000000000000000000000000000004394A3F997200C1BEF7D0F782ACC9D6B2F3E5519F3AE9AF8B24AE05F8AA62D3041081B650A32B7DE5C7577FB8133C0F7C306B250D68DB88BFC2B6AACE90F5DF201081B650A32B7DE5C7577FB8133C0F7C306B250D68DB88BFC2B6AACE90F5DF2000000000000000000000000000000000000000000000000000000000000000001289AB173101F40EB448886875F86E31F77E06441FDBDCDAF5F89D94E9692AFA042F0DD0226CC948A5CA6FDE8CD7C4A3B80F849FCC23D422B340D721D0ED40C21A2F0DD0226CC948A5CA6FDE8CD7C4A3B80F849FCC23D422B340D721D0ED40C21A00000000000000000000000000000000000000000000000000000000000000001E8E9065923A83FCCBC5E2C6F7575B9ACF55992CB212EE34CFA6A16754763B7900000000040AC534D63AF355BADF9B2C6FB980231396922DD5F2B92F10C5AEAB9D795A39230AC534D63AF355BADF9B2C6FB980231396922DD5F2B92F10C5AEAB9D795A39230000000000000000000000000000000000000000000000000000000000000000057AFC67B56EB71529C5B4CEE00D7DAF9523B33BC1761E1E1116BEE40F56E976040E3CDF93433EEE1AEF44FB564025DC6FC1BB5149A5795028A039FA75B03447C00E3CDF93433EEE1AEF44FB564025DC6FC1BB5149A5795028A039FA75B03447C000000000000000000000000000000000000000000000000000000000000000000891ED10F367898219F9C7805AE0AB5C8D258CD6891C5E1716F1A281FD38D8090418349F5C52E401FD258D90E844D74C276C896F460E0169F561C32187BD06829D18349F5C52E401FD258D90E844D74C276C896F460E0169F561C32187BD06829D0000000000000000000000000000000000000000000000000000000000000000251A7C9856C35728194C269B4BFCDA99EA9EF84E0DFC07ED1E98C67234BA12A10417B4D8F704091EC3807D0CC4FFABD0FC1AF3F0DA3A5B00226DB8A98B8F08749117B4D8F704091EC3807D0CC4FFABD0FC1AF3F0DA3A5B00226DB8A98B8F08749100000000000000000000000000000000000000000000000000000000000000002744B6803ADE6896D5DE0BEDFC28413337E9FA485E851C72D29D0F32A46E0A52040203C0D7BAC87C06F44FBA020FEAF26E886D251746AB6F86971676371DC684760203C0D7BAC87C06F44FBA020FEAF26E886D251746AB6F86971676371DC6847600000000000000000000000000000000000000000000000000000000000000000382BC95585CFC9DB25A352721CA063E721C8129447514F06BF6FAF0493BE070041128D417DB05C85CE774377E96EF30DACCC2AD87435C58A955E98FDA10BD12D71128D417DB05C85CE774377E96EF30DACCC2AD87435C58A955E98FDA10BD12D70000000000000000000000000000000000000000000000000000000000000000281607DC16ECB84FE246705D51B2129FEF1CE9F4DBE7C15E0444DA5E27D46579041A5FB15CDF28E3D88639049023A19B074026A35ED3DD764902C7DCE979F8413F1A5FB15CDF28E3D88639049023A19B074026A35ED3DD764902C7DCE979F8413F0000000000000000000000000000000000000000000000000000000000000000010C57BCDCDFBC0600D1807AB552C2692029B1156871C70B32C078E4265F4E460408B4BC00824BE7CF7CFCBDAA8CA6CF1B1F6CFB9581655F0EC17DC9F3AB8C703908B4BC00824BE7CF7CFCBDAA8CA6CF1B1F6CFB9581655F0EC17DC9F3AB8C7039000000000000000000000000000000000000000000000000000000000000000005BCDC24AF2B93B9F862FDF99C5ACA2767E66AACAE2459EA87EA8A450C0D97B104173B19A591D887FC7547772DA180E95A8F6C2CE83043CBBEAA95E6B3400FFC8D173B19A591D887FC7547772DA180E95A8F6C2CE83043CBBEAA95E6B3400FFC8D00000000000000000000000000000000000000000000000000000000000000000C57AA1D83555AB71FB151CCF01FCA34674A760B6CCDD87700B7F3329FB244E2040EF2C4F57F07B15E62CB6FD8CA599F056F2D667ED066E8D2EE7670024BDA8C810EF2C4F57F07B15E62CB6FD8CA599F056F2D667ED066E8D2EE7670024BDA8C810000000000000000000000000000000000000000000000000000000000000000089F5B4E723BD0F48697AD2AF23A8ED2D3BAC5CC388512FCB566DB0AF85433A4042FEBF5BF9832F626E9EFFE58780AF1CABBBBB41B1E6C185A5C0B3D0CCAFA99EF2FEBF5BF9832F626E9EFFE58780AF1CABBBBB41B1E6C185A5C0B3D0CCAFA99EF0000000000000000000000000000000000000000000000000000000000000000284A91DA1C70B0F6B82DB670910738054AC9013AC7E15F90B8B46F2EE340FAD80402729826230622C15857ED05AD58CE2ABFADDC5EF59803BAC7B09E4A9AD1A65302729826230622C15857ED05AD58CE2ABFADDC5EF59803BAC7B09E4A9AD1A65300000000000000000000000000000000000000000000000000000000000000001E87B66461263322DB41C70166F2EB611F04444A61C3DFC8159B4B2B4A7C1C19042B08AE9923A89BB323A08AF6B9FC2DD6D8641B4F0A9800E95EC1446043A0DAF42B08AE9923A89BB323A08AF6B9FC2DD6D8641B4F0A9800E95EC1446043A0DAF40000000000000000000000000000000000000000000000000000000000000000005E21E7A196E23DE6A595528528593419A64C8C7B15180634AABB2057AA8535042D85B8AD36480CD8675DEFF0CD554DEE74B142A5807CE50FD40952CC9A34C3012D85B8AD36480CD8675DEFF0CD554DEE74B142A5807CE50FD40952CC9A34C30100000000000000000000000000000000000000000000000000000000000000002CB35D3CB91AD0BE9A47475F2E3C182BEC40E5A467D7ABEF874E2ACCEA7A82F604250426881BDB7780FB461C62D52CF1776437418FF31F2EB4C43618412DE7F2B5250426881BDB7780FB461C62D52CF1776437418FF31F2EB4C43618412DE7F2B500000000000000000000000000000000000000000000000000000000000000002074801A32A646B3F6B3136315286AF722D2800DB0F6196D88F34792048E6A2304119406C7C0EA15446B43C911739DD31C15A99248370289D45CDBEAFB33E6BA5B119406C7C0EA15446B43C911739DD31C15A99248370289D45CDBEAFB33E6BA5B0000000000000000000000000000000000000000000000000000000000000000296D59040C6FF1E4B59D443D10A03B78839ED2860E707E07C2BA89E78B8D67FC042F078D51BA4A24083C83DEB86F4596B427FA4511C120772BFD0FE4076594B1A22F078D51BA4A24083C83DEB86F4596B427FA4511C120772BFD0FE4076594B1A20000000000000000000000000000000000000000000000000000000000000000122A623ACE5C13F982E799E4D038F04739858CE151988F7FA3305D4D35572263041C2E83826954105437552FEB052BB01C3E6CDE570433CBA1CD0555B387ABD1661C2E83826954105437552FEB052BB01C3E6CDE570433CBA1CD0555B387ABD16600000000000000000000000000000000000000000000000000000000000000001F7FA5911241A1DEBA039EA9133B3AEB595079ED1B13602110FF69A78F3A227E0422A7CD2A7EDD33C9E8478EA7DB15869D6EFFDCA4D660F60DC83D968EC4351C7222A7CD2A7EDD33C9E8478EA7DB15869D6EFFDCA4D660F60DC83D968EC4351C7200000000000000000000000000000000000000000000000000000000000000001203C420D56EF9F9A52D8A31E0834DCE6DB2B7E43F7E56FEF128F7B7F5574C420415F714AC0A1095A01D9D3C1EDCE072B6FB99EB0926666BB5E1058A266EDBBF3B15F714AC0A1095A01D9D3C1EDCE072B6FB99EB0926666BB5E1058A266EDBBF3B0000000000000000000000000000000000000000000000000000000000000000027F09DEDC0C5968FAEC2C1BACB55A28A303AC7EF757C6C125D174B05CBFB9AB0411A37EA5076C89CED127FA3D9541C9EF178F2CEE4289C82B9B404C7A20F969EF11A37EA5076C89CED127FA3D9541C9EF178F2CEE4289C82B9B404C7A20F969EF000000000000000000000000000000000000000000000000000000000000000000D0CC6BF26E28CBE6330DA93A399F3BA60498A2BECC97BEAC4B0F2F4D2D61F7042639856ADB47BA3BD6E5C31BCE6181B80828D57EE42D394FD8EC268615BFA99A2639856ADB47BA3BD6E5C31BCE6181B80828D57EE42D394FD8EC268615BFA99A000000000000000000000000000000000000000000000000000000000000000010A67484AAC9621FCCC942694943AA42F24EAB701FBDDF02FFD8D6EC9D8ED3F5040FD8F00846ABA8DB52B38D4B1D7BE40AAB72E9058B891C79882AE5866C1D84380FD8F00846ABA8DB52B38D4B1D7BE40AAB72E9058B891C79882AE5866C1D843800000000000000000000000000000000000000000000000000000000000000002E510DCFECC42579743F1CE483A4E5345E017CDB740597E2C0AE0E8B584F782C04074ABC740FF6F749465BCE646549532324C1A5889C1B1087E27923D18904CE89074ABC740FF6F749465BCE646549532324C1A5889C1B1087E27923D18904CE89000000000000000000000000000000000000000000000000000000000000000026B0D51FC86BDCED58157337D27E710BB178ECE536F63E48185238FD93E8DBA20419F48518B72D206851792ACC2E7DE9D5ACA2947F7092CAB2234591EB330E0D9419F48518B72D206851792ACC2E7DE9D5ACA2947F7092CAB2234591EB330E0D9400000000000000000000000000000000000000000000000000000000000000002DEFBB2A5738CB29601AD478847F9F49AD5385C0F9F477AEAF51F1445259B47C04188F9F202B9F745A4552C226F3F7D8194572FED2132E41A5269907CEB86F4FE7188F9F202B9F745A4552C226F3F7D8194572FED2132E41A5269907CEB86F4FE7000000000000000000000000000000000000000000000000000000000000000005EC0D2E11473DC6F947F7DAC337EFDAA73AC63DAE3C9B6EB5457466BDFC8CF1040C546575AFEB2C281C98103317D059DEA860835B58F1D7713408696622407FAF0C546575AFEB2C281C98103317D059DEA860835B58F1D7713408696622407FAF000000000000000000000000000000000000000000000000000000000000000023C1A4D41F5D5B8F3D36BF516A70699021F09663CA01FFEA82A8564C33CE026204030F008685661B35B7487D8402807A5AE32AC12BF67931167254A94B3AE2814C030F008685661B35B7487D8402807A5AE32AC12BF67931167254A94B3AE2814C000000000000000000000000000000000000000000000000000000000000000008C3AF3A28688B1D6AA2BACF5508509876E09ECD551AF6265C9D6CE5A1FAAFAC00000000041910BC3748AC3D3CA8FE50E20754D8C204931AEBF2880B6A786BD74ECE1950CB1910BC3748AC3D3CA8FE50E20754D8C204931AEBF2880B6A786BD74ECE1950CB00000000000000000000000000000000000000000000000000000000000000001C4D93671564B5061E3A5D78C0B5D4CAC65062E0111EBA3ECE3E3432535034830400ED5DD636D0198C5DC706414E1C2BB599BF4A2B6B1CF460409F8FD5FB29F12C00ED5DD636D0198C5DC706414E1C2BB599BF4A2B6B1CF460409F8FD5FB29F12C00000000000000000000000000000000000000000000000000000000000000002A343481086C707F323A69F0F062A1335A8A751089EC693FC9D69FF90B1BB9BE0412834467A7519E0C909AF7E360F13028CC192569427A4DD0755815AC9CA5A98E12834467A7519E0C909AF7E360F13028CC192569427A4DD0755815AC9CA5A98E00000000000000000000000000000000000000000000000000000000000000000BFE92709EC08ACB8ED8D6F544E66FF3A4ACC1A9FB1D3972048672AAA62821F10403E61C33BD3CA13D37910999972DD606A54962CDA454CD5DDA1BE5EA6DEC141C03E61C33BD3CA13D37910999972DD606A54962CDA454CD5DDA1BE5EA6DEC141C000000000000000000000000000000000000000000000000000000000000000012FE9407491AF92A3B48652B88D0B829A84E35C7C63D42F4036ACFC12D1348C6040F394F11AB41ADA5630FE4480E190AFF750A03D236B6AC47A8D0777EE0214DA50F394F11AB41ADA5630FE4480E190AFF750A03D236B6AC47A8D0777EE0214DA500000000000000000000000000000000000000000000000000000000000000002E7BE350BB06916D6526F19D5C0312F40979C5B6E93ED88FDD1C7A3C08B1A2CD0427CDF8CCC2C65DD4FA8030DC01D6387090BAAC60B983F168901CADE8CE4FA24127CDF8CCC2C65DD4FA8030DC01D6387090BAAC60B983F168901CADE8CE4FA24100000000000000000000000000000000000000000000000000000000000000000F0CCA5496BFB2AFE5F35A0EDF639AB26D80D46B2B0AAB86F2E134F5C3D2668504180F927AD32BF35E663947249A176B6D94E3C6BE757D514BBC6C3F3DAF4630EE180F927AD32BF35E663947249A176B6D94E3C6BE757D514BBC6C3F3DAF4630EE00000000000000000000000000000000000000000000000000000000000000000BD98C63230B81A514797C9C7832B2658C8785A5B5620E74FAD468E8176EC2FF04087A59FD85B21B21A64595D7C178ADA125CA537839AB15F0B81F0EA337C3B7FE087A59FD85B21B21A64595D7C178ADA125CA537839AB15F0B81F0EA337C3B7FE00000000000000000000000000000000000000000000000000000000000000000774D5E12F0D3FAB377E8EEAD169E8D1397C933A998F8AED944945D802127F04040EB39B545B5AA8CF501585ACC0782A7FBE23E72AAA37DD6B4305330C49FC92A70EB39B545B5AA8CF501585ACC0782A7FBE23E72AAA37DD6B4305330C49FC92A700000000000000000000000000000000000000000000000000000000000000000A509CBE98E2151F81FFA9FE091700895EA074E45B05C814ABF95FEBE08DD7F9041862F6F2967FF2E1D2723BCAF3F802AE45C17590038CEF9ADE526DD974AAF3021862F6F2967FF2E1D2723BCAF3F802AE45C17590038CEF9ADE526DD974AAF302000000000000000000000000000000000000000000000000000000000000000008975083ACD602BC740E35481723B3522B88A4F17BA94AD847D555E68F437C1504212FBD7AAD8FA28DD99FF6DB03A951B43C20296A4C9FBCD79636CF0E22BF10CB212FBD7AAD8FA28DD99FF6DB03A951B43C20296A4C9FBCD79636CF0E22BF10CB000000000000000000000000000000000000000000000000000000000000000003F520FEDDD9CDE2840C760ACC08F94A33F369D4CB3389568CDEB6B99FEBC9530408DB85EA20B12FB1623E7117040633241D099F492DA580E3405B4E7A1E9D5CA508DB85EA20B12FB1623E7117040633241D099F492DA580E3405B4E7A1E9D5CA5000000000000000000000000000000000000000000000000000000000000000018597D5E3DEDF464F27BEFC61B9E62669C7379D367F5EE30973A2C3BF75DF703041253FCC23618739F75CCC205F17D53EBF489EA0FEAF632199AB168DDF18769D51253FCC23618739F75CCC205F17D53EBF489EA0FEAF632199AB168DDF18769D5000000000000000000000000000000000000000000000000000000000000000013243AA8ABAF360FE5A5C127202829BEB41B7BD492176F987523479A149BDD3204211D6B0511ECC0389EBC31DCEF5092893248E61EF39E3043EFE8B281E8EABB9C211D6B0511ECC0389EBC31DCEF5092893248E61EF39E3043EFE8B281E8EABB9C00000000000000000000000000000000000000000000000000000000000000001F7D5CF8B3967D880A80EC7F923B01CF1726AE057EBBCECF7A8FDD1C71F8D83D040ABA0B0C30870D5F0299AD9A0A7063B648B87BC39197BE8F469325FBB303F8D30ABA0B0C30870D5F0299AD9A0A7063B648B87BC39197BE8F469325FBB303F8D300000000000000000000000000000000000000000000000000000000000000002FC1145E1626E3812AFD8D51E5A2358DBFB1EBB0FFC6D14F7E12DBA619B873D9042E7160FF5E5988A991AD055CBCB6675B03191C318E5304E4CB229FA1DFC0451C2E7160FF5E5988A991AD055CBCB6675B03191C318E5304E4CB229FA1DFC0451C00000000000000000000000000000000000000000000000000000000000000002FCD4EEC061C598706F6A0C768A909B009532A3DC513E8D21F5CDB0BA7C9DE5F04174E2BC5FDD26A12D1F38FB4163B4A036E373B0C7B44296E69D9F30E9A136308174E2BC5FDD26A12D1F38FB4163B4A036E373B0C7B44296E69D9F30E9A136308000000000000000000000000000000000000000000000000000000000000000008FCB1D77F68465E7A5CF004FA2F2FF03F363D6A2060B467881211A7D5CBC0890413EFFEAA6B8EB23335518DACCD4081753B151446837D45CE778A6DBE482323E213EFFEAA6B8EB23335518DACCD4081753B151446837D45CE778A6DBE482323E200000000000000000000000000000000000000000000000000000000000000001CC7DED579843277E156EA77D7F0F3F6968CE774AC4DB95A3768E8DFA0AB5BD70402222087C69148193E83596283CD804AD74A68B141F77673C6527D4292673B8602222087C69148193E83596283CD804AD74A68B141F77673C6527D4292673B86000000000000000000000000000000000000000000000000000000000000000025CA8A3CF9532B8D5B14B5357185930CB0AB3A8E74ADCD4C50DF5E9377CC2F98041750B2377C1EC36134B0054517D5F11B18C20E5C56B4D46A59A7125D2CB4D5B21750B2377C1EC36134B0054517D5F11B18C20E5C56B4D46A59A7125D2CB4D5B200000000000000000000000000000000000000000000000000000000000000002A741AE17C241AFC4A7FF14EF6E0BC809544AC31737E07FA8992BA483C8B86FC0423162ED2E4C66227C33EC17DD94196A5A68E6FF376B37467F3903513F35E28F223162ED2E4C66227C33EC17DD94196A5A68E6FF376B37467F3903513F35E28F20000000000000000000000000000000000000000000000000000000000000000149BFE97B50345BDF8DD04F7CD4AEA045D29EB56452CC2F31CE8DD90F0437A740402C5B540CD3FF8BC03FDB932E28FA837CBEAFAB4DF8F2ABAE2A344A16B38DEF202C5B540CD3FF8BC03FDB932E28FA837CBEAFAB4DF8F2ABAE2A344A16B38DEF200000000000000000000000000000000000000000000000000000000000000002E8A463B52FCDA2030D2EBE911B089EB496B358ED80166B425CDBA43FC246ED80410ABB1B112F20FEBB7BD51E45899BA63C1E2F1EC11B425C5AD2239964BD70DAE10ABB1B112F20FEBB7BD51E45899BA63C1E2F1EC11B425C5AD2239964BD70DAE00000000000000000000000000000000000000000000000000000000000000001B0BF8A0D3544E294504C4D39515BEAC1DDAE0673476BD8EE2B320AD0DD38C4B0419E79973409957F1A07D939920B306074877717E617D660C6613EA356ACDDD7419E79973409957F1A07D939920B306074877717E617D660C6613EA356ACDDD7400000000000000000000000000000000000000000000000000000000000000000CFA966A1598627AB91B18A7325F5F739C467A03CE57F9CFA371565545D3D32D04077A0607ECE7858F49AE03D92D6FF6B67C4FCA12B003D506548FDD1110D76AB8077A0607ECE7858F49AE03D92D6FF6B67C4FCA12B003D506548FDD1110D76AB800000000000000000000000000000000000000000000000000000000000000001298FB38EB42148838C5900D5D38587FF9C2C5E2DDC4A49677ADF62DF7B4C3B4041D123671699A176C45DC7DC0D7640CEE29E0C050B1F3823A8F1FE386D5F664DB1D123671699A176C45DC7DC0D7640CEE29E0C050B1F3823A8F1FE386D5F664DB00000000000000000000000000000000000000000000000000000000000000002C2970D363BD92AD72522E030F2DEB04896B5C5A004423E7CE2B8F09255C3405041EA511C674828DC56511EBF99E0349B254BE51218E9109187DBD1857587FB85F1EA511C674828DC56511EBF99E0349B254BE51218E9109187DBD1857587FB85F00000000000000000000000000000000000000000000000000000000000000001EDE18E1611BB45089F1BCE1E836047A63EE9E9F4E1FAB975686633EC84C4AF1042459EDAD4B4EBD44F1A63FB483C4B8064E66BFC61879DE4E241B5EF1AACBA20D2459EDAD4B4EBD44F1A63FB483C4B8064E66BFC61879DE4E241B5EF1AACBA20D00000000000000000000000000000000000000000000000000000000000000002293E5B3D01F007DF9668E77A3E0480B9EC55ABE66552B9DDF0C092D4A403BF60000000004184557933234964404C6A4E8E669F7C88A1B9E570B5E40C5304B2A00BB260CD1184557933234964404C6A4E8E669F7C88A1B9E570B5E40C5304B2A00BB260CD1000000000000000000000000000000000000000000000000000000000000000028AD1C4FEAE31D7A368397B151A2EA6D8D73F130F3DE69FC3049159407453B65041BE1C08C51199E47BA02C97467323B9BAB38F8D7F411820EF1F970ED6937C5B61BE1C08C51199E47BA02C97467323B9BAB38F8D7F411820EF1F970ED6937C5B60000000000000000000000000000000000000000000000000000000000000000281F9F5C019FA60B13AB63ED36034027FD472F8EA47A59A21C170C2153BAECA5040228AD4544BB11BB210CAC2E17200A9779C8D68885C7A7A1BF6D8A13D3FDCDD90228AD4544BB11BB210CAC2E17200A9779C8D68885C7A7A1BF6D8A13D3FDCDD9000000000000000000000000000000000000000000000000000000000000000023DE1F5643F18E1FA396891FFF24E5B44AD7FAA241C8177402B550A8E74E96A1041CA58741D519DF0D73929B92197B7BCB87F839FC0226216D5914FD07609C79911CA58741D519DF0D73929B92197B7BCB87F839FC0226216D5914FD07609C79910000000000000000000000000000000000000000000000000000000000000000002DF0A990D9EB5E254858B1CC2C9BD45B64816F80E76A842347832D10D19C2912E3DC7083D3586EE8ABF34E756C562A32B26D2056FFC23336C6786F49763DF200000000000000000000000000000000000000000000000543D6E000A5506EE400000000000000000000000000000000000000000000000301E6CAFF8BCC737B00000000000000000000000000000000000000000000000744C9A1F398D9E2B100000000000000000000000000000000000000000000000000002FB49BF0862C0000000000000000000000000000000000000000000000052DD62F8C80B7F3CE000000000000000000000000000000000000000000000008B2242BA00A727A9F00000000000000000000000000000000000000000000000FABC53CD3EB70FD240000000000000000000000000000000000000000000000000000EF5317BE9AB1000000000000000000000000000000000000000000000009E1247B66927AE65D00000000000000000000000000000000000000000000000F7F2C1785F3D81FD00000000000000000000000000000000000000000000000031E0CC144DB24077E00000000000000000000000000000000000000000000000000026F36C189DB4E0000000000000000000000000000000000000000000000095EA6757544D19FB000000000000000000000000000000000000000000000000490C7A78CEDE1A92C00000000000000000000000000000000000000000000000E1B7C127735E5767300000000000000000000000000000000000000000000000000014B3281BE3078045B7B3EA97CCA3BBEF1F074F689D2DED8318FD989ED876CA68A6DA4C94FDB770249388099CB5728858FC364CD46D0FE6B18D81E4887D31C74BAE02279716E2F0254B83049F6E887A4052EC692D87BE8C68C9210BB78AEB5E61DA9C27378199C11D41E3AF70F26475B2E484B05AFA8986411481A2B5E0EDEF8FDD249D3054E830634F5291A20CDA1FC8EB3BAF8784B628C4F47B098797B44F3F04DDAC58E20CC21BD74CEF26A3691726830F811E99CE1B59260BBBA8FE0CD659F89323ED03811054F4FECA4984628E7472B810B43ACD40D8BF24C8B6316A052105C111C56E83F2D4F5A06D5BCA819EFCCF4BD090100CD9C1DA1759FF13DB636AAF229F5DE1376116129AE48F72577FF827668F6E4BCEBA1284595CC9E7586EBE1EB38AB4BB4FC26240EF9964A01B22FE3926DDB5D5B1B904DA8AA300391C9E9826C55908278E6209B3ACD605F5903BD3A877FD231A6F29A19C52314EB6D6C1846D6B6CC77198C0EE175BEC60372974637AFA5A090492662F9879A50E1E38C009CB1FC0ED2430B00831CFFBE369E76695D6D46EC289FCEEC5965154A3D5FF078F51AAD7A979E992E3364CF0E6BCC9E004C4D3396CE32184BF498AC9734104FA5A9932E8A330C9A05FDCBACF34EBB8D11D0269F0CA9401443D575BAB0AA4C1C5D24CBFE965D050F30433D8088096D3D961F6135135E25D393D0DFD767909D8D431A65C3C1CA31A525FE122B3672AC7538E46C2BB2DE9303594B8353B604E9B5EDB86D9AC215CA0B1E0A6FDC5661BC888A5E4EA80566A2B7286BF60CA44248B3FEAE0BDAD35F6DF11DEE7ADE9E13AD889EE093F7498E59CD866CAAD4B3061D4F469DABE3879F6BE31A63C6BB2472599DDC822FAC261FB3659DAF61EC1400DD2EE26953172BE828C6243A9F3FCB452C956162A559E6A5B6CA51F34C63EAC45016A6D301E9D34348521796EFEBCF6D778F26D5C5140E10DD39CAD7E0C7F5E69DA32C660B060364C25C13F2EF7A6D1C02AE1E207BE809B68ECEA4377FBBADE733DB913CB59943E10DDF163F21C27B6B0231B7B0A685CA74C47311EEA80E59C9760C0AE946DC61B80F24, _signatures=0x263615A187D87360421D96F743FBB92427EF1EF2D8AAF885A905A2EB16EC1852500DAD800413AF94E05F0BB5AFC8F09E1C68E4E67FA2D08FAFA05C5EDD2187A5000000000000000000000000000000000000000000000000000000000000001BF5627B2E6CBFE8E412BA0C928182FD410FAED1961F2896540E7896BDDA7E5BE73A6AC4BC382802D0C3D0ADC30E4D475492E72583D5C024740E4DDADBE48D9A42000000000000000000000000000000000000000000000000000000000000001C8466855D2A9EC39EB73E69B447101525D03F1CA6CB2DFE601F7402691FE8DFDA015E26C4494DB7CEC140255859C73801AF89A3C6DFA920400B0E18CEDE94D183000000000000000000000000000000000000000000000000000000000000001C9A8AF693B6AFCD653C8CC96443D11D502D050107E0D6A7F2771B355CC55D7AB55B634D31A0B059076AC0413771D8633DB4458C4D631EA6C76DD23722BAC7D100000000000000000000000000000000000000000000000000000000000000001BF17A2B6FE09E50FFC24A70EDB94A581835A4C58F394ECDD3A1BA713E8995DD960747684594D44537B5818E9EF8B17BE465FD7583412AFD234A0F411A63E58376000000000000000000000000000000000000000000000000000000000000001B56AD63C81F54D5DB6DA0B63B85D8ADE5112029518188FCAB8AD795DAD696EF8F09E1505B1CC7946081D843F81EB6CEEF563EABE8C78194AD96E6B912C1E286CC000000000000000000000000000000000000000000000000000000000000001BB217A9C2213A9BE15C917EC3987AB7BB2E95B91AA4C1C7F663AB2504D3549CDB4FDA9FF477884AF264FA64AD0A108050E5FF6B4E7CD0AF977F20703E1A3378F7000000000000000000000000000000000000000000000000000000000000001C910C72CD56D19465097A9355FE1BD7DCA695D6D059E0FEE66BD26204FD18C4F76CEEFB10AAABC536DAE7D9691F8C1A3A1B512A54E6B23AE51025DCD0D96CDCAA000000000000000000000000000000000000000000000000000000000000001B232E237897978247FC3C1D73836D9309707CAED99A384F91F6C907D2043B1A14321ABC887240D811C33AA24E24CDC2AFB8D2B12506AFA88CE2200F6A482C9ED7000000000000000000000000000000000000000000000000000000000000001C7BD572D99F4C12F3B7727B2B17CD0BEBD606C51F41F98206BB4CC309FB40A6B6204BF1D73900C79DF84707216F365CD254E4F13ADE82970807E350B759813B6C000000000000000000000000000000000000000000000000000000000000001C134A72A44B008EE296B60612BF286D921D32A4225FABDFA030E21AB85F6E099A3B4C0D091D8F86791C90B8654EEA5A3382113AA0336757F40684F420B05D2DED000000000000000000000000000000000000000000000000000000000000001BF190A5F0833BC64FD377CE0A66338B8276C6DC36F9315663A736DF681A865B6D26787E01976150826545772211DE86C189BBD879B23B9C970E17A5D2E50323AE000000000000000000000000000000000000000000000000000000000000001CBE39F8DD816E46848FA1A2BDCC9B5977E00B73C0B4E9D540B82C41D3D11697EA3284325FE951BC02C897B1181330F1756631019187E130C2EC8CDF24B5B45528000000000000000000000000000000000000000000000000000000000000001B9F66B10A55C34FB8AF58899EF0C8DD98131ED2CD8ECA383CCB6714E062AA9CD00393D870A0E2DB67788FABD593BE6CD38F16EE7E4E4B8CED76329EC735C73217000000000000000000000000000000000000000000000000000000000000001B0647FBE1DE12E29B61DD04F08889A730B974067E634C1E104AC3926F0F8D9CAD2EB3546573DAAD643F89D1ACDCBF1A500F040B34E15F6D88C0B257C4E1887D44000000000000000000000000000000000000000000000000000000000000001B9EB3B914F5B4C18989C30A0A4529EF2BB5E39D278F4B6761719B630E1264E1C97530A1F7D75F997BA58C967D030BE1CDAC0307858F117326D50EE0F999B0D495000000000000000000000000000000000000000000000000000000000000001CB66A97FD3BB835BB0D6E11EE78ED0E04A1B65867D4971A58D3D441A52EA54E8548C152389F00226F1AD5050A416F43B361FDD7414B9745B8E340FE3B83236A79000000000000000000000000000000000000000000000000000000000000001BAAA4722BBBAD09AB644D6F765D1E03BD0B3800C991913D781C8632E244ED221B0DEF449E408FCDB8862ABC98DBE54F6E576A2B0DC9033D2CAE14EFE65D99A65B000000000000000000000000000000000000000000000000000000000000001C5F9D9EE04D9CFA86F9948B6DAA66ED45D938B4194672367B8B0167EF4CBC26B11085C33F9DF6B61DE78EE727C93293E33D49DEB2FA0C2A3AC34D302B6A7D7AC8000000000000000000000000000000000000000000000000000000000000001B990F2D23BD2B18BE47C67D1103722F7F49C364F65E216E01466F5613BA38F2FA09C64C24041B8296ED35D106B3291C6C4ACC1671C7EDBDB7239A0046D58C57D5000000000000000000000000000000000000000000000000000000000000001B9D4EF8F095189DF3822ADC931DE7A6B9E5076496C3A4A6248AC1639883E04A2A5B79A356CC74FE6DB651515F307D5F053A356B1D2D519F9FAC93BAF48C90074A000000000000000000000000000000000000000000000000000000000000001BA9B6D98755F7E05B139C74C5CA0A37A43815F24D6F23C3B233CDBD373FF0FF9904E7FC16EE4B36EE23E3CF3B4B39DE4AD0C388678EAE58DA23F0C1DC86CDABA1000000000000000000000000000000000000000000000000000000000000001B652718C930FF93FD6370C6D6B8CF00775E704D3F476F7681CD08A4B5820BE41F3CDBA6086CE3BBE524E8439AF91702C7C8A70CDA4C785D7E81411BDC454B5A51000000000000000000000000000000000000000000000000000000000000001BF90D95045910CDA6992B1FA511B205A41B6A10176BAB8542BF41091ED49824B9031C9485C2C7EADB6BE8F11EB79FC7669F606C736C153FB4B55E580B001763DE000000000000000000000000000000000000000000000000000000000000001CD156B6D537D3896CD59A978CE7CDB961812AA1D53530A44EB9C59DCBF296AE3E2ADD9D34A07B60D8104398447B8484FD241FB35D70136D7FFA9FE7273557A489000000000000000000000000000000000000000000000000000000000000001B817A76BE90E68E0CD99F2F749E716F447FA8E90286588B26DA601E1667526B3C1C9B97EC75CE1793C5050FB22FB7CE292FFDE072E1271C5AB549C4887D156F85000000000000000000000000000000000000000000000000000000000000001BE3AA9261C99AD0B607DAEF4BC3EA833BECD4F1F4147E13B526D09373A46C5F266940FD86AD63491675A905B1A9917D35A3B51D918F6C1C803CF6C8B67795F3D0000000000000000000000000000000000000000000000000000000000000001C59198F1279D700A40182454B157ABC533BACF6C993ECB46034E20A7B3FED8A3232866B246D078A837BBC58C4CF4E64FBA237DB5DF2534649E490C69CEFEB225B000000000000000000000000000000000000000000000000000000000000001CA08972D13F872610ECBA142CE4CF4A2D3EC36A5BADE49146211BD2F9AE509F7E5DE1A3E3A7DE8C01B95D5A043BDC5D0AB7FD915F2165AE6B2C079DA198F2CA33000000000000000000000000000000000000000000000000000000000000001B761ED08ACDD521BFA909F6045BDFDB94101205A1286A7ACF51C4A2EF4AF7BC2D3306D0B37B0ABF441AE1187BCF339842256D4CFB751250B718796A3B8A4CF4AD000000000000000000000000000000000000000000000000000000000000001CB700A0DCDCEB8645C7F2A8B912FD2E3FC21B2B7B981BDD23A4A99C06A2247D1C3498A02DDDAE3FD0947518A9218BCE08A6A113415A58D3EFE3FBC18ED1AB50C4000000000000000000000000000000000000000000000000000000000000001C78C46BBFFF8F6535FE7DE5D92BB5616AC3FB81C6B63CC241E9B1D3483C3CF2344DBD40CB3AA72A2453DACD15DF110FF48CA902633F40D2F6FA258F540350AF50000000000000000000000000000000000000000000000000000000000000001B5E47302EFC48836459011D6A6460E68C8151800136A098C571D5E96DBD59EE686B82DE9ABA801B76F23F73964ED90F3FDEA6E915E142016236A335B3C7E9FFFB000000000000000000000000000000000000000000000000000000000000001CF3D9EF7D5D7C3F7BB967F3360D281AA5BAEACB887DF40C5E44845D7747667DFE28CADFC15ED8224E16DFE3EF6E806904663F58DCFCF595AA397A15C37053D3D5000000000000000000000000000000000000000000000000000000000000001CEEB339A3A1B7EB5FC7E3A0037BD0D8D34ED0473CC2665AA2D4AB6A5A9CB7B7F1274F177FBB09CDE880E2547595EBA916515E6F3A197C8393E0429AA8C4517F34000000000000000000000000000000000000000000000000000000000000001BAC458348D8F5D82B8049B2EE407093DEEC7E64B832C8D02E8DEB87BA2039DE90138FD9DA125E805C7CE5B04C81FBBD2E476699D60F3E2C042F3B31A2373DA5C3000000000000000000000000000000000000000000000000000000000000001C )
    • Null: 0x000...002.00000000( )
    • Null: 0x000...002.00000000( )
    • Null: 0x000...002.00000000( )
    • Null: 0x000...002.00000000( )
    • Null: 0x000...002.00000000( )
    • Null: 0x000...002.00000000( )
    • Null: 0x000...002.00000000( )
    • Null: 0x000...002.00000000( )
    • Null: 0x000...002.00000000( )
    • Verifier28x32.verify( 0x12E3DC7083D3586EE8ABF34E756C562A32B26D2056FFC23336C6786F49763DF200000000000000000000000000000000000000000000000543D6E000A5506EE400000000000000000000000000000000000000000000000301E6CAFF8BCC737B00000000000000000000000000000000000000000000000744C9A1F398D9E2B100000000000000000000000000000000000000000000000000002FB49BF0862C0000000000000000000000000000000000000000000000052DD62F8C80B7F3CE000000000000000000000000000000000000000000000008B2242BA00A727A9F00000000000000000000000000000000000000000000000FABC53CD3EB70FD240000000000000000000000000000000000000000000000000000EF5317BE9AB1000000000000000000000000000000000000000000000009E1247B66927AE65D00000000000000000000000000000000000000000000000F7F2C1785F3D81FD00000000000000000000000000000000000000000000000031E0CC144DB24077E00000000000000000000000000000000000000000000000000026F36C189DB4E0000000000000000000000000000000000000000000000095EA6757544D19FB000000000000000000000000000000000000000000000000490C7A78CEDE1A92C00000000000000000000000000000000000000000000000E1B7C127735E5767300000000000000000000000000000000000000000000000000014B3281BE3078045B7B3EA97CCA3BBEF1F074F689D2DED8318FD989ED876CA68A6DA4C94FDB770249388099CB5728858FC364CD46D0FE6B18D81E4887D31C74BAE02279716E2F0254B83049F6E887A4052EC692D87BE8C68C9210BB78AEB5E61DA9C27378199C11D41E3AF70F26475B2E484B05AFA8986411481A2B5E0EDEF8FDD249D3054E830634F5291A20CDA1FC8EB3BAF8784B628C4F47B098797B44F3F04DDAC58E20CC21BD74CEF26A3691726830F811E99CE1B59260BBBA8FE0CD659F89323ED03811054F4FECA4984628E7472B810B43ACD40D8BF24C8B6316A052105C111C56E83F2D4F5A06D5BCA819EFCCF4BD090100CD9C1DA1759FF13DB636AAF229F5DE1376116129AE48F72577FF827668F6E4BCEBA1284595CC9E7586EBE1EB38AB4BB4FC26240EF9964A01B22FE3926DDB5D5B1B904DA8AA300391C9E9826C55908278E6209B3ACD605F5903BD3A877FD231A6F29A19C52314EB6D6C1846D6B6CC77198C0EE175BEC60372974637AFA5A090492662F9879A50E1E38C009CB1FC0ED2430B00831CFFBE369E76695D6D46EC289FCEEC5965154A3D5FF078F51AAD7A979E992E3364CF0E6BCC9E004C4D3396CE32184BF498AC9734104FA5A9932E8A330C9A05FDCBACF34EBB8D11D0269F0CA9401443D575BAB0AA4C1C5D24CBFE965D050F30433D8088096D3D961F6135135E25D393D0DFD767909D8D431A65C3C1CA31A525FE122B3672AC7538E46C2BB2DE9303594B8353B604E9B5EDB86D9AC215CA0B1E0A6FDC5661BC888A5E4EA80566A2B7286BF60CA44248B3FEAE0BDAD35F6DF11DEE7ADE9E13AD889EE093F7498E59CD866CAAD4B3061D4F469DABE3879F6BE31A63C6BB2472599DDC822FAC261FB3659DAF61EC1400DD2EE26953172BE828C6243A9F3FCB452C956162A559E6A5B6CA51F34C63EAC45016A6D301E9D34348521796EFEBCF6D778F26D5C5140E10DD39CAD7E0C7F5E69DA32C660B060364C25C13F2EF7A6D1C02AE1E207BE809B68ECEA4377FBBADE733DB913CB59943E10DDF163F21C27B6B0231B7B0A685CA74C47311EEA80E59C9760C0AE946DC61B80F24, public_inputs_hash=8544226975796661559153999850466004010068468929811330858864693773211761262066 ) => ( True )
      • Null: 0x000...005.00000000( )
      • Null: 0x000...007.1e242bd5( )
      • Null: 0x000...007.2d4f5a06( )
      • Null: 0x000...006.18dcdc9e( )
      • Null: 0x000...007.1d349b89( )
      • Null: 0x000...006.1487bb5a( )
      • Null: 0x000...007.0f497062( )
      • Null: 0x000...006.2983bbd1( )
      • Null: 0x000...007.1da0feb3( )
      • Null: 0x000...006.2d51a141( )
      • Null: 0x000...007.188fa913( )
      • Null: 0x000...006.2c735a2c( )
      • Null: 0x000...007.0e181986( )
      • Null: 0x000...006.2daa4504( )
      • Null: 0x000...007.26240ef9( )
      • Null: 0x000...006.16a84ac9( )
      • Null: 0x000...007.0ee175be( )
      • Null: 0x000...006.11cc43ec( )
      • Null: 0x000...007.2e3364cf( )
      • Null: 0x000...006.15f0d62f( )
      • Null: 0x000...007.02493880( )
      • Null: 0x000...006.2accebf1( )
      • Null: 0x000...007.11d41e3a( )
      • Null: 0x000...006.03033259( )
      • Null: 0x000...007.21bd74ce( )
      • Null: 0x000...006.0cde5edb( )
      • Null: 0x000...007.1ae57998( )
      • Null: 0x000...006.23a56f7c( )
      • Null: 0x000...007.23a3fa19( )
      • Null: 0x000...006.1d560391( )
      • Null: 0x000...007.00000000( )
      • Null: 0x000...006.14e71079( )
      • Null: 0x000...007.1796efeb( )
      • Null: 0x000...006.1ae29648( )
      • Null: 0x000...007.163f21c2( )
      • Null: 0x000...006.2edf44bb( )
      • Null: 0x000...007.163f21c2( )
      • Null: 0x000...006.1796efeb( )
      • Null: 0x000...007.02fb49bf( )
      • Null: 0x000...007.26f36c18( )
      • Null: 0x000...006.00a7e2ab( )
      • Null: 0x000...006.163f5194( )
      • Null: 0x000...008.2e9c6a79( )
      • Null: 0x000...001.c4284d58( )
      • Null: 0x000...001.a24c691d( )
      • Dai.transfer( dst=0x96032fcD94bf017431675ae3dcB032Ca17Fb1f90, wad=10000000000000000000000 ) => ( True )
      • Null: 0x000...001.a721aa8b( )
      • Dai.transfer( dst=0x96032fcD94bf017431675ae3dcB032Ca17Fb1f90, wad=10000000000000000000000 ) => ( True )
      • Null: 0x000...001.db9f0fb9( )
      • Null: 0x000...001.a82d89e0( )
      • Null: 0x000...001.0bee7374( )
      • Null: 0x000...001.68b68555( )
      • Null: 0x000...001.cbc815de( )
      • Null: 0x000...001.49339626( )
      • Null: 0x000...001.9581b890( )
      • Null: 0x000...001.e2955984( )
      • Null: 0x000...001.34c68b71( )
      • Null: 0x000...001.7a70a1f5( )
      • Null: 0x000...001.f501752a( )
      • ETH 0.138672 0x967359e9076c48d3abcc02606fd4d07e12c2332a.CALL( )
      • Null: 0x000...001.e2fdbf81( )
      • Null: 0x000...001.2243b546( )
      • Null: 0x000...001.d913236f( )
      • Null: 0x000...001.c08cd5d5( )
      • Null: 0x000...001.c206d4a5( )
      • Null: 0x000...001.dd28fb78( )
      • Null: 0x000...001.992f729a( )
      • Null: 0x000...001.e2eac47b( )
      • Null: 0x000...001.c8b984c0( )
      • Null: 0x000...001.f8f0cefd( )
      • Null: 0x000...001.d8a854d4( )
      • Null: 0x000...001.b318f0b8( )
      • Null: 0x000...001.5455fd5e( )
      • Null: 0x000...001.64e53178( )
      • Null: 0x000...001.c7076e58( )
      • Null: 0x000...001.032c2186( )
      • Null: 0x000...001.626f880b( )
      • Null: 0x000...001.67425035( )
      • Null: 0x000...001.69d099b5( )
      • Null: 0x000...001.59537d8c( )
      • Null: 0x000...001.17dc8afe( )
      • Null: 0x000...001.d663d867( )
      • DefiBridgeProxy.convert( bridgeAddress=0x3578D6D5e1B4F07A48bb1c958CBfEc135bef7d98, inputAssetA=[{name:id, type:uint256, order:1, indexed:false, value:0, valueString:0}, {name:erc20Address, type:address, order:2, indexed:false, value:0x0000000000000000000000000000000000000000, valueString:0x0000000000000000000000000000000000000000}, {name:assetType, type:uint8, order:3, indexed:false, value:1, valueString:1}], inputAssetB=[{name:id, type:uint256, order:1, indexed:false, value:0, valueString:0}, {name:erc20Address, type:address, order:2, indexed:false, value:0x0000000000000000000000000000000000000000, valueString:0x0000000000000000000000000000000000000000}, {name:assetType, type:uint8, order:3, indexed:false, value:0, valueString:0}], outputAssetA=[{name:id, type:uint256, order:1, indexed:false, value:5, valueString:5}, {name:erc20Address, type:address, order:2, indexed:false, value:0x3c66B18F67CA6C1A71F829E2F6a0c987f97462d0, valueString:0x3c66B18F67CA6C1A71F829E2F6a0c987f97462d0}, {name:assetType, type:uint8, order:3, indexed:false, value:2, valueString:2}], outputAssetB=[{name:id, type:uint256, order:1, indexed:false, value:0, valueString:0}, {name:erc20Address, type:address, order:2, indexed:false, value:0x0000000000000000000000000000000000000000, valueString:0x0000000000000000000000000000000000000000}, {name:assetType, type:uint8, order:3, indexed:false, value:0, valueString:0}], totalInputValue=1669181000000000000, interactionNonce=213216, auxInputData=0, ethPaymentsSlot=13, rollupBeneficiary=0x4cf32670a53657596E641DFCC6d40f01e4d64927 ) => ( outputValueA=1655146345611228071, outputValueB=0, isAsync=False )
        • ETH 1.669181 ERC4626Bridge.convert( _inputAssetA=[{name:id, type:uint256, order:1, indexed:false, value:0, valueString:0}, {name:erc20Address, type:address, order:2, indexed:false, value:0x0000000000000000000000000000000000000000, valueString:0x0000000000000000000000000000000000000000}, {name:assetType, type:uint8, order:3, indexed:false, value:1, valueString:1}], [{name:id, type:uint256, order:1, indexed:false, value:0, valueString:0}, {name:erc20Address, type:address, order:2, indexed:false, value:0x0000000000000000000000000000000000000000, valueString:0x0000000000000000000000000000000000000000}, {name:assetType, type:uint8, order:3, indexed:false, value:0, valueString:0}], _outputAssetA=[{name:id, type:uint256, order:1, indexed:false, value:5, valueString:5}, {name:erc20Address, type:address, order:2, indexed:false, value:0x3c66B18F67CA6C1A71F829E2F6a0c987f97462d0, valueString:0x3c66B18F67CA6C1A71F829E2F6a0c987f97462d0}, {name:assetType, type:uint8, order:3, indexed:false, value:2, valueString:2}], [{name:id, type:uint256, order:1, indexed:false, value:0, valueString:0}, {name:erc20Address, type:address, order:2, indexed:false, value:0x0000000000000000000000000000000000000000, valueString:0x0000000000000000000000000000000000000000}, {name:assetType, type:uint8, order:3, indexed:false, value:0, valueString:0}], _totalInputValue=1669181000000000000, _interactionNonce=213216, _auxData=0, _rollupBeneficiary=0x4cf32670a53657596E641DFCC6d40f01e4d64927 ) => ( outputValueA=1655146345611228071, 0, False )
          • ETH 1.669181 WETH9.CALL( )
          • EulerERC4626.deposit( assets=1669181000000000000, receiver=0x3578D6D5e1B4F07A48bb1c958CBfEc135bef7d98 ) => ( shares=1655146345611228071 )
            • Proxy.3af9e669( )
            • WETH9.transferFrom( src=0x3578D6D5e1B4F07A48bb1c958CBfEc135bef7d98, dst=0x3c66B18F67CA6C1A71F829E2F6a0c987f97462d0, wad=1669181000000000000 ) => ( True )
            • WETH9.approve( guy=0x27182842E098f60e3D576794A5bFFb0777E025d3, wad=1669181000000000000 ) => ( True )
            • Proxy.e2bbb158( )
            • Subsidy.claimSubsidy( _criteria=70895318621746113552450389274749405843997501156192947036688026259764565209335, _beneficiary=0x4cf32670a53657596E641DFCC6d40f01e4d64927 ) => ( 330367876107360 )
            • EulerERC4626.transferFrom( from=0x3578D6D5e1B4F07A48bb1c958CBfEc135bef7d98, to=0xFF1F2B4ADb9dF6FC8eAFecDcbF96A2B351680455, amount=1655146345611228071 ) => ( True )
            • Null: 0x000...002.00000000( )
            • Null: 0x000...002.06819a24( )
            • ETH 0.06068 AztecFeeDistributor.CALL( )
            • Dai.transfer( dst=0x4cf32670a53657596E641DFCC6d40f01e4d64927, wad=22027000000000000000 ) => ( True )
              File 1 of 12: TransparentUpgradeableProxy
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)
              pragma solidity ^0.8.0;
              import "../ERC1967/ERC1967Proxy.sol";
              /**
               * @dev This contract implements a proxy that is upgradeable by an admin.
               *
               * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector
               * clashing], which can potentially be used in an attack, this contract uses the
               * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two
               * things that go hand in hand:
               *
               * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
               * that call matches one of the admin functions exposed by the proxy itself.
               * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the
               * implementation. If the admin tries to call a function on the implementation it will fail with an error that says
               * "admin cannot fallback to proxy target".
               *
               * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing
               * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due
               * to sudden errors when trying to call a function from the proxy implementation.
               *
               * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,
               * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.
               */
              contract TransparentUpgradeableProxy is ERC1967Proxy {
                  /**
                   * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and
                   * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.
                   */
                  constructor(
                      address _logic,
                      address admin_,
                      bytes memory _data
                  ) payable ERC1967Proxy(_logic, _data) {
                      assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1));
                      _changeAdmin(admin_);
                  }
                  /**
                   * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.
                   */
                  modifier ifAdmin() {
                      if (msg.sender == _getAdmin()) {
                          _;
                      } else {
                          _fallback();
                      }
                  }
                  /**
                   * @dev Returns the current admin.
                   *
                   * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.
                   *
                   * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
                   * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
                   * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
                   */
                  function admin() external ifAdmin returns (address admin_) {
                      admin_ = _getAdmin();
                  }
                  /**
                   * @dev Returns the current implementation.
                   *
                   * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.
                   *
                   * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
                   * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
                   * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
                   */
                  function implementation() external ifAdmin returns (address implementation_) {
                      implementation_ = _implementation();
                  }
                  /**
                   * @dev Changes the admin of the proxy.
                   *
                   * Emits an {AdminChanged} event.
                   *
                   * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.
                   */
                  function changeAdmin(address newAdmin) external virtual ifAdmin {
                      _changeAdmin(newAdmin);
                  }
                  /**
                   * @dev Upgrade the implementation of the proxy.
                   *
                   * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.
                   */
                  function upgradeTo(address newImplementation) external ifAdmin {
                      _upgradeToAndCall(newImplementation, bytes(""), false);
                  }
                  /**
                   * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified
                   * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the
                   * proxied contract.
                   *
                   * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.
                   */
                  function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {
                      _upgradeToAndCall(newImplementation, data, true);
                  }
                  /**
                   * @dev Returns the current admin.
                   */
                  function _admin() internal view virtual returns (address) {
                      return _getAdmin();
                  }
                  /**
                   * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.
                   */
                  function _beforeFallback() internal virtual override {
                      require(msg.sender != _getAdmin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target");
                      super._beforeFallback();
                  }
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)
              pragma solidity ^0.8.0;
              import "../Proxy.sol";
              import "./ERC1967Upgrade.sol";
              /**
               * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
               * implementation address that can be changed. This address is stored in storage in the location specified by
               * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the
               * implementation behind the proxy.
               */
              contract ERC1967Proxy is Proxy, ERC1967Upgrade {
                  /**
                   * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.
                   *
                   * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded
                   * function call, and allows initializating the storage of the proxy like a Solidity constructor.
                   */
                  constructor(address _logic, bytes memory _data) payable {
                      assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1));
                      _upgradeToAndCall(_logic, _data, false);
                  }
                  /**
                   * @dev Returns the current implementation address.
                   */
                  function _implementation() internal view virtual override returns (address impl) {
                      return ERC1967Upgrade._getImplementation();
                  }
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)
              pragma solidity ^0.8.0;
              /**
               * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
               * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
               * be specified by overriding the virtual {_implementation} function.
               *
               * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
               * different contract through the {_delegate} function.
               *
               * The success and return data of the delegated call will be returned back to the caller of the proxy.
               */
              abstract contract Proxy {
                  /**
                   * @dev Delegates the current call to `implementation`.
                   *
                   * This function does not return to its internal call site, it will return directly to the external caller.
                   */
                  function _delegate(address implementation) internal virtual {
                      assembly {
                          // Copy msg.data. We take full control of memory in this inline assembly
                          // block because it will not return to Solidity code. We overwrite the
                          // Solidity scratch pad at memory position 0.
                          calldatacopy(0, 0, calldatasize())
                          // Call the implementation.
                          // out and outsize are 0 because we don't know the size yet.
                          let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
                          // Copy the returned data.
                          returndatacopy(0, 0, returndatasize())
                          switch result
                          // delegatecall returns 0 on error.
                          case 0 {
                              revert(0, returndatasize())
                          }
                          default {
                              return(0, returndatasize())
                          }
                      }
                  }
                  /**
                   * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function
                   * and {_fallback} should delegate.
                   */
                  function _implementation() internal view virtual returns (address);
                  /**
                   * @dev Delegates the current call to the address returned by `_implementation()`.
                   *
                   * This function does not return to its internal call site, it will return directly to the external caller.
                   */
                  function _fallback() internal virtual {
                      _beforeFallback();
                      _delegate(_implementation());
                  }
                  /**
                   * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
                   * function in the contract matches the call data.
                   */
                  fallback() external payable virtual {
                      _fallback();
                  }
                  /**
                   * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
                   * is empty.
                   */
                  receive() external payable virtual {
                      _fallback();
                  }
                  /**
                   * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
                   * call, or as part of the Solidity `fallback` or `receive` functions.
                   *
                   * If overridden should call `super._beforeFallback()`.
                   */
                  function _beforeFallback() internal virtual {}
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)
              pragma solidity ^0.8.2;
              import "../beacon/IBeacon.sol";
              import "../../interfaces/draft-IERC1822.sol";
              import "../../utils/Address.sol";
              import "../../utils/StorageSlot.sol";
              /**
               * @dev This abstract contract provides getters and event emitting update functions for
               * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
               *
               * _Available since v4.1._
               *
               * @custom:oz-upgrades-unsafe-allow delegatecall
               */
              abstract contract ERC1967Upgrade {
                  // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
                  bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
                  /**
                   * @dev Storage slot with the address of the current implementation.
                   * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
                   * validated in the constructor.
                   */
                  bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
                  /**
                   * @dev Emitted when the implementation is upgraded.
                   */
                  event Upgraded(address indexed implementation);
                  /**
                   * @dev Returns the current implementation address.
                   */
                  function _getImplementation() internal view returns (address) {
                      return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
                  }
                  /**
                   * @dev Stores a new address in the EIP1967 implementation slot.
                   */
                  function _setImplementation(address newImplementation) private {
                      require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
                      StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
                  }
                  /**
                   * @dev Perform implementation upgrade
                   *
                   * Emits an {Upgraded} event.
                   */
                  function _upgradeTo(address newImplementation) internal {
                      _setImplementation(newImplementation);
                      emit Upgraded(newImplementation);
                  }
                  /**
                   * @dev Perform implementation upgrade with additional setup call.
                   *
                   * Emits an {Upgraded} event.
                   */
                  function _upgradeToAndCall(
                      address newImplementation,
                      bytes memory data,
                      bool forceCall
                  ) internal {
                      _upgradeTo(newImplementation);
                      if (data.length > 0 || forceCall) {
                          Address.functionDelegateCall(newImplementation, data);
                      }
                  }
                  /**
                   * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
                   *
                   * Emits an {Upgraded} event.
                   */
                  function _upgradeToAndCallUUPS(
                      address newImplementation,
                      bytes memory data,
                      bool forceCall
                  ) internal {
                      // Upgrades from old implementations will perform a rollback test. This test requires the new
                      // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
                      // this special case will break upgrade paths from old UUPS implementation to new ones.
                      if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {
                          _setImplementation(newImplementation);
                      } else {
                          try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
                              require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
                          } catch {
                              revert("ERC1967Upgrade: new implementation is not UUPS");
                          }
                          _upgradeToAndCall(newImplementation, data, forceCall);
                      }
                  }
                  /**
                   * @dev Storage slot with the admin of the contract.
                   * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
                   * validated in the constructor.
                   */
                  bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
                  /**
                   * @dev Emitted when the admin account has changed.
                   */
                  event AdminChanged(address previousAdmin, address newAdmin);
                  /**
                   * @dev Returns the current admin.
                   */
                  function _getAdmin() internal view returns (address) {
                      return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
                  }
                  /**
                   * @dev Stores a new address in the EIP1967 admin slot.
                   */
                  function _setAdmin(address newAdmin) private {
                      require(newAdmin != address(0), "ERC1967: new admin is the zero address");
                      StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
                  }
                  /**
                   * @dev Changes the admin of the proxy.
                   *
                   * Emits an {AdminChanged} event.
                   */
                  function _changeAdmin(address newAdmin) internal {
                      emit AdminChanged(_getAdmin(), newAdmin);
                      _setAdmin(newAdmin);
                  }
                  /**
                   * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
                   * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
                   */
                  bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
                  /**
                   * @dev Emitted when the beacon is upgraded.
                   */
                  event BeaconUpgraded(address indexed beacon);
                  /**
                   * @dev Returns the current beacon.
                   */
                  function _getBeacon() internal view returns (address) {
                      return StorageSlot.getAddressSlot(_BEACON_SLOT).value;
                  }
                  /**
                   * @dev Stores a new beacon in the EIP1967 beacon slot.
                   */
                  function _setBeacon(address newBeacon) private {
                      require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract");
                      require(
                          Address.isContract(IBeacon(newBeacon).implementation()),
                          "ERC1967: beacon implementation is not a contract"
                      );
                      StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;
                  }
                  /**
                   * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
                   * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
                   *
                   * Emits a {BeaconUpgraded} event.
                   */
                  function _upgradeBeaconToAndCall(
                      address newBeacon,
                      bytes memory data,
                      bool forceCall
                  ) internal {
                      _setBeacon(newBeacon);
                      emit BeaconUpgraded(newBeacon);
                      if (data.length > 0 || forceCall) {
                          Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
                      }
                  }
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)
              pragma solidity ^0.8.0;
              /**
               * @dev This is the interface that {BeaconProxy} expects of its beacon.
               */
              interface IBeacon {
                  /**
                   * @dev Must return an address that can be used as a delegate call target.
                   *
                   * {BeaconProxy} will check that this address is a contract.
                   */
                  function implementation() external view returns (address);
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)
              pragma solidity ^0.8.0;
              /**
               * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
               * proxy whose upgrades are fully controlled by the current implementation.
               */
              interface IERC1822Proxiable {
                  /**
                   * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
                   * address.
                   *
                   * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
                   * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
                   * function revert if invoked through a proxy.
                   */
                  function proxiableUUID() external view returns (bytes32);
              }
              // 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);
                          }
                      }
                  }
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)
              pragma solidity ^0.8.0;
              /**
               * @dev Library for reading and writing primitive types to specific storage slots.
               *
               * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
               * This library helps with reading and writing to such slots without the need for inline assembly.
               *
               * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
               *
               * Example usage to set ERC1967 implementation slot:
               * ```
               * contract ERC1967 {
               *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
               *
               *     function _getImplementation() internal view returns (address) {
               *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
               *     }
               *
               *     function _setImplementation(address newImplementation) internal {
               *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
               *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
               *     }
               * }
               * ```
               *
               * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
               */
              library StorageSlot {
                  struct AddressSlot {
                      address value;
                  }
                  struct BooleanSlot {
                      bool value;
                  }
                  struct Bytes32Slot {
                      bytes32 value;
                  }
                  struct Uint256Slot {
                      uint256 value;
                  }
                  /**
                   * @dev Returns an `AddressSlot` with member `value` located at `slot`.
                   */
                  function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
                      assembly {
                          r.slot := slot
                      }
                  }
                  /**
                   * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
                   */
                  function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
                      assembly {
                          r.slot := slot
                      }
                  }
                  /**
                   * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
                   */
                  function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
                      assembly {
                          r.slot := slot
                      }
                  }
                  /**
                   * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
                   */
                  function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
                      assembly {
                          r.slot := slot
                      }
                  }
              }
              

              File 2 of 12: Dai
              // hevm: flattened sources of /nix/store/8xb41r4qd0cjb63wcrxf1qmfg88p0961-dss-6fd7de0/src/dai.sol
              pragma solidity =0.5.12;
              
              ////// /nix/store/8xb41r4qd0cjb63wcrxf1qmfg88p0961-dss-6fd7de0/src/lib.sol
              // This program is free software: you can redistribute it and/or modify
              // it under the terms of the GNU General Public License as published by
              // the Free Software Foundation, either version 3 of the License, or
              // (at your option) any later version.
              
              // This program is distributed in the hope that it will be useful,
              // but WITHOUT ANY WARRANTY; without even the implied warranty of
              // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
              // GNU General Public License for more details.
              
              // You should have received a copy of the GNU General Public License
              // along with this program.  If not, see <http://www.gnu.org/licenses/>.
              
              /* pragma solidity 0.5.12; */
              
              contract LibNote {
                  event LogNote(
                      bytes4   indexed  sig,
                      address  indexed  usr,
                      bytes32  indexed  arg1,
                      bytes32  indexed  arg2,
                      bytes             data
                  ) anonymous;
              
                  modifier note {
                      _;
                      assembly {
                          // log an 'anonymous' event with a constant 6 words of calldata
                          // and four indexed topics: selector, caller, arg1 and arg2
                          let mark := msize                         // end of memory ensures zero
                          mstore(0x40, add(mark, 288))              // update free memory pointer
                          mstore(mark, 0x20)                        // bytes type data offset
                          mstore(add(mark, 0x20), 224)              // bytes size (padded)
                          calldatacopy(add(mark, 0x40), 0, 224)     // bytes payload
                          log4(mark, 288,                           // calldata
                               shl(224, shr(224, calldataload(0))), // msg.sig
                               caller,                              // msg.sender
                               calldataload(4),                     // arg1
                               calldataload(36)                     // arg2
                              )
                      }
                  }
              }
              
              ////// /nix/store/8xb41r4qd0cjb63wcrxf1qmfg88p0961-dss-6fd7de0/src/dai.sol
              // Copyright (C) 2017, 2018, 2019 dbrock, rain, mrchico
              
              // This program is free software: you can redistribute it and/or modify
              // it under the terms of the GNU Affero General Public License as published by
              // the Free Software Foundation, either version 3 of the License, or
              // (at your option) any later version.
              //
              // This program is distributed in the hope that it will be useful,
              // but WITHOUT ANY WARRANTY; without even the implied warranty of
              // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
              // GNU Affero General Public License for more details.
              //
              // You should have received a copy of the GNU Affero General Public License
              // along with this program.  If not, see <https://www.gnu.org/licenses/>.
              
              /* pragma solidity 0.5.12; */
              
              /* import "./lib.sol"; */
              
              contract Dai is LibNote {
                  // --- Auth ---
                  mapping (address => uint) public wards;
                  function rely(address guy) external note auth { wards[guy] = 1; }
                  function deny(address guy) external note auth { wards[guy] = 0; }
                  modifier auth {
                      require(wards[msg.sender] == 1, "Dai/not-authorized");
                      _;
                  }
              
                  // --- ERC20 Data ---
                  string  public constant name     = "Dai Stablecoin";
                  string  public constant symbol   = "DAI";
                  string  public constant version  = "1";
                  uint8   public constant decimals = 18;
                  uint256 public totalSupply;
              
                  mapping (address => uint)                      public balanceOf;
                  mapping (address => mapping (address => uint)) public allowance;
                  mapping (address => uint)                      public nonces;
              
                  event Approval(address indexed src, address indexed guy, uint wad);
                  event Transfer(address indexed src, address indexed dst, uint wad);
              
                  // --- Math ---
                  function add(uint x, uint y) internal pure returns (uint z) {
                      require((z = x + y) >= x);
                  }
                  function sub(uint x, uint y) internal pure returns (uint z) {
                      require((z = x - y) <= x);
                  }
              
                  // --- EIP712 niceties ---
                  bytes32 public DOMAIN_SEPARATOR;
                  // bytes32 public constant PERMIT_TYPEHASH = keccak256("Permit(address holder,address spender,uint256 nonce,uint256 expiry,bool allowed)");
                  bytes32 public constant PERMIT_TYPEHASH = 0xea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb;
              
                  constructor(uint256 chainId_) public {
                      wards[msg.sender] = 1;
                      DOMAIN_SEPARATOR = keccak256(abi.encode(
                          keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
                          keccak256(bytes(name)),
                          keccak256(bytes(version)),
                          chainId_,
                          address(this)
                      ));
                  }
              
                  // --- Token ---
                  function transfer(address dst, uint wad) external returns (bool) {
                      return transferFrom(msg.sender, dst, wad);
                  }
                  function transferFrom(address src, address dst, uint wad)
                      public returns (bool)
                  {
                      require(balanceOf[src] >= wad, "Dai/insufficient-balance");
                      if (src != msg.sender && allowance[src][msg.sender] != uint(-1)) {
                          require(allowance[src][msg.sender] >= wad, "Dai/insufficient-allowance");
                          allowance[src][msg.sender] = sub(allowance[src][msg.sender], wad);
                      }
                      balanceOf[src] = sub(balanceOf[src], wad);
                      balanceOf[dst] = add(balanceOf[dst], wad);
                      emit Transfer(src, dst, wad);
                      return true;
                  }
                  function mint(address usr, uint wad) external auth {
                      balanceOf[usr] = add(balanceOf[usr], wad);
                      totalSupply    = add(totalSupply, wad);
                      emit Transfer(address(0), usr, wad);
                  }
                  function burn(address usr, uint wad) external {
                      require(balanceOf[usr] >= wad, "Dai/insufficient-balance");
                      if (usr != msg.sender && allowance[usr][msg.sender] != uint(-1)) {
                          require(allowance[usr][msg.sender] >= wad, "Dai/insufficient-allowance");
                          allowance[usr][msg.sender] = sub(allowance[usr][msg.sender], wad);
                      }
                      balanceOf[usr] = sub(balanceOf[usr], wad);
                      totalSupply    = sub(totalSupply, wad);
                      emit Transfer(usr, address(0), wad);
                  }
                  function approve(address usr, uint wad) external returns (bool) {
                      allowance[msg.sender][usr] = wad;
                      emit Approval(msg.sender, usr, wad);
                      return true;
                  }
              
                  // --- Alias ---
                  function push(address usr, uint wad) external {
                      transferFrom(msg.sender, usr, wad);
                  }
                  function pull(address usr, uint wad) external {
                      transferFrom(usr, msg.sender, wad);
                  }
                  function move(address src, address dst, uint wad) external {
                      transferFrom(src, dst, wad);
                  }
              
                  // --- Approve by signature ---
                  function permit(address holder, address spender, uint256 nonce, uint256 expiry,
                                  bool allowed, uint8 v, bytes32 r, bytes32 s) external
                  {
                      bytes32 digest =
                          keccak256(abi.encodePacked(
                              "\x19\x01",
                              DOMAIN_SEPARATOR,
                              keccak256(abi.encode(PERMIT_TYPEHASH,
                                                   holder,
                                                   spender,
                                                   nonce,
                                                   expiry,
                                                   allowed))
                      ));
              
                      require(holder != address(0), "Dai/invalid-address-0");
                      require(holder == ecrecover(digest, v, r, s), "Dai/invalid-permit");
                      require(expiry == 0 || now <= expiry, "Dai/permit-expired");
                      require(nonce == nonces[holder]++, "Dai/invalid-nonce");
                      uint wad = allowed ? uint(-1) : 0;
                      allowance[holder][spender] = wad;
                      emit Approval(holder, spender, wad);
                  }
              }

              File 3 of 12: WETH9
              // Copyright (C) 2015, 2016, 2017 Dapphub
              
              // This program is free software: you can redistribute it and/or modify
              // it under the terms of the GNU General Public License as published by
              // the Free Software Foundation, either version 3 of the License, or
              // (at your option) any later version.
              
              // This program is distributed in the hope that it will be useful,
              // but WITHOUT ANY WARRANTY; without even the implied warranty of
              // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
              // GNU General Public License for more details.
              
              // You should have received a copy of the GNU General Public License
              // along with this program.  If not, see <http://www.gnu.org/licenses/>.
              
              pragma solidity ^0.4.18;
              
              contract WETH9 {
                  string public name     = "Wrapped Ether";
                  string public symbol   = "WETH";
                  uint8  public decimals = 18;
              
                  event  Approval(address indexed src, address indexed guy, uint wad);
                  event  Transfer(address indexed src, address indexed dst, uint wad);
                  event  Deposit(address indexed dst, uint wad);
                  event  Withdrawal(address indexed src, uint wad);
              
                  mapping (address => uint)                       public  balanceOf;
                  mapping (address => mapping (address => uint))  public  allowance;
              
                  function() public payable {
                      deposit();
                  }
                  function deposit() public payable {
                      balanceOf[msg.sender] += msg.value;
                      Deposit(msg.sender, msg.value);
                  }
                  function withdraw(uint wad) public {
                      require(balanceOf[msg.sender] >= wad);
                      balanceOf[msg.sender] -= wad;
                      msg.sender.transfer(wad);
                      Withdrawal(msg.sender, wad);
                  }
              
                  function totalSupply() public view returns (uint) {
                      return this.balance;
                  }
              
                  function approve(address guy, uint wad) public returns (bool) {
                      allowance[msg.sender][guy] = wad;
                      Approval(msg.sender, guy, wad);
                      return true;
                  }
              
                  function transfer(address dst, uint wad) public returns (bool) {
                      return transferFrom(msg.sender, dst, wad);
                  }
              
                  function transferFrom(address src, address dst, uint wad)
                      public
                      returns (bool)
                  {
                      require(balanceOf[src] >= wad);
              
                      if (src != msg.sender && allowance[src][msg.sender] != uint(-1)) {
                          require(allowance[src][msg.sender] >= wad);
                          allowance[src][msg.sender] -= wad;
                      }
              
                      balanceOf[src] -= wad;
                      balanceOf[dst] += wad;
              
                      Transfer(src, dst, wad);
              
                      return true;
                  }
              }
              
              
              /*
                                  GNU GENERAL PUBLIC LICENSE
                                     Version 3, 29 June 2007
              
               Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
               Everyone is permitted to copy and distribute verbatim copies
               of this license document, but changing it is not allowed.
              
                                          Preamble
              
                The GNU General Public License is a free, copyleft license for
              software and other kinds of works.
              
                The licenses for most software and other practical works are designed
              to take away your freedom to share and change the works.  By contrast,
              the GNU General Public License is intended to guarantee your freedom to
              share and change all versions of a program--to make sure it remains free
              software for all its users.  We, the Free Software Foundation, use the
              GNU General Public License for most of our software; it applies also to
              any other work released this way by its authors.  You can apply it to
              your programs, too.
              
                When we speak of free software, we are referring to freedom, not
              price.  Our General Public Licenses are designed to make sure that you
              have the freedom to distribute copies of free software (and charge for
              them if you wish), that you receive source code or can get it if you
              want it, that you can change the software or use pieces of it in new
              free programs, and that you know you can do these things.
              
                To protect your rights, we need to prevent others from denying you
              these rights or asking you to surrender the rights.  Therefore, you have
              certain responsibilities if you distribute copies of the software, or if
              you modify it: responsibilities to respect the freedom of others.
              
                For example, if you distribute copies of such a program, whether
              gratis or for a fee, you must pass on to the recipients the same
              freedoms that you received.  You must make sure that they, too, receive
              or can get the source code.  And you must show them these terms so they
              know their rights.
              
                Developers that use the GNU GPL protect your rights with two steps:
              (1) assert copyright on the software, and (2) offer you this License
              giving you legal permission to copy, distribute and/or modify it.
              
                For the developers' and authors' protection, the GPL clearly explains
              that there is no warranty for this free software.  For both users' and
              authors' sake, the GPL requires that modified versions be marked as
              changed, so that their problems will not be attributed erroneously to
              authors of previous versions.
              
                Some devices are designed to deny users access to install or run
              modified versions of the software inside them, although the manufacturer
              can do so.  This is fundamentally incompatible with the aim of
              protecting users' freedom to change the software.  The systematic
              pattern of such abuse occurs in the area of products for individuals to
              use, which is precisely where it is most unacceptable.  Therefore, we
              have designed this version of the GPL to prohibit the practice for those
              products.  If such problems arise substantially in other domains, we
              stand ready to extend this provision to those domains in future versions
              of the GPL, as needed to protect the freedom of users.
              
                Finally, every program is threatened constantly by software patents.
              States should not allow patents to restrict development and use of
              software on general-purpose computers, but in those that do, we wish to
              avoid the special danger that patents applied to a free program could
              make it effectively proprietary.  To prevent this, the GPL assures that
              patents cannot be used to render the program non-free.
              
                The precise terms and conditions for copying, distribution and
              modification follow.
              
                                     TERMS AND CONDITIONS
              
                0. Definitions.
              
                "This License" refers to version 3 of the GNU General Public License.
              
                "Copyright" also means copyright-like laws that apply to other kinds of
              works, such as semiconductor masks.
              
                "The Program" refers to any copyrightable work licensed under this
              License.  Each licensee is addressed as "you".  "Licensees" and
              "recipients" may be individuals or organizations.
              
                To "modify" a work means to copy from or adapt all or part of the work
              in a fashion requiring copyright permission, other than the making of an
              exact copy.  The resulting work is called a "modified version" of the
              earlier work or a work "based on" the earlier work.
              
                A "covered work" means either the unmodified Program or a work based
              on the Program.
              
                To "propagate" a work means to do anything with it that, without
              permission, would make you directly or secondarily liable for
              infringement under applicable copyright law, except executing it on a
              computer or modifying a private copy.  Propagation includes copying,
              distribution (with or without modification), making available to the
              public, and in some countries other activities as well.
              
                To "convey" a work means any kind of propagation that enables other
              parties to make or receive copies.  Mere interaction with a user through
              a computer network, with no transfer of a copy, is not conveying.
              
                An interactive user interface displays "Appropriate Legal Notices"
              to the extent that it includes a convenient and prominently visible
              feature that (1) displays an appropriate copyright notice, and (2)
              tells the user that there is no warranty for the work (except to the
              extent that warranties are provided), that licensees may convey the
              work under this License, and how to view a copy of this License.  If
              the interface presents a list of user commands or options, such as a
              menu, a prominent item in the list meets this criterion.
              
                1. Source Code.
              
                The "source code" for a work means the preferred form of the work
              for making modifications to it.  "Object code" means any non-source
              form of a work.
              
                A "Standard Interface" means an interface that either is an official
              standard defined by a recognized standards body, or, in the case of
              interfaces specified for a particular programming language, one that
              is widely used among developers working in that language.
              
                The "System Libraries" of an executable work include anything, other
              than the work as a whole, that (a) is included in the normal form of
              packaging a Major Component, but which is not part of that Major
              Component, and (b) serves only to enable use of the work with that
              Major Component, or to implement a Standard Interface for which an
              implementation is available to the public in source code form.  A
              "Major Component", in this context, means a major essential component
              (kernel, window system, and so on) of the specific operating system
              (if any) on which the executable work runs, or a compiler used to
              produce the work, or an object code interpreter used to run it.
              
                The "Corresponding Source" for a work in object code form means all
              the source code needed to generate, install, and (for an executable
              work) run the object code and to modify the work, including scripts to
              control those activities.  However, it does not include the work's
              System Libraries, or general-purpose tools or generally available free
              programs which are used unmodified in performing those activities but
              which are not part of the work.  For example, Corresponding Source
              includes interface definition files associated with source files for
              the work, and the source code for shared libraries and dynamically
              linked subprograms that the work is specifically designed to require,
              such as by intimate data communication or control flow between those
              subprograms and other parts of the work.
              
                The Corresponding Source need not include anything that users
              can regenerate automatically from other parts of the Corresponding
              Source.
              
                The Corresponding Source for a work in source code form is that
              same work.
              
                2. Basic Permissions.
              
                All rights granted under this License are granted for the term of
              copyright on the Program, and are irrevocable provided the stated
              conditions are met.  This License explicitly affirms your unlimited
              permission to run the unmodified Program.  The output from running a
              covered work is covered by this License only if the output, given its
              content, constitutes a covered work.  This License acknowledges your
              rights of fair use or other equivalent, as provided by copyright law.
              
                You may make, run and propagate covered works that you do not
              convey, without conditions so long as your license otherwise remains
              in force.  You may convey covered works to others for the sole purpose
              of having them make modifications exclusively for you, or provide you
              with facilities for running those works, provided that you comply with
              the terms of this License in conveying all material for which you do
              not control copyright.  Those thus making or running the covered works
              for you must do so exclusively on your behalf, under your direction
              and control, on terms that prohibit them from making any copies of
              your copyrighted material outside their relationship with you.
              
                Conveying under any other circumstances is permitted solely under
              the conditions stated below.  Sublicensing is not allowed; section 10
              makes it unnecessary.
              
                3. Protecting Users' Legal Rights From Anti-Circumvention Law.
              
                No covered work shall be deemed part of an effective technological
              measure under any applicable law fulfilling obligations under article
              11 of the WIPO copyright treaty adopted on 20 December 1996, or
              similar laws prohibiting or restricting circumvention of such
              measures.
              
                When you convey a covered work, you waive any legal power to forbid
              circumvention of technological measures to the extent such circumvention
              is effected by exercising rights under this License with respect to
              the covered work, and you disclaim any intention to limit operation or
              modification of the work as a means of enforcing, against the work's
              users, your or third parties' legal rights to forbid circumvention of
              technological measures.
              
                4. Conveying Verbatim Copies.
              
                You may convey verbatim copies of the Program's source code as you
              receive it, in any medium, provided that you conspicuously and
              appropriately publish on each copy an appropriate copyright notice;
              keep intact all notices stating that this License and any
              non-permissive terms added in accord with section 7 apply to the code;
              keep intact all notices of the absence of any warranty; and give all
              recipients a copy of this License along with the Program.
              
                You may charge any price or no price for each copy that you convey,
              and you may offer support or warranty protection for a fee.
              
                5. Conveying Modified Source Versions.
              
                You may convey a work based on the Program, or the modifications to
              produce it from the Program, in the form of source code under the
              terms of section 4, provided that you also meet all of these conditions:
              
                  a) The work must carry prominent notices stating that you modified
                  it, and giving a relevant date.
              
                  b) The work must carry prominent notices stating that it is
                  released under this License and any conditions added under section
                  7.  This requirement modifies the requirement in section 4 to
                  "keep intact all notices".
              
                  c) You must license the entire work, as a whole, under this
                  License to anyone who comes into possession of a copy.  This
                  License will therefore apply, along with any applicable section 7
                  additional terms, to the whole of the work, and all its parts,
                  regardless of how they are packaged.  This License gives no
                  permission to license the work in any other way, but it does not
                  invalidate such permission if you have separately received it.
              
                  d) If the work has interactive user interfaces, each must display
                  Appropriate Legal Notices; however, if the Program has interactive
                  interfaces that do not display Appropriate Legal Notices, your
                  work need not make them do so.
              
                A compilation of a covered work with other separate and independent
              works, which are not by their nature extensions of the covered work,
              and which are not combined with it such as to form a larger program,
              in or on a volume of a storage or distribution medium, is called an
              "aggregate" if the compilation and its resulting copyright are not
              used to limit the access or legal rights of the compilation's users
              beyond what the individual works permit.  Inclusion of a covered work
              in an aggregate does not cause this License to apply to the other
              parts of the aggregate.
              
                6. Conveying Non-Source Forms.
              
                You may convey a covered work in object code form under the terms
              of sections 4 and 5, provided that you also convey the
              machine-readable Corresponding Source under the terms of this License,
              in one of these ways:
              
                  a) Convey the object code in, or embodied in, a physical product
                  (including a physical distribution medium), accompanied by the
                  Corresponding Source fixed on a durable physical medium
                  customarily used for software interchange.
              
                  b) Convey the object code in, or embodied in, a physical product
                  (including a physical distribution medium), accompanied by a
                  written offer, valid for at least three years and valid for as
                  long as you offer spare parts or customer support for that product
                  model, to give anyone who possesses the object code either (1) a
                  copy of the Corresponding Source for all the software in the
                  product that is covered by this License, on a durable physical
                  medium customarily used for software interchange, for a price no
                  more than your reasonable cost of physically performing this
                  conveying of source, or (2) access to copy the
                  Corresponding Source from a network server at no charge.
              
                  c) Convey individual copies of the object code with a copy of the
                  written offer to provide the Corresponding Source.  This
                  alternative is allowed only occasionally and noncommercially, and
                  only if you received the object code with such an offer, in accord
                  with subsection 6b.
              
                  d) Convey the object code by offering access from a designated
                  place (gratis or for a charge), and offer equivalent access to the
                  Corresponding Source in the same way through the same place at no
                  further charge.  You need not require recipients to copy the
                  Corresponding Source along with the object code.  If the place to
                  copy the object code is a network server, the Corresponding Source
                  may be on a different server (operated by you or a third party)
                  that supports equivalent copying facilities, provided you maintain
                  clear directions next to the object code saying where to find the
                  Corresponding Source.  Regardless of what server hosts the
                  Corresponding Source, you remain obligated to ensure that it is
                  available for as long as needed to satisfy these requirements.
              
                  e) Convey the object code using peer-to-peer transmission, provided
                  you inform other peers where the object code and Corresponding
                  Source of the work are being offered to the general public at no
                  charge under subsection 6d.
              
                A separable portion of the object code, whose source code is excluded
              from the Corresponding Source as a System Library, need not be
              included in conveying the object code work.
              
                A "User Product" is either (1) a "consumer product", which means any
              tangible personal property which is normally used for personal, family,
              or household purposes, or (2) anything designed or sold for incorporation
              into a dwelling.  In determining whether a product is a consumer product,
              doubtful cases shall be resolved in favor of coverage.  For a particular
              product received by a particular user, "normally used" refers to a
              typical or common use of that class of product, regardless of the status
              of the particular user or of the way in which the particular user
              actually uses, or expects or is expected to use, the product.  A product
              is a consumer product regardless of whether the product has substantial
              commercial, industrial or non-consumer uses, unless such uses represent
              the only significant mode of use of the product.
              
                "Installation Information" for a User Product means any methods,
              procedures, authorization keys, or other information required to install
              and execute modified versions of a covered work in that User Product from
              a modified version of its Corresponding Source.  The information must
              suffice to ensure that the continued functioning of the modified object
              code is in no case prevented or interfered with solely because
              modification has been made.
              
                If you convey an object code work under this section in, or with, or
              specifically for use in, a User Product, and the conveying occurs as
              part of a transaction in which the right of possession and use of the
              User Product is transferred to the recipient in perpetuity or for a
              fixed term (regardless of how the transaction is characterized), the
              Corresponding Source conveyed under this section must be accompanied
              by the Installation Information.  But this requirement does not apply
              if neither you nor any third party retains the ability to install
              modified object code on the User Product (for example, the work has
              been installed in ROM).
              
                The requirement to provide Installation Information does not include a
              requirement to continue to provide support service, warranty, or updates
              for a work that has been modified or installed by the recipient, or for
              the User Product in which it has been modified or installed.  Access to a
              network may be denied when the modification itself materially and
              adversely affects the operation of the network or violates the rules and
              protocols for communication across the network.
              
                Corresponding Source conveyed, and Installation Information provided,
              in accord with this section must be in a format that is publicly
              documented (and with an implementation available to the public in
              source code form), and must require no special password or key for
              unpacking, reading or copying.
              
                7. Additional Terms.
              
                "Additional permissions" are terms that supplement the terms of this
              License by making exceptions from one or more of its conditions.
              Additional permissions that are applicable to the entire Program shall
              be treated as though they were included in this License, to the extent
              that they are valid under applicable law.  If additional permissions
              apply only to part of the Program, that part may be used separately
              under those permissions, but the entire Program remains governed by
              this License without regard to the additional permissions.
              
                When you convey a copy of a covered work, you may at your option
              remove any additional permissions from that copy, or from any part of
              it.  (Additional permissions may be written to require their own
              removal in certain cases when you modify the work.)  You may place
              additional permissions on material, added by you to a covered work,
              for which you have or can give appropriate copyright permission.
              
                Notwithstanding any other provision of this License, for material you
              add to a covered work, you may (if authorized by the copyright holders of
              that material) supplement the terms of this License with terms:
              
                  a) Disclaiming warranty or limiting liability differently from the
                  terms of sections 15 and 16 of this License; or
              
                  b) Requiring preservation of specified reasonable legal notices or
                  author attributions in that material or in the Appropriate Legal
                  Notices displayed by works containing it; or
              
                  c) Prohibiting misrepresentation of the origin of that material, or
                  requiring that modified versions of such material be marked in
                  reasonable ways as different from the original version; or
              
                  d) Limiting the use for publicity purposes of names of licensors or
                  authors of the material; or
              
                  e) Declining to grant rights under trademark law for use of some
                  trade names, trademarks, or service marks; or
              
                  f) Requiring indemnification of licensors and authors of that
                  material by anyone who conveys the material (or modified versions of
                  it) with contractual assumptions of liability to the recipient, for
                  any liability that these contractual assumptions directly impose on
                  those licensors and authors.
              
                All other non-permissive additional terms are considered "further
              restrictions" within the meaning of section 10.  If the Program as you
              received it, or any part of it, contains a notice stating that it is
              governed by this License along with a term that is a further
              restriction, you may remove that term.  If a license document contains
              a further restriction but permits relicensing or conveying under this
              License, you may add to a covered work material governed by the terms
              of that license document, provided that the further restriction does
              not survive such relicensing or conveying.
              
                If you add terms to a covered work in accord with this section, you
              must place, in the relevant source files, a statement of the
              additional terms that apply to those files, or a notice indicating
              where to find the applicable terms.
              
                Additional terms, permissive or non-permissive, may be stated in the
              form of a separately written license, or stated as exceptions;
              the above requirements apply either way.
              
                8. Termination.
              
                You may not propagate or modify a covered work except as expressly
              provided under this License.  Any attempt otherwise to propagate or
              modify it is void, and will automatically terminate your rights under
              this License (including any patent licenses granted under the third
              paragraph of section 11).
              
                However, if you cease all violation of this License, then your
              license from a particular copyright holder is reinstated (a)
              provisionally, unless and until the copyright holder explicitly and
              finally terminates your license, and (b) permanently, if the copyright
              holder fails to notify you of the violation by some reasonable means
              prior to 60 days after the cessation.
              
                Moreover, your license from a particular copyright holder is
              reinstated permanently if the copyright holder notifies you of the
              violation by some reasonable means, this is the first time you have
              received notice of violation of this License (for any work) from that
              copyright holder, and you cure the violation prior to 30 days after
              your receipt of the notice.
              
                Termination of your rights under this section does not terminate the
              licenses of parties who have received copies or rights from you under
              this License.  If your rights have been terminated and not permanently
              reinstated, you do not qualify to receive new licenses for the same
              material under section 10.
              
                9. Acceptance Not Required for Having Copies.
              
                You are not required to accept this License in order to receive or
              run a copy of the Program.  Ancillary propagation of a covered work
              occurring solely as a consequence of using peer-to-peer transmission
              to receive a copy likewise does not require acceptance.  However,
              nothing other than this License grants you permission to propagate or
              modify any covered work.  These actions infringe copyright if you do
              not accept this License.  Therefore, by modifying or propagating a
              covered work, you indicate your acceptance of this License to do so.
              
                10. Automatic Licensing of Downstream Recipients.
              
                Each time you convey a covered work, the recipient automatically
              receives a license from the original licensors, to run, modify and
              propagate that work, subject to this License.  You are not responsible
              for enforcing compliance by third parties with this License.
              
                An "entity transaction" is a transaction transferring control of an
              organization, or substantially all assets of one, or subdividing an
              organization, or merging organizations.  If propagation of a covered
              work results from an entity transaction, each party to that
              transaction who receives a copy of the work also receives whatever
              licenses to the work the party's predecessor in interest had or could
              give under the previous paragraph, plus a right to possession of the
              Corresponding Source of the work from the predecessor in interest, if
              the predecessor has it or can get it with reasonable efforts.
              
                You may not impose any further restrictions on the exercise of the
              rights granted or affirmed under this License.  For example, you may
              not impose a license fee, royalty, or other charge for exercise of
              rights granted under this License, and you may not initiate litigation
              (including a cross-claim or counterclaim in a lawsuit) alleging that
              any patent claim is infringed by making, using, selling, offering for
              sale, or importing the Program or any portion of it.
              
                11. Patents.
              
                A "contributor" is a copyright holder who authorizes use under this
              License of the Program or a work on which the Program is based.  The
              work thus licensed is called the contributor's "contributor version".
              
                A contributor's "essential patent claims" are all patent claims
              owned or controlled by the contributor, whether already acquired or
              hereafter acquired, that would be infringed by some manner, permitted
              by this License, of making, using, or selling its contributor version,
              but do not include claims that would be infringed only as a
              consequence of further modification of the contributor version.  For
              purposes of this definition, "control" includes the right to grant
              patent sublicenses in a manner consistent with the requirements of
              this License.
              
                Each contributor grants you a non-exclusive, worldwide, royalty-free
              patent license under the contributor's essential patent claims, to
              make, use, sell, offer for sale, import and otherwise run, modify and
              propagate the contents of its contributor version.
              
                In the following three paragraphs, a "patent license" is any express
              agreement or commitment, however denominated, not to enforce a patent
              (such as an express permission to practice a patent or covenant not to
              sue for patent infringement).  To "grant" such a patent license to a
              party means to make such an agreement or commitment not to enforce a
              patent against the party.
              
                If you convey a covered work, knowingly relying on a patent license,
              and the Corresponding Source of the work is not available for anyone
              to copy, free of charge and under the terms of this License, through a
              publicly available network server or other readily accessible means,
              then you must either (1) cause the Corresponding Source to be so
              available, or (2) arrange to deprive yourself of the benefit of the
              patent license for this particular work, or (3) arrange, in a manner
              consistent with the requirements of this License, to extend the patent
              license to downstream recipients.  "Knowingly relying" means you have
              actual knowledge that, but for the patent license, your conveying the
              covered work in a country, or your recipient's use of the covered work
              in a country, would infringe one or more identifiable patents in that
              country that you have reason to believe are valid.
              
                If, pursuant to or in connection with a single transaction or
              arrangement, you convey, or propagate by procuring conveyance of, a
              covered work, and grant a patent license to some of the parties
              receiving the covered work authorizing them to use, propagate, modify
              or convey a specific copy of the covered work, then the patent license
              you grant is automatically extended to all recipients of the covered
              work and works based on it.
              
                A patent license is "discriminatory" if it does not include within
              the scope of its coverage, prohibits the exercise of, or is
              conditioned on the non-exercise of one or more of the rights that are
              specifically granted under this License.  You may not convey a covered
              work if you are a party to an arrangement with a third party that is
              in the business of distributing software, under which you make payment
              to the third party based on the extent of your activity of conveying
              the work, and under which the third party grants, to any of the
              parties who would receive the covered work from you, a discriminatory
              patent license (a) in connection with copies of the covered work
              conveyed by you (or copies made from those copies), or (b) primarily
              for and in connection with specific products or compilations that
              contain the covered work, unless you entered into that arrangement,
              or that patent license was granted, prior to 28 March 2007.
              
                Nothing in this License shall be construed as excluding or limiting
              any implied license or other defenses to infringement that may
              otherwise be available to you under applicable patent law.
              
                12. No Surrender of Others' Freedom.
              
                If conditions are imposed on you (whether by court order, agreement or
              otherwise) that contradict the conditions of this License, they do not
              excuse you from the conditions of this License.  If you cannot convey a
              covered work so as to satisfy simultaneously your obligations under this
              License and any other pertinent obligations, then as a consequence you may
              not convey it at all.  For example, if you agree to terms that obligate you
              to collect a royalty for further conveying from those to whom you convey
              the Program, the only way you could satisfy both those terms and this
              License would be to refrain entirely from conveying the Program.
              
                13. Use with the GNU Affero General Public License.
              
                Notwithstanding any other provision of this License, you have
              permission to link or combine any covered work with a work licensed
              under version 3 of the GNU Affero General Public License into a single
              combined work, and to convey the resulting work.  The terms of this
              License will continue to apply to the part which is the covered work,
              but the special requirements of the GNU Affero General Public License,
              section 13, concerning interaction through a network will apply to the
              combination as such.
              
                14. Revised Versions of this License.
              
                The Free Software Foundation may publish revised and/or new versions of
              the GNU General Public License from time to time.  Such new versions will
              be similar in spirit to the present version, but may differ in detail to
              address new problems or concerns.
              
                Each version is given a distinguishing version number.  If the
              Program specifies that a certain numbered version of the GNU General
              Public License "or any later version" applies to it, you have the
              option of following the terms and conditions either of that numbered
              version or of any later version published by the Free Software
              Foundation.  If the Program does not specify a version number of the
              GNU General Public License, you may choose any version ever published
              by the Free Software Foundation.
              
                If the Program specifies that a proxy can decide which future
              versions of the GNU General Public License can be used, that proxy's
              public statement of acceptance of a version permanently authorizes you
              to choose that version for the Program.
              
                Later license versions may give you additional or different
              permissions.  However, no additional obligations are imposed on any
              author or copyright holder as a result of your choosing to follow a
              later version.
              
                15. Disclaimer of Warranty.
              
                THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
              APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
              HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
              OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
              THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
              PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
              IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
              ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
              
                16. Limitation of Liability.
              
                IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
              WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
              THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
              GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
              USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
              DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
              PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
              EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
              SUCH DAMAGES.
              
                17. Interpretation of Sections 15 and 16.
              
                If the disclaimer of warranty and limitation of liability provided
              above cannot be given local legal effect according to their terms,
              reviewing courts shall apply local law that most closely approximates
              an absolute waiver of all civil liability in connection with the
              Program, unless a warranty or assumption of liability accompanies a
              copy of the Program in return for a fee.
              
                                   END OF TERMS AND CONDITIONS
              
                          How to Apply These Terms to Your New Programs
              
                If you develop a new program, and you want it to be of the greatest
              possible use to the public, the best way to achieve this is to make it
              free software which everyone can redistribute and change under these terms.
              
                To do so, attach the following notices to the program.  It is safest
              to attach them to the start of each source file to most effectively
              state the exclusion of warranty; and each file should have at least
              the "copyright" line and a pointer to where the full notice is found.
              
                  <one line to give the program's name and a brief idea of what it does.>
                  Copyright (C) <year>  <name of author>
              
                  This program is free software: you can redistribute it and/or modify
                  it under the terms of the GNU General Public License as published by
                  the Free Software Foundation, either version 3 of the License, or
                  (at your option) any later version.
              
                  This program is distributed in the hope that it will be useful,
                  but WITHOUT ANY WARRANTY; without even the implied warranty of
                  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                  GNU General Public License for more details.
              
                  You should have received a copy of the GNU General Public License
                  along with this program.  If not, see <http://www.gnu.org/licenses/>.
              
              Also add information on how to contact you by electronic and paper mail.
              
                If the program does terminal interaction, make it output a short
              notice like this when it starts in an interactive mode:
              
                  <program>  Copyright (C) <year>  <name of author>
                  This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
                  This is free software, and you are welcome to redistribute it
                  under certain conditions; type `show c' for details.
              
              The hypothetical commands `show w' and `show c' should show the appropriate
              parts of the General Public License.  Of course, your program's commands
              might be different; for a GUI interface, you would use an "about box".
              
                You should also get your employer (if you work as a programmer) or school,
              if any, to sign a "copyright disclaimer" for the program, if necessary.
              For more information on this, and how to apply and follow the GNU GPL, see
              <http://www.gnu.org/licenses/>.
              
                The GNU General Public License does not permit incorporating your program
              into proprietary programs.  If your program is a subroutine library, you
              may consider it more useful to permit linking proprietary applications with
              the library.  If this is what you want to do, use the GNU Lesser General
              Public License instead of this License.  But first, please read
              <http://www.gnu.org/philosophy/why-not-lgpl.html>.
              
              */

              File 4 of 12: ERC4626Bridge
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec.
              pragma solidity >=0.8.4;
              import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
              import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
              import {IERC4626} from "@openzeppelin/contracts/interfaces/IERC4626.sol";
              import {IRollupProcessor} from "../../aztec/interfaces/IRollupProcessor.sol";
              import {AztecTypes} from "../../aztec/libraries/AztecTypes.sol";
              import {BridgeBase} from "../base/BridgeBase.sol";
              import {ErrorLib} from "../base/ErrorLib.sol";
              import {IWETH} from "../../interfaces/IWETH.sol";
              /**
               * @title Aztec Connect Bridge for ERC4626 compatible vaults
               * @author johhonn (on github) and the Aztec team
               * @notice You can use this contract to issue or redeem shares of any ERC4626 vault
               */
              contract ERC4626Bridge is BridgeBase {
                  using SafeERC20 for IERC20;
                  IWETH public constant WETH = IWETH(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
                  /**
                   * @notice Sets the address of RollupProcessor
                   * @param _rollupProcessor Address of RollupProcessor
                   */
                  constructor(address _rollupProcessor) BridgeBase(_rollupProcessor) {}
                  receive() external payable {}
                  /**
                   * @notice Sets all the approvals necessary for issuance and redemption of `_vault` shares and registers
                   *         derived criteria in the Subsidy contract
                   * @param _vault An address of erc4626 vault
                   */
                  function listVault(address _vault) external {
                      IERC20 asset = IERC20(IERC4626(_vault).asset());
                      // Resetting allowance to 0 for USDT compatibility
                      asset.safeApprove(address(_vault), 0);
                      asset.safeApprove(address(_vault), type(uint256).max);
                      asset.safeApprove(address(ROLLUP_PROCESSOR), 0);
                      asset.safeApprove(address(ROLLUP_PROCESSOR), type(uint256).max);
                      IERC20(_vault).approve(ROLLUP_PROCESSOR, type(uint256).max);
                      // Registering the vault for subsidy
                      uint256[] memory criteria = new uint256[](2);
                      uint32[] memory gasUsage = new uint32[](2);
                      uint32[] memory minGasPerMinute = new uint32[](2);
                      // Having 2 different criteria for deposit and withdrawal flow
                      criteria[0] = _computeCriteria(address(asset), _vault);
                      criteria[1] = _computeCriteria(_vault, address(asset));
                      gasUsage[0] = 200000;
                      gasUsage[1] = 200000;
                      // This is approximately 200k / (24 * 60) / 2 --> targeting 1 full subsidized call per 2 days
                      minGasPerMinute[0] = 70;
                      minGasPerMinute[1] = 70;
                      // We set gas usage and minGasPerMinute in the Subsidy contract
                      SUBSIDY.setGasUsageAndMinGasPerMinute(criteria, gasUsage, minGasPerMinute);
                  }
                  /**
                   * @notice Issues or redeems shares of any ERC4626 vault
                   * @param _inputAssetA Vault asset (deposit) or vault shares (redeem)
                   * @param _outputAssetA Vault shares (deposit) or vault asset (redeem)
                   * @param _totalInputValue The amount of assets to deposit or shares to redeem
                   * @param _interactionNonce A globally unique identifier of this call
                   * @param _auxData Number indicating which flow to execute (0 is deposit flow, 1 is redeem flow)
                   * @param _rollupBeneficiary - Address which receives subsidy if the call is eligible for it
                   * @return outputValueA The amount of shares (deposit) or assets (redeem) returned
                   * @dev Not checking validity of input/output assets because if they were invalid, approvals could not get set
                   *      in the `listVault(...)` method.
                   * @dev In case input or output asset is ETH, the bridge wraps/unwraps it.
                   */
                  function convert(
                      AztecTypes.AztecAsset calldata _inputAssetA,
                      AztecTypes.AztecAsset calldata,
                      AztecTypes.AztecAsset calldata _outputAssetA,
                      AztecTypes.AztecAsset calldata,
                      uint256 _totalInputValue,
                      uint256 _interactionNonce,
                      uint64 _auxData,
                      address _rollupBeneficiary
                  )
                      external
                      payable
                      override(BridgeBase)
                      onlyRollup
                      returns (
                          uint256 outputValueA,
                          uint256,
                          bool
                      )
                  {
                      address inputToken = _inputAssetA.erc20Address;
                      address outputToken = _outputAssetA.erc20Address;
                      if (_auxData == 0) {
                          // Issuing new shares - input can be ETH
                          if (_inputAssetA.assetType == AztecTypes.AztecAssetType.ETH) {
                              WETH.deposit{value: _totalInputValue}();
                              inputToken = address(WETH);
                          }
                          // If input asset is not the vault asset (or ETH if vault asset is WETH) the following will revert when
                          // trying to pull the funds from the bridge
                          outputValueA = IERC4626(_outputAssetA.erc20Address).deposit(_totalInputValue, address(this));
                      } else if (_auxData == 1) {
                          // Redeeming shares
                          // If output asset is not the vault asset the convert call will revert when RollupProcessor tries to pull
                          // the funds from the bridge
                          outputValueA = IERC4626(_inputAssetA.erc20Address).redeem(_totalInputValue, address(this), address(this));
                          if (_outputAssetA.assetType == AztecTypes.AztecAssetType.ETH) {
                              IWETH(WETH).withdraw(outputValueA);
                              IRollupProcessor(ROLLUP_PROCESSOR).receiveEthFromBridge{value: outputValueA}(_interactionNonce);
                              outputToken = address(WETH);
                          }
                      } else {
                          revert ErrorLib.InvalidAuxData();
                      }
                      // Accumulate subsidy to _rollupBeneficiary
                      SUBSIDY.claimSubsidy(_computeCriteria(inputToken, outputToken), _rollupBeneficiary);
                  }
                  /**
                   * @notice Computes the criteria that is passed when claiming subsidy.
                   * @param _inputAssetA The input asset
                   * @param _outputAssetA The output asset
                   * @return The criteria
                   */
                  function computeCriteria(
                      AztecTypes.AztecAsset calldata _inputAssetA,
                      AztecTypes.AztecAsset calldata,
                      AztecTypes.AztecAsset calldata _outputAssetA,
                      AztecTypes.AztecAsset calldata,
                      uint64
                  ) public pure override(BridgeBase) returns (uint256) {
                      return _computeCriteria(_inputAssetA.erc20Address, _outputAssetA.erc20Address);
                  }
                  function _computeCriteria(address _inputToken, address _outputToken) private pure returns (uint256) {
                      return uint256(keccak256(abi.encodePacked(_inputToken, _outputToken)));
                  }
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
              pragma solidity ^0.8.0;
              /**
               * @dev Interface of the ERC20 standard as defined in the EIP.
               */
              interface IERC20 {
                  /**
                   * @dev Emitted when `value` tokens are moved from one account (`from`) to
                   * another (`to`).
                   *
                   * Note that `value` may be zero.
                   */
                  event Transfer(address indexed from, address indexed to, uint256 value);
                  /**
                   * @dev Emitted when the allowance of a `spender` for an `owner` is set by
                   * a call to {approve}. `value` is the new allowance.
                   */
                  event Approval(address indexed owner, address indexed spender, uint256 value);
                  /**
                   * @dev Returns the amount of tokens in existence.
                   */
                  function totalSupply() external view returns (uint256);
                  /**
                   * @dev Returns the amount of tokens owned by `account`.
                   */
                  function balanceOf(address account) external view returns (uint256);
                  /**
                   * @dev Moves `amount` tokens from the caller's account to `to`.
                   *
                   * Returns a boolean value indicating whether the operation succeeded.
                   *
                   * Emits a {Transfer} event.
                   */
                  function transfer(address to, uint256 amount) external returns (bool);
                  /**
                   * @dev Returns the remaining number of tokens that `spender` will be
                   * allowed to spend on behalf of `owner` through {transferFrom}. This is
                   * zero by default.
                   *
                   * This value changes when {approve} or {transferFrom} are called.
                   */
                  function allowance(address owner, address spender) external view returns (uint256);
                  /**
                   * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
                   *
                   * Returns a boolean value indicating whether the operation succeeded.
                   *
                   * IMPORTANT: Beware that changing an allowance with this method brings the risk
                   * that someone may use both the old and the new allowance by unfortunate
                   * transaction ordering. One possible solution to mitigate this race
                   * condition is to first reduce the spender's allowance to 0 and set the
                   * desired value afterwards:
                   * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
                   *
                   * Emits an {Approval} event.
                   */
                  function approve(address spender, uint256 amount) external returns (bool);
                  /**
                   * @dev Moves `amount` tokens from `from` to `to` using the
                   * allowance mechanism. `amount` is then deducted from the caller's
                   * allowance.
                   *
                   * Returns a boolean value indicating whether the operation succeeded.
                   *
                   * Emits a {Transfer} event.
                   */
                  function transferFrom(
                      address from,
                      address to,
                      uint256 amount
                  ) external returns (bool);
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)
              pragma solidity ^0.8.0;
              import "../IERC20.sol";
              import "../extensions/draft-IERC20Permit.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));
                      }
                  }
                  function safePermit(
                      IERC20Permit token,
                      address owner,
                      address spender,
                      uint256 value,
                      uint256 deadline,
                      uint8 v,
                      bytes32 r,
                      bytes32 s
                  ) internal {
                      uint256 nonceBefore = token.nonces(owner);
                      token.permit(owner, spender, value, deadline, v, r, s);
                      uint256 nonceAfter = token.nonces(owner);
                      require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
                  }
                  /**
                   * @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");
                      }
                  }
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts (last updated v4.7.0) (interfaces/IERC4626.sol)
              pragma solidity ^0.8.0;
              import "../token/ERC20/IERC20.sol";
              import "../token/ERC20/extensions/IERC20Metadata.sol";
              /**
               * @dev Interface of the ERC4626 "Tokenized Vault Standard", as defined in
               * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].
               *
               * _Available since v4.7._
               */
              interface IERC4626 is IERC20, IERC20Metadata {
                  event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares);
                  event Withdraw(
                      address indexed caller,
                      address indexed receiver,
                      address indexed owner,
                      uint256 assets,
                      uint256 shares
                  );
                  /**
                   * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.
                   *
                   * - MUST be an ERC-20 token contract.
                   * - MUST NOT revert.
                   */
                  function asset() external view returns (address assetTokenAddress);
                  /**
                   * @dev Returns the total amount of the underlying asset that is “managed” by Vault.
                   *
                   * - SHOULD include any compounding that occurs from yield.
                   * - MUST be inclusive of any fees that are charged against assets in the Vault.
                   * - MUST NOT revert.
                   */
                  function totalAssets() external view returns (uint256 totalManagedAssets);
                  /**
                   * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal
                   * scenario where all the conditions are met.
                   *
                   * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
                   * - MUST NOT show any variations depending on the caller.
                   * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
                   * - MUST NOT revert.
                   *
                   * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
                   * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
                   * from.
                   */
                  function convertToShares(uint256 assets) external view returns (uint256 shares);
                  /**
                   * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal
                   * scenario where all the conditions are met.
                   *
                   * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
                   * - MUST NOT show any variations depending on the caller.
                   * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
                   * - MUST NOT revert.
                   *
                   * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
                   * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
                   * from.
                   */
                  function convertToAssets(uint256 shares) external view returns (uint256 assets);
                  /**
                   * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,
                   * through a deposit call.
                   *
                   * - MUST return a limited value if receiver is subject to some deposit limit.
                   * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.
                   * - MUST NOT revert.
                   */
                  function maxDeposit(address receiver) external view returns (uint256 maxAssets);
                  /**
                   * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given
                   * current on-chain conditions.
                   *
                   * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit
                   *   call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called
                   *   in the same transaction.
                   * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the
                   *   deposit would be accepted, regardless if the user has enough tokens approved, etc.
                   * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
                   * - MUST NOT revert.
                   *
                   * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in
                   * share price or some other type of condition, meaning the depositor will lose assets by depositing.
                   */
                  function previewDeposit(uint256 assets) external view returns (uint256 shares);
                  /**
                   * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.
                   *
                   * - MUST emit the Deposit event.
                   * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
                   *   deposit execution, and are accounted for during deposit.
                   * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not
                   *   approving enough underlying tokens to the Vault contract, etc).
                   *
                   * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
                   */
                  function deposit(uint256 assets, address receiver) external returns (uint256 shares);
                  /**
                   * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.
                   * - MUST return a limited value if receiver is subject to some mint limit.
                   * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.
                   * - MUST NOT revert.
                   */
                  function maxMint(address receiver) external view returns (uint256 maxShares);
                  /**
                   * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given
                   * current on-chain conditions.
                   *
                   * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call
                   *   in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the
                   *   same transaction.
                   * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint
                   *   would be accepted, regardless if the user has enough tokens approved, etc.
                   * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
                   * - MUST NOT revert.
                   *
                   * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in
                   * share price or some other type of condition, meaning the depositor will lose assets by minting.
                   */
                  function previewMint(uint256 shares) external view returns (uint256 assets);
                  /**
                   * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.
                   *
                   * - MUST emit the Deposit event.
                   * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint
                   *   execution, and are accounted for during mint.
                   * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not
                   *   approving enough underlying tokens to the Vault contract, etc).
                   *
                   * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
                   */
                  function mint(uint256 shares, address receiver) external returns (uint256 assets);
                  /**
                   * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the
                   * Vault, through a withdraw call.
                   *
                   * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
                   * - MUST NOT revert.
                   */
                  function maxWithdraw(address owner) external view returns (uint256 maxAssets);
                  /**
                   * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,
                   * given current on-chain conditions.
                   *
                   * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw
                   *   call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if
                   *   called
                   *   in the same transaction.
                   * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though
                   *   the withdrawal would be accepted, regardless if the user has enough shares, etc.
                   * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
                   * - MUST NOT revert.
                   *
                   * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in
                   * share price or some other type of condition, meaning the depositor will lose assets by depositing.
                   */
                  function previewWithdraw(uint256 assets) external view returns (uint256 shares);
                  /**
                   * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.
                   *
                   * - MUST emit the Withdraw event.
                   * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
                   *   withdraw execution, and are accounted for during withdraw.
                   * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner
                   *   not having enough shares, etc).
                   *
                   * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
                   * Those methods should be performed separately.
                   */
                  function withdraw(
                      uint256 assets,
                      address receiver,
                      address owner
                  ) external returns (uint256 shares);
                  /**
                   * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,
                   * through a redeem call.
                   *
                   * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
                   * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.
                   * - MUST NOT revert.
                   */
                  function maxRedeem(address owner) external view returns (uint256 maxShares);
                  /**
                   * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,
                   * given current on-chain conditions.
                   *
                   * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call
                   *   in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the
                   *   same transaction.
                   * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the
                   *   redemption would be accepted, regardless if the user has enough shares, etc.
                   * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
                   * - MUST NOT revert.
                   *
                   * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in
                   * share price or some other type of condition, meaning the depositor will lose assets by redeeming.
                   */
                  function previewRedeem(uint256 shares) external view returns (uint256 assets);
                  /**
                   * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.
                   *
                   * - MUST emit the Withdraw event.
                   * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
                   *   redeem execution, and are accounted for during redeem.
                   * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner
                   *   not having enough shares, etc).
                   *
                   * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
                   * Those methods should be performed separately.
                   */
                  function redeem(
                      uint256 shares,
                      address receiver,
                      address owner
                  ) external returns (uint256 assets);
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              // @dev For documentation of the functions within this interface see RollupProcessor contract
              interface IRollupProcessor {
                  /*----------------------------------------
                  EVENTS
                  ----------------------------------------*/
                  event OffchainData(uint256 indexed rollupId, uint256 chunk, uint256 totalChunks, address sender);
                  event RollupProcessed(uint256 indexed rollupId, bytes32[] nextExpectedDefiHashes, address sender);
                  event DefiBridgeProcessed(
                      uint256 indexed encodedBridgeCallData,
                      uint256 indexed nonce,
                      uint256 totalInputValue,
                      uint256 totalOutputValueA,
                      uint256 totalOutputValueB,
                      bool result,
                      bytes errorReason
                  );
                  event AsyncDefiBridgeProcessed(
                      uint256 indexed encodedBridgeCallData,
                      uint256 indexed nonce,
                      uint256 totalInputValue
                  );
                  event Deposit(uint256 indexed assetId, address indexed depositorAddress, uint256 depositValue);
                  event WithdrawError(bytes errorReason);
                  event AssetAdded(uint256 indexed assetId, address indexed assetAddress, uint256 assetGasLimit);
                  event BridgeAdded(uint256 indexed bridgeAddressId, address indexed bridgeAddress, uint256 bridgeGasLimit);
                  event RollupProviderUpdated(address indexed providerAddress, bool valid);
                  event VerifierUpdated(address indexed verifierAddress);
                  event Paused(address account);
                  event Unpaused(address account);
                  /*----------------------------------------
                    MUTATING FUNCTIONS
                    ----------------------------------------*/
                  function pause() external;
                  function unpause() external;
                  function setRollupProvider(address _provider, bool _valid) external;
                  function setVerifier(address _verifier) external;
                  function setAllowThirdPartyContracts(bool _allowThirdPartyContracts) external;
                  function setDefiBridgeProxy(address _defiBridgeProxy) external;
                  function setSupportedAsset(address _token, uint256 _gasLimit) external;
                  function setSupportedBridge(address _bridge, uint256 _gasLimit) external;
                  function processRollup(bytes calldata _encodedProofData, bytes calldata _signatures) external;
                  function receiveEthFromBridge(uint256 _interactionNonce) external payable;
                  function approveProof(bytes32 _proofHash) external;
                  function depositPendingFunds(
                      uint256 _assetId,
                      uint256 _amount,
                      address _owner,
                      bytes32 _proofHash
                  ) external payable;
                  function offchainData(
                      uint256 _rollupId,
                      uint256 _chunk,
                      uint256 _totalChunks,
                      bytes calldata _offchainTxData
                  ) external;
                  function processAsyncDefiInteraction(uint256 _interactionNonce) external returns (bool);
                  /*----------------------------------------
                    NON-MUTATING FUNCTIONS
                    ----------------------------------------*/
                  function rollupStateHash() external view returns (bytes32);
                  function userPendingDeposits(uint256 _assetId, address _user) external view returns (uint256);
                  function defiBridgeProxy() external view returns (address);
                  function prevDefiInteractionsHash() external view returns (bytes32);
                  function paused() external view returns (bool);
                  function verifier() external view returns (address);
                  function getDataSize() external view returns (uint256);
                  function getPendingDefiInteractionHashesLength() external view returns (uint256);
                  function getDefiInteractionHashesLength() external view returns (uint256);
                  function getAsyncDefiInteractionHashesLength() external view returns (uint256);
                  function getSupportedBridge(uint256 _bridgeAddressId) external view returns (address);
                  function getSupportedBridgesLength() external view returns (uint256);
                  function getSupportedAssetsLength() external view returns (uint256);
                  function getSupportedAsset(uint256 _assetId) external view returns (address);
                  function getEscapeHatchStatus() external view returns (bool, uint256);
                  function assetGasLimits(uint256 _bridgeAddressId) external view returns (uint256);
                  function bridgeGasLimits(uint256 _bridgeAddressId) external view returns (uint256);
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              library AztecTypes {
                  enum AztecAssetType {
                      NOT_USED,
                      ETH,
                      ERC20,
                      VIRTUAL
                  }
                  struct AztecAsset {
                      uint256 id;
                      address erc20Address;
                      AztecAssetType assetType;
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec.
              pragma solidity >=0.8.4;
              import {IDefiBridge} from "../../aztec/interfaces/IDefiBridge.sol";
              import {ISubsidy} from "../../aztec/interfaces/ISubsidy.sol";
              import {AztecTypes} from "../../aztec/libraries/AztecTypes.sol";
              import {ErrorLib} from "./ErrorLib.sol";
              /**
               * @title BridgeBase
               * @notice A base that bridges can be built upon which imports a limited set of features
               * @dev Reverts `convert` with missing implementation, and `finalise` with async disabled
               * @author Lasse Herskind
               */
              abstract contract BridgeBase is IDefiBridge {
                  error MissingImplementation();
                  ISubsidy public constant SUBSIDY = ISubsidy(0xABc30E831B5Cc173A9Ed5941714A7845c909e7fA);
                  address public immutable ROLLUP_PROCESSOR;
                  constructor(address _rollupProcessor) {
                      ROLLUP_PROCESSOR = _rollupProcessor;
                  }
                  modifier onlyRollup() {
                      if (msg.sender != ROLLUP_PROCESSOR) {
                          revert ErrorLib.InvalidCaller();
                      }
                      _;
                  }
                  function convert(
                      AztecTypes.AztecAsset calldata,
                      AztecTypes.AztecAsset calldata,
                      AztecTypes.AztecAsset calldata,
                      AztecTypes.AztecAsset calldata,
                      uint256,
                      uint256,
                      uint64,
                      address
                  )
                      external
                      payable
                      virtual
                      override(IDefiBridge)
                      returns (
                          uint256,
                          uint256,
                          bool
                      )
                  {
                      revert MissingImplementation();
                  }
                  function finalise(
                      AztecTypes.AztecAsset calldata,
                      AztecTypes.AztecAsset calldata,
                      AztecTypes.AztecAsset calldata,
                      AztecTypes.AztecAsset calldata,
                      uint256,
                      uint64
                  )
                      external
                      payable
                      virtual
                      override(IDefiBridge)
                      returns (
                          uint256,
                          uint256,
                          bool
                      )
                  {
                      revert ErrorLib.AsyncDisabled();
                  }
                  /**
                   * @notice Computes the criteria that is passed on to the subsidy contract when claiming
                   * @dev Should be overridden by bridge implementation if intended to limit subsidy.
                   * @return The criteria to be passed along
                   */
                  function computeCriteria(
                      AztecTypes.AztecAsset calldata,
                      AztecTypes.AztecAsset calldata,
                      AztecTypes.AztecAsset calldata,
                      AztecTypes.AztecAsset calldata,
                      uint64
                  ) public view virtual returns (uint256) {
                      return 0;
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec.
              pragma solidity >=0.8.4;
              library ErrorLib {
                  error InvalidCaller();
                  error InvalidInput();
                  error InvalidInputA();
                  error InvalidInputB();
                  error InvalidOutputA();
                  error InvalidOutputB();
                  error InvalidInputAmount();
                  error InvalidAuxData();
                  error ApproveFailed(address token);
                  error TransferFailed(address token);
                  error InvalidNonce();
                  error AsyncDisabled();
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec.
              pragma solidity >=0.8.4;
              import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
              interface IWETH is IERC20 {
                  function deposit() external payable;
                  function withdraw(uint256 amount) external;
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)
              pragma solidity ^0.8.0;
              /**
               * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
               * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
               *
               * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
               * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
               * need to send a transaction, and thus is not required to hold Ether at all.
               */
              interface IERC20Permit {
                  /**
                   * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
                   * given ``owner``'s signed approval.
                   *
                   * IMPORTANT: The same issues {IERC20-approve} has related to transaction
                   * ordering also apply here.
                   *
                   * Emits an {Approval} event.
                   *
                   * Requirements:
                   *
                   * - `spender` cannot be the zero address.
                   * - `deadline` must be a timestamp in the future.
                   * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
                   * over the EIP712-formatted function arguments.
                   * - the signature must use ``owner``'s current nonce (see {nonces}).
                   *
                   * For more information on the signature format, see the
                   * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
                   * section].
                   */
                  function permit(
                      address owner,
                      address spender,
                      uint256 value,
                      uint256 deadline,
                      uint8 v,
                      bytes32 r,
                      bytes32 s
                  ) external;
                  /**
                   * @dev Returns the current nonce for `owner`. This value must be
                   * included whenever a signature is generated for {permit}.
                   *
                   * Every successful call to {permit} increases ``owner``'s nonce by one. This
                   * prevents a signature from being used multiple times.
                   */
                  function nonces(address owner) external view returns (uint256);
                  /**
                   * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
                   */
                  // solhint-disable-next-line func-name-mixedcase
                  function DOMAIN_SEPARATOR() external view returns (bytes32);
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts (last updated v4.7.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
                              /// @solidity memory-safe-assembly
                              assembly {
                                  let returndata_size := mload(returndata)
                                  revert(add(32, returndata), returndata_size)
                              }
                          } else {
                              revert(errorMessage);
                          }
                      }
                  }
              }
              // 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);
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              import {AztecTypes} from "../libraries/AztecTypes.sol";
              interface IDefiBridge {
                  /**
                   * @notice A function which converts input assets to output assets.
                   * @param _inputAssetA A struct detailing the first input asset
                   * @param _inputAssetB A struct detailing the second input asset
                   * @param _outputAssetA A struct detailing the first output asset
                   * @param _outputAssetB A struct detailing the second output asset
                   * @param _totalInputValue An amount of input assets transferred to the bridge (Note: "total" is in the name
                   *                         because the value can represent summed/aggregated token amounts of users actions on L2)
                   * @param _interactionNonce A globally unique identifier of this interaction/`convert(...)` call.
                   * @param _auxData Bridge specific data to be passed into the bridge contract (e.g. slippage, nftID etc.)
                   * @return outputValueA An amount of `_outputAssetA` returned from this interaction.
                   * @return outputValueB An amount of `_outputAssetB` returned from this interaction.
                   * @return isAsync A flag indicating if the interaction is async.
                   * @dev This function is called from the RollupProcessor contract via the DefiBridgeProxy. Before this function is
                   *      called _RollupProcessor_ contract will have sent you all the assets defined by the input params. This
                   *      function is expected to convert input assets to output assets (e.g. on Uniswap) and return the amounts
                   *      of output assets to be received by the _RollupProcessor_. If output assets are ERC20 tokens the bridge has
                   *      to _RollupProcessor_ as a spender before the interaction is finished. If some of the output assets is ETH
                   *      it has to be sent to _RollupProcessor_ via the `receiveEthFromBridge(uint256 _interactionNonce)` method
                   *      inside before the `convert(...)` function call finishes.
                   * @dev If there are two input assets, equal amounts of both assets will be transferred to the bridge before this
                   *      method is called.
                   * @dev **BOTH** output assets could be virtual but since their `assetId` is currently assigned as
                   *      `_interactionNonce` it would simply mean that more of the same virtual asset is minted.
                   * @dev If this interaction is async the function has to return `(0,0 true)`. Async interaction will be finalised at
                   *      a later time and its output assets will be returned in a `IDefiBridge.finalise(...)` call.
                   **/
                  function convert(
                      AztecTypes.AztecAsset calldata _inputAssetA,
                      AztecTypes.AztecAsset calldata _inputAssetB,
                      AztecTypes.AztecAsset calldata _outputAssetA,
                      AztecTypes.AztecAsset calldata _outputAssetB,
                      uint256 _totalInputValue,
                      uint256 _interactionNonce,
                      uint64 _auxData,
                      address _rollupBeneficiary
                  )
                      external
                      payable
                      returns (
                          uint256 outputValueA,
                          uint256 outputValueB,
                          bool isAsync
                      );
                  /**
                   * @notice A function that finalises asynchronous interaction.
                   * @param _inputAssetA A struct detailing the first input asset
                   * @param _inputAssetB A struct detailing the second input asset
                   * @param _outputAssetA A struct detailing the first output asset
                   * @param _outputAssetB A struct detailing the second output asset
                   * @param _interactionNonce A globally unique identifier of this interaction/`convert(...)` call.
                   * @param _auxData Bridge specific data to be passed into the bridge contract (e.g. slippage, nftID etc.)
                   * @return outputValueA An amount of `_outputAssetA` returned from this interaction.
                   * @return outputValueB An amount of `_outputAssetB` returned from this interaction.
                   * @dev This function should use the `BridgeBase.onlyRollup()` modifier to ensure it can only be called from
                   *      the `RollupProcessor.processAsyncDefiInteraction(uint256 _interactionNonce)` method.
                   **/
                  function finalise(
                      AztecTypes.AztecAsset calldata _inputAssetA,
                      AztecTypes.AztecAsset calldata _inputAssetB,
                      AztecTypes.AztecAsset calldata _outputAssetA,
                      AztecTypes.AztecAsset calldata _outputAssetB,
                      uint256 _interactionNonce,
                      uint64 _auxData
                  )
                      external
                      payable
                      returns (
                          uint256 outputValueA,
                          uint256 outputValueB,
                          bool interactionComplete
                      );
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              // @dev documentation of this interface is in its implementation (Subsidy contract)
              interface ISubsidy {
                  /**
                   * @notice Container for Subsidy related information
                   * @member available Amount of ETH remaining to be paid out
                   * @member gasUsage Amount of gas the interaction consumes (used to define max possible payout)
                   * @member minGasPerMinute Minimum amount of gas per minute the subsidizer has to subsidize
                   * @member gasPerMinute Amount of gas per minute the subsidizer is willing to subsidize
                   * @member lastUpdated Last time subsidy was paid out or funded (if not subsidy was yet claimed after funding)
                   */
                  struct Subsidy {
                      uint128 available;
                      uint32 gasUsage;
                      uint32 minGasPerMinute;
                      uint32 gasPerMinute;
                      uint32 lastUpdated;
                  }
                  function setGasUsageAndMinGasPerMinute(
                      uint256 _criteria,
                      uint32 _gasUsage,
                      uint32 _minGasPerMinute
                  ) external;
                  function setGasUsageAndMinGasPerMinute(
                      uint256[] calldata _criteria,
                      uint32[] calldata _gasUsage,
                      uint32[] calldata _minGasPerMinute
                  ) external;
                  function registerBeneficiary(address _beneficiary) external;
                  function subsidize(
                      address _bridge,
                      uint256 _criteria,
                      uint32 _gasPerMinute
                  ) external payable;
                  function topUp(address _bridge, uint256 _criteria) external payable;
                  function claimSubsidy(uint256 _criteria, address _beneficiary) external returns (uint256);
                  function withdraw(address _beneficiary) external returns (uint256);
                  // solhint-disable-next-line
                  function MIN_SUBSIDY_VALUE() external view returns (uint256);
                  function claimableAmount(address _beneficiary) external view returns (uint256);
                  function isRegistered(address _beneficiary) external view returns (bool);
                  function getSubsidy(address _bridge, uint256 _criteria) external view returns (Subsidy memory);
                  function getAccumulatedSubsidyAmount(address _bridge, uint256 _criteria) external view returns (uint256);
              }
              

              File 5 of 12: EulerERC4626
              // SPDX-License-Identifier: AGPL-3.0
              pragma solidity ^0.8.13;
              import {ERC20} from "solmate/tokens/ERC20.sol";
              import {ERC4626} from "solmate/mixins/ERC4626.sol";
              import {SafeTransferLib} from "solmate/utils/SafeTransferLib.sol";
              import {IEulerEToken} from "./external/IEulerEToken.sol";
              /// @title EulerERC4626
              /// @author zefram.eth
              /// @notice ERC4626 wrapper for Euler Finance
              contract EulerERC4626 is ERC4626 {
                  /// -----------------------------------------------------------------------
                  /// Libraries usage
                  /// -----------------------------------------------------------------------
                  using SafeTransferLib for ERC20;
                  /// -----------------------------------------------------------------------
                  /// Immutable params
                  /// -----------------------------------------------------------------------
                  /// @notice The Euler main contract address
                  /// @dev Target of ERC20 approval when depositing
                  address public immutable euler;
                  /// @notice The Euler eToken contract
                  IEulerEToken public immutable eToken;
                  /// -----------------------------------------------------------------------
                  /// Constructor
                  /// -----------------------------------------------------------------------
                  constructor(ERC20 asset_, address euler_, IEulerEToken eToken_)
                      ERC4626(asset_, _vaultName(asset_), _vaultSymbol(asset_))
                  {
                      euler = euler_;
                      eToken = eToken_;
                  }
                  /// -----------------------------------------------------------------------
                  /// ERC4626 overrides
                  /// -----------------------------------------------------------------------
                  function totalAssets() public view virtual override returns (uint256) {
                      return eToken.balanceOfUnderlying(address(this));
                  }
                  function beforeWithdraw(uint256 assets, uint256 /*shares*/ ) internal virtual override {
                      /// -----------------------------------------------------------------------
                      /// Withdraw assets from Euler
                      /// -----------------------------------------------------------------------
                      eToken.withdraw(0, assets);
                  }
                  function afterDeposit(uint256 assets, uint256 /*shares*/ ) internal virtual override {
                      /// -----------------------------------------------------------------------
                      /// Deposit assets into Euler
                      /// -----------------------------------------------------------------------
                      // approve to euler
                      asset.safeApprove(address(euler), assets);
                      // deposit into eToken
                      eToken.deposit(0, assets);
                  }
                  function maxWithdraw(address owner) public view override returns (uint256) {
                      uint256 cash = asset.balanceOf(euler);
                      uint256 assetsBalance = convertToAssets(balanceOf[owner]);
                      return cash < assetsBalance ? cash : assetsBalance;
                  }
                  function maxRedeem(address owner) public view override returns (uint256) {
                      uint256 cash = asset.balanceOf(euler);
                      uint256 cashInShares = convertToShares(cash);
                      uint256 shareBalance = balanceOf[owner];
                      return cashInShares < shareBalance ? cashInShares : shareBalance;
                  }
                  /// -----------------------------------------------------------------------
                  /// ERC20 metadata generation
                  /// -----------------------------------------------------------------------
                  function _vaultName(ERC20 asset_) internal view virtual returns (string memory vaultName) {
                      vaultName = string.concat("ERC4626-Wrapped Euler ", asset_.symbol());
                  }
                  function _vaultSymbol(ERC20 asset_) internal view virtual returns (string memory vaultSymbol) {
                      vaultSymbol = string.concat("we", asset_.symbol());
                  }
              }
              // SPDX-License-Identifier: AGPL-3.0-only
              pragma solidity >=0.8.0;
              /// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.
              /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC20.sol)
              /// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)
              /// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.
              abstract contract ERC20 {
                  /*//////////////////////////////////////////////////////////////
                                               EVENTS
                  //////////////////////////////////////////////////////////////*/
                  event Transfer(address indexed from, address indexed to, uint256 amount);
                  event Approval(address indexed owner, address indexed spender, uint256 amount);
                  /*//////////////////////////////////////////////////////////////
                                          METADATA STORAGE
                  //////////////////////////////////////////////////////////////*/
                  string public name;
                  string public symbol;
                  uint8 public immutable decimals;
                  /*//////////////////////////////////////////////////////////////
                                            ERC20 STORAGE
                  //////////////////////////////////////////////////////////////*/
                  uint256 public totalSupply;
                  mapping(address => uint256) public balanceOf;
                  mapping(address => mapping(address => uint256)) public allowance;
                  /*//////////////////////////////////////////////////////////////
                                          EIP-2612 STORAGE
                  //////////////////////////////////////////////////////////////*/
                  uint256 internal immutable INITIAL_CHAIN_ID;
                  bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;
                  mapping(address => uint256) public nonces;
                  /*//////////////////////////////////////////////////////////////
                                             CONSTRUCTOR
                  //////////////////////////////////////////////////////////////*/
                  constructor(
                      string memory _name,
                      string memory _symbol,
                      uint8 _decimals
                  ) {
                      name = _name;
                      symbol = _symbol;
                      decimals = _decimals;
                      INITIAL_CHAIN_ID = block.chainid;
                      INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();
                  }
                  /*//////////////////////////////////////////////////////////////
                                             ERC20 LOGIC
                  //////////////////////////////////////////////////////////////*/
                  function approve(address spender, uint256 amount) public virtual returns (bool) {
                      allowance[msg.sender][spender] = amount;
                      emit Approval(msg.sender, spender, amount);
                      return true;
                  }
                  function transfer(address to, uint256 amount) public virtual returns (bool) {
                      balanceOf[msg.sender] -= amount;
                      // Cannot overflow because the sum of all user
                      // balances can't exceed the max uint256 value.
                      unchecked {
                          balanceOf[to] += amount;
                      }
                      emit Transfer(msg.sender, to, amount);
                      return true;
                  }
                  function transferFrom(
                      address from,
                      address to,
                      uint256 amount
                  ) public virtual returns (bool) {
                      uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.
                      if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;
                      balanceOf[from] -= amount;
                      // Cannot overflow because the sum of all user
                      // balances can't exceed the max uint256 value.
                      unchecked {
                          balanceOf[to] += amount;
                      }
                      emit Transfer(from, to, amount);
                      return true;
                  }
                  /*//////////////////////////////////////////////////////////////
                                           EIP-2612 LOGIC
                  //////////////////////////////////////////////////////////////*/
                  function permit(
                      address owner,
                      address spender,
                      uint256 value,
                      uint256 deadline,
                      uint8 v,
                      bytes32 r,
                      bytes32 s
                  ) public virtual {
                      require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED");
                      // Unchecked because the only math done is incrementing
                      // the owner's nonce which cannot realistically overflow.
                      unchecked {
                          address recoveredAddress = ecrecover(
                              keccak256(
                                  abi.encodePacked(
                                      "\\x19\\x01",
                                      DOMAIN_SEPARATOR(),
                                      keccak256(
                                          abi.encode(
                                              keccak256(
                                                  "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
                                              ),
                                              owner,
                                              spender,
                                              value,
                                              nonces[owner]++,
                                              deadline
                                          )
                                      )
                                  )
                              ),
                              v,
                              r,
                              s
                          );
                          require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER");
                          allowance[recoveredAddress][spender] = value;
                      }
                      emit Approval(owner, spender, value);
                  }
                  function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {
                      return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();
                  }
                  function computeDomainSeparator() internal view virtual returns (bytes32) {
                      return
                          keccak256(
                              abi.encode(
                                  keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
                                  keccak256(bytes(name)),
                                  keccak256("1"),
                                  block.chainid,
                                  address(this)
                              )
                          );
                  }
                  /*//////////////////////////////////////////////////////////////
                                      INTERNAL MINT/BURN LOGIC
                  //////////////////////////////////////////////////////////////*/
                  function _mint(address to, uint256 amount) internal virtual {
                      totalSupply += amount;
                      // Cannot overflow because the sum of all user
                      // balances can't exceed the max uint256 value.
                      unchecked {
                          balanceOf[to] += amount;
                      }
                      emit Transfer(address(0), to, amount);
                  }
                  function _burn(address from, uint256 amount) internal virtual {
                      balanceOf[from] -= amount;
                      // Cannot underflow because a user's balance
                      // will never be larger than the total supply.
                      unchecked {
                          totalSupply -= amount;
                      }
                      emit Transfer(from, address(0), amount);
                  }
              }
              // SPDX-License-Identifier: AGPL-3.0-only
              pragma solidity >=0.8.0;
              import {ERC20} from "../tokens/ERC20.sol";
              import {SafeTransferLib} from "../utils/SafeTransferLib.sol";
              import {FixedPointMathLib} from "../utils/FixedPointMathLib.sol";
              /// @notice Minimal ERC4626 tokenized Vault implementation.
              /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/mixins/ERC4626.sol)
              abstract contract ERC4626 is ERC20 {
                  using SafeTransferLib for ERC20;
                  using FixedPointMathLib for uint256;
                  /*//////////////////////////////////////////////////////////////
                                               EVENTS
                  //////////////////////////////////////////////////////////////*/
                  event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares);
                  event Withdraw(
                      address indexed caller,
                      address indexed receiver,
                      address indexed owner,
                      uint256 assets,
                      uint256 shares
                  );
                  /*//////////////////////////////////////////////////////////////
                                             IMMUTABLES
                  //////////////////////////////////////////////////////////////*/
                  ERC20 public immutable asset;
                  constructor(
                      ERC20 _asset,
                      string memory _name,
                      string memory _symbol
                  ) ERC20(_name, _symbol, _asset.decimals()) {
                      asset = _asset;
                  }
                  /*//////////////////////////////////////////////////////////////
                                      DEPOSIT/WITHDRAWAL LOGIC
                  //////////////////////////////////////////////////////////////*/
                  function deposit(uint256 assets, address receiver) public virtual returns (uint256 shares) {
                      // Check for rounding error since we round down in previewDeposit.
                      require((shares = previewDeposit(assets)) != 0, "ZERO_SHARES");
                      // Need to transfer before minting or ERC777s could reenter.
                      asset.safeTransferFrom(msg.sender, address(this), assets);
                      _mint(receiver, shares);
                      emit Deposit(msg.sender, receiver, assets, shares);
                      afterDeposit(assets, shares);
                  }
                  function mint(uint256 shares, address receiver) public virtual returns (uint256 assets) {
                      assets = previewMint(shares); // No need to check for rounding error, previewMint rounds up.
                      // Need to transfer before minting or ERC777s could reenter.
                      asset.safeTransferFrom(msg.sender, address(this), assets);
                      _mint(receiver, shares);
                      emit Deposit(msg.sender, receiver, assets, shares);
                      afterDeposit(assets, shares);
                  }
                  function withdraw(
                      uint256 assets,
                      address receiver,
                      address owner
                  ) public virtual returns (uint256 shares) {
                      shares = previewWithdraw(assets); // No need to check for rounding error, previewWithdraw rounds up.
                      if (msg.sender != owner) {
                          uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals.
                          if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares;
                      }
                      beforeWithdraw(assets, shares);
                      _burn(owner, shares);
                      emit Withdraw(msg.sender, receiver, owner, assets, shares);
                      asset.safeTransfer(receiver, assets);
                  }
                  function redeem(
                      uint256 shares,
                      address receiver,
                      address owner
                  ) public virtual returns (uint256 assets) {
                      if (msg.sender != owner) {
                          uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals.
                          if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares;
                      }
                      // Check for rounding error since we round down in previewRedeem.
                      require((assets = previewRedeem(shares)) != 0, "ZERO_ASSETS");
                      beforeWithdraw(assets, shares);
                      _burn(owner, shares);
                      emit Withdraw(msg.sender, receiver, owner, assets, shares);
                      asset.safeTransfer(receiver, assets);
                  }
                  /*//////////////////////////////////////////////////////////////
                                          ACCOUNTING LOGIC
                  //////////////////////////////////////////////////////////////*/
                  function totalAssets() public view virtual returns (uint256);
                  function convertToShares(uint256 assets) public view virtual returns (uint256) {
                      uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.
                      return supply == 0 ? assets : assets.mulDivDown(supply, totalAssets());
                  }
                  function convertToAssets(uint256 shares) public view virtual returns (uint256) {
                      uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.
                      return supply == 0 ? shares : shares.mulDivDown(totalAssets(), supply);
                  }
                  function previewDeposit(uint256 assets) public view virtual returns (uint256) {
                      return convertToShares(assets);
                  }
                  function previewMint(uint256 shares) public view virtual returns (uint256) {
                      uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.
                      return supply == 0 ? shares : shares.mulDivUp(totalAssets(), supply);
                  }
                  function previewWithdraw(uint256 assets) public view virtual returns (uint256) {
                      uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.
                      return supply == 0 ? assets : assets.mulDivUp(supply, totalAssets());
                  }
                  function previewRedeem(uint256 shares) public view virtual returns (uint256) {
                      return convertToAssets(shares);
                  }
                  /*//////////////////////////////////////////////////////////////
                                   DEPOSIT/WITHDRAWAL LIMIT LOGIC
                  //////////////////////////////////////////////////////////////*/
                  function maxDeposit(address) public view virtual returns (uint256) {
                      return type(uint256).max;
                  }
                  function maxMint(address) public view virtual returns (uint256) {
                      return type(uint256).max;
                  }
                  function maxWithdraw(address owner) public view virtual returns (uint256) {
                      return convertToAssets(balanceOf[owner]);
                  }
                  function maxRedeem(address owner) public view virtual returns (uint256) {
                      return balanceOf[owner];
                  }
                  /*//////////////////////////////////////////////////////////////
                                        INTERNAL HOOKS LOGIC
                  //////////////////////////////////////////////////////////////*/
                  function beforeWithdraw(uint256 assets, uint256 shares) internal virtual {}
                  function afterDeposit(uint256 assets, uint256 shares) internal virtual {}
              }
              // SPDX-License-Identifier: AGPL-3.0-only
              pragma solidity >=0.8.0;
              import {ERC20} from "../tokens/ERC20.sol";
              /// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.
              /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol)
              /// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.
              /// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.
              library SafeTransferLib {
                  /*//////////////////////////////////////////////////////////////
                                           ETH OPERATIONS
                  //////////////////////////////////////////////////////////////*/
                  function safeTransferETH(address to, uint256 amount) internal {
                      bool success;
                      assembly {
                          // Transfer the ETH and store if it succeeded or not.
                          success := call(gas(), to, amount, 0, 0, 0, 0)
                      }
                      require(success, "ETH_TRANSFER_FAILED");
                  }
                  /*//////////////////////////////////////////////////////////////
                                          ERC20 OPERATIONS
                  //////////////////////////////////////////////////////////////*/
                  function safeTransferFrom(
                      ERC20 token,
                      address from,
                      address to,
                      uint256 amount
                  ) internal {
                      bool success;
                      assembly {
                          // Get a pointer to some free memory.
                          let freeMemoryPointer := mload(0x40)
                          // Write the abi-encoded calldata into memory, beginning with the function selector.
                          mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
                          mstore(add(freeMemoryPointer, 4), from) // Append the "from" argument.
                          mstore(add(freeMemoryPointer, 36), to) // Append the "to" argument.
                          mstore(add(freeMemoryPointer, 68), amount) // Append the "amount" argument.
                          success := and(
                              // Set success to whether the call reverted, if not we check it either
                              // returned exactly 1 (can't just be non-zero data), or had no return data.
                              or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
                              // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.
                              // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
                              // Counterintuitively, this call must be positioned second to the or() call in the
                              // surrounding and() call or else returndatasize() will be zero during the computation.
                              call(gas(), token, 0, freeMemoryPointer, 100, 0, 32)
                          )
                      }
                      require(success, "TRANSFER_FROM_FAILED");
                  }
                  function safeTransfer(
                      ERC20 token,
                      address to,
                      uint256 amount
                  ) internal {
                      bool success;
                      assembly {
                          // Get a pointer to some free memory.
                          let freeMemoryPointer := mload(0x40)
                          // Write the abi-encoded calldata into memory, beginning with the function selector.
                          mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)
                          mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument.
                          mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument.
                          success := and(
                              // Set success to whether the call reverted, if not we check it either
                              // returned exactly 1 (can't just be non-zero data), or had no return data.
                              or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
                              // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
                              // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
                              // Counterintuitively, this call must be positioned second to the or() call in the
                              // surrounding and() call or else returndatasize() will be zero during the computation.
                              call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)
                          )
                      }
                      require(success, "TRANSFER_FAILED");
                  }
                  function safeApprove(
                      ERC20 token,
                      address to,
                      uint256 amount
                  ) internal {
                      bool success;
                      assembly {
                          // Get a pointer to some free memory.
                          let freeMemoryPointer := mload(0x40)
                          // Write the abi-encoded calldata into memory, beginning with the function selector.
                          mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000)
                          mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument.
                          mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument.
                          success := and(
                              // Set success to whether the call reverted, if not we check it either
                              // returned exactly 1 (can't just be non-zero data), or had no return data.
                              or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
                              // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
                              // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
                              // Counterintuitively, this call must be positioned second to the or() call in the
                              // surrounding and() call or else returndatasize() will be zero during the computation.
                              call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)
                          )
                      }
                      require(success, "APPROVE_FAILED");
                  }
              }
              // SPDX-License-Identifier: AGPL-3.0
              pragma solidity ^0.8.13;
              /// @notice Tokenised representation of assets
              interface IEulerEToken {
                  /// @notice Balance of a particular account, in underlying units (increases as interest is earned)
                  function balanceOfUnderlying(address account) external view returns (uint256);
                  /// @notice Transfer underlying tokens from sender to the Euler pool, and increase account's eTokens
                  /// @param subAccountId 0 for primary, 1-255 for a sub-account
                  /// @param amount In underlying units (use max uint256 for full underlying token balance)
                  function deposit(uint256 subAccountId, uint256 amount) external;
                  /// @notice Transfer underlying tokens from Euler pool to sender, and decrease account's eTokens
                  /// @param subAccountId 0 for primary, 1-255 for a sub-account
                  /// @param amount In underlying units (use max uint256 for full pool balance)
                  function withdraw(uint256 subAccountId, uint256 amount) external;
              }
              // SPDX-License-Identifier: AGPL-3.0-only
              pragma solidity >=0.8.0;
              /// @notice Arithmetic library with operations for fixed-point numbers.
              /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/FixedPointMathLib.sol)
              /// @author Inspired by USM (https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol)
              library FixedPointMathLib {
                  /*//////////////////////////////////////////////////////////////
                                  SIMPLIFIED FIXED POINT OPERATIONS
                  //////////////////////////////////////////////////////////////*/
                  uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s.
                  function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) {
                      return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down.
                  }
                  function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) {
                      return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up.
                  }
                  function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) {
                      return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down.
                  }
                  function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) {
                      return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up.
                  }
                  /*//////////////////////////////////////////////////////////////
                                  LOW LEVEL FIXED POINT OPERATIONS
                  //////////////////////////////////////////////////////////////*/
                  function mulDivDown(
                      uint256 x,
                      uint256 y,
                      uint256 denominator
                  ) internal pure returns (uint256 z) {
                      assembly {
                          // Store x * y in z for now.
                          z := mul(x, y)
                          // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))
                          if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {
                              revert(0, 0)
                          }
                          // Divide z by the denominator.
                          z := div(z, denominator)
                      }
                  }
                  function mulDivUp(
                      uint256 x,
                      uint256 y,
                      uint256 denominator
                  ) internal pure returns (uint256 z) {
                      assembly {
                          // Store x * y in z for now.
                          z := mul(x, y)
                          // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))
                          if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {
                              revert(0, 0)
                          }
                          // First, divide z - 1 by the denominator and add 1.
                          // We allow z - 1 to underflow if z is 0, because we multiply the
                          // end result by 0 if z is zero, ensuring we return 0 if z is zero.
                          z := mul(iszero(iszero(z)), add(div(sub(z, 1), denominator), 1))
                      }
                  }
                  function rpow(
                      uint256 x,
                      uint256 n,
                      uint256 scalar
                  ) internal pure returns (uint256 z) {
                      assembly {
                          switch x
                          case 0 {
                              switch n
                              case 0 {
                                  // 0 ** 0 = 1
                                  z := scalar
                              }
                              default {
                                  // 0 ** n = 0
                                  z := 0
                              }
                          }
                          default {
                              switch mod(n, 2)
                              case 0 {
                                  // If n is even, store scalar in z for now.
                                  z := scalar
                              }
                              default {
                                  // If n is odd, store x in z for now.
                                  z := x
                              }
                              // Shifting right by 1 is like dividing by 2.
                              let half := shr(1, scalar)
                              for {
                                  // Shift n right by 1 before looping to halve it.
                                  n := shr(1, n)
                              } n {
                                  // Shift n right by 1 each iteration to halve it.
                                  n := shr(1, n)
                              } {
                                  // Revert immediately if x ** 2 would overflow.
                                  // Equivalent to iszero(eq(div(xx, x), x)) here.
                                  if shr(128, x) {
                                      revert(0, 0)
                                  }
                                  // Store x squared.
                                  let xx := mul(x, x)
                                  // Round to the nearest number.
                                  let xxRound := add(xx, half)
                                  // Revert if xx + half overflowed.
                                  if lt(xxRound, xx) {
                                      revert(0, 0)
                                  }
                                  // Set x to scaled xxRound.
                                  x := div(xxRound, scalar)
                                  // If n is even:
                                  if mod(n, 2) {
                                      // Compute z * x.
                                      let zx := mul(z, x)
                                      // If z * x overflowed:
                                      if iszero(eq(div(zx, x), z)) {
                                          // Revert if x is non-zero.
                                          if iszero(iszero(x)) {
                                              revert(0, 0)
                                          }
                                      }
                                      // Round to the nearest number.
                                      let zxRound := add(zx, half)
                                      // Revert if zx + half overflowed.
                                      if lt(zxRound, zx) {
                                          revert(0, 0)
                                      }
                                      // Return properly scaled zxRound.
                                      z := div(zxRound, scalar)
                                  }
                              }
                          }
                      }
                  }
                  /*//////////////////////////////////////////////////////////////
                                      GENERAL NUMBER UTILITIES
                  //////////////////////////////////////////////////////////////*/
                  function sqrt(uint256 x) internal pure returns (uint256 z) {
                      assembly {
                          // Start off with z at 1.
                          z := 1
                          // Used below to help find a nearby power of 2.
                          let y := x
                          // Find the lowest power of 2 that is at least sqrt(x).
                          if iszero(lt(y, 0x100000000000000000000000000000000)) {
                              y := shr(128, y) // Like dividing by 2 ** 128.
                              z := shl(64, z) // Like multiplying by 2 ** 64.
                          }
                          if iszero(lt(y, 0x10000000000000000)) {
                              y := shr(64, y) // Like dividing by 2 ** 64.
                              z := shl(32, z) // Like multiplying by 2 ** 32.
                          }
                          if iszero(lt(y, 0x100000000)) {
                              y := shr(32, y) // Like dividing by 2 ** 32.
                              z := shl(16, z) // Like multiplying by 2 ** 16.
                          }
                          if iszero(lt(y, 0x10000)) {
                              y := shr(16, y) // Like dividing by 2 ** 16.
                              z := shl(8, z) // Like multiplying by 2 ** 8.
                          }
                          if iszero(lt(y, 0x100)) {
                              y := shr(8, y) // Like dividing by 2 ** 8.
                              z := shl(4, z) // Like multiplying by 2 ** 4.
                          }
                          if iszero(lt(y, 0x10)) {
                              y := shr(4, y) // Like dividing by 2 ** 4.
                              z := shl(2, z) // Like multiplying by 2 ** 2.
                          }
                          if iszero(lt(y, 0x8)) {
                              // Equivalent to 2 ** z.
                              z := shl(1, z)
                          }
                          // Shifting right by 1 is like dividing by 2.
                          z := shr(1, add(z, div(x, z)))
                          z := shr(1, add(z, div(x, z)))
                          z := shr(1, add(z, div(x, z)))
                          z := shr(1, add(z, div(x, z)))
                          z := shr(1, add(z, div(x, z)))
                          z := shr(1, add(z, div(x, z)))
                          z := shr(1, add(z, div(x, z)))
                          // Compute a rounded down version of z.
                          let zRoundDown := div(x, z)
                          // If zRoundDown is smaller, use it.
                          if lt(zRoundDown, z) {
                              z := zRoundDown
                          }
                      }
                  }
              }
              

              File 6 of 12: Euler
              // SPDX-License-Identifier: GPL-2.0-or-later
              pragma solidity ^0.8.0;
              import "./Base.sol";
              /// @notice Main storage contract for the Euler system
              contract Euler is Base {
                  constructor(address admin, address installerModule) {
                      emit Genesis();
                      reentrancyLock = REENTRANCYLOCK__UNLOCKED;
                      upgradeAdmin = admin;
                      governorAdmin = admin;
                      moduleLookup[MODULEID__INSTALLER] = installerModule;
                      address installerProxy = _createProxy(MODULEID__INSTALLER);
                      trustedSenders[installerProxy].moduleImpl = installerModule;
                  }
                  string public constant name = "Euler Protocol";
                  /// @notice Lookup the current implementation contract for a module
                  /// @param moduleId Fixed constant that refers to a module type (ie MODULEID__ETOKEN)
                  /// @return An internal address specifies the module's implementation code
                  function moduleIdToImplementation(uint moduleId) external view returns (address) {
                      return moduleLookup[moduleId];
                  }
                  /// @notice Lookup a proxy that can be used to interact with a module (only valid for single-proxy modules)
                  /// @param moduleId Fixed constant that refers to a module type (ie MODULEID__MARKETS)
                  /// @return An address that should be cast to the appropriate module interface, ie IEulerMarkets(moduleIdToProxy(2))
                  function moduleIdToProxy(uint moduleId) external view returns (address) {
                      return proxyLookup[moduleId];
                  }
                  function dispatch() external {
                      uint32 moduleId = trustedSenders[msg.sender].moduleId;
                      address moduleImpl = trustedSenders[msg.sender].moduleImpl;
                      require(moduleId != 0, "e/sender-not-trusted");
                      if (moduleImpl == address(0)) moduleImpl = moduleLookup[moduleId];
                      uint msgDataLength = msg.data.length;
                      require(msgDataLength >= (4 + 4 + 20), "e/input-too-short");
                      assembly {
                          let payloadSize := sub(calldatasize(), 4)
                          calldatacopy(0, 4, payloadSize)
                          mstore(payloadSize, shl(96, caller()))
                          let result := delegatecall(gas(), moduleImpl, 0, add(payloadSize, 20), 0, 0)
                          returndatacopy(0, 0, returndatasize())
                          switch result
                              case 0 { revert(0, returndatasize()) }
                              default { return(0, returndatasize()) }
                      }
                  }
              }
              // SPDX-License-Identifier: GPL-2.0-or-later
              pragma solidity ^0.8.0;
              //import "hardhat/console.sol"; // DEV_MODE
              import "./Storage.sol";
              import "./Events.sol";
              import "./Proxy.sol";
              abstract contract Base is Storage, Events {
                  // Modules
                  function _createProxy(uint proxyModuleId) internal returns (address) {
                      require(proxyModuleId != 0, "e/create-proxy/invalid-module");
                      require(proxyModuleId <= MAX_EXTERNAL_MODULEID, "e/create-proxy/internal-module");
                      // If we've already created a proxy for a single-proxy module, just return it:
                      if (proxyLookup[proxyModuleId] != address(0)) return proxyLookup[proxyModuleId];
                      // Otherwise create a proxy:
                      address proxyAddr = address(new Proxy());
                      if (proxyModuleId <= MAX_EXTERNAL_SINGLE_PROXY_MODULEID) proxyLookup[proxyModuleId] = proxyAddr;
                      trustedSenders[proxyAddr] = TrustedSenderInfo({ moduleId: uint32(proxyModuleId), moduleImpl: address(0) });
                      emit ProxyCreated(proxyAddr, proxyModuleId);
                      return proxyAddr;
                  }
                  function callInternalModule(uint moduleId, bytes memory input) internal returns (bytes memory) {
                      (bool success, bytes memory result) = moduleLookup[moduleId].delegatecall(input);
                      if (!success) revertBytes(result);
                      return result;
                  }
                  // Modifiers
                  modifier nonReentrant() {
                      require(reentrancyLock == REENTRANCYLOCK__UNLOCKED, "e/reentrancy");
                      reentrancyLock = REENTRANCYLOCK__LOCKED;
                      _;
                      reentrancyLock = REENTRANCYLOCK__UNLOCKED;
                  }
                  modifier reentrantOK() { // documentation only
                      _;
                  }
                  // WARNING: Must be very careful with this modifier. It resets the free memory pointer
                  // to the value it was when the function started. This saves gas if more memory will
                  // be allocated in the future. However, if the memory will be later referenced
                  // (for example because the function has returned a pointer to it) then you cannot
                  // use this modifier.
                  modifier FREEMEM() {
                      uint origFreeMemPtr;
                      assembly {
                          origFreeMemPtr := mload(0x40)
                      }
                      _;
                      /*
                      assembly { // DEV_MODE: overwrite the freed memory with garbage to detect bugs
                          let garbage := 0xDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF
                          for { let i := origFreeMemPtr } lt(i, mload(0x40)) { i := add(i, 32) } { mstore(i, garbage) }
                      }
                      */
                      assembly {
                          mstore(0x40, origFreeMemPtr)
                      }
                  }
                  // Error handling
                  function revertBytes(bytes memory errMsg) internal pure {
                      if (errMsg.length > 0) {
                          assembly {
                              revert(add(32, errMsg), mload(errMsg))
                          }
                      }
                      revert("e/empty-error");
                  }
              }
              // SPDX-License-Identifier: GPL-2.0-or-later
              pragma solidity ^0.8.0;
              import "./Constants.sol";
              abstract contract Storage is Constants {
                  // Dispatcher and upgrades
                  uint reentrancyLock;
                  address upgradeAdmin;
                  address governorAdmin;
                  mapping(uint => address) moduleLookup; // moduleId => module implementation
                  mapping(uint => address) proxyLookup; // moduleId => proxy address (only for single-proxy modules)
                  struct TrustedSenderInfo {
                      uint32 moduleId; // 0 = un-trusted
                      address moduleImpl; // only non-zero for external single-proxy modules
                  }
                  mapping(address => TrustedSenderInfo) trustedSenders; // sender address => moduleId (0 = un-trusted)
                  // Account-level state
                  // Sub-accounts are considered distinct accounts
                  struct AccountStorage {
                      // Packed slot: 1 + 5 + 4 + 20 = 30
                      uint8 deferLiquidityStatus;
                      uint40 lastAverageLiquidityUpdate;
                      uint32 numMarketsEntered;
                      address firstMarketEntered;
                      uint averageLiquidity;
                      address averageLiquidityDelegate;
                  }
                  mapping(address => AccountStorage) accountLookup;
                  mapping(address => address[MAX_POSSIBLE_ENTERED_MARKETS]) marketsEntered;
                  // Markets and assets
                  struct AssetConfig {
                      // Packed slot: 20 + 1 + 4 + 4 + 3 = 32
                      address eTokenAddress;
                      bool borrowIsolated;
                      uint32 collateralFactor;
                      uint32 borrowFactor;
                      uint24 twapWindow;
                  }
                  struct UserAsset {
                      uint112 balance;
                      uint144 owed;
                      uint interestAccumulator;
                  }
                  struct AssetStorage {
                      // Packed slot: 5 + 1 + 4 + 12 + 4 + 2 + 4 = 32
                      uint40 lastInterestAccumulatorUpdate;
                      uint8 underlyingDecimals; // Not dynamic, but put here to live in same storage slot
                      uint32 interestRateModel;
                      int96 interestRate;
                      uint32 reserveFee;
                      uint16 pricingType;
                      uint32 pricingParameters;
                      address underlying;
                      uint96 reserveBalance;
                      address dTokenAddress;
                      uint112 totalBalances;
                      uint144 totalBorrows;
                      uint interestAccumulator;
                      mapping(address => UserAsset) users;
                      mapping(address => mapping(address => uint)) eTokenAllowance;
                      mapping(address => mapping(address => uint)) dTokenAllowance;
                  }
                  mapping(address => AssetConfig) internal underlyingLookup; // underlying => AssetConfig
                  mapping(address => AssetStorage) internal eTokenLookup; // EToken => AssetStorage
                  mapping(address => address) internal dTokenLookup; // DToken => EToken
                  mapping(address => address) internal pTokenLookup; // PToken => underlying
                  mapping(address => address) internal reversePTokenLookup; // underlying => PToken
              }
              // SPDX-License-Identifier: GPL-2.0-or-later
              pragma solidity ^0.8.0;
              import "./Storage.sol";
              abstract contract Events {
                  event Genesis();
                  event ProxyCreated(address indexed proxy, uint moduleId);
                  event MarketActivated(address indexed underlying, address indexed eToken, address indexed dToken);
                  event PTokenActivated(address indexed underlying, address indexed pToken);
                  event EnterMarket(address indexed underlying, address indexed account);
                  event ExitMarket(address indexed underlying, address indexed account);
                  event Deposit(address indexed underlying, address indexed account, uint amount);
                  event Withdraw(address indexed underlying, address indexed account, uint amount);
                  event Borrow(address indexed underlying, address indexed account, uint amount);
                  event Repay(address indexed underlying, address indexed account, uint amount);
                  event Liquidation(address indexed liquidator, address indexed violator, address indexed underlying, address collateral, uint repay, uint yield, uint healthScore, uint baseDiscount, uint discount);
                  event TrackAverageLiquidity(address indexed account);
                  event UnTrackAverageLiquidity(address indexed account);
                  event DelegateAverageLiquidity(address indexed account, address indexed delegate);
                  event PTokenWrap(address indexed underlying, address indexed account, uint amount);
                  event PTokenUnWrap(address indexed underlying, address indexed account, uint amount);
                  event AssetStatus(address indexed underlying, uint totalBalances, uint totalBorrows, uint96 reserveBalance, uint poolSize, uint interestAccumulator, int96 interestRate, uint timestamp);
                  event RequestDeposit(address indexed account, uint amount);
                  event RequestWithdraw(address indexed account, uint amount);
                  event RequestMint(address indexed account, uint amount);
                  event RequestBurn(address indexed account, uint amount);
                  event RequestTransferEToken(address indexed from, address indexed to, uint amount);
                  event RequestBorrow(address indexed account, uint amount);
                  event RequestRepay(address indexed account, uint amount);
                  event RequestTransferDToken(address indexed from, address indexed to, uint amount);
                  event RequestLiquidate(address indexed liquidator, address indexed violator, address indexed underlying, address collateral, uint repay, uint minYield);
                  event InstallerSetUpgradeAdmin(address indexed newUpgradeAdmin);
                  event InstallerSetGovernorAdmin(address indexed newGovernorAdmin);
                  event InstallerInstallModule(uint indexed moduleId, address indexed moduleImpl, bytes32 moduleGitCommit);
                  event GovSetAssetConfig(address indexed underlying, Storage.AssetConfig newConfig);
                  event GovSetIRM(address indexed underlying, uint interestRateModel, bytes resetParams);
                  event GovSetPricingConfig(address indexed underlying, uint16 newPricingType, uint32 newPricingParameter);
                  event GovSetReserveFee(address indexed underlying, uint32 newReserveFee);
                  event GovConvertReserves(address indexed underlying, address indexed recipient, uint amount);
                  event RequestSwap(address indexed accountIn, address indexed accountOut, address indexed underlyingIn, address underlyingOut, uint amount, uint swapType);
              }
              // SPDX-License-Identifier: GPL-2.0-or-later
              pragma solidity ^0.8.0;
              contract Proxy {
                  address immutable creator;
                  constructor() {
                      creator = msg.sender;
                  }
                  // External interface
                  fallback() external {
                      address creator_ = creator;
                      if (msg.sender == creator_) {
                          assembly {
                              mstore(0, 0)
                              calldatacopy(31, 0, calldatasize())
                              switch mload(0) // numTopics
                                  case 0 { log0(32,  sub(calldatasize(), 1)) }
                                  case 1 { log1(64,  sub(calldatasize(), 33),  mload(32)) }
                                  case 2 { log2(96,  sub(calldatasize(), 65),  mload(32), mload(64)) }
                                  case 3 { log3(128, sub(calldatasize(), 97),  mload(32), mload(64), mload(96)) }
                                  case 4 { log4(160, sub(calldatasize(), 129), mload(32), mload(64), mload(96), mload(128)) }
                                  default { revert(0, 0) }
                              return(0, 0)
                          }
                      } else {
                          assembly {
                              mstore(0, 0xe9c4a3ac00000000000000000000000000000000000000000000000000000000) // dispatch() selector
                              calldatacopy(4, 0, calldatasize())
                              mstore(add(4, calldatasize()), shl(96, caller()))
                              let result := call(gas(), creator_, 0, 0, add(24, calldatasize()), 0, 0)
                              returndatacopy(0, 0, returndatasize())
                              switch result
                                  case 0 { revert(0, returndatasize()) }
                                  default { return(0, returndatasize()) }
                          }
                      }
                  }
              }
              // SPDX-License-Identifier: GPL-2.0-or-later
              pragma solidity ^0.8.0;
              abstract contract Constants {
                  // Universal
                  uint internal constant SECONDS_PER_YEAR = 365.2425 * 86400; // Gregorian calendar
                  // Protocol parameters
                  uint internal constant MAX_SANE_AMOUNT = type(uint112).max;
                  uint internal constant MAX_SANE_SMALL_AMOUNT = type(uint96).max;
                  uint internal constant MAX_SANE_DEBT_AMOUNT = type(uint144).max;
                  uint internal constant INTERNAL_DEBT_PRECISION = 1e9;
                  uint internal constant MAX_ENTERED_MARKETS = 10; // per sub-account
                  uint internal constant MAX_POSSIBLE_ENTERED_MARKETS = 2**32; // limited by size of AccountStorage.numMarketsEntered
                  uint internal constant CONFIG_FACTOR_SCALE = 4_000_000_000; // must fit into a uint32
                  uint internal constant RESERVE_FEE_SCALE = 4_000_000_000; // must fit into a uint32
                  uint32 internal constant DEFAULT_RESERVE_FEE = uint32(0.23 * 4_000_000_000);
                  uint internal constant INITIAL_INTEREST_ACCUMULATOR = 1e27;
                  uint internal constant AVERAGE_LIQUIDITY_PERIOD = 24 * 60 * 60;
                  uint16 internal constant MIN_UNISWAP3_OBSERVATION_CARDINALITY = 10;
                  uint24 internal constant DEFAULT_TWAP_WINDOW_SECONDS = 30 * 60;
                  uint32 internal constant DEFAULT_BORROW_FACTOR = uint32(0.28 * 4_000_000_000);
                  // Implementation internals
                  uint internal constant REENTRANCYLOCK__UNLOCKED = 1;
                  uint internal constant REENTRANCYLOCK__LOCKED = 2;
                  uint8 internal constant DEFERLIQUIDITY__NONE = 0;
                  uint8 internal constant DEFERLIQUIDITY__CLEAN = 1;
                  uint8 internal constant DEFERLIQUIDITY__DIRTY = 2;
                  // Pricing types
                  uint16 internal constant PRICINGTYPE__PEGGED = 1;
                  uint16 internal constant PRICINGTYPE__UNISWAP3_TWAP = 2;
                  uint16 internal constant PRICINGTYPE__FORWARDED = 3;
                  // Modules
                  // Public single-proxy modules
                  uint internal constant MODULEID__INSTALLER = 1;
                  uint internal constant MODULEID__MARKETS = 2;
                  uint internal constant MODULEID__LIQUIDATION = 3;
                  uint internal constant MODULEID__GOVERNANCE = 4;
                  uint internal constant MODULEID__EXEC = 5;
                  uint internal constant MODULEID__SWAP = 6;
                  uint internal constant MAX_EXTERNAL_SINGLE_PROXY_MODULEID = 499_999;
                  // Public multi-proxy modules
                  uint internal constant MODULEID__ETOKEN = 500_000;
                  uint internal constant MODULEID__DTOKEN = 500_001;
                  uint internal constant MAX_EXTERNAL_MODULEID = 999_999;
                  // Internal modules
                  uint internal constant MODULEID__RISK_MANAGER = 1_000_000;
                  // Interest rate models
                  //   Default for new markets
                  uint internal constant MODULEID__IRM_DEFAULT = 2_000_000;
                  //   Testing-only
                  uint internal constant MODULEID__IRM_ZERO = 2_000_001;
                  uint internal constant MODULEID__IRM_FIXED = 2_000_002;
                  uint internal constant MODULEID__IRM_LINEAR = 2_000_100;
                  //   Classes
                  uint internal constant MODULEID__IRM_CLASS__STABLE = 2_000_500;
                  uint internal constant MODULEID__IRM_CLASS__MAJOR = 2_000_501;
                  uint internal constant MODULEID__IRM_CLASS__MIDCAP = 2_000_502;
                  // Swap types
                  uint internal constant SWAP_TYPE__UNI_EXACT_INPUT_SINGLE = 1;
                  uint internal constant SWAP_TYPE__UNI_EXACT_INPUT = 2;
                  uint internal constant SWAP_TYPE__UNI_EXACT_OUTPUT_SINGLE = 3;
                  uint internal constant SWAP_TYPE__UNI_EXACT_OUTPUT = 4;
                  uint internal constant SWAP_TYPE__1INCH = 5;
              }
              

              File 7 of 12: Proxy
              // SPDX-License-Identifier: GPL-2.0-or-later
              pragma solidity ^0.8.0;
              contract Proxy {
                  address immutable creator;
                  constructor() {
                      creator = msg.sender;
                  }
                  // External interface
                  fallback() external {
                      address creator_ = creator;
                      if (msg.sender == creator_) {
                          assembly {
                              mstore(0, 0)
                              calldatacopy(31, 0, calldatasize())
                              switch mload(0) // numTopics
                                  case 0 { log0(32,  sub(calldatasize(), 1)) }
                                  case 1 { log1(64,  sub(calldatasize(), 33),  mload(32)) }
                                  case 2 { log2(96,  sub(calldatasize(), 65),  mload(32), mload(64)) }
                                  case 3 { log3(128, sub(calldatasize(), 97),  mload(32), mload(64), mload(96)) }
                                  case 4 { log4(160, sub(calldatasize(), 129), mload(32), mload(64), mload(96), mload(128)) }
                                  default { revert(0, 0) }
                              return(0, 0)
                          }
                      } else {
                          assembly {
                              mstore(0, 0xe9c4a3ac00000000000000000000000000000000000000000000000000000000) // dispatch() selector
                              calldatacopy(4, 0, calldatasize())
                              mstore(add(4, calldatasize()), shl(96, caller()))
                              let result := call(gas(), creator_, 0, 0, add(24, calldatasize()), 0, 0)
                              returndatacopy(0, 0, returndatasize())
                              switch result
                                  case 0 { revert(0, returndatasize()) }
                                  default { return(0, returndatasize()) }
                          }
                      }
                  }
              }
              

              File 8 of 12: AztecFeeDistributor
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              library AztecTypes {
                  enum AztecAssetType {
                      NOT_USED,
                      ETH,
                      ERC20,
                      VIRTUAL
                  }
                  struct AztecAsset {
                      uint256 id;
                      address erc20Address;
                      AztecAssetType assetType;
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              import {IDefiBridge} from '../interfaces/IDefiBridge.sol';
              import {AztecTypes} from '../AztecTypes.sol';
              import {IRollupProcessor} from '../interfaces/IRollupProcessor.sol';
              /**
               * @dev Warning: do not deploy in real environments, for testing only
               */
              contract ReentryBridge is IDefiBridge {
                  /*----------------------------------------
                    ERROR TAGS
                    ----------------------------------------*/
                  error PAUSED();
                  error NOT_PAUSED();
                  error LOCKED_NO_REENTER();
                  error INVALID_PROVIDER();
                  error THIRD_PARTY_CONTRACTS_FLAG_NOT_SET();
                  error INSUFFICIENT_DEPOSIT();
                  error INVALID_ASSET_ID();
                  error INVALID_ASSET_ADDRESS();
                  error INVALID_LINKED_TOKEN_ADDRESS();
                  error INVALID_LINKED_BRIDGE_ADDRESS();
                  error INVALID_BRIDGE_ID();
                  error INVALID_BRIDGE_ADDRESS();
                  error BRIDGE_ID_IS_INCONSISTENT();
                  error BRIDGE_WITH_IDENTICAL_INPUT_ASSETS(uint256 inputAssetId);
                  error BRIDGE_WITH_IDENTICAL_OUTPUT_ASSETS(uint256 outputAssetId);
                  error ZERO_TOTAL_INPUT_VALUE();
                  error ARRAY_OVERFLOW();
                  error MSG_VALUE_WRONG_AMOUNT();
                  error INSUFFICIENT_ETH_PAYMENT();
                  error WITHDRAW_TO_ZERO_ADDRESS();
                  error DEPOSIT_TOKENS_WRONG_PAYMENT_TYPE();
                  error INSUFFICIENT_TOKEN_APPROVAL();
                  error NONZERO_OUTPUT_VALUE_ON_NOT_USED_ASSET(uint256 outputValue);
                  error INCORRECT_STATE_HASH(bytes32 oldStateHash, bytes32 newStateHash);
                  error INCORRECT_DATA_START_INDEX(uint256 providedIndex, uint256 expectedIndex);
                  error INCORRECT_PREVIOUS_DEFI_INTERACTION_HASH(
                      bytes32 providedDefiInteractionHash,
                      bytes32 expectedDefiInteractionHash
                  );
                  error PUBLIC_INPUTS_HASH_VERIFICATION_FAILED(uint256, uint256);
                  error PROOF_VERIFICATION_FAILED();
                  address public immutable rollupProcessor;
                  struct Action {
                      uint256 id;
                      uint256 nonce;
                      bool noOp;
                      bool canFinalise;
                      bool isAsync;
                      bytes nextAction;
                      uint256 a;
                      uint256 b;
                  }
                  mapping(uint256 => bool) public executed;
                  uint256 idCount;
                  Action[] public actions;
                  bool public died;
                  uint256 public lastNonce;
                  receive() external payable {}
                  constructor(address _rollupProcessor) {
                      rollupProcessor = _rollupProcessor;
                  }
                  function addAction(
                      uint256 _nonce,
                      bool _isAsync,
                      bool _canFinalise,
                      bool _noOp,
                      bytes memory _nextAction,
                      uint256 _a,
                      uint256 _b
                  ) external {
                      Action memory action = Action({
                          id: idCount++,
                          nonce: _nonce,
                          isAsync: _isAsync,
                          canFinalise: _canFinalise,
                          noOp: _noOp,
                          nextAction: _nextAction,
                          a: _a,
                          b: _b
                      });
                      actions.push(action);
                  }
                  function convert(
                      AztecTypes.AztecAsset memory,
                      AztecTypes.AztecAsset memory,
                      AztecTypes.AztecAsset memory,
                      AztecTypes.AztecAsset memory,
                      uint256,
                      uint256,
                      uint64,
                      address
                  )
                      external
                      payable
                      override
                      returns (
                          uint256,
                          uint256,
                          bool
                      )
                  {
                      Action memory action = actions[actions.length - 1];
                      bool isAsync = action.isAsync;
                      if (isAsync) {
                          return (0, 0, isAsync);
                      }
                      execute();
                      return (action.a, action.b, isAsync);
                  }
                  function canFinalise(uint256) external view override returns (bool) {
                      return actions[actions.length - 1].canFinalise;
                  }
                  function finalise(
                      AztecTypes.AztecAsset memory,
                      AztecTypes.AztecAsset memory,
                      AztecTypes.AztecAsset memory,
                      AztecTypes.AztecAsset memory,
                      uint256,
                      uint64
                  )
                      external
                      payable
                      override
                      returns (
                          uint256,
                          uint256,
                          bool
                      )
                  {
                      require(msg.sender == rollupProcessor, 'invalid sender!');
                      (uint256 a, uint256 b) = execute();
                      return (a, b, true);
                  }
                  function execute() internal returns (uint256, uint256) {
                      Action memory action = actions[actions.length - 1];
                      executed[action.id] = true;
                      actions.pop();
                      lastNonce = action.nonce;
                      IRollupProcessor(rollupProcessor).receiveEthFromBridge{value: 1}(action.nonce);
                      if (!action.noOp) {
                          (bool success, ) = rollupProcessor.call(action.nextAction);
                          assembly {
                              if iszero(success) {
                                  returndatacopy(0, 0, returndatasize())
                                  revert(0, returndatasize())
                              }
                          }
                          if (!success) {
                              died = true;
                          }
                      }
                      return (action.a, action.b);
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              import {AztecTypes} from '../AztecTypes.sol';
              interface IDefiBridge {
                  function convert(
                      AztecTypes.AztecAsset memory inputAssetA,
                      AztecTypes.AztecAsset memory inputAssetB,
                      AztecTypes.AztecAsset memory outputAssetA,
                      AztecTypes.AztecAsset memory outputAssetB,
                      uint256 totalInputValue,
                      uint256 interactionNonce,
                      uint64 auxData,
                      address rollupBeneficiary
                  )
                      external
                      payable
                      returns (
                          uint256 outputValueA,
                          uint256 outputValueB,
                          bool isAsync
                      );
                  function canFinalise(uint256 interactionNonce) external view returns (bool);
                  function finalise(
                      AztecTypes.AztecAsset memory inputAssetA,
                      AztecTypes.AztecAsset memory inputAssetB,
                      AztecTypes.AztecAsset memory outputAssetA,
                      AztecTypes.AztecAsset memory outputAssetB,
                      uint256 interactionNonce,
                      uint64 auxData
                  )
                      external
                      payable
                      returns (
                          uint256 outputValueA,
                          uint256 outputValueB,
                          bool interactionCompleted
                      );
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              interface IRollupProcessor {
                  /*----------------------------------------
                    MUTATING FUNCTIONS
                    ----------------------------------------*/
                  function pause() external;
                  function unpause() external;
                  function setRollupProvider(address providerAddress, bool valid) external;
                  function setVerifier(address verifierAddress) external;
                  function setAllowThirdPartyContracts(bool _flag) external;
                  function setDefiBridgeProxy(address feeDistributorAddress) external;
                  function setSupportedAsset(address linkedToken, uint256 gasLimit) external;
                  function setSupportedBridge(address linkedBridge, uint256 gasLimit) external;
                  function processRollup(bytes calldata proofData, bytes calldata signatures) external;
                  function receiveEthFromBridge(uint256 interactionNonce) external payable;
                  function approveProof(bytes32 _proofHash) external;
                  function depositPendingFunds(
                      uint256 assetId,
                      uint256 amount,
                      address owner,
                      bytes32 proofHash
                  ) external payable;
                  function depositPendingFundsPermit(
                      uint256 assetId,
                      uint256 amount,
                      address owner,
                      bytes32 proofHash,
                      uint256 deadline,
                      uint8 v,
                      bytes32 r,
                      bytes32 s
                  ) external;
                  function depositPendingFundsPermitNonStandard(
                      uint256 assetId,
                      uint256 amount,
                      address owner,
                      bytes32 proofHash,
                      uint256 nonce,
                      uint256 deadline,
                      uint8 v,
                      bytes32 r,
                      bytes32 s
                  ) external;
                  function offchainData(
                      uint256 rollupId,
                      uint256 chunk,
                      uint256 totalChunks,
                      bytes calldata offchainTxData
                  ) external;
                  function processAsyncDefiInteraction(uint256 interactionNonce) external returns (bool);
                  /*----------------------------------------
                    NON-MUTATING FUNCTIONS
                    ----------------------------------------*/
                  function rollupStateHash() external view returns (bytes32);
                  function userPendingDeposits(uint256 assetId, address userAddress) external view returns (uint256);
                  function defiBridgeProxy() external view returns (address);
                  function prevDefiInteractionsHash() external view returns (bytes32);
                  function paused() external view returns (bool);
                  function verifier() external view returns (address);
                  function getDataSize() external view returns (uint256);
                  function getPendingDefiInteractionHashesLength() external view returns (uint256);
                  function getDefiInteractionHashesLength() external view returns (uint256);
                  function getAsyncDefiInteractionHashesLength() external view returns (uint256 res);
                  function getSupportedBridge(uint256 bridgeAddressId) external view returns (address);
                  function getSupportedBridgesLength() external view returns (uint256);
                  function getSupportedAssetsLength() external view returns (uint256);
                  function getSupportedAsset(uint256 assetId) external view returns (address);
                  function getBridgeGasLimit(uint256 bridgeAddressId) external view returns (uint256);
                  function getEscapeHatchStatus() external view returns (bool, uint256);
                  function getDefiInteractionHashes() external view returns (bytes32[] memory);
                  function getAsyncDefiInteractionHashes() external view returns (bytes32[] memory);
                  function getSupportedAssets() external view returns (address[] memory, uint256[] memory);
                  function getSupportedBridges() external view returns (address[] memory, uint256[] memory);
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
              import {IDefiBridge} from '../interfaces/IDefiBridge.sol';
              import {AztecTypes} from '../AztecTypes.sol';
              import {IRollupProcessor} from '../interfaces/IRollupProcessor.sol';
              /**
               * @dev Warning: do not deploy in real environments, for testing only
               */
              contract ReentryAsync is IDefiBridge {
                  address public immutable rollupProcessor;
                  uint256 public nonce;
                  uint256 public counter;
                  uint256 public aOut;
                  receive() external payable {}
                  constructor(address _rollupProcessor) {
                      rollupProcessor = _rollupProcessor;
                  }
                  function setValues(uint256 _nonce, uint256 _aOut) public {
                      nonce = _nonce;
                      aOut = _aOut;
                  }
                  function convert(
                      AztecTypes.AztecAsset memory,
                      AztecTypes.AztecAsset memory,
                      AztecTypes.AztecAsset memory,
                      AztecTypes.AztecAsset memory,
                      uint256,
                      uint256,
                      uint64,
                      address
                  )
                      external
                      payable
                      override
                      returns (
                          uint256,
                          uint256,
                          bool
                      )
                  {
                      return (0, 0, true);
                  }
                  function canFinalise(uint256) external pure override returns (bool) {
                      return true;
                  }
                  function finalise(
                      AztecTypes.AztecAsset memory,
                      AztecTypes.AztecAsset memory,
                      AztecTypes.AztecAsset memory,
                      AztecTypes.AztecAsset memory,
                      uint256,
                      uint64
                  )
                      external
                      payable
                      override
                      returns (
                          uint256,
                          uint256,
                          bool
                      )
                  {
                      require(msg.sender == rollupProcessor, 'invalid sender!');
                      counter++;
                      if (counter < 2) {
                          IRollupProcessor(rollupProcessor).processAsyncDefiInteraction(nonce);
                      }
                      IRollupProcessor(rollupProcessor).receiveEthFromBridge{value: aOut}(nonce);
                      return (aOut, 0, true);
                  }
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
              pragma solidity ^0.8.0;
              /**
               * @dev Interface of the ERC20 standard as defined in the EIP.
               */
              interface IERC20 {
                  /**
                   * @dev Emitted when `value` tokens are moved from one account (`from`) to
                   * another (`to`).
                   *
                   * Note that `value` may be zero.
                   */
                  event Transfer(address indexed from, address indexed to, uint256 value);
                  /**
                   * @dev Emitted when the allowance of a `spender` for an `owner` is set by
                   * a call to {approve}. `value` is the new allowance.
                   */
                  event Approval(address indexed owner, address indexed spender, uint256 value);
                  /**
                   * @dev Returns the amount of tokens in existence.
                   */
                  function totalSupply() external view returns (uint256);
                  /**
                   * @dev Returns the amount of tokens owned by `account`.
                   */
                  function balanceOf(address account) external view returns (uint256);
                  /**
                   * @dev Moves `amount` tokens from the caller's account to `to`.
                   *
                   * Returns a boolean value indicating whether the operation succeeded.
                   *
                   * Emits a {Transfer} event.
                   */
                  function transfer(address to, uint256 amount) external returns (bool);
                  /**
                   * @dev Returns the remaining number of tokens that `spender` will be
                   * allowed to spend on behalf of `owner` through {transferFrom}. This is
                   * zero by default.
                   *
                   * This value changes when {approve} or {transferFrom} are called.
                   */
                  function allowance(address owner, address spender) external view returns (uint256);
                  /**
                   * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
                   *
                   * Returns a boolean value indicating whether the operation succeeded.
                   *
                   * IMPORTANT: Beware that changing an allowance with this method brings the risk
                   * that someone may use both the old and the new allowance by unfortunate
                   * transaction ordering. One possible solution to mitigate this race
                   * condition is to first reduce the spender's allowance to 0 and set the
                   * desired value afterwards:
                   * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
                   *
                   * Emits an {Approval} event.
                   */
                  function approve(address spender, uint256 amount) external returns (bool);
                  /**
                   * @dev Moves `amount` tokens from `from` to `to` using the
                   * allowance mechanism. `amount` is then deducted from the caller's
                   * allowance.
                   *
                   * Returns a boolean value indicating whether the operation succeeded.
                   *
                   * Emits a {Transfer} event.
                   */
                  function transferFrom(
                      address from,
                      address to,
                      uint256 amount
                  ) external returns (bool);
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
              import {IDefiBridge} from '../interfaces/IDefiBridge.sol';
              import {AztecTypes} from '../AztecTypes.sol';
              /**
               * @dev Warning: do not deploy in real environments, for testing only
               */
              contract MockDefiBridge is IDefiBridge {
                  address public immutable rollupProcessor;
                  bool immutable canConvert;
                  bool immutable isAsync;
                  uint256 immutable outputValueA;
                  uint256 immutable outputValueB;
                  uint256 immutable returnValueA;
                  uint256 immutable returnValueB;
                  uint256 immutable returnInputValue;
                  mapping(uint256 => uint256) interestRates;
                  mapping(uint256 => uint256) interactions;
                  enum AUX_DATA_SELECTOR {
                      NADA,
                      OPEN_LOAN,
                      CLOSE_LOAN,
                      OPEN_LP,
                      CLOSE_LP
                  }
                  receive() external payable {}
                  constructor(
                      address _rollupProcessor,
                      bool _canConvert,
                      uint256 _outputValueA,
                      uint256 _outputValueB,
                      uint256 _returnValueA,
                      uint256 _returnValueB,
                      uint256 _returnInputValue,
                      bool _isAsync
                  ) {
                      rollupProcessor = _rollupProcessor;
                      canConvert = _canConvert;
                      outputValueA = _outputValueA;
                      outputValueB = _outputValueB;
                      returnValueA = _returnValueA;
                      returnValueB = _returnValueB;
                      returnInputValue = _returnInputValue;
                      isAsync = _isAsync;
                  }
                  // Input cases:
                  // Case1: 1 real input.
                  // Case2: 1 virtual asset input.
                  // Case3: 1 real 1 virtual input.
                  // Output cases:
                  // 1 real
                  // 2 real
                  // 1 real 1 virtual
                  // 1 virtual
                  // E2E example use cases.
                  // 1 1: Swapping.
                  // 1 2: Swapping with incentives (2nd output reward token).
                  // 1 3: Borrowing. Lock up collateral, get back loan asset and virtual position asset.
                  // 1 4: Opening lending position OR Purchasing NFT. Input real asset, get back virtual asset representing NFT or position.
                  // 2 1: Selling NFT. Input the virtual asset, get back a real asset.
                  // 2 2: Closing a lending position. Get back original asset and reward asset.
                  // 2 3: Claiming fees from an open position.
                  // 2 4: Voting on a 1 4 case.
                  // 3 1: Repaying a borrow. Return loan plus interest. Get collateral back.
                  // 3 2: Repaying a borrow. Return loan plus interest. Get collateral plus reward token. (AAVE)
                  // 3 3: Partial loan repayment.
                  // 3 4: DAO voting stuff.
                  function convert(
                      AztecTypes.AztecAsset memory inputAssetA,
                      AztecTypes.AztecAsset memory inputAssetB,
                      AztecTypes.AztecAsset memory outputAssetA,
                      AztecTypes.AztecAsset memory outputAssetB,
                      uint256 totalInputValue,
                      uint256 interactionNonce,
                      uint64 auxData,
                      address
                  )
                      external
                      payable
                      override
                      returns (
                          uint256,
                          uint256,
                          bool
                      )
                  {
                      require(canConvert, 'MockDefiBridge: canConvert = false');
                      uint256 modifiedReturnValueA = returnValueA;
                      if (auxData == uint32(AUX_DATA_SELECTOR.CLOSE_LOAN) && inputAssetB.id > 0) {
                          require(
                              inputAssetB.assetType == AztecTypes.AztecAssetType.VIRTUAL,
                              'MockDefiBridge: INPUT_ASSET_A_NOT_VIRTUAL'
                          );
                          // get interest rate from the mapping interestRates
                          modifiedReturnValueA -= (returnValueA * interestRates[inputAssetB.id]) / 100;
                      }
                      if (!isAsync) {
                          approveTransfer(inputAssetA, returnInputValue, interactionNonce);
                          approveTransfer(outputAssetA, modifiedReturnValueA, interactionNonce);
                          approveTransfer(outputAssetB, returnValueB, interactionNonce);
                      }
                      interactions[interactionNonce] = totalInputValue;
                      if (isAsync) {
                          return (0, 0, isAsync);
                      }
                      return (modifiedReturnValueA, returnValueB, isAsync);
                  }
                  function recordInterestRate(uint256 interactionNonce, uint256 rate) external {
                      interestRates[interactionNonce] = rate;
                  }
                  function canFinalise(
                      uint256 /*interactionNonce*/
                  ) external pure override returns (bool) {
                      return true;
                  }
                  function finalise(
                      AztecTypes.AztecAsset memory inputAssetA,
                      AztecTypes.AztecAsset memory, /*inputAssetB*/
                      AztecTypes.AztecAsset memory outputAssetA,
                      AztecTypes.AztecAsset memory outputAssetB,
                      uint256 interactionNonce,
                      uint64
                  )
                      external
                      payable
                      override
                      returns (
                          uint256,
                          uint256,
                          bool
                      )
                  {
                      require(msg.sender == rollupProcessor, 'invalid sender!');
                      approveTransfer(inputAssetA, returnInputValue, interactionNonce);
                      approveTransfer(outputAssetA, returnValueA, interactionNonce);
                      approveTransfer(outputAssetB, returnValueB, interactionNonce);
                      return (outputValueA, outputValueB, true);
                  }
                  function approveTransfer(
                      AztecTypes.AztecAsset memory asset,
                      uint256 value,
                      uint256 interactionNonce
                  ) internal returns (uint256 msgCallValue) {
                      if (asset.assetType == AztecTypes.AztecAssetType.ETH) {
                          msgCallValue = value;
                          bytes memory payload = abi.encodeWithSignature('receiveEthFromBridge(uint256)', interactionNonce);
                          (bool success, ) = address(rollupProcessor).call{value: msgCallValue}(payload);
                          assembly {
                              if iszero(success) {
                                  returndatacopy(0x00, 0x00, returndatasize())
                                  revert(0x00, returndatasize())
                              }
                          }
                      } else if (asset.assetType == AztecTypes.AztecAssetType.ERC20) {
                          IERC20(asset.erc20Address).approve(rollupProcessor, value);
                      }
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
              import {IDefiBridge} from '../interfaces/IDefiBridge.sol';
              import {AztecTypes} from '../AztecTypes.sol';
              import {IRollupProcessor} from '../interfaces/IRollupProcessor.sol';
              /**
               * @dev Warning: do not deploy in real environments, for testing only
               */
              contract FailingBridge is IDefiBridge {
                  address public immutable rollupProcessor;
                  bool public complete;
                  uint256 public nonce;
                  receive() external payable {}
                  constructor(address _rollupProcessor) {
                      rollupProcessor = _rollupProcessor;
                  }
                  function setComplete(bool flag, uint256 _nonce) public {
                      complete = flag;
                      nonce = _nonce;
                  }
                  function convert(
                      AztecTypes.AztecAsset memory,
                      AztecTypes.AztecAsset memory,
                      AztecTypes.AztecAsset memory,
                      AztecTypes.AztecAsset memory,
                      uint256,
                      uint256,
                      uint64,
                      address
                  )
                      external
                      payable
                      override
                      returns (
                          uint256,
                          uint256,
                          bool
                      )
                  {
                      return (0, 0, true);
                  }
                  function canFinalise(uint256) external pure override returns (bool) {
                      return true;
                  }
                  function finalise(
                      AztecTypes.AztecAsset memory,
                      AztecTypes.AztecAsset memory,
                      AztecTypes.AztecAsset memory,
                      AztecTypes.AztecAsset memory,
                      uint256,
                      uint64
                  )
                      external
                      payable
                      override
                      returns (
                          uint256,
                          uint256,
                          bool
                      )
                  {
                      require(msg.sender == rollupProcessor, 'invalid sender!');
                      if (!complete) {
                          return (0, 0, false);
                      }
                      IRollupProcessor(rollupProcessor).receiveEthFromBridge{value: 1}(nonce);
                      return (1, 0, true);
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
              import {IDefiBridge} from '../interfaces/IDefiBridge.sol';
              import {AztecTypes} from '../AztecTypes.sol';
              import {IRollupProcessor} from '../interfaces/IRollupProcessor.sol';
              /**
               * @dev Warning: do not deploy in real environments, for testing only
               */
              contract FailingAsyncBridge is IDefiBridge {
                  address public immutable rollupProcessor;
                  uint256 public a;
                  uint256 public b;
                  receive() external payable {}
                  constructor(address _rollupProcessor) {
                      rollupProcessor = _rollupProcessor;
                  }
                  function setReturnValues(uint256 _a, uint256 _b) public {
                      a = _a;
                      b = _b;
                  }
                  function convert(
                      AztecTypes.AztecAsset memory,
                      AztecTypes.AztecAsset memory,
                      AztecTypes.AztecAsset memory,
                      AztecTypes.AztecAsset memory,
                      uint256,
                      uint256,
                      uint64,
                      address
                  )
                      external
                      payable
                      override
                      returns (
                          uint256,
                          uint256,
                          bool
                      )
                  {
                      return (a, b, true);
                  }
                  function canFinalise(uint256) external pure override returns (bool) {
                      return true;
                  }
                  function finalise(
                      AztecTypes.AztecAsset memory,
                      AztecTypes.AztecAsset memory,
                      AztecTypes.AztecAsset memory,
                      AztecTypes.AztecAsset memory,
                      uint256,
                      uint64
                  )
                      external
                      payable
                      override
                      returns (
                          uint256,
                          uint256,
                          bool
                      )
                  {
                      return (1, 0, true);
                  }
              }
              // 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);
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts (last updated v4.6.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, allowance(owner, spender) + addedValue);
                      return true;
                  }
                  /**
                   * @dev Atomically decreases the allowance granted to `spender` by the caller.
                   *
                   * This is an alternative to {approve} that can be used as a mitigation for
                   * problems described in {IERC20-approve}.
                   *
                   * Emits an {Approval} event indicating the updated allowance.
                   *
                   * Requirements:
                   *
                   * - `spender` cannot be the zero address.
                   * - `spender` must have allowance for the caller of at least
                   * `subtractedValue`.
                   */
                  function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
                      address owner = _msgSender();
                      uint256 currentAllowance = allowance(owner, spender);
                      require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
                      unchecked {
                          _approve(owner, spender, currentAllowance - subtractedValue);
                      }
                      return true;
                  }
                  /**
                   * @dev Moves `amount` of tokens from `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 Updates `owner` s allowance for `spender` based on spent `amount`.
                   *
                   * Does not update the allowance amount in case of infinite allowance.
                   * Revert if not enough allowance is available.
                   *
                   * Might emit an {Approval} event.
                   */
                  function _spendAllowance(
                      address owner,
                      address spender,
                      uint256 amount
                  ) internal virtual {
                      uint256 currentAllowance = allowance(owner, spender);
                      if (currentAllowance != type(uint256).max) {
                          require(currentAllowance >= amount, "ERC20: insufficient allowance");
                          unchecked {
                              _approve(owner, spender, currentAllowance - amount);
                          }
                      }
                  }
                  /**
                   * @dev Hook that is called before any transfer of tokens. This includes
                   * minting and burning.
                   *
                   * Calling conditions:
                   *
                   * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
                   * will be transferred to `to`.
                   * - when `from` is zero, `amount` tokens will be minted for `to`.
                   * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
                   * - `from` and `to` are never both zero.
                   *
                   * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
                   */
                  function _beforeTokenTransfer(
                      address from,
                      address to,
                      uint256 amount
                  ) internal virtual {}
                  /**
                   * @dev Hook that is called after any transfer of tokens. This includes
                   * minting and burning.
                   *
                   * Calling conditions:
                   *
                   * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
                   * has been transferred to `to`.
                   * - when `from` is zero, `amount` tokens have been minted for `to`.
                   * - when `to` is zero, `amount` of ``from``'s tokens have been burned.
                   * - `from` and `to` are never both zero.
                   *
                   * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
                   */
                  function _afterTokenTransfer(
                      address from,
                      address to,
                      uint256 amount
                  ) internal virtual {}
              }
              // 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;
                  }
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts (last updated v4.6.0) (access/AccessControl.sol)
              pragma solidity ^0.8.0;
              import "./IAccessControl.sol";
              import "../utils/Context.sol";
              import "../utils/Strings.sol";
              import "../utils/introspection/ERC165.sol";
              /**
               * @dev Contract module that allows children to implement role-based access
               * control mechanisms. This is a lightweight version that doesn't allow enumerating role
               * members except through off-chain means by accessing the contract event logs. Some
               * applications may benefit from on-chain enumerability, for those cases see
               * {AccessControlEnumerable}.
               *
               * Roles are referred to by their `bytes32` identifier. These should be exposed
               * in the external API and be unique. The best way to achieve this is by
               * using `public constant` hash digests:
               *
               * ```
               * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
               * ```
               *
               * Roles can be used to represent a set of permissions. To restrict access to a
               * function call, use {hasRole}:
               *
               * ```
               * function foo() public {
               *     require(hasRole(MY_ROLE, msg.sender));
               *     ...
               * }
               * ```
               *
               * Roles can be granted and revoked dynamically via the {grantRole} and
               * {revokeRole} functions. Each role has an associated admin role, and only
               * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
               *
               * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
               * that only accounts with this role will be able to grant or revoke other
               * roles. More complex role relationships can be created by using
               * {_setRoleAdmin}.
               *
               * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
               * grant and revoke this role. Extra precautions should be taken to secure
               * accounts that have been granted it.
               */
              abstract contract AccessControl is Context, IAccessControl, ERC165 {
                  struct RoleData {
                      mapping(address => bool) members;
                      bytes32 adminRole;
                  }
                  mapping(bytes32 => RoleData) private _roles;
                  bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
                  /**
                   * @dev Modifier that checks that an account has a specific role. Reverts
                   * with a standardized message including the required role.
                   *
                   * The format of the revert reason is given by the following regular expression:
                   *
                   *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
                   *
                   * _Available since v4.1._
                   */
                  modifier onlyRole(bytes32 role) {
                      _checkRole(role);
                      _;
                  }
                  /**
                   * @dev See {IERC165-supportsInterface}.
                   */
                  function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
                      return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
                  }
                  /**
                   * @dev Returns `true` if `account` has been granted `role`.
                   */
                  function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
                      return _roles[role].members[account];
                  }
                  /**
                   * @dev Revert with a standard message if `_msgSender()` is missing `role`.
                   * Overriding this function changes the behavior of the {onlyRole} modifier.
                   *
                   * Format of the revert message is described in {_checkRole}.
                   *
                   * _Available since v4.6._
                   */
                  function _checkRole(bytes32 role) internal view virtual {
                      _checkRole(role, _msgSender());
                  }
                  /**
                   * @dev Revert with a standard message if `account` is missing `role`.
                   *
                   * The format of the revert reason is given by the following regular expression:
                   *
                   *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
                   */
                  function _checkRole(bytes32 role, address account) internal view virtual {
                      if (!hasRole(role, account)) {
                          revert(
                              string(
                                  abi.encodePacked(
                                      "AccessControl: account ",
                                      Strings.toHexString(uint160(account), 20),
                                      " is missing role ",
                                      Strings.toHexString(uint256(role), 32)
                                  )
                              )
                          );
                      }
                  }
                  /**
                   * @dev Returns the admin role that controls `role`. See {grantRole} and
                   * {revokeRole}.
                   *
                   * To change a role's admin, use {_setRoleAdmin}.
                   */
                  function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
                      return _roles[role].adminRole;
                  }
                  /**
                   * @dev Grants `role` to `account`.
                   *
                   * If `account` had not been already granted `role`, emits a {RoleGranted}
                   * event.
                   *
                   * Requirements:
                   *
                   * - the caller must have ``role``'s admin role.
                   */
                  function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
                      _grantRole(role, account);
                  }
                  /**
                   * @dev Revokes `role` from `account`.
                   *
                   * If `account` had been granted `role`, emits a {RoleRevoked} event.
                   *
                   * Requirements:
                   *
                   * - the caller must have ``role``'s admin role.
                   */
                  function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
                      _revokeRole(role, account);
                  }
                  /**
                   * @dev Revokes `role` from the calling account.
                   *
                   * Roles are often managed via {grantRole} and {revokeRole}: this function's
                   * purpose is to provide a mechanism for accounts to lose their privileges
                   * if they are compromised (such as when a trusted device is misplaced).
                   *
                   * If the calling account had been revoked `role`, emits a {RoleRevoked}
                   * event.
                   *
                   * Requirements:
                   *
                   * - the caller must be `account`.
                   */
                  function renounceRole(bytes32 role, address account) public virtual override {
                      require(account == _msgSender(), "AccessControl: can only renounce roles for self");
                      _revokeRole(role, account);
                  }
                  /**
                   * @dev Grants `role` to `account`.
                   *
                   * If `account` had not been already granted `role`, emits a {RoleGranted}
                   * event. Note that unlike {grantRole}, this function doesn't perform any
                   * checks on the calling account.
                   *
                   * [WARNING]
                   * ====
                   * This function should only be called from the constructor when setting
                   * up the initial roles for the system.
                   *
                   * Using this function in any other way is effectively circumventing the admin
                   * system imposed by {AccessControl}.
                   * ====
                   *
                   * NOTE: This function is deprecated in favor of {_grantRole}.
                   */
                  function _setupRole(bytes32 role, address account) internal virtual {
                      _grantRole(role, account);
                  }
                  /**
                   * @dev Sets `adminRole` as ``role``'s admin role.
                   *
                   * Emits a {RoleAdminChanged} event.
                   */
                  function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
                      bytes32 previousAdminRole = getRoleAdmin(role);
                      _roles[role].adminRole = adminRole;
                      emit RoleAdminChanged(role, previousAdminRole, adminRole);
                  }
                  /**
                   * @dev Grants `role` to `account`.
                   *
                   * Internal function without access restriction.
                   */
                  function _grantRole(bytes32 role, address account) internal virtual {
                      if (!hasRole(role, account)) {
                          _roles[role].members[account] = true;
                          emit RoleGranted(role, account, _msgSender());
                      }
                  }
                  /**
                   * @dev Revokes `role` from `account`.
                   *
                   * Internal function without access restriction.
                   */
                  function _revokeRole(bytes32 role, address account) internal virtual {
                      if (hasRole(role, account)) {
                          _roles[role].members[account] = false;
                          emit RoleRevoked(role, account, _msgSender());
                      }
                  }
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
              pragma solidity ^0.8.0;
              /**
               * @dev External interface of AccessControl declared to support ERC165 detection.
               */
              interface IAccessControl {
                  /**
                   * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
                   *
                   * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
                   * {RoleAdminChanged} not being emitted signaling this.
                   *
                   * _Available since v3.1._
                   */
                  event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
                  /**
                   * @dev Emitted when `account` is granted `role`.
                   *
                   * `sender` is the account that originated the contract call, an admin role
                   * bearer except when using {AccessControl-_setupRole}.
                   */
                  event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
                  /**
                   * @dev Emitted when `account` is revoked `role`.
                   *
                   * `sender` is the account that originated the contract call:
                   *   - if using `revokeRole`, it is the admin role bearer
                   *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
                   */
                  event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
                  /**
                   * @dev Returns `true` if `account` has been granted `role`.
                   */
                  function hasRole(bytes32 role, address account) external view returns (bool);
                  /**
                   * @dev Returns the admin role that controls `role`. See {grantRole} and
                   * {revokeRole}.
                   *
                   * To change a role's admin, use {AccessControl-_setRoleAdmin}.
                   */
                  function getRoleAdmin(bytes32 role) external view returns (bytes32);
                  /**
                   * @dev Grants `role` to `account`.
                   *
                   * If `account` had not been already granted `role`, emits a {RoleGranted}
                   * event.
                   *
                   * Requirements:
                   *
                   * - the caller must have ``role``'s admin role.
                   */
                  function grantRole(bytes32 role, address account) external;
                  /**
                   * @dev Revokes `role` from `account`.
                   *
                   * If `account` had been granted `role`, emits a {RoleRevoked} event.
                   *
                   * Requirements:
                   *
                   * - the caller must have ``role``'s admin role.
                   */
                  function revokeRole(bytes32 role, address account) external;
                  /**
                   * @dev Revokes `role` from the calling account.
                   *
                   * Roles are often managed via {grantRole} and {revokeRole}: this function's
                   * purpose is to provide a mechanism for accounts to lose their privileges
                   * if they are compromised (such as when a trusted device is misplaced).
                   *
                   * If the calling account had been granted `role`, emits a {RoleRevoked}
                   * event.
                   *
                   * Requirements:
                   *
                   * - the caller must be `account`.
                   */
                  function renounceRole(bytes32 role, address account) external;
              }
              // 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);
                  }
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
              pragma solidity ^0.8.0;
              import "./IERC165.sol";
              /**
               * @dev Implementation of the {IERC165} interface.
               *
               * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
               * for the additional interface id that will be supported. For example:
               *
               * ```solidity
               * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
               *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
               * }
               * ```
               *
               * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
               */
              abstract contract ERC165 is IERC165 {
                  /**
                   * @dev See {IERC165-supportsInterface}.
                   */
                  function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
                      return interfaceId == type(IERC165).interfaceId;
                  }
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
              pragma solidity ^0.8.0;
              /**
               * @dev Interface of the ERC165 standard, as defined in the
               * https://eips.ethereum.org/EIPS/eip-165[EIP].
               *
               * Implementers can declare support of contract interfaces, which can then be
               * queried by others ({ERC165Checker}).
               *
               * For an implementation, see {ERC165}.
               */
              interface IERC165 {
                  /**
                   * @dev Returns true if this contract implements the interface defined by
                   * `interfaceId`. See the corresponding
                   * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
                   * to learn more about how these ids are created.
                   *
                   * This function call must use less than 30 000 gas.
                   */
                  function supportsInterface(bytes4 interfaceId) external view returns (bool);
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec.
              pragma solidity >=0.8.4;
              import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
              import {AccessControl} from '@openzeppelin/contracts/access/AccessControl.sol';
              import {Initializable} from '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol';
              import {IVerifier} from './interfaces/IVerifier.sol';
              import {IRollupProcessor} from './interfaces/IRollupProcessor.sol';
              import {IERC20Permit} from './interfaces/IERC20Permit.sol';
              import {IDefiBridge} from './interfaces/IDefiBridge.sol';
              import {Decoder} from './Decoder.sol';
              import {AztecTypes} from './AztecTypes.sol';
              import {TokenTransfers} from './libraries/TokenTransfers.sol';
              import './libraries/RollupProcessorLibrary.sol';
              /**
               * @title Rollup Processor
               * @dev Smart contract responsible for processing Aztec zkRollups, including relaying them to a verifier
               * contract for validation and performing all relevant ERC20 token transfers
               */
              contract RollupProcessor is IRollupProcessor, Decoder, Initializable, AccessControl {
                  /*----------------------------------------
                    ERROR TAGS
                    ----------------------------------------*/
                  error PAUSED();
                  error NOT_PAUSED();
                  error LOCKED_NO_REENTER();
                  error INVALID_PROVIDER();
                  error THIRD_PARTY_CONTRACTS_FLAG_NOT_SET();
                  error INSUFFICIENT_DEPOSIT();
                  error INVALID_ASSET_ID();
                  error INVALID_ASSET_ADDRESS();
                  error INVALID_LINKED_TOKEN_ADDRESS();
                  error INVALID_LINKED_BRIDGE_ADDRESS();
                  error INVALID_BRIDGE_ID();
                  error INVALID_BRIDGE_ADDRESS();
                  error BRIDGE_ID_IS_INCONSISTENT();
                  error BRIDGE_WITH_IDENTICAL_INPUT_ASSETS(uint256 inputAssetId);
                  error BRIDGE_WITH_IDENTICAL_OUTPUT_ASSETS(uint256 outputAssetId);
                  error ZERO_TOTAL_INPUT_VALUE();
                  error ARRAY_OVERFLOW();
                  error MSG_VALUE_WRONG_AMOUNT();
                  error INSUFFICIENT_ETH_PAYMENT();
                  error WITHDRAW_TO_ZERO_ADDRESS();
                  error DEPOSIT_TOKENS_WRONG_PAYMENT_TYPE();
                  error INSUFFICIENT_TOKEN_APPROVAL();
                  error NONZERO_OUTPUT_VALUE_ON_NOT_USED_ASSET(uint256 outputValue);
                  error INCORRECT_STATE_HASH(bytes32 oldStateHash, bytes32 newStateHash);
                  error INCORRECT_DATA_START_INDEX(uint256 providedIndex, uint256 expectedIndex);
                  error INCORRECT_PREVIOUS_DEFI_INTERACTION_HASH(
                      bytes32 providedDefiInteractionHash,
                      bytes32 expectedDefiInteractionHash
                  );
                  error PUBLIC_INPUTS_HASH_VERIFICATION_FAILED(uint256, uint256);
                  error PROOF_VERIFICATION_FAILED();
                  /*----------------------------------------
                    EVENTS
                    ----------------------------------------*/
                  event OffchainData(uint256 indexed rollupId, uint256 chunk, uint256 totalChunks, address sender);
                  event RollupProcessed(uint256 indexed rollupId, bytes32[] nextExpectedDefiHashes, address sender);
                  event DefiBridgeProcessed(
                      uint256 indexed bridgeId,
                      uint256 indexed nonce,
                      uint256 totalInputValue,
                      uint256 totalOutputValueA,
                      uint256 totalOutputValueB,
                      bool result,
                      bytes errorReason
                  );
                  event AsyncDefiBridgeProcessed(uint256 indexed bridgeId, uint256 indexed nonce, uint256 totalInputValue);
                  event Deposit(uint256 indexed assetId, address indexed depositorAddress, uint256 depositValue);
                  event WithdrawError(bytes errorReason);
                  event AssetAdded(uint256 indexed assetId, address indexed assetAddress, uint256 assetGasLimit);
                  event BridgeAdded(uint256 indexed bridgeAddressId, address indexed bridgeAddress, uint256 bridgeGasLimit);
                  event RollupProviderUpdated(address indexed providerAddress, bool valid);
                  event VerifierUpdated(address indexed verifierAddress);
                  event Paused(address account);
                  event Unpaused(address account);
                  /*----------------------------------------
                    STRUCTS
                    ----------------------------------------*/
                  enum Lock {
                      UNLOCKED,
                      ALLOW_ASYNC_REENTER,
                      LOCKED
                  }
                  /**
                   * @dev RollupState struct contains the following data (offsets are for when used as storage slot):
                   *
                   * | bit offset   | num bits    | description |
                   * | ---          | ---         | ---         |
                   * | 0            | 160         | PLONK verifier contract address |
                   * | 160          | 32          | datasize: number of filled entries in note tree |
                   * | 192          | 16          | asyncDefiInteractionHashes.length : number of entries in asyncDefiInteractionHashes array |
                   * | 208          | 16          | defiInteractionHashes.length : number of entries in defiInteractionHashes array |
                   * | 224          | 8           | Lock enum used to guard against reentrancy attacks (minimum value to store in is uint8)
                   * | 232          | 8           | pause flag, true if contract is paused, false otherwise
                   */
                  struct RollupState {
                      IVerifier verifier;
                      uint32 datasize;
                      uint16 numAsyncDefiInteractionHashes;
                      uint16 numDefiInteractionHashes;
                      Lock lock;
                      bool paused;
                  }
                  /**
                   * @dev Contains information that describes a specific DeFi bridge
                   * @notice A single smart contract can be used to represent multiple bridges
                   *
                   * @param bridgeAddressId the bridge contract address = supportedBridges[bridgeAddressId]
                   * @param bridgeAddress   the bridge contract address
                   * @param inputAssetIdA
                   */
                  struct BridgeData {
                      uint256 bridgeAddressId;
                      address bridgeAddress;
                      uint256 inputAssetIdA;
                      uint256 inputAssetIdB;
                      uint256 outputAssetIdA;
                      uint256 outputAssetIdB;
                      uint256 auxData;
                      bool firstInputVirtual;
                      bool secondInputVirtual;
                      bool firstOutputVirtual;
                      bool secondOutputVirtual;
                      bool secondInputInUse;
                      bool secondOutputInUse;
                      uint256 bridgeGasLimit;
                  }
                  /**
                   * @dev Represents an asynchronous defi bridge interaction that has not been resolved
                   * @param bridgeId the bridge id
                   * @param totalInputValue number of tokens/wei sent to the bridge
                   */
                  struct PendingDefiBridgeInteraction {
                      uint256 bridgeId;
                      uint256 totalInputValue;
                  }
                  /**
                   * @dev Container for the results of a DeFi interaction
                   * @param outputValueA number of returned tokens for the interaction's first output asset
                   * @param outputValueB number of returned tokens for the interaction's second output asset (if relevant)
                   * @param isAsync is the interaction asynchronous? i.e. triggering an interaction does not immediately resolve
                   * @param success did the call to the bridge succeed or fail?
                   *
                   * @notice async interactions must have outputValueA == 0 and outputValueB == 0 (tokens get returned later via calling `processAsyncDefiInteraction`)
                   */
                  struct BridgeResult {
                      uint256 outputValueA;
                      uint256 outputValueB;
                      bool isAsync;
                      bool success;
                  }
                  /**
                   * @dev Container for the inputs of a Defi interaction
                   * @param totalInputValue number of tokens/wei sent to the bridge
                   * @param interactionNonce the unique id of the interaction
                   * @param auxData additional input specific to the type of interaction
                   */
                  struct InteractionInputs {
                      uint256 totalInputValue;
                      uint256 interactionNonce;
                      uint64 auxData;
                  }
                  /*----------------------------------------
                    FUNCTION SELECTORS (PRECOMPUTED)
                    ----------------------------------------*/
                  // DEFI_BRIDGE_PROXY_CONVERT_SELECTOR = function signature of:
                  //   function convert(
                  //       address,
                  //       AztecTypes.AztecAsset memory inputAssetA,
                  //       AztecTypes.AztecAsset memory inputAssetB,
                  //       AztecTypes.AztecAsset memory outputAssetA,
                  //       AztecTypes.AztecAsset memory outputAssetB,
                  //       uint256 totalInputValue,
                  //       uint256 interactionNonce,
                  //       uint256 auxData,
                  //       uint256 ethPaymentsSlot
                  //       address rollupBeneficary)
                  // N.B. this is the selector of the 'convert' function of the DefiBridgeProxy contract.
                  //      This has a different interface to the IDefiBridge.convert function
                  bytes4 private constant DEFI_BRIDGE_PROXY_CONVERT_SELECTOR = 0x4bd947a8;
                  /*----------------------------------------
                    CONSTANT STATE VARIABLES
                    ----------------------------------------*/
                  uint256 private constant ethAssetId = 0; // if assetId == ethAssetId, treat as native ETH and not ERC20 token
                  // starting root hash of the DeFi interaction result Merkle tree
                  bytes32 private constant INIT_DEFI_ROOT = 0x2e4ab7889ab3139204945f9e722c7a8fdb84e66439d787bd066c3d896dba04ea;
                  bytes32 private constant DEFI_BRIDGE_PROCESSED_SIGHASH =
                      0x692cf5822a02f5edf084dc7249b3a06293621e069f11975ed70908ed10ed2e2c;
                  bytes32 private constant ASYNC_BRIDGE_PROCESSED_SIGHASH =
                      0x38ce48f4c2f3454bcf130721f25a4262b2ff2c8e36af937b30edf01ba481eb1d;
                  // We need to cap the amount of gas sent to the DeFi bridge contract for two reasons.
                  // 1: To provide consistency to rollup providers around costs.
                  // 2: To prevent griefing attacks where a bridge consumes all our gas.
                  uint256 private constant MIN_BRIDGE_GAS_LIMIT = 35000;
                  uint256 private constant MIN_ERC20_GAS_LIMIT = 55000;
                  uint256 private constant MAX_BRIDGE_GAS_LIMIT = 5000000;
                  uint256 private constant MAX_ERC20_GAS_LIMIT = 1500000;
                  // Bit offsets and bit masks used to convert a `uint256 bridgeId` into a BridgeData member
                  uint256 private constant INPUT_ASSET_ID_A_SHIFT = 32;
                  uint256 private constant INPUT_ASSET_ID_B_SHIFT = 62;
                  uint256 private constant OUTPUT_ASSET_ID_A_SHIFT = 92;
                  uint256 private constant OUTPUT_ASSET_ID_B_SHIFT = 122;
                  uint256 private constant BITCONFIG_SHIFT = 152;
                  uint256 private constant AUX_DATA_SHIFT = 184;
                  uint256 private constant VIRTUAL_ASSET_ID_FLAG_SHIFT = 29;
                  uint256 private constant VIRTUAL_ASSET_ID_FLAG = 0x20000000; // 2 ** 29
                  uint256 private constant MASK_THIRTY_TWO_BITS = 0xffffffff;
                  uint256 private constant MASK_THIRTY_BITS = 0x3fffffff;
                  uint256 private constant MASK_SIXTY_FOUR_BITS = 0xffffffffffffffff;
                  // Offsets and masks used to encode/decode the stateHash storage variable of RollupProcessor
                  uint256 private constant DATASIZE_BIT_OFFSET = 160;
                  uint256 private constant ASYNCDEFIINTERACTIONHASHES_BIT_OFFSET = 192;
                  uint256 private constant DEFIINTERACTIONHASHES_BIT_OFFSET = 208;
                  uint256 private constant ARRAY_LENGTH_MASK = 0x3ff; // 1023
                  uint256 private constant DATASIZE_MASK = 0xffffffff;
                  // the value of hashing a 'zeroed' defi interaction result
                  bytes32 private constant DEFI_RESULT_ZERO_HASH = 0x2d25a1e3a51eb293004c4b56abe12ed0da6bca2b4a21936752a85d102593c1b4;
                  // roles used in access control
                  bytes32 public constant OWNER_ROLE = keccak256('OWNER_ROLE');
                  bytes32 public constant EMERGENCY_ROLE = keccak256('EMERGENCY_ROLE');
                  // bounds used for escapehatch
                  uint256 public immutable escapeBlockLowerBound;
                  uint256 public immutable escapeBlockUpperBound;
                  /*----------------------------------------
                    STATE VARIABLES
                    ----------------------------------------*/
                  RollupState internal rollupState;
                  // Array of supported ERC20 token address.
                  address[] internal supportedAssets;
                  // Array of supported bridge contract addresses (similar to assetIds)
                  address[] internal supportedBridges;
                  // Mapping from index to async interaction hash (emulates an array), next index stored in the RollupState
                  mapping(uint256 => bytes32) public asyncDefiInteractionHashes;
                  // Mapping from index to sync interaction hash (emulates an array), next index stored in the RollupState
                  mapping(uint256 => bytes32) public defiInteractionHashes;
                  // Mapping from assetId to mapping of userAddress to public userBalance stored on this contract
                  mapping(uint256 => mapping(address => uint256)) public userPendingDeposits;
                  // Mapping from user address to mapping of proof hashes to flag for approval
                  mapping(address => mapping(bytes32 => bool)) public depositProofApprovals;
                  // The hash of the latest rollup state
                  bytes32 public override(IRollupProcessor) rollupStateHash;
                  // The address of the defi bridge proxy
                  address public override(IRollupProcessor) defiBridgeProxy;
                  // Flag to allow third party contracts to list assets and bridges when out of BETA
                  bool public allowThirdPartyContracts;
                  // Mapping from address to flag, true if address is approved, false otherwise
                  mapping(address => bool) public rollupProviders;
                  // map defiInteractionNonce to PendingDefiBridgeInteraction
                  mapping(uint256 => PendingDefiBridgeInteraction) public pendingDefiInteractions;
                  // map interaction nonces to eth send to RollupProcessor during a bridge interaction
                  mapping(uint256 => uint256) public ethPayments;
                  // map asset id to Gas Limit
                  mapping(uint256 => uint256) public assetGasLimits;
                  // map bridge id to Gas Limit
                  mapping(uint256 => uint256) public bridgeGasLimits;
                  // stores the hash of the hashes of the pending defi interactions, the notes of which are expected to be added in the 'next' rollup
                  bytes32 public override(IRollupProcessor) prevDefiInteractionsHash;
                  /*----------------------------------------
                    MODIFIERS
                    ----------------------------------------*/
                  /**
                   * @dev Modifier to protect functions from being called while the contract is still in BETA.
                   */
                  modifier checkThirdPartyContractStatus() {
                      if (!hasRole(OWNER_ROLE, msg.sender) && !allowThirdPartyContracts) {
                          revert THIRD_PARTY_CONTRACTS_FLAG_NOT_SET();
                      }
                      _;
                  }
                  /**
                   * @dev Modifier reverting if contract is paused
                   */
                  modifier whenNotPaused() {
                      if (rollupState.paused) {
                          revert PAUSED();
                      }
                      _;
                  }
                  /**
                   * @dev Modifier reverting if contract is NOT paused
                   */
                  modifier whenPaused() {
                      if (!rollupState.paused) {
                          revert NOT_PAUSED();
                      }
                      _;
                  }
                  /**
                   * @dev Modifier reverting on any re-enter.
                   */
                  modifier noReenter() {
                      if (rollupState.lock != Lock.UNLOCKED) {
                          revert LOCKED_NO_REENTER();
                      }
                      rollupState.lock = Lock.LOCKED;
                      _;
                      rollupState.lock = Lock.UNLOCKED;
                  }
                  /**
                   * @dev Modifier reverting on any re-enter but allowing async to be called.
                   */
                  modifier allowAsyncReenter() {
                      if (rollupState.lock != Lock.UNLOCKED) {
                          revert LOCKED_NO_REENTER();
                      }
                      rollupState.lock = Lock.ALLOW_ASYNC_REENTER;
                      _;
                      rollupState.lock = Lock.UNLOCKED;
                  }
                  /**
                   * @dev Modifier reverting if re-entering after locking, but passes if unlocked or allowing async.
                   */
                  modifier noReenterButAsync() {
                      Lock lock = rollupState.lock;
                      if (lock == Lock.ALLOW_ASYNC_REENTER) {
                          _;
                      } else if (lock == Lock.UNLOCKED) {
                          rollupState.lock = Lock.ALLOW_ASYNC_REENTER;
                          _;
                          rollupState.lock = Lock.UNLOCKED;
                      } else {
                          revert LOCKED_NO_REENTER();
                      }
                  }
                  /**
                   * @dev throw if a given assetId represents a virtual asset
                   * @param assetId 30-bit integer that describes the asset.
                   * If assetId's 29th bit is set, it represents a virtual asset with no ERC20 equivalent
                   * Virtual assets are used by defi bridges to track non-token data. E.g. to represent a loan.
                   * If an assetId is *not* a virtual asset, its ERC20 address can be recovered from `supportedAssets[assetId]`
                   */
                  modifier validateAssetIdIsNotVirtual(uint256 assetId) {
                      if (assetId > 0x1fffffff) {
                          revert INVALID_ASSET_ID();
                      }
                      _;
                  }
                  /*----------------------------------------
                    CONSTRUCTORS & INITIALIZERS
                    ----------------------------------------*/
                  /**
                   * @dev Constructor used to store immutable values for escape hatch window and
                   * ensure that the implementation cannot be initialized
                   * @param _escapeBlockLowerBound defines start of escape hatch window
                   * @param _escapeBlockUpperBound defines end of the escape hatch window
                   */
                  constructor(uint256 _escapeBlockLowerBound, uint256 _escapeBlockUpperBound) {
                      _disableInitializers();
                      rollupState.paused = true;
                      escapeBlockLowerBound = _escapeBlockLowerBound;
                      escapeBlockUpperBound = _escapeBlockUpperBound;
                  }
                  /**
                   * @dev Initialiser function. Emulates constructor behaviour for upgradeable contracts
                   * @param _verifierAddress the address of the Plonk verification smart contract
                   * @param _defiBridgeProxy address of the proxy contract that we route defi bridge calls through via `delegateCall`
                   * @param _contractOwner owner address of RollupProcessor. Should be a multisig contract
                   * @param _initDataRoot starting state of the Aztec data tree. Init tree state should be all-zeroes excluding migrated account notes
                   * @param _initNullRoot starting state of the Aztec nullifier tree. Init tree state should be all-zeroes excluding migrated account nullifiers
                   * @param _initRootRoot starting state of the Aztec data roots tree. Init tree state should be all-zeroes excluding 1 leaf containing _initDataRoot
                   * @param _initDatasize starting size of the Aztec data tree.
                   * @param _allowThirdPartyContracts flag that specifies whether 3rd parties are allowed to add state to the contract
                   */
                  function initialize(
                      address _verifierAddress,
                      address _defiBridgeProxy,
                      address _contractOwner,
                      bytes32 _initDataRoot,
                      bytes32 _initNullRoot,
                      bytes32 _initRootRoot,
                      uint32 _initDatasize,
                      bool _allowThirdPartyContracts
                  ) external reinitializer(getImplementationVersion()) {
                      _grantRole(DEFAULT_ADMIN_ROLE, _contractOwner);
                      _grantRole(OWNER_ROLE, _contractOwner);
                      _grantRole(EMERGENCY_ROLE, _contractOwner);
                      // compute rollupStateHash
                      assembly {
                          let mPtr := mload(0x40)
                          mstore(mPtr, 0) // nextRollupId
                          mstore(add(mPtr, 0x20), _initDataRoot)
                          mstore(add(mPtr, 0x40), _initNullRoot)
                          mstore(add(mPtr, 0x60), _initRootRoot)
                          mstore(add(mPtr, 0x80), INIT_DEFI_ROOT)
                          sstore(rollupStateHash.slot, keccak256(mPtr, 0xa0))
                      }
                      rollupState.datasize = _initDatasize;
                      rollupState.verifier = IVerifier(_verifierAddress);
                      defiBridgeProxy = _defiBridgeProxy;
                      allowThirdPartyContracts = _allowThirdPartyContracts;
                      // initial value of the hash of 32 'zero' defi note hashes
                      prevDefiInteractionsHash = 0x14e0f351ade4ba10438e9b15f66ab2e6389eea5ae870d6e8b2df1418b2e6fd5b;
                  }
                  /*----------------------------------------
                    MUTATING FUNCTIONS WITH ACCESS CONTROL 
                    ----------------------------------------*/
                  /**
                   * @dev Allow the multisig owner to pause the contract.
                   */
                  function pause() public override(IRollupProcessor) whenNotPaused onlyRole(EMERGENCY_ROLE) noReenter {
                      rollupState.paused = true;
                      emit Paused(msg.sender);
                  }
                  /**
                   * @dev Allow the multisig owner to unpause the contract.
                   */
                  function unpause() public override(IRollupProcessor) whenPaused onlyRole(OWNER_ROLE) noReenter {
                      rollupState.paused = false;
                      emit Unpaused(msg.sender);
                  }
                  /**
                   * @dev adds/removes an authorized rollup provider that can publish rollup blocks. Admin only
                   * @param providerAddress address of rollup provider
                   * @param valid are we adding or removing the provider?
                   */
                  function setRollupProvider(address providerAddress, bool valid)
                      external
                      override(IRollupProcessor)
                      onlyRole(OWNER_ROLE)
                      noReenter
                  {
                      rollupProviders[providerAddress] = valid;
                      emit RollupProviderUpdated(providerAddress, valid);
                  }
                  /**
                   * @dev sets the address of the PLONK verification smart contract. Admin only
                   * @param _verifierAddress address of the verification smart contract
                   */
                  function setVerifier(address _verifierAddress) public override(IRollupProcessor) onlyRole(OWNER_ROLE) noReenter {
                      rollupState.verifier = IVerifier(_verifierAddress);
                      emit VerifierUpdated(_verifierAddress);
                  }
                  /**
                   * @dev Set a flag that allows a third party dev to register assets and bridges.
                   * @param _flag - bool if the flag should be set or not
                   */
                  function setAllowThirdPartyContracts(bool _flag)
                      external
                      override(IRollupProcessor)
                      onlyRole(OWNER_ROLE)
                      noReenter
                  {
                      allowThirdPartyContracts = _flag;
                  }
                  /**
                   * @dev sets the address of the defi bridge proxy. Admin only
                   * @param defiBridgeProxyAddress address of the defi bridge proxy contract
                   */
                  function setDefiBridgeProxy(address defiBridgeProxyAddress)
                      public
                      override(IRollupProcessor)
                      onlyRole(OWNER_ROLE)
                      noReenter
                  {
                      defiBridgeProxy = defiBridgeProxyAddress;
                  }
                  /**
                   * @dev Set the mapping between an assetId and the address of the linked asset.
                   * @param linkedToken - address of the asset
                   * @param gasLimit - uint256 gas limit for ERC20 token transfers of this asset
                   */
                  function setSupportedAsset(address linkedToken, uint256 gasLimit)
                      external
                      override(IRollupProcessor)
                      whenNotPaused
                      checkThirdPartyContractStatus
                      noReenter
                  {
                      if (linkedToken == address(0)) {
                          revert INVALID_LINKED_TOKEN_ADDRESS();
                      }
                      supportedAssets.push(linkedToken);
                      uint256 assetId = supportedAssets.length;
                      assetGasLimits[assetId] = sanitiseAssetGasLimit(gasLimit);
                      emit AssetAdded(assetId, linkedToken, assetGasLimits[assetId]);
                  }
                  /**
                   * @dev Set the mapping between an bridge contract id and the address of the linked bridge contract.
                   * @param linkedBridge - address of the bridge contract
                   * @param gasLimit - uint256 gas limit to send to the bridge convert function
                   */
                  function setSupportedBridge(address linkedBridge, uint256 gasLimit)
                      external
                      override(IRollupProcessor)
                      whenNotPaused
                      checkThirdPartyContractStatus
                      noReenter
                  {
                      if (linkedBridge == address(0)) {
                          revert INVALID_LINKED_BRIDGE_ADDRESS();
                      }
                      supportedBridges.push(linkedBridge);
                      uint256 bridgeAddressId = supportedBridges.length;
                      bridgeGasLimits[bridgeAddressId] = sanitiseBridgeGasLimit(gasLimit);
                      emit BridgeAdded(bridgeAddressId, linkedBridge, bridgeGasLimits[bridgeAddressId]);
                  }
                  /**
                   * @dev Process a rollup - decode the rollup, update relevant state variables and
                   * verify the proof
                   * @param - cryptographic proof data associated with a rollup
                   * @param signatures - bytes array of secp256k1 ECDSA signatures, authorising a transfer of tokens
                   * from the publicOwner for the particular inner proof in question. There is a signature for each
                   * inner proof.
                   *
                   * Structure of each signature in the bytes array is:
                   * 0x00 - 0x20 : r
                   * 0x20 - 0x40 : s
                   * 0x40 - 0x60 : v (in form: 0x0000....0001b for example)
                   *
                   * @param - offchainTxData Note: not used in the logic
                   * of the rollupProcessor contract, but called here as a convenient to place data on chain
                   */
                  function processRollup(
                      bytes calldata, /* encodedProofData */
                      bytes calldata signatures
                  ) external override(IRollupProcessor) whenNotPaused allowAsyncReenter {
                      // 1. Process a rollup if the escape hatch is open or,
                      // 2. There msg.sender is an authorised rollup provider
                      // 3. Always transfer fees to the passed in feeReceiver
                      (bool isOpen, ) = getEscapeHatchStatus();
                      if (!(rollupProviders[msg.sender] || isOpen)) {
                          revert INVALID_PROVIDER();
                      }
                      (bytes memory proofData, uint256 numTxs, uint256 publicInputsHash) = decodeProof();
                      address rollupBeneficiary = extractRollupBeneficiaryAddress(proofData);
                      processRollupProof(proofData, signatures, numTxs, publicInputsHash, rollupBeneficiary);
                      transferFee(proofData, rollupBeneficiary);
                  }
                  /*----------------------------------------
                    PUBLIC/EXTERNAL MUTATING FUNCTIONS 
                    ----------------------------------------*/
                  /**
                   * @dev Used by bridge contracts to send RollupProcessor ETH during a bridge interaction
                   * @param interactionNonce the Defi interaction nonce that this payment is logged against
                   */
                  function receiveEthFromBridge(uint256 interactionNonce) external payable override(IRollupProcessor) {
                      assembly {
                          // ethPayments[interactionNonce] += msg.value
                          mstore(0x00, interactionNonce)
                          mstore(0x20, ethPayments.slot)
                          let slot := keccak256(0x00, 0x40)
                          // no need to check for overflows as this would require sending more than the blockchain's total supply of ETH!
                          sstore(slot, add(sload(slot), callvalue()))
                      }
                  }
                  /**
                   * @dev Approve a proofHash for spending a users deposited funds, this is one way and must be called by the owner of the funds
                   * @param _proofHash - keccack256 hash of the inner proof public inputs
                   */
                  function approveProof(bytes32 _proofHash) public override(IRollupProcessor) whenNotPaused {
                      // asm implementation to reduce compiled bytecode size
                      assembly {
                          // depositProofApprovals[msg.sender][_proofHash] = true;
                          mstore(0x00, caller())
                          mstore(0x20, depositProofApprovals.slot)
                          mstore(0x20, keccak256(0x00, 0x40))
                          mstore(0x00, _proofHash)
                          sstore(keccak256(0x00, 0x40), 1)
                      }
                  }
                  /**
                   * @dev Deposit funds as part of the first stage of the two stage deposit. Non-permit flow
                   * @param assetId - unique ID of the asset
                   * @param amount - number of tokens being deposited
                   * @param owner - address that can spend the deposited funds
                   * @param proofHash - the 32 byte transaction id that can spend the deposited funds
                   */
                  function depositPendingFunds(
                      uint256 assetId,
                      uint256 amount,
                      address owner,
                      bytes32 proofHash
                  ) external payable override(IRollupProcessor) whenNotPaused noReenter {
                      // Perform sanity checks on user input
                      if (assetId == ethAssetId && msg.value != amount) {
                          revert MSG_VALUE_WRONG_AMOUNT();
                      }
                      if (assetId != ethAssetId && msg.value != 0) {
                          revert DEPOSIT_TOKENS_WRONG_PAYMENT_TYPE();
                      }
                      internalDeposit(assetId, owner, amount, proofHash);
                      if (assetId != ethAssetId) {
                          address assetAddress = getSupportedAsset(assetId);
                          // check user approved contract to transfer funds, so can throw helpful error to user
                          if (IERC20(assetAddress).allowance(msg.sender, address(this)) < amount) {
                              revert INSUFFICIENT_TOKEN_APPROVAL();
                          }
                          TokenTransfers.safeTransferFrom(assetAddress, msg.sender, address(this), amount);
                      }
                  }
                  /**
                   * @dev Deposit funds as part of the first stage of the two stage deposit. Permit flow
                   * @param assetId - unique ID of the asset
                   * @param amount - number of tokens being deposited
                   * @param depositorAddress - address from which funds are being transferred to the contract
                   * @param proofHash - the 32 byte transaction id that can spend the deposited funds
                   * @param deadline - when the permit signature expires
                   * @param v - ECDSA sig param
                   * @param r - ECDSA sig param
                   * @param s - ECDSA sig param
                   */
                  function depositPendingFundsPermit(
                      uint256 assetId,
                      uint256 amount,
                      address depositorAddress,
                      bytes32 proofHash,
                      uint256 deadline,
                      uint8 v,
                      bytes32 r,
                      bytes32 s
                  ) external override(IRollupProcessor) whenNotPaused noReenter {
                      internalDeposit(assetId, depositorAddress, amount, proofHash);
                      address assetAddress = getSupportedAsset(assetId);
                      IERC20Permit(assetAddress).permit(depositorAddress, address(this), amount, deadline, v, r, s);
                      TokenTransfers.safeTransferFrom(assetAddress, depositorAddress, address(this), amount);
                  }
                  /**
                   * @dev Deposit funds as part of the first stage of the two stage deposit. Permit flow
                   * @param assetId - unique ID of the asset
                   * @param amount - number of tokens being deposited
                   * @param depositorAddress - address from which funds are being transferred to the contract
                   * @param proofHash - the 32 byte transaction id that can spend the deposited funds
                   * @param nonce - user's nonce on the erc20 contract, for replay protection
                   * @param deadline - when the permit signature expires
                   * @param v - ECDSA sig param
                   * @param r - ECDSA sig param
                   * @param s - ECDSA sig param
                   */
                  function depositPendingFundsPermitNonStandard(
                      uint256 assetId,
                      uint256 amount,
                      address depositorAddress,
                      bytes32 proofHash,
                      uint256 nonce,
                      uint256 deadline,
                      uint8 v,
                      bytes32 r,
                      bytes32 s
                  ) external override(IRollupProcessor) whenNotPaused noReenter {
                      internalDeposit(assetId, depositorAddress, amount, proofHash);
                      address assetAddress = getSupportedAsset(assetId);
                      IERC20Permit(assetAddress).permit(depositorAddress, address(this), nonce, deadline, true, v, r, s);
                      TokenTransfers.safeTransferFrom(assetAddress, depositorAddress, address(this), amount);
                  }
                  /**
                   * @dev Used to publish data that doesn't need to be on chain. Should eventually be published elsewhere.
                   * This maybe called multiple times to work around maximum tx size limits.
                   * The data will need to be reconstructed by the client.
                   * @param rollupId - the rollup id this data is related to.
                   * @param chunk - the chunk number, from 0 to totalChunks-1.
                   * @param totalChunks - the total number of chunks.
                   * @param - the data.
                   */
                  function offchainData(
                      uint256 rollupId,
                      uint256 chunk,
                      uint256 totalChunks,
                      bytes calldata /* offchainTxData */
                  ) external override(IRollupProcessor) whenNotPaused {
                      emit OffchainData(rollupId, chunk, totalChunks, msg.sender);
                  }
                  /**
                   * @dev Process asyncdefi interactions.
                   *      Callback function for asynchronous bridge interactions.
                   * @param interactionNonce - unique id of the interaection
                   */
                  function processAsyncDefiInteraction(uint256 interactionNonce)
                      external
                      override(IRollupProcessor)
                      whenNotPaused
                      noReenterButAsync
                      returns (bool)
                  {
                      uint256 bridgeId;
                      uint256 totalInputValue;
                      assembly {
                          mstore(0x00, interactionNonce)
                          mstore(0x20, pendingDefiInteractions.slot)
                          let interactionPtr := keccak256(0x00, 0x40)
                          bridgeId := sload(interactionPtr)
                          totalInputValue := sload(add(interactionPtr, 0x01))
                      }
                      if (bridgeId == 0) {
                          revert INVALID_BRIDGE_ID();
                      }
                      BridgeData memory bridgeData = getBridgeData(bridgeId);
                      (
                          AztecTypes.AztecAsset memory inputAssetA,
                          AztecTypes.AztecAsset memory inputAssetB,
                          AztecTypes.AztecAsset memory outputAssetA,
                          AztecTypes.AztecAsset memory outputAssetB
                      ) = getAztecAssetTypes(bridgeData, interactionNonce);
                      // Extract the bridge address from the bridgeId
                      IDefiBridge bridgeContract;
                      assembly {
                          mstore(0x00, supportedBridges.slot)
                          let bridgeSlot := keccak256(0x00, 0x20)
                          bridgeContract := and(bridgeId, 0xffffffff)
                          bridgeContract := sload(add(bridgeSlot, sub(bridgeContract, 0x01)))
                          bridgeContract := and(bridgeContract, ADDRESS_MASK)
                      }
                      if (address(bridgeContract) == address(0)) {
                          revert INVALID_BRIDGE_ADDRESS();
                      }
                      // delete pendingDefiInteractions[interactionNonce]
                      // N.B. only need to delete 1st slot value `bridgeId`. Deleting vars costs gas post-London
                      // setting bridgeId to 0 is enough to cause future calls with this interaction nonce to fail
                      pendingDefiInteractions[interactionNonce].bridgeId = 0;
                      // Copy some variables to front of stack to get around stack too deep errors
                      InteractionInputs memory inputs = InteractionInputs(
                          totalInputValue,
                          interactionNonce,
                          uint64(bridgeData.auxData)
                      );
                      (uint256 outputValueA, uint256 outputValueB, bool interactionCompleted) = bridgeContract.finalise(
                          inputAssetA,
                          inputAssetB,
                          outputAssetA,
                          outputAssetB,
                          inputs.interactionNonce,
                          inputs.auxData
                      );
                      if (!interactionCompleted) {
                          pendingDefiInteractions[inputs.interactionNonce].bridgeId = bridgeId;
                          return false;
                      }
                      if (outputValueB > 0 && outputAssetB.assetType == AztecTypes.AztecAssetType.NOT_USED) {
                          revert NONZERO_OUTPUT_VALUE_ON_NOT_USED_ASSET(outputValueB);
                      }
                      if (outputValueA == 0 && outputValueB == 0) {
                          // issue refund.
                          transferTokensAsync(address(bridgeContract), inputAssetA, inputs.totalInputValue, inputs.interactionNonce);
                      } else {
                          // transfer output tokens to rollup contract
                          transferTokensAsync(address(bridgeContract), outputAssetA, outputValueA, inputs.interactionNonce);
                          transferTokensAsync(address(bridgeContract), outputAssetB, outputValueB, inputs.interactionNonce);
                      }
                      // compute defiInteractionHash and push it onto the asyncDefiInteractionHashes array
                      bool result;
                      assembly {
                          // Load values from `input` (to get around stack too deep)
                          let inputValue := mload(inputs)
                          let nonce := mload(add(inputs, 0x20))
                          result := iszero(and(eq(outputValueA, 0), eq(outputValueB, 0)))
                          // Compute defi interaction hash
                          let mPtr := mload(0x40)
                          mstore(mPtr, bridgeId)
                          mstore(add(mPtr, 0x20), nonce)
                          mstore(add(mPtr, 0x40), inputValue)
                          mstore(add(mPtr, 0x60), outputValueA)
                          mstore(add(mPtr, 0x80), outputValueB)
                          mstore(add(mPtr, 0xa0), result)
                          pop(staticcall(gas(), 0x2, mPtr, 0xc0, 0x00, 0x20))
                          let defiInteractionHash := mod(mload(0x00), CIRCUIT_MODULUS)
                          // Load sync and async array lengths from rollup state
                          let state := sload(rollupState.slot)
                          // asyncArrayLen = rollupState.numAsyncDefiInteractionHashes
                          let asyncArrayLen := and(ARRAY_LENGTH_MASK, shr(ASYNCDEFIINTERACTIONHASHES_BIT_OFFSET, state))
                          // defiArrayLen = rollupState.numDefiInteractionHashes
                          let defiArrayLen := and(ARRAY_LENGTH_MASK, shr(DEFIINTERACTIONHASHES_BIT_OFFSET, state))
                          // check that size of asyncDefiInteractionHashes isn't such that
                          // adding 1 to it will make the next block's defiInteractionHashes length hit 512
                          if gt(add(add(1, asyncArrayLen), defiArrayLen), 512) {
                              // store keccak256("ARRAY_OVERFLOW()")
                              // this code is equivalent to `revert ARRAY_OVERFLOW()`
                              mstore(mPtr, 0x58a4ab0e00000000000000000000000000000000000000000000000000000000)
                              revert(mPtr, 0x04)
                          }
                          // asyncDefiInteractionHashes[asyncArrayLen] = defiInteractionHash
                          mstore(0x00, asyncArrayLen)
                          mstore(0x20, asyncDefiInteractionHashes.slot)
                          sstore(keccak256(0x00, 0x40), defiInteractionHash)
                          // increase asyncDefiInteractionHashes.length by 1
                          let oldState := and(not(shl(ASYNCDEFIINTERACTIONHASHES_BIT_OFFSET, ARRAY_LENGTH_MASK)), state)
                          let newState := or(oldState, shl(ASYNCDEFIINTERACTIONHASHES_BIT_OFFSET, add(asyncArrayLen, 0x01)))
                          sstore(rollupState.slot, newState)
                      }
                      emit DefiBridgeProcessed(
                          bridgeId,
                          inputs.interactionNonce,
                          inputs.totalInputValue,
                          outputValueA,
                          outputValueB,
                          result,
                          ''
                      );
                      return true;
                  }
                  /*----------------------------------------
                    INTERNAL/PRIVATE MUTATING FUNCTIONS 
                    ----------------------------------------*/
                  /**
                   * @dev Increase the userPendingDeposits mapping
                   * assembly impl to reduce compiled bytecode size and improve gas costs
                   */
                  function increasePendingDepositBalance(
                      uint256 assetId,
                      address depositorAddress,
                      uint256 amount
                  ) internal validateAssetIdIsNotVirtual(assetId) {
                      assembly {
                          // userPendingDeposit = userPendingDeposits[assetId][depositorAddress]
                          mstore(0x00, assetId)
                          mstore(0x20, userPendingDeposits.slot)
                          mstore(0x20, keccak256(0x00, 0x40))
                          mstore(0x00, depositorAddress)
                          let userPendingDepositSlot := keccak256(0x00, 0x40)
                          let userPendingDeposit := sload(userPendingDepositSlot)
                          let newDeposit := add(userPendingDeposit, amount)
                          if lt(newDeposit, userPendingDeposit) {
                              revert(0, 0)
                          }
                          sstore(userPendingDepositSlot, newDeposit)
                      }
                  }
                  /**
                   * @dev Decrease the userPendingDeposits mapping
                   * assembly impl to reduce compiled bytecode size. Also removes a sload op and saves a fair chunk of gas per deposit tx
                   */
                  function decreasePendingDepositBalance(
                      uint256 assetId,
                      address transferFromAddress,
                      uint256 amount
                  ) internal validateAssetIdIsNotVirtual(assetId) {
                      bool insufficientDeposit = false;
                      assembly {
                          // userPendingDeposit = userPendingDeposits[assetId][transferFromAddress]
                          mstore(0x00, assetId)
                          mstore(0x20, userPendingDeposits.slot)
                          mstore(0x20, keccak256(0x00, 0x40))
                          mstore(0x00, transferFromAddress)
                          let userPendingDepositSlot := keccak256(0x00, 0x40)
                          let userPendingDeposit := sload(userPendingDepositSlot)
                          insufficientDeposit := lt(userPendingDeposit, amount)
                          let newDeposit := sub(userPendingDeposit, amount)
                          sstore(userPendingDepositSlot, newDeposit)
                      }
                      if (insufficientDeposit) {
                          revert INSUFFICIENT_DEPOSIT();
                      }
                  }
                  /**
                   * @dev Deposit funds as part of the first stage of the two stage deposit. Non-permit flow
                   * @param assetId - unique ID of the asset
                   * @param depositorAddress - address from which funds are being transferred to the contract
                   * @param amount - amount being deposited
                   * @param proofHash - the 32 byte transaction id that can spend the deposited funds
                   */
                  function internalDeposit(
                      uint256 assetId,
                      address depositorAddress,
                      uint256 amount,
                      bytes32 proofHash
                  ) internal {
                      increasePendingDepositBalance(assetId, depositorAddress, amount);
                      if (proofHash != 0) {
                          approveProof(proofHash);
                      }
                      emit Deposit(assetId, depositorAddress, amount);
                  }
                  /**
                   * @dev processes a rollup proof. Will verify the proof's correctness and use the provided
                   * proof data to update the rollup state + merkle roots, as well as validate/enact any deposits/withdrawals in the block.
                   * Finally any defi interactions specified in the block will be executed
                   * @param proofData the block's proof data (contains PLONK proof and public input data linked to the proof)
                   * @param signatures ECDSA signatures from users authorizing deposit transactions
                   * @param numTxs the number of transactions in the block
                   * @param publicInputsHash the SHA256 hash of the proof's public inputs
                   */
                  function processRollupProof(
                      bytes memory proofData,
                      bytes memory signatures,
                      uint256 numTxs,
                      uint256 publicInputsHash,
                      address rollupBeneficiary
                  ) internal {
                      uint256 rollupId = verifyProofAndUpdateState(proofData, publicInputsHash);
                      processDepositsAndWithdrawals(proofData, numTxs, signatures);
                      bytes32[] memory nextDefiHashes = processDefiBridges(proofData, rollupBeneficiary);
                      emit RollupProcessed(rollupId, nextDefiHashes, msg.sender);
                  }
                  /**
                   * @dev Verify the zk proof and update the contract state variables with those provided by the rollup.
                   * @param proofData - cryptographic zk proof data. Passed to the verifier for verification.
                   */
                  function verifyProofAndUpdateState(bytes memory proofData, uint256 publicInputsHash)
                      internal
                      returns (uint256 rollupId)
                  {
                      // Verify the rollup proof.
                      //
                      // We manually call the verifier contract via assembly to save on gas costs and to reduce contract bytecode size
                      assembly {
                          /**
                           * Validate correctness of zk proof.
                           *
                           * 1st Item is to format verifier calldata.
                           **/
                          // Our first input param `encodedProofData` contains the concatenation of
                          // encoded 'broadcasted inputs' and the actual zk proof data.
                          // (The `boadcasted inputs` is converted into a 32-byte SHA256 hash, which is
                          // validated to equal the first public inputs of the zk proof. This is done in `Decoder.sol`).
                          // We need to identify the location in calldata that points to the start of the zk proof data.
                          // Step 1: compute size of zk proof data and its calldata pointer.
                          /**
                              Data layout for `bytes encodedProofData`...
                              0x00 : 0x20 : length of array
                              0x20 : 0x20 + header : root rollup header data
                              0x20 + header : 0x24 + header : X, the length of encoded inner join-split public inputs
                              0x24 + header : 0x24 + header + X : (inner join-split public inputs)
                              0x24 + header + X : 0x28 + header + X : Y, the length of the zk proof data
                              0x28 + header + X : 0x28 + haeder + X + Y : zk proof data
                              We need to recover the numeric value of `0x28 + header + X` and `Y`
                           **/
                          // Begin by getting length of encoded inner join-split public inputs.
                          // `calldataload(0x04)` points to start of bytes array. Add 0x24 to skip over length param and function signature.
                          // The calldata param 4 bytes *after* the header is the length of the pub inputs array. However it is a packed 4-byte param.
                          // To extract it, we subtract 24 bytes from the calldata pointer and mask off all but the 4 least significant bytes.
                          let encodedInnerDataSize := and(
                              calldataload(add(add(calldataload(0x04), 0x24), sub(ROLLUP_HEADER_LENGTH, 0x18))),
                              0xffffffff
                          )
                          // add 8 bytes to skip over the two packed params that follow the rollup header data
                          // broadcastedDataSize = inner join-split pubinput size + header size
                          let broadcastedDataSize := add(add(ROLLUP_HEADER_LENGTH, 8), encodedInnerDataSize)
                          // Compute zk proof data size by subtracting broadcastedDataSize from overall length of bytes encodedProofsData
                          let zkProofDataSize := sub(calldataload(add(calldataload(0x04), 0x04)), broadcastedDataSize)
                          // Compute calldata pointer to start of zk proof data by adding calldata offset to broadcastedDataSize
                          // (+0x24 skips over function signature and length param of bytes encodedProofData)
                          let zkProofDataPtr := add(broadcastedDataSize, add(calldataload(0x04), 0x24))
                          // Step 2: Format calldata for verifier contract call.
                          // Get free memory pointer - we copy calldata into memory starting here
                          let dataPtr := mload(0x40)
                          // We call the function `verify(bytes,uint256)`
                          // The function signature is 0xac318c5d
                          // Calldata map is:
                          // 0x00 - 0x04 : 0xac318c5d
                          // 0x04 - 0x24 : 0x40 (number of bytes between 0x04 and the start of the `proofData` array at 0x44)
                          // 0x24 - 0x44 : publicInputsHash
                          // 0x44 - .... : proofData
                          mstore8(dataPtr, 0xac)
                          mstore8(add(dataPtr, 0x01), 0x31)
                          mstore8(add(dataPtr, 0x02), 0x8c)
                          mstore8(add(dataPtr, 0x03), 0x5d)
                          mstore(add(dataPtr, 0x04), 0x40)
                          mstore(add(dataPtr, 0x24), publicInputsHash)
                          mstore(add(dataPtr, 0x44), zkProofDataSize) // length of zkProofData bytes array
                          calldatacopy(add(dataPtr, 0x64), zkProofDataPtr, zkProofDataSize) // copy the zk proof data into memory
                          // Step 3: Call our verifier contract. If does not return any values, but will throw an error if the proof is not valid
                          // i.e. verified == false if proof is not valid
                          let verifierAddress := and(sload(rollupState.slot), ADDRESS_MASK)
                          let proof_verified := staticcall(gas(), verifierAddress, dataPtr, add(zkProofDataSize, 0x64), 0x00, 0x00)
                          // Check the proof is valid!
                          if iszero(proof_verified) {
                              returndatacopy(0, 0, returndatasize())
                              revert(0, returndatasize())
                          }
                      }
                      // Validate and update state hash
                      rollupId = validateAndUpdateMerkleRoots(proofData);
                  }
                  /**
                   * @dev Extract public inputs and validate they are inline with current contract rollupState.
                   * @param proofData - Rollup proof data.
                   */
                  function validateAndUpdateMerkleRoots(bytes memory proofData) internal returns (uint256) {
                      (
                          uint256 rollupId,
                          bytes32 oldStateHash,
                          bytes32 newStateHash,
                          uint32 numDataLeaves,
                          uint32 dataStartIndex
                      ) = computeRootHashes(proofData);
                      if (oldStateHash != rollupStateHash) {
                          revert INCORRECT_STATE_HASH(oldStateHash, newStateHash);
                      }
                      unchecked {
                          uint32 storedDataSize = rollupState.datasize;
                          // Ensure we are inserting at the next subtree boundary.
                          if (storedDataSize % numDataLeaves == 0) {
                              if (dataStartIndex != storedDataSize) {
                                  revert INCORRECT_DATA_START_INDEX(dataStartIndex, storedDataSize);
                              }
                          } else {
                              uint256 expected = storedDataSize + numDataLeaves - (storedDataSize % numDataLeaves);
                              if (dataStartIndex != expected) {
                                  revert INCORRECT_DATA_START_INDEX(dataStartIndex, expected);
                              }
                          }
                          rollupStateHash = newStateHash;
                          rollupState.datasize = dataStartIndex + numDataLeaves;
                      }
                      return rollupId;
                  }
                  /**
                   * @dev Process deposits and withdrawls.
                   * @param proofData - the proof data
                   * @param numTxs - number of transactions rolled up in the proof
                   * @param signatures - bytes array of secp256k1 ECDSA signatures, authorising a transfer of tokens
                   */
                  function processDepositsAndWithdrawals(
                      bytes memory proofData,
                      uint256 numTxs,
                      bytes memory signatures
                  ) internal {
                      uint256 sigIndex = 0x00;
                      uint256 proofDataPtr;
                      uint256 end;
                      assembly {
                          // add 0x20 to skip over 1st member of the bytes type (the length field).
                          // Also skip over the rollup header.
                          proofDataPtr := add(ROLLUP_HEADER_LENGTH, add(proofData, 0x20))
                          // compute the position of proofDataPtr after we iterate through every transaction
                          end := add(proofDataPtr, mul(numTxs, TX_PUBLIC_INPUT_LENGTH))
                      }
                      // This is a bit of a hot loop, we iterate over every tx to determine whether to process deposits or withdrawals.
                      while (proofDataPtr < end) {
                          // extract the minimum information we need to determine whether to skip this iteration
                          uint256 publicValue;
                          assembly {
                              publicValue := mload(add(proofDataPtr, 0xa0))
                          }
                          if (publicValue > 0) {
                              uint256 proofId;
                              uint256 assetId;
                              address publicOwner;
                              assembly {
                                  proofId := mload(proofDataPtr)
                                  assetId := mload(add(proofDataPtr, 0xe0))
                                  publicOwner := mload(add(proofDataPtr, 0xc0))
                              }
                              if (proofId == 1) {
                                  // validate user has approved deposit
                                  bytes32 digest;
                                  assembly {
                                      // compute the tx id to check if user has approved tx
                                      digest := keccak256(proofDataPtr, TX_PUBLIC_INPUT_LENGTH)
                                  }
                                  // check if there is an existing entry in depositProofApprovals
                                  // if there is, no further work required.
                                  // we don't need to clear `depositProofApprovals[publicOwner][digest]` because proofs cannot be re-used.
                                  // A single proof describes the creation of 2 output notes and the addition of 2 input note nullifiers
                                  // (both of these nullifiers can be categorised as "fake". They may not map to existing notes but are still inserted in the nullifier set)
                                  // Replaying the proof will fail to satisfy the rollup circuit's non-membership check on the input nullifiers.
                                  // We avoid resetting `depositProofApprovals` because that would cost additional gas post-London hard fork.
                                  if (!depositProofApprovals[publicOwner][digest]) {
                                      // extract and validate signature
                                      // we can create a bytes memory container for the signature without allocating new memory,
                                      // by overwriting the previous 32 bytes in the `signatures` array with the 'length' of our synthetic byte array (92)
                                      // we store the memory we overwrite in `temp`, so that we can restore it
                                      bytes memory signature;
                                      uint256 temp;
                                      assembly {
                                          // set `signature` to point to 32 bytes less than the desired `r, s, v` values in `signatures`
                                          signature := add(signatures, sigIndex)
                                          // cache the memory we're about to overwrite
                                          temp := mload(signature)
                                          // write in a 92-byte 'length' parameter into the `signature` bytes array
                                          mstore(signature, 0x60)
                                      }
                                      bytes32 hashedMessage = RollupProcessorLibrary.getSignedMessageForTxId(digest);
                                      RollupProcessorLibrary.validateSheildSignatureUnpacked(hashedMessage, signature, publicOwner);
                                      // restore the memory we overwrote
                                      assembly {
                                          mstore(signature, temp)
                                          sigIndex := add(sigIndex, 0x60)
                                      }
                                  }
                                  decreasePendingDepositBalance(assetId, publicOwner, publicValue);
                              }
                              if (proofId == 2) {
                                  withdraw(publicValue, publicOwner, assetId);
                              }
                          }
                          // don't check for overflow, would take > 2^200 iterations of this loop for that to happen!
                          unchecked {
                              proofDataPtr += TX_PUBLIC_INPUT_LENGTH;
                          }
                      }
                  }
                  /**
                   * @dev Token transfer method used by processAsyncDefiInteraction
                   * Calls `transferFrom` on the target erc20 token, if asset is of type ERC
                   * If asset is ETH, we validate a payment has been made against the provided interaction nonce
                   * @param bridgeContract address of bridge contract we're taking tokens from
                   * @param asset the AztecAsset being transferred
                   * @param outputValue the expected value transferred
                   * @param interactionNonce the defi interaction nonce of the interaction
                   */
                  function transferTokensAsync(
                      address bridgeContract,
                      AztecTypes.AztecAsset memory asset,
                      uint256 outputValue,
                      uint256 interactionNonce
                  ) internal {
                      if (outputValue == 0) {
                          return;
                      }
                      if (asset.assetType == AztecTypes.AztecAssetType.ETH) {
                          if (outputValue > ethPayments[interactionNonce]) {
                              revert INSUFFICIENT_ETH_PAYMENT();
                          }
                          ethPayments[interactionNonce] = 0;
                      } else if (asset.assetType == AztecTypes.AztecAssetType.ERC20) {
                          address tokenAddress = asset.erc20Address;
                          TokenTransfers.safeTransferFrom(tokenAddress, bridgeContract, address(this), outputValue);
                      }
                  }
                  /**
                   * @dev Transfer a fee to the feeReceiver
                   * @param proofData proof of knowledge of a rollup block update
                   * @param feeReceiver fee beneficiary as described kby the rollup provider
                   */
                  function transferFee(bytes memory proofData, address feeReceiver) internal {
                      for (uint256 i = 0; i < NUMBER_OF_ASSETS; ) {
                          uint256 txFee = extractTotalTxFee(proofData, i);
                          if (txFee > 0) {
                              uint256 assetId = extractAssetId(proofData, i);
                              if (assetId == ethAssetId) {
                                  // We explicitly do not throw if this call fails, as this opens up the possiblity of
                                  // griefing attacks, as engineering a failed fee will invalidate an entire rollup block
                                  assembly {
                                      pop(call(50000, feeReceiver, txFee, 0, 0, 0, 0))
                                  }
                              } else {
                                  address assetAddress = getSupportedAsset(assetId);
                                  TokenTransfers.transferToDoNotBubbleErrors(
                                      assetAddress,
                                      feeReceiver,
                                      txFee,
                                      assetGasLimits[assetId]
                                  );
                              }
                          }
                          unchecked {
                              ++i;
                          }
                      }
                  }
                  /**
                   * @dev Internal utility function to withdraw funds from the contract to a receiver address
                   * @param withdrawValue - value being withdrawn from the contract
                   * @param receiverAddress - address receiving public ERC20 tokens
                   * @param assetId - ID of the asset for which a withdrawl is being performed
                   */
                  function withdraw(
                      uint256 withdrawValue,
                      address receiverAddress,
                      uint256 assetId
                  ) internal validateAssetIdIsNotVirtual(assetId) {
                      if (receiverAddress == address(0)) {
                          revert WITHDRAW_TO_ZERO_ADDRESS();
                      }
                      if (assetId == 0) {
                          // We explicitly do not throw if this call fails, as this opens up the possiblity of
                          // griefing attacks, as engineering a failed withdrawal will invalidate an entire rollup block
                          assembly {
                              pop(call(30000, receiverAddress, withdrawValue, 0, 0, 0, 0))
                          }
                          // payable(receiverAddress).call{gas: 30000, value: withdrawValue}('');
                      } else {
                          // We explicitly do not throw if this call fails, as this opens up the possiblity of
                          // griefing attacks, as engineering a failed withdrawal will invalidate an entire rollup block
                          // the user should ensure their withdrawal will succeed or they will loose funds
                          address assetAddress = getSupportedAsset(assetId);
                          TokenTransfers.transferToDoNotBubbleErrors(
                              assetAddress,
                              receiverAddress,
                              withdrawValue,
                              assetGasLimits[assetId]
                          );
                      }
                  }
                  /*----------------------------------------
                    PUBLIC/EXTERNAL NON-MUTATING FUNCTIONS 
                    ----------------------------------------*/
                  /**
                   * @dev Get the version number of the implementation
                   * @return version - The version number of the implementation
                   */
                  function getImplementationVersion() public view virtual returns (uint8 version) {
                      return 1;
                  }
                  /**
                   * @dev Get true if the contract is paused, false otherwise
                   * @return isPaused - True if paused, false otherwise
                   */
                  function paused() external view override(IRollupProcessor) returns (bool isPaused) {
                      return rollupState.paused;
                  }
                  /**
                   * @dev get the number of filled entries in the data tree.
                   * This is equivalent to the number of notes created in the Aztec L2
                   * @return dataSize
                   */
                  function getDataSize() public view override(IRollupProcessor) returns (uint256 dataSize) {
                      assembly {
                          dataSize := and(DATASIZE_MASK, shr(DATASIZE_BIT_OFFSET, sload(rollupState.slot)))
                      }
                  }
                  /**
                   * @dev Get number of pending defi interactions that have resolved but have not yet added into the Defi Tree
                   * This value can never exceed 512. This is to prevent griefing attacks; `processRollup` iterates through `asyncDefiInteractionHashes` and
                   * copies their values into `defiInteractionHashes`. Loop is bounded to < 512 so that tx does not exceed block gas limit
                   * @return res the number of pending interactions
                   */
                  function getPendingDefiInteractionHashesLength() public view override(IRollupProcessor) returns (uint256 res) {
                      assembly {
                          let state := sload(rollupState.slot)
                          let defiInteractionHashesLength := and(ARRAY_LENGTH_MASK, shr(DEFIINTERACTIONHASHES_BIT_OFFSET, state))
                          let asyncDefiInteractionhashesLength := and(
                              ARRAY_LENGTH_MASK,
                              shr(ASYNCDEFIINTERACTIONHASHES_BIT_OFFSET, state)
                          )
                          res := add(defiInteractionHashesLength, asyncDefiInteractionhashesLength)
                      }
                  }
                  /**
                   * @dev get the address of the PLONK verification smart contract
                   * @return verifierAddress - address of the verification smart contract
                   */
                  function verifier() public view override(IRollupProcessor) returns (address verifierAddress) {
                      // asm implementation to reduce compiled bytecode size
                      assembly {
                          verifierAddress := and(sload(rollupState.slot), ADDRESS_MASK)
                      }
                  }
                  /**
                   * @dev Get the number of supported bridges
                   * @return res The number of supported bridges
                   */
                  function getSupportedBridgesLength() external view override(IRollupProcessor) returns (uint256 res) {
                      res = supportedBridges.length;
                  }
                  /**
                   * @dev Get the bridge contract address for a given bridgeAddressId
                   * @param bridgeAddressId - identifier used to denote a particular bridge
                   */
                  function getSupportedBridge(uint256 bridgeAddressId) public view override(IRollupProcessor) returns (address) {
                      return supportedBridges[bridgeAddressId - 1];
                  }
                  /**
                   * @dev Get the number of supported assets
                   * @return res The number of supported assets
                   */
                  function getSupportedAssetsLength() external view override(IRollupProcessor) returns (uint256 res) {
                      res = supportedAssets.length;
                  }
                  /**
                   * @dev Get the ERC20 token address of a supported asset, for a given assetId
                   * @param assetId - identifier used to denote a particular asset
                   */
                  function getSupportedAsset(uint256 assetId) public view override(IRollupProcessor) returns (address) {
                      // If the asset ID is >= 2^29, the asset represents a 'virtual' asset that has no ERC20 analogue
                      // Virtual assets are used by defi bridges to track non-token data. E.g. to represent a loan.
                      // If an assetId is *not* a virtual asset, its ERC20 address can be recovered from `supportedAssets[assetId]`
                      if (assetId > 0x1fffffff) {
                          revert INVALID_ASSET_ID();
                      }
                      // If assetId == ethAssetId (i.e. 0), this represents native ETH.
                      // ERC20 token asset id values start at 1
                      if (assetId == ethAssetId) {
                          return address(0x0);
                      }
                      address result = supportedAssets[assetId - 1];
                      if (result == address(0)) {
                          revert INVALID_ASSET_ADDRESS();
                      }
                      return result;
                  }
                  /**
                   * @dev Get the gas limit for the bridge specified by bridgeAddressId
                   * @param bridgeAddressId - identifier used to denote a particular bridge
                   */
                  function getBridgeGasLimit(uint256 bridgeAddressId) public view override(IRollupProcessor) returns (uint256) {
                      return bridgeGasLimits[bridgeAddressId];
                  }
                  /**
                   * @dev Get the status of the escape hatch, specifically retrieve whether the
                   * hatch is open and also the number of blocks until the hatch will switch from
                   * open to closed or vice versa
                   */
                  function getEscapeHatchStatus() public view override(IRollupProcessor) returns (bool, uint256) {
                      uint256 blockNum = block.number;
                      bool isOpen = blockNum % escapeBlockUpperBound >= escapeBlockLowerBound;
                      uint256 blocksRemaining = 0;
                      if (isOpen) {
                          // num blocks escape hatch will remain open for
                          blocksRemaining = escapeBlockUpperBound - (blockNum % escapeBlockUpperBound);
                      } else {
                          // num blocks until escape hatch will be opened
                          blocksRemaining = escapeBlockLowerBound - (blockNum % escapeBlockUpperBound);
                      }
                      return (isOpen, blocksRemaining);
                  }
                  /**
                   * @dev Get number of defi interaction hashes
                   * A defi interaction hash represents a synchronous defi interaction that has resolved, but whose interaction result data
                   * has not yet been added into the Aztec Defi Merkle tree. This step is needed in order to convert L2 Defi claim notes into L2 value notes
                   * @return res the number of pending defi interaction hashes
                   */
                  function getDefiInteractionHashesLength() public view override(IRollupProcessor) returns (uint256 res) {
                      assembly {
                          res := and(ARRAY_LENGTH_MASK, shr(DEFIINTERACTIONHASHES_BIT_OFFSET, sload(rollupState.slot)))
                      }
                  }
                  /**
                   * @dev Get all pending defi interaction hashes
                   * A defi interaction hash represents a synchronous defi interaction that has resolved, but whose interaction result data
                   * has not yet been added into the Aztec Defi Merkle tree. This step is needed in order to convert L2 Defi claim notes into L2 value notes
                   * @return res the set of all pending defi interaction hashes
                   */
                  function getDefiInteractionHashes() external view override(IRollupProcessor) returns (bytes32[] memory res) {
                      uint256 len = getDefiInteractionHashesLength();
                      assembly {
                          // Allocate memory for return value
                          res := mload(0x40)
                          mstore(res, len)
                          // Update 0x40 (the free memory pointer)
                          mstore(0x40, add(res, add(0x20, mul(len, 0x20))))
                          // Prepare slot computation
                          mstore(0x20, defiInteractionHashes.slot)
                          let ptr := add(res, 0x20)
                          for {
                              let i := 0
                          } lt(i, len) {
                              i := add(i, 0x01)
                          } {
                              // Fetch defiInteractionHashes[i] and add it to the return value
                              mstore(0x00, i)
                              mstore(ptr, sload(keccak256(0x00, 0x40)))
                              ptr := add(ptr, 0x20)
                          }
                      }
                      return res;
                  }
                  /**
                   * @dev Get number of asynchronous defi interaction hashes
                   * An async defi interaction hash represents an asynchronous defi interaction that has resolved, but whose interaction result data
                   * has not yet been added into the Aztec Defi Merkle tree. This step is needed in order to convert L2 Defi claim notes into L2 value notes
                   * @return res the number of pending async defi interaction hashes
                   */
                  function getAsyncDefiInteractionHashesLength() public view override(IRollupProcessor) returns (uint256 res) {
                      assembly {
                          res := and(ARRAY_LENGTH_MASK, shr(ASYNCDEFIINTERACTIONHASHES_BIT_OFFSET, sload(rollupState.slot)))
                      }
                  }
                  /**
                   * @dev Get all pending async defi interaction hashes
                   * An async defi interaction hash represents an asynchronous defi interaction that has resolved, but whose interaction result data
                   * has not yet been added into the Aztec Defi Merkle tree. This step is needed in order to convert L2 Defi claim notes into L2 value notes
                   * @return res the set of all pending async defi interaction hashes
                   */
                  function getAsyncDefiInteractionHashes() external view override(IRollupProcessor) returns (bytes32[] memory res) {
                      uint256 len = getAsyncDefiInteractionHashesLength();
                      assembly {
                          // Allocate memory for return value
                          res := mload(0x40)
                          mstore(res, len)
                          // Update 0x40 (the free memory pointer)
                          mstore(0x40, add(res, add(0x20, mul(len, 0x20))))
                          // Prepare slot computation
                          mstore(0x20, asyncDefiInteractionHashes.slot)
                          let ptr := add(res, 0x20)
                          for {
                              let i := 0
                          } lt(i, len) {
                              i := add(i, 0x01)
                          } {
                              // Fetch asyncDefiInteractionHashes[i] and add it to the return value
                              mstore(0x00, i)
                              mstore(ptr, sload(keccak256(0x00, 0x40)))
                              ptr := add(ptr, 0x20)
                          }
                      }
                      return res;
                  }
                  /**
                   * @dev Get the addresses of all supported bridge contracts
                   */
                  function getSupportedBridges()
                      external
                      view
                      override(IRollupProcessor)
                      returns (address[] memory, uint256[] memory)
                  {
                      uint256 supportedBridgesLength = supportedBridges.length;
                      uint256[] memory gasLimits = new uint256[](supportedBridgesLength);
                      for (uint256 i = 0; i < supportedBridgesLength; ) {
                          gasLimits[i] = bridgeGasLimits[i + 1];
                          unchecked {
                              ++i;
                          }
                      }
                      return (supportedBridges, gasLimits);
                  }
                  /**
                   * @dev Get the addresses of all supported ERC20 tokens
                   */
                  function getSupportedAssets()
                      external
                      view
                      override(IRollupProcessor)
                      returns (address[] memory, uint256[] memory)
                  {
                      uint256 supportedAssetsLength = supportedAssets.length;
                      uint256[] memory gasLimits = new uint256[](supportedAssetsLength);
                      for (uint256 i = 0; i < supportedAssetsLength; ) {
                          gasLimits[i] = assetGasLimits[i + 1];
                          unchecked {
                              ++i;
                          }
                      }
                      return (supportedAssets, gasLimits);
                  }
                  /*----------------------------------------
                    INTERNAL/PRIVATE NON-MUTATING FUNCTIONS
                    ----------------------------------------*/
                  /**
                   * @dev helper function to sanitise a given bridge gas limit value to be within pre-defined limits
                   * @param bridgeGasLimit - the gas limit that needs to be sanitised
                   */
                  function sanitiseBridgeGasLimit(uint256 bridgeGasLimit) internal pure returns (uint256) {
                      if (bridgeGasLimit < MIN_BRIDGE_GAS_LIMIT) {
                          return MIN_BRIDGE_GAS_LIMIT;
                      }
                      if (bridgeGasLimit > MAX_BRIDGE_GAS_LIMIT) {
                          return MAX_BRIDGE_GAS_LIMIT;
                      }
                      return bridgeGasLimit;
                  }
                  /**
                   * @dev helper function to sanitise a given asset gas limit value to be within pre-defined limits
                   * @param assetGasLimit - the gas limit that needs to be sanitised
                   */
                  function sanitiseAssetGasLimit(uint256 assetGasLimit) internal pure returns (uint256) {
                      if (assetGasLimit < MIN_ERC20_GAS_LIMIT) {
                          return MIN_ERC20_GAS_LIMIT;
                      }
                      if (assetGasLimit > MAX_ERC20_GAS_LIMIT) {
                          return MAX_ERC20_GAS_LIMIT;
                      }
                      return assetGasLimit;
                  }
                  /**
                   * @dev Unpack the bridgeId into a BridgeData struct
                   * @param bridgeId - Bit-array that encodes data that describes a DeFi bridge.
                   *
                   * Structure of the bit array is as follows (starting at least significant bit):
                   * | bit range | parameter       | description |
                   * | 0 - 32    | bridgeAddressId | The address ID. Bridge address = `supportedBridges[bridgeAddressId]` |
                   * | 32 - 62   | inputAssetIdA   | First input asset ID. |
                   * | 62 - 92   | inputAssetIdB   | Second input asset ID. Must be 0 if bridge does not have a 2nd input asset. |
                   * | 92 - 122  | outputAssetIdA  | First output asset ID. |
                   * | 122 - 152 | outputAssetIdB  | Second output asset ID. Must be 0 if bridge does not have a 2nd output asset. |
                   * | 152 - 184 | bitConfig       | Bit-array that contains boolean bridge settings. |
                   * | 184 - 248 | auxData         | 64 bits of custom data to be passed to the bridge contract. Structure is defined/checked by the bridge contract. |
                   *
                   * Structure of the `bitConfig` parameter is as follows
                   * | bit | parameter               | description |
                   * | 0   | secondInputInUse        | Does the bridge have a second input asset? |
                   * | 1   | secondOutputInUse       | Does the bridge have a second output asset? |
                   *
                   * Brief note on virtual assets: Virtual assets are assets that don't have an ERC20 token analogue and exist solely as notes within the Aztec network.
                   * They can be created/spent as a result of DeFi interactions. They are used to enable defi bridges to track internally-defined data without having to
                   * mint a new token on-chain.
                   * An example use of a virtual asset would a virtual loan asset that tracks an outstanding debt that must be repaid to recover collateral deposited into the bridge.
                   *
                   * @return bridgeData - struct that contains bridgeId data in a human-readable form.
                   */
                  function getBridgeData(uint256 bridgeId) internal view returns (BridgeData memory bridgeData) {
                      assembly {
                          mstore(bridgeData, and(bridgeId, MASK_THIRTY_TWO_BITS)) // bridgeAddressId
                          mstore(add(bridgeData, 0x40), and(shr(INPUT_ASSET_ID_A_SHIFT, bridgeId), MASK_THIRTY_BITS)) // inputAssetIdA
                          mstore(add(bridgeData, 0x60), and(shr(INPUT_ASSET_ID_B_SHIFT, bridgeId), MASK_THIRTY_BITS)) // inputAssetIdB
                          mstore(add(bridgeData, 0x80), and(shr(OUTPUT_ASSET_ID_A_SHIFT, bridgeId), MASK_THIRTY_BITS)) // outputAssetIdA
                          mstore(add(bridgeData, 0xa0), and(shr(OUTPUT_ASSET_ID_B_SHIFT, bridgeId), MASK_THIRTY_BITS)) // outputAssetIdB
                          mstore(add(bridgeData, 0xc0), and(shr(AUX_DATA_SHIFT, bridgeId), MASK_SIXTY_FOUR_BITS)) // auxData
                          mstore(
                              add(bridgeData, 0xe0),
                              and(shr(add(INPUT_ASSET_ID_A_SHIFT, VIRTUAL_ASSET_ID_FLAG_SHIFT), bridgeId), 1)
                          ) // firstInputVirtual (30th bit of inputAssetIdA) == 1
                          mstore(
                              add(bridgeData, 0x100),
                              and(shr(add(INPUT_ASSET_ID_B_SHIFT, VIRTUAL_ASSET_ID_FLAG_SHIFT), bridgeId), 1)
                          ) // secondInputVirtual (30th bit of inputAssetIdB) == 1
                          mstore(
                              add(bridgeData, 0x120),
                              and(shr(add(OUTPUT_ASSET_ID_A_SHIFT, VIRTUAL_ASSET_ID_FLAG_SHIFT), bridgeId), 1)
                          ) // firstOutputVirtual (30th bit of outputAssetIdA) == 1
                          mstore(
                              add(bridgeData, 0x140),
                              and(shr(add(OUTPUT_ASSET_ID_B_SHIFT, VIRTUAL_ASSET_ID_FLAG_SHIFT), bridgeId), 1)
                          ) // secondOutputVirtual (30th bit of outputAssetIdB) == 1
                          let bitConfig := and(shr(BITCONFIG_SHIFT, bridgeId), MASK_THIRTY_TWO_BITS)
                          // bitConfig = bit mask that contains bridge ID settings
                          // bit 0 = second input asset in use?
                          // bit 1 = second output asset in use?
                          mstore(add(bridgeData, 0x160), eq(and(bitConfig, 1), 1)) // secondInputInUse (bitConfig & 1) == 1
                          mstore(add(bridgeData, 0x180), eq(and(shr(1, bitConfig), 1), 1)) // secondOutputInUse ((bitConfig >> 1) & 1) == 1
                      }
                      bridgeData.bridgeAddress = supportedBridges[bridgeData.bridgeAddressId - 1];
                      bridgeData.bridgeGasLimit = getBridgeGasLimit(bridgeData.bridgeAddressId);
                      // potential conflicting states that are explicitly ruled out by circuit constraints:
                      if (!bridgeData.secondInputInUse && bridgeData.inputAssetIdB > 0) {
                          revert BRIDGE_ID_IS_INCONSISTENT();
                      }
                      if (!bridgeData.secondOutputInUse && bridgeData.outputAssetIdB > 0) {
                          revert BRIDGE_ID_IS_INCONSISTENT();
                      }
                      if (bridgeData.secondInputInUse && (bridgeData.inputAssetIdA == bridgeData.inputAssetIdB)) {
                          revert BRIDGE_WITH_IDENTICAL_INPUT_ASSETS(bridgeData.inputAssetIdA);
                      }
                      // Outputs can both be virtual. In that case, their asset ids will both be 2 ** 29.
                      bool secondOutputReal = bridgeData.secondOutputInUse && !bridgeData.secondOutputVirtual;
                      if (secondOutputReal && bridgeData.outputAssetIdA == bridgeData.outputAssetIdB) {
                          revert BRIDGE_WITH_IDENTICAL_OUTPUT_ASSETS(bridgeData.outputAssetIdA);
                      }
                  }
                  /**
                   * @dev Get the four input/output assets associated with a DeFi bridge
                   * @param bridgeData - Information about the DeFi bridge
                   * @param defiInteractionNonce - The defi interaction nonce
                   *
                   * @return inputAssetA inputAssetB outputAssetA outputAssetB : input and output assets represented as AztecAsset structs
                   */
                  function getAztecAssetTypes(BridgeData memory bridgeData, uint256 defiInteractionNonce)
                      internal
                      view
                      returns (
                          AztecTypes.AztecAsset memory inputAssetA,
                          AztecTypes.AztecAsset memory inputAssetB,
                          AztecTypes.AztecAsset memory outputAssetA,
                          AztecTypes.AztecAsset memory outputAssetB
                      )
                  {
                      if (bridgeData.firstInputVirtual) {
                          // asset id will be defi interaction nonce that created note
                          inputAssetA.id = bridgeData.inputAssetIdA - VIRTUAL_ASSET_ID_FLAG;
                          inputAssetA.erc20Address = address(0x0);
                          inputAssetA.assetType = AztecTypes.AztecAssetType.VIRTUAL;
                      } else {
                          inputAssetA.id = bridgeData.inputAssetIdA;
                          inputAssetA.erc20Address = getSupportedAsset(bridgeData.inputAssetIdA);
                          inputAssetA.assetType = inputAssetA.erc20Address == address(0x0)
                              ? AztecTypes.AztecAssetType.ETH
                              : AztecTypes.AztecAssetType.ERC20;
                      }
                      if (bridgeData.firstOutputVirtual) {
                          // use nonce as asset id.
                          outputAssetA.id = defiInteractionNonce;
                          outputAssetA.erc20Address = address(0x0);
                          outputAssetA.assetType = AztecTypes.AztecAssetType.VIRTUAL;
                      } else {
                          outputAssetA.id = bridgeData.outputAssetIdA;
                          outputAssetA.erc20Address = getSupportedAsset(bridgeData.outputAssetIdA);
                          outputAssetA.assetType = outputAssetA.erc20Address == address(0x0)
                              ? AztecTypes.AztecAssetType.ETH
                              : AztecTypes.AztecAssetType.ERC20;
                      }
                      if (bridgeData.secondInputVirtual) {
                          // asset id will be defi interaction nonce that created note
                          inputAssetB.id = bridgeData.inputAssetIdB - VIRTUAL_ASSET_ID_FLAG;
                          inputAssetB.erc20Address = address(0x0);
                          inputAssetB.assetType = AztecTypes.AztecAssetType.VIRTUAL;
                      } else if (bridgeData.secondInputInUse) {
                          inputAssetB.id = bridgeData.inputAssetIdB;
                          inputAssetB.erc20Address = getSupportedAsset(bridgeData.inputAssetIdB);
                          inputAssetB.assetType = inputAssetB.erc20Address == address(0x0)
                              ? AztecTypes.AztecAssetType.ETH
                              : AztecTypes.AztecAssetType.ERC20;
                      } else {
                          inputAssetB.id = 0;
                          inputAssetB.erc20Address = address(0x0);
                          inputAssetB.assetType = AztecTypes.AztecAssetType.NOT_USED;
                      }
                      if (bridgeData.secondOutputVirtual) {
                          // use nonce as asset id.
                          outputAssetB.id = defiInteractionNonce;
                          outputAssetB.erc20Address = address(0x0);
                          outputAssetB.assetType = AztecTypes.AztecAssetType.VIRTUAL;
                      } else if (bridgeData.secondOutputInUse) {
                          outputAssetB.id = bridgeData.outputAssetIdB;
                          outputAssetB.erc20Address = getSupportedAsset(bridgeData.outputAssetIdB);
                          outputAssetB.assetType = outputAssetB.erc20Address == address(0x0)
                              ? AztecTypes.AztecAssetType.ETH
                              : AztecTypes.AztecAssetType.ERC20;
                      } else {
                          outputAssetB.id = 0;
                          outputAssetB.erc20Address = address(0x0);
                          outputAssetB.assetType = AztecTypes.AztecAssetType.NOT_USED;
                      }
                  }
                  /**
                   * @dev Get the length of the defi interaction hashes array and the number of pending interactions
                   *
                   * @return defiInteractionHashesLength the complete length of the defi interaction array
                   * @return numPendingInteractions the current number of pending defi interactions
                   */
                  function getDefiHashesLengths()
                      internal
                      view
                      returns (uint256 defiInteractionHashesLength, uint256 numPendingInteractions)
                  {
                      assembly {
                          // retrieve the total length of the defi interactions array and also the number of pending interactions to a maximum of NUMBER_OF_BRIDGE_CALLS
                          let state := sload(rollupState.slot)
                          {
                              defiInteractionHashesLength := and(ARRAY_LENGTH_MASK, shr(DEFIINTERACTIONHASHES_BIT_OFFSET, state))
                              numPendingInteractions := defiInteractionHashesLength
                              if gt(numPendingInteractions, NUMBER_OF_BRIDGE_CALLS) {
                                  numPendingInteractions := NUMBER_OF_BRIDGE_CALLS
                              }
                          }
                      }
                  }
                  /**
                   * @dev Get the set of hashes that comprise the current pending defi interactions
                   *
                   * @return hashes the set of valid (i.e. non-zero) hashes that comprise the pending defi interactions
                   * @return nextExpectedHash the hash of all hashes (including zero hashes) that comprise the pending defi interactions
                   */
                  function calculateNextExpectedDefiHash() internal view returns (bytes32[] memory hashes, bytes32 nextExpectedHash) {
                      /**----------------------------------------
                       * Compute nextExpectedHash
                       *-----------------------------------------
                       *
                       * The `defiInteractionHashes` mapping emulates an array that represents the
                       * set of defi interactions from previous blocks that have been resolved.
                       *
                       * We need to take the interaction result data from each of the above defi interactions,
                       * and add that data into the Aztec L2 merkle tree that contains defi interaction results
                       * (the "Defi Tree". Its merkle root is one of the inputs to the storage variable `rollupStateHash`)
                       *
                       * It is the rollup provider's responsibility to perform these additions.
                       * In the current block being processed, the rollup provider must take these pending interaction results,
                       * create commitments to each result and insert each commitment into the next empty leaf of the defi tree.
                       *
                       * The following code validates that this has happened! This is how:
                       *
                       * Part 1: What are we checking?
                       *
                       * The rollup circuit will receive, as a private input from the rollup provider, the pending defi interaction results
                       * (`bridgeId`, `totalInputValue`, `totalOutputValueA`, `totalOutputValueB`, `result`)
                       * The rollup circuit will compute the SHA256 hash of each interaction result (the defiInteractionHash)
                       * Finally the SHA256 hash of `NUMBER_OF_BRIDGE_CALLS` of these defiInteractionHash values is computed.
                       * (if there are fewer than `NUMBER_OF_BRIDGE_CALLS` pending defi interaction results, the SHA256 hash of an empty defi interaction result is used instead. i.e. all variable values are set to 0)
                       * The above SHA256 hash, the `pendingDefiInteractionHash` is one of the broadcasted values that forms the `publicInputsHash` public input to the rollup circuit.
                       * When verifying a rollup proof, this smart contract will compute `publicInputsHash` from the input calldata. The PLONK Verifier smart contract will then validate
                       * that our computed value for `publicInputHash` matches the value used when generating the rollup proof.
                       *
                       * TLDR of the above: our proof data contains a variable `pendingDefiInteractionHash`, which is the CLAIMED VALUE of SHA256 hashing the SHA256 hashes of the defi interactions that have resolved but whose data has not yet been added into the defi tree.
                       *
                       * Part 2: How do we check `pendingDefiInteractionHash` is correct???
                       *
                       * This contract will call `DefiBridgeProxy.convert` (via delegatecall) on every new defi interaction present in the block.
                       * The return values from the bridge proxy contract are used to construct a defi interaction result. Its hash is then computed
                       * and stored in `defiInteractionHashes`.
                       *
                       * N.B. It's very important that DefiBridgeProxy does not call selfdestruct, or makes a delegatecall out to a contract that can selfdestruct :o
                       *
                       * Similarly, when async defi interactions resolve, the interaction result is stored in `asyncDefiInteractionHashes`. At the end of the processDefiBridges function,
                       * the contents of the async array is copied into `defiInteractionHashes` (i.e. async interaction results are delayed by 1 rollup block. This is to prevent griefing attacks where
                       * the rollup state changes between the time taken for a rollup tx to be constructed and the rollup tx to be mined)
                       *
                       * We use the contents of `defiInteractionHashes` to reconstruct `pendingDefiInteractionHash`, and validate it matches the value present in calldata and
                       * therefore the value used in the rollup circuit when this block's rollup proof was constructed.
                       * This validates that all of the required defi interaction results were added into the defi tree by the rollup provider
                       * (the circuit logic enforces this, we just need to check the rollup provider used the correct inputs)
                       */
                      (uint256 defiInteractionHashesLength, uint256 numPendingInteractions) = getDefiHashesLengths();
                      uint256 offset = defiInteractionHashesLength - numPendingInteractions;
                      assembly {
                          // allocate the output array of hashes
                          hashes := mload(0x40)
                          let hashData := add(hashes, 0x20)
                          // update the free memory pointer to point past the end of our array
                          // our array will consume 32 bytes for the length field plus NUMBER_OF_BRIDGE_BYTES for all of the hashes
                          mstore(0x40, add(hashes, add(NUMBER_OF_BRIDGE_BYTES, 0x20)))
                          // set the length of hashes to only include the non-zero hash values
                          // although this function will write all of the hashes into our allocated memory, we only want to return the non-zero hashes
                          mstore(hashes, numPendingInteractions)
                          // Prepare the reusable part of the defi interaction hashes slot computation
                          mstore(0x20, defiInteractionHashes.slot)
                          let i := 0
                          // Iterate over numPendingInteractions (will be between 0 and NUMBER_OF_BRIDGE_CALLS)
                          // Load defiInteractionHashes[offset + i] and store in memory
                          // in order to compute SHA2 hash (nextExpectedHash)
                          for {
                          } lt(i, numPendingInteractions) {
                              i := add(i, 0x01)
                          } {
                              // hashData[i] = defiInteractionHashes[offset + i]
                              mstore(0x00, add(offset, i))
                              mstore(add(hashData, mul(i, 0x20)), sload(keccak256(0x00, 0x40)))
                          }
                          // If numPendingInteractions < NUMBER_OF_BRIDGE_CALLS, continue iterating up to NUMBER_OF_BRIDGE_CALLS, this time
                          // inserting the "zero hash", the result of sha256(emptyDefiInteractionResult)
                          for {
                          } lt(i, NUMBER_OF_BRIDGE_CALLS) {
                              i := add(i, 0x01)
                          } {
                              // hashData[i] = DEFI_RESULT_ZERO_HASH
                              mstore(add(hashData, mul(i, 0x20)), DEFI_RESULT_ZERO_HASH)
                          }
                          pop(staticcall(gas(), 0x2, hashData, NUMBER_OF_BRIDGE_BYTES, 0x00, 0x20))
                          nextExpectedHash := mod(mload(0x00), CIRCUIT_MODULUS)
                      }
                  }
                  /**
                   * @dev Process defi interactions.
                   *      1. pop NUMBER_OF_BRIDGE_CALLS (if available) interaction hashes off of `defiInteractionHashes`,
                   *         validate their hash (calculated at the end of the previous rollup and stored as nextExpectedDefiInteractionsHash) equals `numPendingInteractions`
                   *         (this validates that rollup block has added these interaction results into the L2 data tree)
                   *      2. iterate over rollup block's new defi interactions (up to NUMBER_OF_BRIDGE_CALLS). Trigger interactions by
                   *         calling DefiBridgeProxy contract. Record results in either `defiInteractionHashes` (for synchrohnous txns)
                   *         or, for async txns, the `pendingDefiInteractions` mapping
                   *      3. copy the contents of `asyncInteractionHashes` into `defiInteractionHashes` && clear `asyncInteractionHashes`
                   *      4. calculate the next value of nextExpectedDefiInteractionsHash from the new set of defiInteractionHashes
                   * @param proofData - the proof data
                   * @param rollupBeneficiary - the address that should be paid any subsidy for processing a defi bridge
                   * @return nextExpectedHashes - the set of non-zero hashes that comprise the current pending defi interactions
                   */
                  function processDefiBridges(bytes memory proofData, address rollupBeneficiary)
                      internal
                      returns (bytes32[] memory nextExpectedHashes)
                  {
                      uint256 defiInteractionHashesLength;
                      // Verify that nextExpectedDefiInteractionsHash equals the value given in the rollup
                      // Then remove the set of pending hashes
                      {
                          // Extract the claimed value of previousDefiInteractionHash present in the proof data
                          bytes32 providedDefiInteractionsHash = extractPrevDefiInteractionHash(proofData);
                          // Validate the stored interactionHash matches the value used when making the rollup proof!
                          if (providedDefiInteractionsHash != prevDefiInteractionsHash) {
                              revert INCORRECT_PREVIOUS_DEFI_INTERACTION_HASH(providedDefiInteractionsHash, prevDefiInteractionsHash);
                          }
                          uint256 numPendingInteractions;
                          (defiInteractionHashesLength, numPendingInteractions) = getDefiHashesLengths();
                          // numPendingInteraction equals the number of interactions expected to be in the given rollup
                          // this is the length of the defiInteractionHashes array, capped at the NUM_BRIDGE_CALLS as per the following
                          // numPendingInteractions = min(defiInteractionsHashesLength, numberOfBridgeCalls)
                          // Reduce DefiInteractionHashes.length by numPendingInteractions
                          defiInteractionHashesLength -= numPendingInteractions;
                          assembly {
                              // Update DefiInteractionHashes.length in storage
                              let state := sload(rollupState.slot)
                              let oldState := and(not(shl(DEFIINTERACTIONHASHES_BIT_OFFSET, ARRAY_LENGTH_MASK)), state)
                              let newState := or(oldState, shl(DEFIINTERACTIONHASHES_BIT_OFFSET, defiInteractionHashesLength))
                              sstore(rollupState.slot, newState)
                          }
                      }
                      uint256 interactionNonce = getRollupId(proofData) * NUMBER_OF_BRIDGE_CALLS;
                      // ### Process DefiBridge Calls
                      uint256 proofDataPtr;
                      assembly {
                          proofDataPtr := add(proofData, BRIDGE_IDS_OFFSET)
                      }
                      BridgeResult memory bridgeResult;
                      assembly {
                          bridgeResult := mload(0x40)
                          mstore(0x40, add(bridgeResult, 0x80))
                      }
                      for (uint256 i = 0; i < NUMBER_OF_BRIDGE_CALLS; ) {
                          uint256 bridgeId;
                          assembly {
                              bridgeId := mload(proofDataPtr)
                          }
                          if (bridgeId == 0) {
                              // no more bridges to call
                              break;
                          }
                          uint256 totalInputValue;
                          assembly {
                              totalInputValue := mload(add(proofDataPtr, mul(0x20, NUMBER_OF_BRIDGE_CALLS)))
                          }
                          if (totalInputValue == 0) {
                              revert ZERO_TOTAL_INPUT_VALUE();
                          }
                          BridgeData memory bridgeData = getBridgeData(bridgeId);
                          (
                              AztecTypes.AztecAsset memory inputAssetA,
                              AztecTypes.AztecAsset memory inputAssetB,
                              AztecTypes.AztecAsset memory outputAssetA,
                              AztecTypes.AztecAsset memory outputAssetB
                          ) = getAztecAssetTypes(bridgeData, interactionNonce);
                          assembly {
                              // call the following function of DefiBridgeProxy via delegatecall...
                              //     function convert(
                              //          address bridgeAddress,
                              //          AztecTypes.AztecAsset calldata inputAssetA,
                              //          AztecTypes.AztecAsset calldata inputAssetB,
                              //          AztecTypes.AztecAsset calldata outputAssetA,
                              //          AztecTypes.AztecAsset calldata outputAssetB,
                              //          uint256 totalInputValue,
                              //          uint256 interactionNonce,
                              //          uint256 auxInputData,
                              //          uint256 ethPaymentsSlot,
                              //          address rollupBeneficary
                              //     )
                              // Construct the calldata we send to DefiBridgeProxy
                              // mPtr = memory pointer. Set to free memory location (0x40)
                              let mPtr := mload(0x40)
                              // first 4 bytes is the function signature
                              mstore(mPtr, DEFI_BRIDGE_PROXY_CONVERT_SELECTOR)
                              mPtr := add(mPtr, 0x04)
                              let bridgeAddress := mload(add(bridgeData, 0x20))
                              mstore(mPtr, bridgeAddress)
                              mstore(add(mPtr, 0x20), mload(inputAssetA))
                              mstore(add(mPtr, 0x40), mload(add(inputAssetA, 0x20)))
                              mstore(add(mPtr, 0x60), mload(add(inputAssetA, 0x40)))
                              mstore(add(mPtr, 0x80), mload(inputAssetB))
                              mstore(add(mPtr, 0xa0), mload(add(inputAssetB, 0x20)))
                              mstore(add(mPtr, 0xc0), mload(add(inputAssetB, 0x40)))
                              mstore(add(mPtr, 0xe0), mload(outputAssetA))
                              mstore(add(mPtr, 0x100), mload(add(outputAssetA, 0x20)))
                              mstore(add(mPtr, 0x120), mload(add(outputAssetA, 0x40)))
                              mstore(add(mPtr, 0x140), mload(outputAssetB))
                              mstore(add(mPtr, 0x160), mload(add(outputAssetB, 0x20)))
                              mstore(add(mPtr, 0x180), mload(add(outputAssetB, 0x40)))
                              mstore(add(mPtr, 0x1a0), totalInputValue)
                              mstore(add(mPtr, 0x1c0), interactionNonce)
                              let auxData := mload(add(bridgeData, 0xc0))
                              mstore(add(mPtr, 0x1e0), auxData)
                              mstore(add(mPtr, 0x200), ethPayments.slot)
                              mstore(add(mPtr, 0x220), rollupBeneficiary)
                              // Call the bridge proxy via delegatecall!
                              // We want the proxy to share state with the rollup processor, as the proxy is the entity sending/recovering tokens from the bridge contracts.
                              // We wrap this logic in a delegatecall so that if the call fails (i.e. the bridge interaction fails), we can unwind bridge-interaction specific state changes,
                              // without reverting the entire transaction.
                              let success := delegatecall(
                                  mload(add(bridgeData, 0x1a0)), // bridgeData.gasSentToBridge
                                  sload(defiBridgeProxy.slot),
                                  sub(mPtr, 0x04),
                                  0x244,
                                  0,
                                  0
                              )
                              returndatacopy(mPtr, 0, returndatasize())
                              switch success
                              case 1 {
                                  mstore(bridgeResult, mload(mPtr)) // outputValueA
                                  mstore(add(bridgeResult, 0x20), mload(add(mPtr, 0x20))) // outputValueB
                                  mstore(add(bridgeResult, 0x40), mload(add(mPtr, 0x40))) // isAsync
                                  mstore(add(bridgeResult, 0x60), 1) // success
                              }
                              default {
                                  // If the call failed, mark this interaction as failed. No tokens have been exchanged, users can
                                  // use the "claim" circuit to recover the initial tokens they sent to the bridge
                                  mstore(bridgeResult, 0) // outputValueA
                                  mstore(add(bridgeResult, 0x20), 0) // outputValueB
                                  mstore(add(bridgeResult, 0x40), 0) // isAsync
                                  mstore(add(bridgeResult, 0x60), 0) // success
                              }
                          }
                          if (!bridgeData.secondOutputInUse) {
                              bridgeResult.outputValueB = 0;
                          }
                          // emit events and update state
                          assembly {
                              // if interaction is Async, update pendingDefiInteractions
                              // if interaction is synchronous, compute the interaction hash and add to defiInteractionHashes
                              switch mload(add(bridgeResult, 0x40)) // switch isAsync
                              case 1 {
                                  let mPtr := mload(0x40)
                                  // emit AsyncDefiBridgeProcessed(indexed bridgeId, indexed interactionNonce, totalInputValue)
                                  {
                                      mstore(mPtr, totalInputValue)
                                      log3(mPtr, 0x20, ASYNC_BRIDGE_PROCESSED_SIGHASH, bridgeId, interactionNonce)
                                  }
                                  // pendingDefiInteractions[interactionNonce] = PendingDefiBridgeInteraction(bridgeId, totalInputValue)
                                  mstore(0x00, interactionNonce)
                                  mstore(0x20, pendingDefiInteractions.slot)
                                  let pendingDefiInteractionsSlotBase := keccak256(0x00, 0x40)
                                  sstore(pendingDefiInteractionsSlotBase, bridgeId)
                                  sstore(add(pendingDefiInteractionsSlotBase, 0x01), totalInputValue)
                              }
                              default {
                                  let mPtr := mload(0x40)
                                  // prepare the data required to publish the DefiBridgeProcessed event, we will only publish it if isAsync == false
                                  // async interactions that have failed, have their isAsync property modified to false above
                                  // emit DefiBridgeProcessed(indexed bridgeId, indexed interactionNonce, totalInputValue, outputValueA, outputValueB, success)
                                  {
                                      mstore(mPtr, totalInputValue)
                                      mstore(add(mPtr, 0x20), mload(bridgeResult)) // outputValueA
                                      mstore(add(mPtr, 0x40), mload(add(bridgeResult, 0x20))) // outputValueB
                                      mstore(add(mPtr, 0x60), mload(add(bridgeResult, 0x60))) // success
                                      mstore(add(mPtr, 0x80), 0xa0) // position in event data block of `bytes` object
                                      if mload(add(bridgeResult, 0x60)) {
                                          mstore(add(mPtr, 0xa0), 0)
                                          log3(mPtr, 0xc0, DEFI_BRIDGE_PROCESSED_SIGHASH, bridgeId, interactionNonce)
                                      }
                                      if iszero(mload(add(bridgeResult, 0x60))) {
                                          mstore(add(mPtr, 0xa0), returndatasize())
                                          let size := returndatasize()
                                          let remainder := mul(iszero(iszero(size)), sub(32, mod(size, 32)))
                                          returndatacopy(add(mPtr, 0xc0), 0, size)
                                          mstore(add(mPtr, add(0xc0, size)), 0)
                                          log3(
                                              mPtr,
                                              add(0xc0, add(size, remainder)),
                                              DEFI_BRIDGE_PROCESSED_SIGHASH,
                                              bridgeId,
                                              interactionNonce
                                          )
                                      }
                                  }
                                  // compute defiInteractionnHash
                                  mstore(mPtr, bridgeId)
                                  mstore(add(mPtr, 0x20), interactionNonce)
                                  mstore(add(mPtr, 0x40), totalInputValue)
                                  mstore(add(mPtr, 0x60), mload(bridgeResult)) // outputValueA
                                  mstore(add(mPtr, 0x80), mload(add(bridgeResult, 0x20))) // outputValueB
                                  mstore(add(mPtr, 0xa0), mload(add(bridgeResult, 0x60))) // success
                                  pop(staticcall(gas(), 0x2, mPtr, 0xc0, 0x00, 0x20))
                                  let defiInteractionHash := mod(mload(0x00), CIRCUIT_MODULUS)
                                  // defiInteractionHashes[defiInteractionHashesLength] = defiInteractionHash;
                                  mstore(0x00, defiInteractionHashesLength)
                                  mstore(0x20, defiInteractionHashes.slot)
                                  sstore(keccak256(0x00, 0x40), defiInteractionHash)
                                  // Increase the length of defiInteractionHashes by 1
                                  defiInteractionHashesLength := add(defiInteractionHashesLength, 0x01)
                              }
                              // advance interactionNonce and proofDataPtr
                              interactionNonce := add(interactionNonce, 0x01)
                              proofDataPtr := add(proofDataPtr, 0x20)
                          }
                          unchecked {
                              ++i;
                          }
                      }
                      assembly {
                          /**
                           * Cleanup
                           *
                           * 1. Copy asyncDefiInteractionHashes into defiInteractionHashes
                           * 2. Update defiInteractionHashes.length
                           * 2. Clear asyncDefiInteractionHashes.length
                           */
                          let state := sload(rollupState.slot)
                          let asyncDefiInteractionHashesLength := and(
                              ARRAY_LENGTH_MASK,
                              shr(ASYNCDEFIINTERACTIONHASHES_BIT_OFFSET, state)
                          )
                          // Validate we are not overflowing our 1024 array size
                          let arrayOverflow := gt(
                              add(asyncDefiInteractionHashesLength, defiInteractionHashesLength),
                              ARRAY_LENGTH_MASK
                          )
                          // Throw an error if defiInteractionHashesLength > ARRAY_LENGTH_MASK (i.e. is >= 1024)
                          // should never hit this! If block `i` generates synchronous txns,
                          // block 'i + 1' must process them.
                          // Only way this array size hits 1024 is if we produce a glut of async interaction results
                          // between blocks. HOWEVER we ensure that async interaction callbacks fail iff they would increase
                          // defiInteractionHashes length to be >= 512
                          // Still, can't hurt to check...
                          if arrayOverflow {
                              // keccak256("ARRAY_OVERFLOW()")
                              mstore(0x00, 0x58a4ab0e00000000000000000000000000000000000000000000000000000000)
                              revert(0x00, 0x04)
                          }
                          // Now, copy async hashes into defiInteractionHashes
                          // Cache the free memory pointer
                          let freePtr := mload(0x40)
                          // Prepare the reusable parts of slot computation
                          mstore(0x20, defiInteractionHashes.slot)
                          mstore(0x60, asyncDefiInteractionHashes.slot)
                          for {
                              let i := 0
                          } lt(i, asyncDefiInteractionHashesLength) {
                              i := add(i, 1)
                          } {
                              // defiInteractionHashesLength[defiInteractionHashesLength + i] = asyncDefiInteractionHashes[i]
                              mstore(0x00, add(defiInteractionHashesLength, i))
                              mstore(0x40, i)
                              sstore(keccak256(0x00, 0x40), sload(keccak256(0x40, 0x40)))
                          }
                          // Restore the free memory pointer
                          mstore(0x40, freePtr)
                          // clear defiInteractionHashesLength in state
                          state := and(not(shl(DEFIINTERACTIONHASHES_BIT_OFFSET, ARRAY_LENGTH_MASK)), state)
                          // write new defiInteractionHashesLength in state
                          state := or(
                              shl(
                                  DEFIINTERACTIONHASHES_BIT_OFFSET,
                                  add(asyncDefiInteractionHashesLength, defiInteractionHashesLength)
                              ),
                              state
                          )
                          // clear asyncDefiInteractionHashesLength in state
                          state := and(not(shl(ASYNCDEFIINTERACTIONHASHES_BIT_OFFSET, ARRAY_LENGTH_MASK)), state)
                          // write new state
                          sstore(rollupState.slot, state)
                      }
                      // now we want to extract the next set of pending defi interaction hashes and calculate their hash to store for the next rollup
                      (bytes32[] memory hashes, bytes32 nextExpectedHash) = calculateNextExpectedDefiHash();
                      nextExpectedHashes = hashes;
                      prevDefiInteractionsHash = nextExpectedHash;
                  }
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts (last updated v4.6.0) (proxy/utils/Initializable.sol)
              pragma solidity ^0.8.2;
              import "../../utils/AddressUpgradeable.sol";
              /**
               * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
               * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
               * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
               * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
               *
               * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
               * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
               * case an upgrade adds a module that needs to be initialized.
               *
               * For example:
               *
               * [.hljs-theme-light.nopadding]
               * ```
               * contract MyToken is ERC20Upgradeable {
               *     function initialize() initializer public {
               *         __ERC20_init("MyToken", "MTK");
               *     }
               * }
               * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
               *     function initializeV2() reinitializer(2) public {
               *         __ERC20Permit_init("MyToken");
               *     }
               * }
               * ```
               *
               * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
               * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
               *
               * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
               * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
               *
               * [CAUTION]
               * ====
               * Avoid leaving a contract uninitialized.
               *
               * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
               * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
               * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
               *
               * [.hljs-theme-light.nopadding]
               * ```
               * /// @custom:oz-upgrades-unsafe-allow constructor
               * constructor() {
               *     _disableInitializers();
               * }
               * ```
               * ====
               */
              abstract contract Initializable {
                  /**
                   * @dev Indicates that the contract has been initialized.
                   * @custom:oz-retyped-from bool
                   */
                  uint8 private _initialized;
                  /**
                   * @dev Indicates that the contract is in the process of being initialized.
                   */
                  bool private _initializing;
                  /**
                   * @dev Triggered when the contract has been initialized or reinitialized.
                   */
                  event Initialized(uint8 version);
                  /**
                   * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
                   * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
                   */
                  modifier initializer() {
                      bool isTopLevelCall = _setInitializedVersion(1);
                      if (isTopLevelCall) {
                          _initializing = true;
                      }
                      _;
                      if (isTopLevelCall) {
                          _initializing = false;
                          emit Initialized(1);
                      }
                  }
                  /**
                   * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
                   * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
                   * used to initialize parent contracts.
                   *
                   * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
                   * initialization step. This is essential to configure modules that are added through upgrades and that require
                   * initialization.
                   *
                   * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
                   * a contract, executing them in the right order is up to the developer or operator.
                   */
                  modifier reinitializer(uint8 version) {
                      bool isTopLevelCall = _setInitializedVersion(version);
                      if (isTopLevelCall) {
                          _initializing = true;
                      }
                      _;
                      if (isTopLevelCall) {
                          _initializing = false;
                          emit Initialized(version);
                      }
                  }
                  /**
                   * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
                   * {initializer} and {reinitializer} modifiers, directly or indirectly.
                   */
                  modifier onlyInitializing() {
                      require(_initializing, "Initializable: contract is not initializing");
                      _;
                  }
                  /**
                   * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
                   * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
                   * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
                   * through proxies.
                   */
                  function _disableInitializers() internal virtual {
                      _setInitializedVersion(type(uint8).max);
                  }
                  function _setInitializedVersion(uint8 version) private returns (bool) {
                      // If the contract is initializing we ignore whether _initialized is set in order to support multiple
                      // inheritance patterns, but we only do this in the context of a constructor, and for the lowest level
                      // of initializers, because in other contexts the contract may have been reentered.
                      if (_initializing) {
                          require(
                              version == 1 && !AddressUpgradeable.isContract(address(this)),
                              "Initializable: contract is already initialized"
                          );
                          return false;
                      } else {
                          require(_initialized < version, "Initializable: contract is already initialized");
                          _initialized = version;
                          return true;
                      }
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              interface IVerifier {
                  function verify(bytes memory serialized_proof, uint256 _publicInputsHash) external returns (bool);
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
              interface IERC20Permit is IERC20 {
                  function nonces(address user) external view returns (uint256);
                  function permit(
                      address owner,
                      address spender,
                      uint256 value,
                      uint256 deadline,
                      uint8 v,
                      bytes32 r,
                      bytes32 s
                  ) external;
                  function permit(
                      address holder,
                      address spender,
                      uint256 nonce,
                      uint256 expiry,
                      bool allowed,
                      uint8 v,
                      bytes32 r,
                      bytes32 s
                  ) external;
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              /**
               * ----------------------------------------
               *  PROOF DATA SPECIFICATION
               * ----------------------------------------
               * Our input "proof data" is represented as a single byte array - we use a custom encoding the encode the
               * data associated with a rollup block. The encoded structure is as follows (excluding the length param of the bytes type):
               * 
                 | byte range      | num bytes        | name                             | description |
                 | ---             | ---              | ---                              | ---         |
                 | 0x00  - 0x20    | 32               | rollupId                         | Unique rollup block identifier. Equivalent to block number |
                 | 0x20  - 0x40    | 32               | rollupSize                       | Max number of transactions in the block |
                 | 0x40  - 0x60    | 32               | dataStartIndex                   | Position of the next empty slot in the Aztec data tree |
                 | 0x60  - 0x80    | 32               | oldDataRoot                      | Root of the data tree prior to rollup block's state updates |
                 | 0x80  - 0xa0    | 32               | newDataRoot                      | Root of the data tree after rollup block's state updates |
                 | 0xa0  - 0xc0    | 32               | oldNullRoot                      | Root of the nullifier tree prior to rollup block's state updates |
                 | 0xc0  - 0xe0    | 32               | newNullRoot                      | Root of the nullifier tree after rollup block's state updates |
                 | 0xe0  - 0x100   | 32               | oldDataRootsRoot                 | Root of the tree of data tree roots prior to rollup block's state updates |
                 | 0x100 - 0x120   | 32               | newDataRootsRoot                 | Root of the tree of data tree roots after rollup block's state updates |
                 | 0x120 - 0x140   | 32               | oldDefiRoot                      | Root of the defi tree prior to rollup block's state updates |
                 | 0x140 - 0x160   | 32               | newDefiRoot                      | Root of the defi tree after rollup block's state updates |
                 | 0x160 - 0x560   | 1024             | bridgeIds[NUMBER_OF_BRIDGE_CALLS]   | Size-32 array of bridgeIds for bridges being called in this block. If bridgeId == 0, no bridge is called |
                 | 0x560 - 0x960   | 1024             | depositSums[NUMBER_OF_BRIDGE_CALLS] | Size-32 array of deposit values being sent for bridges being called in this block |
                 | 0x960 - 0xb60   | 512              | assetIds[NUMBER_OF_ASSETS]         | Size-16 array of the assetIds for assets being deposited/withdrawn/used to pay fees in this block |
                 | 0xb60 - 0xd60   | 512              | txFees[NUMBER_OF_ASSETS]           | Size-16 array of transaction fees paid to the rollup beneficiary, denominated in each assetId |
                 | 0xd60 - 0x1160  | 1024             | interactionNotes[NUMBER_OF_BRIDGE_CALLS] | Size-32 array of defi interaction result commitments that must be inserted into the defi tree at this rollup block |
                 | 0x1160 - 0x1180 | 32               | prevDefiInteractionHash          | A SHA256 hash of the data used to create each interaction result commitment. Used to validate correctness of interactionNotes |
                 | 0x1180 - 0x11a0 | 32               | rollupBeneficiary                | The address that the fees from this rollup block should be sent to. Prevents a rollup proof being taken from the transaction pool and having its fees redirected |
                 | 0x11a0 - 0x11c0 | 32               | numRollupTxs                     | Number of "inner rollup" proofs used to create the block proof. "inner rollup" circuits process 3-28 user txns, the outer rollup circuit processes 1-28 inner rollup proofs. |
                 | 0x11c0 - 0x11c4 | 4                | numRealTxs                       | Number of transactions in the rollup excluding right-padded padding proofs
                 | 0x11c4 - 0x11c8 | 4                | encodedInnerTxData.length        | Number of bytes of encodedInnerTxData |
                 | 0x11c8 - end    | encodedInnerTxData.length | encodedInnerTxData      | Encoded inner transaction data. Contains encoded form of the broadcasted data associated with each tx in the rollup block |
               **/
               /**
                * --------------------------------------------
                *  DETERMINING THE NUMBER OF REAL TRANSACTIONS
                * --------------------------------------------
                * The `rollupSize` parameter describes the MAX number of txns in a block.
                * However the block may not be full.
                * Incomplete blocks will be padded with "padding" transactions that represent empty txns.
                *
                * The amount of end padding is not explicitly defined in `proofData`. It is derived.
                * The encodedInnerTxData does not include tx data for the txns associated with this end padding.
                * (it does include any padding transactions that are not part of the end padding, which can sometimes happen)
                * When decoded, the transaction data for each transaction is a fixed size (256 bytes)
                * Number of real transactions = rollupSize - (decoded tx data size / 256)
                *
                * The decoded transaction data associated with padding transactions is 256 zero bytes.
               **/
              /**
               * @title Decoder
               * @dev contains functions for decoding/extracting the encoded proof data passed in as calldata,
               * as well as computing the SHA256 hash of the decoded data (publicInputsHash).
               * The publicInputsHash is used to ensure the data passed in as calldata matches the data used within the rollup circuit
               */
              contract Decoder {
                  /*----------------------------------------
                    CONSTANTS
                    ----------------------------------------*/
                  uint256 internal constant NUMBER_OF_ASSETS = 16; // max number of assets in a block
                  uint256 internal constant NUMBER_OF_BRIDGE_CALLS = 32; // max number of bridge calls in a block
                  uint256 internal constant NUMBER_OF_BRIDGE_BYTES = 1024; // NUMBER_OF_BRIDGE_CALLS * 32
                  uint256 internal constant NUMBER_OF_PUBLIC_INPUTS_PER_TX = 8; // number of ZK-SNARK "public inputs" per join-split/account/claim transaction
                  uint256 internal constant TX_PUBLIC_INPUT_LENGTH = 256; // byte-length of NUMBER_OF_PUBLIC_INPUTS_PER_TX. NUMBER_OF_PUBLIC_INPUTS_PER_TX * 32;
                  uint256 internal constant ROLLUP_NUM_HEADER_INPUTS = 142; // 58; // number of ZK-SNARK "public inputs" that make up the rollup header 14 + (NUMBER_OF_BRIDGE_CALLS * 3) + (NUMBER_OF_ASSETS * 2);
                  uint256 internal constant ROLLUP_HEADER_LENGTH = 4544; // 1856; // ROLLUP_NUM_HEADER_INPUTS * 32;
                  // ENCODED_PROOF_DATA_LENGTH_OFFSET = byte offset into the rollup header such that `numRealTransactions` occupies
                  // the least significant 4 bytes of the 32-byte word being pointed to.
                  // i.e. ROLLUP_HEADER_LENGTH - 28
                  uint256 internal constant NUM_REAL_TRANSACTIONS_OFFSET = 4516;
                  // ENCODED_PROOF_DATA_LENGTH_OFFSET = byte offset into the rollup header such that `encodedInnerProofData.length` occupies
                  // the least significant 4 bytes of the 32-byte word being pointed to.
                  // i.e. ROLLUP_HEADER_LENGTH - 24
                  uint256 internal constant ENCODED_PROOF_DATA_LENGTH_OFFSET = 4520;
                  // offset we add to `proofData` to point to the bridgeIds
                  uint256 internal constant BRIDGE_IDS_OFFSET = 0x180;
                  // offset we add to `proofData` to point to prevDefiInteractionhash
                  uint256 internal constant PREVIOUS_DEFI_INTERACTION_HASH_OFFSET = 4480; // ROLLUP_HEADER_LENGTH - 0x40
                  // offset we add to `proofData` to point to rollupBeneficiary
                  uint256 internal constant ROLLUP_BENEFICIARY_OFFSET = 4512; // ROLLUP_HEADER_LENGTH - 0x20
                  // CIRCUIT_MODULUS = group order of the BN254 elliptic curve. All arithmetic gates in our ZK-SNARK circuits are evaluated modulo this prime.
                  // Is used when computing the public inputs hash - our SHA256 hash outputs are reduced modulo CIRCUIT_MODULUS
                  uint256 internal constant CIRCUIT_MODULUS =
                      21888242871839275222246405745257275088548364400416034343698204186575808495617;
                  // SHA256 hashes
                  uint256 internal constant PADDING_ROLLUP_HASH_SIZE_1 =
                      0x22dd983f8337d97d56071f7986209ab2ee6039a422242e89126701c6ee005af0;
                  uint256 internal constant PADDING_ROLLUP_HASH_SIZE_2 =
                      0x076a27c79e5ace2a3d47f9dd2e83e4ff6ea8872b3c2218f66c92b89b55f36560;
                  uint256 internal constant PADDING_ROLLUP_HASH_SIZE_4 =
                      0x2f0c70a5bf5460465e9902f9c96be324e8064e762a5de52589fdb97cbce3c6ee;
                  uint256 internal constant PADDING_ROLLUP_HASH_SIZE_8 =
                      0x240ed0de145447ff0ceff2aa477f43e0e2ed7f3543ee3d8832f158ec76b183a9;
                  uint256 internal constant PADDING_ROLLUP_HASH_SIZE_16 =
                      0x1c52c159b4dae66c3dcf33b44d4d61ead6bc4d260f882ac6ba34dccf78892ca4;
                  uint256 internal constant PADDING_ROLLUP_HASH_SIZE_32 =
                      0x0df0e06ab8a02ce2ff08babd7144ab23ca2e99ddf318080cf88602eeb8913d44;
                  uint256 internal constant PADDING_ROLLUP_HASH_SIZE_64 =
                      0x1f83672815ac9b3ca31732d641784035834e96b269eaf6a2e759bf4fcc8e5bfd;
                  uint256 internal constant ADDRESS_MASK = 0x00ffffffffffffffffffffffffffffffffffffffff;
                  /*----------------------------------------
                    ERROR TAGS
                    ----------------------------------------*/
                  error ENCODING_BYTE_INVALID();
                  error INVALID_ROLLUP_TOPOLOGY();
                  /*----------------------------------------
                    DECODING FUNCTIONS
                    ----------------------------------------*/
                  /**
                   * In `bytes proofData`, transaction data is appended after the rollup header data
                   * Each transaction is described by 8 'public inputs' used to create a user transaction ZK-SNARK proof
                   * (i.e. there are 8 public inputs for each of the "join-split", "account" and "claim" circuits)
                   * The public inputs are represented in calldata according to the following specification:
                   *
                   * | public input idx | calldata size (bytes) | variable | description |
                   * | 0                | 1                     |proofId         | transaction type identifier       |
                   * | 1                | 32                    | encrypted form of 1st output note |
                   * | 2                | 32                    | encrypted form of 2nd output note |
                   * | 3                | 32                    | nullifier of 1st input note       |
                   * | 4                | 32                    | nullifier of 2nd input note       |
                   * | 5                | 32                    | amount being deposited or withdrawn |
                   * | 6                | 20                    | address of depositor or withdraw destination |
                   * | 7                | 4                     | assetId used in transaction |
                   *
                   * The following table maps proofId values to transaction types
                   *
                   *
                   * | proofId | tx type     | description |
                   * | ---     | ---         | ---         |
                   * | 0       | padding     | empty transaction. Rollup blocks have a fixed number of txns. If number of real txns is less than block size, padding txns make up the difference |
                   * | 1       | deposit     | deposit Eth/tokens into Aztec in exchange for encrypted Aztec notes |
                   * | 2       | withdraw    | exchange encrypted Aztec notes for Eth/tokens sent to a public address |
                   * | 3       | send        | private send |
                   * | 4       | account     | creates an Aztec account |
                   * | 5       | defiDeposit | deposit Eth/tokens into a L1 smart contract via a Defi bridge contract |
                   * | 6       | defiClaim   | convert proceeds of defiDeposit tx back into encrypted Aztec notes |
                   *
                   * Most of the above transaction types do not use the full set of 8 public inputs (i.e. some are zero).
                   * To save on calldata costs, we encode each transaction into the smallest payload possible.
                   * In `decodeProof`, the encoded transaction data decoded, with the decoded tx data written into memory
                   *
                   * As part of the decoding algorithms we must convert the 20-byte `publicOwner` and 4-byte `assetId` fields
                   * into 32-byte EVM words
                   *
                   * The following functions perform transaction-specific decoding. The `proofId` field is decoded prior to calling these functions
                   */
                  /**
                   * @dev decode a padding tx
                   * @param inPtr location in calldata of the encoded transaction
                   * @return location in calldata of the next encoded transaction
                   *
                   * Encoded padding tx consists of 1 byte, the `proofId`
                   * The proofId has been written into memory before we called this function so there is nothing to copy.
                   * Advance the calldatapointer by 1 byte to move to the next transaction
                   */
                  function paddingTx(uint256 inPtr, uint256) internal pure returns (uint256) {
                      unchecked{
                          return (inPtr + 0x1);
                      }
                  }
                  /**
                   * @dev decode a deposit or a withdraw tx
                   * @param inPtr location in calldata of the encoded transaction
                   * @param outPtr location in memory to write the decoded transaction to
                   * @return location in calldata of the next encoded transaction
                   *
                   * the deposit tx uses all 8 public inputs. All calldata is copied into memory
                   */
                  function depositOrWithdrawTx(uint256 inPtr, uint256 outPtr) internal pure returns (uint256) {
                      // Copy deposit calldata into memory
                      assembly {
                          // start copying into `outPtr + 0x20`, as `outPtr` points to `proofId`, which has already been written into memry
                          calldatacopy(add(outPtr, 0x20), add(inPtr, 0x20), 0xa0) // noteCommitment1 ... publicValue
                          calldatacopy(add(outPtr, 0xcc), add(inPtr, 0xc0), 0x14) // convert 20-byte publicOwner calldata variable into 32-byte EVM word
                          calldatacopy(add(outPtr, 0xfc), add(inPtr, 0xd4), 0x4) // convert 4-byte assetId variable into 32-byte EVM word
                      }
                      // advance calldata ptr by 185 bytes
                      unchecked {
                          return (inPtr + 0xb9);
                      }
                  }
                  /**
                   * @dev decode a send tx
                   * @param inPtr location in calldata of the encoded transaction
                   * @param outPtr location in memory to write the decoded transaction to
                   * @return location in calldata of the next encoded transaction
                   *
                   * The send tx has 0-values for `publicValue`, `publicOwner` and `assetId`
                   * No need to copy anything into memory for these fields as memory defaults to 0
                   */
                  function sendTx(uint256 inPtr, uint256 outPtr) internal pure returns (uint256) {
                      assembly {
                          calldatacopy(add(outPtr, 0x20), add(inPtr, 0x20), 0x80) // noteCommitment1 ... nullifier2
                      }
                      unchecked {
                          return (inPtr + 0x81);
                      }
                  }
                  /**
                   * @dev decode an account tx
                   * @param inPtr location in calldata of the encoded transaction
                   * @param outPtr location in memory to write the decoded transaction to
                   * @return location in calldata of the next encoded transaction
                   *
                   * The send tx has 0-values for `nullifier2`, `publicValue`, `publicOwner` and `assetId`
                   * No need to copy anything into memory for these fields as memory defaults to 0
                   */
                  function accountTx(uint256 inPtr, uint256 outPtr) internal pure returns (uint256) {
                      assembly {
                          calldatacopy(add(outPtr, 0x20), add(inPtr, 0x20), 0x80) // noteCommitment1 ... nullifier2
                      }
                      unchecked {
                          return (inPtr + 0x81);
                      }
                  }
                  /**
                   * @dev decode a defi deposit or claim tx
                   * @param inPtr location in calldata of the encoded transaction
                   * @param outPtr location in memory to write the decoded transaction to
                   * @return location in calldata of the next encoded transaction
                   *
                   * The defi deposit/claim txns has 0-values for `publicValue`, `publicOwner` and `assetId`
                   * No need to copy anything into memory for these fields as memory defaults to 0
                   */
                  function defiDepositOrClaimTx(uint256 inPtr, uint256 outPtr) internal pure returns (uint256) {
                      assembly {
                          calldatacopy(add(outPtr, 0x20), add(inPtr, 0x20), 0x80) // noteCommitment1 ... nullifier2
                      }
                      unchecked {
                          return (inPtr + 0x81);
                      }
                  }
                  /**
                   * @dev invalid transaction function
                   * If we hit this, there is a transaction whose proofId is invalid (i.e. not 0 to 7).
                   * Throw an error and revert the tx.
                   */
                  function invalidTx(uint256, uint256) internal pure returns (uint256) {
                      revert ENCODING_BYTE_INVALID();
                  }
                  /**
                   * @dev decodes the rollup block's proof data
                   * This function converts the proof data into a representation we can work with in memory
                   * In particular, encoded transaction calldata is decoded and written into memory
                   * The rollup header is also copied from calldata into memory
                   * @return proofData numTxs publicInputsHash
                   * proofData is a memory pointer to the decoded proof data
                   *
                   * The publicInputsHash is a sha256 hash of the public inputs associated with each transaction in the rollup.
                   * It is used to validate the correctness of the data being fed into the rollup circuit
                   * (there is a bit of nomenclature abuse here. Processing a public input in the verifier algorithm costs 150 gas, which
                   * adds up very quickly. Instead of this, we sha256 hash what used to be the "public" inputs and only set the hash to be public.
                   * We then make the old "public" inputs private in the rollup circuit, and validate their correctness by checking their sha256 hash matches
                   * what we compute in the decodeProof function!
                   *
                   * numTxs = number of transactions in the rollup, excluding end-padding transactions
                   * 
                   */
                  function decodeProof()
                      internal
                      view
                      returns (
                          bytes memory proofData,
                          uint256 numTxs,
                          uint256 publicInputsHash
                      )
                  {
                      // declare some variables that will be set inside asm blocks
                      uint256 dataSize; // size of our decoded transaction data, in bytes
                      uint256 outPtr; // memory pointer to where we will write our decoded transaction data
                      uint256 inPtr; // calldata pointer into our proof data
                      uint256 rollupSize; // max number of transactions in the rollup block
                      uint256 decodedTxDataStart;
                      {
                          uint256 tailInPtr; // calldata pointer to the end of our proof data
                          /**
                           * Let's build a function table!
                           *
                           * To decode our tx data, we need to iterate over every encoded transaction and call its
                           * associated decoding function. If we did this via a `switch` statement this would be VERY expensive,
                           * due to the large number of JUMPI instructions that would be called.
                           *
                           * Instead, we use function pointers.
                           * The `proofId` field in our encoded proof data is an integer from 0-6,
                           * we can use `proofId` to index a table of function pointers for our respective decoding functions.
                           * This is much faster as there is no conditional branching!
                           */
                          function(uint256, uint256) pure returns (uint256) callfunc; // we're going to use `callfunc` as a function pointer
                          // `functionTable` is a pointer to a table in memory, containing function pointers
                          // Step 1: reserve memory for functionTable
                          uint256 functionTable;
                          assembly {
                              functionTable := mload(0x40)
                              mstore(0x40, add(functionTable, 0x100)) // reserve 256 bytes for function pointers
                          }
                          {
                              // Step 2: copy function pointers into local variables so that inline asm code can access them
                              function(uint256, uint256) pure returns (uint256) t0 = paddingTx;
                              function(uint256, uint256) pure returns (uint256) t1 = depositOrWithdrawTx;
                              function(uint256, uint256) pure returns (uint256) t3 = sendTx;
                              function(uint256, uint256) pure returns (uint256) t4 = accountTx;
                              function(uint256, uint256) pure returns (uint256) t5 = defiDepositOrClaimTx;
                              function(uint256, uint256) pure returns (uint256) t7 = invalidTx;
                              // Step 3: write function pointers into the table!
                              assembly {
                                  mstore(functionTable, t0)
                                  mstore(add(functionTable, 0x20), t1)
                                  mstore(add(functionTable, 0x40), t1)
                                  mstore(add(functionTable, 0x60), t3)
                                  mstore(add(functionTable, 0x80), t4)
                                  mstore(add(functionTable, 0xa0), t5)
                                  mstore(add(functionTable, 0xc0), t5)
                                  mstore(add(functionTable, 0xe0), t7) // a proofId of 7 is not a valid transaction type, set to invalidTx
                              }
                          }
                          uint256 decodedTransactionDataSize;
                          assembly {
                              // Add encoded proof data size to dataSize, minus the 4 bytes of encodedInnerProofData.length.
                              // Set inPtr to point to the length parameter of `bytes calldata proofData`
                              inPtr := add(calldataload(0x04), 0x4) // `proofData = first input parameter. Calldata offset to proofData will be at 0x04. Add 0x04 to account for function signature.
                              
                              // set dataSize to be the length of `bytes calldata proofData`
                              // dataSize := sub(calldataload(inPtr), 0x4)
                              // Advance inPtr to point to the start of proofData
                              inPtr := add(inPtr, 0x20)
                              numTxs := and(
                                  calldataload(add(inPtr, NUM_REAL_TRANSACTIONS_OFFSET)),
                                  0xffffffff
                              )
                              // Get encoded inner proof data size.
                              // add ENCODED_PROOF_DATA_LENGTH_OFFSET to inPtr to point to the correct variable in our header block,
                              // mask off all but 4 least significant bytes as this is a packed 32-bit variable.
                              let encodedInnerDataSize := and(
                                  calldataload(add(inPtr, ENCODED_PROOF_DATA_LENGTH_OFFSET)),
                                  0xffffffff
                              )
                              // Add the size of trimmed zero bytes to dataSize.
                              // load up the rollup size from `proofData`
                              rollupSize := calldataload(add(inPtr, 0x20))
                              // compute the number of bytes our decoded proof data will take up.
                              // i.e. num total txns in the rollup (including padding) * number of public inputs per transaction
                              let decodedInnerDataSize := mul(rollupSize, TX_PUBLIC_INPUT_LENGTH)
                              // we want dataSize to equal: rollup header length + decoded tx length (excluding padding blocks)
                              let numInnerRollups := calldataload(add(inPtr, sub(ROLLUP_HEADER_LENGTH, 0x20)))
                              let numTxsPerRollup := div(rollupSize, numInnerRollups)
                              let numFilledBlocks := div(numTxs, numTxsPerRollup)
                              numFilledBlocks := add(numFilledBlocks, iszero(eq(mul(numFilledBlocks, numTxsPerRollup), numTxs)))
                              decodedTransactionDataSize := mul(mul(numFilledBlocks, numTxsPerRollup), TX_PUBLIC_INPUT_LENGTH)
                              // i.e. current dataSize value + (difference between decoded and encoded data)
                              dataSize := add(ROLLUP_HEADER_LENGTH, decodedTransactionDataSize)
                              // Allocate memory for `proofData`.
                              proofData := mload(0x40)
                              // set free mem ptr to dataSize + 0x20 (to account for the 0x20 bytes for the length param of proofData)
                              // This allocates memory whose size is equal to the rollup header size, plus the data required for
                              // each transaction's decoded tx data (256 bytes * number of non-padding blocks)
                              // only reserve memory for blocks that contain non-padding proofs. These "padding" blocks don't need to be
                              // stored in memory as we don't need their data for any computations
                              mstore(0x40, add(proofData, add(dataSize, 0x20)))
                              // set outPtr to point to the proofData length parameter
                              outPtr := proofData
                              // write dataSize into proofData.length
                              mstore(outPtr, dataSize)
                              // advance outPtr to point to start of proofData
                              outPtr := add(outPtr, 0x20)
                              // Copy rollup header data to `proofData`.
                              calldatacopy(outPtr, inPtr, ROLLUP_HEADER_LENGTH)
                              // Advance outPtr to point to the end of the header data (i.e. the start of the decoded inner transaction data)
                              outPtr := add(outPtr, ROLLUP_HEADER_LENGTH)
                              // Advance inPtr to point to the start of our encoded inner transaction data.
                              // Add (ROLLUP_HEADER_LENGTH + 0x08) to skip over the packed (numRealTransactions, encodedProofData.length) parameters
                              inPtr := add(inPtr, add(ROLLUP_HEADER_LENGTH, 0x08))
                              // Set tailInPtr to point to the end of our encoded transaction data
                              tailInPtr := add(inPtr, encodedInnerDataSize)
                              // Set decodedTxDataStart pointer
                              decodedTxDataStart := outPtr
                          }
                          /**
                           * Start of decoding algorithm
                           *
                           * Iterate over every encoded transaction, load out the first byte (`proofId`) and use it to
                           * jump to the relevant transaction's decoding function
                           */
                          assembly {
                              // subtract 31 bytes off of inPtr, so that the first byte of the encoded transaction data
                              // is located at the least significant byte of calldataload(inPtr)
                              // also adjust tailInPtr as we compare inPtr against tailInPtr
                              inPtr := sub(inPtr, 0x1f)
                              tailInPtr := sub(tailInPtr, 0x1f)
                          }
                          unchecked {
                              for (; tailInPtr > inPtr; ) {
                                  assembly {
                                      // For each tx, the encoding byte determines how we decode the tx calldata
                                      // The encoding byte can take values from 0 to 7; we want to turn these into offsets that can index our function table.
                                      // 1. Access encoding byte via `calldataload(inPtr)`. The least significant byte is our encoding byte. Mask off all but the 3 least sig bits
                                      // 2. Shift left by 5 bits. This is equivalent to multiplying the encoding byte by 32.
                                      // 4. The result will be 1 of 8 offset values (0x00, 0x20, ..., 0xe0) which we can use to retrieve the relevant function pointer from `functionTable`
                                      let encoding := and(calldataload(inPtr), 7)
                                      // store proofId at outPtr.
                                      mstore(outPtr, encoding) // proofId
                                      // use proofId to extract the relevant function pointer from functionTable
                                      callfunc := mload(add(functionTable, shl(5, encoding)))
                                  }
                                  // call the decoding function. Return value will be next required value of inPtr
                                  inPtr = callfunc(inPtr, outPtr);
                                  // advance outPtr by the size of a decoded transaction
                                  outPtr += TX_PUBLIC_INPUT_LENGTH;
                              }
                          }
                      }
                      /**
                       * Compute the public inputs hash
                       *
                       * We need to take our decoded proof data and compute its SHA256 hash.
                       * This hash is fed into our rollup proof as a public input.
                       * If the hash does not match the SHA256 hash computed within the rollup circuit
                       * on the equivalent parameters, the proof will reject.
                       * This check ensures that the transaction data present in calldata are equal to
                       * the transaction data values present in the rollup ZK-SNARK circuit.
                       *
                       * One complication is the structure of the SHA256 hash.
                       * We slice transactions into chunks equal to the number of transactions in the "inner rollup" circuit
                       * (a rollup circuit verifies multiple "inner rollup" circuits, which each verify 3-28 private user transactions.
                       *  This tree structure helps parallelise proof construction)
                       * We then SHA256 hash each transaction *chunk*
                       * Finally we SHA256 hash the above SHA256 hashes to get our public input hash!
                       *
                       * We do the above instead of a straight hash of all of the transaction data,
                       * because it's faster to parallelise proof construction if the majority of the SHA256 hashes are computed in
                       * the "inner rollup" circuit and not the main rollup circuit.
                       */
                      // Step 1: compute the hashes that constitute the inner proofs data
                      bool invalidRollupTopology;
                      assembly {
                          // we need to figure out how many rollup proofs are in this tx and how many user transactions are in each rollup
                          let numRollupTxs := mload(add(proofData, ROLLUP_HEADER_LENGTH))
                          let numJoinSplitsPerRollup := div(rollupSize, numRollupTxs)
                          let rollupDataSize := mul(mul(numJoinSplitsPerRollup, NUMBER_OF_PUBLIC_INPUTS_PER_TX), 32)
                          // Compute the number of inner rollups that don't contain padding proofs
                          let numNotEmptyInnerRollups := div(numTxs, numJoinSplitsPerRollup)
                          numNotEmptyInnerRollups := add(
                              numNotEmptyInnerRollups,
                              iszero(eq(mul(numNotEmptyInnerRollups, numJoinSplitsPerRollup), numTxs))
                          )
                          // Compute the number of inner rollups that only contain padding proofs!
                          // For these "empty" inner rollups, we don't need to compute their public inputs hash directly,
                          // we can use a precomputed value
                          let numEmptyInnerRollups := sub(numRollupTxs, numNotEmptyInnerRollups)
                          let proofdataHashPtr := mload(0x40)
                          // copy the header data into the proofdataHash
                          // header start is at calldataload(0x04) + 0x24 (+0x04 to skip over func signature, +0x20 to skip over byte array length param)
                          calldatacopy(proofdataHashPtr, add(calldataload(0x04), 0x24), ROLLUP_HEADER_LENGTH)
                          // update pointer
                          proofdataHashPtr := add(proofdataHashPtr, ROLLUP_HEADER_LENGTH)
                          // compute the endpoint for the proofdataHashPtr (used as a loop boundary condition)
                          let endPtr := add(proofdataHashPtr, mul(numNotEmptyInnerRollups, 0x20))
                          // iterate over the public inputs for each inner rollup proof and compute their SHA256 hash
                          // better solution here is ... iterate over number of non-padding rollup blocks
                          // and hash those
                          // for padding rollup blocks...just append the zero hash
                          for {
                          } lt(proofdataHashPtr, endPtr) {
                              proofdataHashPtr := add(proofdataHashPtr, 0x20)
                          } {
                              // address(0x02) is the SHA256 precompile address
                              if iszero(staticcall(gas(), 0x02, decodedTxDataStart, rollupDataSize, 0x00, 0x20)) {
                                  revert(0x00, 0x00)
                              }
                              mstore(proofdataHashPtr, mod(mload(0x00), CIRCUIT_MODULUS))
                              decodedTxDataStart := add(decodedTxDataStart, rollupDataSize)
                          }
                          // If there are empty inner rollups, we can use a precomputed hash
                          // of their public inputs instead of computing it directly.
                          if iszero(iszero(numEmptyInnerRollups))
                          {
                              let zeroHash
                              switch numJoinSplitsPerRollup
                              case 32 {
                                  zeroHash := PADDING_ROLLUP_HASH_SIZE_32
                              }
                              case 16 {
                                  zeroHash := PADDING_ROLLUP_HASH_SIZE_16
                              }
                              case 64 {
                                  zeroHash := PADDING_ROLLUP_HASH_SIZE_64
                              }
                              case 1 {
                                  zeroHash := PADDING_ROLLUP_HASH_SIZE_1
                              }
                              case 2 {
                                  zeroHash := PADDING_ROLLUP_HASH_SIZE_2
                              }
                              case 4 {
                                  zeroHash := PADDING_ROLLUP_HASH_SIZE_4
                              }
                              case 8 {
                                  zeroHash := PADDING_ROLLUP_HASH_SIZE_8
                              }
                              default {
                                  invalidRollupTopology := true
                              }
                  
                              endPtr := add(endPtr, mul(numEmptyInnerRollups, 0x20))
                              for {
                              } lt (proofdataHashPtr, endPtr) {
                                  proofdataHashPtr := add(proofdataHashPtr, 0x20)
                              } {
                                  mstore(proofdataHashPtr, zeroHash)
                              }
                          }
                          // compute SHA256 hash of header data + inner public input hashes
                          let startPtr := mload(0x40)
                          if iszero(staticcall(gas(), 0x02, startPtr, sub(proofdataHashPtr, startPtr), 0x00, 0x20)) {
                              revert(0x00, 0x00)
                          }
                          publicInputsHash := mod(mload(0x00), CIRCUIT_MODULUS)
                      }
                      if (invalidRollupTopology)
                      {
                          revert INVALID_ROLLUP_TOPOLOGY();
                      }
                  }
                  /**
                   * @dev Extract the `rollupId` param from the decoded proof data.
                   * represents the rollupId of the next valid rollup block
                   * @param proofData the decoded proof data
                   * @return nextRollupId the expected id of the next rollup block
                   */
                  function getRollupId(bytes memory proofData) internal pure returns (uint256 nextRollupId) {
                      assembly {
                          nextRollupId := mload(add(proofData, 0x20))
                      }
                  }
                  /**
                   * @dev Decode the public inputs component of proofData and compute sha3 hash of merkle roots && dataStartIndex
                   *      The rollup's state is uniquely defined by the following variables:
                   *          * The next empty location in the data root tree (rollupId + 1)
                   *          * The next empty location in the data tree (dataStartIndex + rollupSize)
                   *          * The root of the data tree
                   *          * The root of the nullifier set
                   *          * The root of the data root tree (tree containing all previous roots of the data tree)
                   *          * The root of the defi tree
                   *      Instead of storing all of these variables in storage (expensive!), we store a keccak256 hash of them.
                   *      To validate the correctness of a block's state transition, we must perform the following:
                   *          * Use proof broadcasted inputs to reconstruct the "old" state hash
                   *          * Use proof broadcasted inputs to reconstruct the "new" state hash
                   *          * Validate the old state hash matches what is in storage
                   *          * Set the old state hash to the new state hash
                   *      N.B. we still store dataSize as a separate storage var as proofData does not contain all
                   *           neccessary information to reconstruct its old value.
                   * @param proofData - cryptographic proofData associated with a rollup
                   */
                  function computeRootHashes(bytes memory proofData)
                      internal
                      pure
                      returns (
                          uint256 rollupId,
                          bytes32 oldStateHash,
                          bytes32 newStateHash,
                          uint32 numDataLeaves,
                          uint32 dataStartIndex
                      )
                  {
                      assembly {
                          let dataStart := add(proofData, 0x20) // jump over first word, it's length of data
                          numDataLeaves := shl(1, mload(add(dataStart, 0x20))) // rollupSize * 2 (2 notes per tx)
                          dataStartIndex := mload(add(dataStart, 0x40))
                          // validate numDataLeaves && dataStartIndex are uint32s
                          if or(gt(numDataLeaves, 0xffffffff), gt(dataStartIndex, 0xffffffff))
                          {
                              revert(0,0)
                          }
                          rollupId := mload(dataStart)
                          let mPtr := mload(0x40)
                          mstore(mPtr, rollupId) // old nextRollupId
                          mstore(add(mPtr, 0x20), mload(add(dataStart, 0x60))) // oldDataRoot
                          mstore(add(mPtr, 0x40), mload(add(dataStart, 0xa0))) // oldNullRoot
                          mstore(add(mPtr, 0x60), mload(add(dataStart, 0xe0))) // oldRootRoot
                          mstore(add(mPtr, 0x80), mload(add(dataStart, 0x120))) // oldDefiRoot
                          oldStateHash := keccak256(mPtr, 0xa0)
                          mstore(mPtr, add(rollupId, 0x01)) // new nextRollupId
                          mstore(add(mPtr, 0x20), mload(add(dataStart, 0x80))) // newDataRoot
                          mstore(add(mPtr, 0x40), mload(add(dataStart, 0xc0))) // newNullRoot
                          mstore(add(mPtr, 0x60), mload(add(dataStart, 0x100))) // newRootRoot
                          mstore(add(mPtr, 0x80), mload(add(dataStart, 0x140))) // newDefiRoot
                          newStateHash := keccak256(mPtr, 0xa0)
                      }
                  }
                  /**
                   * @dev extract the `prevDefiInterationHash` from the proofData's rollup header
                   * @param proofData byte array of our input proof data
                   * @return prevDefiInteractionHash the defiInteractionHash of the previous rollup block
                   */
                  function extractPrevDefiInteractionHash(bytes memory proofData)
                      internal
                      pure
                      returns (bytes32 prevDefiInteractionHash)
                  {
                      assembly {
                          prevDefiInteractionHash := mload(add(proofData, PREVIOUS_DEFI_INTERACTION_HASH_OFFSET))
                      }
                  }
                  /**
                   * @dev extract the address we pay the rollup fee to, from the proofData's rollup header
                   * This "rollup beneficiary" address is included as part of the ZK-SNARK circuit data, so that
                   * the rollup provider can explicitly define who should get the fee at the point they generate the ZK-SNARK proof.
                   * (instead of simply sending the fee to msg.sender)
                   * This prevents front-running attacks where an attacker can take somebody else's rollup proof from out of the tx pool and replay it, stealing the fee.
                   * @param proofData byte array of our input proof data
                   * @return rollupBeneficiaryAddress the address we pay this rollup block's fee to
                   */
                  function extractRollupBeneficiaryAddress(bytes memory proofData)
                      internal
                      pure
                      returns (address rollupBeneficiaryAddress)
                  {
                      assembly {
                          rollupBeneficiaryAddress := mload(add(proofData, ROLLUP_BENEFICIARY_OFFSET))
                          // validate rollupBeneficiaryAddress is an address!
                          if gt(rollupBeneficiaryAddress, ADDRESS_MASK) {
                              revert(0, 0)
                          }
                      }
                  }
                  /**
                   * @dev Extract an assetId from the rollup block.
                   * The rollup block contains up to 16 different assets, which can be recovered from the rollup header data.
                   * @param proofData byte array of our input proof data
                   * @param idx The index of the asset we want. assetId = header.assetIds[idx]
                   * @return assetId the 30-bit identifier of an asset. The ERC20 token address is obtained via the mapping `supportedAssets[assetId]`, 
                   */
                  function extractAssetId(
                      bytes memory proofData,
                      uint256 idx
                  ) internal pure returns (uint256 assetId) {
                      assembly {
                          assetId := mload(add(add(add(proofData, BRIDGE_IDS_OFFSET), mul(0x40, NUMBER_OF_BRIDGE_CALLS)), mul(0x20, idx)))
                          // validate assetId is a uint32!
                          if gt(assetId, 0xffffffff) {
                              revert(0, 0)
                          }
                      }
                  }
                  /**
                   * @dev Extract the transaction fee, for a given asset, due to be paid to the rollup beneficiary
                   * The total fee is the sum of the individual fees paid by each transaction in the rollup block.
                   * This sum is computed directly in the rollup circuit, and is present in the rollup header data
                   * @param proofData byte array of our input proof data
                   * @param idx The index of the asset the fee is denominated in
                   * @return totalTxFee 
                   */
                  function extractTotalTxFee(
                      bytes memory proofData,
                      uint256 idx
                  ) internal pure returns (uint256 totalTxFee) {
                      assembly {
                          totalTxFee := mload(add(add(add(proofData, 0x380), mul(0x40, NUMBER_OF_BRIDGE_CALLS)), mul(0x20, idx)))
                      }
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              /**
               * @title TokenTransfers
               * @dev Provides functions to safely call `transfer` and `transferFrom` methods on ERC20 tokens,
               * as well as the ability to call `transfer` and `transferFrom` without bubbling up errors
               */
              library TokenTransfers {
                  bytes4 private constant TRANSFER_SELECTOR = 0xa9059cbb; // bytes4(keccak256('transfer(address,uint256)'));
                  bytes4 private constant TRANSFER_FROM_SELECTOR = 0x23b872dd; // bytes4(keccak256('transferFrom(address,address,uint256)'));
                  /**
                   * @dev Safely call ERC20.transfer, handles tokens that do not throw on transfer failure or do not return transfer result
                   * @param tokenAddress Where does the token live?
                   * @param to Who are we sending tokens to?
                   * @param amount How many tokens are we transferring?
                   */
                  function safeTransferTo(
                      address tokenAddress,
                      address to,
                      uint256 amount
                  ) internal {
                      // The ERC20 token standard states that:
                      // 1. failed transfers must throw
                      // 2. the result of the transfer (success/fail) is returned as a boolean
                      // Some token contracts don't implement the spec correctly and will do one of the following:
                      // 1. Contract does not throw if transfer fails, instead returns false
                      // 2. Contract throws if transfer fails, but does not return any boolean value
                      // We can check for these by evaluating the following:
                      // | call succeeds? (c) | return value (v) | returndatasize == 0 (r)| interpreted result |
                      // | ---                | ---              | ---                    | ---                |
                      // | false              | false            | false                  | transfer fails     |
                      // | false              | false            | true                   | transfer fails     |
                      // | false              | true             | false                  | transfer fails     |
                      // | false              | true             | true                   | transfer fails     |
                      // | true               | false            | false                  | transfer fails     |
                      // | true               | false            | true                   | transfer succeeds  |
                      // | true               | true             | false                  | transfer succeeds  |
                      // | true               | true             | true                   | transfer succeeds  |
                      //
                      // i.e. failure state = !(c && (r || v))
                      assembly {
                          let ptr := mload(0x40)
                          mstore(ptr, TRANSFER_SELECTOR)
                          mstore(add(ptr, 0x4), to)
                          mstore(add(ptr, 0x24), amount)
                          let call_success := call(gas(), tokenAddress, 0, ptr, 0x44, 0x00, 0x20)
                          let result_success := or(iszero(returndatasize()), and(mload(0), 1))
                          if iszero(and(call_success, result_success)) {
                              returndatacopy(0, 0, returndatasize())
                              revert(0, returndatasize())
                          }
                      }
                  }
                  /**
                   * @dev Safely call ERC20.transferFrom, handles tokens that do not throw on transfer failure or do not return transfer result
                   * @param tokenAddress Where does the token live?
                   * @param source Who are we transferring tokens from
                   * @param target Who are we transferring tokens to?
                   * @param amount How many tokens are being transferred?
                   */
                  function safeTransferFrom(
                      address tokenAddress,
                      address source,
                      address target,
                      uint256 amount
                  ) internal {
                      assembly {
                          // call tokenAddress.transferFrom(source, target, value)
                          let mPtr := mload(0x40)
                          mstore(mPtr, TRANSFER_FROM_SELECTOR)
                          mstore(add(mPtr, 0x04), source)
                          mstore(add(mPtr, 0x24), target)
                          mstore(add(mPtr, 0x44), amount)
                          let call_success := call(gas(), tokenAddress, 0, mPtr, 0x64, 0x00, 0x20)
                          let result_success := or(iszero(returndatasize()), and(mload(0), 1))
                          if iszero(and(call_success, result_success)) {
                              returndatacopy(0, 0, returndatasize())
                              revert(0, returndatasize())
                          }
                      }
                  }
                  /**
                   * @dev Calls ERC(tokenAddress).transfer(to, amount). Errors are ignored! Use with caution!
                   * @param tokenAddress Where does the token live?
                   * @param to Who are we sending to?
                   * @param amount How many tokens are being transferred?
                   * @param gasToSend Amount of gas to send the contract. If value is 0, function uses gas() instead
                   */
                  function transferToDoNotBubbleErrors(
                      address tokenAddress,
                      address to,
                      uint256 amount,
                      uint256 gasToSend
                  ) internal {
                      assembly {
                          let callGas := gas()
                          if gasToSend {
                              callGas := gasToSend
                          }
                          let ptr := mload(0x40)
                          mstore(ptr, TRANSFER_SELECTOR)
                          mstore(add(ptr, 0x4), to)
                          mstore(add(ptr, 0x24), amount)
                          pop(call(callGas, tokenAddress, 0, ptr, 0x44, 0x00, 0x00))
                      }
                  }
                  /**
                   * @dev Calls ERC(tokenAddress).transferFrom(source, target, amount). Errors are ignored! Use with caution!
                   * @param tokenAddress Where does the token live?
                   * @param source Who are we transferring tokens from
                   * @param target Who are we transferring tokens to?
                   * @param amount How many tokens are being transferred?
                   * @param gasToSend Amount of gas to send the contract. If value is 0, function uses gas() instead
                   */
                  function transferFromDoNotBubbleErrors(
                      address tokenAddress,
                      address source,
                      address target,
                      uint256 amount,
                      uint256 gasToSend
                  ) internal {
                      assembly {
                          let callGas := gas()
                          if gasToSend {
                              callGas := gasToSend
                          }
                          let mPtr := mload(0x40)
                          mstore(mPtr, TRANSFER_FROM_SELECTOR)
                          mstore(add(mPtr, 0x04), source)
                          mstore(add(mPtr, 0x24), target)
                          mstore(add(mPtr, 0x44), amount)
                          pop(call(callGas, tokenAddress, 0, mPtr, 0x64, 0x00, 0x00))
                      }
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              library RollupProcessorLibrary {
                  error SIGNATURE_ADDRESS_IS_ZERO();
                  error SIGNATURE_RECOVERY_FAILED();
                  error INVALID_SIGNATURE();
                  /**
                   * Extracts the address of the signer with ECDSA. Performs checks on `s` and `v` to
                   * to prevent signature malleability based attacks
                   * @param digest - Hashed data being signed over.
                   * @param signature - ECDSA signature over the secp256k1 elliptic curve.
                   * @param signer - Address that signs the signature.
                   */
                  function validateSignature(
                      bytes32 digest,
                      bytes memory signature,
                      address signer
                  ) internal view {
                      bool result;
                      address recoveredSigner = address(0x0);
                      if (signer == address(0x0)) {
                          revert SIGNATURE_ADDRESS_IS_ZERO();
                      }
                      // prepend "\\x19Ethereum Signed Message:\
              32" to the digest to create the signed message
                      bytes32 message;
                      assembly {
                          mstore(0, '\\x19Ethereum Signed Message:\
              32')
                          mstore(add(0, 28), digest)
                          message := keccak256(0, 60)
                      }
                      assembly {
                          let mPtr := mload(0x40)
                          let byteLength := mload(signature)
                          // store the signature digest
                          mstore(mPtr, message)
                          // load 'v' - we need it for a condition check
                          // add 0x60 to jump over 3 words - length of bytes array, r and s
                          let v := shr(248, mload(add(signature, 0x60))) // bitshifting, to resemble padLeft
                          let s := mload(add(signature, 0x40))
                          /**
                           * Original memory map for input to precompile
                           *
                           * signature : signature + 0x20            message
                           * signature + 0x20 : signature + 0x40     r
                           * signature + 0x40 : signature + 0x60     s
                           * signature + 0x60 : signature + 0x80     v
                           * Desired memory map for input to precompile
                           *
                           * signature : signature + 0x20            message
                           * signature + 0x20 : signature + 0x40     v
                           * signature + 0x40 : signature + 0x60     r
                           * signature + 0x60 : signature + 0x80     s
                           */
                          // store s
                          mstore(add(mPtr, 0x60), s)
                          // store r
                          mstore(add(mPtr, 0x40), mload(add(signature, 0x20)))
                          // store v
                          mstore(add(mPtr, 0x20), v)
                          result := and(
                              and(
                                  // validate s is in lower half order
                                  lt(s, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A1),
                                  and(
                                      // validate signature length == 0x41
                                      eq(byteLength, 0x41),
                                      // validate v == 27 or v == 28
                                      or(eq(v, 27), eq(v, 28))
                                  )
                              ),
                              // validate call to ecrecover precompile succeeds
                              staticcall(gas(), 0x01, mPtr, 0x80, mPtr, 0x20)
                          )
                          // save the recoveredSigner only if the first word in signature is not `message` anymore
                          switch eq(message, mload(mPtr))
                          case 0 {
                              recoveredSigner := mload(mPtr)
                          }
                          mstore(mPtr, byteLength) // and put the byte length back where it belongs
                          // validate that recoveredSigner is not address(0x00)
                          result := and(result, not(iszero(recoveredSigner)))
                      }
                      if (!result) {
                          revert SIGNATURE_RECOVERY_FAILED();
                      }
                      if (recoveredSigner != signer) {
                          revert INVALID_SIGNATURE();
                      }
                  }
                  /**
                   * Extracts the address of the signer with ECDSA. Performs checks on `s` and `v` to
                   * to prevent signature malleability based attacks
                   * This 'Unpacked' version expects 'signature' to be a 92-byte array.
                   * i.e. the `v` parameter occupies a full 32 bytes of memory, not 1 byte
                   * @param hashedMessage - Hashed data being signed over. This function only works if the message has been pre formated to EIP https://eips.ethereum.org/EIPS/eip-191
                   * @param signature - ECDSA signature over the secp256k1 elliptic curve.
                   * @param signer - Address that signs the signature.
                   */
                  function validateSheildSignatureUnpacked(
                      bytes32 hashedMessage,
                      bytes memory signature,
                      address signer
                  ) internal view {
                      bool result;
                      address recoveredSigner = address(0x0);
                      if (signer == address(0x0)) {
                          revert SIGNATURE_ADDRESS_IS_ZERO();
                      }
                      assembly {
                          let mPtr := mload(0x40)
                          // There's a little trick we can pull. We expect `signature` to be a byte array, of length 0x60, with
                          // 'v', 'r' and 's' located linearly in memory. Preceeding this is the length parameter of `signature`.
                          // We *replace* the length param with the signature msg to get a memory block formatted for the precompile
                          // load length as a temporary variable
                          // N.B. we mutate the signature by re-ordering r, s, and v!
                          let byteLength := mload(signature)
                          // store the signature digest
                          mstore(signature, hashedMessage)
                          // load 'v' - we need it for a condition check
                          // add 0x60 to jump over 3 words - length of bytes array, r and s
                          let v := mload(add(signature, 0x60))
                          let s := mload(add(signature, 0x40))
                          /**
                           * Original memory map for input to precompile
                           *
                           * signature : signature + 0x20            message
                           * signature + 0x20 : signature + 0x40     r
                           * signature + 0x40 : signature + 0x60     s
                           * signature + 0x60 : signature + 0x80     v
                           * Desired memory map for input to precompile
                           *
                           * signature : signature + 0x20            message
                           * signature + 0x20 : signature + 0x40     v
                           * signature + 0x40 : signature + 0x60     r
                           * signature + 0x60 : signature + 0x80     s
                           */
                          // move s to v position
                          mstore(add(signature, 0x60), s)
                          // move r to s position
                          mstore(add(signature, 0x40), mload(add(signature, 0x20)))
                          // move v to r position
                          mstore(add(signature, 0x20), v)
                          result := and(
                              and(
                                  // validate s is in lower half order
                                  lt(s, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A1),
                                  and(
                                      // validate signature length == 0x60 (unpacked)
                                      eq(byteLength, 0x60),
                                      // validate v == 27 or v == 28
                                      or(eq(v, 27), eq(v, 28))
                                  )
                              ),
                              // validate call to ecrecover precompile succeeds
                              staticcall(gas(), 0x01, signature, 0x80, signature, 0x20)
                          )
                          // save the recoveredSigner only if the first word in signature is not `message` anymore
                          switch eq(hashedMessage, mload(signature))
                          case 0 {
                              recoveredSigner := mload(signature)
                          }
                          mstore(signature, byteLength) // and put the byte length back where it belongs
                          // validate that recoveredSigner is not address(0x00)
                          result := and(result, not(iszero(recoveredSigner)))
                      }
                      if (!result) {
                          revert SIGNATURE_RECOVERY_FAILED();
                      }
                      if (recoveredSigner != signer) {
                          revert INVALID_SIGNATURE();
                      }
                  }
                  /**
                   * Extracts the address of the signer with ECDSA. Performs checks on `s` and `v` to
                   * to prevent signature malleability based attacks
                   * This 'Unpacked' version expects 'signature' to be a 92-byte array.
                   * i.e. the `v` parameter occupies a full 32 bytes of memory, not 1 byte
                   * @param digest - Hashed data being signed over.
                   * @param signature - ECDSA signature over the secp256k1 elliptic curve.
                   * @param signer - Address that signs the signature.
                   */
                  function validateUnpackedSignature(
                      bytes32 digest,
                      bytes memory signature,
                      address signer
                  ) internal view {
                      bool result;
                      address recoveredSigner = address(0x0);
                      if (signer == address(0x0)) {
                          revert SIGNATURE_ADDRESS_IS_ZERO();
                      }
                      // prepend "\\x19Ethereum Signed Message:\
              32" to the digest to create the signed message
                      bytes32 message;
                      assembly {
                          mstore(0, '\\x19Ethereum Signed Message:\
              32')
                          mstore(28, digest)
                          message := keccak256(0, 60)
                      }
                      assembly {
                          // There's a little trick we can pull. We expect `signature` to be a byte array, of length 0x60, with
                          // 'v', 'r' and 's' located linearly in memory. Preceeding this is the length parameter of `signature`.
                          // We *replace* the length param with the signature msg to get a memory block formatted for the precompile
                          // load length as a temporary variable
                          // N.B. we mutate the signature by re-ordering r, s, and v!
                          let byteLength := mload(signature)
                          // store the signature digest
                          mstore(signature, message)
                          // load 'v' - we need it for a condition check
                          // add 0x60 to jump over 3 words - length of bytes array, r and s
                          let v := mload(add(signature, 0x60))
                          let s := mload(add(signature, 0x40))
                          /**
                           * Original memory map for input to precompile
                           *
                           * signature : signature + 0x20            message
                           * signature + 0x20 : signature + 0x40     r
                           * signature + 0x40 : signature + 0x60     s
                           * signature + 0x60 : signature + 0x80     v
                           * Desired memory map for input to precompile
                           *
                           * signature : signature + 0x20            message
                           * signature + 0x20 : signature + 0x40     v
                           * signature + 0x40 : signature + 0x60     r
                           * signature + 0x60 : signature + 0x80     s
                           */
                          // move s to v position
                          mstore(add(signature, 0x60), s)
                          // move r to s position
                          mstore(add(signature, 0x40), mload(add(signature, 0x20)))
                          // move v to r position
                          mstore(add(signature, 0x20), v)
                          result := and(
                              and(
                                  // validate s is in lower half order
                                  lt(s, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A1),
                                  and(
                                      // validate signature length == 0x60 (unpacked)
                                      eq(byteLength, 0x60),
                                      // validate v == 27 or v == 28
                                      or(eq(v, 27), eq(v, 28))
                                  )
                              ),
                              // validate call to ecrecover precompile succeeds
                              staticcall(gas(), 0x01, signature, 0x80, signature, 0x20)
                          )
                          // save the recoveredSigner only if the first word in signature is not `message` anymore
                          switch eq(message, mload(signature))
                          case 0 {
                              recoveredSigner := mload(signature)
                          }
                          mstore(signature, byteLength) // and put the byte length back where it belongs
                          // validate that recoveredSigner is not address(0x00)
                          result := and(result, not(iszero(recoveredSigner)))
                      }
                      if (!result) {
                          revert SIGNATURE_RECOVERY_FAILED();
                      }
                      if (recoveredSigner != signer) {
                          revert INVALID_SIGNATURE();
                      }
                  }
                  /**
                   * Convert a bytes32 into an ASCII encoded hex string
                   * @param input bytes32 variable
                   * @return result hex-encoded string
                   */
                  function toHexString(bytes32 input) public pure returns (string memory result) {
                      if (uint256(input) == 0x00) {
                          assembly {
                              result := mload(0x40)
                              mstore(result, 0x40)
                              mstore(add(result, 0x20), 0x3030303030303030303030303030303030303030303030303030303030303030)
                              mstore(add(result, 0x40), 0x3030303030303030303030303030303030303030303030303030303030303030)
                              mstore(0x40, add(result, 0x60))
                          }
                          return result;
                      }
                      assembly {
                          result := mload(0x40)
                          let table := add(result, 0x60)
                          // Store lookup table that maps an integer from 0 to 99 into a 2-byte ASCII equivalent
                          // Store lookup table that maps an integer from 0 to ff into a 2-byte ASCII equivalent
                          mstore(add(table, 0x1e), 0x3030303130323033303430353036303730383039306130623063306430653066)
                          mstore(add(table, 0x3e), 0x3130313131323133313431353136313731383139316131623163316431653166)
                          mstore(add(table, 0x5e), 0x3230323132323233323432353236323732383239326132623263326432653266)
                          mstore(add(table, 0x7e), 0x3330333133323333333433353336333733383339336133623363336433653366)
                          mstore(add(table, 0x9e), 0x3430343134323433343434353436343734383439346134623463346434653466)
                          mstore(add(table, 0xbe), 0x3530353135323533353435353536353735383539356135623563356435653566)
                          mstore(add(table, 0xde), 0x3630363136323633363436353636363736383639366136623663366436653666)
                          mstore(add(table, 0xfe), 0x3730373137323733373437353736373737383739376137623763376437653766)
                          mstore(add(table, 0x11e), 0x3830383138323833383438353836383738383839386138623863386438653866)
                          mstore(add(table, 0x13e), 0x3930393139323933393439353936393739383939396139623963396439653966)
                          mstore(add(table, 0x15e), 0x6130613161326133613461356136613761386139616161626163616461656166)
                          mstore(add(table, 0x17e), 0x6230623162326233623462356236623762386239626162626263626462656266)
                          mstore(add(table, 0x19e), 0x6330633163326333633463356336633763386339636163626363636463656366)
                          mstore(add(table, 0x1be), 0x6430643164326433643464356436643764386439646164626463646464656466)
                          mstore(add(table, 0x1de), 0x6530653165326533653465356536653765386539656165626563656465656566)
                          mstore(add(table, 0x1fe), 0x6630663166326633663466356636663766386639666166626663666466656666)
                          /**
                           * Convert `input` into ASCII.
                           *
                           * Slice 2 base-10  digits off of the input, use to index the ASCII lookup table.
                           *
                           * We start from the least significant digits, write results into mem backwards,
                           * this prevents us from overwriting memory despite the fact that each mload
                           * only contains 2 byteso f useful data.
                           **/
                          let base := input
                          function slice(v, tableptr) {
                              mstore(0x1e, mload(add(tableptr, shl(1, and(v, 0xff)))))
                              mstore(0x1c, mload(add(tableptr, shl(1, and(shr(8, v), 0xff)))))
                              mstore(0x1a, mload(add(tableptr, shl(1, and(shr(16, v), 0xff)))))
                              mstore(0x18, mload(add(tableptr, shl(1, and(shr(24, v), 0xff)))))
                              mstore(0x16, mload(add(tableptr, shl(1, and(shr(32, v), 0xff)))))
                              mstore(0x14, mload(add(tableptr, shl(1, and(shr(40, v), 0xff)))))
                              mstore(0x12, mload(add(tableptr, shl(1, and(shr(48, v), 0xff)))))
                              mstore(0x10, mload(add(tableptr, shl(1, and(shr(56, v), 0xff)))))
                              mstore(0x0e, mload(add(tableptr, shl(1, and(shr(64, v), 0xff)))))
                              mstore(0x0c, mload(add(tableptr, shl(1, and(shr(72, v), 0xff)))))
                              mstore(0x0a, mload(add(tableptr, shl(1, and(shr(80, v), 0xff)))))
                              mstore(0x08, mload(add(tableptr, shl(1, and(shr(88, v), 0xff)))))
                              mstore(0x06, mload(add(tableptr, shl(1, and(shr(96, v), 0xff)))))
                              mstore(0x04, mload(add(tableptr, shl(1, and(shr(104, v), 0xff)))))
                              mstore(0x02, mload(add(tableptr, shl(1, and(shr(112, v), 0xff)))))
                              mstore(0x00, mload(add(tableptr, shl(1, and(shr(120, v), 0xff)))))
                          }
                          mstore(result, 0x40)
                          slice(base, table)
                          mstore(add(result, 0x40), mload(0x1e))
                          base := shr(128, base)
                          slice(base, table)
                          mstore(add(result, 0x20), mload(0x1e))
                          mstore(0x40, add(result, 0x60))
                      }
                  }
                  function getSignedMessageForTxId(bytes32 txId) internal pure returns (bytes32 hashedMessage) {
                      // we know this string length is 64 bytes
                      string memory txIdHexString = toHexString(txId);
                      assembly {
                          let mPtr := mload(0x40)
                          mstore(add(mPtr, 32), '\\x19Ethereum Signed Message:\
              210')
                          mstore(add(mPtr, 61), 'Signing this message will allow ')
                          mstore(add(mPtr, 93), 'your pending funds to be spent i')
                          mstore(add(mPtr, 125), 'n Aztec transaction:\
              \
              0x')
                          mstore(add(mPtr, 149), mload(add(txIdHexString, 0x20)))
                          mstore(add(mPtr, 181), mload(add(txIdHexString, 0x40)))
                          mstore(add(mPtr, 213), '\
              \
              IMPORTANT: Only sign the messa')
                          mstore(add(mPtr, 245), 'ge if you trust the client')
                          hashedMessage := keccak256(add(mPtr, 32), 239)
                      }
                  }
              }
              // 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 AddressUpgradeable {
                  /**
                   * @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 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);
                          }
                      }
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              import {RollupProcessor} from '../RollupProcessor.sol';
              /**
               * @title Rollup processor contract
               * @dev Warning: do not deploy in real environments, for testing only
               * Adds some methods to fiddle around with storage vars
               */
              contract TestRollupProcessor is RollupProcessor {
                  constructor(uint256 _escapeBlockLowerBound, uint256 _escapeBlockUpperBound)
                      RollupProcessor(_escapeBlockLowerBound, _escapeBlockUpperBound)
                  {}
                  // Used to pre-fund the rollup with some Eth (to mimic deposited Eth for defi interactions)
                  receive() external payable {}
                  // Used to test we correctly check the length of asyncDefiTransactionHashes
                  function stubAsyncTransactionHashesLength(uint256 size) public {
                      rollupState.numAsyncDefiInteractionHashes = uint16(size);
                  }
                  // Used to test we correctly check length of defiTransactionhashes
                  function stubTransactionHashesLength(uint256 size) public {
                      rollupState.numDefiInteractionHashes = uint16(size);
                      assembly {
                          mstore(0x00, defiInteractionHashes.slot)
                          // Write the 'zero-hash' into the last `numberOfBridgeCalls` entries to ensure that computed
                          // defiInteractionHash will be correct
                          let slot := keccak256(0x00, 0x20)
                          for {
                              let i := 0
                          } lt(i, NUMBER_OF_BRIDGE_CALLS) {
                              i := add(i, 1)
                          } {
                              sstore(
                                  add(slot, sub(size, add(i, 1))),
                                  0x2d25a1e3a51eb293004c4b56abe12ed0da6bca2b4a21936752a85d102593c1b4
                              )
                          }
                      }
                  }
              }
              contract UpgradedTestRollupProcessorV0 is TestRollupProcessor {
                  constructor(uint256 _escapeBlockLowerBound, uint256 _escapeBlockUpperBound)
                      TestRollupProcessor(_escapeBlockLowerBound, _escapeBlockUpperBound)
                  {}
                  function getImplementationVersion() public pure override returns (uint8) {
                      return 0;
                  }
              }
              contract UpgradedTestRollupProcessorV2 is TestRollupProcessor {
                  constructor(uint256 _escapeBlockLowerBound, uint256 _escapeBlockUpperBound)
                      TestRollupProcessor(_escapeBlockLowerBound, _escapeBlockUpperBound)
                  {}
                  function getImplementationVersion() public pure override returns (uint8) {
                      return 2;
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
              import {Ownable} from '@openzeppelin/contracts/access/Ownable.sol';
              import {IUniswapV2Router02} from '@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol';
              import {IUniswapV2Pair} from '@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol';
              import {IWETH} from '@uniswap/v2-periphery/contracts/interfaces/IWETH.sol';
              import {TokenTransfers} from '../libraries/TokenTransfers.sol';
              import {IFeeDistributor} from './interfaces/IFeeDistributor.sol';
              /**
               * @title UniswapV2LibraryErrata
               * @dev Methods from UniswapV2Library that we need. Re-implemented due to the original from @uniswap failing to compile w. Solidity >=0.8.0
               */
              library UniswapV2LibraryErrata {
                  // returns sorted token addresses, used to handle return values from pairs sorted in this order
                  function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
                      require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
                      (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
                      require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
                  }
                  // calculates the CREATE2 address for a pair without making any external calls
                  function pairFor(
                      address factory,
                      address tokenA,
                      address tokenB
                  ) internal pure returns (address pair) {
                      (address token0, address token1) = sortTokens(tokenA, tokenB);
                      uint256 pairUint = uint256(
                          keccak256(
                              abi.encodePacked(
                                  hex'ff',
                                  factory,
                                  keccak256(abi.encodePacked(token0, token1)),
                                  hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
                              )
                          )
                      );
                      assembly {
                          pair := and(pairUint, 0xffffffffffffffffffffffffffffffffffffffff)
                      }
                  }
                  // fetches and sorts the reserves for a pair
                  function getReserves(
                      address factory,
                      address tokenA,
                      address tokenB
                  ) internal view returns (uint256 reserveA, uint256 reserveB) {
                      (address token0, ) = sortTokens(tokenA, tokenB);
                      (uint256 reserve0, uint256 reserve1, ) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
                      (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
                  }
                  // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
                  function getAmountOut(
                      uint256 amountIn,
                      uint256 reserveIn,
                      uint256 reserveOut
                  ) internal pure returns (uint256 amountOut) {
                      require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
                      require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
                      uint256 amountInWithFee = amountIn * 997;
                      uint256 numerator = amountInWithFee * reserveOut;
                      uint256 denominator = reserveIn * 1000 + amountInWithFee;
                      amountOut = numerator / denominator;
                  }
              }
              contract AztecFeeDistributor is IFeeDistributor, Ownable {
                  using TokenTransfers for address;
                  uint256 public override feeLimit = 4e17;
                  address public override aztecFeeClaimer;
                  address public rollupProcessor;
                  uint256 public override convertConstant = 157768 * 20; // gas for calling convert() / 5%
                  address public immutable override router;
                  address public immutable override factory;
                  address public immutable override WETH;
                  constructor(
                      address _feeClaimer,
                      address _rollupProcessor,
                      address _router
                  ) {
                      aztecFeeClaimer = _feeClaimer;
                      rollupProcessor = _rollupProcessor;
                      router = _router;
                      factory = IUniswapV2Router02(_router).factory();
                      WETH = IUniswapV2Router02(_router).WETH();
                  }
                  // @dev top up the designated address by feeLimit
                  receive() external payable {
                      if (msg.sender == rollupProcessor) {
                          if (aztecFeeClaimer.balance < feeLimit) {
                              uint256 toSend = address(this).balance > feeLimit ? feeLimit : address(this).balance;
                              (bool success, ) = aztecFeeClaimer.call{gas: 3000, value: toSend}('');
                              emit FeeReimbursed(aztecFeeClaimer, toSend);
                          }
                      }
                  }
                  function setFeeLimit(uint256 _feeLimit) external override onlyOwner {
                      feeLimit = _feeLimit;
                  }
                  function setConvertConstant(uint256 _convertConstant) external override onlyOwner {
                      convertConstant = _convertConstant;
                  }
                  function setFeeClaimer(address _feeClaimer) external override onlyOwner {
                      aztecFeeClaimer = _feeClaimer;
                  }
                  function txFeeBalance(address assetAddress) public view override returns (uint256) {
                      if (assetAddress == address(0)) {
                          return address(this).balance;
                      } else {
                          return IERC20(assetAddress).balanceOf(address(this));
                      }
                  }
                  function convert(address assetAddress, uint256 minOutputValue)
                      public
                      override
                      onlyOwner
                      returns (uint256 outputValue)
                  {
                      require(assetAddress != address(0), 'Fee Distributor: NOT_A_TOKEN_ASSET');
                      uint256 inputValue = IERC20(assetAddress).balanceOf(address(this));
                      require(inputValue > 0, 'Fee Distributor: EMPTY_BALANCE');
                      if (assetAddress == WETH) {
                          IWETH(WETH).withdraw(inputValue);
                      } else {
                          outputValue = getAmountOut(assetAddress, inputValue);
                          require(outputValue >= minOutputValue, 'Fee Distributor: INSUFFICIENT_OUTPUT_AMOUNT');
                          swapTokensForETH(assetAddress, inputValue, outputValue);
                      }
                      emit Convert(assetAddress, inputValue, outputValue);
                  }
                  function getAmountOut(address assetAddress, uint256 inputValue) internal view returns (uint256 outputValue) {
                      (uint256 reserveIn, uint256 reserveOut) = UniswapV2LibraryErrata.getReserves(factory, assetAddress, WETH);
                      outputValue = UniswapV2LibraryErrata.getAmountOut(inputValue, reserveIn, reserveOut);
                  }
                  function swapTokensForETH(
                      address assetAddress,
                      uint256 inputValue,
                      uint256 outputValue
                  ) internal {
                      address pair = UniswapV2LibraryErrata.pairFor(factory, assetAddress, WETH);
                      assetAddress.safeTransferTo(pair, inputValue);
                      (uint256 amountOut0, uint256 amountOut1) = assetAddress < WETH
                          ? (uint256(0), outputValue)
                          : (outputValue, uint256(0));
                      IUniswapV2Pair(pair).swap(amountOut0, amountOut1, address(this), new bytes(0));
                      IWETH(WETH).withdraw(outputValue);
                  }
              }
              // 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);
                  }
              }
              pragma solidity >=0.6.2;
              import './IUniswapV2Router01.sol';
              interface IUniswapV2Router02 is IUniswapV2Router01 {
                  function removeLiquidityETHSupportingFeeOnTransferTokens(
                      address token,
                      uint liquidity,
                      uint amountTokenMin,
                      uint amountETHMin,
                      address to,
                      uint deadline
                  ) external returns (uint amountETH);
                  function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
                      address token,
                      uint liquidity,
                      uint amountTokenMin,
                      uint amountETHMin,
                      address to,
                      uint deadline,
                      bool approveMax, uint8 v, bytes32 r, bytes32 s
                  ) external returns (uint amountETH);
                  function swapExactTokensForTokensSupportingFeeOnTransferTokens(
                      uint amountIn,
                      uint amountOutMin,
                      address[] calldata path,
                      address to,
                      uint deadline
                  ) external;
                  function swapExactETHForTokensSupportingFeeOnTransferTokens(
                      uint amountOutMin,
                      address[] calldata path,
                      address to,
                      uint deadline
                  ) external payable;
                  function swapExactTokensForETHSupportingFeeOnTransferTokens(
                      uint amountIn,
                      uint amountOutMin,
                      address[] calldata path,
                      address to,
                      uint deadline
                  ) external;
              }
              pragma solidity >=0.5.0;
              interface IUniswapV2Pair {
                  event Approval(address indexed owner, address indexed spender, uint value);
                  event Transfer(address indexed from, address indexed to, uint value);
                  function name() external pure returns (string memory);
                  function symbol() external pure returns (string memory);
                  function decimals() external pure returns (uint8);
                  function totalSupply() external view returns (uint);
                  function balanceOf(address owner) external view returns (uint);
                  function allowance(address owner, address spender) external view returns (uint);
                  function approve(address spender, uint value) external returns (bool);
                  function transfer(address to, uint value) external returns (bool);
                  function transferFrom(address from, address to, uint value) external returns (bool);
                  function DOMAIN_SEPARATOR() external view returns (bytes32);
                  function PERMIT_TYPEHASH() external pure returns (bytes32);
                  function nonces(address owner) external view returns (uint);
                  function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
                  event Mint(address indexed sender, uint amount0, uint amount1);
                  event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
                  event Swap(
                      address indexed sender,
                      uint amount0In,
                      uint amount1In,
                      uint amount0Out,
                      uint amount1Out,
                      address indexed to
                  );
                  event Sync(uint112 reserve0, uint112 reserve1);
                  function MINIMUM_LIQUIDITY() external pure returns (uint);
                  function factory() external view returns (address);
                  function token0() external view returns (address);
                  function token1() external view returns (address);
                  function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
                  function price0CumulativeLast() external view returns (uint);
                  function price1CumulativeLast() external view returns (uint);
                  function kLast() external view returns (uint);
                  function mint(address to) external returns (uint liquidity);
                  function burn(address to) external returns (uint amount0, uint amount1);
                  function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
                  function skim(address to) external;
                  function sync() external;
                  function initialize(address, address) external;
              }
              pragma solidity >=0.5.0;
              interface IWETH {
                  function deposit() external payable;
                  function transfer(address to, uint value) external returns (bool);
                  function withdraw(uint) external;
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              interface IFeeDistributor {
                  event FeeReimbursed(address receiver, uint256 amount);
                  event Convert(address assetAddress, uint256 inputValue, uint256 outputValue);
                  function convertConstant() external view returns (uint256);
                  function feeLimit() external view returns (uint256);
                  function aztecFeeClaimer() external view returns (address);
                  function router() external view returns (address);
                  function factory() external view returns (address);
                  function WETH() external view returns (address);
                  function setFeeClaimer(address _feeClaimer) external;
                  function setFeeLimit(uint256 _feeLimit) external;
                  function setConvertConstant(uint256 _convertConstant) external;
                  function txFeeBalance(address assetAddress) external view returns (uint256);
                  function convert(address assetAddress, uint256 minOutputValue) external returns (uint256 outputValue);
              }
              pragma solidity >=0.6.2;
              interface IUniswapV2Router01 {
                  function factory() external pure returns (address);
                  function WETH() external pure returns (address);
                  function addLiquidity(
                      address tokenA,
                      address tokenB,
                      uint amountADesired,
                      uint amountBDesired,
                      uint amountAMin,
                      uint amountBMin,
                      address to,
                      uint deadline
                  ) external returns (uint amountA, uint amountB, uint liquidity);
                  function addLiquidityETH(
                      address token,
                      uint amountTokenDesired,
                      uint amountTokenMin,
                      uint amountETHMin,
                      address to,
                      uint deadline
                  ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
                  function removeLiquidity(
                      address tokenA,
                      address tokenB,
                      uint liquidity,
                      uint amountAMin,
                      uint amountBMin,
                      address to,
                      uint deadline
                  ) external returns (uint amountA, uint amountB);
                  function removeLiquidityETH(
                      address token,
                      uint liquidity,
                      uint amountTokenMin,
                      uint amountETHMin,
                      address to,
                      uint deadline
                  ) external returns (uint amountToken, uint amountETH);
                  function removeLiquidityWithPermit(
                      address tokenA,
                      address tokenB,
                      uint liquidity,
                      uint amountAMin,
                      uint amountBMin,
                      address to,
                      uint deadline,
                      bool approveMax, uint8 v, bytes32 r, bytes32 s
                  ) external returns (uint amountA, uint amountB);
                  function removeLiquidityETHWithPermit(
                      address token,
                      uint liquidity,
                      uint amountTokenMin,
                      uint amountETHMin,
                      address to,
                      uint deadline,
                      bool approveMax, uint8 v, bytes32 r, bytes32 s
                  ) external returns (uint amountToken, uint amountETH);
                  function swapExactTokensForTokens(
                      uint amountIn,
                      uint amountOutMin,
                      address[] calldata path,
                      address to,
                      uint deadline
                  ) external returns (uint[] memory amounts);
                  function swapTokensForExactTokens(
                      uint amountOut,
                      uint amountInMax,
                      address[] calldata path,
                      address to,
                      uint deadline
                  ) external returns (uint[] memory amounts);
                  function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
                      external
                      payable
                      returns (uint[] memory amounts);
                  function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
                      external
                      returns (uint[] memory amounts);
                  function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
                      external
                      returns (uint[] memory amounts);
                  function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
                      external
                      payable
                      returns (uint[] memory amounts);
                  function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
                  function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
                  function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
                  function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
                  function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              // import {UniswapV2Library} from '@uniswap/v2-periphery/contracts/libraries/UniswapV2Library.sol';
              import {IUniswapV2Router02} from '@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol';
              import {IDefiBridge} from '../interfaces/IDefiBridge.sol';
              import {IERC20Permit} from '../interfaces/IERC20Permit.sol';
              import {AztecTypes} from '../AztecTypes.sol';
              contract UniswapBridge is IDefiBridge {
                  address public immutable rollupProcessor;
                  address public weth;
                  IUniswapV2Router02 router;
                  constructor(address _rollupProcessor, address _router) {
                      rollupProcessor = _rollupProcessor;
                      router = IUniswapV2Router02(_router);
                      weth = router.WETH();
                  }
                  receive() external payable {}
                  function convert(
                      AztecTypes.AztecAsset memory inputAssetA,
                      AztecTypes.AztecAsset memory inputAssetB,
                      AztecTypes.AztecAsset memory outputAssetA,
                      AztecTypes.AztecAsset memory outputAssetB,
                      uint256 totalInputValue,
                      uint256 interactionNonce,
                      uint64, /*auxData*/
                      address
                  )
                      external
                      payable
                      override
                      returns (
                          uint256 outputValueA,
                          uint256 outputValueB,
                          bool isAsync
                      )
                  {
                      // ### INITIALIZATION AND SANITY CHECKS
                      require(msg.sender == rollupProcessor, 'UniswapBridge: INVALID_CALLER');
                      require(
                          inputAssetB.assetType == AztecTypes.AztecAssetType.NOT_USED,
                          'UniswapBridge: EXPECTED_SECOND_INPUT_ASSET_NOT_USED'
                      );
                      require(
                          outputAssetB.assetType == AztecTypes.AztecAssetType.NOT_USED,
                          'UniswapBridge: EXPECTED_SECOND_OUTPUT_ASSET_NOT_USED'
                      );
                      outputValueB = 0;
                      isAsync = false;
                      // ### BRIDGE LOGIC
                      uint256[] memory amounts;
                      uint256 deadline = block.timestamp;
                      if (inputAssetA.assetType == AztecTypes.AztecAssetType.ETH) {
                          require(
                              outputAssetA.assetType != AztecTypes.AztecAssetType.ETH,
                              'UniswapBridge: INPUT_AND_OUTPUT_BOTH_ETH!'
                          );
                          address[] memory path = new address[](2);
                          path[0] = weth;
                          path[1] = outputAssetA.erc20Address;
                          amounts = router.swapExactETHForTokens{value: totalInputValue}(0, path, address(this), deadline);
                          outputValueA = amounts[1];
                          IERC20Permit(outputAssetA.erc20Address).approve(rollupProcessor, outputValueA);
                      } else if (outputAssetA.assetType == AztecTypes.AztecAssetType.ETH) {
                          address[] memory path = new address[](2);
                          path[0] = inputAssetA.erc20Address;
                          path[1] = weth;
                          require(
                              IERC20Permit(inputAssetA.erc20Address).approve(address(router), totalInputValue),
                              'UniswapBridge: APPROVE_FAILED'
                          );
                          amounts = router.swapExactTokensForETH(totalInputValue, 0, path, address(this), deadline);
                          outputValueA = amounts[1];
                          bytes memory payload = abi.encodeWithSignature('receiveEthFromBridge(uint256)', interactionNonce);
                          (bool success, ) = address(rollupProcessor).call{value: outputValueA}(payload);
                      } else {
                          require(
                              inputAssetA.assetType == AztecTypes.AztecAssetType.ERC20,
                              'UniswapBridge: INPUT_ASSET_A_NOT_ETH_OR_ERC20'
                          );
                          require(
                              outputAssetA.assetType == AztecTypes.AztecAssetType.ERC20,
                              'UniswapBridge: OUTPUT_ASSET_A_NOT_ETH_OR_ERC20'
                          );
                          address[] memory path = new address[](3);
                          path[0] = inputAssetA.erc20Address;
                          path[1] = weth;
                          path[2] = outputAssetA.erc20Address;
                          require(
                              IERC20Permit(inputAssetA.erc20Address).approve(address(router), totalInputValue),
                              'UniswapBridge: APPROVE_FAILED'
                          );
                          amounts = router.swapExactTokensForTokens(totalInputValue, 0, path, rollupProcessor, deadline);
                          outputValueA = amounts[2];
                          IERC20Permit(outputAssetA.erc20Address).approve(rollupProcessor, outputValueA);
                      }
                  }
                  function canFinalise(
                      uint256 /*interactionNonce*/
                  ) external pure override returns (bool) {
                      return false;
                  }
                  function finalise(
                      AztecTypes.AztecAsset memory, /*inputAssetA*/
                      AztecTypes.AztecAsset memory, /*inputAssetB*/
                      AztecTypes.AztecAsset memory, /*outputAssetA*/
                      AztecTypes.AztecAsset memory, /*outputAssetB*/
                      uint256, /*interactionNonce*/
                      uint64 /*auxData*/
                  )
                      external
                      payable
                      override
                      returns (
                          uint256,
                          uint256,
                          bool
                      )
                  {
                      require(false);
                      return (0, 0, false);
                  }
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts v4.4.1 (proxy/transparent/ProxyAdmin.sol)
              pragma solidity ^0.8.0;
              import "./TransparentUpgradeableProxy.sol";
              import "../../access/Ownable.sol";
              /**
               * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an
               * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.
               */
              contract ProxyAdmin is Ownable {
                  /**
                   * @dev Returns the current implementation of `proxy`.
                   *
                   * Requirements:
                   *
                   * - This contract must be the admin of `proxy`.
                   */
                  function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {
                      // We need to manually run the static call since the getter cannot be flagged as view
                      // bytes4(keccak256("implementation()")) == 0x5c60da1b
                      (bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b");
                      require(success);
                      return abi.decode(returndata, (address));
                  }
                  /**
                   * @dev Returns the current admin of `proxy`.
                   *
                   * Requirements:
                   *
                   * - This contract must be the admin of `proxy`.
                   */
                  function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) {
                      // We need to manually run the static call since the getter cannot be flagged as view
                      // bytes4(keccak256("admin()")) == 0xf851a440
                      (bool success, bytes memory returndata) = address(proxy).staticcall(hex"f851a440");
                      require(success);
                      return abi.decode(returndata, (address));
                  }
                  /**
                   * @dev Changes the admin of `proxy` to `newAdmin`.
                   *
                   * Requirements:
                   *
                   * - This contract must be the current admin of `proxy`.
                   */
                  function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {
                      proxy.changeAdmin(newAdmin);
                  }
                  /**
                   * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.
                   *
                   * Requirements:
                   *
                   * - This contract must be the admin of `proxy`.
                   */
                  function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {
                      proxy.upgradeTo(implementation);
                  }
                  /**
                   * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See
                   * {TransparentUpgradeableProxy-upgradeToAndCall}.
                   *
                   * Requirements:
                   *
                   * - This contract must be the admin of `proxy`.
                   */
                  function upgradeAndCall(
                      TransparentUpgradeableProxy proxy,
                      address implementation,
                      bytes memory data
                  ) public payable virtual onlyOwner {
                      proxy.upgradeToAndCall{value: msg.value}(implementation, data);
                  }
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)
              pragma solidity ^0.8.0;
              import "../ERC1967/ERC1967Proxy.sol";
              /**
               * @dev This contract implements a proxy that is upgradeable by an admin.
               *
               * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector
               * clashing], which can potentially be used in an attack, this contract uses the
               * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two
               * things that go hand in hand:
               *
               * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
               * that call matches one of the admin functions exposed by the proxy itself.
               * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the
               * implementation. If the admin tries to call a function on the implementation it will fail with an error that says
               * "admin cannot fallback to proxy target".
               *
               * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing
               * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due
               * to sudden errors when trying to call a function from the proxy implementation.
               *
               * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,
               * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.
               */
              contract TransparentUpgradeableProxy is ERC1967Proxy {
                  /**
                   * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and
                   * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.
                   */
                  constructor(
                      address _logic,
                      address admin_,
                      bytes memory _data
                  ) payable ERC1967Proxy(_logic, _data) {
                      assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1));
                      _changeAdmin(admin_);
                  }
                  /**
                   * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.
                   */
                  modifier ifAdmin() {
                      if (msg.sender == _getAdmin()) {
                          _;
                      } else {
                          _fallback();
                      }
                  }
                  /**
                   * @dev Returns the current admin.
                   *
                   * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.
                   *
                   * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
                   * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
                   * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
                   */
                  function admin() external ifAdmin returns (address admin_) {
                      admin_ = _getAdmin();
                  }
                  /**
                   * @dev Returns the current implementation.
                   *
                   * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.
                   *
                   * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
                   * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
                   * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
                   */
                  function implementation() external ifAdmin returns (address implementation_) {
                      implementation_ = _implementation();
                  }
                  /**
                   * @dev Changes the admin of the proxy.
                   *
                   * Emits an {AdminChanged} event.
                   *
                   * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.
                   */
                  function changeAdmin(address newAdmin) external virtual ifAdmin {
                      _changeAdmin(newAdmin);
                  }
                  /**
                   * @dev Upgrade the implementation of the proxy.
                   *
                   * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.
                   */
                  function upgradeTo(address newImplementation) external ifAdmin {
                      _upgradeToAndCall(newImplementation, bytes(""), false);
                  }
                  /**
                   * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified
                   * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the
                   * proxied contract.
                   *
                   * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.
                   */
                  function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {
                      _upgradeToAndCall(newImplementation, data, true);
                  }
                  /**
                   * @dev Returns the current admin.
                   */
                  function _admin() internal view virtual returns (address) {
                      return _getAdmin();
                  }
                  /**
                   * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.
                   */
                  function _beforeFallback() internal virtual override {
                      require(msg.sender != _getAdmin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target");
                      super._beforeFallback();
                  }
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)
              pragma solidity ^0.8.0;
              import "../Proxy.sol";
              import "./ERC1967Upgrade.sol";
              /**
               * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
               * implementation address that can be changed. This address is stored in storage in the location specified by
               * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the
               * implementation behind the proxy.
               */
              contract ERC1967Proxy is Proxy, ERC1967Upgrade {
                  /**
                   * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.
                   *
                   * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded
                   * function call, and allows initializating the storage of the proxy like a Solidity constructor.
                   */
                  constructor(address _logic, bytes memory _data) payable {
                      assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1));
                      _upgradeToAndCall(_logic, _data, false);
                  }
                  /**
                   * @dev Returns the current implementation address.
                   */
                  function _implementation() internal view virtual override returns (address impl) {
                      return ERC1967Upgrade._getImplementation();
                  }
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)
              pragma solidity ^0.8.0;
              /**
               * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
               * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
               * be specified by overriding the virtual {_implementation} function.
               *
               * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
               * different contract through the {_delegate} function.
               *
               * The success and return data of the delegated call will be returned back to the caller of the proxy.
               */
              abstract contract Proxy {
                  /**
                   * @dev Delegates the current call to `implementation`.
                   *
                   * This function does not return to its internal call site, it will return directly to the external caller.
                   */
                  function _delegate(address implementation) internal virtual {
                      assembly {
                          // Copy msg.data. We take full control of memory in this inline assembly
                          // block because it will not return to Solidity code. We overwrite the
                          // Solidity scratch pad at memory position 0.
                          calldatacopy(0, 0, calldatasize())
                          // Call the implementation.
                          // out and outsize are 0 because we don't know the size yet.
                          let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
                          // Copy the returned data.
                          returndatacopy(0, 0, returndatasize())
                          switch result
                          // delegatecall returns 0 on error.
                          case 0 {
                              revert(0, returndatasize())
                          }
                          default {
                              return(0, returndatasize())
                          }
                      }
                  }
                  /**
                   * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function
                   * and {_fallback} should delegate.
                   */
                  function _implementation() internal view virtual returns (address);
                  /**
                   * @dev Delegates the current call to the address returned by `_implementation()`.
                   *
                   * This function does not return to its internal call site, it will return directly to the external caller.
                   */
                  function _fallback() internal virtual {
                      _beforeFallback();
                      _delegate(_implementation());
                  }
                  /**
                   * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
                   * function in the contract matches the call data.
                   */
                  fallback() external payable virtual {
                      _fallback();
                  }
                  /**
                   * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
                   * is empty.
                   */
                  receive() external payable virtual {
                      _fallback();
                  }
                  /**
                   * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
                   * call, or as part of the Solidity `fallback` or `receive` functions.
                   *
                   * If overridden should call `super._beforeFallback()`.
                   */
                  function _beforeFallback() internal virtual {}
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)
              pragma solidity ^0.8.2;
              import "../beacon/IBeacon.sol";
              import "../../interfaces/draft-IERC1822.sol";
              import "../../utils/Address.sol";
              import "../../utils/StorageSlot.sol";
              /**
               * @dev This abstract contract provides getters and event emitting update functions for
               * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
               *
               * _Available since v4.1._
               *
               * @custom:oz-upgrades-unsafe-allow delegatecall
               */
              abstract contract ERC1967Upgrade {
                  // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
                  bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
                  /**
                   * @dev Storage slot with the address of the current implementation.
                   * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
                   * validated in the constructor.
                   */
                  bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
                  /**
                   * @dev Emitted when the implementation is upgraded.
                   */
                  event Upgraded(address indexed implementation);
                  /**
                   * @dev Returns the current implementation address.
                   */
                  function _getImplementation() internal view returns (address) {
                      return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
                  }
                  /**
                   * @dev Stores a new address in the EIP1967 implementation slot.
                   */
                  function _setImplementation(address newImplementation) private {
                      require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
                      StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
                  }
                  /**
                   * @dev Perform implementation upgrade
                   *
                   * Emits an {Upgraded} event.
                   */
                  function _upgradeTo(address newImplementation) internal {
                      _setImplementation(newImplementation);
                      emit Upgraded(newImplementation);
                  }
                  /**
                   * @dev Perform implementation upgrade with additional setup call.
                   *
                   * Emits an {Upgraded} event.
                   */
                  function _upgradeToAndCall(
                      address newImplementation,
                      bytes memory data,
                      bool forceCall
                  ) internal {
                      _upgradeTo(newImplementation);
                      if (data.length > 0 || forceCall) {
                          Address.functionDelegateCall(newImplementation, data);
                      }
                  }
                  /**
                   * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
                   *
                   * Emits an {Upgraded} event.
                   */
                  function _upgradeToAndCallUUPS(
                      address newImplementation,
                      bytes memory data,
                      bool forceCall
                  ) internal {
                      // Upgrades from old implementations will perform a rollback test. This test requires the new
                      // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
                      // this special case will break upgrade paths from old UUPS implementation to new ones.
                      if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {
                          _setImplementation(newImplementation);
                      } else {
                          try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
                              require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
                          } catch {
                              revert("ERC1967Upgrade: new implementation is not UUPS");
                          }
                          _upgradeToAndCall(newImplementation, data, forceCall);
                      }
                  }
                  /**
                   * @dev Storage slot with the admin of the contract.
                   * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
                   * validated in the constructor.
                   */
                  bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
                  /**
                   * @dev Emitted when the admin account has changed.
                   */
                  event AdminChanged(address previousAdmin, address newAdmin);
                  /**
                   * @dev Returns the current admin.
                   */
                  function _getAdmin() internal view returns (address) {
                      return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
                  }
                  /**
                   * @dev Stores a new address in the EIP1967 admin slot.
                   */
                  function _setAdmin(address newAdmin) private {
                      require(newAdmin != address(0), "ERC1967: new admin is the zero address");
                      StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
                  }
                  /**
                   * @dev Changes the admin of the proxy.
                   *
                   * Emits an {AdminChanged} event.
                   */
                  function _changeAdmin(address newAdmin) internal {
                      emit AdminChanged(_getAdmin(), newAdmin);
                      _setAdmin(newAdmin);
                  }
                  /**
                   * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
                   * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
                   */
                  bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
                  /**
                   * @dev Emitted when the beacon is upgraded.
                   */
                  event BeaconUpgraded(address indexed beacon);
                  /**
                   * @dev Returns the current beacon.
                   */
                  function _getBeacon() internal view returns (address) {
                      return StorageSlot.getAddressSlot(_BEACON_SLOT).value;
                  }
                  /**
                   * @dev Stores a new beacon in the EIP1967 beacon slot.
                   */
                  function _setBeacon(address newBeacon) private {
                      require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract");
                      require(
                          Address.isContract(IBeacon(newBeacon).implementation()),
                          "ERC1967: beacon implementation is not a contract"
                      );
                      StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;
                  }
                  /**
                   * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
                   * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
                   *
                   * Emits a {BeaconUpgraded} event.
                   */
                  function _upgradeBeaconToAndCall(
                      address newBeacon,
                      bytes memory data,
                      bool forceCall
                  ) internal {
                      _setBeacon(newBeacon);
                      emit BeaconUpgraded(newBeacon);
                      if (data.length > 0 || forceCall) {
                          Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
                      }
                  }
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)
              pragma solidity ^0.8.0;
              /**
               * @dev This is the interface that {BeaconProxy} expects of its beacon.
               */
              interface IBeacon {
                  /**
                   * @dev Must return an address that can be used as a delegate call target.
                   *
                   * {BeaconProxy} will check that this address is a contract.
                   */
                  function implementation() external view returns (address);
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)
              pragma solidity ^0.8.0;
              /**
               * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
               * proxy whose upgrades are fully controlled by the current implementation.
               */
              interface IERC1822Proxiable {
                  /**
                   * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
                   * address.
                   *
                   * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
                   * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
                   * function revert if invoked through a proxy.
                   */
                  function proxiableUUID() external view returns (bytes32);
              }
              // 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);
                          }
                      }
                  }
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)
              pragma solidity ^0.8.0;
              /**
               * @dev Library for reading and writing primitive types to specific storage slots.
               *
               * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
               * This library helps with reading and writing to such slots without the need for inline assembly.
               *
               * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
               *
               * Example usage to set ERC1967 implementation slot:
               * ```
               * contract ERC1967 {
               *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
               *
               *     function _getImplementation() internal view returns (address) {
               *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
               *     }
               *
               *     function _setImplementation(address newImplementation) internal {
               *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
               *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
               *     }
               * }
               * ```
               *
               * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
               */
              library StorageSlot {
                  struct AddressSlot {
                      address value;
                  }
                  struct BooleanSlot {
                      bool value;
                  }
                  struct Bytes32Slot {
                      bytes32 value;
                  }
                  struct Uint256Slot {
                      uint256 value;
                  }
                  /**
                   * @dev Returns an `AddressSlot` with member `value` located at `slot`.
                   */
                  function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
                      assembly {
                          r.slot := slot
                      }
                  }
                  /**
                   * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
                   */
                  function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
                      assembly {
                          r.slot := slot
                      }
                  }
                  /**
                   * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
                   */
                  function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
                      assembly {
                          r.slot := slot
                      }
                  }
                  /**
                   * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
                   */
                  function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
                      assembly {
                          r.slot := slot
                      }
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              import {TransparentUpgradeableProxy} from '@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol';
              contract ProxyDeployer {
                  event ProxyDeployed(address logic, address admin, bytes32 salt, address proxy);
                  constructor() {}
                  function deployProxy(
                      address _logic,
                      address _admin,
                      bytes memory _data,
                      bytes32 _salt
                  ) public returns (address) {
                      TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy{salt: _salt}(_logic, _admin, _data);
                      emit ProxyDeployed(_logic, _admin, _salt, address(proxy));
                      return address(proxy);
                  }
              }
              // SPDX-License-Identifier: MIT
              pragma solidity >=0.8.4;
              import {TransparentUpgradeableProxy} from '@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol';
              import {ProxyAdmin} from '@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol';// SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              import {IDefiBridge} from './interfaces/IDefiBridge.sol';
              import {AztecTypes} from './AztecTypes.sol';
              import {TokenTransfers} from './libraries/TokenTransfers.sol';
              contract DefiBridgeProxy {
                  error OUTPUT_A_EXCEEDS_252_BITS(uint256 outputValue);
                  error OUTPUT_B_EXCEEDS_252_BITS(uint256 outputValue);
                  error ASYNC_NONZERO_OUTPUT_VALUES(uint256 outputValueA, uint256 outputValueB);
                  error INSUFFICIENT_ETH_PAYMENT();
                  /**
                   * @dev Use interaction result data to pull tokens into DefiBridgeProxy
                   * @param asset The AztecAsset being targetted
                   * @param outputValue The claimed output value provided by the bridge
                   * @param interactionNonce The defi interaction nonce of the interaction
                   * @param bridgeContract Address of the defi bridge contract
                   * @param ethPaymentsSlot The slot value of the `ethPayments` storage mapping in RollupProcessor.sol!
                   * More details on ethPaymentsSlot are in the comments for the `convert` function
                   */
                  function recoverTokens(
                      AztecTypes.AztecAsset memory asset,
                      uint256 outputValue,
                      uint256 interactionNonce,
                      address bridgeContract,
                      uint256 ethPaymentsSlot
                  ) internal {
                      if (outputValue == 0) {
                          return;
                      }
                      if (asset.assetType == AztecTypes.AztecAssetType.ETH) {
                          uint256 ethPayment;
                          uint256 ethPaymentsSlotBase;
                          assembly {
                              mstore(0x00, interactionNonce)
                              mstore(0x20, ethPaymentsSlot)
                              ethPaymentsSlotBase := keccak256(0x00, 0x40)
                              ethPayment := sload(ethPaymentsSlotBase) // ethPayment = ethPayments[interactionNonce]
                          }
                          if (outputValue > ethPayment) {
                              revert INSUFFICIENT_ETH_PAYMENT();
                          }
                          assembly {
                              sstore(ethPaymentsSlotBase, 0) // ethPayments[interactionNonce] = 0;
                          }
                      } else if (asset.assetType == AztecTypes.AztecAssetType.ERC20) {
                          TokenTransfers.safeTransferFrom(asset.erc20Address, bridgeContract, address(this), outputValue);
                      }
                  }
                  /**
                   * @dev Convert input assets into output assets via calling a defi bridge contract
                   * @param bridgeAddress Address of the defi bridge contract
                   * @param inputAssetA First input asset
                   * @param inputAssetB Second input asset. Is either VIRTUAL or NOT_USED (checked by RollupProcessor)
                   * @param outputAssetA First output asset
                   * @param outputAssetB Second output asset
                   * @param totalInputValue The total amount of inputAssetA to be sent to the bridge
                   * @param interactionNonce Integer that is unique for a given defi interaction
                   * @param auxInputData Optional custom data to be sent to the bridge (defined in the L2 SNARK circuits when creating claim notes)
                   * @param ethPaymentsSlot The slot value of the `ethPayments` storage mapping in RollupProcessor.sol!
                   * @param rollupBeneficiary The address that should be payed any fees / subsidy for executing this bridge.
                   * We assume this contract is called from the RollupProcessor via `delegateCall`,
                   * if not... this contract behaviour is undefined! So don't do that.
                   * The idea here is that, if the defi bridge has returned native ETH, they will do so via calling
                   * `RollupProcessor.receiveEthPayment(uint256 interactionNonce)`.
                   * To summarise the issue, we must solve for the following:
                   * 1. We need to be able to read the `ethPayments` state variable to determine how much Eth has been sent (and reset it)
                   * 2. We must encapsulate the entire defi interaction flow via a 'delegatecall' so that we can safely revert
                   *    all token/eth transfers if the defi interaction fails, *without* throwing the entire rollup transaction
                   * 3. We don't want to directly call `delegateCall` on RollupProcessor.sol to minimise the attack surface against delegatecall re-entrancy exploits
                   *
                   * Solution is to pass the ethPayments.slot storage slot in as a param during the delegateCall and update in assembly via `sstore`
                   * We could achieve the same effect via getters/setters on the function, but that would be expensive as that would trigger additional `call` opcodes.
                   * We could *also* just hard-code the slot value, but that is quite brittle as
                   * any re-ordering of storage variables during development would require updating the hardcoded constant
                   *
                   * @return outputValueA outputvalueB isAsync
                   * outputValueA = the number of outputAssetA tokens we must recover from the bridge
                   * outputValueB = the number of outputAssetB tokens we must recover from the bridge
                   * isAsync describes whether the defi interaction has instantly resolved, or if the interaction must be finalised in a future Eth block
                   * if isAsync == true, outputValueA and outputValueB must both equal 0
                   */
                  function convert(
                      address bridgeAddress,
                      AztecTypes.AztecAsset memory inputAssetA,
                      AztecTypes.AztecAsset memory inputAssetB,
                      AztecTypes.AztecAsset memory outputAssetA,
                      AztecTypes.AztecAsset memory outputAssetB,
                      uint256 totalInputValue,
                      uint256 interactionNonce,
                      uint256 auxInputData, // (auxData)
                      uint256 ethPaymentsSlot,
                      address rollupBeneficiary
                  )
                      external
                      returns (
                          uint256 outputValueA,
                          uint256 outputValueB,
                          bool isAsync
                      )
                  {
                      if (inputAssetA.assetType == AztecTypes.AztecAssetType.ERC20) {
                          // Transfer totalInputValue to the bridge contract if erc20. ETH is sent on call to convert.
                          TokenTransfers.safeTransferTo(inputAssetA.erc20Address, bridgeAddress, totalInputValue);
                      }
                      if (inputAssetB.assetType == AztecTypes.AztecAssetType.ERC20) {
                          // Transfer totalInputValue to the bridge contract if erc20. ETH is sent on call to convert.
                          TokenTransfers.safeTransferTo(inputAssetB.erc20Address, bridgeAddress, totalInputValue);
                      }
                      // Call bridge.convert(), which will return output values for the two output assets.
                      // If input is ETH, send it along with call to convert.
                      uint256 ethValue = (inputAssetA.assetType == AztecTypes.AztecAssetType.ETH ||
                          inputAssetB.assetType == AztecTypes.AztecAssetType.ETH)
                          ? totalInputValue
                          : 0;
                      (outputValueA, outputValueB, isAsync) = IDefiBridge(bridgeAddress).convert{value: ethValue}(
                          inputAssetA,
                          inputAssetB,
                          outputAssetA,
                          outputAssetB,
                          totalInputValue,
                          interactionNonce,
                          uint64(auxInputData),
                          rollupBeneficiary
                      );
                      if (isAsync) {
                          if (outputValueA > 0 || outputValueB > 0) {
                              revert ASYNC_NONZERO_OUTPUT_VALUES(outputValueA, outputValueB);
                          }
                      } else {
                          address bridgeAddressCopy = bridgeAddress; // stack overflow workaround
                          if (outputValueA >= (1 << 252)) {
                              revert OUTPUT_A_EXCEEDS_252_BITS(outputValueA);
                          }
                          if (outputValueB >= (1 << 252)) {
                              revert OUTPUT_B_EXCEEDS_252_BITS(outputValueB);
                          }
                          recoverTokens(outputAssetA, outputValueA, interactionNonce, bridgeAddressCopy, ethPaymentsSlot);
                          recoverTokens(outputAssetB, outputValueB, interactionNonce, bridgeAddressCopy, ethPaymentsSlot);
                      }
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              import {Decoder} from '../Decoder.sol';
              import {IVerifier} from '../interfaces/IVerifier.sol';
              /**
               * TODO: Pretty sure this should all be removed and we should be testing decodeProof response directly.
               */
              contract HashInputs is Decoder {
                  IVerifier public verifier;
                  error PUBLIC_INPUTS_HASH_VERIFICATION_FAILED(uint256, uint256);
                  constructor(address _verifierAddress) {
                      verifier = IVerifier(_verifierAddress);
                  }
                  function computePublicInputHash(
                      bytes calldata /* encodedProofData */
                  ) external view returns (bytes32) {
                      decodeProof();
                      return 0;
                  }
                  function verifyProofTest(
                      bytes calldata /* encodedProofData */
                  ) external view {
                      (, , uint256 publicInputsHash) = decodeProof();
                      uint256 broadcastedDataSize = ROLLUP_HEADER_LENGTH + 8; // add 8 bytes for two packed params at end of header
                      bool proof_verified;
                      assembly {
                          /**
                           * Validate correctness of zk proof.
                           *
                           * 1st Item is to format verifier calldata.
                           **/
                          // Our first input param `encodedProofData` contains the concatenation of
                          // encoded 'broadcasted inputs' and the actual zk proof data.
                          // (The `boadcasted inputs` is converted into a 32-byte SHA256 hash, which is
                          // validated to equal the first public inputs of the zk proof. This is done in `Decoder.sol`).
                          // We need to identify the location in calldata that points to the start of the zk proof data.
                          // Step 1: compute size of zk proof data and its calldata pointer.
                          /**
                              Data layout for `bytes encodedProofData`...
                              0x00 : 0x20 : length of array
                              0x20 : 0x20 + header : root rollup header data
                              0x20 + header : 0x24 + header : X, the length of encoded inner join-split public inputs
                              0x24 + header : 0x24 + header + X : (inner join-split public inputs)
                              0x24 + header + X : 0x28 + header + X : Y, the length of the zk proof data
                              0x28 + header + X : 0x28 + haeder + X + Y : zk proof data
                              We need to recover the numeric value of `0x28 + header + X` and `Y`
                           **/
                          // Begin by getting length of encoded inner join-split public inputs.
                          // `calldataload(0x04)` points to start of bytes array. Add 0x24 to skip over length param and function signature.
                          // The calldata param *after* the header is the length of the pub inputs array. However it is a packed 4-byte param.
                          // To extract it, we subtract 28 bytes from the calldata pointer and mask off all but the 4 least significant bytes.
                          let encodedInnerDataSize := and(
                              calldataload(add(add(calldataload(0x04), 0x24), sub(ROLLUP_HEADER_LENGTH, 0x18))),
                              0xffffffff
                          )
                          // broadcastedDataSize = inner join-split pubinput size + header size + 8 bytes (skip over zk proof length param)
                          broadcastedDataSize := add(broadcastedDataSize, encodedInnerDataSize)
                          // Compute zk proof data size by subtracting broadcastedDataSize from overall length of bytes encodedProofsData
                          let zkProofDataSize := sub(calldataload(add(calldataload(0x04), 0x04)), broadcastedDataSize)
                          // Compute calldata pointer to start of zk proof data by adding calldata offset to broadcastedDataSize
                          // (+0x24 skips over function signature and numRealTxs param and length param of bytes encodedProofData)
                          // add +4 for new param or not?
                          let zkProofDataPtr := add(broadcastedDataSize, add(calldataload(0x04), 0x24))
                          // Step 2: Format calldata for verifier contract call.
                          // Get free memory pointer - we copy calldata into memory starting here
                          let dataPtr := mload(0x40)
                          // We call the function `verify(bytes,uint256)`
                          // The function signature is 0xac318c5d
                          // Calldata map is:
                          // 0x00 - 0x04 : 0xac318c5d
                          // 0x04 - 0x24 : 0x40 (number of bytes between 0x04 and the start of the `proofData` array at 0x44)
                          // 0x24 - 0x44 : publicInputsHash
                          // 0x44 - .... : proofData
                          mstore8(dataPtr, 0xac)
                          mstore8(add(dataPtr, 0x01), 0x31)
                          mstore8(add(dataPtr, 0x02), 0x8c)
                          mstore8(add(dataPtr, 0x03), 0x5d)
                          mstore(add(dataPtr, 0x04), 0x40)
                          mstore(add(dataPtr, 0x24), publicInputsHash)
                          mstore(add(dataPtr, 0x44), zkProofDataSize) // length of zkProofData bytes array
                          calldatacopy(add(dataPtr, 0x64), zkProofDataPtr, zkProofDataSize) // copy the zk proof data into memory
                          // Step 3: Call our verifier contract. If does not return any values, but will throw an error if the proof is not valid
                          // i.e. verified == false if proof is not valid
                          proof_verified := staticcall(gas(), sload(verifier.slot), dataPtr, add(zkProofDataSize, 0x64), 0x00, 0x00)
                      }
                      if (!proof_verified) {
                          assembly {
                              returndatacopy(0, 0, returndatasize())
                              revert(0, returndatasize())
                          }
                      }
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              // gas count: 299,341 (includes 21,000 tx base cost, includes cost of 3 pub inputs. Cost of circuit without pub inputs is 298,312)
              import {IVerifier} from '../interfaces/IVerifier.sol';
              import {VerificationKey} from './keys/VerificationKey.sol';
              import {StandardTypes} from './cryptography/StandardTypes.sol';
              /**
               * @title Standard Plonk proof verification contract
               * @dev Top level Plonk proof verification contract, which allows Plonk proof to be verified
               *
               * Copyright 2022 Aztec
               *
               * Licensed under the GNU General Public License, Version 2.0 (the "License");
               * you may not use this file except in compliance with the License.
               *
               * This program is distributed in the hope that it will be useful,
               * but WITHOUT ANY WARRANTY; without even the implied warranty of
               * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
               * GNU General Public License for more details.
               *
               * You should have received a copy of the GNU General Public License
               * along with this program.  If not, see <https://www.gnu.org/licenses/>.
               */
              contract StandardVerifier is IVerifier {
                  // VERIFICATION KEY MEMORY LOCATIONS
                  uint256 internal constant N_LOC =                                    0x200 + 0x00;
                  uint256 internal constant NUM_INPUTS_LOC =                           0x200 + 0x20;
                  uint256 internal constant OMEGA_LOC =                                0x200 + 0x40;
                  uint256 internal constant DOMAIN_INVERSE_LOC =                       0x200 + 0x60;
                  uint256 internal constant Q1_X_LOC =                                 0x200 + 0x80;
                  uint256 internal constant Q1_Y_LOC =                                 0x200 + 0xa0;
                  uint256 internal constant Q2_X_LOC =                                 0x200 + 0xc0;
                  uint256 internal constant Q2_Y_LOC =                                 0x200 + 0xe0;
                  uint256 internal constant Q3_X_LOC =                                 0x200 + 0x100;
                  uint256 internal constant Q3_Y_LOC =                                 0x200 + 0x120;
                  uint256 internal constant QM_X_LOC =                                 0x200 + 0x140;
                  uint256 internal constant QM_Y_LOC =                                 0x200 + 0x160;
                  uint256 internal constant QC_X_LOC =                                 0x200 + 0x180;
                  uint256 internal constant QC_Y_LOC =                                 0x200 + 0x1a0;
                  uint256 internal constant SIGMA1_X_LOC =                             0x200 + 0x1c0;
                  uint256 internal constant SIGMA1_Y_LOC =                             0x200 + 0x1e0;
                  uint256 internal constant SIGMA2_X_LOC =                             0x200 + 0x200;
                  uint256 internal constant SIGMA2_Y_LOC =                             0x200 + 0x220;
                  uint256 internal constant SIGMA3_X_LOC =                             0x200 + 0x240;
                  uint256 internal constant SIGMA3_Y_LOC =                             0x200 + 0x260;
                  uint256 internal constant CONTAINS_RECURSIVE_PROOF_LOC =             0x200 + 0x280;
                  uint256 internal constant RECURSIVE_PROOF_PUBLIC_INPUT_INDICES_LOC = 0x200 + 0x2a0;
                  uint256 internal constant G2X_X0_LOC =                               0x200 + 0x2c0;
                  uint256 internal constant G2X_X1_LOC =                               0x200 + 0x2e0;
                  uint256 internal constant G2X_Y0_LOC =                               0x200 + 0x300;
                  uint256 internal constant G2X_Y1_LOC =                               0x200 + 0x320;
                  // 26
                  // ### PROOF DATA MEMORY LOCATIONS
                  uint256 internal constant W1_X_LOC =                                 0x200 + 0x340 + 0x00;
                  uint256 internal constant W1_Y_LOC =                                 0x200 + 0x340 + 0x20;
                  uint256 internal constant W2_X_LOC =                                 0x200 + 0x340 + 0x40;
                  uint256 internal constant W2_Y_LOC =                                 0x200 + 0x340 + 0x60;
                  uint256 internal constant W3_X_LOC =                                 0x200 + 0x340 + 0x80;
                  uint256 internal constant W3_Y_LOC =                                 0x200 + 0x340 + 0xa0;
                  uint256 internal constant Z_X_LOC =                                  0x200 + 0x340 + 0xc0;
                  uint256 internal constant Z_Y_LOC =                                  0x200 + 0x340 + 0xe0;
                  uint256 internal constant T1_X_LOC =                                 0x200 + 0x340 + 0x100;
                  uint256 internal constant T1_Y_LOC =                                 0x200 + 0x340 + 0x120;
                  uint256 internal constant T2_X_LOC =                                 0x200 + 0x340 + 0x140;
                  uint256 internal constant T2_Y_LOC =                                 0x200 + 0x340 + 0x160;
                  uint256 internal constant T3_X_LOC =                                 0x200 + 0x340 + 0x180;
                  uint256 internal constant T3_Y_LOC =                                 0x200 + 0x340 + 0x1a0;
                  uint256 internal constant W1_EVAL_LOC =                              0x200 + 0x340 + 0x1c0;
                  uint256 internal constant W2_EVAL_LOC =                              0x200 + 0x340 + 0x1e0;
                  uint256 internal constant W3_EVAL_LOC =                              0x200 + 0x340 + 0x200;
                  uint256 internal constant SIGMA1_EVAL_LOC =                          0x200 + 0x340 + 0x220;
                  uint256 internal constant SIGMA2_EVAL_LOC =                          0x200 + 0x340 + 0x240;
                  uint256 internal constant Z_OMEGA_EVAL_LOC =                         0x200 + 0x340 + 0x260;
                  uint256 internal constant PI_Z_X_LOC =                               0x200 + 0x340 + 0x280;
                  uint256 internal constant PI_Z_Y_LOC =                               0x200 + 0x340 + 0x2a0;
                  uint256 internal constant PI_Z_OMEGA_X_LOC =                         0x200 + 0x340 + 0x2c0;
                  uint256 internal constant PI_Z_OMEGA_Y_LOC =                         0x200 + 0x340 + 0x2e0;
                  // 25
                  // ### CHALLENGES MEMORY OFFSETS
                  uint256 internal constant C_BETA_LOC =                               0x200 + 0x340 + 0x300 + 0x00;
                  uint256 internal constant C_GAMMA_LOC =                              0x200 + 0x340 + 0x300 + 0x20;
                  uint256 internal constant C_ALPHA_LOC =                              0x200 + 0x340 + 0x300 + 0x40;
                  uint256 internal constant C_ARITHMETIC_ALPHA_LOC =                   0x200 + 0x340 + 0x300 + 0x60;
                  uint256 internal constant C_ZETA_LOC =                               0x200 + 0x340 + 0x300 + 0x80;
                  uint256 internal constant C_CURRENT_LOC =                            0x200 + 0x340 + 0x300 + 0xa0;
                  uint256 internal constant C_V0_LOC =                                 0x200 + 0x340 + 0x300 + 0xc0;
                  uint256 internal constant C_V1_LOC =                                 0x200 + 0x340 + 0x300 + 0xe0;
                  uint256 internal constant C_V2_LOC =                                 0x200 + 0x340 + 0x300 + 0x100;
                  uint256 internal constant C_V3_LOC =                                 0x200 + 0x340 + 0x300 + 0x120;
                  uint256 internal constant C_V4_LOC =                                 0x200 + 0x340 + 0x300 + 0x140;
                  uint256 internal constant C_V5_LOC =                                 0x200 + 0x340 + 0x300 + 0x160;
                  uint256 internal constant C_U_LOC =                                  0x200 + 0x340 + 0x300 + 0x180;
                  // 13
                  // ### LOCAL VARIABLES MEMORY OFFSETS
                  uint256 internal constant DELTA_NUMERATOR_LOC =                      0x200 + 0x340 + 0x300 + 0x1a0 + 0x00;
                  uint256 internal constant DELTA_DENOMINATOR_LOC =                    0x200 + 0x340 + 0x300 + 0x1a0 + 0x20;
                  uint256 internal constant ZETA_POW_N_LOC =                           0x200 + 0x340 + 0x300 + 0x1a0 + 0x40;
                  uint256 internal constant PUBLIC_INPUT_DELTA_LOC =                   0x200 + 0x340 + 0x300 + 0x1a0 + 0x60;
                  uint256 internal constant ZERO_POLY_LOC =                            0x200 + 0x340 + 0x300 + 0x1a0 + 0x80;
                  uint256 internal constant L_START_LOC =                              0x200 + 0x340 + 0x300 + 0x1a0 + 0xa0;
                  uint256 internal constant L_END_LOC =                                0x200 + 0x340 + 0x300 + 0x1a0 + 0xc0;
                  uint256 internal constant R_ZERO_EVAL_LOC =                          0x200 + 0x340 + 0x300 + 0x1a0 + 0xe0;
                  uint256 internal constant ACCUMULATOR_X_LOC =                        0x200 + 0x340 + 0x300 + 0x1a0 + 0x100;
                  uint256 internal constant ACCUMULATOR_Y_LOC =                        0x200 + 0x340 + 0x300 + 0x1a0 + 0x120;
                  uint256 internal constant ACCUMULATOR2_X_LOC =                       0x200 + 0x340 + 0x300 + 0x1a0 + 0x140;
                  uint256 internal constant ACCUMULATOR2_Y_LOC =                       0x200 + 0x340 + 0x300 + 0x1a0 + 0x160;
                  uint256 internal constant PAIRING_LHS_X_LOC =                        0x200 + 0x340 + 0x300 + 0x1a0 + 0x180;
                  uint256 internal constant PAIRING_LHS_Y_LOC =                        0x200 + 0x340 + 0x300 + 0x1a0 + 0x1a0;
                  uint256 internal constant PAIRING_RHS_X_LOC =                        0x200 + 0x340 + 0x300 + 0x1a0 + 0x1c0;
                  uint256 internal constant PAIRING_RHS_Y_LOC =                        0x200 + 0x340 + 0x300 + 0x1a0 + 0x1e0;
                  // 21
                  // ### SUCCESS FLAG MEMORY LOCATIONS
                  uint256 internal constant GRAND_PRODUCT_SUCCESS_FLAG =               0x200 + 0x340 + 0x300 + 0x1a0 + 0x200 + 0x00;
                  uint256 internal constant ARITHMETIC_TERM_SUCCESS_FLAG =             0x200 + 0x340 + 0x300 + 0x1a0 + 0x200 + 0x20;
                  uint256 internal constant BATCH_OPENING_SUCCESS_FLAG =               0x200 + 0x340 + 0x300 + 0x1a0 + 0x200 + 0x40;
                  uint256 internal constant OPENING_COMMITMENT_SUCCESS_FLAG =          0x200 + 0x340 + 0x300 + 0x1a0 + 0x200 + 0x60;
                  uint256 internal constant PAIRING_PREAMBLE_SUCCESS_FLAG =            0x200 + 0x340 + 0x300 + 0x1a0 + 0x200 + 0x80;
                  uint256 internal constant PAIRING_SUCCESS_FLAG =                     0x200 + 0x340 + 0x300 + 0x1a0 + 0x200 + 0xa0;
                  uint256 internal constant RESULT_FLAG =                              0x200 + 0x340 + 0x300 + 0x1a0 + 0x200 + 0xc0;
                  // 7
                  // misc stuff
                  uint256 internal constant OMEGA_INVERSE_LOC = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x200 + 0xe0;
                  uint256 internal constant C_ALPHA_SQR_LOC = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x200 + 0xe0 + 0x20;
                  // 3
                  // ### RECURSION VARIABLE MEMORY LOCATIONS
                  uint256 internal constant RECURSIVE_P1_X_LOC = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x200 + 0xe0 + 0x40;
                  uint256 internal constant RECURSIVE_P1_Y_LOC = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x200 + 0xe0 + 0x60;
                  uint256 internal constant RECURSIVE_P2_X_LOC = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x200 + 0xe0 + 0x80;
                  uint256 internal constant RECURSIVE_P2_Y_LOC = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x200 + 0xe0 + 0xa0;
                  uint256 internal constant PUBLIC_INPUTS_HASH_LOCATION = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x200 + 0xe0 + 0xc0;
                  error PUBLIC_INPUTS_HASH_VERIFICATION_FAILED(uint256, uint256);
                  /**
                   * @dev Verify a Plonk proof
                   * @param - array of serialized proof data
                   * @param - public input hash as computed from the broadcast data
                   */
                  function verify(bytes calldata, uint256 public_inputs_hash) external view override returns (bool) {
                      // validate the correctness of the public inputs hash
                      {
                          bool hash_matches_input;
                          uint256 recovered_hash;
                          assembly {
                              recovered_hash := calldataload(add(calldataload(0x04), 0x24))
                              hash_matches_input := eq(recovered_hash, public_inputs_hash)
                          }
                          if (!hash_matches_input)
                          {
                              revert PUBLIC_INPUTS_HASH_VERIFICATION_FAILED(public_inputs_hash, recovered_hash);
                          }
                      }
                      StandardTypes.VerificationKey memory vk = VerificationKey.get_verification_key();
                      assembly {
                          /**
                           * LOAD VKEY
                           * TODO REPLACE THIS WITH A CONTRACT CALL
                           */
                          {
                              mstore(N_LOC, mload(vk))
                              mstore(NUM_INPUTS_LOC, mload(add(vk, 0x20)))
                              mstore(OMEGA_LOC,           mload(add(vk, 0x40)))
                              mstore(DOMAIN_INVERSE_LOC,  mload(add(vk, 0x60)))
                              mstore(OMEGA_INVERSE_LOC,   mload(add(vk, 0x80)))
                              mstore(Q1_X_LOC,            mload(mload(add(vk, 0xa0))))
                              mstore(Q1_Y_LOC,            mload(add(mload(add(vk, 0xa0)), 0x20)))
                              mstore(Q2_X_LOC,            mload(mload(add(vk, 0xc0))))
                              mstore(Q2_Y_LOC,            mload(add(mload(add(vk, 0xc0)), 0x20)))
                              mstore(Q3_X_LOC,            mload(mload(add(vk, 0xe0))))
                              mstore(Q3_Y_LOC,            mload(add(mload(add(vk, 0xe0)), 0x20)))
                              mstore(QM_X_LOC,            mload(mload(add(vk, 0x100))))
                              mstore(QM_Y_LOC,            mload(add(mload(add(vk, 0x100)), 0x20)))
                              mstore(QC_X_LOC,            mload(mload(add(vk, 0x120))))
                              mstore(QC_Y_LOC,            mload(add(mload(add(vk, 0x120)), 0x20)))
                              mstore(SIGMA1_X_LOC,        mload(mload(add(vk, 0x140))))
                              mstore(SIGMA1_Y_LOC,        mload(add(mload(add(vk, 0x140)), 0x20)))
                              mstore(SIGMA2_X_LOC,        mload(mload(add(vk, 0x160))))
                              mstore(SIGMA2_Y_LOC,        mload(add(mload(add(vk, 0x160)), 0x20)))
                              mstore(SIGMA3_X_LOC,        mload(mload(add(vk, 0x180))))
                              mstore(SIGMA3_Y_LOC,        mload(add(mload(add(vk, 0x180)), 0x20)))
                              mstore(CONTAINS_RECURSIVE_PROOF_LOC, mload(add(vk, 0x1a0)))
                              mstore(RECURSIVE_PROOF_PUBLIC_INPUT_INDICES_LOC, mload(add(vk, 0x1c0)))
                              mstore(G2X_X0_LOC, 0x260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c1)
                              mstore(G2X_X1_LOC, 0x0118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b0)
                              mstore(G2X_Y0_LOC, 0x04fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe4)
                              mstore(G2X_Y1_LOC, 0x22febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55)
                          }
                          let q := 21888242871839275222246405745257275088696311157297823662689037894645226208583 // EC group order
                          let p := 21888242871839275222246405745257275088548364400416034343698204186575808495617 // Prime field order
                          /**
                           * LOAD PROOF FROM CALLDATA
                           */
                          {
                              let data_ptr := add(calldataload(0x04), 0x24)
                              if mload(CONTAINS_RECURSIVE_PROOF_LOC)
                              {
                                  let index_counter := add(mul(mload(RECURSIVE_PROOF_PUBLIC_INPUT_INDICES_LOC), 32), data_ptr)
                                  let x0 := calldataload(index_counter)
                                  x0 := add(x0, shl(68, calldataload(add(index_counter, 0x20))))
                                  x0 := add(x0, shl(136, calldataload(add(index_counter, 0x40))))
                                  x0 := add(x0, shl(204, calldataload(add(index_counter, 0x60))))
                                  let y0 := calldataload(add(index_counter, 0x80))
                                  y0 := add(y0, shl(68, calldataload(add(index_counter, 0xa0))))
                                  y0 := add(y0, shl(136, calldataload(add(index_counter, 0xc0))))
                                  y0 := add(y0, shl(204, calldataload(add(index_counter, 0xe0))))
                                  let x1 := calldataload(add(index_counter, 0x100))
                                  x1 := add(x1, shl(68, calldataload(add(index_counter, 0x120))))
                                  x1 := add(x1, shl(136, calldataload(add(index_counter, 0x140))))
                                  x1 := add(x1, shl(204, calldataload(add(index_counter, 0x160))))
                                  let y1 := calldataload(add(index_counter, 0x180))
                                  y1 := add(y1, shl(68, calldataload(add(index_counter, 0x1a0))))
                                  y1 := add(y1, shl(136, calldataload(add(index_counter, 0x1c0))))
                                  y1 := add(y1, shl(204, calldataload(add(index_counter, 0x1e0))))
                                  mstore(RECURSIVE_P1_X_LOC, x0)
                                  mstore(RECURSIVE_P1_Y_LOC, y0)
                                  mstore(RECURSIVE_P2_X_LOC, x1)
                                  mstore(RECURSIVE_P2_Y_LOC, y1)
                                  // validate these are valid bn128 G1 points
                                  if iszero(and(
                                      and(lt(x0, q), lt(x1, q)),
                                      and(lt(y0, q), lt(y1, q))
                                  )) {
                                      revert(0x00, 0x00)
                                  }
                              }
                          let public_input_byte_length := mul(mload(NUM_INPUTS_LOC), 32)
                          data_ptr := add(data_ptr, public_input_byte_length)
                          mstore(W1_X_LOC, mod(calldataload(add(data_ptr, 0x20)), q))
                          mstore(W1_Y_LOC, mod(calldataload(data_ptr), q))
                          mstore(W2_X_LOC, mod(calldataload(add(data_ptr, 0x60)), q))
                          mstore(W2_Y_LOC, mod(calldataload(add(data_ptr, 0x40)), q))
                          mstore(W3_X_LOC, mod(calldataload(add(data_ptr, 0xa0)), q))
                          mstore(W3_Y_LOC, mod(calldataload(add(data_ptr, 0x80)), q))
                          mstore(Z_X_LOC, mod(calldataload(add(data_ptr, 0xe0)), q))
                          mstore(Z_Y_LOC, mod(calldataload(add(data_ptr, 0xc0)), q))
                          mstore(T1_X_LOC, mod(calldataload(add(data_ptr, 0x120)), q))
                          mstore(T1_Y_LOC, mod(calldataload(add(data_ptr, 0x100)), q))
                          mstore(T2_X_LOC, mod(calldataload(add(data_ptr, 0x160)), q))
                          mstore(T2_Y_LOC, mod(calldataload(add(data_ptr, 0x140)), q))
                          mstore(T3_X_LOC, mod(calldataload(add(data_ptr, 0x1a0)), q))
                          mstore(T3_Y_LOC, mod(calldataload(add(data_ptr, 0x180)), q))
                          mstore(W1_EVAL_LOC, mod(calldataload(add(data_ptr, 0x1c0)), p))
                          mstore(W2_EVAL_LOC, mod(calldataload(add(data_ptr, 0x1e0)), p))
                          mstore(W3_EVAL_LOC, mod(calldataload(add(data_ptr, 0x200)), p))
                          mstore(SIGMA1_EVAL_LOC, mod(calldataload(add(data_ptr, 0x220)), p))
                          mstore(SIGMA2_EVAL_LOC, mod(calldataload(add(data_ptr, 0x240)), p))
                          mstore(Z_OMEGA_EVAL_LOC, mod(calldataload(add(data_ptr, 0x260)), p))
                          mstore(PI_Z_X_LOC, mod(calldataload(add(data_ptr, 0x2a0)), q))
                          mstore(PI_Z_Y_LOC, mod(calldataload(add(data_ptr, 0x280)), q))
                          mstore(PI_Z_OMEGA_X_LOC, mod(calldataload(add(data_ptr, 0x2e0)), q))
                          mstore(PI_Z_OMEGA_Y_LOC, mod(calldataload(add(data_ptr, 0x2c0)), q))
                          }
                          {
                          /**
                           * Generate initial challenge
                           **/
                          mstore(0x00, shl(224, mload(N_LOC)))
                          mstore(0x04, shl(224, mload(NUM_INPUTS_LOC)))
                          let challenge := keccak256(0x00, 0x08)
                          /**
                           * Generate beta, gamma challenges
                           */
                          mstore(PUBLIC_INPUTS_HASH_LOCATION, challenge)
                          let inputs_start := add(calldataload(0x04), 0x24)
                          let num_calldata_bytes := add(0xc0, mul(mload(NUM_INPUTS_LOC), 0x20))
                          calldatacopy(add(PUBLIC_INPUTS_HASH_LOCATION, 0x20), inputs_start, num_calldata_bytes)
                          challenge := keccak256(PUBLIC_INPUTS_HASH_LOCATION, add(num_calldata_bytes, 0x20))
                          mstore(C_BETA_LOC, mod(challenge, p))
                          mstore(0x00, challenge)
                          mstore8(0x20, 0x01)
                          challenge := keccak256(0x00, 0x21)
                          mstore(C_GAMMA_LOC, mod(challenge, p))
                          /**
                           * Generate alpha challenge
                           */
                          mstore(0x00, challenge)
                          mstore(0x20, mload(Z_Y_LOC))
                          mstore(0x40, mload(Z_X_LOC))
                          challenge := keccak256(0x00, 0x60)
                          mstore(C_ALPHA_LOC, mod(challenge, p))
                          /**
                           * Generate zeta challenge
                           */
                          mstore(0x00, challenge)
                          mstore(0x20, mload(T1_Y_LOC))
                          mstore(0x40, mload(T1_X_LOC))
                          mstore(0x60, mload(T2_Y_LOC))
                          mstore(0x80, mload(T2_X_LOC))
                          mstore(0xa0, mload(T3_Y_LOC))
                          mstore(0xc0, mload(T3_X_LOC))
                          challenge := keccak256(0x00, 0xe0)
                          mstore(C_ZETA_LOC, mod(challenge, p))
                          mstore(C_CURRENT_LOC, challenge)
                          }
                          /**
                           * EVALUATE FIELD OPERATIONS
                           */
                          /**
                           * COMPUTE PUBLIC INPUT DELTA
                           */
                          {
                              let gamma := mload(C_GAMMA_LOC)
                              let work_root := mload(OMEGA_LOC)
                              let endpoint := sub(mul(mload(NUM_INPUTS_LOC), 0x20), 0x20)
                              let public_inputs
                              let root_1 := mload(C_BETA_LOC)
                              let root_2 := root_1
                              let numerator_value := 1
                              let denominator_value := 1
                              let p_clone := p // move p to the front of the stack
                              let valid := true
                              root_1 := mulmod(root_1, 0x05, p_clone) // k1.beta
                              root_2 := mulmod(root_2, 0x07, p_clone) // 0x05 + 0x07 = 0x0c = external coset generator
                              public_inputs := add(calldataload(0x04), 0x24)
                              endpoint := add(endpoint, public_inputs)
                              for {} lt(public_inputs, endpoint) {}
                              {
                                  let input0 := calldataload(public_inputs)
                                  let N0 := add(root_1, add(input0, gamma))
                                  let D0 := add(root_2, N0) // 4x overloaded
                                  root_1 := mulmod(root_1, work_root, p_clone)
                                  root_2 := mulmod(root_2, work_root, p_clone)
                                  let input1 := calldataload(add(public_inputs, 0x20))
                                  let N1 := add(root_1, add(input1, gamma))
                                  denominator_value := mulmod(mulmod(D0, denominator_value, p_clone), add(N1, root_2), p_clone)
                                  numerator_value := mulmod(mulmod(N1, N0, p_clone), numerator_value, p_clone)
                                  root_1 := mulmod(root_1, work_root, p_clone)
                                  root_2 := mulmod(root_2, work_root, p_clone)
                                  valid := and(valid, and(lt(input0, p_clone), lt(input1, p_clone)))
                                  public_inputs := add(public_inputs, 0x40)
                                  // validate public inputs are field elements (i.e. < p)
                                  if iszero(and(lt(input0, p), lt(input1, p)))
                                  {
                                      revert(0x00, 0x00)
                                  }
                              }
                              endpoint := add(endpoint, 0x20)
                              for {} lt(public_inputs, endpoint) { public_inputs := add(public_inputs, 0x20) }
                              {
                                  let input0 := calldataload(public_inputs)
                                  // validate public inputs are field elements (i.e. < p)
                                  if iszero(lt(input0, p))
                                  {
                                      revert(0x00, 0x00)
                                  }
                      
                                  valid := and(valid, lt(input0, p_clone))
                                  let T0 := addmod(input0, gamma, p_clone)
                                  numerator_value := mulmod(
                                      numerator_value,
                                      add(root_1, T0), // 0x05 = coset_generator0
                                      p
                                  )
                                  denominator_value := mulmod(
                                      denominator_value,
                                      add(add(root_1, root_2), T0), // 0x0c = coset_generator7
                                      p
                                  )
                                  root_1 := mulmod(root_1, work_root, p_clone)
                                  root_2 := mulmod(root_2, work_root, p_clone)
                              }
                              mstore(DELTA_NUMERATOR_LOC, numerator_value)
                              mstore(DELTA_DENOMINATOR_LOC, denominator_value)
                          }
                          /**
                           * Compute lagrange poly and vanishing poly fractions
                           */
                          {
                              let zeta := mload(C_ZETA_LOC)
                              // compute zeta^n, where n is a power of 2
                              let vanishing_numerator := zeta
                              {
                                  // pow_small
                                  let exponent := mload(N_LOC)
                                  let count := 1
                                  for {} lt(count, exponent) { count := add(count, count) }
                                  {
                                      vanishing_numerator := mulmod(vanishing_numerator, vanishing_numerator, p)
                                  }
                              }
                              mstore(ZETA_POW_N_LOC, vanishing_numerator)
                              vanishing_numerator := addmod(vanishing_numerator, sub(p, 1), p)
                              let accumulating_root := mload(OMEGA_INVERSE_LOC)
                              let work_root := sub(p, accumulating_root)
                              let domain_inverse := mload(DOMAIN_INVERSE_LOC)
                              let vanishing_denominator := addmod(zeta, work_root, p)
                              work_root := mulmod(work_root, accumulating_root, p)
                              vanishing_denominator := mulmod(vanishing_denominator, addmod(zeta, work_root, p), p)
                              work_root := mulmod(work_root, accumulating_root, p)
                              vanishing_denominator := mulmod(vanishing_denominator, addmod(zeta, work_root, p), p)
                              vanishing_denominator := mulmod(vanishing_denominator, addmod(zeta, mulmod(work_root, accumulating_root, p), p), p)
                              work_root := mload(OMEGA_LOC)
                              let lagrange_numerator := mulmod(vanishing_numerator, domain_inverse, p)
                              let l_start_denominator := addmod(zeta, sub(p, 1), p)
                              // l_end_denominator term contains a term \\omega^5 to cut out 5 roots of unity from vanishing poly
                              accumulating_root := mulmod(work_root, work_root, p)
                              let l_end_denominator := addmod(
                                  mulmod(
                                      mulmod(
                                          mulmod(accumulating_root, accumulating_root, p),
                                          work_root, p
                                      ),
                                      zeta, p
                                  ),
                                  sub(p, 1), p
                              )
                          /**
                           * Compute inversions using Montgomery's batch inversion trick
                           */
                              let accumulator := mload(DELTA_DENOMINATOR_LOC)
                              let t0 := accumulator
                              accumulator := mulmod(accumulator, vanishing_denominator, p)
                              let t1 := accumulator
                              accumulator := mulmod(accumulator, l_start_denominator, p)
                              let t2 := accumulator
                              {
                                  mstore(0, 0x20)
                                  mstore(0x20, 0x20)
                                  mstore(0x40, 0x20)
                                  mstore(0x60, mulmod(accumulator, l_end_denominator, p))
                                  mstore(0x80, sub(p, 2))
                                  mstore(0xa0, p)
                                  if iszero(staticcall(gas(), 0x05, 0x00, 0xc0, 0x00, 0x20))
                                  {
                                      mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
                                      mstore(0x04, 0x20)
                                      mstore(0x24, 32)
                                      mstore(0x44, "PROOF_VERIFICATION_FAILED_TYPE_1")
                                      revert(0x00, 0x64)
                                  }
                                  accumulator := mload(0x00)
                              }
                              t2 := mulmod(accumulator, t2, p)
                              accumulator := mulmod(accumulator, l_end_denominator, p)
                              t1 := mulmod(accumulator, t1, p)
                              accumulator := mulmod(accumulator, l_start_denominator, p)
                              t0 := mulmod(accumulator, t0, p)
                              accumulator := mulmod(accumulator, vanishing_denominator, p)
                              accumulator := mulmod(mulmod(accumulator, accumulator, p), mload(DELTA_DENOMINATOR_LOC), p)
                              mstore(PUBLIC_INPUT_DELTA_LOC, mulmod(mload(DELTA_NUMERATOR_LOC), accumulator, p))
                              mstore(ZERO_POLY_LOC, mulmod(vanishing_numerator, t0, p))
                              mstore(L_START_LOC, mulmod(lagrange_numerator, t1, p))
                              mstore(L_END_LOC, mulmod(lagrange_numerator, t2, p))
                          }
                          /**
                           * COMPUTE CONSTANT TERM (r_0) OF LINEARISATION POLYNOMIAL
                           */
                          {
                              let alpha := mload(C_ALPHA_LOC)
                              let beta := mload(C_BETA_LOC)
                              let gamma := mload(C_GAMMA_LOC)
                              let r_0 := sub(p,
                                  mulmod(
                                      mulmod(
                                          mulmod(
                                              add(add(mload(W1_EVAL_LOC), gamma), mulmod(beta, mload(SIGMA1_EVAL_LOC), p)),
                                              add(add(mload(W2_EVAL_LOC), gamma), mulmod(beta, mload(SIGMA2_EVAL_LOC), p)),
                                              p
                                          ),
                                          add(mload(W3_EVAL_LOC), gamma),
                                          p
                                      ),
                                      mload(Z_OMEGA_EVAL_LOC),
                                      p
                                  )
                              )
                              // r_0 = -(ā + βs̄_σ1 + γ)( b̄ + βs̄_σ2 + γ)(c̄ + γ)z̄_ω
                              let alpha_sqr := mulmod(alpha, alpha, p)
                              mstore(C_ALPHA_SQR_LOC, alpha_sqr)
                              mstore(C_ARITHMETIC_ALPHA_LOC, mulmod(alpha_sqr, alpha_sqr, p))
                              mstore(R_ZERO_EVAL_LOC,
                                          mulmod(
                                              addmod(
                                                  addmod(r_0, sub(p, mulmod(mload(L_START_LOC), alpha_sqr, p)), p),
                                                  mulmod(
                                                      mulmod(mload(L_END_LOC), alpha, p),
                                                      addmod(mload(Z_OMEGA_EVAL_LOC), sub(p, mload(PUBLIC_INPUT_DELTA_LOC)), p), p
                                                  ), p
                                              ),
                                              alpha, p
                                          )
                                      )
                          }
                          /**
                           * GENERATE NU AND SEPARATOR CHALLENGES
                           */
                          {
                              let current_challenge := mload(C_CURRENT_LOC)
                              // get a calldata pointer that points to the start of the data we want to copy
                              let calldata_ptr := add(calldataload(0x04), 0x24)
                              // skip over the public inputs
                              calldata_ptr := add(calldata_ptr, mul(mload(NUM_INPUTS_LOC), 0x20))
                              // There are SEVEN G1 group elements added into the transcript in the `beta` round, that we need to skip over
                              // W1, W2, W3 (W4), Z, T1, T2, T3, (T4)
                              calldata_ptr := add(calldata_ptr, 0x1c0) // 7 * 0x40 = 0x1c0
                              mstore(0x00, current_challenge)
                              calldatacopy(0x20, calldata_ptr, 0xc0) // 6 * 0x20 = 0xc0
                              let challenge := keccak256(0x00, 0xe0) // hash length = 0xe0 (0x20 + num field elements), we include the previous challenge in the hash
                              mstore(C_V0_LOC, mod(challenge, p))
                              mstore(0x00, challenge)
                              mstore8(0x20, 0x01)
                              mstore(C_V1_LOC, mod(keccak256(0x00, 0x21), p))
                              mstore8(0x20, 0x02)
                              mstore(C_V2_LOC, mod(keccak256(0x00, 0x21), p))
                              mstore8(0x20, 0x03)
                              mstore(C_V3_LOC, mod(keccak256(0x00, 0x21), p))
                              mstore8(0x20, 0x04)
                              mstore(C_V4_LOC, mod(keccak256(0x00, 0x21), p))
                              mstore8(0x20, 0x05)
                              challenge := keccak256(0x00, 0x21)
                              mstore(C_V5_LOC, mod(challenge, p))
                              // separator
                              mstore(0x00, challenge)
                              mstore(0x20, mload(PI_Z_Y_LOC))
                              mstore(0x40, mload(PI_Z_X_LOC))
                              mstore(0x60, mload(PI_Z_OMEGA_Y_LOC))
                              mstore(0x80, mload(PI_Z_OMEGA_X_LOC))
                              mstore(C_U_LOC, mod(keccak256(0x00, 0xa0), p))
                          }
                          // mstore(C_ALPHA_BASE_LOC, mload(C_ALPHA_LOC))
                          /**
                           * COMPUTE LINEARISED OPENING TERMS
                           */
                          {
                              // /**
                              //  * COMPUTE GRAND PRODUCT OPENING GROUP ELEMENT
                              //  */
                              let beta := mload(C_BETA_LOC)
                              let zeta := mload(C_ZETA_LOC)
                              let gamma := mload(C_GAMMA_LOC)
                              let alpha := mload(C_ALPHA_LOC)
                              let beta_zeta := mulmod(beta, zeta, p)
                              let witness_term := addmod(mload(W1_EVAL_LOC), gamma, p)
                              let partial_grand_product := addmod(beta_zeta, witness_term, p)
                              let sigma_multiplier := addmod(mulmod(mload(SIGMA1_EVAL_LOC), beta, p), witness_term, p)
                              witness_term := addmod(mload(W2_EVAL_LOC), gamma, p)
                              sigma_multiplier := mulmod(sigma_multiplier, addmod(mulmod(mload(SIGMA2_EVAL_LOC), beta, p), witness_term, p), p)
                              let k1_beta_zeta := mulmod(0x05, beta_zeta, p)
                              //  partial_grand_product = mulmod( mulmod( partial_grand_product, w2 + k1.beta.zeta + gamma , p), k2.beta.zeta + gamma + w3, p)
                              partial_grand_product := mulmod(
                                  mulmod(
                                      partial_grand_product,
                                      addmod(k1_beta_zeta, witness_term, p), // w2 + k1.beta.zeta + gamma
                                      p
                                  ),
                                  addmod(addmod(add(k1_beta_zeta, beta_zeta), gamma, p), mload(W3_EVAL_LOC), p), // k2.beta.zeta + gamma + w3 where k2 = k1+1
                                  p
                              )
                              let linear_challenge := alpha // Owing to the simplified Plonk, nu =1, linear_challenge = nu * alpha = alpha
                              mstore(0x00, mload(SIGMA3_X_LOC))
                              mstore(0x20, mload(SIGMA3_Y_LOC))
                              mstore(0x40, mulmod(
                                  mulmod(
                                      sub(p, mulmod(sigma_multiplier, mload(Z_OMEGA_EVAL_LOC), p)),
                                      beta,
                                      p
                                  ),
                                  linear_challenge,
                                  p
                              ))
                              // Validate Z
                              let success
                              {
                                  let x := mload(Z_X_LOC)
                                  let y := mload(Z_Y_LOC)
                                  let xx := mulmod(x, x, q)
                                  success := eq(mulmod(y, y, q), addmod(mulmod(x, xx, q), 3, q))
                                  mstore(0x60, x)
                                  mstore(0x80, y)
                              }
                              mstore(0xa0, addmod(
                                  mulmod(
                                      addmod(partial_grand_product, mulmod(mload(L_START_LOC), mload(C_ALPHA_SQR_LOC), p), p),
                                      linear_challenge,
                                      p),
                                  mload(C_U_LOC),
                                  p
                              ))
                          // 0x00 = SIGMA3_X_LOC,
                          // 0x20 = SIGMA3_Y_LOC,
                          // 0x40 = −(ā + βs̄_σ1 + γ)( b̄ + βs̄_σ2 + γ)αβz̄_ω,
                          // 0x60 = Z_X_LOC,
                          // 0x80 = Z_Y_LOC,
                          // 0xa0 = (ā + βz + γ)( b̄ + βk_1 z + γ)(c̄ + βk_2 z + γ)α + L_1(z)α^3 + u
                              success := and(success, and(
                                  staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                  // Why ACCUMULATOR_X_LOC := ACCUMULATOR_X_LOC + ACCUMULATOR2_X_LOC? Inner parenthesis is executed before?
                                  and(
                                      staticcall(gas(), 7, 0x60, 0x60, ACCUMULATOR_X_LOC, 0x40),
                                      // [ACCUMULATOR_X_LOC, ACCUMULATOR_X_LOC + 0x40) = ((ā + βz + γ)( b̄ + βk_1 z + γ)(c̄ + βk_2 z + γ)α + L_1(z)α^3 + u)*[z]_1
                                      staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40)
                                      // [ACCUMULATOR2_X_LOC, ACCUMULATOR2_X_LOC + 0x40) = −(ā + βs̄_σ1 + γ)( b̄ + βs̄_σ2 + γ)αβz̄_ω * [s_σ3]_1
                                  )
                              ))
                              mstore(GRAND_PRODUCT_SUCCESS_FLAG, success)
                          }
                          /**
                           * COMPUTE ARITHMETIC SELECTOR OPENING GROUP ELEMENT
                           */
                          {
                              let linear_challenge := mload(C_ARITHMETIC_ALPHA_LOC) // Owing to simplified Plonk, nu = 1,  linear_challenge = C_ARITHMETIC_ALPHA (= alpha^4)
                              let t1 := mulmod(mload(W1_EVAL_LOC), linear_challenge, p) // reuse this for QM scalar multiplier
                              // Q1
                              mstore(0x00, mload(Q1_X_LOC))
                              mstore(0x20, mload(Q1_Y_LOC))
                              mstore(0x40, t1)
                              // add Q1 scalar mul into grand product scalar mul
                              // Observe that ACCUMULATOR_X_LOC and ACCUMULATOR2_X_LOC are 0x40 bytes apart. Below, ACCUMULATOR2_X_LOC
                              // captures new terms Q1, Q2, and so on and they get accumulated to ACCUMULATOR_X_LOC
                              let success := and(
                                  staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                  // [ACCUMULATOR_X_LOC, ACCUMULATOR_X_LOC + 0x40) = ((ā + βz + γ)( b̄ + βk_1 z + γ)(c̄ + βk_2 z + γ)α + L_1(z)α^3 + u)*[z]_1 −(ā + βs̄_σ1 + γ)( b̄ + βs̄_σ2 + γ)αβz̄_ω * [s_σ3]_1
                                  staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40)
                                  // [ACCUMULATOR2_X_LOC, ACCUMULATOR2_X_LOC + 0x40) = ā * [q_L]_1
                              )
                              // Q2
                              mstore(0x00, mload(Q2_X_LOC))
                              mstore(0x20, mload(Q2_Y_LOC))
                              mstore(0x40, mulmod(mload(W2_EVAL_LOC), linear_challenge, p))
                              success := and(
                                  success,
                                  and(
                                      staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                      staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40)
                                  )
                              )
                              // Q3
                              mstore(0x00, mload(Q3_X_LOC))
                              mstore(0x20, mload(Q3_Y_LOC))
                              mstore(0x40, mulmod(mload(W3_EVAL_LOC), linear_challenge, p))
                              success := and(
                                  success,
                                  and(
                                      staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                      staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40)
                                  )
                              )
                              // QM
                              mstore(0x00, mload(QM_X_LOC))
                              mstore(0x20, mload(QM_Y_LOC))
                              mstore(0x40, mulmod(t1, mload(W2_EVAL_LOC), p))
                              success := and(
                                  success,
                                  and(
                                      staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                      staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40)
                                  )
                              )
                              // QC
                              mstore(0x00, mload(QC_X_LOC))
                              mstore(0x20, mload(QC_Y_LOC))
                              mstore(0x40, linear_challenge)
                              success := and(
                                  success,
                                  and(
                                      staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                      staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40)
                                  )
                              )
                              mstore(ARITHMETIC_TERM_SUCCESS_FLAG, success)
                          }
                           /**
                           * COMPUTE BATCH OPENING COMMITMENT
                           */
                          {
                              // previous scalar_multiplier = 1, z^n, z^2n
                              // scalar_multiplier owing to the simplified Plonk = 1 * -Z_H(z), z^n * -Z_H(z), z^2n * -Z_H(z)
                              // VALIDATE T1
                              let success
                              {
                                  let x := mload(T1_X_LOC)
                                  let y := mload(T1_Y_LOC)
                                  let xx := mulmod(x, x, q)
                                  success := eq(mulmod(y, y, q), addmod(mulmod(x, xx, q), 3, q))
                                  mstore(0x00, x)
                                  mstore(0x20, y)
                                  mstore(0x40, sub(p, mload(ZERO_POLY_LOC)))
                                  // mstore(ACCUMULATOR2_X_LOC, x)
                                  // mstore(ACCUMULATOR2_Y_LOC, y)
                              }
                              success := and(success,
                              and(
                                  staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                  staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40)
                              ))
                              // VALIDATE T2
                              let scalar_multiplier := mload(ZETA_POW_N_LOC)
                              {
                                  let x := mload(T2_X_LOC)
                                  let y := mload(T2_Y_LOC)
                                  let xx := mulmod(x, x, q)
                                  success := and(success, eq(mulmod(y, y, q), addmod(mulmod(x, xx, q), 3, q)))
                                  mstore(0x00, x)
                                  mstore(0x20, y)
                              }
                              mstore(0x40, mulmod(scalar_multiplier, sub(p, mload(ZERO_POLY_LOC)), p))
                              success := and(
                                  staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                  and(
                                      success,
                                      staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40)
                                  )
                              )
                              // VALIDATE T3
                              {
                                  let x := mload(T3_X_LOC)
                                  let y := mload(T3_Y_LOC)
                                  let xx := mulmod(x, x, q)
                                  success := and(success, eq(mulmod(y, y, q), addmod(mulmod(x, xx, q), 3, q)))
                                  mstore(0x00, x)
                                  mstore(0x20, y)
                              }
                              mstore(0x40, mulmod(scalar_multiplier, mulmod(scalar_multiplier, sub(p, mload(ZERO_POLY_LOC)), p), p))
                              success := and(
                                  staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                  and(
                                      success,
                                      staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40)
                                  )
                              )
                              // VALIDATE W1
                              {
                                  let x := mload(W1_X_LOC)
                                  let y := mload(W1_Y_LOC)
                                  let xx := mulmod(x, x, q)
                                  success := and(success, eq(mulmod(y, y, q), addmod(mulmod(x, xx, q), 3, q)))
                                  mstore(0x00, x)
                                  mstore(0x20, y)
                              }
                              mstore(0x40, mload(C_V0_LOC))
                              success := and(
                                  staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                  and(
                                      success,
                                      staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40)
                                  )
                              )
                              // VALIDATE W2
                              {
                                  let x := mload(W2_X_LOC)
                                  let y := mload(W2_Y_LOC)
                                  let xx := mulmod(x, x, q)
                                  success := and(success, eq(mulmod(y, y, q), addmod(mulmod(x, xx, q), 3, q)))
                                  mstore(0x00, x)
                                  mstore(0x20, y)
                              }
                              mstore(0x40, mload(C_V1_LOC))
                              success := and(
                                  staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                  and(
                                      success,
                                      staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40)
                                  )
                              )
                              // VALIDATE W3
                              {
                                  let x := mload(W3_X_LOC)
                                  let y := mload(W3_Y_LOC)
                                  let xx := mulmod(x, x, q)
                                  success := and(success, eq(mulmod(y, y, q), addmod(mulmod(x, xx, q), 3, q)))
                                  mstore(0x00, x)
                                  mstore(0x20, y)
                              }
                              mstore(0x40, mload(C_V2_LOC))
                              success := and(
                                  staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                  and(
                                      success,
                                      staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40)
                                  )
                              )
                              mstore(0x00, mload(SIGMA1_X_LOC))
                              mstore(0x20, mload(SIGMA1_Y_LOC))
                              mstore(0x40, mload(C_V3_LOC))
                              success := and(
                                  staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                  and(
                                      success,
                                      staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40)
                                  )
                              )
                              mstore(0x00, mload(SIGMA2_X_LOC))
                              mstore(0x20, mload(SIGMA2_Y_LOC))
                              mstore(0x40, mload(C_V4_LOC))
                              success := and(
                                  staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                  and(
                                      success,
                                      staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40)
                                  )
                              )
                              mstore(BATCH_OPENING_SUCCESS_FLAG, success)
                          }
                          /**
                           * COMPUTE BATCH EVALUATION SCALAR MULTIPLIER
                           */
                          {
                              mstore(0x00, 0x01) // [1].x
                              mstore(0x20, 0x02) // [1].y
                              // Yul stack optimizer doing some work here...
                              mstore(0x40, sub(p,
                                  addmod(
                                      mulmod(mload(C_U_LOC), mload(Z_OMEGA_EVAL_LOC), p),
                                      addmod(
                                          sub(p, mload(R_ZERO_EVAL_LOC)), // Change owing to the simplified Plonk
                                              addmod(
                                                  mulmod(mload(C_V4_LOC), mload(SIGMA2_EVAL_LOC), p),
                                                  addmod(
                                                      mulmod(mload(C_V3_LOC), mload(SIGMA1_EVAL_LOC), p),
                                                      addmod(
                                                          mulmod(mload(C_V2_LOC), mload(W3_EVAL_LOC), p),
                                                          addmod(
                                                              mulmod(mload(C_V1_LOC), mload(W2_EVAL_LOC), p),
                                                              mulmod(mload(C_V0_LOC), mload(W1_EVAL_LOC), p),
                                                              p
                                                          ),
                                                          p
                                                      ),
                                                      p
                                                  ),
                                                  p
                                              ),
                                              p
                                          ),
                                          p
                                      )
                                  )
                              )
                              let success := and(
                                  staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                  staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40)
                              )
                              mstore(OPENING_COMMITMENT_SUCCESS_FLAG, success)
                          }
                           /**
                           * PERFORM PAIRING PREAMBLE
                           */
                          {
                              let u := mload(C_U_LOC)
                              let zeta := mload(C_ZETA_LOC)
                              let success
                              // VALIDATE PI_Z
                              {
                                  let x := mload(PI_Z_X_LOC)
                                  let y := mload(PI_Z_Y_LOC)
                                  let xx := mulmod(x, x, q)
                                  success := eq(mulmod(y, y, q), addmod(mulmod(x, xx, q), 3, q))
                                  mstore(0x00, x)
                                  mstore(0x20, y)
                              }
                              // compute zeta.[PI_Z] and add into accumulator
                              mstore(0x40, zeta)
                              success := and(success, and(
                                  staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                  staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40)
                              ))
                              // VALIDATE PI_Z_OMEGA
                              {
                                  let x := mload(PI_Z_OMEGA_X_LOC)
                                  let y := mload(PI_Z_OMEGA_Y_LOC)
                                  let xx := mulmod(x, x, q)
                                  success := and(success, eq(mulmod(y, y, q), addmod(mulmod(x, xx, q), 3, q)))
                                  mstore(0x00, x)
                                  mstore(0x20, y)
                              }
                              // compute u.zeta.omega.[PI_Z_OMEGA] and add into accumulator
                              mstore(0x40, mulmod(mulmod(u, zeta, p), mload(OMEGA_LOC), p))
                              success := and(
                                  staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, PAIRING_RHS_X_LOC, 0x40),
                                  and(
                                      success,
                                      staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40)
                                  )
                              )
                              mstore(0x00, mload(PI_Z_X_LOC))
                              mstore(0x20, mload(PI_Z_Y_LOC))
                              mstore(0x40, mload(PI_Z_OMEGA_X_LOC))
                              mstore(0x60, mload(PI_Z_OMEGA_Y_LOC))
                              mstore(0x80, u)
                              success := and(
                                  staticcall(gas(), 6, 0x00, 0x80, PAIRING_LHS_X_LOC, 0x40),
                                  and(
                                      success,
                                      staticcall(gas(), 7, 0x40, 0x60, 0x40, 0x40)
                                  )
                              )
                              // negate lhs y-coordinate
                              mstore(PAIRING_LHS_Y_LOC, sub(q, mload(PAIRING_LHS_Y_LOC)))
                              if mload(CONTAINS_RECURSIVE_PROOF_LOC)
                              {
                                  // VALIDATE RECURSIVE P1
                                  {
                                      let x := mload(RECURSIVE_P1_X_LOC)
                                      let y := mload(RECURSIVE_P1_Y_LOC)
                                      let xx := mulmod(x, x, q)
                                      success := and(success, eq(mulmod(y, y, q), addmod(mulmod(x, xx, q), 3, q)))
                                      mstore(0x00, x)
                                      mstore(0x20, y)
                                  }
                                  // compute u.u.[recursive_p1] and write into 0x60
                                  mstore(0x40, mulmod(u, u, p))
                                  success := and(success, staticcall(gas(), 7, 0x00, 0x60, 0x60, 0x40))
                                  // VALIDATE RECURSIVE P2
                                  {
                                      let x := mload(RECURSIVE_P2_X_LOC)
                                      let y := mload(RECURSIVE_P2_Y_LOC)
                                      let xx := mulmod(x, x, q)
                                      success := and(success, eq(mulmod(y, y, q), addmod(mulmod(x, xx, q), 3, q)))
                                      mstore(0x00, x)
                                      mstore(0x20, y)
                                  }
                                  // compute u.u.[recursive_p2] and write into 0x00
                                  // 0x40 still contains u*u
                                  success := and(success, staticcall(gas(), 7, 0x00, 0x60, 0x00, 0x40))
                                  // compute u.u.[recursiveP1] + rhs and write into rhs
                                  mstore(0xa0, mload(PAIRING_RHS_X_LOC))
                                  mstore(0xc0, mload(PAIRING_RHS_Y_LOC))
                                  success := and(success, staticcall(gas(), 6, 0x60, 0x80, PAIRING_RHS_X_LOC, 0x40))
                                  // compute u.u.[recursiveP2] + lhs and write into lhs
                                  mstore(0x40, mload(PAIRING_LHS_X_LOC))
                                  mstore(0x60, mload(PAIRING_LHS_Y_LOC))
                                  success := and(success, staticcall(gas(), 6, 0x00, 0x80, PAIRING_LHS_X_LOC, 0x40))
                              }
                              if iszero(success)
                              {
                                  mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
                                  mstore(0x04, 0x20)
                                  mstore(0x24, 32)
                                  mstore(0x44, "PROOF_VERIFICATION_FAILED_TYPE_2")
                                  revert(0x00, 0x64)
                              }
                              mstore(PAIRING_PREAMBLE_SUCCESS_FLAG, success)
                          }
                          /**
                           * PERFORM PAIRING
                           */
                          {
                              // rhs paired with [1]_2
                              // lhs paired with [x]_2
                              mstore(0x00, mload(PAIRING_RHS_X_LOC))
                              mstore(0x20, mload(PAIRING_RHS_Y_LOC))
                              mstore(0x40, 0x198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2) // this is [1]_2
                              mstore(0x60, 0x1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed)
                              mstore(0x80, 0x090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b)
                              mstore(0xa0, 0x12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa)
                              mstore(0xc0, mload(PAIRING_LHS_X_LOC))
                              mstore(0xe0, mload(PAIRING_LHS_Y_LOC))
                              mstore(0x100, mload(G2X_X0_LOC))
                              mstore(0x120, mload(G2X_X1_LOC))
                              mstore(0x140, mload(G2X_Y0_LOC))
                              mstore(0x160, mload(G2X_Y1_LOC))
                              let success := staticcall(
                                  gas(),
                                  8,
                                  0x00,
                                  0x180,
                                  0x00,
                                  0x20
                              )
                              mstore(PAIRING_SUCCESS_FLAG, success)
                              mstore(RESULT_FLAG, mload(0x00))
                          }
                          if iszero(and(
                              and(
                                  and(
                                      and(
                                          and(
                                              and(
                                                  mload(PAIRING_SUCCESS_FLAG),
                                                  mload(RESULT_FLAG)
                                              ),
                                              mload(PAIRING_PREAMBLE_SUCCESS_FLAG)
                                          ),
                                          mload(OPENING_COMMITMENT_SUCCESS_FLAG)
                                      ),
                                      mload(BATCH_OPENING_SUCCESS_FLAG)
                                  ),
                                  mload(ARITHMETIC_TERM_SUCCESS_FLAG)
                              ),
                              mload(GRAND_PRODUCT_SUCCESS_FLAG)
                          ))
                          {
                              mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
                              mstore(0x04, 0x20)
                              mstore(0x24, 32)
                              mstore(0x44, "PROOF_VERIFICATION_FAILED_TYPE_3")
                              revert(0x00, 0x64)
                          }
                          {
                              mstore(0x00, 0x01)
                              return(0x00, 0x20) // Proof succeeded!
                          }
                      }
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              import {StandardTypes} from '../cryptography/StandardTypes.sol';
              // Placeholder VK
              library VerificationKey {
                  function get_verification_key() external pure returns (StandardTypes.VerificationKey memory) {
                      StandardTypes.VerificationKey memory vk;
                      return vk;
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              /**
               * @title Bn254Crypto library used for the fr, g1 and g2 point types
               * @dev Used to manipulate fr, g1, g2 types, perform modular arithmetic on them and call
               * the precompiles add, scalar mul and pairing
               *
               * Notes on optimisations
               * 1) Perform addmod, mulmod etc. in assembly - removes the check that Solidity performs to confirm that
               * the supplied modulus is not 0. This is safe as the modulus's used (r_mod, q_mod) are hard coded
               * inside the contract and not supplied by the user
               */
              library StandardTypes {
                  uint256 internal constant PROGRAM_WIDTH = 3;
                  uint256 internal constant NUM_NU_CHALLENGES = 6;
                  uint256 internal constant coset_generator0 = 0x0000000000000000000000000000000000000000000000000000000000000005;
                  uint256 internal constant coset_generator1 = 0x0000000000000000000000000000000000000000000000000000000000000006;
                  uint256 internal constant coset_generator2 = 0x0000000000000000000000000000000000000000000000000000000000000007;
                  // TODO: add external_coset_generator() method to compute this
                  uint256 internal constant coset_generator7 = 0x000000000000000000000000000000000000000000000000000000000000000c;
                  struct G1Point {
                      uint256 x;
                      uint256 y;
                  }
                  // G2 group element where x \\in Fq2 = x0 * z + x1
                  struct G2Point {
                      uint256 x0;
                      uint256 x1;
                      uint256 y0;
                      uint256 y1;
                  }
                  // N>B. Do not re-order these fields! They must appear in the same order as they
                  // appear in the proof data
                  struct Proof {
                      G1Point W1;
                      G1Point W2;
                      G1Point W3;
                      G1Point Z;
                      G1Point T1;
                      G1Point T2;
                      G1Point T3;
                      uint256 w1;
                      uint256 w2;
                      uint256 w3;
                      uint256 sigma1;
                      uint256 sigma2;
                      //    uint256 linearization_polynomial;
                      uint256 grand_product_at_z_omega;
                      G1Point PI_Z;
                      G1Point PI_Z_OMEGA;
                      G1Point recursive_P1;
                      G1Point recursive_P2;
                      uint256 r_0; // Changes owing to the simplified Plonk
                  }
                  struct ChallengeTranscript {
                      uint256 alpha_base;
                      uint256 alpha;
                      uint256 zeta;
                      uint256 beta;
                      uint256 gamma;
                      uint256 u;
                      uint256 v0;
                      uint256 v1;
                      uint256 v2;
                      uint256 v3;
                      uint256 v4;
                      uint256 v5;
                      uint256 v6;
                      // uint256 v7;
                  }
                  struct VerificationKey {
                      uint256 circuit_size;
                      uint256 num_inputs;
                      uint256 work_root;
                      uint256 domain_inverse;
                      uint256 work_root_inverse;
                      G1Point Q1;
                      G1Point Q2;
                      G1Point Q3;
                      G1Point QM;
                      G1Point QC;
                      G1Point SIGMA1;
                      G1Point SIGMA2;
                      G1Point SIGMA3;
                      bool contains_recursive_proof;
                      uint256 recursive_proof_indices;
                      G2Point g2_x;
                      // zeta challenge raised to the power of the circuit size.
                      // Not actually part of the verification key, but we put it here to prevent stack depth errors
                      uint256 zeta_pow_n;
                  }
              }
              /**
                  ### MEMORY LAYOUT
                  0x00 - 0x200 RESERVED FOR SCRATCH SPACE
                  0x200 - 0x600 RESERVED FOR VERIFICATION KEY
                  0x600 - 0x900 RESERVED FOR LOCAL VARIABLES
                  ### VERIFICATION KEY ###
                  ### ALL LOCALTIONS ARE RELATIVE TO THE START OF THIS BLOCK IN MEMORY (0x200)
                  0x00          : n
                  0x20          : num_inputs
                  0x40          : omega
                  0x60          : n^{-1}
                  0x80          : omega^{-1}
                  0xa0 - 0xe0   : Q1
                  0xe0 - 0x120  : Q2
                  0x120 - 0x160 : Q3
                  0x160 - 0x1a0 : QM
                  0x1a0 - 0x1e0 : QC
                  0x1e0 - 0x220 : SIGMA1
                  0x220 - 0x260 : SIGMA2
                  0x260 - 0x2a0 : SIGMA3
                  0x2a0 - 0x2c0 : contains_recursive_proof
                  0x2c0 - 0x340 : G2_x ([x]_2)
                  ### LOCAL VARIABLES ###
                  ### ALL LOCALTIONS ARE RELATIVE TO THE START OF THIS BLOCK IN MEMORY (0x200)
                  0x00  : zeta_pow_n
                  0x20  : quotient_poly_eval
                  0x40  : public_input_delta_numerator
                  0x60  : public_input_delta_denominator
                  0x80  : vanishing_numerator
                  0xa0  : vanishing_denominator
                  0xc0  : lagrange_numerator
                  0xe0  : l_start_denominator
                  0x100 : l_end_denominator
                  0x120 : zero_poly_eval
                  0x140 : public_input_delta
                  0x160 : l_start
                  0x180 : l_end
                  0x200 : p
                  0x220 : proof_calldata_ptr
                  ### PROOF ###
                  0x00  - 0x40  : W1
                  0x40  - 0x80  : W2
                  0x80  - 0xc0  : W3
                  0xc0  - 0x100 : Z
                  0x100 - 0x140 : T1
                  0x140 - 0x180 : T2
                  0x180 - 0x1c0 : T3
                  0x1c0 - 0x200 : w1
                  0x200 - 0x220 : w2
                  0x220 - 0x240 : w3
                  0x240 - 0x260 : sigma1
                  0x260 - 0x280 : sigma2
                  0x280 - 0x2a0 : r
                  0x2a0 - 0x2c0 : z_omega
                  0x2c0 - 0x300 : PI_Z
                  0x300 - 0x340 : PI_Z_OMEGA
                  0x340 - 0x380 : RECURSIVE_P1
                  0x380 - 0x3c0 : RECURSIVE_P2
               */
              // Verification Key Hash: 231a6b3ded1c9472f543428e5fa1b7dd085d852173f37b4659308745c9e930e6
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              import {StandardTypes} from '../cryptography/StandardTypes.sol';
              library VerificationKey28x32 {
                  function get_verification_key() external pure returns (StandardTypes.VerificationKey memory) {
                      StandardTypes.VerificationKey memory vk;
                      assembly {
                          mstore(add(vk, 0x00), 8388608) // vk.circuit_size
                          mstore(add(vk, 0x20), 17) // vk.num_inputs
                          mstore(add(vk, 0x40),0x0210fe635ab4c74d6b7bcf70bc23a1395680c64022dd991fb54d4506ab80c59d) // vk.work_root
                          mstore(add(vk, 0x60),0x30644e121894ba67550ff245e0f5eb5a25832df811e8df9dd100d30c2c14d821) // vk.domain_inverse
                          mstore(add(vk, 0x80),0x2165a1a5bda6792b1dd75c9f4e2b8e61126a786ba1a6eadf811b03e7d69ca83b) // vk.work_root_inverse
                          mstore(mload(add(vk, 0xa0)), 0x0f7c715011823362f824b9de259a685032eedb928431724439a567967852d773)//vk.Q1
                          mstore(add(mload(add(vk, 0xa0)), 0x20), 0x17ec42a324359512a7d093faa7e55103b1f017af1bfaa5e1ccd31cc9e4ff8df0)
                          mstore(mload(add(vk, 0xc0)), 0x12bba50d7bc3e87e00bd3ce419001f3b2c59201b5ddf8cd1bba70f74061c7e7b)//vk.Q2
                          mstore(add(mload(add(vk, 0xc0)), 0x20), 0x2c3cd5dbb0d5a28b93f57660812ad5ae468aa908c5cf3ec3499973af026d9e2a)
                          mstore(mload(add(vk, 0xe0)), 0x07c448ca9631b9d24fc45d555f1b1952134eaf083c3bd46a000fcf5434a94478)//vk.Q3
                          mstore(add(mload(add(vk, 0xe0)), 0x20), 0x0e18227b6c1a461c1cbb59826cac7ebabe89e6490d80312be1504d0f7fb98059)
                          mstore(mload(add(vk, 0x100)), 0x24a14b8c3bc0ee2a31a5a8bb1c69a1519a814de7c78cb5fe3248b1717893e7f8)//vk.QM
                          mstore(add(mload(add(vk, 0x100)), 0x20), 0x1abd8e73735327575cec64e8d3c20fe5ae58f23468478a9dc6aee652332ed569)
                          mstore(mload(add(vk, 0x120)), 0x1531778c4bbda77a659dd68bf49102ceb1ab6fbd96fd5cc2f7f335e3c1ec2ce5)//vk.QC
                          mstore(add(mload(add(vk, 0x120)), 0x20), 0x166f3cd25cc14370885bf52637ff5dc382c8a6243f552cfb96a09a64f314631f)
                          mstore(mload(add(vk, 0x140)), 0x289dcb3bb09ce8d1a5c6d08cdf87ba9fc0f22ea255cf644523a602e6d3ae348e)//vk.SIGMA1
                          mstore(add(mload(add(vk, 0x140)), 0x20), 0x2d21049d7f8b99c666d353e6f7101663ed09b4877f0a829d275bb83c223d1076)
                          mstore(mload(add(vk, 0x160)), 0x0d4e31a8d510770f6912e7ee0f7454ecaf51b4df1c5f5865e0017023eab933c8)//vk.SIGMA2
                          mstore(add(mload(add(vk, 0x160)), 0x20), 0x0f974eb06e1bae83bf339bc7d15b5ea18d826aa4c877ca1b63317e2a8debe7d1)
                          mstore(mload(add(vk, 0x180)), 0x2d1d6ae2a57defc6f3a789129f67f9c9969961b8642a92b91a9bdc0afb8b7f99)//vk.SIGMA3
                          mstore(add(mload(add(vk, 0x180)), 0x20), 0x300c3f15de1f550c772a7306a3a7e491b84ec7e7a9d4601c8b88107eff4f45ee)
                          mstore(add(vk, 0x1a0), 0x01) // vk.contains_recursive_proof
                          mstore(add(vk, 0x1c0), 1) // vk.recursive_proof_public_input_indices
                          mstore(mload(add(vk, 0x1e0)), 0x260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c1) // vk.g2_x.X.c1
                          mstore(add(mload(add(vk, 0x1e0)), 0x20), 0x0118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b0) // vk.g2_x.X.c0
                          mstore(add(mload(add(vk, 0x1e0)), 0x40), 0x04fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe4) // vk.g2_x.Y.c1
                          mstore(add(mload(add(vk, 0x1e0)), 0x60), 0x22febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55) // vk.g2_x.Y.c0
                      }
                      return vk;
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              import {StandardTypes} from '../cryptography/StandardTypes.sol';
              library VerificationKey1x1 {
                  function get_verification_key() external pure returns (StandardTypes.VerificationKey memory) {
                      StandardTypes.VerificationKey memory vk;
                      assembly {
                          mstore(add(vk, 0x00), 8388608) // vk.circuit_size
                          mstore(add(vk, 0x20), 17) // vk.num_inputs
                          mstore(add(vk, 0x40), 0x0210fe635ab4c74d6b7bcf70bc23a1395680c64022dd991fb54d4506ab80c59d) // vk.work_root
                          mstore(add(vk, 0x60), 0x30644e121894ba67550ff245e0f5eb5a25832df811e8df9dd100d30c2c14d821) // vk.domain_inverse
                          mstore(add(vk, 0x80), 0x2165a1a5bda6792b1dd75c9f4e2b8e61126a786ba1a6eadf811b03e7d69ca83b) // vk.work_root_inverse
                          mstore(mload(add(vk, 0xa0)), 0x0f7c715011823362f824b9de259a685032eedb928431724439a567967852d773) //vk.Q1
                          mstore(add(mload(add(vk, 0xa0)), 0x20), 0x17ec42a324359512a7d093faa7e55103b1f017af1bfaa5e1ccd31cc9e4ff8df0)
                          mstore(mload(add(vk, 0xc0)), 0x3010206be637307bc068ce5169be29f803e7fd6c2b69f653ca3b745864d30996) //vk.Q2
                          mstore(add(mload(add(vk, 0xc0)), 0x20), 0x0de1236425db4e2287118dec6d53937eb1cb8d3b4a0e3816ef3d9c61aa394cf0)
                          mstore(mload(add(vk, 0xe0)), 0x07c448ca9631b9d24fc45d555f1b1952134eaf083c3bd46a000fcf5434a94478) //vk.Q3
                          mstore(add(mload(add(vk, 0xe0)), 0x20), 0x0e18227b6c1a461c1cbb59826cac7ebabe89e6490d80312be1504d0f7fb98059)
                          mstore(mload(add(vk, 0x100)), 0x24a14b8c3bc0ee2a31a5a8bb1c69a1519a814de7c78cb5fe3248b1717893e7f8) //vk.QM
                          mstore(add(mload(add(vk, 0x100)), 0x20), 0x1abd8e73735327575cec64e8d3c20fe5ae58f23468478a9dc6aee652332ed569)
                          mstore(mload(add(vk, 0x120)), 0x1531778c4bbda77a659dd68bf49102ceb1ab6fbd96fd5cc2f7f335e3c1ec2ce5) //vk.QC
                          mstore(add(mload(add(vk, 0x120)), 0x20), 0x166f3cd25cc14370885bf52637ff5dc382c8a6243f552cfb96a09a64f314631f)
                          mstore(mload(add(vk, 0x140)), 0x289dcb3bb09ce8d1a5c6d08cdf87ba9fc0f22ea255cf644523a602e6d3ae348e) //vk.SIGMA1
                          mstore(add(mload(add(vk, 0x140)), 0x20), 0x2d21049d7f8b99c666d353e6f7101663ed09b4877f0a829d275bb83c223d1076)
                          mstore(mload(add(vk, 0x160)), 0x0d4e31a8d510770f6912e7ee0f7454ecaf51b4df1c5f5865e0017023eab933c8) //vk.SIGMA2
                          mstore(add(mload(add(vk, 0x160)), 0x20), 0x0f974eb06e1bae83bf339bc7d15b5ea18d826aa4c877ca1b63317e2a8debe7d1)
                          mstore(mload(add(vk, 0x180)), 0x2d1d6ae2a57defc6f3a789129f67f9c9969961b8642a92b91a9bdc0afb8b7f99) //vk.SIGMA3
                          mstore(add(mload(add(vk, 0x180)), 0x20), 0x300c3f15de1f550c772a7306a3a7e491b84ec7e7a9d4601c8b88107eff4f45ee)
                          mstore(add(vk, 0x1a0), 0x01) // vk.contains_recursive_proof
                          mstore(add(vk, 0x1c0), 1) // vk.recursive_proof_public_input_indices
                          mstore(mload(add(vk, 0x1e0)), 0x260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c1) // vk.g2_x.X.c1
                          mstore(add(mload(add(vk, 0x1e0)), 0x20), 0x0118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b0) // vk.g2_x.X.c0
                          mstore(add(mload(add(vk, 0x1e0)), 0x40), 0x04fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe4) // vk.g2_x.Y.c1
                          mstore(add(mload(add(vk, 0x1e0)), 0x60), 0x22febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55) // vk.g2_x.Y.c0
                      }
                      return vk;
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              import {StandardTypes} from '../cryptography/StandardTypes.sol';
              library MockVerificationKey {
                  function get_verification_key() external pure returns (StandardTypes.VerificationKey memory) {
                      StandardTypes.VerificationKey memory vk;
                      assembly {
                          mstore(add(vk, 0x00), 8192) // vk.circuit_size
                          mstore(add(vk, 0x20), 17) // vk.num_inputs
                          mstore(add(vk, 0x40), 0x006fab49b869ae62001deac878b2667bd31bf3e28e3a2d764aa49b8d9bbdd310) // vk.work_root
                          mstore(add(vk, 0x60), 0x3062cb506d9a969cb702833453cd4c52654aa6a93775a2c5bf57d68443608001) // vk.domain_inverse
                          mstore(add(vk, 0x80), 0x1670ed58bfac610408e124db6a1cb6c8c8df74fa978188ca3b0b205aabd95dc9) // vk.work_root_inverse
                          mstore(mload(add(vk, 0xa0)), 0x0be8a2b6819e5ed4fd15bb5cb484086e452297e53e83878519ea8dd5f7abbf2c) //vk.Q1
                          mstore(add(mload(add(vk, 0xa0)), 0x20), 0x295a1fca477ff3f65be1f71f2f4fc2df95cb23bf05de6b9cd2779348570c9236)
                          mstore(mload(add(vk, 0xc0)), 0x0b051497e878ea0d54f0004fec15b1c6d3be2d8872a688e39d43b61499942094) //vk.Q2
                          mstore(add(mload(add(vk, 0xc0)), 0x20), 0x19ae5022420456ca185141db41f6a64ed82b8a2217fd9d50f6dddb0dab725f45)
                          mstore(mload(add(vk, 0xe0)), 0x043a124edd1942909fbd2ba016716b174326462cf54f8c20e567eb39b858e83a) //vk.Q3
                          mstore(add(mload(add(vk, 0xe0)), 0x20), 0x0d50bd8e2c83217fdbf3c150d51f3b9e4baa4b1dc3ee57e305d3896a53bc3562)
                          mstore(mload(add(vk, 0x100)), 0x137d4c5f8e111374a1b162a273b058ac41c42735a7f26910443e48796206171c) //vk.QM
                          mstore(add(mload(add(vk, 0x100)), 0x20), 0x047e986785533350b315c24a1e029349870e22258c4c1293f7094a6376c1ab12)
                          mstore(mload(add(vk, 0x120)), 0x06a31854eac27a0a9b65f9b098d3a47ca10ee3d5ae1c178d9704e94c8b889f4b) //vk.QC
                          mstore(add(mload(add(vk, 0x120)), 0x20), 0x08d9b7926623abaab8b5decac0415b3849c112d3396b5296ee3a7a0a34285469)
                          mstore(mload(add(vk, 0x140)), 0x095f1b2a902ebe4a8351574b3ccbf9a2024b0e56b3d0cbe781b9244505d52894) //vk.SIGMA1
                          mstore(add(mload(add(vk, 0x140)), 0x20), 0x1314e8bb583f3166f76f0d1e1ce9f964c06d88e6bbecfc64ce38aab8df55f1fc)
                          mstore(mload(add(vk, 0x160)), 0x0db72f65f3a6cf58085528d93d19b58ea26919ac206b240822616015185d2f3d) //vk.SIGMA2
                          mstore(add(mload(add(vk, 0x160)), 0x20), 0x2b3c4c58a3cc75c104c9f0f5af5218616b71d7430df19b2a1bd5f4ecc0dac64e)
                          mstore(mload(add(vk, 0x180)), 0x09342cc8fc28c2fd14f3a3219c311575d4ab9adeba8385a53f201d8afba4312d) //vk.SIGMA3
                          mstore(add(mload(add(vk, 0x180)), 0x20), 0x1156442cf1bd1cd4d4583d3b21a054b3171b5452e4fa96a2ddcd769004ecd3d8)
                          mstore(add(vk, 0x1a0), 0x00) // vk.contains_recursive_proof
                          mstore(add(vk, 0x1c0), 0) // vk.recursive_proof_public_input_indices
                          mstore(mload(add(vk, 0x1e0)), 0x260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c1) // vk.g2_x.X.c1
                          mstore(add(mload(add(vk, 0x1e0)), 0x20), 0x0118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b0) // vk.g2_x.X.c0
                          mstore(add(mload(add(vk, 0x1e0)), 0x40), 0x04fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe4) // vk.g2_x.Y.c1
                          mstore(add(mload(add(vk, 0x1e0)), 0x60), 0x22febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55) // vk.g2_x.Y.c0
                      }
                      return vk;
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              import {IVerifier} from '../interfaces/IVerifier.sol';
              /**
               * @title Plonk proof verification contract
               * @dev Warning: do not deploy in real environments, for testing only
               * Mocks the role of a PLONK verifier contract
               */
              contract MockVerifier is IVerifier {
                  /**
                   * @dev Mock verify a Plonk proof
                   */
                  function verify(bytes memory, uint256) external pure override returns (bool) {
                      return true;
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              import {ERC20} from '@openzeppelin/contracts/token/ERC20/ERC20.sol';
              /**
               * @dev Warning: do not deploy in real environments, for testing only
               * ERC20 contract where anybody is able to mint
               */
              contract ERC20Mintable is ERC20 {
                  uint8 public asset_decimals = 18;
                  constructor(string memory symbol_) ERC20(symbol_, symbol_) {}
                  function mint(address _to, uint256 _value) public returns (bool) {
                      _mint(_to, _value);
                      return true;
                  }
                  function decimals() public view virtual override returns (uint8) {
                      return asset_decimals;
                  }
                  function setDecimals(uint8 _decimals) external {
                      asset_decimals = _decimals;
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              import {ERC20Mintable} from './ERC20Mintable.sol';
              import {IRollupProcessor} from '../interfaces/IRollupProcessor.sol';
              /**
               * @dev Warning: do not deploy in real environments, for testing only
               * ERC20 contract where the transfer() fn will always throw
               */
              contract ERC20Reenter is ERC20Mintable {
                  error LOCKED_NO_REENTER();
                  constructor() ERC20Mintable('TEST') {}
                  function transferFrom(
                      address,
                      address to,
                      uint256
                  ) public override returns (bool) {
                      IRollupProcessor(to).processRollup('', '');
                      return true;
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              import {ERC20Mintable} from './ERC20Mintable.sol';
              /**
               * @dev Warning: do not deploy in real environments, for testing only
               * ERC20 contract which has permit implementation and is mintable
               */
              contract ERC20Permit is ERC20Mintable {
                  bytes32 public DOMAIN_SEPARATOR;
                  bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
                  mapping(address => uint256) public nonces;
                  // bytes32 public constant PERMIT_TYPEHASH_NON_STANDARD = keccak256("Permit(address holder,address spender,uint256 nonce,uint256 expiry,bool allowed)");
                  bytes32 public constant PERMIT_TYPEHASH_NON_STANDARD =
                      0xea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb;
                  constructor(string memory symbol_) ERC20Mintable(symbol_) {
                      uint256 chainId;
                      assembly {
                          chainId := chainid()
                      }
                      DOMAIN_SEPARATOR = keccak256(
                          abi.encode(
                              keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'),
                              keccak256(bytes(name())),
                              keccak256(bytes('1')),
                              chainId,
                              address(this)
                          )
                      );
                  }
                  function permit(
                      address owner,
                      address spender,
                      uint256 value,
                      uint256 deadline,
                      uint8 v,
                      bytes32 r,
                      bytes32 s
                  ) external {
                      require(deadline >= block.timestamp, 'EXPIRED');
                      bytes32 digest = keccak256(
                          abi.encodePacked(
                              '\\x19\\x01',
                              DOMAIN_SEPARATOR,
                              keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline))
                          )
                      );
                      address recoveredAddress = ecrecover(digest, v, r, s);
                      require(recoveredAddress != address(0) && recoveredAddress == owner, 'INVALID_SIGNATURE');
                      _approve(owner, spender, value);
                  }
                  function permit(
                      address holder,
                      address spender,
                      uint256 nonce,
                      uint256 expiry,
                      bool allowed,
                      uint8 v,
                      bytes32 r,
                      bytes32 s
                  ) external {
                      bytes32 digest = keccak256(
                          abi.encodePacked(
                              '\\x19\\x01',
                              DOMAIN_SEPARATOR,
                              keccak256(abi.encode(PERMIT_TYPEHASH_NON_STANDARD, holder, spender, nonce, expiry, allowed))
                          )
                      );
                      require(holder != address(0), 'INVALID_HOLDER');
                      require(holder == ecrecover(digest, v, r, s), 'INVALID_SIGNATURE');
                      require(expiry == 0 || expiry >= block.timestamp, 'EXPIRED');
                      require(nonce == nonces[holder]++, 'INVALID_NONCE');
                      uint256 value = allowed ? (2**256) - 1 : 0;
                      _approve(holder, spender, value);
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              import {ERC20Mintable} from './ERC20Mintable.sol';
              /**
               * @dev Warning: do not deploy in real environments, for testing only
               * ERC20 contract where the transfer() fn will always throw
               */
              contract ERC20FaultyTransfer is ERC20Mintable {
                  constructor() ERC20Mintable('TEST') {}
                  function transfer(address, uint256) public pure override returns (bool) {
                      require(true == false, 'ERC20FaultyTransfer: FAILED');
                      return false;
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
              import {IDefiBridge} from '../interfaces/IDefiBridge.sol';
              import {AztecTypes} from '../AztecTypes.sol';
              /**
               * @dev Warning: do not deploy in real environments, for testing only
               */
              contract DummyDefiBridge is IDefiBridge {
                  address public immutable rollupProcessor;
                  uint256 immutable outputValueEth;
                  uint256 immutable outputValueToken;
                  uint256 immutable outputVirtualValueA;
                  uint256 immutable outputVirtualValueB;
                  receive() external payable {}
                  constructor(
                      address _rollupProcessor,
                      uint256 _outputValueEth,
                      uint256 _outputValueToken,
                      uint256 _outputVirtualValueA,
                      uint256 _outputVirtualValueB
                  ) {
                      rollupProcessor = _rollupProcessor;
                      outputValueEth = _outputValueEth;
                      outputValueToken = _outputValueToken;
                      outputVirtualValueA = _outputVirtualValueA;
                      outputVirtualValueB = _outputVirtualValueB;
                  }
                  function convert(
                      AztecTypes.AztecAsset memory, /*inputAssetA*/
                      AztecTypes.AztecAsset memory, /*inputAssetB*/
                      AztecTypes.AztecAsset memory outputAssetA,
                      AztecTypes.AztecAsset memory outputAssetB,
                      uint256, /*totalInputValue*/
                      uint256 interactionNonce,
                      uint64 auxData,
                      address
                  )
                      external
                      payable
                      override
                      returns (
                          uint256,
                          uint256,
                          bool
                      )
                  {
                      bool isAsync = auxData > 0;
                      if (isAsync) {
                          return (0, 0, isAsync);
                      }
                      uint256 returnValueA = approveTransfer(outputAssetA, outputVirtualValueA, interactionNonce);
                      uint256 returnValueB = approveTransfer(outputAssetB, outputVirtualValueB, interactionNonce);
                      return (returnValueA, returnValueB, isAsync);
                  }
                  function canFinalise(
                      uint256 /*interactionNonce*/
                  ) external pure override returns (bool) {
                      return true;
                  }
                  function finalise(
                      AztecTypes.AztecAsset memory, /*inputAssetA*/
                      AztecTypes.AztecAsset memory, /*inputAssetB*/
                      AztecTypes.AztecAsset memory outputAssetA,
                      AztecTypes.AztecAsset memory outputAssetB,
                      uint256 interactionNonce,
                      uint64
                  )
                      external
                      payable
                      override
                      returns (
                          uint256,
                          uint256,
                          bool
                      )
                  {
                      require(msg.sender == rollupProcessor, 'invalid sender!');
                      uint256 returnValueA = approveTransfer(outputAssetA, outputVirtualValueA, interactionNonce);
                      uint256 returnValueB = approveTransfer(outputAssetB, outputVirtualValueB, interactionNonce);
                      return (returnValueA, returnValueB, true);
                  }
                  function approveTransfer(
                      AztecTypes.AztecAsset memory asset,
                      uint256 virtualValue,
                      uint256 interactionNonce
                  ) internal returns (uint256 returnValue) {
                      if (asset.assetType == AztecTypes.AztecAssetType.VIRTUAL) {
                          returnValue = virtualValue;
                      } else if (asset.assetType == AztecTypes.AztecAssetType.ETH) {
                          returnValue = outputValueEth;
                          bytes memory payload = abi.encodeWithSignature('receiveEthFromBridge(uint256)', interactionNonce);
                          (bool success, ) = address(rollupProcessor).call{value: outputValueEth}(payload);
                          assembly {
                              if iszero(success) {
                                  returndatacopy(0x00, 0x00, returndatasize())
                                  revert(0x00, returndatasize())
                              }
                          }
                      } else if (asset.assetType == AztecTypes.AztecAssetType.ERC20) {
                          returnValue = outputValueToken;
                          IERC20(asset.erc20Address).approve(rollupProcessor, outputValueToken);
                      }
                  }
              }
              

              File 9 of 12: RollupProcessorV2
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)
              pragma solidity ^0.8.0;
              import "./IAccessControl.sol";
              import "../utils/Context.sol";
              import "../utils/Strings.sol";
              import "../utils/introspection/ERC165.sol";
              /**
               * @dev Contract module that allows children to implement role-based access
               * control mechanisms. This is a lightweight version that doesn't allow enumerating role
               * members except through off-chain means by accessing the contract event logs. Some
               * applications may benefit from on-chain enumerability, for those cases see
               * {AccessControlEnumerable}.
               *
               * Roles are referred to by their `bytes32` identifier. These should be exposed
               * in the external API and be unique. The best way to achieve this is by
               * using `public constant` hash digests:
               *
               * ```
               * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
               * ```
               *
               * Roles can be used to represent a set of permissions. To restrict access to a
               * function call, use {hasRole}:
               *
               * ```
               * function foo() public {
               *     require(hasRole(MY_ROLE, msg.sender));
               *     ...
               * }
               * ```
               *
               * Roles can be granted and revoked dynamically via the {grantRole} and
               * {revokeRole} functions. Each role has an associated admin role, and only
               * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
               *
               * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
               * that only accounts with this role will be able to grant or revoke other
               * roles. More complex role relationships can be created by using
               * {_setRoleAdmin}.
               *
               * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
               * grant and revoke this role. Extra precautions should be taken to secure
               * accounts that have been granted it.
               */
              abstract contract AccessControl is Context, IAccessControl, ERC165 {
                  struct RoleData {
                      mapping(address => bool) members;
                      bytes32 adminRole;
                  }
                  mapping(bytes32 => RoleData) private _roles;
                  bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
                  /**
                   * @dev Modifier that checks that an account has a specific role. Reverts
                   * with a standardized message including the required role.
                   *
                   * The format of the revert reason is given by the following regular expression:
                   *
                   *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
                   *
                   * _Available since v4.1._
                   */
                  modifier onlyRole(bytes32 role) {
                      _checkRole(role);
                      _;
                  }
                  /**
                   * @dev See {IERC165-supportsInterface}.
                   */
                  function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
                      return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
                  }
                  /**
                   * @dev Returns `true` if `account` has been granted `role`.
                   */
                  function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
                      return _roles[role].members[account];
                  }
                  /**
                   * @dev Revert with a standard message if `_msgSender()` is missing `role`.
                   * Overriding this function changes the behavior of the {onlyRole} modifier.
                   *
                   * Format of the revert message is described in {_checkRole}.
                   *
                   * _Available since v4.6._
                   */
                  function _checkRole(bytes32 role) internal view virtual {
                      _checkRole(role, _msgSender());
                  }
                  /**
                   * @dev Revert with a standard message if `account` is missing `role`.
                   *
                   * The format of the revert reason is given by the following regular expression:
                   *
                   *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
                   */
                  function _checkRole(bytes32 role, address account) internal view virtual {
                      if (!hasRole(role, account)) {
                          revert(
                              string(
                                  abi.encodePacked(
                                      "AccessControl: account ",
                                      Strings.toHexString(account),
                                      " is missing role ",
                                      Strings.toHexString(uint256(role), 32)
                                  )
                              )
                          );
                      }
                  }
                  /**
                   * @dev Returns the admin role that controls `role`. See {grantRole} and
                   * {revokeRole}.
                   *
                   * To change a role's admin, use {_setRoleAdmin}.
                   */
                  function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
                      return _roles[role].adminRole;
                  }
                  /**
                   * @dev Grants `role` to `account`.
                   *
                   * If `account` had not been already granted `role`, emits a {RoleGranted}
                   * event.
                   *
                   * Requirements:
                   *
                   * - the caller must have ``role``'s admin role.
                   *
                   * May emit a {RoleGranted} event.
                   */
                  function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
                      _grantRole(role, account);
                  }
                  /**
                   * @dev Revokes `role` from `account`.
                   *
                   * If `account` had been granted `role`, emits a {RoleRevoked} event.
                   *
                   * Requirements:
                   *
                   * - the caller must have ``role``'s admin role.
                   *
                   * May emit a {RoleRevoked} event.
                   */
                  function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
                      _revokeRole(role, account);
                  }
                  /**
                   * @dev Revokes `role` from the calling account.
                   *
                   * Roles are often managed via {grantRole} and {revokeRole}: this function's
                   * purpose is to provide a mechanism for accounts to lose their privileges
                   * if they are compromised (such as when a trusted device is misplaced).
                   *
                   * If the calling account had been revoked `role`, emits a {RoleRevoked}
                   * event.
                   *
                   * Requirements:
                   *
                   * - the caller must be `account`.
                   *
                   * May emit a {RoleRevoked} event.
                   */
                  function renounceRole(bytes32 role, address account) public virtual override {
                      require(account == _msgSender(), "AccessControl: can only renounce roles for self");
                      _revokeRole(role, account);
                  }
                  /**
                   * @dev Grants `role` to `account`.
                   *
                   * If `account` had not been already granted `role`, emits a {RoleGranted}
                   * event. Note that unlike {grantRole}, this function doesn't perform any
                   * checks on the calling account.
                   *
                   * May emit a {RoleGranted} event.
                   *
                   * [WARNING]
                   * ====
                   * This function should only be called from the constructor when setting
                   * up the initial roles for the system.
                   *
                   * Using this function in any other way is effectively circumventing the admin
                   * system imposed by {AccessControl}.
                   * ====
                   *
                   * NOTE: This function is deprecated in favor of {_grantRole}.
                   */
                  function _setupRole(bytes32 role, address account) internal virtual {
                      _grantRole(role, account);
                  }
                  /**
                   * @dev Sets `adminRole` as ``role``'s admin role.
                   *
                   * Emits a {RoleAdminChanged} event.
                   */
                  function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
                      bytes32 previousAdminRole = getRoleAdmin(role);
                      _roles[role].adminRole = adminRole;
                      emit RoleAdminChanged(role, previousAdminRole, adminRole);
                  }
                  /**
                   * @dev Grants `role` to `account`.
                   *
                   * Internal function without access restriction.
                   *
                   * May emit a {RoleGranted} event.
                   */
                  function _grantRole(bytes32 role, address account) internal virtual {
                      if (!hasRole(role, account)) {
                          _roles[role].members[account] = true;
                          emit RoleGranted(role, account, _msgSender());
                      }
                  }
                  /**
                   * @dev Revokes `role` from `account`.
                   *
                   * Internal function without access restriction.
                   *
                   * May emit a {RoleRevoked} event.
                   */
                  function _revokeRole(bytes32 role, address account) internal virtual {
                      if (hasRole(role, account)) {
                          _roles[role].members[account] = false;
                          emit RoleRevoked(role, account, _msgSender());
                      }
                  }
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
              pragma solidity ^0.8.0;
              /**
               * @dev External interface of AccessControl declared to support ERC165 detection.
               */
              interface IAccessControl {
                  /**
                   * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
                   *
                   * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
                   * {RoleAdminChanged} not being emitted signaling this.
                   *
                   * _Available since v3.1._
                   */
                  event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
                  /**
                   * @dev Emitted when `account` is granted `role`.
                   *
                   * `sender` is the account that originated the contract call, an admin role
                   * bearer except when using {AccessControl-_setupRole}.
                   */
                  event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
                  /**
                   * @dev Emitted when `account` is revoked `role`.
                   *
                   * `sender` is the account that originated the contract call:
                   *   - if using `revokeRole`, it is the admin role bearer
                   *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
                   */
                  event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
                  /**
                   * @dev Returns `true` if `account` has been granted `role`.
                   */
                  function hasRole(bytes32 role, address account) external view returns (bool);
                  /**
                   * @dev Returns the admin role that controls `role`. See {grantRole} and
                   * {revokeRole}.
                   *
                   * To change a role's admin, use {AccessControl-_setRoleAdmin}.
                   */
                  function getRoleAdmin(bytes32 role) external view returns (bytes32);
                  /**
                   * @dev Grants `role` to `account`.
                   *
                   * If `account` had not been already granted `role`, emits a {RoleGranted}
                   * event.
                   *
                   * Requirements:
                   *
                   * - the caller must have ``role``'s admin role.
                   */
                  function grantRole(bytes32 role, address account) external;
                  /**
                   * @dev Revokes `role` from `account`.
                   *
                   * If `account` had been granted `role`, emits a {RoleRevoked} event.
                   *
                   * Requirements:
                   *
                   * - the caller must have ``role``'s admin role.
                   */
                  function revokeRole(bytes32 role, address account) external;
                  /**
                   * @dev Revokes `role` from the calling account.
                   *
                   * Roles are often managed via {grantRole} and {revokeRole}: this function's
                   * purpose is to provide a mechanism for accounts to lose their privileges
                   * if they are compromised (such as when a trusted device is misplaced).
                   *
                   * If the calling account had been granted `role`, emits a {RoleRevoked}
                   * event.
                   *
                   * Requirements:
                   *
                   * - the caller must be `account`.
                   */
                  function renounceRole(bytes32 role, address account) external;
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
              pragma solidity ^0.8.0;
              /**
               * @dev Interface of the ERC20 standard as defined in the EIP.
               */
              interface IERC20 {
                  /**
                   * @dev Emitted when `value` tokens are moved from one account (`from`) to
                   * another (`to`).
                   *
                   * Note that `value` may be zero.
                   */
                  event Transfer(address indexed from, address indexed to, uint256 value);
                  /**
                   * @dev Emitted when the allowance of a `spender` for an `owner` is set by
                   * a call to {approve}. `value` is the new allowance.
                   */
                  event Approval(address indexed owner, address indexed spender, uint256 value);
                  /**
                   * @dev Returns the amount of tokens in existence.
                   */
                  function totalSupply() external view returns (uint256);
                  /**
                   * @dev Returns the amount of tokens owned by `account`.
                   */
                  function balanceOf(address account) external view returns (uint256);
                  /**
                   * @dev Moves `amount` tokens from the caller's account to `to`.
                   *
                   * Returns a boolean value indicating whether the operation succeeded.
                   *
                   * Emits a {Transfer} event.
                   */
                  function transfer(address to, uint256 amount) external returns (bool);
                  /**
                   * @dev Returns the remaining number of tokens that `spender` will be
                   * allowed to spend on behalf of `owner` through {transferFrom}. This is
                   * zero by default.
                   *
                   * This value changes when {approve} or {transferFrom} are called.
                   */
                  function allowance(address owner, address spender) external view returns (uint256);
                  /**
                   * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
                   *
                   * Returns a boolean value indicating whether the operation succeeded.
                   *
                   * IMPORTANT: Beware that changing an allowance with this method brings the risk
                   * that someone may use both the old and the new allowance by unfortunate
                   * transaction ordering. One possible solution to mitigate this race
                   * condition is to first reduce the spender's allowance to 0 and set the
                   * desired value afterwards:
                   * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
                   *
                   * Emits an {Approval} event.
                   */
                  function approve(address spender, uint256 amount) external returns (bool);
                  /**
                   * @dev Moves `amount` tokens from `from` to `to` using the
                   * allowance mechanism. `amount` is then deducted from the caller's
                   * allowance.
                   *
                   * Returns a boolean value indicating whether the operation succeeded.
                   *
                   * Emits a {Transfer} event.
                   */
                  function transferFrom(
                      address from,
                      address to,
                      uint256 amount
                  ) external returns (bool);
              }
              // 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;
                  }
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)
              pragma solidity ^0.8.0;
              import "./math/Math.sol";
              /**
               * @dev String operations.
               */
              library Strings {
                  bytes16 private constant _SYMBOLS = "0123456789abcdef";
                  uint8 private constant _ADDRESS_LENGTH = 20;
                  /**
                   * @dev Converts a `uint256` to its ASCII `string` decimal representation.
                   */
                  function toString(uint256 value) internal pure returns (string memory) {
                      unchecked {
                          uint256 length = Math.log10(value) + 1;
                          string memory buffer = new string(length);
                          uint256 ptr;
                          /// @solidity memory-safe-assembly
                          assembly {
                              ptr := add(buffer, add(32, length))
                          }
                          while (true) {
                              ptr--;
                              /// @solidity memory-safe-assembly
                              assembly {
                                  mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                              }
                              value /= 10;
                              if (value == 0) break;
                          }
                          return buffer;
                      }
                  }
                  /**
                   * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
                   */
                  function toHexString(uint256 value) internal pure returns (string memory) {
                      unchecked {
                          return toHexString(value, Math.log256(value) + 1);
                      }
                  }
                  /**
                   * @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] = _SYMBOLS[value & 0xf];
                          value >>= 4;
                      }
                      require(value == 0, "Strings: hex length insufficient");
                      return string(buffer);
                  }
                  /**
                   * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
                   */
                  function toHexString(address addr) internal pure returns (string memory) {
                      return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
                  }
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
              pragma solidity ^0.8.0;
              import "./IERC165.sol";
              /**
               * @dev Implementation of the {IERC165} interface.
               *
               * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
               * for the additional interface id that will be supported. For example:
               *
               * ```solidity
               * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
               *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
               * }
               * ```
               *
               * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
               */
              abstract contract ERC165 is IERC165 {
                  /**
                   * @dev See {IERC165-supportsInterface}.
                   */
                  function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
                      return interfaceId == type(IERC165).interfaceId;
                  }
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
              pragma solidity ^0.8.0;
              /**
               * @dev Interface of the ERC165 standard, as defined in the
               * https://eips.ethereum.org/EIPS/eip-165[EIP].
               *
               * Implementers can declare support of contract interfaces, which can then be
               * queried by others ({ERC165Checker}).
               *
               * For an implementation, see {ERC165}.
               */
              interface IERC165 {
                  /**
                   * @dev Returns true if this contract implements the interface defined by
                   * `interfaceId`. See the corresponding
                   * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
                   * to learn more about how these ids are created.
                   *
                   * This function call must use less than 30 000 gas.
                   */
                  function supportsInterface(bytes4 interfaceId) external view returns (bool);
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol)
              pragma solidity ^0.8.0;
              /**
               * @dev Standard math utilities missing in the Solidity language.
               */
              library Math {
                  enum Rounding {
                      Down, // Toward negative infinity
                      Up, // Toward infinity
                      Zero // Toward zero
                  }
                  /**
                   * @dev Returns the largest of two numbers.
                   */
                  function max(uint256 a, uint256 b) internal pure returns (uint256) {
                      return a > b ? a : b;
                  }
                  /**
                   * @dev Returns the smallest of two numbers.
                   */
                  function min(uint256 a, uint256 b) internal pure returns (uint256) {
                      return a < b ? a : b;
                  }
                  /**
                   * @dev Returns the average of two numbers. The result is rounded towards
                   * zero.
                   */
                  function average(uint256 a, uint256 b) internal pure returns (uint256) {
                      // (a + b) / 2 can overflow.
                      return (a & b) + (a ^ b) / 2;
                  }
                  /**
                   * @dev Returns the ceiling of the division of two numbers.
                   *
                   * This differs from standard division with `/` in that it rounds up instead
                   * of rounding down.
                   */
                  function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
                      // (a + b - 1) / b can overflow on addition, so we distribute.
                      return a == 0 ? 0 : (a - 1) / b + 1;
                  }
                  /**
                   * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
                   * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
                   * with further edits by Uniswap Labs also under MIT license.
                   */
                  function mulDiv(
                      uint256 x,
                      uint256 y,
                      uint256 denominator
                  ) internal pure returns (uint256 result) {
                      unchecked {
                          // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
                          // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
                          // variables such that product = prod1 * 2^256 + prod0.
                          uint256 prod0; // Least significant 256 bits of the product
                          uint256 prod1; // Most significant 256 bits of the product
                          assembly {
                              let mm := mulmod(x, y, not(0))
                              prod0 := mul(x, y)
                              prod1 := sub(sub(mm, prod0), lt(mm, prod0))
                          }
                          // Handle non-overflow cases, 256 by 256 division.
                          if (prod1 == 0) {
                              return prod0 / denominator;
                          }
                          // Make sure the result is less than 2^256. Also prevents denominator == 0.
                          require(denominator > prod1);
                          ///////////////////////////////////////////////
                          // 512 by 256 division.
                          ///////////////////////////////////////////////
                          // Make division exact by subtracting the remainder from [prod1 prod0].
                          uint256 remainder;
                          assembly {
                              // Compute remainder using mulmod.
                              remainder := mulmod(x, y, denominator)
                              // Subtract 256 bit number from 512 bit number.
                              prod1 := sub(prod1, gt(remainder, prod0))
                              prod0 := sub(prod0, remainder)
                          }
                          // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
                          // See https://cs.stackexchange.com/q/138556/92363.
                          // Does not overflow because the denominator cannot be zero at this stage in the function.
                          uint256 twos = denominator & (~denominator + 1);
                          assembly {
                              // Divide denominator by twos.
                              denominator := div(denominator, twos)
                              // Divide [prod1 prod0] by twos.
                              prod0 := div(prod0, twos)
                              // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                              twos := add(div(sub(0, twos), twos), 1)
                          }
                          // Shift in bits from prod1 into prod0.
                          prod0 |= prod1 * twos;
                          // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
                          // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
                          // four bits. That is, denominator * inv = 1 mod 2^4.
                          uint256 inverse = (3 * denominator) ^ 2;
                          // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
                          // in modular arithmetic, doubling the correct bits in each step.
                          inverse *= 2 - denominator * inverse; // inverse mod 2^8
                          inverse *= 2 - denominator * inverse; // inverse mod 2^16
                          inverse *= 2 - denominator * inverse; // inverse mod 2^32
                          inverse *= 2 - denominator * inverse; // inverse mod 2^64
                          inverse *= 2 - denominator * inverse; // inverse mod 2^128
                          inverse *= 2 - denominator * inverse; // inverse mod 2^256
                          // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
                          // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
                          // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
                          // is no longer required.
                          result = prod0 * inverse;
                          return result;
                      }
                  }
                  /**
                   * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
                   */
                  function mulDiv(
                      uint256 x,
                      uint256 y,
                      uint256 denominator,
                      Rounding rounding
                  ) internal pure returns (uint256) {
                      uint256 result = mulDiv(x, y, denominator);
                      if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
                          result += 1;
                      }
                      return result;
                  }
                  /**
                   * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
                   *
                   * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
                   */
                  function sqrt(uint256 a) internal pure returns (uint256) {
                      if (a == 0) {
                          return 0;
                      }
                      // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
                      //
                      // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
                      // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
                      //
                      // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
                      // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
                      // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
                      //
                      // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
                      uint256 result = 1 << (log2(a) >> 1);
                      // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
                      // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
                      // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
                      // into the expected uint128 result.
                      unchecked {
                          result = (result + a / result) >> 1;
                          result = (result + a / result) >> 1;
                          result = (result + a / result) >> 1;
                          result = (result + a / result) >> 1;
                          result = (result + a / result) >> 1;
                          result = (result + a / result) >> 1;
                          result = (result + a / result) >> 1;
                          return min(result, a / result);
                      }
                  }
                  /**
                   * @notice Calculates sqrt(a), following the selected rounding direction.
                   */
                  function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
                      unchecked {
                          uint256 result = sqrt(a);
                          return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
                      }
                  }
                  /**
                   * @dev Return the log in base 2, rounded down, of a positive value.
                   * Returns 0 if given 0.
                   */
                  function log2(uint256 value) internal pure returns (uint256) {
                      uint256 result = 0;
                      unchecked {
                          if (value >> 128 > 0) {
                              value >>= 128;
                              result += 128;
                          }
                          if (value >> 64 > 0) {
                              value >>= 64;
                              result += 64;
                          }
                          if (value >> 32 > 0) {
                              value >>= 32;
                              result += 32;
                          }
                          if (value >> 16 > 0) {
                              value >>= 16;
                              result += 16;
                          }
                          if (value >> 8 > 0) {
                              value >>= 8;
                              result += 8;
                          }
                          if (value >> 4 > 0) {
                              value >>= 4;
                              result += 4;
                          }
                          if (value >> 2 > 0) {
                              value >>= 2;
                              result += 2;
                          }
                          if (value >> 1 > 0) {
                              result += 1;
                          }
                      }
                      return result;
                  }
                  /**
                   * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
                   * Returns 0 if given 0.
                   */
                  function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
                      unchecked {
                          uint256 result = log2(value);
                          return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
                      }
                  }
                  /**
                   * @dev Return the log in base 10, rounded down, of a positive value.
                   * Returns 0 if given 0.
                   */
                  function log10(uint256 value) internal pure returns (uint256) {
                      uint256 result = 0;
                      unchecked {
                          if (value >= 10**64) {
                              value /= 10**64;
                              result += 64;
                          }
                          if (value >= 10**32) {
                              value /= 10**32;
                              result += 32;
                          }
                          if (value >= 10**16) {
                              value /= 10**16;
                              result += 16;
                          }
                          if (value >= 10**8) {
                              value /= 10**8;
                              result += 8;
                          }
                          if (value >= 10**4) {
                              value /= 10**4;
                              result += 4;
                          }
                          if (value >= 10**2) {
                              value /= 10**2;
                              result += 2;
                          }
                          if (value >= 10**1) {
                              result += 1;
                          }
                      }
                      return result;
                  }
                  /**
                   * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
                   * Returns 0 if given 0.
                   */
                  function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
                      unchecked {
                          uint256 result = log10(value);
                          return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
                      }
                  }
                  /**
                   * @dev Return the log in base 256, rounded down, of a positive value.
                   * Returns 0 if given 0.
                   *
                   * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
                   */
                  function log256(uint256 value) internal pure returns (uint256) {
                      uint256 result = 0;
                      unchecked {
                          if (value >> 128 > 0) {
                              value >>= 128;
                              result += 16;
                          }
                          if (value >> 64 > 0) {
                              value >>= 64;
                              result += 8;
                          }
                          if (value >> 32 > 0) {
                              value >>= 32;
                              result += 4;
                          }
                          if (value >> 16 > 0) {
                              value >>= 16;
                              result += 2;
                          }
                          if (value >> 8 > 0) {
                              result += 1;
                          }
                      }
                      return result;
                  }
                  /**
                   * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
                   * Returns 0 if given 0.
                   */
                  function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
                      unchecked {
                          uint256 result = log256(value);
                          return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
                      }
                  }
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)
              pragma solidity ^0.8.2;
              import "../../utils/AddressUpgradeable.sol";
              /**
               * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
               * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
               * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
               * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
               *
               * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
               * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
               * case an upgrade adds a module that needs to be initialized.
               *
               * For example:
               *
               * [.hljs-theme-light.nopadding]
               * ```
               * contract MyToken is ERC20Upgradeable {
               *     function initialize() initializer public {
               *         __ERC20_init("MyToken", "MTK");
               *     }
               * }
               * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
               *     function initializeV2() reinitializer(2) public {
               *         __ERC20Permit_init("MyToken");
               *     }
               * }
               * ```
               *
               * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
               * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
               *
               * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
               * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
               *
               * [CAUTION]
               * ====
               * Avoid leaving a contract uninitialized.
               *
               * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
               * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
               * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
               *
               * [.hljs-theme-light.nopadding]
               * ```
               * /// @custom:oz-upgrades-unsafe-allow constructor
               * constructor() {
               *     _disableInitializers();
               * }
               * ```
               * ====
               */
              abstract contract Initializable {
                  /**
                   * @dev Indicates that the contract has been initialized.
                   * @custom:oz-retyped-from bool
                   */
                  uint8 private _initialized;
                  /**
                   * @dev Indicates that the contract is in the process of being initialized.
                   */
                  bool private _initializing;
                  /**
                   * @dev Triggered when the contract has been initialized or reinitialized.
                   */
                  event Initialized(uint8 version);
                  /**
                   * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
                   * `onlyInitializing` functions can be used to initialize parent contracts.
                   *
                   * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
                   * constructor.
                   *
                   * Emits an {Initialized} event.
                   */
                  modifier initializer() {
                      bool isTopLevelCall = !_initializing;
                      require(
                          (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
                          "Initializable: contract is already initialized"
                      );
                      _initialized = 1;
                      if (isTopLevelCall) {
                          _initializing = true;
                      }
                      _;
                      if (isTopLevelCall) {
                          _initializing = false;
                          emit Initialized(1);
                      }
                  }
                  /**
                   * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
                   * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
                   * used to initialize parent contracts.
                   *
                   * A reinitializer may be used after the original initialization step. This is essential to configure modules that
                   * are added through upgrades and that require initialization.
                   *
                   * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
                   * cannot be nested. If one is invoked in the context of another, execution will revert.
                   *
                   * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
                   * a contract, executing them in the right order is up to the developer or operator.
                   *
                   * WARNING: setting the version to 255 will prevent any future reinitialization.
                   *
                   * Emits an {Initialized} event.
                   */
                  modifier reinitializer(uint8 version) {
                      require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
                      _initialized = version;
                      _initializing = true;
                      _;
                      _initializing = false;
                      emit Initialized(version);
                  }
                  /**
                   * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
                   * {initializer} and {reinitializer} modifiers, directly or indirectly.
                   */
                  modifier onlyInitializing() {
                      require(_initializing, "Initializable: contract is not initializing");
                      _;
                  }
                  /**
                   * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
                   * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
                   * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
                   * through proxies.
                   *
                   * Emits an {Initialized} event the first time it is successfully executed.
                   */
                  function _disableInitializers() internal virtual {
                      require(!_initializing, "Initializable: contract is initializing");
                      if (_initialized != type(uint8).max) {
                          _initialized = type(uint8).max;
                          emit Initialized(type(uint8).max);
                      }
                  }
                  /**
                   * @dev Internal function that returns the initialized version. Returns `_initialized`
                   */
                  function _getInitializedVersion() internal view returns (uint8) {
                      return _initialized;
                  }
                  /**
                   * @dev Internal function that returns the initialized version. Returns `_initializing`
                   */
                  function _isInitializing() internal view returns (bool) {
                      return _initializing;
                  }
              }
              // SPDX-License-Identifier: MIT
              // OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)
              pragma solidity ^0.8.1;
              /**
               * @dev Collection of functions related to the address type
               */
              library AddressUpgradeable {
                  /**
                   * @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://consensys.net/diligence/blog/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 functionCallWithValue(target, data, 0, "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");
                      (bool success, bytes memory returndata) = target.call{value: value}(data);
                      return verifyCallResultFromTarget(target, 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) {
                      (bool success, bytes memory returndata) = target.staticcall(data);
                      return verifyCallResultFromTarget(target, success, returndata, errorMessage);
                  }
                  /**
                   * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
                   * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
                   *
                   * _Available since v4.8._
                   */
                  function verifyCallResultFromTarget(
                      address target,
                      bool success,
                      bytes memory returndata,
                      string memory errorMessage
                  ) internal view returns (bytes memory) {
                      if (success) {
                          if (returndata.length == 0) {
                              // only check isContract if the call was successful and the return data is empty
                              // otherwise we already know that it was a contract
                              require(isContract(target), "Address: call to non-contract");
                          }
                          return returndata;
                      } else {
                          _revert(returndata, errorMessage);
                      }
                  }
                  /**
                   * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
                   * revert reason or 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 {
                          _revert(returndata, errorMessage);
                      }
                  }
                  function _revert(bytes memory returndata, string memory errorMessage) private pure {
                      // 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
                          /// @solidity memory-safe-assembly
                          assembly {
                              let returndata_size := mload(returndata)
                              revert(add(32, returndata), returndata_size)
                          }
                      } else {
                          revert(errorMessage);
                      }
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              // @dev For documentation of the functions within this interface see RollupProcessor contract
              interface IRollupProcessor {
                  /*----------------------------------------
                    MUTATING FUNCTIONS
                    ----------------------------------------*/
                  function pause() external;
                  function unpause() external;
                  function setRollupProvider(address _provider, bool _valid) external;
                  function setVerifier(address _verifier) external;
                  function setAllowThirdPartyContracts(bool _allowThirdPartyContracts) external;
                  function setDefiBridgeProxy(address _defiBridgeProxy) external;
                  function setSupportedAsset(address _token, uint256 _gasLimit) external;
                  function setSupportedBridge(address _bridge, uint256 _gasLimit) external;
                  function processRollup(bytes calldata _encodedProofData, bytes calldata _signatures) external;
                  function receiveEthFromBridge(uint256 _interactionNonce) external payable;
                  function approveProof(bytes32 _proofHash) external;
                  function depositPendingFunds(uint256 _assetId, uint256 _amount, address _owner, bytes32 _proofHash)
                      external
                      payable;
                  function offchainData(uint256 _rollupId, uint256 _chunk, uint256 _totalChunks, bytes calldata _offchainTxData)
                      external;
                  function processAsyncDefiInteraction(uint256 _interactionNonce) external returns (bool);
                  /*----------------------------------------
                    NON-MUTATING FUNCTIONS
                    ----------------------------------------*/
                  function rollupStateHash() external view returns (bytes32);
                  function userPendingDeposits(uint256 _assetId, address _user) external view returns (uint256);
                  function defiBridgeProxy() external view returns (address);
                  function prevDefiInteractionsHash() external view returns (bytes32);
                  function paused() external view returns (bool);
                  function verifier() external view returns (address);
                  function getDataSize() external view returns (uint256);
                  function getPendingDefiInteractionHashesLength() external view returns (uint256);
                  function getDefiInteractionHashesLength() external view returns (uint256);
                  function getAsyncDefiInteractionHashesLength() external view returns (uint256);
                  function getSupportedBridge(uint256 _bridgeAddressId) external view returns (address);
                  function getSupportedBridgesLength() external view returns (uint256);
                  function getSupportedAssetsLength() external view returns (uint256);
                  function getSupportedAsset(uint256 _assetId) external view returns (address);
                  function getEscapeHatchStatus() external view returns (bool, uint256);
                  function assetGasLimits(uint256 _bridgeAddressId) external view returns (uint256);
                  function bridgeGasLimits(uint256 _bridgeAddressId) external view returns (uint256);
                  function allowThirdPartyContracts() external view returns (bool);
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              import {IRollupProcessor} from "./IRollupProcessor.sol";
              // @dev For documentation of the functions within this interface see RollupProcessorV2 contract
              interface IRollupProcessorV2 is IRollupProcessor {
                  function getCapped() external view returns (bool);
                  function defiInteractionHashes(uint256) external view returns (bytes32);
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              library AztecTypes {
                  enum AztecAssetType {
                      NOT_USED,
                      ETH,
                      ERC20,
                      VIRTUAL
                  }
                  struct AztecAsset {
                      uint256 id;
                      address erc20Address;
                      AztecAssetType assetType;
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              library RollupProcessorLibrary {
                  error SIGNATURE_ADDRESS_IS_ZERO();
                  error SIGNATURE_RECOVERY_FAILED();
                  error INVALID_SIGNATURE();
                  /**
                   * Extracts the address of the signer with ECDSA. Performs checks on `s` and `v` to
                   * to prevent signature malleability based attacks
                   * @param digest - Hashed data being signed over.
                   * @param signature - ECDSA signature over the secp256k1 elliptic curve.
                   * @param signer - Address that signs the signature.
                   */
                  function validateSignature(bytes32 digest, bytes memory signature, address signer) internal view {
                      bool result;
                      address recoveredSigner = address(0x0);
                      if (signer == address(0x0)) {
                          revert SIGNATURE_ADDRESS_IS_ZERO();
                      }
                      // prepend "\\x19Ethereum Signed Message:\
              32" to the digest to create the signed message
                      bytes32 message;
                      assembly {
                          mstore(0, "\\x19Ethereum Signed Message:\
              32")
                          mstore(add(0, 28), digest)
                          message := keccak256(0, 60)
                      }
                      assembly {
                          let mPtr := mload(0x40)
                          let byteLength := mload(signature)
                          // store the signature digest
                          mstore(mPtr, message)
                          // load 'v' - we need it for a condition check
                          // add 0x60 to jump over 3 words - length of bytes array, r and s
                          let v := shr(248, mload(add(signature, 0x60))) // bitshifting, to resemble padLeft
                          let s := mload(add(signature, 0x40))
                          /**
                           * Original memory map for input to precompile
                           *
                           * signature : signature + 0x20            message
                           * signature + 0x20 : signature + 0x40     r
                           * signature + 0x40 : signature + 0x60     s
                           * signature + 0x60 : signature + 0x80     v
                           * Desired memory map for input to precompile
                           *
                           * signature : signature + 0x20            message
                           * signature + 0x20 : signature + 0x40     v
                           * signature + 0x40 : signature + 0x60     r
                           * signature + 0x60 : signature + 0x80     s
                           */
                          // store s
                          mstore(add(mPtr, 0x60), s)
                          // store r
                          mstore(add(mPtr, 0x40), mload(add(signature, 0x20)))
                          // store v
                          mstore(add(mPtr, 0x20), v)
                          result :=
                              and(
                                  and(
                                      // validate s is in lower half order
                                      lt(s, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A1),
                                      and(
                                          // validate signature length == 0x41
                                          eq(byteLength, 0x41),
                                          // validate v == 27 or v == 28
                                          or(eq(v, 27), eq(v, 28))
                                      )
                                  ),
                                  // validate call to ecrecover precompile succeeds
                                  staticcall(gas(), 0x01, mPtr, 0x80, mPtr, 0x20)
                              )
                          // save the recoveredSigner only if the first word in signature is not `message` anymore
                          switch eq(message, mload(mPtr))
                          case 0 { recoveredSigner := mload(mPtr) }
                          mstore(mPtr, byteLength) // and put the byte length back where it belongs
                          // validate that recoveredSigner is not address(0x00)
                          result := and(result, not(iszero(recoveredSigner)))
                      }
                      if (!result) {
                          revert SIGNATURE_RECOVERY_FAILED();
                      }
                      if (recoveredSigner != signer) {
                          revert INVALID_SIGNATURE();
                      }
                  }
                  /**
                   * Extracts the address of the signer with ECDSA. Performs checks on `s` and `v` to
                   * to prevent signature malleability based attacks
                   * This 'Unpacked' version expects 'signature' to be a 96-byte array.
                   * i.e. the `v` parameter occupies a full 32 bytes of memory, not 1 byte
                   * @param hashedMessage - Hashed data being signed over. This function only works if the message has been pre formated to EIP https://eips.ethereum.org/EIPS/eip-191
                   * @param signature - ECDSA signature over the secp256k1 elliptic curve.
                   * @param signer - Address that signs the signature.
                   */
                  function validateShieldSignatureUnpacked(bytes32 hashedMessage, bytes memory signature, address signer)
                      internal
                      view
                  {
                      bool result;
                      address recoveredSigner = address(0x0);
                      if (signer == address(0x0)) {
                          revert SIGNATURE_ADDRESS_IS_ZERO();
                      }
                      assembly {
                          // There's a little trick we can pull. We expect `signature` to be a byte array, of length 0x60, with
                          // 'v', 'r' and 's' located linearly in memory. Preceeding this is the length parameter of `signature`.
                          // We *replace* the length param with the signature msg to get a memory block formatted for the precompile
                          // load length as a temporary variable
                          // N.B. we mutate the signature by re-ordering r, s, and v!
                          let byteLength := mload(signature)
                          // store the signature digest
                          mstore(signature, hashedMessage)
                          // load 'v' - we need it for a condition check
                          // add 0x60 to jump over 3 words - length of bytes array, r and s
                          let v := mload(add(signature, 0x60))
                          let s := mload(add(signature, 0x40))
                          /**
                           * Original memory map for input to precompile
                           *
                           * signature : signature + 0x20            message
                           * signature + 0x20 : signature + 0x40     r
                           * signature + 0x40 : signature + 0x60     s
                           * signature + 0x60 : signature + 0x80     v
                           * Desired memory map for input to precompile
                           *
                           * signature : signature + 0x20            message
                           * signature + 0x20 : signature + 0x40     v
                           * signature + 0x40 : signature + 0x60     r
                           * signature + 0x60 : signature + 0x80     s
                           */
                          // move s to v position
                          mstore(add(signature, 0x60), s)
                          // move r to s position
                          mstore(add(signature, 0x40), mload(add(signature, 0x20)))
                          // move v to r position
                          mstore(add(signature, 0x20), v)
                          result :=
                              and(
                                  and(
                                      // validate s is in lower half order
                                      lt(s, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A1),
                                      and(
                                          // validate signature length == 0x60 (unpacked)
                                          eq(byteLength, 0x60),
                                          // validate v == 27 or v == 28
                                          or(eq(v, 27), eq(v, 28))
                                      )
                                  ),
                                  // validate call to ecrecover precompile succeeds
                                  staticcall(gas(), 0x01, signature, 0x80, signature, 0x20)
                              )
                          // save the recoveredSigner only if the first word in signature is not `message` anymore
                          switch eq(hashedMessage, mload(signature))
                          case 0 { recoveredSigner := mload(signature) }
                          mstore(signature, byteLength) // and put the byte length back where it belongs
                          // validate that recoveredSigner is not address(0x00)
                          result := and(result, not(iszero(recoveredSigner)))
                      }
                      if (!result) {
                          revert SIGNATURE_RECOVERY_FAILED();
                      }
                      if (recoveredSigner != signer) {
                          revert INVALID_SIGNATURE();
                      }
                  }
                  /**
                   * Extracts the address of the signer with ECDSA. Performs checks on `s` and `v` to
                   * to prevent signature malleability based attacks
                   * This 'Unpacked' version expects 'signature' to be a 96-byte array.
                   * i.e. the `v` parameter occupies a full 32 bytes of memory, not 1 byte
                   * @param digest - Hashed data being signed over.
                   * @param signature - ECDSA signature over the secp256k1 elliptic curve.
                   * @param signer - Address that signs the signature.
                   */
                  function validateUnpackedSignature(bytes32 digest, bytes memory signature, address signer) internal view {
                      bool result;
                      address recoveredSigner = address(0x0);
                      if (signer == address(0x0)) {
                          revert SIGNATURE_ADDRESS_IS_ZERO();
                      }
                      // prepend "\\x19Ethereum Signed Message:\
              32" to the digest to create the signed message
                      bytes32 message;
                      assembly {
                          mstore(0, "\\x19Ethereum Signed Message:\
              32")
                          mstore(28, digest)
                          message := keccak256(0, 60)
                      }
                      assembly {
                          // There's a little trick we can pull. We expect `signature` to be a byte array, of length 0x60, with
                          // 'v', 'r' and 's' located linearly in memory. Preceeding this is the length parameter of `signature`.
                          // We *replace* the length param with the signature msg to get a memory block formatted for the precompile
                          // load length as a temporary variable
                          // N.B. we mutate the signature by re-ordering r, s, and v!
                          let byteLength := mload(signature)
                          // store the signature digest
                          mstore(signature, message)
                          // load 'v' - we need it for a condition check
                          // add 0x60 to jump over 3 words - length of bytes array, r and s
                          let v := mload(add(signature, 0x60))
                          let s := mload(add(signature, 0x40))
                          /**
                           * Original memory map for input to precompile
                           *
                           * signature : signature + 0x20            message
                           * signature + 0x20 : signature + 0x40     r
                           * signature + 0x40 : signature + 0x60     s
                           * signature + 0x60 : signature + 0x80     v
                           * Desired memory map for input to precompile
                           *
                           * signature : signature + 0x20            message
                           * signature + 0x20 : signature + 0x40     v
                           * signature + 0x40 : signature + 0x60     r
                           * signature + 0x60 : signature + 0x80     s
                           */
                          // move s to v position
                          mstore(add(signature, 0x60), s)
                          // move r to s position
                          mstore(add(signature, 0x40), mload(add(signature, 0x20)))
                          // move v to r position
                          mstore(add(signature, 0x20), v)
                          result :=
                              and(
                                  and(
                                      // validate s is in lower half order
                                      lt(s, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A1),
                                      and(
                                          // validate signature length == 0x60 (unpacked)
                                          eq(byteLength, 0x60),
                                          // validate v == 27 or v == 28
                                          or(eq(v, 27), eq(v, 28))
                                      )
                                  ),
                                  // validate call to ecrecover precompile succeeds
                                  staticcall(gas(), 0x01, signature, 0x80, signature, 0x20)
                              )
                          // save the recoveredSigner only if the first word in signature is not `message` anymore
                          switch eq(message, mload(signature))
                          case 0 { recoveredSigner := mload(signature) }
                          mstore(signature, byteLength) // and put the byte length back where it belongs
                          // validate that recoveredSigner is not address(0x00)
                          result := and(result, not(iszero(recoveredSigner)))
                      }
                      if (!result) {
                          revert SIGNATURE_RECOVERY_FAILED();
                      }
                      if (recoveredSigner != signer) {
                          revert INVALID_SIGNATURE();
                      }
                  }
                  /**
                   * Convert a bytes32 into an ASCII encoded hex string
                   * @param input bytes32 variable
                   * @return result hex-encoded string
                   */
                  function toHexString(bytes32 input) public pure returns (string memory result) {
                      if (uint256(input) == 0x00) {
                          assembly {
                              result := mload(0x40)
                              mstore(result, 0x40)
                              mstore(add(result, 0x20), 0x3030303030303030303030303030303030303030303030303030303030303030)
                              mstore(add(result, 0x40), 0x3030303030303030303030303030303030303030303030303030303030303030)
                              mstore(0x40, add(result, 0x60))
                          }
                          return result;
                      }
                      assembly {
                          result := mload(0x40)
                          let table := add(result, 0x60)
                          // Store lookup table that maps an integer from 0 to 99 into a 2-byte ASCII equivalent
                          // Store lookup table that maps an integer from 0 to ff into a 2-byte ASCII equivalent
                          mstore(add(table, 0x1e), 0x3030303130323033303430353036303730383039306130623063306430653066)
                          mstore(add(table, 0x3e), 0x3130313131323133313431353136313731383139316131623163316431653166)
                          mstore(add(table, 0x5e), 0x3230323132323233323432353236323732383239326132623263326432653266)
                          mstore(add(table, 0x7e), 0x3330333133323333333433353336333733383339336133623363336433653366)
                          mstore(add(table, 0x9e), 0x3430343134323433343434353436343734383439346134623463346434653466)
                          mstore(add(table, 0xbe), 0x3530353135323533353435353536353735383539356135623563356435653566)
                          mstore(add(table, 0xde), 0x3630363136323633363436353636363736383639366136623663366436653666)
                          mstore(add(table, 0xfe), 0x3730373137323733373437353736373737383739376137623763376437653766)
                          mstore(add(table, 0x11e), 0x3830383138323833383438353836383738383839386138623863386438653866)
                          mstore(add(table, 0x13e), 0x3930393139323933393439353936393739383939396139623963396439653966)
                          mstore(add(table, 0x15e), 0x6130613161326133613461356136613761386139616161626163616461656166)
                          mstore(add(table, 0x17e), 0x6230623162326233623462356236623762386239626162626263626462656266)
                          mstore(add(table, 0x19e), 0x6330633163326333633463356336633763386339636163626363636463656366)
                          mstore(add(table, 0x1be), 0x6430643164326433643464356436643764386439646164626463646464656466)
                          mstore(add(table, 0x1de), 0x6530653165326533653465356536653765386539656165626563656465656566)
                          mstore(add(table, 0x1fe), 0x6630663166326633663466356636663766386639666166626663666466656666)
                          /**
                           * Convert `input` into ASCII.
                           *
                           * Slice 2 base-10  digits off of the input, use to index the ASCII lookup table.
                           *
                           * We start from the least significant digits, write results into mem backwards,
                           * this prevents us from overwriting memory despite the fact that each mload
                           * only contains 2 byteso f useful data.
                           *
                           */
                          let base := input
                          function slice(v, tableptr) {
                              mstore(0x1e, mload(add(tableptr, shl(1, and(v, 0xff)))))
                              mstore(0x1c, mload(add(tableptr, shl(1, and(shr(8, v), 0xff)))))
                              mstore(0x1a, mload(add(tableptr, shl(1, and(shr(16, v), 0xff)))))
                              mstore(0x18, mload(add(tableptr, shl(1, and(shr(24, v), 0xff)))))
                              mstore(0x16, mload(add(tableptr, shl(1, and(shr(32, v), 0xff)))))
                              mstore(0x14, mload(add(tableptr, shl(1, and(shr(40, v), 0xff)))))
                              mstore(0x12, mload(add(tableptr, shl(1, and(shr(48, v), 0xff)))))
                              mstore(0x10, mload(add(tableptr, shl(1, and(shr(56, v), 0xff)))))
                              mstore(0x0e, mload(add(tableptr, shl(1, and(shr(64, v), 0xff)))))
                              mstore(0x0c, mload(add(tableptr, shl(1, and(shr(72, v), 0xff)))))
                              mstore(0x0a, mload(add(tableptr, shl(1, and(shr(80, v), 0xff)))))
                              mstore(0x08, mload(add(tableptr, shl(1, and(shr(88, v), 0xff)))))
                              mstore(0x06, mload(add(tableptr, shl(1, and(shr(96, v), 0xff)))))
                              mstore(0x04, mload(add(tableptr, shl(1, and(shr(104, v), 0xff)))))
                              mstore(0x02, mload(add(tableptr, shl(1, and(shr(112, v), 0xff)))))
                              mstore(0x00, mload(add(tableptr, shl(1, and(shr(120, v), 0xff)))))
                          }
                          mstore(result, 0x40)
                          slice(base, table)
                          mstore(add(result, 0x40), mload(0x1e))
                          base := shr(128, base)
                          slice(base, table)
                          mstore(add(result, 0x20), mload(0x1e))
                          mstore(0x40, add(result, 0x60))
                      }
                  }
                  function getSignedMessageForTxId(bytes32 txId) internal pure returns (bytes32 hashedMessage) {
                      // we know this string length is 64 bytes
                      string memory txIdHexString = toHexString(txId);
                      assembly {
                          let mPtr := mload(0x40)
                          mstore(add(mPtr, 32), "\\x19Ethereum Signed Message:\
              210")
                          mstore(add(mPtr, 61), "Signing this message will allow ")
                          mstore(add(mPtr, 93), "your pending funds to be spent i")
                          mstore(add(mPtr, 125), "n Aztec transaction:\
              \
              0x")
                          mstore(add(mPtr, 149), mload(add(txIdHexString, 0x20)))
                          mstore(add(mPtr, 181), mload(add(txIdHexString, 0x40)))
                          mstore(add(mPtr, 213), "\
              \
              IMPORTANT: Only sign the messa")
                          mstore(add(mPtr, 245), "ge if you trust the client")
                          hashedMessage := keccak256(add(mPtr, 32), 239)
                      }
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              /**
               * ----------------------------------------
               *  PROOF DATA SPECIFICATION
               * ----------------------------------------
               * Our input "proof data" is represented as a single byte array - we use custom encoding to encode the
               * data associated with a rollup block. The encoded structure is as follows (excluding the length param of the bytes type):
               *
               *    | byte range      | num bytes        | name                             | description |
               *    | ---             | ---              | ---                              | ---         |
               *    | 0x00  - 0x20    | 32               | rollupId                         | Unique rollup block identifier. Equivalent to block number |
               *    | 0x20  - 0x40    | 32               | rollupSize                       | Max number of transactions in the block |
               *    | 0x40  - 0x60    | 32               | dataStartIndex                   | Position of the next empty slot in the Aztec data tree |
               *    | 0x60  - 0x80    | 32               | oldDataRoot                      | Root of the data tree prior to rollup block's state updates |
               *    | 0x80  - 0xa0    | 32               | newDataRoot                      | Root of the data tree after rollup block's state updates |
               *    | 0xa0  - 0xc0    | 32               | oldNullRoot                      | Root of the nullifier tree prior to rollup block's state updates |
               *    | 0xc0  - 0xe0    | 32               | newNullRoot                      | Root of the nullifier tree after rollup block's state updates |
               *    | 0xe0  - 0x100   | 32               | oldDataRootsRoot                 | Root of the tree of data tree roots prior to rollup block's state updates |
               *    | 0x100 - 0x120   | 32               | newDataRootsRoot                 | Root of the tree of data tree roots after rollup block's state updates |
               *    | 0x120 - 0x140   | 32               | oldDefiRoot                      | Root of the defi tree prior to rollup block's state updates |
               *    | 0x140 - 0x160   | 32               | newDefiRoot                      | Root of the defi tree after rollup block's state updates |
               *    | 0x160 - 0x560   | 1024             | encodedBridgeCallDatas[NUMBER_OF_BRIDGE_CALLS]   | Size-32 array of encodedBridgeCallDatas for bridges being called in this block. If encodedBridgeCallData == 0, no bridge is called |
               *    | 0x560 - 0x960   | 1024             | depositSums[NUMBER_OF_BRIDGE_CALLS] | Size-32 array of deposit values being sent to bridges which are called in this block |
               *    | 0x960 - 0xb60   | 512              | assetIds[NUMBER_OF_ASSETS]         | Size-16 array of assetIds which correspond to assets being used to pay fees in this block |
               *    | 0xb60 - 0xd60   | 512              | txFees[NUMBER_OF_ASSETS]           | Size-16 array of transaction fees paid to the rollup beneficiary, denominated in each assetId |
               *    | 0xd60 - 0x1160  | 1024             | interactionNotes[NUMBER_OF_BRIDGE_CALLS] | Size-32 array of defi interaction result commitments that must be inserted into the defi tree at this rollup block |
               *    | 0x1160 - 0x1180 | 32               | prevDefiInteractionHash          | A SHA256 hash of the data used to create each interaction result commitment. Used to validate correctness of interactionNotes |
               *    | 0x1180 - 0x11a0 | 32               | rollupBeneficiary                | The address that the fees from this rollup block should be sent to. Prevents a rollup proof being taken from the transaction pool and having its fees redirected |
               *    | 0x11a0 - 0x11c0 | 32               | numRollupTxs                     | Number of "inner rollup" proofs used to create the block proof. "inner rollup" circuits process 3-28 user txns, the outer rollup circuit processes 1-28 inner rollup proofs. |
               *    | 0x11c0 - 0x11c4 | 4                | numRealTxs                       | Number of transactions in the rollup excluding right-padded padding proofs |
               *    | 0x11c4 - 0x11c8 | 4                | encodedInnerTxData.length        | Number of bytes of encodedInnerTxData |
               *    | 0x11c8 - end    | encodedInnerTxData.length | encodedInnerTxData      | Encoded inner transaction data. Contains encoded form of the broadcasted data associated with each tx in the rollup block |
               *
               */
              /**
               * --------------------------------------------
               *  DETERMINING THE NUMBER OF REAL TRANSACTIONS
               * --------------------------------------------
               * The `rollupSize` parameter describes the MAX number of txns in a block.
               * However the block may not be full.
               * Incomplete blocks will be padded with "padding" transactions that represent empty txns.
               *
               * The amount of end padding is not explicitly defined in `proofData`. It is derived.
               * The encodedInnerTxData does not include tx data for the txns associated with this end padding.
               * (it does include any padding transactions that are not part of the end padding, which can sometimes happen)
               * When decoded, the transaction data for each transaction is a fixed size (256 bytes)
               * Number of real transactions = rollupSize - (decoded tx data size / 256)
               *
               * The decoded transaction data associated with padding transactions is 256 zero bytes.
               *
               */
              /**
               * @title Decoder
               * @dev contains functions for decoding/extracting the encoded proof data passed in as calldata,
               * as well as computing the SHA256 hash of the decoded data (publicInputsHash).
               * The publicInputsHash is used to ensure the data passed in as calldata matches the data used within the rollup circuit
               */
              contract Decoder {
                  /*----------------------------------------
                    CONSTANTS
                    ----------------------------------------*/
                  uint256 internal constant NUMBER_OF_ASSETS = 16; // max number of assets in a block
                  uint256 internal constant NUMBER_OF_BRIDGE_CALLS = 32; // max number of bridge calls in a block
                  uint256 internal constant NUMBER_OF_BRIDGE_BYTES = 1024; // NUMBER_OF_BRIDGE_CALLS * 32
                  uint256 internal constant NUMBER_OF_PUBLIC_INPUTS_PER_TX = 8; // number of ZK-SNARK "public inputs" per join-split/account/claim transaction
                  uint256 internal constant TX_PUBLIC_INPUT_LENGTH = 256; // byte-length of NUMBER_OF_PUBLIC_INPUTS_PER_TX. NUMBER_OF_PUBLIC_INPUTS_PER_TX * 32;
                  uint256 internal constant ROLLUP_NUM_HEADER_INPUTS = 142; // 58; // number of ZK-SNARK "public inputs" that make up the rollup header 14 + (NUMBER_OF_BRIDGE_CALLS * 3) + (NUMBER_OF_ASSETS * 2);
                  uint256 internal constant ROLLUP_HEADER_LENGTH = 4544; // 1856; // ROLLUP_NUM_HEADER_INPUTS * 32;
                  // ENCODED_PROOF_DATA_LENGTH_OFFSET = byte offset into the rollup header such that `numRealTransactions` occupies
                  // the least significant 4 bytes of the 32-byte word being pointed to.
                  // i.e. ROLLUP_HEADER_LENGTH - 28
                  uint256 internal constant NUM_REAL_TRANSACTIONS_OFFSET = 4516;
                  // ENCODED_PROOF_DATA_LENGTH_OFFSET = byte offset into the rollup header such that `encodedInnerProofData.length` occupies
                  // the least significant 4 bytes of the 32-byte word being pointed to.
                  // i.e. ROLLUP_HEADER_LENGTH - 24
                  uint256 internal constant ENCODED_PROOF_DATA_LENGTH_OFFSET = 4520;
                  // offset we add to `proofData` to point to the encodedBridgeCallDatas
                  uint256 internal constant BRIDGE_CALL_DATAS_OFFSET = 0x180;
                  // offset we add to `proofData` to point to prevDefiInteractionhash
                  uint256 internal constant PREVIOUS_DEFI_INTERACTION_HASH_OFFSET = 4480; // ROLLUP_HEADER_LENGTH - 0x40
                  // offset we add to `proofData` to point to rollupBeneficiary
                  uint256 internal constant ROLLUP_BENEFICIARY_OFFSET = 4512; // ROLLUP_HEADER_LENGTH - 0x20
                  // CIRCUIT_MODULUS = group order of the BN254 elliptic curve. All arithmetic gates in our ZK-SNARK circuits are evaluated modulo this prime.
                  // Is used when computing the public inputs hash - our SHA256 hash outputs are reduced modulo CIRCUIT_MODULUS
                  uint256 internal constant CIRCUIT_MODULUS =
                      21888242871839275222246405745257275088548364400416034343698204186575808495617;
                  // SHA256 hashes
                  uint256 internal constant PADDING_ROLLUP_HASH_SIZE_1 =
                      0x22dd983f8337d97d56071f7986209ab2ee6039a422242e89126701c6ee005af0;
                  uint256 internal constant PADDING_ROLLUP_HASH_SIZE_2 =
                      0x076a27c79e5ace2a3d47f9dd2e83e4ff6ea8872b3c2218f66c92b89b55f36560;
                  uint256 internal constant PADDING_ROLLUP_HASH_SIZE_4 =
                      0x2f0c70a5bf5460465e9902f9c96be324e8064e762a5de52589fdb97cbce3c6ee;
                  uint256 internal constant PADDING_ROLLUP_HASH_SIZE_8 =
                      0x240ed0de145447ff0ceff2aa477f43e0e2ed7f3543ee3d8832f158ec76b183a9;
                  uint256 internal constant PADDING_ROLLUP_HASH_SIZE_16 =
                      0x1c52c159b4dae66c3dcf33b44d4d61ead6bc4d260f882ac6ba34dccf78892ca4;
                  uint256 internal constant PADDING_ROLLUP_HASH_SIZE_32 =
                      0x0df0e06ab8a02ce2ff08babd7144ab23ca2e99ddf318080cf88602eeb8913d44;
                  uint256 internal constant PADDING_ROLLUP_HASH_SIZE_64 =
                      0x1f83672815ac9b3ca31732d641784035834e96b269eaf6a2e759bf4fcc8e5bfd;
                  uint256 internal constant ADDRESS_MASK = 0x00_ffff_ffff_ffff_ffff_ffff_ffff_ffff_ffff_ffff_ffff;
                  /*----------------------------------------
                    ERROR TAGS
                    ----------------------------------------*/
                  error ENCODING_BYTE_INVALID();
                  error INVALID_ROLLUP_TOPOLOGY();
                  /*----------------------------------------
                    DECODING FUNCTIONS
                    ----------------------------------------*/
                  /**
                   * In `bytes proofData`, transaction data is appended after the rollup header data
                   * Each transaction is described by 8 'public inputs' used to create a user transaction's ZK-SNARK proof
                   * (i.e. there are 8 public inputs for each of the "join-split", "account" and "claim" circuits)
                   * The public inputs are represented in calldata according to the following specification:
                   *
                   * | public input idx | calldata size (bytes) | variable description                         |
                   * | 0                | 1                     | proofId - transaction type identifier        |
                   * | 1                | 32                    | encrypted form of 1st output note            |
                   * | 2                | 32                    | encrypted form of 2nd output note            |
                   * | 3                | 32                    | nullifier of 1st input note                  |
                   * | 4                | 32                    | nullifier of 2nd input note                  |
                   * | 5                | 32                    | amount being deposited or withdrawn          |
                   * | 6                | 20                    | address of depositor or withdraw destination |
                   * | 7                | 4                     | assetId used in transaction                  |
                   *
                   * The following table maps proofId values to transaction types
                   *
                   *
                   * | proofId | tx type     | description |
                   * | ---     | ---         | ---         |
                   * | 0       | padding     | empty transaction. Rollup blocks have a fixed number of txns. If number of real txns is less than block size, padding txns make up the difference |
                   * | 1       | deposit     | deposit Eth/tokens into Aztec in exchange for encrypted Aztec notes |
                   * | 2       | withdraw    | exchange encrypted Aztec notes for Eth/tokens sent to a public address |
                   * | 3       | send        | private send |
                   * | 4       | account     | creates an Aztec account |
                   * | 5       | defiDeposit | deposit Eth/tokens into a L1 smart contract via a Defi bridge contract |
                   * | 6       | defiClaim   | convert proceeds of defiDeposit tx back into encrypted Aztec notes |
                   *
                   * Most of the above transaction types do not use the full set of 8 public inputs (i.e. some are zero).
                   * To save on calldata costs, we encode each transaction into the smallest payload possible.
                   * In `decodeProof`, the encoded transaction data is decoded and written into memory
                   *
                   * As part of the decoding algorithms we must convert the 20-byte `publicOwner` and 4-byte `assetId` fields
                   * into 32-byte EVM words
                   *
                   * The following functions perform transaction-specific decoding. The `proofId` field is decoded prior to calling these functions
                   */
                  /**
                   * @notice Decodes a padding tx
                   * @param _inPtr location in calldata of the encoded transaction
                   * @return - a location in calldata of the next encoded transaction
                   *
                   * @dev Encoded padding tx consists of 1 byte, the `proofId`
                   *      The `proofId` has been written into memory before we called this function so there is nothing to copy
                   *      Advance the calldatapointer by 1 byte to move to the next transaction
                   */
                  function paddingTx(uint256 _inPtr, uint256) internal pure returns (uint256) {
                      unchecked {
                          return (_inPtr + 0x1);
                      }
                  }
                  /**
                   * @notice Decodes a deposit or a withdraw tx
                   * @param _inPtr location in calldata of the encoded transaction
                   * @param _outPtr location in memory to write the decoded transaction to
                   * @return - location in calldata of the next encoded transaction
                   *
                   * @dev The deposit tx uses all 8 public inputs. All calldata is copied into memory.
                   */
                  function depositOrWithdrawTx(uint256 _inPtr, uint256 _outPtr) internal pure returns (uint256) {
                      // Copy deposit calldata into memory
                      assembly {
                          // start copying into `outPtr + 0x20`, as `outPtr` points to `proofId`, which has already been written into memory
                          calldatacopy(add(_outPtr, 0x20), add(_inPtr, 0x20), 0xa0) // noteCommitment{1, 2}, nullifier{1,2}, publicValue; 32*5 bytes
                          calldatacopy(add(_outPtr, 0xcc), add(_inPtr, 0xc0), 0x14) // convert 20-byte `publicOwner` calldata variable into 32-byte EVM word
                          calldatacopy(add(_outPtr, 0xfc), add(_inPtr, 0xd4), 0x4) // convert 4-byte `assetId` variable into 32-byte EVM word
                      }
                      // advance calldata ptr by 185 bytes
                      unchecked {
                          return (_inPtr + 0xb9);
                      }
                  }
                  /**
                   * @notice Decodes a send-type tx
                   * @param _inPtr location in calldata of the encoded transaction
                   * @param _outPtr location in memory to write the decoded transaction to
                   * @return - location in calldata of the next encoded transaction
                   *
                   * @dev The send tx has 0-values for `publicValue`, `publicOwner` and `assetId`
                   *      No need to copy anything into memory for these fields as memory defaults to 0
                   */
                  function sendTx(uint256 _inPtr, uint256 _outPtr) internal pure returns (uint256) {
                      assembly {
                          calldatacopy(add(_outPtr, 0x20), add(_inPtr, 0x20), 0x80) // noteCommitment{1, 2}, nullifier{1,2}; 32*4 bytes
                      }
                      unchecked {
                          return (_inPtr + 0x81);
                      }
                  }
                  /**
                   * @notice Decodes an account creation tx
                   * @param _inPtr location in calldata of the encoded transaction
                   * @param _outPtr location in memory to write the decoded transaction to
                   * @return - location in calldata of the next encoded transaction
                   *
                   * @dev The account tx has 0-values for `nullifier2`, `publicValue`, `publicOwner` and `assetId`
                   *      No need to copy anything into memory for these fields as memory defaults to 0
                   */
                  function accountTx(uint256 _inPtr, uint256 _outPtr) internal pure returns (uint256) {
                      assembly {
                          calldatacopy(add(_outPtr, 0x20), add(_inPtr, 0x20), 0x80) // noteCommitment{1, 2}, nullifier{1,2}; 32*4 bytes
                      }
                      unchecked {
                          return (_inPtr + 0x81);
                      }
                  }
                  /**
                   * @notice Decodes a defi deposit or claim tx
                   * @param _inPtr location in calldata of the encoded transaction
                   * @param _outPtr location in memory to write the decoded transaction to
                   * @return - location in calldata of the next encoded transaction
                   *
                   * @dev The defi deposit/claim tx has 0-values for `publicValue`, `publicOwner` and `assetId`
                   *      No need to copy anything into memory for these fields as memory defaults to 0
                   */
                  function defiDepositOrClaimTx(uint256 _inPtr, uint256 _outPtr) internal pure returns (uint256) {
                      assembly {
                          calldatacopy(add(_outPtr, 0x20), add(_inPtr, 0x20), 0x80) // noteCommitment{1, 2}, nullifier{1,2}; 32*4 bytes
                      }
                      unchecked {
                          return (_inPtr + 0x81);
                      }
                  }
                  /**
                   * @notice Throws an error and reverts.
                   * @dev If we hit this, there is a transaction whose proofId is invalid (i.e. not 0 to 7).
                   */
                  function invalidTx(uint256, uint256) internal pure returns (uint256) {
                      revert ENCODING_BYTE_INVALID();
                  }
                  /**
                   * @notice Decodes the rollup block's proof data
                   * @dev This function converts the proof data into a representation we can work with in memory
                   *      In particular, encoded transaction calldata is decoded and written into memory
                   *      The rollup header is copied from calldata into memory as well
                   * @return proofData a memory pointer to the decoded proof data
                   * @return numTxs number of transactions in the rollup, excluding end-padding transactions
                   * @return publicInputsHash sha256 hash of the public inputs
                   *
                   * @dev The `publicInputsHash` is a sha256 hash of the public inputs associated with each transaction in the rollup.
                   *      It is used to validate the correctness of the data being fed into the rollup circuit.
                   *
                   *      (There is a bit of nomenclature abuse here. Processing a public input in the verifier algorithm costs 150 gas,
                   *      which adds up very quickly. Instead of this, we sha256 hash what used to be the "public" inputs and only set
                   *      the hash to be public. We then make the old "public" inputs private in the rollup circuit, and validate their
                   *      correctness by checking that their sha256 hash matches what we compute in the decodeProof function!
                   */
                  function decodeProof() internal view returns (bytes memory proofData, uint256 numTxs, uint256 publicInputsHash) {
                      // declare some variables that will be set inside asm blocks
                      uint256 dataSize; // size of our decoded transaction data, in bytes
                      uint256 outPtr; // memory pointer to where we will write our decoded transaction data
                      uint256 inPtr; // calldata pointer into our proof data
                      uint256 rollupSize; // max number of transactions in the rollup block
                      uint256 decodedTxDataStart;
                      {
                          uint256 tailInPtr; // calldata pointer to the end of our proof data
                          /**
                           * Let's build a function table!
                           *
                           * To decode our tx data, we need to iterate over every encoded transaction and call its
                           * associated decoding function. If we did this via a `switch` statement this would be VERY expensive,
                           * due to the large number of JUMPI instructions that would be called.
                           *
                           * Instead, we use function pointers.
                           * The `proofId` field in our encoded proof data is an integer from 0-6,
                           * we can use `proofId` to index a table of function pointers for our respective decoding functions.
                           * This is much faster as there is no conditional branching!
                           */
                          function(uint256, uint256) pure returns (uint256) callfunc; // we're going to use `callfunc` as a function pointer
                          // `functionTable` is a pointer to a table in memory, containing function pointers
                          // Step 1: reserve memory for functionTable
                          uint256 functionTable;
                          assembly {
                              functionTable := mload(0x40)
                              mstore(0x40, add(functionTable, 0x100)) // reserve 256 bytes for function pointers
                          }
                          {
                              // Step 2: copy function pointers into local variables so that inline asm code can access them
                              function(uint256, uint256) pure returns (uint256) t0 = paddingTx;
                              function(uint256, uint256) pure returns (uint256) t1 = depositOrWithdrawTx;
                              function(uint256, uint256) pure returns (uint256) t3 = sendTx;
                              function(uint256, uint256) pure returns (uint256) t4 = accountTx;
                              function(uint256, uint256) pure returns (uint256) t5 = defiDepositOrClaimTx;
                              function(uint256, uint256) pure returns (uint256) t7 = invalidTx;
                              // Step 3: write function pointers into the table!
                              assembly {
                                  mstore(functionTable, t0)
                                  mstore(add(functionTable, 0x20), t1)
                                  mstore(add(functionTable, 0x40), t1)
                                  mstore(add(functionTable, 0x60), t3)
                                  mstore(add(functionTable, 0x80), t4)
                                  mstore(add(functionTable, 0xa0), t5)
                                  mstore(add(functionTable, 0xc0), t5)
                                  mstore(add(functionTable, 0xe0), t7) // a proofId of 7 is not a valid transaction type, set to invalidTx
                              }
                          }
                          uint256 decodedTransactionDataSize;
                          assembly {
                              // Add encoded proof data size to dataSize, minus the 4 bytes of encodedInnerProofData.length.
                              // Set inPtr to point to the length parameter of `bytes calldata proofData`
                              inPtr := add(calldataload(0x04), 0x4) // `proofData = first input parameter. Calldata offset to proofData will be at 0x04. Add 0x04 to account for function signature.
                              // Advance inPtr to point to the start of `proofData`
                              inPtr := add(inPtr, 0x20)
                              numTxs := and(calldataload(add(inPtr, NUM_REAL_TRANSACTIONS_OFFSET)), 0xffffffff)
                              // Get encoded inner proof data size.
                              // Add ENCODED_PROOF_DATA_LENGTH_OFFSET to inPtr to point to the correct variable in our header block,
                              // mask off all but 4 least significant bytes as this is a packed 32-bit variable.
                              let encodedInnerDataSize := and(calldataload(add(inPtr, ENCODED_PROOF_DATA_LENGTH_OFFSET)), 0xffffffff)
                              // Load up the rollup size from `proofData`
                              rollupSize := calldataload(add(inPtr, 0x20))
                              // Compute the number of bytes our decoded proof data will take up.
                              // i.e. num total txns in the rollup (including padding) * number of public inputs per transaction
                              let decodedInnerDataSize := mul(rollupSize, TX_PUBLIC_INPUT_LENGTH)
                              // We want `dataSize` to equal: rollup header length + decoded tx length (excluding padding blocks)
                              let numInnerRollups := calldataload(add(inPtr, sub(ROLLUP_HEADER_LENGTH, 0x20)))
                              let numTxsPerRollup := div(rollupSize, numInnerRollups)
                              let numFilledBlocks := div(numTxs, numTxsPerRollup)
                              numFilledBlocks := add(numFilledBlocks, iszero(eq(mul(numFilledBlocks, numTxsPerRollup), numTxs)))
                              decodedTransactionDataSize := mul(mul(numFilledBlocks, numTxsPerRollup), TX_PUBLIC_INPUT_LENGTH)
                              dataSize := add(ROLLUP_HEADER_LENGTH, decodedTransactionDataSize)
                              // Allocate memory for `proofData`.
                              proofData := mload(0x40)
                              // Set free mem ptr to `dataSize` + 0x20 (to account for the 0x20 bytes for the length param of proofData)
                              // This allocates memory whose size is equal to the rollup header size, plus the data required for
                              // each transaction's decoded tx data (256 bytes * number of non-padding blocks).
                              // Only reserve memory for blocks that contain non-padding proofs. These "padding" blocks don't need to be
                              // stored in memory as we don't need their data for any computations.
                              mstore(0x40, add(proofData, add(dataSize, 0x20)))
                              // Set `outPtr` to point to the `proofData` length parameter
                              outPtr := proofData
                              // Write `dataSize` into `proofData.length`
                              mstore(outPtr, dataSize)
                              // Advance `outPtr` to point to start of `proofData`
                              outPtr := add(outPtr, 0x20)
                              // Copy rollup header data to `proofData`.
                              calldatacopy(outPtr, inPtr, ROLLUP_HEADER_LENGTH)
                              // Advance `outPtr` to point to the end of the header data (i.e. the start of the decoded inner transaction data)
                              outPtr := add(outPtr, ROLLUP_HEADER_LENGTH)
                              // Advance `inPtr` to point to the start of our encoded inner transaction data.
                              // Add (ROLLUP_HEADER_LENGTH + 0x08) to skip over the packed (numRealTransactions, encodedProofData.length) parameters
                              inPtr := add(inPtr, add(ROLLUP_HEADER_LENGTH, 0x08))
                              // Set `tailInPtr` to point to the end of our encoded transaction data
                              tailInPtr := add(inPtr, encodedInnerDataSize)
                              // Set `decodedTxDataStart` pointer
                              decodedTxDataStart := outPtr
                          }
                          /**
                           * Start of decoding algorithm
                           *
                           * Iterate over every encoded transaction, load out the first byte (`proofId`) and use it to
                           * jump to the relevant transaction's decoding function
                           */
                          assembly {
                              // Subtract 31 bytes off of `inPtr`, so that the first byte of the encoded transaction data
                              // is located at the least significant byte of calldataload(inPtr)
                              // also adjust `tailInPtr` as we compare `inPtr` against `tailInPtr`
                              inPtr := sub(inPtr, 0x1f)
                              tailInPtr := sub(tailInPtr, 0x1f)
                          }
                          unchecked {
                              for (; tailInPtr > inPtr;) {
                                  assembly {
                                      // For each tx, the encoding byte determines how we decode the tx calldata
                                      // The encoding byte can take values from 0 to 7; we want to turn these into offsets that can index our function table.
                                      // 1. Access encoding byte via `calldataload(inPtr)`. The least significant byte is our encoding byte. Mask off all but the 3 least sig bits
                                      // 2. Shift left by 5 bits. This is equivalent to multiplying the encoding byte by 32.
                                      // 3. The result will be 1 of 8 offset values (0x00, 0x20, ..., 0xe0) which we can use to retrieve the relevant function pointer from `functionTable`
                                      let encoding := and(calldataload(inPtr), 7)
                                      // Store `proofId` at `outPtr`.
                                      mstore(outPtr, encoding) // proofId
                                      // Use `proofId` to extract the relevant function pointer from `functionTable`
                                      callfunc := mload(add(functionTable, shl(5, encoding)))
                                  }
                                  // Call the decoding function. Return value will be next required value of inPtr
                                  inPtr = callfunc(inPtr, outPtr);
                                  // advance outPtr by the size of a decoded transaction
                                  outPtr += TX_PUBLIC_INPUT_LENGTH;
                              }
                          }
                      }
                      /**
                       * Compute the public inputs hash
                       *
                       * We need to take our decoded proof data and compute its SHA256 hash.
                       * This hash is fed into our rollup proof as a public input.
                       * If the hash does not match the SHA256 hash computed within the rollup circuit
                       * on the equivalent parameters, the proof will reject.
                       * This check ensures that the transaction data present in calldata are equal to
                       * the transaction data values present in the rollup ZK-SNARK circuit.
                       *
                       * One complication is the structure of the SHA256 hash.
                       * We slice transactions into chunks equal to the number of transactions in the "inner rollup" circuit
                       * (a rollup circuit verifies multiple "inner rollup" circuits, which each verify 3-28 private user transactions.
                       *  This tree structure helps parallelise proof construction)
                       * We then SHA256 hash each transaction *chunk*
                       * Finally we SHA256 hash the above SHA256 hashes to get our public input hash!
                       *
                       * We do the above instead of a straight hash of all of the transaction data,
                       * because it's faster to parallelise proof construction if the majority of the SHA256 hashes are computed in
                       * the "inner rollup" circuit and not the main rollup circuit.
                       */
                      // Step 1: compute the hashes that constitute the inner proofs data
                      bool invalidRollupTopology;
                      assembly {
                          // We need to figure out how many rollup proofs are in this tx and how many user transactions are in each rollup
                          let numRollupTxs := mload(add(proofData, ROLLUP_HEADER_LENGTH))
                          let numJoinSplitsPerRollup := div(rollupSize, numRollupTxs)
                          let rollupDataSize := mul(mul(numJoinSplitsPerRollup, NUMBER_OF_PUBLIC_INPUTS_PER_TX), 32)
                          // Compute the number of inner rollups that don't contain padding proofs
                          let numNotEmptyInnerRollups := div(numTxs, numJoinSplitsPerRollup)
                          numNotEmptyInnerRollups :=
                              add(numNotEmptyInnerRollups, iszero(eq(mul(numNotEmptyInnerRollups, numJoinSplitsPerRollup), numTxs)))
                          // Compute the number of inner rollups that only contain padding proofs!
                          // For these "empty" inner rollups, we don't need to compute their public inputs hash directly,
                          // we can use a precomputed value
                          let numEmptyInnerRollups := sub(numRollupTxs, numNotEmptyInnerRollups)
                          let proofdataHashPtr := mload(0x40)
                          // Copy the header data into the `proofdataHash`
                          // Header start is at calldataload(0x04) + 0x24 (+0x04 to skip over func signature, +0x20 to skip over byte array length param)
                          calldatacopy(proofdataHashPtr, add(calldataload(0x04), 0x24), ROLLUP_HEADER_LENGTH)
                          // Update pointer
                          proofdataHashPtr := add(proofdataHashPtr, ROLLUP_HEADER_LENGTH)
                          // Compute the endpoint for the `proofdataHashPtr` (used as a loop boundary condition)
                          let endPtr := add(proofdataHashPtr, mul(numNotEmptyInnerRollups, 0x20))
                          // Iterate over the public inputs of each inner rollup proof and compute their SHA256 hash
                          // better solution here is ... iterate over number of non-padding rollup blocks
                          // and hash those
                          // for padding rollup blocks...just append the zero hash
                          for {} lt(proofdataHashPtr, endPtr) { proofdataHashPtr := add(proofdataHashPtr, 0x20) } {
                              // address(0x02) is the SHA256 precompile address
                              if iszero(staticcall(gas(), 0x02, decodedTxDataStart, rollupDataSize, 0x00, 0x20)) {
                                  revert(0x00, 0x00)
                              }
                              mstore(proofdataHashPtr, mod(mload(0x00), CIRCUIT_MODULUS))
                              decodedTxDataStart := add(decodedTxDataStart, rollupDataSize)
                          }
                          // If there are empty inner rollups, we can use a precomputed hash
                          // of their public inputs instead of computing it directly.
                          if iszero(iszero(numEmptyInnerRollups)) {
                              let zeroHash
                              switch numJoinSplitsPerRollup
                              case 32 { zeroHash := PADDING_ROLLUP_HASH_SIZE_32 }
                              case 16 { zeroHash := PADDING_ROLLUP_HASH_SIZE_16 }
                              case 64 { zeroHash := PADDING_ROLLUP_HASH_SIZE_64 }
                              case 1 { zeroHash := PADDING_ROLLUP_HASH_SIZE_1 }
                              case 2 { zeroHash := PADDING_ROLLUP_HASH_SIZE_2 }
                              case 4 { zeroHash := PADDING_ROLLUP_HASH_SIZE_4 }
                              case 8 { zeroHash := PADDING_ROLLUP_HASH_SIZE_8 }
                              default { invalidRollupTopology := true }
                              endPtr := add(endPtr, mul(numEmptyInnerRollups, 0x20))
                              for {} lt(proofdataHashPtr, endPtr) { proofdataHashPtr := add(proofdataHashPtr, 0x20) } {
                                  mstore(proofdataHashPtr, zeroHash)
                              }
                          }
                          // Compute SHA256 hash of header data + inner public input hashes
                          let startPtr := mload(0x40)
                          if iszero(staticcall(gas(), 0x02, startPtr, sub(proofdataHashPtr, startPtr), 0x00, 0x20)) {
                              revert(0x00, 0x00)
                          }
                          publicInputsHash := mod(mload(0x00), CIRCUIT_MODULUS)
                      }
                      if (invalidRollupTopology) {
                          revert INVALID_ROLLUP_TOPOLOGY();
                      }
                  }
                  /**
                   * @notice Extracts the `rollupId` param from the decoded proof data
                   * @dev This represents the rollupId of the next valid rollup block
                   * @param _proofData the decoded proof data
                   * @return nextRollupId the expected id of the next rollup block
                   */
                  function getRollupId(bytes memory _proofData) internal pure returns (uint256 nextRollupId) {
                      assembly {
                          nextRollupId := mload(add(_proofData, 0x20))
                      }
                  }
                  /**
                   * @notice Decodes the input merkle roots of `proofData` and computes rollupId && sha3 hash of roots && dataStartIndex
                   * @dev The rollup's state is uniquely defined by the following variables:
                   *          * The next empty location in the data root tree (rollupId + 1)
                   *          * The next empty location in the data tree (dataStartIndex + rollupSize)
                   *          * The root of the data tree
                   *          * The root of the nullifier set
                   *          * The root of the data root tree (tree containing all previous roots of the data tree)
                   *          * The root of the defi tree
                   *      Instead of storing all of these variables in storage (expensive!), we store a keccak256 hash of them.
                   *      To validate the correctness of a block's state transition, we must perform the following:
                   *          * Use proof broadcasted inputs to reconstruct the "old" state hash
                   *          * Use proof broadcasted inputs to reconstruct the "new" state hash
                   *          * Validate that the old state hash matches what is in storage
                   *          * Set the old state hash to the new state hash
                   *      N.B. we still store `dataSize` as a separate storage var as `proofData does not contain all
                   *           neccessary information to reconstruct its old value.
                   * @param _proofData cryptographic proofData associated with a rollup
                   * @return rollupId
                   * @return oldStateHash
                   * @return newStateHash
                   * @return numDataLeaves
                   * @return dataStartIndex
                   */
                  function computeRootHashes(bytes memory _proofData)
                      internal
                      pure
                      returns (
                          uint256 rollupId,
                          bytes32 oldStateHash,
                          bytes32 newStateHash,
                          uint32 numDataLeaves,
                          uint32 dataStartIndex
                      )
                  {
                      assembly {
                          let dataStart := add(_proofData, 0x20) // jump over first word, it's length of data
                          numDataLeaves := shl(1, mload(add(dataStart, 0x20))) // rollupSize * 2 (2 notes per tx)
                          dataStartIndex := mload(add(dataStart, 0x40))
                          // validate numDataLeaves && dataStartIndex are uint32s
                          if or(gt(numDataLeaves, 0xffffffff), gt(dataStartIndex, 0xffffffff)) { revert(0, 0) }
                          rollupId := mload(dataStart)
                          let mPtr := mload(0x40)
                          mstore(mPtr, rollupId) // old nextRollupId
                          mstore(add(mPtr, 0x20), mload(add(dataStart, 0x60))) // oldDataRoot
                          mstore(add(mPtr, 0x40), mload(add(dataStart, 0xa0))) // oldNullRoot
                          mstore(add(mPtr, 0x60), mload(add(dataStart, 0xe0))) // oldRootRoot
                          mstore(add(mPtr, 0x80), mload(add(dataStart, 0x120))) // oldDefiRoot
                          oldStateHash := keccak256(mPtr, 0xa0)
                          mstore(mPtr, add(rollupId, 0x01)) // new nextRollupId
                          mstore(add(mPtr, 0x20), mload(add(dataStart, 0x80))) // newDataRoot
                          mstore(add(mPtr, 0x40), mload(add(dataStart, 0xc0))) // newNullRoot
                          mstore(add(mPtr, 0x60), mload(add(dataStart, 0x100))) // newRootRoot
                          mstore(add(mPtr, 0x80), mload(add(dataStart, 0x140))) // newDefiRoot
                          newStateHash := keccak256(mPtr, 0xa0)
                      }
                  }
                  /**
                   * @notice Extract the `prevDefiInteractionHash` from the proofData's rollup header
                   * @param _proofData decoded rollup proof data
                   * @return prevDefiInteractionHash the defiInteractionHash of the previous rollup block
                   */
                  function extractPrevDefiInteractionHash(bytes memory _proofData)
                      internal
                      pure
                      returns (bytes32 prevDefiInteractionHash)
                  {
                      assembly {
                          prevDefiInteractionHash := mload(add(_proofData, PREVIOUS_DEFI_INTERACTION_HASH_OFFSET))
                      }
                  }
                  /**
                   * @notice Extracts the address we pay the rollup fee to from the proofData's rollup header
                   * @dev Rollup beneficiary address is included as part of the ZK-SNARK circuit data, so that the rollup provider
                   *      can explicitly define who should get the fee when they are generating the ZK-SNARK proof (instead of
                   *      simply sending the fee to msg.sender).
                   *      This prevents front-running attacks where an attacker can take somebody else's rollup proof from out of
                   *      the tx pool and replay it, stealing the fee.
                   * @param _proofData byte array of our input proof data
                   * @return rollupBeneficiary the address we pay this rollup block's fee to
                   */
                  function extractRollupBeneficiary(bytes memory _proofData) internal pure returns (address rollupBeneficiary) {
                      assembly {
                          rollupBeneficiary := mload(add(_proofData, ROLLUP_BENEFICIARY_OFFSET))
                          // Validate `rollupBeneficiary` is an address
                          if gt(rollupBeneficiary, ADDRESS_MASK) { revert(0, 0) }
                      }
                  }
                  /**
                   * @notice Extracts an `assetId` in which a fee is going to be paid from a rollup block
                   * @dev The rollup block contains up to 16 different assets, which can be recovered from the rollup header data.
                   * @param _proofData byte array of our input proof data
                   * @param _idx index of the asset we want (assetId = header.assetIds[_idx])
                   * @return assetId 30-bit identifier of an asset. The ERC20 token address is obtained via the mapping `supportedAssets[assetId]`,
                   */
                  function extractFeeAssetId(bytes memory _proofData, uint256 _idx) internal pure returns (uint256 assetId) {
                      assembly {
                          assetId :=
                              mload(
                                  add(add(add(_proofData, BRIDGE_CALL_DATAS_OFFSET), mul(0x40, NUMBER_OF_BRIDGE_CALLS)), mul(0x20, _idx))
                              )
                          // Validate `assetId` is a uint32!
                          if gt(assetId, 0xffffffff) { revert(0, 0) }
                      }
                  }
                  /**
                   * @notice Extracts the transaction fee for a given asset which is to be paid to the rollup beneficiary
                   * @dev The total fee is the sum of the individual fees paid by each transaction in the rollup block.
                   *      This sum is computed directly in the rollup circuit, and is present in the rollup header data.
                   * @param _proofData byte array of decoded rollup proof data
                   * @param _idx The index of the asset the fee is denominated in
                   * @return totalTxFee total rollup block transaction fee for a given asset
                   */
                  function extractTotalTxFee(bytes memory _proofData, uint256 _idx) internal pure returns (uint256 totalTxFee) {
                      assembly {
                          totalTxFee := mload(add(add(add(_proofData, 0x380), mul(0x40, NUMBER_OF_BRIDGE_CALLS)), mul(0x20, _idx)))
                      }
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              import {AztecTypes} from "rollup-encoder/libraries/AztecTypes.sol";
              interface IDefiBridge {
                  /**
                   * @notice A function which converts input assets to output assets.
                   * @param _inputAssetA A struct detailing the first input asset
                   * @param _inputAssetB A struct detailing the second input asset
                   * @param _outputAssetA A struct detailing the first output asset
                   * @param _outputAssetB A struct detailing the second output asset
                   * @param _totalInputValue An amount of input assets transferred to the bridge (Note: "total" is in the name
                   *                         because the value can represent summed/aggregated token amounts of users actions on L2)
                   * @param _interactionNonce A globally unique identifier of this interaction/`convert(...)` call.
                   * @param _auxData Bridge specific data to be passed into the bridge contract (e.g. slippage, nftID etc.)
                   * @return outputValueA An amount of `_outputAssetA` returned from this interaction.
                   * @return outputValueB An amount of `_outputAssetB` returned from this interaction.
                   * @return isAsync A flag indicating if the interaction is async.
                   * @dev This function is called from the RollupProcessor contract via the DefiBridgeProxy. Before this function is
                   *      called _RollupProcessor_ contract will have sent you all the assets defined by the input params. This
                   *      function is expected to convert input assets to output assets (e.g. on Uniswap) and return the amounts
                   *      of output assets to be received by the _RollupProcessor_. If output assets are ERC20 tokens the bridge has
                   *      to set _RollupProcessor_ as a spender before the interaction is finished. If some of the output assets is ETH
                   *      it has to be sent to _RollupProcessor_ via the `receiveEthFromBridge(uint256 _interactionNonce)` method
                   *      before the `convert(...)` function call finishes.
                   * @dev If there are two input assets, equal amounts of both assets will be transferred to the bridge before this
                   *      method is called.
                   * @dev **BOTH** output assets could be virtual but since their `assetId` is currently assigned as
                   *      `_interactionNonce` it would simply mean that more of the same virtual asset is minted.
                   * @dev If this interaction is async the function has to return `(0, 0, true)`. Async interaction will be finalised at
                   *      a later time and its output assets will be returned in a `IDefiBridge.finalise(...)` call.
                   *
                   */
                  function convert(
                      AztecTypes.AztecAsset calldata _inputAssetA,
                      AztecTypes.AztecAsset calldata _inputAssetB,
                      AztecTypes.AztecAsset calldata _outputAssetA,
                      AztecTypes.AztecAsset calldata _outputAssetB,
                      uint256 _totalInputValue,
                      uint256 _interactionNonce,
                      uint64 _auxData,
                      address _rollupBeneficiary
                  ) external payable returns (uint256 outputValueA, uint256 outputValueB, bool isAsync);
                  /**
                   * @notice A function that finalises asynchronous interaction.
                   * @param _inputAssetA A struct detailing the first input asset
                   * @param _inputAssetB A struct detailing the second input asset
                   * @param _outputAssetA A struct detailing the first output asset
                   * @param _outputAssetB A struct detailing the second output asset
                   * @param _interactionNonce A globally unique identifier of this interaction/`convert(...)` call.
                   * @param _auxData Bridge specific data to be passed into the bridge contract (e.g. slippage, nftID etc.)
                   * @return outputValueA An amount of `_outputAssetA` returned from this interaction.
                   * @return outputValueB An amount of `_outputAssetB` returned from this interaction.
                   * @return interactionComplete A flag indicating whether an async interaction was successfully completed/finalised.
                   * @dev This function should use the `BridgeBase.onlyRollup()` modifier to ensure it can only be called from
                   *      the `RollupProcessor.processAsyncDefiInteraction(uint256 _interactionNonce)` method.
                   *
                   */
                  function finalise(
                      AztecTypes.AztecAsset calldata _inputAssetA,
                      AztecTypes.AztecAsset calldata _inputAssetB,
                      AztecTypes.AztecAsset calldata _outputAssetA,
                      AztecTypes.AztecAsset calldata _outputAssetB,
                      uint256 _interactionNonce,
                      uint64 _auxData
                  ) external payable returns (uint256 outputValueA, uint256 outputValueB, bool interactionComplete);
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              interface IVerifier {
                  function verify(bytes memory _serializedProof, uint256 _publicInputsHash) external returns (bool);
                  function getVerificationKeyHash() external pure returns (bytes32);
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec.
              pragma solidity >=0.8.4;
              library SafeCast {
                  error SAFE_CAST_OVERFLOW();
                  function toU128(uint256 a) internal pure returns (uint128) {
                      if (a > type(uint128).max) revert SAFE_CAST_OVERFLOW();
                      return uint128(a);
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              /**
               * @title TokenTransfers
               * @dev Provides functions to safely call `transfer` and `transferFrom` methods on ERC20 tokens,
               * as well as the ability to call `transfer` and `transferFrom` without bubbling up errors
               */
              library TokenTransfers {
                  error INVALID_ADDRESS_NO_CODE();
                  bytes4 private constant INVALID_ADDRESS_NO_CODE_SELECTOR = 0x21409272; // bytes4(keccak256('INVALID_ADDRESS_NO_CODE()'));
                  bytes4 private constant TRANSFER_SELECTOR = 0xa9059cbb; // bytes4(keccak256('transfer(address,uint256)'));
                  bytes4 private constant TRANSFER_FROM_SELECTOR = 0x23b872dd; // bytes4(keccak256('transferFrom(address,address,uint256)'));
                  /**
                   * @dev Safely call ERC20.transfer, handles tokens that do not throw on transfer failure or do not return transfer result
                   * @param tokenAddress Where does the token live?
                   * @param to Who are we sending tokens to?
                   * @param amount How many tokens are we transferring?
                   */
                  function safeTransferTo(address tokenAddress, address to, uint256 amount) internal {
                      // The ERC20 token standard states that:
                      // 1. failed transfers must throw
                      // 2. the result of the transfer (success/fail) is returned as a boolean
                      // Some token contracts don't implement the spec correctly and will do one of the following:
                      // 1. Contract does not throw if transfer fails, instead returns false
                      // 2. Contract throws if transfer fails, but does not return any boolean value
                      // We can check for these by evaluating the following:
                      // | call succeeds? (c) | return value (v) | returndatasize == 0 (r)| interpreted result |
                      // | ---                | ---              | ---                    | ---                |
                      // | false              | false            | false                  | transfer fails     |
                      // | false              | false            | true                   | transfer fails     |
                      // | false              | true             | false                  | transfer fails     |
                      // | false              | true             | true                   | transfer fails     |
                      // | true               | false            | false                  | transfer fails     |
                      // | true               | false            | true                   | transfer succeeds  |
                      // | true               | true             | false                  | transfer succeeds  |
                      // | true               | true             | true                   | transfer succeeds  |
                      //
                      // i.e. failure state = !(c && (r || v))
                      assembly {
                          let ptr := mload(0x40)
                          mstore(ptr, TRANSFER_SELECTOR)
                          mstore(add(ptr, 0x4), to)
                          mstore(add(ptr, 0x24), amount)
                          if iszero(extcodesize(tokenAddress)) {
                              mstore(0, INVALID_ADDRESS_NO_CODE_SELECTOR)
                              revert(0, 0x4)
                          }
                          let call_success := call(gas(), tokenAddress, 0, ptr, 0x44, 0x00, 0x20)
                          let result_success := or(iszero(returndatasize()), and(mload(0), 1))
                          if iszero(and(call_success, result_success)) {
                              returndatacopy(0, 0, returndatasize())
                              revert(0, returndatasize())
                          }
                      }
                  }
                  /**
                   * @dev Safely call ERC20.transferFrom, handles tokens that do not throw on transfer failure or do not return transfer result
                   * @param tokenAddress Where does the token live?
                   * @param source Who are we transferring tokens from
                   * @param target Who are we transferring tokens to?
                   * @param amount How many tokens are being transferred?
                   */
                  function safeTransferFrom(address tokenAddress, address source, address target, uint256 amount) internal {
                      assembly {
                          // call tokenAddress.transferFrom(source, target, value)
                          let mPtr := mload(0x40)
                          mstore(mPtr, TRANSFER_FROM_SELECTOR)
                          mstore(add(mPtr, 0x04), source)
                          mstore(add(mPtr, 0x24), target)
                          mstore(add(mPtr, 0x44), amount)
                          if iszero(extcodesize(tokenAddress)) {
                              mstore(0, INVALID_ADDRESS_NO_CODE_SELECTOR)
                              revert(0, 0x4)
                          }
                          let call_success := call(gas(), tokenAddress, 0, mPtr, 0x64, 0x00, 0x20)
                          let result_success := or(iszero(returndatasize()), and(mload(0), 1))
                          if iszero(and(call_success, result_success)) {
                              returndatacopy(0, 0, returndatasize())
                              revert(0, returndatasize())
                          }
                      }
                  }
                  /**
                   * @dev Calls ERC(tokenAddress).transfer(to, amount). Errors are ignored! Use with caution!
                   * @param tokenAddress Where does the token live?
                   * @param to Who are we sending to?
                   * @param amount How many tokens are being transferred?
                   * @param gasToSend Amount of gas to send the contract. If value is 0, function uses gas() instead
                   */
                  function transferToDoNotBubbleErrors(address tokenAddress, address to, uint256 amount, uint256 gasToSend)
                      internal
                  {
                      assembly {
                          let callGas := gas()
                          if gasToSend { callGas := gasToSend }
                          let ptr := mload(0x40)
                          mstore(ptr, TRANSFER_SELECTOR)
                          mstore(add(ptr, 0x4), to)
                          mstore(add(ptr, 0x24), amount)
                          pop(call(callGas, tokenAddress, 0, ptr, 0x44, 0x00, 0x00))
                      }
                  }
                  /**
                   * @dev Calls ERC(tokenAddress).transferFrom(source, target, amount). Errors are ignored! Use with caution!
                   * @param tokenAddress Where does the token live?
                   * @param source Who are we transferring tokens from
                   * @param target Who are we transferring tokens to?
                   * @param amount How many tokens are being transferred?
                   * @param gasToSend Amount of gas to send the contract. If value is 0, function uses gas() instead
                   */
                  function transferFromDoNotBubbleErrors(
                      address tokenAddress,
                      address source,
                      address target,
                      uint256 amount,
                      uint256 gasToSend
                  ) internal {
                      assembly {
                          let callGas := gas()
                          if gasToSend { callGas := gasToSend }
                          let mPtr := mload(0x40)
                          mstore(mPtr, TRANSFER_FROM_SELECTOR)
                          mstore(add(mPtr, 0x04), source)
                          mstore(add(mPtr, 0x24), target)
                          mstore(add(mPtr, 0x44), amount)
                          pop(call(callGas, tokenAddress, 0, mPtr, 0x64, 0x00, 0x00))
                      }
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec.
              pragma solidity >=0.8.4;
              import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
              import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";
              import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
              import {IVerifier} from "../interfaces/IVerifier.sol";
              import {IRollupProcessorV2, IRollupProcessor} from "rollup-encoder/interfaces/IRollupProcessorV2.sol";
              import {IDefiBridge} from "../interfaces/IDefiBridge.sol";
              import {Decoder} from "../Decoder.sol";
              import {AztecTypes} from "rollup-encoder/libraries/AztecTypes.sol";
              import {TokenTransfers} from "../libraries/TokenTransfers.sol";
              import {RollupProcessorLibrary} from "rollup-encoder/libraries/RollupProcessorLibrary.sol";
              import {SafeCast} from "../libraries/SafeCast.sol";
              /**
               * @title Rollup Processor
               * @dev Smart contract responsible for processing Aztec zkRollups, relaying them to a verifier
               *      contract for validation and performing all the relevant ERC20 token transfers
               */
              contract RollupProcessorV2 is IRollupProcessorV2, Decoder, Initializable, AccessControl {
                  using SafeCast for uint256;
                  /*----------------------------------------
                    ERROR TAGS
                    ----------------------------------------*/
                  error PAUSED();
                  error NOT_PAUSED();
                  error LOCKED_NO_REENTER();
                  error INVALID_PROVIDER();
                  error THIRD_PARTY_CONTRACTS_FLAG_NOT_SET();
                  error INSUFFICIENT_DEPOSIT();
                  error INVALID_ADDRESS_NO_CODE();
                  error INVALID_ASSET_GAS();
                  error INVALID_ASSET_ID();
                  error INVALID_ASSET_ADDRESS();
                  error INVALID_BRIDGE_GAS();
                  error INVALID_BRIDGE_CALL_DATA();
                  error INVALID_BRIDGE_ADDRESS();
                  error INVALID_ESCAPE_BOUNDS();
                  error INCONSISTENT_BRIDGE_CALL_DATA();
                  error BRIDGE_WITH_IDENTICAL_INPUT_ASSETS(uint256 inputAssetId);
                  error BRIDGE_WITH_IDENTICAL_OUTPUT_ASSETS(uint256 outputAssetId);
                  error ZERO_TOTAL_INPUT_VALUE();
                  error ARRAY_OVERFLOW();
                  error MSG_VALUE_WRONG_AMOUNT();
                  error INSUFFICIENT_ETH_PAYMENT();
                  error WITHDRAW_TO_ZERO_ADDRESS();
                  error DEPOSIT_TOKENS_WRONG_PAYMENT_TYPE();
                  error INSUFFICIENT_TOKEN_APPROVAL();
                  error NONZERO_OUTPUT_VALUE_ON_NOT_USED_ASSET(uint256 outputValue);
                  error INCORRECT_STATE_HASH(bytes32 oldStateHash, bytes32 newStateHash);
                  error INCORRECT_DATA_START_INDEX(uint256 providedIndex, uint256 expectedIndex);
                  error INCORRECT_PREVIOUS_DEFI_INTERACTION_HASH(
                      bytes32 providedDefiInteractionHash, bytes32 expectedDefiInteractionHash
                  );
                  error PUBLIC_INPUTS_HASH_VERIFICATION_FAILED(uint256, uint256);
                  error PROOF_VERIFICATION_FAILED();
                  error PENDING_CAP_SURPASSED();
                  error DAILY_CAP_SURPASSED();
                  /*----------------------------------------
                    EVENTS
                    ----------------------------------------*/
                  event OffchainData(uint256 indexed rollupId, uint256 chunk, uint256 totalChunks, address sender);
                  event RollupProcessed(uint256 indexed rollupId, bytes32[] nextExpectedDefiHashes, address sender);
                  event DefiBridgeProcessed(
                      uint256 indexed encodedBridgeCallData,
                      uint256 indexed nonce,
                      uint256 totalInputValue,
                      uint256 totalOutputValueA,
                      uint256 totalOutputValueB,
                      bool result,
                      bytes errorReason
                  );
                  event AsyncDefiBridgeProcessed(
                      uint256 indexed encodedBridgeCallData, uint256 indexed nonce, uint256 totalInputValue
                  );
                  event Deposit(uint256 indexed assetId, address indexed depositorAddress, uint256 depositValue);
                  event AssetAdded(uint256 indexed assetId, address indexed assetAddress, uint256 assetGasLimit);
                  event BridgeAdded(uint256 indexed bridgeAddressId, address indexed bridgeAddress, uint256 bridgeGasLimit);
                  event RollupProviderUpdated(address indexed providerAddress, bool valid);
                  event VerifierUpdated(address indexed verifierAddress);
                  event AllowThirdPartyContractsUpdated(bool allowed);
                  event DefiBridgeProxyUpdated(address defiBridgeProxy);
                  event Paused(address account);
                  event Unpaused(address account);
                  event DelayBeforeEscapeHatchUpdated(uint32 delay);
                  event AssetCapUpdated(uint256 assetId, uint256 pendingCap, uint256 dailyCap);
                  event CappedUpdated(bool isCapped);
                  /*----------------------------------------
                    STRUCTS
                    ----------------------------------------*/
                  // @dev ALLOW_ASYNC_REENTER lock is present to allow calling of `processAsyncDefiInteraction(...)` from within
                  //      bridge's `convert(...)` method.
                  enum Lock {
                      UNLOCKED,
                      ALLOW_ASYNC_REENTER,
                      LOCKED
                  }
                  /**
                   * @dev RollupState struct contains the following data:
                   *
                   * | bit offset   | num bits    | description |
                   * | ---          | ---         | ---         |
                   * | 0            | 160         | PLONK verifier contract address |
                   * | 160          | 32          | datasize: number of filled entries in note tree |
                   * | 192          | 16          | asyncDefiInteractionHashes.length : number of entries in asyncDefiInteractionHashes array |
                   * | 208          | 16          | defiInteractionHashes.length : number of entries in defiInteractionHashes array |
                   * | 224          | 8           | Lock enum used to guard against reentrancy attacks (minimum value to store in is uint8)
                   * | 232          | 8           | pause flag, true if contract is paused, false otherwise
                   * | 240          | 8           | capped flag, true if assets should check cap, false otherwise
                   *
                   * Note: (RollupState struct gets packed to 1 storage slot -> bit offset signifies location withing the 256 bit string)
                   */
                  struct RollupState {
                      IVerifier verifier;
                      uint32 datasize;
                      uint16 numAsyncDefiInteractionHashes;
                      uint16 numDefiInteractionHashes;
                      Lock lock;
                      bool paused;
                      bool capped;
                  }
                  /**
                   * @dev Contains information that describes a specific call to a bridge
                   */
                  struct FullBridgeCallData {
                      uint256 bridgeAddressId;
                      address bridgeAddress;
                      uint256 inputAssetIdA;
                      uint256 inputAssetIdB;
                      uint256 outputAssetIdA;
                      uint256 outputAssetIdB;
                      uint256 auxData;
                      bool firstInputVirtual;
                      bool secondInputVirtual;
                      bool firstOutputVirtual;
                      bool secondOutputVirtual;
                      bool secondInputInUse;
                      bool secondOutputInUse;
                      uint256 bridgeGasLimit;
                  }
                  /**
                   * @dev Represents an asynchronous DeFi bridge interaction that has not been resolved
                   * @param encodedBridgeCallData bit-string encoded bridge call data
                   * @param totalInputValue number of tokens/wei sent to the bridge
                   */
                  struct PendingDefiBridgeInteraction {
                      uint256 encodedBridgeCallData;
                      uint256 totalInputValue;
                  }
                  /**
                   * @dev Container for the results of a DeFi interaction
                   * @param outputValueA amount of output asset A returned from the interaction
                   * @param outputValueB amount of output asset B returned from the interaction (0 if asset B unused)
                   * @param isAsync true if the interaction is asynchronous, false otherwise
                   * @param success true if the call succeeded, false otherwise
                   */
                  struct BridgeResult {
                      uint256 outputValueA;
                      uint256 outputValueB;
                      bool isAsync;
                      bool success;
                  }
                  /**
                   * @dev Container for the inputs of a DeFi interaction
                   * @param totalInputValue number of tokens/wei sent to the bridge
                   * @param interactionNonce the unique id of the interaction
                   * @param auxData additional input specific to the type of interaction
                   */
                  struct InteractionInputs {
                      uint256 totalInputValue;
                      uint256 interactionNonce;
                      uint64 auxData;
                  }
                  /**
                   * @dev Container for asset cap restrictions
                   * @dev Caps used to limit usefulness of using Aztec to "wash" larger hacks
                   * @param available The amount of tokens that can be deposited, bounded by `dailyCap * 10 ** decimals`.
                   * @param lastUpdatedTimestamp The timestamp of the last deposit with caps activated
                   * @param pendingCap The cap for each individual pending deposit measured in whole tokens
                   * @param dailyCap The cap for total amount that can be added to `available` in 24 hours, measured in whole tokens
                   * @param precision The number of decimals in the precision for specific asset.
                   */
                  struct AssetCap {
                      uint128 available;
                      uint32 lastUpdatedTimestamp;
                      uint32 pendingCap;
                      uint32 dailyCap;
                      uint8 precision;
                  }
                  /*----------------------------------------
                    FUNCTION SELECTORS (PRECOMPUTED)
                    ----------------------------------------*/
                  // DEFI_BRIDGE_PROXY_CONVERT_SELECTOR = function signature of:
                  //   function convert(
                  //       address,
                  //       AztecTypes.AztecAsset memory inputAssetA,
                  //       AztecTypes.AztecAsset memory inputAssetB,
                  //       AztecTypes.AztecAsset memory outputAssetA,
                  //       AztecTypes.AztecAsset memory outputAssetB,
                  //       uint256 totalInputValue,
                  //       uint256 interactionNonce,
                  //       uint256 auxData,
                  //       uint256 ethPaymentsSlot
                  //       address rollupBeneficary)
                  // N.B. this is the selector of the 'convert' function of the DefiBridgeProxy contract.
                  //      This has a different interface to the IDefiBridge.convert function
                  bytes4 private constant DEFI_BRIDGE_PROXY_CONVERT_SELECTOR = 0x4bd947a8;
                  bytes4 private constant INVALID_ADDRESS_NO_CODE_SELECTOR = 0x21409272; // bytes4(keccak256('INVALID_ADDRESS_NO_CODE()'));
                  bytes4 private constant ARRAY_OVERFLOW_SELECTOR = 0x58a4ab0e; // bytes4(keccak256('ARRAY_OVERFLOW()'));
                  /*----------------------------------------
                    CONSTANT STATE VARIABLES
                    ----------------------------------------*/
                  uint256 private constant ETH_ASSET_ID = 0; // if assetId == ETH_ASSET_ID, treat as native ETH and not ERC20 token
                  // starting root hash of the DeFi interaction result Merkle tree
                  bytes32 private constant INIT_DEFI_ROOT = 0x2e4ab7889ab3139204945f9e722c7a8fdb84e66439d787bd066c3d896dba04ea;
                  bytes32 private constant DEFI_BRIDGE_PROCESSED_SIGHASH =
                      0x692cf5822a02f5edf084dc7249b3a06293621e069f11975ed70908ed10ed2e2c;
                  bytes32 private constant ASYNC_BRIDGE_PROCESSED_SIGHASH =
                      0x38ce48f4c2f3454bcf130721f25a4262b2ff2c8e36af937b30edf01ba481eb1d;
                  // We need to cap the amount of gas sent to the DeFi bridge contract for two reasons:
                  // 1. To provide consistency to rollup providers around costs,
                  // 2. to prevent griefing attacks where a bridge consumes all our gas.
                  uint256 private constant MIN_BRIDGE_GAS_LIMIT = 35000;
                  uint256 private constant MIN_ERC20_GAS_LIMIT = 55000;
                  uint256 private constant MAX_BRIDGE_GAS_LIMIT = 5000000;
                  uint256 private constant MAX_ERC20_GAS_LIMIT = 1500000;
                  // Bit offsets and bit masks used to extract values from `uint256 encodedBridgeCallData` to FullBridgeCallData struct
                  uint256 private constant INPUT_ASSET_ID_A_SHIFT = 32;
                  uint256 private constant INPUT_ASSET_ID_B_SHIFT = 62;
                  uint256 private constant OUTPUT_ASSET_ID_A_SHIFT = 92;
                  uint256 private constant OUTPUT_ASSET_ID_B_SHIFT = 122;
                  uint256 private constant BITCONFIG_SHIFT = 152;
                  uint256 private constant AUX_DATA_SHIFT = 184;
                  uint256 private constant VIRTUAL_ASSET_ID_FLAG_SHIFT = 29;
                  uint256 private constant VIRTUAL_ASSET_ID_FLAG = 0x2000_0000; // 2 ** 29
                  uint256 private constant MASK_THIRTY_TWO_BITS = 0xffff_ffff;
                  uint256 private constant MASK_THIRTY_BITS = 0x3fff_ffff;
                  uint256 private constant MASK_SIXTY_FOUR_BITS = 0xffff_ffff_ffff_ffff;
                  // Offsets and masks used to encode/decode the rollupState storage variable of RollupProcessor
                  uint256 private constant DATASIZE_BIT_OFFSET = 160;
                  uint256 private constant ASYNCDEFIINTERACTIONHASHES_BIT_OFFSET = 192;
                  uint256 private constant DEFIINTERACTIONHASHES_BIT_OFFSET = 208;
                  uint256 private constant ARRAY_LENGTH_MASK = 0x3ff; // 1023
                  uint256 private constant DATASIZE_MASK = 0xffff_ffff;
                  // the value of hashing a 'zeroed' DeFi interaction result
                  bytes32 private constant DEFI_RESULT_ZERO_HASH = 0x2d25a1e3a51eb293004c4b56abe12ed0da6bca2b4a21936752a85d102593c1b4;
                  // roles used in access control
                  bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE");
                  bytes32 public constant EMERGENCY_ROLE = keccak256("EMERGENCY_ROLE");
                  bytes32 public constant LISTER_ROLE = keccak256("LISTER_ROLE");
                  bytes32 public constant RESUME_ROLE = keccak256("RESUME_ROLE");
                  // bounds used for escape hatch
                  uint256 public immutable escapeBlockLowerBound;
                  uint256 public immutable escapeBlockUpperBound;
                  /*----------------------------------------
                    STATE VARIABLES
                    ----------------------------------------*/
                  RollupState internal rollupState;
                  // An array of addresses of supported ERC20 tokens
                  address[] internal supportedAssets;
                  // An array of addresses of supported bridges
                  // @dev `bridgeAddressId` is an index of the bridge's address in this array incremented by 1
                  address[] internal supportedBridges;
                  // A mapping from index to async interaction hash (emulates an array)
                  // @dev next index is stored in `RollupState.numAsyncDefiInteractionHashes`
                  mapping(uint256 => bytes32) public asyncDefiInteractionHashes;
                  // A mapping from index to interaction hash (emulates an array)
                  // @dev next index is stored in the `RollupState.numDefiInteractionHashes`
                  mapping(uint256 => bytes32) public defiInteractionHashes;
                  // A mapping from assetId to a mapping of userAddress to the user's public pending balance
                  mapping(uint256 => mapping(address => uint256)) public userPendingDeposits;
                  // A mapping from user's address to a mapping of proof hashes to a boolean which indicates approval
                  mapping(address => mapping(bytes32 => bool)) public depositProofApprovals;
                  // A hash of the latest rollup state
                  bytes32 public override(IRollupProcessor) rollupStateHash;
                  // An address of DefiBridgeProxy contract
                  address public override(IRollupProcessor) defiBridgeProxy;
                  // A flag indicating whether addresses without a LISTER role can list assets and bridges
                  // Note: will be set to true once Aztec Connect is no longer in BETA
                  bool public allowThirdPartyContracts;
                  // A mapping from an address to a boolean which indicates whether address is an approved rollup provider
                  // @dev A rollup provider is an address which is allowed to call `processRollup(...)` out of escape hatch window.
                  mapping(address => bool) public rollupProviders;
                  // A mapping from interactionNonce to PendingDefiBridgeInteraction struct
                  mapping(uint256 => PendingDefiBridgeInteraction) public pendingDefiInteractions;
                  // A mapping from interactionNonce to ETH amount which was received for that interaction.
                  // interaction
                  mapping(uint256 => uint256) public ethPayments;
                  // A mapping from an `assetId` to a gas limit
                  mapping(uint256 => uint256) public assetGasLimits;
                  // A mapping from a `bridgeAddressId` to a gas limit
                  mapping(uint256 => uint256) public bridgeGasLimits;
                  // A hash of hashes of pending DeFi interactions, the notes of which are expected to be added in the 'next' rollup
                  bytes32 public override(IRollupProcessor) prevDefiInteractionsHash;
                  // The timestamp of the last rollup that was performed by a rollup provider
                  uint32 public lastRollupTimeStamp;
                  // The delay in seconds from `lastRollupTimeStamp` until the escape hatch can be used.
                  uint32 public delayBeforeEscapeHatch;
                  mapping(uint256 => AssetCap) public caps;
                  /*----------------------------------------
                    MODIFIERS
                    ----------------------------------------*/
                  /**
                   * @notice A modifier forbidding functions from being called by addresses without LISTER role when Aztec Connect
                   *         is still in BETA (`allowThirdPartyContracts` variable set to false)
                   */
                  modifier checkThirdPartyContractStatus() {
                      if (!hasRole(LISTER_ROLE, msg.sender) && !allowThirdPartyContracts) {
                          revert THIRD_PARTY_CONTRACTS_FLAG_NOT_SET();
                      }
                      _;
                  }
                  /**
                   * @notice A modifier reverting if this contract is paused
                   */
                  modifier whenNotPaused() {
                      if (rollupState.paused) {
                          revert PAUSED();
                      }
                      _;
                  }
                  /**
                   * @notice A modifier reverting if this contract is NOT paused
                   */
                  modifier whenPaused() {
                      if (!rollupState.paused) {
                          revert NOT_PAUSED();
                      }
                      _;
                  }
                  /**
                   * @notice A modifier reverting on any re-enter
                   */
                  modifier noReenter() {
                      if (rollupState.lock != Lock.UNLOCKED) {
                          revert LOCKED_NO_REENTER();
                      }
                      rollupState.lock = Lock.LOCKED;
                      _;
                      rollupState.lock = Lock.UNLOCKED;
                  }
                  /**
                   * @notice A modifier reverting on any re-enter but allowing async to be called
                   */
                  modifier allowAsyncReenter() {
                      if (rollupState.lock != Lock.UNLOCKED) {
                          revert LOCKED_NO_REENTER();
                      }
                      rollupState.lock = Lock.ALLOW_ASYNC_REENTER;
                      _;
                      rollupState.lock = Lock.UNLOCKED;
                  }
                  /**
                   * @notice A modifier reverting if re-entering after locking, but passes if unlocked or if async is re-enter is
                   *         allowed
                   */
                  modifier noReenterButAsync() {
                      Lock lock = rollupState.lock;
                      if (lock == Lock.ALLOW_ASYNC_REENTER) {
                          _;
                      } else if (lock == Lock.UNLOCKED) {
                          rollupState.lock = Lock.ALLOW_ASYNC_REENTER;
                          _;
                          rollupState.lock = Lock.UNLOCKED;
                      } else {
                          revert LOCKED_NO_REENTER();
                      }
                  }
                  /**
                   * @notice A modifier which reverts if a given `_assetId` represents a virtual asset
                   * @param _assetId 30-bit integer that describes the asset
                   * @dev If _assetId's 29th bit is set, it represents a virtual asset with no ERC20 equivalent
                   *      Virtual assets are used by the bridges to track non-token data. E.g. to represent a loan.
                   *      If an _assetId is *not* a virtual asset, its ERC20 address can be recovered from
                   *      `supportedAssets[_assetId]`
                   */
                  modifier validateAssetIdIsNotVirtual(uint256 _assetId) {
                      if (_assetId > 0x1fffffff) {
                          revert INVALID_ASSET_ID();
                      }
                      _;
                  }
                  /*----------------------------------------
                    CONSTRUCTORS & INITIALIZERS
                    ----------------------------------------*/
                  /**
                   * @notice Constructor sets escape hatch window and ensure that the implementation cannot be initialized
                   * @param _escapeBlockLowerBound a block number which defines a start of the escape hatch window
                   * @param _escapeBlockUpperBound a block number which defines an end of the escape hatch window
                   */
                  constructor(uint256 _escapeBlockLowerBound, uint256 _escapeBlockUpperBound) {
                      if (_escapeBlockLowerBound == 0 || _escapeBlockLowerBound >= _escapeBlockUpperBound) {
                          revert INVALID_ESCAPE_BOUNDS();
                      }
                      // Set storage in implementation.
                      // Disable initializers to ensure no-one can call initialize on implementation directly
                      // Pause to limit possibility for user error
                      _disableInitializers();
                      rollupState.paused = true;
                      // Set immutables (part of code) so will be used in proxy calls as well
                      escapeBlockLowerBound = _escapeBlockLowerBound;
                      escapeBlockUpperBound = _escapeBlockUpperBound;
                  }
                  /**
                   * @notice Initialiser function which emulates constructor behaviour for upgradeable contracts
                   */
                  function initialize() external reinitializer(getImplementationVersion()) {
                      rollupState.capped = true;
                      lastRollupTimeStamp = uint32(block.timestamp);
                      // Set Eth asset caps. 6 Eth to cover 5 eth deposits + fee up to 1 eth.
                      caps[0] = AssetCap({
                          available: uint128(1000e18),
                          lastUpdatedTimestamp: uint32(block.timestamp),
                          pendingCap: 6,
                          dailyCap: 1000,
                          precision: 18
                      });
                      // Set Dai asset cap. 10100 Dai to cover 10K deposits + fee up to 100 dai.
                      caps[1] = AssetCap({
                          available: uint128(1e24),
                          lastUpdatedTimestamp: uint32(block.timestamp),
                          pendingCap: 10100,
                          dailyCap: 1e6,
                          precision: 18
                      });
                      emit AssetCapUpdated(0, 6, 1000);
                      emit AssetCapUpdated(1, 10100, 1e6);
                  }
                  /*----------------------------------------
                    MUTATING FUNCTIONS WITH ACCESS CONTROL 
                    ----------------------------------------*/
                  /**
                   * @notice A function which allow the holders of the EMERGENCY_ROLE role to pause the contract
                   */
                  function pause() public override (IRollupProcessor) whenNotPaused onlyRole(EMERGENCY_ROLE) noReenter {
                      rollupState.paused = true;
                      emit Paused(msg.sender);
                  }
                  /**
                   * @dev Allow the holders of the RESUME_ROLE to unpause the contract.
                   */
                  function unpause() public override (IRollupProcessor) whenPaused onlyRole(RESUME_ROLE) noReenter {
                      rollupState.paused = false;
                      emit Unpaused(msg.sender);
                  }
                  /**
                   * @notice A function which allows holders of OWNER_ROLE to set the capped flag
                   * @dev When going from uncapped to capped, will update `lastRollupTimeStamp`
                   * @param _isCapped a flag indicating whether caps are used or not
                   */
                  function setCapped(bool _isCapped) external onlyRole(OWNER_ROLE) noReenter {
                      if (_isCapped == rollupState.capped) return;
                      if (_isCapped) {
                          lastRollupTimeStamp = uint32(block.timestamp);
                      }
                      rollupState.capped = _isCapped;
                      emit CappedUpdated(_isCapped);
                  }
                  /**
                   * @notice A function which allows holders of OWNER_ROLE to add and remove a rollup provider.
                   * @param _provider an address of the rollup provider
                   * @param _valid a flag indicating whether `_provider` is valid
                   */
                  function setRollupProvider(address _provider, bool _valid)
                      external
                      override (IRollupProcessor)
                      onlyRole(OWNER_ROLE)
                      noReenter
                  {
                      rollupProviders[_provider] = _valid;
                      emit RollupProviderUpdated(_provider, _valid);
                  }
                  /**
                   * @notice A function which allows holders of the LISTER_ROLE to update asset caps
                   * @param _assetId The asset id to update the cap for
                   * @param _pendingCap The pending cap in whole tokens
                   * @param _dailyCap The daily "accrual" to available deposits in whole tokens
                   * @param _precision The precision (decimals) to multiply the caps with
                   */
                  function setAssetCap(uint256 _assetId, uint32 _pendingCap, uint32 _dailyCap, uint8 _precision)
                      external
                      onlyRole(LISTER_ROLE)
                      noReenter
                  {
                      caps[_assetId] = AssetCap({
                          available: (uint256(_dailyCap) * 10 ** _precision).toU128(),
                          lastUpdatedTimestamp: uint32(block.timestamp),
                          pendingCap: _pendingCap,
                          dailyCap: _dailyCap,
                          precision: _precision
                      });
                      emit AssetCapUpdated(_assetId, _pendingCap, _dailyCap);
                  }
                  /**
                   * @notice A function which allows holders of the OWNER_ROLE to specify the delay before escapehatch is possible
                   * @param _delay the delay in seconds between last rollup by a provider, and escape hatch being possible
                   */
                  function setDelayBeforeEscapeHatch(uint32 _delay) external onlyRole(OWNER_ROLE) noReenter {
                      delayBeforeEscapeHatch = _delay;
                      emit DelayBeforeEscapeHatchUpdated(_delay);
                  }
                  /**
                   * @notice A function which allows holders of OWNER_ROLE to set the address of the PLONK verification smart
                   *  (         contract
                   * @param _verifier an address of the verification smart contract
                   */
                  function setVerifier(address _verifier) public override (IRollupProcessor) onlyRole(OWNER_ROLE) noReenter {
                      if (_verifier.code.length == 0) {
                          revert INVALID_ADDRESS_NO_CODE();
                      }
                      rollupState.verifier = IVerifier(_verifier);
                      emit VerifierUpdated(_verifier);
                  }
                  /**
                   * @notice A function which allows holders of OWNER_ROLE to set `allowThirdPartyContracts` flag
                   * @param _allowThirdPartyContracts A flag indicating true if allowing third parties to register, false otherwise
                   */
                  function setAllowThirdPartyContracts(bool _allowThirdPartyContracts)
                      external
                      override (IRollupProcessor)
                      onlyRole(OWNER_ROLE)
                      noReenter
                  {
                      allowThirdPartyContracts = _allowThirdPartyContracts;
                      emit AllowThirdPartyContractsUpdated(_allowThirdPartyContracts);
                  }
                  /**
                   * @notice A function which allows holders of OWNER_ROLE to set address of `DefiBridgeProxy` contract
                   * @param _defiBridgeProxy an address of `DefiBridgeProxy` contract
                   */
                  function setDefiBridgeProxy(address _defiBridgeProxy)
                      public
                      override (IRollupProcessor)
                      onlyRole(OWNER_ROLE)
                      noReenter
                  {
                      if (_defiBridgeProxy.code.length == 0) {
                          revert INVALID_ADDRESS_NO_CODE();
                      }
                      defiBridgeProxy = _defiBridgeProxy;
                      emit DefiBridgeProxyUpdated(_defiBridgeProxy);
                  }
                  /**
                   * @notice Registers an ERC20 token as a supported asset
                   * @param _token address of the ERC20 token
                   * @param _gasLimit gas limit used when transferring the token (in withdraw or transferFee)
                   */
                  function setSupportedAsset(address _token, uint256 _gasLimit)
                      external
                      override (IRollupProcessor)
                      whenNotPaused
                      checkThirdPartyContractStatus
                      noReenter
                  {
                      if (_token.code.length == 0) {
                          revert INVALID_ADDRESS_NO_CODE();
                      }
                      if (_gasLimit < MIN_ERC20_GAS_LIMIT || _gasLimit > MAX_ERC20_GAS_LIMIT) {
                          revert INVALID_ASSET_GAS();
                      }
                      supportedAssets.push(_token);
                      uint256 assetId = supportedAssets.length;
                      assetGasLimits[assetId] = _gasLimit;
                      emit AssetAdded(assetId, _token, assetGasLimits[assetId]);
                  }
                  /**
                   * @dev Appends a bridge contract to the supportedBridges
                   * @param _bridge address of the bridge contract
                   * @param _gasLimit gas limit forwarded to the DefiBridgeProxy to perform convert
                   */
                  function setSupportedBridge(address _bridge, uint256 _gasLimit)
                      external
                      override (IRollupProcessor)
                      whenNotPaused
                      checkThirdPartyContractStatus
                      noReenter
                  {
                      if (_bridge.code.length == 0) {
                          revert INVALID_ADDRESS_NO_CODE();
                      }
                      if (_gasLimit < MIN_BRIDGE_GAS_LIMIT || _gasLimit > MAX_BRIDGE_GAS_LIMIT) {
                          revert INVALID_BRIDGE_GAS();
                      }
                      supportedBridges.push(_bridge);
                      uint256 bridgeAddressId = supportedBridges.length;
                      bridgeGasLimits[bridgeAddressId] = _gasLimit;
                      emit BridgeAdded(bridgeAddressId, _bridge, bridgeGasLimits[bridgeAddressId]);
                  }
                  /**
                   * @notice A function which processes a rollup
                   * @dev Rollup processing consists of decoding a rollup, verifying the corresponding proof and updating relevant
                   *      state variables
                   * @dev The `encodedProofData` is unnamed param as we are reading it directly from calldata when decoding
                   *      and creating the `proofData` in `Decoder::decodeProof()`.
                   * @dev For the rollup to be processed `msg.sender` has to be an authorised rollup provider or escape hatch has
                   *      to be open
                   * @dev This function always transfers fees to the `rollupBeneficiary` encoded in the proof data
                   *
                   * @param - cryptographic proof data associated with a rollup
                   * @param _signatures a byte array of secp256k1 ECDSA signatures, authorising a transfer of tokens from
                   *                    the publicOwner for the particular inner proof in question
                   *
                   * Structure of each signature in the bytes array is:
                   * 0x00 - 0x20 : r
                   * 0x20 - 0x40 : s
                   * 0x40 - 0x60 : v (in form: 0x0000....0001b for example)
                   */
                  function processRollup(bytes calldata, /* encodedProofData */ bytes calldata _signatures)
                      external
                      override (IRollupProcessor)
                      whenNotPaused
                      allowAsyncReenter
                  {
                      if (rollupProviders[msg.sender]) {
                          if (rollupState.capped) {
                              lastRollupTimeStamp = uint32(block.timestamp);
                          }
                      } else {
                          (bool isOpen,) = getEscapeHatchStatus();
                          if (!isOpen) {
                              revert INVALID_PROVIDER();
                          }
                      }
                      (bytes memory proofData, uint256 numTxs, uint256 publicInputsHash) = decodeProof();
                      address rollupBeneficiary = extractRollupBeneficiary(proofData);
                      processRollupProof(proofData, _signatures, numTxs, publicInputsHash, rollupBeneficiary);
                      transferFee(proofData, rollupBeneficiary);
                  }
                  /*----------------------------------------
                    PUBLIC/EXTERNAL MUTATING FUNCTIONS 
                    ----------------------------------------*/
                  /**
                   * @notice A function used by bridges to send ETH to the RollupProcessor during an interaction
                   * @param _interactionNonce an interaction nonce that used as an ID of this payment
                   */
                  function receiveEthFromBridge(uint256 _interactionNonce) external payable override (IRollupProcessor) {
                      assembly {
                          // ethPayments[interactionNonce] += msg.value
                          mstore(0x00, _interactionNonce)
                          mstore(0x20, ethPayments.slot)
                          let slot := keccak256(0x00, 0x40)
                          // no need to check for overflows as this would require sending more than the blockchain's total supply of ETH!
                          sstore(slot, add(sload(slot), callvalue()))
                      }
                  }
                  /**
                   * @notice A function which approves a proofHash to spend the user's pending deposited funds
                   * @dev this function is one way and must be called by the owner of the funds
                   * @param _proofHash keccak256 hash of the inner proof public inputs
                   */
                  function approveProof(bytes32 _proofHash) public override (IRollupProcessor) whenNotPaused {
                      // asm implementation to reduce compiled bytecode size
                      assembly {
                          // depositProofApprovals[msg.sender][_proofHash] = true;
                          mstore(0x00, caller())
                          mstore(0x20, depositProofApprovals.slot)
                          mstore(0x20, keccak256(0x00, 0x40))
                          mstore(0x00, _proofHash)
                          sstore(keccak256(0x00, 0x40), 1)
                      }
                  }
                  /**
                   * @notice A function which deposits funds to the contract
                   * @dev This is the first stage of a 2 stage deposit process. In the second stage funds are claimed by the user on
                   *      L2.
                   * @param _assetId asset ID which was assigned during asset registration
                   * @param _amount token deposit amount
                   * @param _owner address that can spend the deposited funds
                   * @param _proofHash 32 byte transaction id that can spend the deposited funds
                   */
                  function depositPendingFunds(uint256 _assetId, uint256 _amount, address _owner, bytes32 _proofHash)
                      external
                      payable
                      override (IRollupProcessor)
                      whenNotPaused
                      noReenter
                  {
                      // Perform sanity checks on user input
                      if (_assetId == ETH_ASSET_ID && msg.value != _amount) {
                          revert MSG_VALUE_WRONG_AMOUNT();
                      }
                      if (_assetId != ETH_ASSET_ID && msg.value != 0) {
                          revert DEPOSIT_TOKENS_WRONG_PAYMENT_TYPE();
                      }
                      increasePendingDepositBalance(_assetId, _owner, _amount);
                      if (_proofHash != 0) approveProof(_proofHash);
                      emit Deposit(_assetId, _owner, _amount);
                      if (_assetId != ETH_ASSET_ID) {
                          address assetAddress = getSupportedAsset(_assetId);
                          // check user approved contract to transfer funds, so can throw helpful error to user
                          if (IERC20(assetAddress).allowance(msg.sender, address(this)) < _amount) {
                              revert INSUFFICIENT_TOKEN_APPROVAL();
                          }
                          TokenTransfers.safeTransferFrom(assetAddress, msg.sender, address(this), _amount);
                      }
                  }
                  /**
                   * @notice A function used to publish data that doesn't need to be accessible on-chain
                   * @dev This function can be called multiple times to work around maximum tx size limits
                   * @dev The data is expected to be reconstructed by the client
                   * @param _rollupId rollup id this data is related to
                   * @param _chunk the chunk number, from 0 to totalChunks-1.
                   * @param _totalChunks the total number of chunks.
                   * @param - the data
                   */
                  function offchainData(uint256 _rollupId, uint256 _chunk, uint256 _totalChunks, bytes calldata /* offchainTxData */ )
                      external
                      override (IRollupProcessor)
                      whenNotPaused
                  {
                      emit OffchainData(_rollupId, _chunk, _totalChunks, msg.sender);
                  }
                  /**
                   * @notice A function which process async bridge interaction
                   * @param _interactionNonce unique id of the interaction
                   * @return true if successful, false otherwise
                   */
                  function processAsyncDefiInteraction(uint256 _interactionNonce)
                      external
                      override (IRollupProcessor)
                      whenNotPaused
                      noReenterButAsync
                      returns (bool)
                  {
                      uint256 encodedBridgeCallData;
                      uint256 totalInputValue;
                      assembly {
                          mstore(0x00, _interactionNonce)
                          mstore(0x20, pendingDefiInteractions.slot)
                          let interactionPtr := keccak256(0x00, 0x40)
                          encodedBridgeCallData := sload(interactionPtr)
                          totalInputValue := sload(add(interactionPtr, 0x01))
                      }
                      if (encodedBridgeCallData == 0) {
                          revert INVALID_BRIDGE_CALL_DATA();
                      }
                      FullBridgeCallData memory fullBridgeCallData = getFullBridgeCallData(encodedBridgeCallData);
                      (
                          AztecTypes.AztecAsset memory inputAssetA,
                          AztecTypes.AztecAsset memory inputAssetB,
                          AztecTypes.AztecAsset memory outputAssetA,
                          AztecTypes.AztecAsset memory outputAssetB
                      ) = getAztecAssetTypes(fullBridgeCallData, _interactionNonce);
                      // Extract the bridge address from the encodedBridgeCallData
                      IDefiBridge bridgeContract;
                      assembly {
                          mstore(0x00, supportedBridges.slot)
                          let bridgeSlot := keccak256(0x00, 0x20)
                          bridgeContract := and(encodedBridgeCallData, 0xffffffff)
                          bridgeContract := sload(add(bridgeSlot, sub(bridgeContract, 0x01)))
                          bridgeContract := and(bridgeContract, ADDRESS_MASK)
                      }
                      if (address(bridgeContract) == address(0)) {
                          revert INVALID_BRIDGE_ADDRESS();
                      }
                      // delete pendingDefiInteractions[interactionNonce]
                      // N.B. only need to delete 1st slot value `encodedBridgeCallData`. Deleting vars costs gas post-London
                      // setting encodedBridgeCallData to 0 is enough to cause future calls with this interaction nonce to fail
                      pendingDefiInteractions[_interactionNonce].encodedBridgeCallData = 0;
                      // Copy some variables to front of stack to get around stack too deep errors
                      InteractionInputs memory inputs =
                          InteractionInputs(totalInputValue, _interactionNonce, uint64(fullBridgeCallData.auxData));
                      (uint256 outputValueA, uint256 outputValueB, bool interactionCompleted) = bridgeContract.finalise(
                          inputAssetA, inputAssetB, outputAssetA, outputAssetB, inputs.interactionNonce, inputs.auxData
                      );
                      if (!interactionCompleted) {
                          pendingDefiInteractions[inputs.interactionNonce].encodedBridgeCallData = encodedBridgeCallData;
                          return false;
                      }
                      if (outputValueB > 0 && outputAssetB.assetType == AztecTypes.AztecAssetType.NOT_USED) {
                          revert NONZERO_OUTPUT_VALUE_ON_NOT_USED_ASSET(outputValueB);
                      }
                      if (outputValueA == 0 && outputValueB == 0) {
                          // issue refund.
                          transferTokensAsync(address(bridgeContract), inputAssetA, inputs.totalInputValue, inputs.interactionNonce);
                          transferTokensAsync(address(bridgeContract), inputAssetB, inputs.totalInputValue, inputs.interactionNonce);
                      } else {
                          // transfer output tokens to rollup contract
                          transferTokensAsync(address(bridgeContract), outputAssetA, outputValueA, inputs.interactionNonce);
                          transferTokensAsync(address(bridgeContract), outputAssetB, outputValueB, inputs.interactionNonce);
                      }
                      // compute defiInteractionHash and push it onto the asyncDefiInteractionHashes array
                      bool result;
                      assembly {
                          // Load values from `input` (to get around stack too deep)
                          let inputValue := mload(inputs)
                          let nonce := mload(add(inputs, 0x20))
                          result := iszero(and(eq(outputValueA, 0), eq(outputValueB, 0)))
                          // Compute defi interaction hash
                          let mPtr := mload(0x40)
                          mstore(mPtr, encodedBridgeCallData)
                          mstore(add(mPtr, 0x20), nonce)
                          mstore(add(mPtr, 0x40), inputValue)
                          mstore(add(mPtr, 0x60), outputValueA)
                          mstore(add(mPtr, 0x80), outputValueB)
                          mstore(add(mPtr, 0xa0), result)
                          pop(staticcall(gas(), 0x2, mPtr, 0xc0, 0x00, 0x20))
                          let defiInteractionHash := mod(mload(0x00), CIRCUIT_MODULUS)
                          // Load sync and async array lengths from rollup state
                          let state := sload(rollupState.slot)
                          // asyncArrayLen = rollupState.numAsyncDefiInteractionHashes
                          let asyncArrayLen := and(ARRAY_LENGTH_MASK, shr(ASYNCDEFIINTERACTIONHASHES_BIT_OFFSET, state))
                          // defiArrayLen = rollupState.numDefiInteractionHashes
                          let defiArrayLen := and(ARRAY_LENGTH_MASK, shr(DEFIINTERACTIONHASHES_BIT_OFFSET, state))
                          // check that size of asyncDefiInteractionHashes isn't such that
                          // adding 1 to it will make the next block's defiInteractionHashes length hit 512
                          if gt(add(add(1, asyncArrayLen), defiArrayLen), 512) {
                              mstore(0, ARRAY_OVERFLOW_SELECTOR)
                              revert(0, 0x4)
                          }
                          // asyncDefiInteractionHashes[asyncArrayLen] = defiInteractionHash
                          mstore(0x00, asyncArrayLen)
                          mstore(0x20, asyncDefiInteractionHashes.slot)
                          sstore(keccak256(0x00, 0x40), defiInteractionHash)
                          // increase asyncDefiInteractionHashes.length by 1
                          let oldState := and(not(shl(ASYNCDEFIINTERACTIONHASHES_BIT_OFFSET, ARRAY_LENGTH_MASK)), state)
                          let newState := or(oldState, shl(ASYNCDEFIINTERACTIONHASHES_BIT_OFFSET, add(asyncArrayLen, 0x01)))
                          sstore(rollupState.slot, newState)
                      }
                      emit DefiBridgeProcessed(
                          encodedBridgeCallData,
                          inputs.interactionNonce,
                          inputs.totalInputValue,
                          outputValueA,
                          outputValueB,
                          result,
                          ""
                          );
                      return true;
                  }
                  /*----------------------------------------
                    INTERNAL/PRIVATE MUTATING FUNCTIONS 
                    ----------------------------------------*/
                  /**
                   * @notice A function which increasees pending deposit amount in the `userPendingDeposits` mapping
                   * @dev Implemented in assembly in order to reduce compiled bytecode size and improve gas costs
                   * @param _assetId asset ID which was assigned during asset registration
                   * @param _owner address that can spend the deposited funds
                   * @param _amount deposit token amount
                   */
                  function increasePendingDepositBalance(uint256 _assetId, address _owner, uint256 _amount)
                      internal
                      validateAssetIdIsNotVirtual(_assetId)
                  {
                      uint256 pending = userPendingDeposits[_assetId][_owner];
                      if (rollupState.capped) {
                          AssetCap memory cap = caps[_assetId];
                          uint256 precision = 10 ** cap.precision;
                          if (cap.pendingCap == 0 || pending + _amount > uint256(cap.pendingCap) * precision) {
                              revert PENDING_CAP_SURPASSED();
                          }
                          if (cap.dailyCap == 0) {
                              revert DAILY_CAP_SURPASSED();
                          } else {
                              // Increase the available amount, capped by dailyCap
                              uint256 capVal = uint256(cap.dailyCap) * precision;
                              uint256 rate = capVal / 1 days;
                              cap.available += (rate * (block.timestamp - cap.lastUpdatedTimestamp)).toU128();
                              if (cap.available > capVal) {
                                  cap.available = capVal.toU128();
                              }
                              if (_amount > cap.available) {
                                  revert DAILY_CAP_SURPASSED();
                              }
                              // Update available and timestamp
                              cap.available -= _amount.toU128();
                              cap.lastUpdatedTimestamp = uint32(block.timestamp);
                              caps[_assetId] = cap;
                          }
                      }
                      userPendingDeposits[_assetId][_owner] = pending + _amount;
                  }
                  /**
                   * @notice A function which decreases pending deposit amount in the `userPendingDeposits` mapping
                   * @dev Implemented in assembly in order to reduce compiled bytecode size and improve gas costs
                   * @param _assetId asset ID which was assigned during asset registration
                   * @param _owner address that owns the pending deposit
                   * @param _amount amount of tokens to decrease pending by
                   */
                  function decreasePendingDepositBalance(uint256 _assetId, address _owner, uint256 _amount)
                      internal
                      validateAssetIdIsNotVirtual(_assetId)
                  {
                      bool insufficientDeposit = false;
                      assembly {
                          // userPendingDeposit = userPendingDeposits[_assetId][_owner]
                          mstore(0x00, _assetId)
                          mstore(0x20, userPendingDeposits.slot)
                          mstore(0x20, keccak256(0x00, 0x40))
                          mstore(0x00, _owner)
                          let userPendingDepositSlot := keccak256(0x00, 0x40)
                          let userPendingDeposit := sload(userPendingDepositSlot)
                          insufficientDeposit := lt(userPendingDeposit, _amount)
                          let newDeposit := sub(userPendingDeposit, _amount)
                          sstore(userPendingDepositSlot, newDeposit)
                      }
                      if (insufficientDeposit) {
                          revert INSUFFICIENT_DEPOSIT();
                      }
                  }
                  /**
                   * @notice A function that processes a rollup proof
                   * @dev Processing a rollup proof consists of:
                   *          1) Verifying the proof's correctness,
                   *          2) using the provided proof data to update rollup state + merkle roots,
                   *          3) validate/enacting any deposits/withdrawals,
                   *          4) processing bridge calls.
                   * @param _proofData decoded rollup proof data
                   * @param _signatures ECDSA signatures from users authorizing deposit transactions
                   * @param _numTxs the number of transactions in the block
                   * @param _publicInputsHash the SHA256 hash of the proof's public inputs
                   * @param _rollupBeneficiary The address to be paid any subsidy for bridge calls and rollup fees
                   */
                  function processRollupProof(
                      bytes memory _proofData,
                      bytes memory _signatures,
                      uint256 _numTxs,
                      uint256 _publicInputsHash,
                      address _rollupBeneficiary
                  ) internal {
                      uint256 rollupId = verifyProofAndUpdateState(_proofData, _publicInputsHash);
                      processDepositsAndWithdrawals(_proofData, _numTxs, _signatures);
                      bytes32[] memory nextDefiHashes = processBridgeCalls(_proofData, _rollupBeneficiary);
                      emit RollupProcessed(rollupId, nextDefiHashes, msg.sender);
                  }
                  /**
                   * @notice A function which verifies zk proof and updates the contract's state variables
                   * @dev encodedProofData is read from calldata passed into the transaction and differs from `_proofData`
                   * @param _proofData decoded rollup proof data
                   * @param _publicInputsHash a hash of public inputs (computed by `Decoder.sol`)
                   * @return rollupId id of the rollup which is being processed
                   */
                  function verifyProofAndUpdateState(bytes memory _proofData, uint256 _publicInputsHash)
                      internal
                      returns (uint256 rollupId)
                  {
                      // Verify the rollup proof.
                      //
                      // We manually call the verifier contract via assembly to save on gas costs and to reduce contract bytecode size
                      assembly {
                          /**
                           * Validate correctness of zk proof.
                           *
                           * 1st Item is to format verifier calldata.
                           *
                           */
                          // The `encodedProofData` (in calldata) contains the concatenation of
                          // encoded 'broadcasted inputs' and the actual zk proof data.
                          // (The `boadcasted inputs` is converted into a 32-byte SHA256 hash, which is
                          // validated to equal the first public inputs of the zk proof. This is done in `Decoder.sol`).
                          // We need to identify the location in calldata that points to the start of the zk proof data.
                          // Step 1: compute size of zk proof data and its calldata pointer.
                          /**
                           * Data layout for `bytes encodedProofData`...
                           *
                           *             0x00 : 0x20 : length of array
                           *             0x20 : 0x20 + header : root rollup header data
                           *             0x20 + header : 0x24 + header : X, the length of encoded inner join-split public inputs
                           *             0x24 + header : 0x24 + header + X : (inner join-split public inputs)
                           *             0x24 + header + X : 0x28 + header + X : Y, the length of the zk proof data
                           *             0x28 + header + X : 0x28 + haeder + X + Y : zk proof data
                           *
                           *             We need to recover the numeric value of `0x28 + header + X` and `Y`
                           *
                           */
                          // Begin by getting length of encoded inner join-split public inputs.
                          // `calldataload(0x04)` points to start of bytes array. Add 0x24 to skip over length param and function signature.
                          // The calldata param 4 bytes *after* the header is the length of the pub inputs array. However it is a packed 4-byte param.
                          // To extract it, we subtract 24 bytes from the calldata pointer and mask off all but the 4 least significant bytes.
                          let encodedInnerDataSize :=
                              and(calldataload(add(add(calldataload(0x04), 0x24), sub(ROLLUP_HEADER_LENGTH, 0x18))), 0xffffffff)
                          // add 8 bytes to skip over the two packed params that follow the rollup header data
                          // broadcastedDataSize = inner join-split pubinput size + header size
                          let broadcastedDataSize := add(add(ROLLUP_HEADER_LENGTH, 8), encodedInnerDataSize)
                          // Compute zk proof data size by subtracting broadcastedDataSize from overall length of bytes encodedProofsData
                          let zkProofDataSize := sub(calldataload(add(calldataload(0x04), 0x04)), broadcastedDataSize)
                          // Compute calldata pointer to start of zk proof data by adding calldata offset to broadcastedDataSize
                          // (+0x24 skips over function signature and length param of bytes encodedProofData)
                          let zkProofDataPtr := add(broadcastedDataSize, add(calldataload(0x04), 0x24))
                          // Step 2: Format calldata for verifier contract call.
                          // Get free memory pointer - we copy calldata into memory starting here
                          let dataPtr := mload(0x40)
                          // We call the function `verify(bytes,uint256)`
                          // The function signature is 0xac318c5d
                          // Calldata map is:
                          // 0x00 - 0x04 : 0xac318c5d
                          // 0x04 - 0x24 : 0x40 (number of bytes between 0x04 and the start of the `proofData` array at 0x44)
                          // 0x24 - 0x44 : publicInputsHash
                          // 0x44 - .... : proofData
                          mstore8(dataPtr, 0xac)
                          mstore8(add(dataPtr, 0x01), 0x31)
                          mstore8(add(dataPtr, 0x02), 0x8c)
                          mstore8(add(dataPtr, 0x03), 0x5d)
                          mstore(add(dataPtr, 0x04), 0x40)
                          mstore(add(dataPtr, 0x24), _publicInputsHash)
                          mstore(add(dataPtr, 0x44), zkProofDataSize) // length of zkProofData bytes array
                          calldatacopy(add(dataPtr, 0x64), zkProofDataPtr, zkProofDataSize) // copy the zk proof data into memory
                          // Step 3: Call our verifier contract. It does not return any values, but will throw an error if the proof is not valid
                          // i.e. verified == false if proof is not valid
                          let verifierAddress := and(sload(rollupState.slot), ADDRESS_MASK)
                          if iszero(extcodesize(verifierAddress)) {
                              mstore(0, INVALID_ADDRESS_NO_CODE_SELECTOR)
                              revert(0, 0x4)
                          }
                          let proof_verified := staticcall(gas(), verifierAddress, dataPtr, add(zkProofDataSize, 0x64), 0x00, 0x00)
                          // Check the proof is valid!
                          if iszero(proof_verified) {
                              returndatacopy(0, 0, returndatasize())
                              revert(0, returndatasize())
                          }
                      }
                      // Validate and update state hash
                      rollupId = validateAndUpdateMerkleRoots(_proofData);
                  }
                  /**
                   * @notice Extracts roots from public inputs and validate that they are inline with current contract `rollupState`
                   * @param _proofData decoded rollup proof data
                   * @return rollup id
                   * @dev To make the circuits happy, we want to only insert at the next subtree. The subtrees that we are using are
                   *      28 leafs in size. They could be smaller but we just want them to be of same size for circuit related
                   *      reasons.
                   *          When we have the case that the `storedDataSize % numDataLeaves == 0`, we are perfectly dividing. This
                   *      means that the incoming rollup matches perfectly with a boundry of the next subtree.
                   *          When this is not the case, we have to compute an offset that we then apply so that the full state can
                   *      be build with a bunch of same-sized trees (when the rollup is not full we insert a tree with some zero
                   *      leaves). This offset can be computed as `numDataLeaves - (storedDataSize % numDataLeaves)` and is,
                   *      essentially, how big a "space" we should leave so that the currently inserted subtree ends exactly at
                   *      the subtree boundry. The value is always >= 0. In the function below we won’t hit the zero case, because
                   *      that would be cought by the "if-branch".
                   *
                   *      Example: We have just had 32 rollups of size 28 (`storedDataSize = 896`). Now there is a small rollup with
                   *      only 6 transactions. We are not perfectly dividing, hence we compute the offset as `6 - 896 % 6 = 4`.
                   *      The start index is `896 + 4 = 900`. With the added leaves, the stored data size now becomes `906`.
                   *          Now, comes another full rollup (28 txs). We compute `906 % 28 = 10`. The value is non-zero which means
                   *      that we don’t perfectly divide and have to compute an offset `28 - 906 % 28 = 18`. The start index is
                   *      `906 + 18 = 924`. Notice that `924 % 28 == 0`, so this will land us exactly at a location where everything
                   *      in the past could have been subtrees of size 28.
                   */
                  function validateAndUpdateMerkleRoots(bytes memory _proofData) internal returns (uint256) {
                      (uint256 rollupId, bytes32 oldStateHash, bytes32 newStateHash, uint32 numDataLeaves, uint32 dataStartIndex) =
                          computeRootHashes(_proofData);
                      if (oldStateHash != rollupStateHash) {
                          revert INCORRECT_STATE_HASH(oldStateHash, newStateHash);
                      }
                      unchecked {
                          uint32 storedDataSize = rollupState.datasize;
                          // Ensure we are inserting at the next subtree boundary.
                          if (storedDataSize % numDataLeaves == 0) {
                              if (dataStartIndex != storedDataSize) {
                                  revert INCORRECT_DATA_START_INDEX(dataStartIndex, storedDataSize);
                              }
                          } else {
                              uint256 expected = storedDataSize + numDataLeaves - (storedDataSize % numDataLeaves);
                              if (dataStartIndex != expected) {
                                  revert INCORRECT_DATA_START_INDEX(dataStartIndex, expected);
                              }
                          }
                          rollupStateHash = newStateHash;
                          rollupState.datasize = dataStartIndex + numDataLeaves;
                      }
                      return rollupId;
                  }
                  /**
                   * @notice A function which processes deposits and withdrawls
                   * @param _proofData decoded rollup proof data
                   * @param _numTxs number of transactions rolled up in the proof
                   * @param _signatures byte array of secp256k1 ECDSA signatures, authorising a transfer of tokens
                   */
                  function processDepositsAndWithdrawals(bytes memory _proofData, uint256 _numTxs, bytes memory _signatures)
                      internal
                  {
                      uint256 sigIndex = 0x00;
                      uint256 proofDataPtr;
                      uint256 end;
                      assembly {
                          // add 0x20 to skip over 1st member of the bytes type (the length field).
                          // Also skip over the rollup header.
                          proofDataPtr := add(ROLLUP_HEADER_LENGTH, add(_proofData, 0x20))
                          // compute the position of proofDataPtr after we iterate through every transaction
                          end := add(proofDataPtr, mul(_numTxs, TX_PUBLIC_INPUT_LENGTH))
                      }
                      // This is a bit of a hot loop, we iterate over every tx to determine whether to process deposits or withdrawals.
                      while (proofDataPtr < end) {
                          // extract the minimum information we need to determine whether to skip this iteration
                          uint256 publicValue;
                          assembly {
                              publicValue := mload(add(proofDataPtr, 0xa0))
                          }
                          if (publicValue > 0) {
                              uint256 proofId;
                              uint256 assetId;
                              address publicOwner;
                              assembly {
                                  proofId := mload(proofDataPtr)
                                  assetId := mload(add(proofDataPtr, 0xe0))
                                  publicOwner := mload(add(proofDataPtr, 0xc0))
                              }
                              if (proofId == 1) {
                                  // validate user has approved deposit
                                  bytes32 digest;
                                  assembly {
                                      // compute the tx id to check if user has approved tx
                                      digest := keccak256(proofDataPtr, TX_PUBLIC_INPUT_LENGTH)
                                  }
                                  // check if there is an existing entry in depositProofApprovals
                                  // if there is, no further work required.
                                  // we don't need to clear `depositProofApprovals[publicOwner][digest]` because proofs cannot be re-used.
                                  // A single proof describes the creation of 2 output notes and the addition of 2 input note nullifiers
                                  // (both of these nullifiers can be categorised as "fake". They may not map to existing notes but are still inserted in the nullifier set)
                                  // Replaying the proof will fail to satisfy the rollup circuit's non-membership check on the input nullifiers.
                                  // We avoid resetting `depositProofApprovals` because that would cost additional gas post-London hard fork.
                                  if (!depositProofApprovals[publicOwner][digest]) {
                                      // extract and validate signature
                                      // we can create a bytes memory container for the signature without allocating new memory,
                                      // by overwriting the previous 32 bytes in the `signatures` array with the 'length' of our synthetic byte array (96)
                                      // we store the memory we overwrite in `temp`, so that we can restore it
                                      bytes memory signature;
                                      uint256 temp;
                                      assembly {
                                          // set `signature` to point to 32 bytes less than the desired `r, s, v` values in `signatures`
                                          signature := add(_signatures, sigIndex)
                                          // cache the memory we're about to overwrite
                                          temp := mload(signature)
                                          // write in a 96-byte 'length' parameter into the `signature` bytes array
                                          mstore(signature, 0x60)
                                      }
                                      bytes32 hashedMessage = RollupProcessorLibrary.getSignedMessageForTxId(digest);
                                      RollupProcessorLibrary.validateShieldSignatureUnpacked(hashedMessage, signature, publicOwner);
                                      // restore the memory we overwrote
                                      assembly {
                                          mstore(signature, temp)
                                          sigIndex := add(sigIndex, 0x60)
                                      }
                                  }
                                  decreasePendingDepositBalance(assetId, publicOwner, publicValue);
                              }
                              if (proofId == 2) {
                                  withdraw(publicValue, publicOwner, assetId);
                              }
                          }
                          // don't check for overflow, would take > 2^200 iterations of this loop for that to happen!
                          unchecked {
                              proofDataPtr += TX_PUBLIC_INPUT_LENGTH;
                          }
                      }
                  }
                  /**
                   * @notice A function which pulls tokens from a bridge
                   * @dev Calls `transferFrom` if asset is of type ERC20. If asset is ETH we validate a payment has been made
                   *      against the provided interaction nonce. This function is used by `processAsyncDefiInteraction`.
                   * @param _bridge address of bridge contract we're transferring tokens from
                   * @param _asset the AztecAsset being transferred
                   * @param _outputValue the expected value transferred
                   * @param _interactionNonce the defi interaction nonce of the interaction
                   */
                  function transferTokensAsync(
                      address _bridge,
                      AztecTypes.AztecAsset memory _asset,
                      uint256 _outputValue,
                      uint256 _interactionNonce
                  ) internal {
                      if (_outputValue == 0) {
                          return;
                      }
                      if (_asset.assetType == AztecTypes.AztecAssetType.ETH) {
                          if (_outputValue > ethPayments[_interactionNonce]) {
                              revert INSUFFICIENT_ETH_PAYMENT();
                          }
                          ethPayments[_interactionNonce] = 0;
                      } else if (_asset.assetType == AztecTypes.AztecAssetType.ERC20) {
                          address tokenAddress = _asset.erc20Address;
                          TokenTransfers.safeTransferFrom(tokenAddress, _bridge, address(this), _outputValue);
                      }
                  }
                  /**
                   * @notice A function which transfers fees to the `_feeReceiver`
                   * @dev Note: function will not revert if underlying transfers fails
                   * @param _proofData decoded rollup proof data
                   * @param _feeReceiver fee beneficiary as described by the rollup provider
                   */
                  function transferFee(bytes memory _proofData, address _feeReceiver) internal {
                      for (uint256 i = 0; i < NUMBER_OF_ASSETS;) {
                          uint256 txFee = extractTotalTxFee(_proofData, i);
                          if (txFee > 0) {
                              uint256 assetId = extractFeeAssetId(_proofData, i);
                              if (assetId == ETH_ASSET_ID) {
                                  // We explicitly do not throw if this call fails, as this opens up the possiblity of griefing
                                  // attacks --> engineering a failed fee would invalidate an entire rollup block. As griefing could
                                  // be done by consuming all gas in the `_feeReceiver` fallback only 50K gas is forwarded. We are
                                  // forwarding a bit more gas than in the withdraw function because this code will only be hit
                                  // at most once each rollup-block and we want to give the provider a bit more flexibility.
                                  assembly {
                                      pop(call(50000, _feeReceiver, txFee, 0, 0, 0, 0))
                                  }
                              } else {
                                  address assetAddress = getSupportedAsset(assetId);
                                  TokenTransfers.transferToDoNotBubbleErrors(
                                      assetAddress, _feeReceiver, txFee, assetGasLimits[assetId]
                                  );
                              }
                          }
                          unchecked {
                              ++i;
                          }
                      }
                  }
                  /**
                   * @notice Internal utility function which withdraws funds from the contract to a receiver address
                   * @param _withdrawValue - value being withdrawn from the contract
                   * @param _receiver - address receiving public ERC20 tokens
                   * @param _assetId - ID of the asset for which a withdrawal is being performed
                   * @dev The function doesn't throw if the inner call fails, as this opens up the possiblity of griefing attacks
                   *      -> engineering a failed withdrawal would invalidate an entire rollup block.
                   *      A griefing attack could be done by consuming all gas in the `_receiver` fallback and for this reason we
                   *      only forward 30K gas. This still allows the recipient to handle accounting if recipient is a contract.
                   *      The user should ensure their withdrawal will succeed or they will lose the funds.
                   */
                  function withdraw(uint256 _withdrawValue, address _receiver, uint256 _assetId) internal {
                      if (_receiver == address(0)) {
                          revert WITHDRAW_TO_ZERO_ADDRESS();
                      }
                      if (_assetId == 0) {
                          assembly {
                              pop(call(30000, _receiver, _withdrawValue, 0, 0, 0, 0))
                          }
                          // payable(_receiver).call{gas: 30000, value: _withdrawValue}('');
                      } else {
                          address assetAddress = getSupportedAsset(_assetId);
                          TokenTransfers.transferToDoNotBubbleErrors(
                              assetAddress, _receiver, _withdrawValue, assetGasLimits[_assetId]
                          );
                      }
                  }
                  /*----------------------------------------
                    PUBLIC/EXTERNAL NON-MUTATING FUNCTIONS 
                    ----------------------------------------*/
                  /**
                   * @notice Get implementation's version number
                   * @return version version number of the implementation
                   */
                  function getImplementationVersion() public view virtual returns (uint8 version) {
                      return 2;
                  }
                  /**
                   * @notice Get true if the contract is paused, false otherwise
                   * @return isPaused - True if paused, false otherwise
                   */
                  function paused() external view override (IRollupProcessor) returns (bool isPaused) {
                      return rollupState.paused;
                  }
                  /**
                   * @notice Gets the number of filled entries in the data tree
                   * @return dataSize number of filled entries in the data tree (equivalent to the number of notes created on L2)
                   */
                  function getDataSize() public view override (IRollupProcessor) returns (uint256 dataSize) {
                      return rollupState.datasize;
                  }
                  /**
                   * @notice Returns true if deposits are capped, false otherwise
                   * @return capped - True if deposits are capped, false otherwise
                   */
                  function getCapped() public view override (IRollupProcessorV2) returns (bool capped) {
                      return rollupState.capped;
                  }
                  /**
                   * @notice Gets the number of pending defi interactions that have resolved but have not yet been added into the
                   *         DeFi tree
                   * @return - the number of pending interactions
                   * @dev This value can never exceed 512. This limit is set in order to prevent griefing attacks - `processRollup`
                   *      iterates through `asyncDefiInteractionHashes` and copies their values into `defiInteractionHashes`. Loop
                   *      is bounded to < 512 so that tx does not exceed block gas limit.
                   */
                  function getPendingDefiInteractionHashesLength() public view override (IRollupProcessor) returns (uint256) {
                      return rollupState.numAsyncDefiInteractionHashes + rollupState.numDefiInteractionHashes;
                  }
                  /**
                   * @notice Gets the address of the PLONK verification smart contract
                   * @return - address of the verification smart contract
                   */
                  function verifier() public view override (IRollupProcessor) returns (address) {
                      return address(rollupState.verifier);
                  }
                  /**
                   * @notice Gets the number of supported bridges
                   * @return - the number of supported bridges
                   */
                  function getSupportedBridgesLength() external view override (IRollupProcessor) returns (uint256) {
                      return supportedBridges.length;
                  }
                  /**
                   * @notice Gets the bridge contract address for a given bridgeAddressId
                   * @param _bridgeAddressId identifier used to denote a particular bridge
                   * @return - the address of the matching bridge contract
                   */
                  function getSupportedBridge(uint256 _bridgeAddressId) public view override (IRollupProcessor) returns (address) {
                      return supportedBridges[_bridgeAddressId - 1];
                  }
                  /**
                   * @notice Gets the number of supported assets
                   * @return - the number of supported assets
                   */
                  function getSupportedAssetsLength() external view override (IRollupProcessor) returns (uint256) {
                      return supportedAssets.length;
                  }
                  /**
                   * @notice Gets the ERC20 token address of a supported asset for a given `_assetId`
                   * @param _assetId identifier used to denote a particular asset
                   * @return - the address of the matching asset
                   */
                  function getSupportedAsset(uint256 _assetId)
                      public
                      view
                      override (IRollupProcessor)
                      validateAssetIdIsNotVirtual(_assetId)
                      returns (address)
                  {
                      // If assetId == ETH_ASSET_ID (i.e. 0), this represents native ETH.
                      // ERC20 token asset id values start at 1
                      if (_assetId == ETH_ASSET_ID) {
                          return address(0x0);
                      }
                      address result = supportedAssets[_assetId - 1];
                      if (result == address(0)) {
                          revert INVALID_ASSET_ADDRESS();
                      }
                      return result;
                  }
                  /**
                   * @notice Gets the status of the escape hatch.
                   * @return True if escape hatch is open, false otherwise
                   * @return The number of blocks until the next opening/closing of escape hatch
                   */
                  function getEscapeHatchStatus() public view override (IRollupProcessor) returns (bool, uint256) {
                      uint256 blockNum = block.number;
                      bool isOpen = blockNum % escapeBlockUpperBound >= escapeBlockLowerBound;
                      uint256 blocksRemaining = 0;
                      if (isOpen) {
                          if (block.timestamp < uint256(lastRollupTimeStamp) + delayBeforeEscapeHatch) {
                              isOpen = false;
                          }
                          // num blocks escape hatch will remain open for
                          blocksRemaining = escapeBlockUpperBound - (blockNum % escapeBlockUpperBound);
                      } else {
                          // num blocks until escape hatch will be opened
                          blocksRemaining = escapeBlockLowerBound - (blockNum % escapeBlockUpperBound);
                      }
                      return (isOpen, blocksRemaining);
                  }
                  /**
                   * @notice Gets the number of defi interaction hashes
                   * @dev A defi interaction hash represents a defi interaction that has resolved, but whose
                   *      result data has not yet been added into the Aztec Defi Merkle tree. This step is needed in order to convert
                   *      L2 Defi claim notes into L2 value notes.
                   * @return - the number of pending defi interaction hashes
                   */
                  function getDefiInteractionHashesLength() public view override (IRollupProcessor) returns (uint256) {
                      return rollupState.numDefiInteractionHashes;
                  }
                  /**
                   * @notice Gets the number of asynchronous defi interaction hashes
                   * @dev A defi interaction hash represents an asynchronous defi interaction that has resolved, but whose interaction
                   *      result data has not yet been added into the Aztec Defi Merkle tree. This step is needed in order to convert
                   *      L2 Defi claim notes into L2 value notes.
                   * @return - the number of pending async defi interaction hashes
                   */
                  function getAsyncDefiInteractionHashesLength() public view override (IRollupProcessor) returns (uint256) {
                      return rollupState.numAsyncDefiInteractionHashes;
                  }
                  /*----------------------------------------
                    INTERNAL/PRIVATE NON-MUTATING FUNCTIONS
                    ----------------------------------------*/
                  /**
                   * @notice A function which constructs a FullBridgeCallData struct based on values from `_encodedBridgeCallData`
                   * @param _encodedBridgeCallData a bit-array that contains data describing a specific bridge call
                   *
                   * Structure of the bit array is as follows (starting at the least significant bit):
                   * | bit range | parameter       | description |
                   * | 0 - 32    | bridgeAddressId | The address ID. Bridge address = `supportedBridges[bridgeAddressId]` |
                   * | 32 - 62   | inputAssetIdA   | First input asset ID. |
                   * | 62 - 92   | inputAssetIdB   | Second input asset ID. Must be 0 if bridge does not have a 2nd input asset. |
                   * | 92 - 122  | outputAssetIdA  | First output asset ID. |
                   * | 122 - 152 | outputAssetIdB  | Second output asset ID. Must be 0 if bridge does not have a 2nd output asset. |
                   * | 152 - 184 | bitConfig       | Bit-array that contains boolean bridge settings. |
                   * | 184 - 248 | auxData         | 64 bits of custom data to be passed to the bridge contract. Structure of auxData
                   *                                 is defined/checked by the bridge contract. |
                   *
                   * Structure of the `bitConfig` parameter is as follows
                   * | bit | parameter               | description |
                   * | 0   | secondInputInUse        | Does the bridge have a second input asset? |
                   * | 1   | secondOutputInUse       | Does the bridge have a second output asset? |
                   *
                   * @dev Note: Virtual assets are assets that don't have an ERC20 token analogue and exist solely as notes within
                   *            the Aztec network. They can be created/spent within bridge calls. They are used to enable bridges
                   *            to track internally-defined data without having to mint a new token on-chain. An example use of
                   *            a virtual asset would be a virtual loan asset that tracks an outstanding debt that must be repaid
                   *            to recover a collateral deposited into the bridge.
                   *
                   * @return fullBridgeCallData a struct that contains information defining a specific bridge call
                   */
                  function getFullBridgeCallData(uint256 _encodedBridgeCallData)
                      internal
                      view
                      returns (FullBridgeCallData memory fullBridgeCallData)
                  {
                      assembly {
                          mstore(fullBridgeCallData, and(_encodedBridgeCallData, MASK_THIRTY_TWO_BITS)) // bridgeAddressId
                          mstore(
                              add(fullBridgeCallData, 0x40),
                              and(shr(INPUT_ASSET_ID_A_SHIFT, _encodedBridgeCallData), MASK_THIRTY_BITS)
                          ) // inputAssetIdA
                          mstore(
                              add(fullBridgeCallData, 0x60),
                              and(shr(INPUT_ASSET_ID_B_SHIFT, _encodedBridgeCallData), MASK_THIRTY_BITS)
                          ) // inputAssetIdB
                          mstore(
                              add(fullBridgeCallData, 0x80),
                              and(shr(OUTPUT_ASSET_ID_A_SHIFT, _encodedBridgeCallData), MASK_THIRTY_BITS)
                          ) // outputAssetIdA
                          mstore(
                              add(fullBridgeCallData, 0xa0),
                              and(shr(OUTPUT_ASSET_ID_B_SHIFT, _encodedBridgeCallData), MASK_THIRTY_BITS)
                          ) // outputAssetIdB
                          mstore(
                              add(fullBridgeCallData, 0xc0), and(shr(AUX_DATA_SHIFT, _encodedBridgeCallData), MASK_SIXTY_FOUR_BITS)
                          ) // auxData
                          mstore(
                              add(fullBridgeCallData, 0xe0),
                              and(shr(add(INPUT_ASSET_ID_A_SHIFT, VIRTUAL_ASSET_ID_FLAG_SHIFT), _encodedBridgeCallData), 1)
                          ) // firstInputVirtual (30th bit of inputAssetIdA) == 1
                          mstore(
                              add(fullBridgeCallData, 0x100),
                              and(shr(add(INPUT_ASSET_ID_B_SHIFT, VIRTUAL_ASSET_ID_FLAG_SHIFT), _encodedBridgeCallData), 1)
                          ) // secondInputVirtual (30th bit of inputAssetIdB) == 1
                          mstore(
                              add(fullBridgeCallData, 0x120),
                              and(shr(add(OUTPUT_ASSET_ID_A_SHIFT, VIRTUAL_ASSET_ID_FLAG_SHIFT), _encodedBridgeCallData), 1)
                          ) // firstOutputVirtual (30th bit of outputAssetIdA) == 1
                          mstore(
                              add(fullBridgeCallData, 0x140),
                              and(shr(add(OUTPUT_ASSET_ID_B_SHIFT, VIRTUAL_ASSET_ID_FLAG_SHIFT), _encodedBridgeCallData), 1)
                          ) // secondOutputVirtual (30th bit of outputAssetIdB) == 1
                          let bitConfig := and(shr(BITCONFIG_SHIFT, _encodedBridgeCallData), MASK_THIRTY_TWO_BITS)
                          // bitConfig = bit mask that contains bridge ID settings
                          // bit 0 = second input asset in use?
                          // bit 1 = second output asset in use?
                          mstore(add(fullBridgeCallData, 0x160), eq(and(bitConfig, 1), 1)) // secondInputInUse (bitConfig & 1) == 1
                          mstore(add(fullBridgeCallData, 0x180), eq(and(shr(1, bitConfig), 1), 1)) // secondOutputInUse ((bitConfig >> 1) & 1) == 1
                      }
                      fullBridgeCallData.bridgeAddress = supportedBridges[fullBridgeCallData.bridgeAddressId - 1];
                      fullBridgeCallData.bridgeGasLimit = bridgeGasLimits[fullBridgeCallData.bridgeAddressId];
                      // potential conflicting states that are explicitly ruled out by circuit constraints:
                      if (!fullBridgeCallData.secondInputInUse && fullBridgeCallData.inputAssetIdB > 0) {
                          revert INCONSISTENT_BRIDGE_CALL_DATA();
                      }
                      if (!fullBridgeCallData.secondOutputInUse && fullBridgeCallData.outputAssetIdB > 0) {
                          revert INCONSISTENT_BRIDGE_CALL_DATA();
                      }
                      if (
                          fullBridgeCallData.secondInputInUse
                              && (fullBridgeCallData.inputAssetIdA == fullBridgeCallData.inputAssetIdB)
                      ) {
                          revert BRIDGE_WITH_IDENTICAL_INPUT_ASSETS(fullBridgeCallData.inputAssetIdA);
                      }
                      // Outputs can both be virtual. In that case, their asset ids will both be 2 ** 29.
                      bool secondOutputReal = fullBridgeCallData.secondOutputInUse && !fullBridgeCallData.secondOutputVirtual;
                      if (secondOutputReal && fullBridgeCallData.outputAssetIdA == fullBridgeCallData.outputAssetIdB) {
                          revert BRIDGE_WITH_IDENTICAL_OUTPUT_ASSETS(fullBridgeCallData.outputAssetIdA);
                      }
                  }
                  /**
                   * @notice Gets the four input/output assets associated with a specific bridge call
                   * @param _fullBridgeCallData a struct that contains information defining a specific bridge call
                   * @param _interactionNonce interaction nonce of a corresponding bridge call
                   * @dev `_interactionNonce` param is here because it is used as an ID of output virtual asset
                   *
                   * @return inputAssetA the first input asset
                   * @return inputAssetB the second input asset
                   * @return outputAssetA the first output asset
                   * @return outputAssetB the second output asset
                   */
                  function getAztecAssetTypes(FullBridgeCallData memory _fullBridgeCallData, uint256 _interactionNonce)
                      internal
                      view
                      returns (
                          AztecTypes.AztecAsset memory inputAssetA,
                          AztecTypes.AztecAsset memory inputAssetB,
                          AztecTypes.AztecAsset memory outputAssetA,
                          AztecTypes.AztecAsset memory outputAssetB
                      )
                  {
                      if (_fullBridgeCallData.firstInputVirtual) {
                          // asset id is a nonce of the interaction in which the virtual asset was created
                          inputAssetA.id = _fullBridgeCallData.inputAssetIdA - VIRTUAL_ASSET_ID_FLAG;
                          inputAssetA.erc20Address = address(0x0);
                          inputAssetA.assetType = AztecTypes.AztecAssetType.VIRTUAL;
                      } else {
                          inputAssetA.id = _fullBridgeCallData.inputAssetIdA;
                          inputAssetA.erc20Address = getSupportedAsset(_fullBridgeCallData.inputAssetIdA);
                          inputAssetA.assetType = inputAssetA.erc20Address == address(0x0)
                              ? AztecTypes.AztecAssetType.ETH
                              : AztecTypes.AztecAssetType.ERC20;
                      }
                      if (_fullBridgeCallData.firstOutputVirtual) {
                          // use nonce as asset id.
                          outputAssetA.id = _interactionNonce;
                          outputAssetA.erc20Address = address(0x0);
                          outputAssetA.assetType = AztecTypes.AztecAssetType.VIRTUAL;
                      } else {
                          outputAssetA.id = _fullBridgeCallData.outputAssetIdA;
                          outputAssetA.erc20Address = getSupportedAsset(_fullBridgeCallData.outputAssetIdA);
                          outputAssetA.assetType = outputAssetA.erc20Address == address(0x0)
                              ? AztecTypes.AztecAssetType.ETH
                              : AztecTypes.AztecAssetType.ERC20;
                      }
                      if (_fullBridgeCallData.secondInputVirtual) {
                          // asset id is a nonce of the interaction in which the virtual asset was created
                          inputAssetB.id = _fullBridgeCallData.inputAssetIdB - VIRTUAL_ASSET_ID_FLAG;
                          inputAssetB.erc20Address = address(0x0);
                          inputAssetB.assetType = AztecTypes.AztecAssetType.VIRTUAL;
                      } else if (_fullBridgeCallData.secondInputInUse) {
                          inputAssetB.id = _fullBridgeCallData.inputAssetIdB;
                          inputAssetB.erc20Address = getSupportedAsset(_fullBridgeCallData.inputAssetIdB);
                          inputAssetB.assetType = inputAssetB.erc20Address == address(0x0)
                              ? AztecTypes.AztecAssetType.ETH
                              : AztecTypes.AztecAssetType.ERC20;
                      } else {
                          inputAssetB.id = 0;
                          inputAssetB.erc20Address = address(0x0);
                          inputAssetB.assetType = AztecTypes.AztecAssetType.NOT_USED;
                      }
                      if (_fullBridgeCallData.secondOutputVirtual) {
                          // use nonce as asset id.
                          outputAssetB.id = _interactionNonce;
                          outputAssetB.erc20Address = address(0x0);
                          outputAssetB.assetType = AztecTypes.AztecAssetType.VIRTUAL;
                      } else if (_fullBridgeCallData.secondOutputInUse) {
                          outputAssetB.id = _fullBridgeCallData.outputAssetIdB;
                          outputAssetB.erc20Address = getSupportedAsset(_fullBridgeCallData.outputAssetIdB);
                          outputAssetB.assetType = outputAssetB.erc20Address == address(0x0)
                              ? AztecTypes.AztecAssetType.ETH
                              : AztecTypes.AztecAssetType.ERC20;
                      } else {
                          outputAssetB.id = 0;
                          outputAssetB.erc20Address = address(0x0);
                          outputAssetB.assetType = AztecTypes.AztecAssetType.NOT_USED;
                      }
                  }
                  /**
                   * @notice Gets the length of the defi interaction hashes array and the number of pending interactions
                   *
                   * @return defiInteractionHashesLength the complete length of the defi interaction array
                   * @return numPendingInteractions the current number of pending defi interactions
                   * @dev `numPendingInteractions` is capped at `NUMBER_OF_BRIDGE_CALLS`
                   */
                  function getDefiHashesLengthsAndNumPendingInteractions()
                      internal
                      view
                      returns (uint256 defiInteractionHashesLength, uint256 numPendingInteractions)
                  {
                      assembly {
                          // retrieve the total length of the defi interactions array and also the number of pending interactions to a maximum of NUMBER_OF_BRIDGE_CALLS
                          let state := sload(rollupState.slot)
                          {
                              defiInteractionHashesLength := and(ARRAY_LENGTH_MASK, shr(DEFIINTERACTIONHASHES_BIT_OFFSET, state))
                              numPendingInteractions := defiInteractionHashesLength
                              if gt(numPendingInteractions, NUMBER_OF_BRIDGE_CALLS) {
                                  numPendingInteractions := NUMBER_OF_BRIDGE_CALLS
                              }
                          }
                      }
                  }
                  /**
                   * @notice Gets the set of hashes that comprise the current pending interactions and nextExpectedHash
                   *
                   * @return hashes the set of valid (i.e. non-zero) hashes that comprise the pending interactions
                   * @return nextExpectedHash the hash of all hashes (including zero hashes) that comprise the pending interactions
                   */
                  function getPendingAndNextExpectedHashes()
                      internal
                      view
                      returns (bytes32[] memory hashes, bytes32 nextExpectedHash)
                  {
                      /**
                       * ----------------------------------------
                       * Compute nextExpectedHash
                       * -----------------------------------------
                       *
                       * The `defiInteractionHashes` mapping emulates an array that represents the
                       * set of defi interactions from previous blocks that have been resolved.
                       *
                       * We need to take the interaction result data from each of the above defi interactions,
                       * and add that data into the Aztec L2 merkle tree that contains defi interaction results
                       * (the "Defi Tree". Its merkle root is one of the inputs to the storage variable `rollupStateHash`)
                       *
                       * It is the rollup provider's responsibility to perform these additions.
                       * In the current block being processed, the rollup provider must take these pending interaction results,
                       * create commitments to each result and insert each commitment into the next empty leaf of the defi tree.
                       *
                       * The following code validates that this has happened! This is how:
                       *
                       * Part 1: What are we checking?
                       *
                       * The rollup circuit will receive, as a private input from the rollup provider, the pending defi interaction
                       * results
                       * (`encodedBridgeCallData`, `totalInputValue`, `totalOutputValueA`, `totalOutputValueB`, `result`)
                       * The rollup circuit will compute the SHA256 hash of each interaction result (the defiInteractionHash)
                       * Finally the SHA256 hash of `NUMBER_OF_BRIDGE_CALLS` of these defiInteractionHash values is computed.
                       * (if there are fewer than `NUMBER_OF_BRIDGE_CALLS` pending defi interaction results, the SHA256 hash of
                       * an empty defi interaction result is used instead. i.e. all variable values are set to 0)
                       * The computed SHA256 hash, the `pendingDefiInteractionHash`, is one of the broadcasted values that forms
                       * the `publicInputsHash` public input to the rollup circuit.
                       * When verifying a rollup proof, this smart contract will compute `publicInputsHash` from the input calldata.
                       * The PLONK Verifier smart contract will then validate that our computed value for `publicInputHash` matches
                       * the value used when generating the rollup proof.
                       *
                       * TLDR of the above: our proof data contains a variable called `pendingDefiInteractionHash`, which is
                       * the CLAIMED VALUE of SHA256 hashing the SHA256 hashes of the defi interactions that have resolved but whose
                       * data has not yet been added into the defi tree.
                       *
                       * Part 2: How do we check `pendingDefiInteractionHash` is correct???
                       *
                       * This contract will call `DefiBridgeProxy.convert` (via delegatecall) on every new defi interaction present
                       * in the block. The return values from the bridge proxy contract are used to construct a defi interaction
                       * result. Its hash is then computed and stored in `defiInteractionHashes`.
                       *
                       * N.B. It's very important that DefiBridgeProxy does not call selfdestruct, or makes a delegatecall out to
                       *      a contract that can selfdestruct :o
                       *
                       * Similarly, when async defi interactions resolve, the interaction result is stored in
                       * `asyncDefiInteractionHashes`. At the end of the processBridgeCalls function, the contents of the async array
                       * is copied into `defiInteractionHashes` (i.e. async interaction results are delayed by 1 rollup block.
                       * This is to prevent griefing attacks where the rollup state changes between the time taken for a rollup tx
                       * to be constructed and the rollup tx to be mined)
                       *
                       * We use the contents of `defiInteractionHashes` to reconstruct `pendingDefiInteractionHash`, and validate it
                       * matches the value present in calldata and therefore the value used in the rollup circuit when this block's
                       * rollup proof was constructed. This validates that all of the required defi interaction results were added
                       * into the defi tree by the rollup provider (the circuit logic enforces this, we just need to check the rollup
                       * provider used the correct inputs)
                       */
                      (uint256 defiInteractionHashesLength, uint256 numPendingInteractions) =
                          getDefiHashesLengthsAndNumPendingInteractions();
                      uint256 offset = defiInteractionHashesLength - numPendingInteractions;
                      assembly {
                          // allocate the output array of hashes
                          hashes := mload(0x40)
                          let hashData := add(hashes, 0x20)
                          // update the free memory pointer to point past the end of our array
                          // our array will consume 32 bytes for the length field plus NUMBER_OF_BRIDGE_BYTES for all of the hashes
                          mstore(0x40, add(hashes, add(NUMBER_OF_BRIDGE_BYTES, 0x20)))
                          // set the length of hashes to only include the non-zero hash values
                          // although this function will write all of the hashes into our allocated memory, we only want to return the non-zero hashes
                          mstore(hashes, numPendingInteractions)
                          // Prepare the reusable part of the defi interaction hashes slot computation
                          mstore(0x20, defiInteractionHashes.slot)
                          let i := 0
                          // Iterate over numPendingInteractions (will be between 0 and NUMBER_OF_BRIDGE_CALLS)
                          // Load defiInteractionHashes[offset + i] and store in memory
                          // in order to compute SHA2 hash (nextExpectedHash)
                          for {} lt(i, numPendingInteractions) { i := add(i, 0x01) } {
                              // hashData[i] = defiInteractionHashes[offset + i]
                              mstore(0x00, add(offset, i))
                              mstore(add(hashData, mul(i, 0x20)), sload(keccak256(0x00, 0x40)))
                          }
                          // If numPendingInteractions < NUMBER_OF_BRIDGE_CALLS, continue iterating up to NUMBER_OF_BRIDGE_CALLS, this time
                          // inserting the "zero hash", the result of sha256(emptyDefiInteractionResult)
                          for {} lt(i, NUMBER_OF_BRIDGE_CALLS) { i := add(i, 0x01) } {
                              // hashData[i] = DEFI_RESULT_ZERO_HASH
                              mstore(add(hashData, mul(i, 0x20)), DEFI_RESULT_ZERO_HASH)
                          }
                          pop(staticcall(gas(), 0x2, hashData, NUMBER_OF_BRIDGE_BYTES, 0x00, 0x20))
                          nextExpectedHash := mod(mload(0x00), CIRCUIT_MODULUS)
                      }
                  }
                  /**
                   * @notice A function that processes bridge calls.
                   * @dev 1. pop NUMBER_OF_BRIDGE_CALLS (if available) interaction hashes off of `defiInteractionHashes`,
                   *         validate their hash (calculated at the end of the previous rollup and stored as
                   *         nextExpectedDefiInteractionsHash) equals `numPendingInteractions` (this validates that rollup block
                   *         has added these interaction results into the L2 data tree)
                   *      2. iterate over rollup block's new defi interactions (up to NUMBER_OF_BRIDGE_CALLS). Trigger interactions
                   *         by calling DefiBridgeProxy contract. Record results in either `defiInteractionHashes` (for synchrohnous
                   *         txns) or, for async txns, the `pendingDefiInteractions` mapping
                   *      3. copy the contents of `asyncInteractionHashes` into `defiInteractionHashes` && clear
                   *         `asyncInteractionHashes`
                   *      4. calculate the next value of nextExpectedDefiInteractionsHash from the new set of defiInteractionHashes
                   * @param _proofData decoded rollup proof data
                   * @param _rollupBeneficiary the address that should be paid any subsidy for processing a bridge call
                   * @return nextExpectedHashes the set of non-zero hashes that comprise the current pending defi interactions
                   */
                  function processBridgeCalls(bytes memory _proofData, address _rollupBeneficiary)
                      internal
                      returns (bytes32[] memory nextExpectedHashes)
                  {
                      uint256 defiInteractionHashesLength;
                      // Verify that nextExpectedDefiInteractionsHash equals the value given in the rollup
                      // Then remove the set of pending hashes
                      {
                          // Extract the claimed value of previousDefiInteractionHash present in the proof data
                          bytes32 providedDefiInteractionsHash = extractPrevDefiInteractionHash(_proofData);
                          // Validate the stored interactionHash matches the value used when making the rollup proof!
                          if (providedDefiInteractionsHash != prevDefiInteractionsHash) {
                              revert INCORRECT_PREVIOUS_DEFI_INTERACTION_HASH(providedDefiInteractionsHash, prevDefiInteractionsHash);
                          }
                          uint256 numPendingInteractions;
                          (defiInteractionHashesLength, numPendingInteractions) = getDefiHashesLengthsAndNumPendingInteractions();
                          // numPendingInteraction equals the number of interactions expected to be in the given rollup
                          // this is the length of the defiInteractionHashes array, capped at the NUM_BRIDGE_CALLS as per the following
                          // numPendingInteractions = min(defiInteractionsHashesLength, numberOfBridgeCalls)
                          // Reduce DefiInteractionHashes.length by numPendingInteractions
                          defiInteractionHashesLength -= numPendingInteractions;
                          assembly {
                              // Update DefiInteractionHashes.length in storage
                              let state := sload(rollupState.slot)
                              let oldState := and(not(shl(DEFIINTERACTIONHASHES_BIT_OFFSET, ARRAY_LENGTH_MASK)), state)
                              let newState := or(oldState, shl(DEFIINTERACTIONHASHES_BIT_OFFSET, defiInteractionHashesLength))
                              sstore(rollupState.slot, newState)
                          }
                      }
                      uint256 interactionNonce = getRollupId(_proofData) * NUMBER_OF_BRIDGE_CALLS;
                      // ### Process bridge calls
                      uint256 proofDataPtr;
                      assembly {
                          proofDataPtr := add(_proofData, BRIDGE_CALL_DATAS_OFFSET)
                      }
                      BridgeResult memory bridgeResult;
                      assembly {
                          bridgeResult := mload(0x40)
                          mstore(0x40, add(bridgeResult, 0x80))
                      }
                      for (uint256 i = 0; i < NUMBER_OF_BRIDGE_CALLS;) {
                          uint256 encodedBridgeCallData;
                          assembly {
                              encodedBridgeCallData := mload(proofDataPtr)
                          }
                          if (encodedBridgeCallData == 0) {
                              // no more bridges to call
                              break;
                          }
                          uint256 totalInputValue;
                          assembly {
                              totalInputValue := mload(add(proofDataPtr, mul(0x20, NUMBER_OF_BRIDGE_CALLS)))
                          }
                          if (totalInputValue == 0) {
                              revert ZERO_TOTAL_INPUT_VALUE();
                          }
                          FullBridgeCallData memory fullBridgeCallData = getFullBridgeCallData(encodedBridgeCallData);
                          (
                              AztecTypes.AztecAsset memory inputAssetA,
                              AztecTypes.AztecAsset memory inputAssetB,
                              AztecTypes.AztecAsset memory outputAssetA,
                              AztecTypes.AztecAsset memory outputAssetB
                          ) = getAztecAssetTypes(fullBridgeCallData, interactionNonce);
                          assembly {
                              // call the following function of DefiBridgeProxy via delegatecall...
                              //     function convert(
                              //          address bridgeAddress,
                              //          AztecTypes.AztecAsset calldata inputAssetA,
                              //          AztecTypes.AztecAsset calldata inputAssetB,
                              //          AztecTypes.AztecAsset calldata outputAssetA,
                              //          AztecTypes.AztecAsset calldata outputAssetB,
                              //          uint256 totalInputValue,
                              //          uint256 interactionNonce,
                              //          uint256 auxInputData,
                              //          uint256 ethPaymentsSlot,
                              //          address rollupBeneficary
                              //     )
                              // Construct the calldata we send to DefiBridgeProxy
                              // mPtr = memory pointer. Set to free memory location (0x40)
                              let mPtr := mload(0x40)
                              // first 4 bytes is the function signature
                              mstore(mPtr, DEFI_BRIDGE_PROXY_CONVERT_SELECTOR)
                              mPtr := add(mPtr, 0x04)
                              let bridgeAddress := mload(add(fullBridgeCallData, 0x20))
                              mstore(mPtr, bridgeAddress)
                              mstore(add(mPtr, 0x20), mload(inputAssetA))
                              mstore(add(mPtr, 0x40), mload(add(inputAssetA, 0x20)))
                              mstore(add(mPtr, 0x60), mload(add(inputAssetA, 0x40)))
                              mstore(add(mPtr, 0x80), mload(inputAssetB))
                              mstore(add(mPtr, 0xa0), mload(add(inputAssetB, 0x20)))
                              mstore(add(mPtr, 0xc0), mload(add(inputAssetB, 0x40)))
                              mstore(add(mPtr, 0xe0), mload(outputAssetA))
                              mstore(add(mPtr, 0x100), mload(add(outputAssetA, 0x20)))
                              mstore(add(mPtr, 0x120), mload(add(outputAssetA, 0x40)))
                              mstore(add(mPtr, 0x140), mload(outputAssetB))
                              mstore(add(mPtr, 0x160), mload(add(outputAssetB, 0x20)))
                              mstore(add(mPtr, 0x180), mload(add(outputAssetB, 0x40)))
                              mstore(add(mPtr, 0x1a0), totalInputValue)
                              mstore(add(mPtr, 0x1c0), interactionNonce)
                              let auxData := mload(add(fullBridgeCallData, 0xc0))
                              mstore(add(mPtr, 0x1e0), auxData)
                              mstore(add(mPtr, 0x200), ethPayments.slot)
                              mstore(add(mPtr, 0x220), _rollupBeneficiary)
                              // Call the bridge proxy via delegatecall!
                              // We want the proxy to share state with the rollup processor, as the proxy is the entity
                              // sending/recovering tokens from the bridge contracts. We wrap this logic in a delegatecall so that
                              // if the call fails (i.e. the bridge interaction fails), we can unwind bridge-interaction specific
                              // state changes without reverting the entire transaction.
                              let bridgeProxy := sload(defiBridgeProxy.slot)
                              if iszero(extcodesize(bridgeProxy)) {
                                  mstore(0, INVALID_ADDRESS_NO_CODE_SELECTOR)
                                  revert(0, 0x4)
                              }
                              let success :=
                                  delegatecall(
                                      mload(add(fullBridgeCallData, 0x1a0)), // fullBridgeCallData.bridgeGasLimit
                                      bridgeProxy,
                                      sub(mPtr, 0x04),
                                      0x244,
                                      0,
                                      0
                                  )
                              returndatacopy(mPtr, 0, returndatasize())
                              switch success
                              case 1 {
                                  mstore(bridgeResult, mload(mPtr)) // outputValueA
                                  mstore(add(bridgeResult, 0x20), mload(add(mPtr, 0x20))) // outputValueB
                                  mstore(add(bridgeResult, 0x40), mload(add(mPtr, 0x40))) // isAsync
                                  mstore(add(bridgeResult, 0x60), 1) // success
                              }
                              default {
                                  // If the call failed, mark this interaction as failed. No tokens have been exchanged, users can
                                  // use the "claim" circuit to recover the initial tokens they sent to the bridge
                                  mstore(bridgeResult, 0) // outputValueA
                                  mstore(add(bridgeResult, 0x20), 0) // outputValueB
                                  mstore(add(bridgeResult, 0x40), 0) // isAsync
                                  mstore(add(bridgeResult, 0x60), 0) // success
                              }
                          }
                          if (!fullBridgeCallData.secondOutputInUse) {
                              bridgeResult.outputValueB = 0;
                          }
                          // emit events and update state
                          assembly {
                              // if interaction is Async, update pendingDefiInteractions
                              // if interaction is synchronous, compute the interaction hash and add to defiInteractionHashes
                              switch mload(add(bridgeResult, 0x40))
                              // switch isAsync
                              case 1 {
                                  let mPtr := mload(0x40)
                                  // emit AsyncDefiBridgeProcessed(indexed encodedBridgeCallData, indexed interactionNonce, totalInputValue)
                                  {
                                      mstore(mPtr, totalInputValue)
                                      log3(mPtr, 0x20, ASYNC_BRIDGE_PROCESSED_SIGHASH, encodedBridgeCallData, interactionNonce)
                                  }
                                  // pendingDefiInteractions[interactionNonce] = PendingDefiBridgeInteraction(encodedBridgeCallData, totalInputValue)
                                  mstore(0x00, interactionNonce)
                                  mstore(0x20, pendingDefiInteractions.slot)
                                  let pendingDefiInteractionsSlotBase := keccak256(0x00, 0x40)
                                  sstore(pendingDefiInteractionsSlotBase, encodedBridgeCallData)
                                  sstore(add(pendingDefiInteractionsSlotBase, 0x01), totalInputValue)
                              }
                              default {
                                  let mPtr := mload(0x40)
                                  // prepare the data required to publish the DefiBridgeProcessed event, we will only publish it if
                                  // isAsync == false
                                  // async interactions that have failed, have their isAsync property modified to false above
                                  // emit DefiBridgeProcessed(indexed encodedBridgeCallData, indexed interactionNonce, totalInputValue, outputValueA, outputValueB, success)
                                  {
                                      mstore(mPtr, totalInputValue)
                                      mstore(add(mPtr, 0x20), mload(bridgeResult)) // outputValueA
                                      mstore(add(mPtr, 0x40), mload(add(bridgeResult, 0x20))) // outputValueB
                                      mstore(add(mPtr, 0x60), mload(add(bridgeResult, 0x60))) // success
                                      mstore(add(mPtr, 0x80), 0xa0) // position in event data block of `bytes` object
                                      if mload(add(bridgeResult, 0x60)) {
                                          mstore(add(mPtr, 0xa0), 0)
                                          log3(mPtr, 0xc0, DEFI_BRIDGE_PROCESSED_SIGHASH, encodedBridgeCallData, interactionNonce)
                                      }
                                      if iszero(mload(add(bridgeResult, 0x60))) {
                                          mstore(add(mPtr, 0xa0), returndatasize())
                                          let size := returndatasize()
                                          let remainder := mul(iszero(iszero(size)), sub(32, mod(size, 32)))
                                          returndatacopy(add(mPtr, 0xc0), 0, size)
                                          mstore(add(mPtr, add(0xc0, size)), 0)
                                          log3(
                                              mPtr,
                                              add(0xc0, add(size, remainder)),
                                              DEFI_BRIDGE_PROCESSED_SIGHASH,
                                              encodedBridgeCallData,
                                              interactionNonce
                                          )
                                      }
                                  }
                                  // compute defiInteractionnHash
                                  mstore(mPtr, encodedBridgeCallData)
                                  mstore(add(mPtr, 0x20), interactionNonce)
                                  mstore(add(mPtr, 0x40), totalInputValue)
                                  mstore(add(mPtr, 0x60), mload(bridgeResult)) // outputValueA
                                  mstore(add(mPtr, 0x80), mload(add(bridgeResult, 0x20))) // outputValueB
                                  mstore(add(mPtr, 0xa0), mload(add(bridgeResult, 0x60))) // success
                                  pop(staticcall(gas(), 0x2, mPtr, 0xc0, 0x00, 0x20))
                                  let defiInteractionHash := mod(mload(0x00), CIRCUIT_MODULUS)
                                  // defiInteractionHashes[defiInteractionHashesLength] = defiInteractionHash;
                                  mstore(0x00, defiInteractionHashesLength)
                                  mstore(0x20, defiInteractionHashes.slot)
                                  sstore(keccak256(0x00, 0x40), defiInteractionHash)
                                  // Increase the length of defiInteractionHashes by 1
                                  defiInteractionHashesLength := add(defiInteractionHashesLength, 0x01)
                              }
                              // advance interactionNonce and proofDataPtr
                              interactionNonce := add(interactionNonce, 0x01)
                              proofDataPtr := add(proofDataPtr, 0x20)
                          }
                          unchecked {
                              ++i;
                          }
                      }
                      assembly {
                          /**
                           * Cleanup
                           *
                           * 1. Copy asyncDefiInteractionHashes into defiInteractionHashes
                           * 2. Update defiInteractionHashes.length
                           * 2. Clear asyncDefiInteractionHashes.length
                           */
                          let state := sload(rollupState.slot)
                          let asyncDefiInteractionHashesLength :=
                              and(ARRAY_LENGTH_MASK, shr(ASYNCDEFIINTERACTIONHASHES_BIT_OFFSET, state))
                          // Validate we are not overflowing our 1024 array size
                          let arrayOverflow :=
                              gt(add(asyncDefiInteractionHashesLength, defiInteractionHashesLength), ARRAY_LENGTH_MASK)
                          // Throw an error if defiInteractionHashesLength > ARRAY_LENGTH_MASK (i.e. is >= 1024)
                          // should never hit this! If block `i` generates synchronous txns,
                          // block 'i + 1' must process them.
                          // Only way this array size hits 1024 is if we produce a glut of async interaction results
                          // between blocks. HOWEVER we ensure that async interaction callbacks fail if they would increase
                          // defiInteractionHashes length to be >= 512
                          // Still, can't hurt to check...
                          if arrayOverflow {
                              mstore(0, ARRAY_OVERFLOW_SELECTOR)
                              revert(0, 0x4)
                          }
                          // Now, copy async hashes into defiInteractionHashes
                          // Cache the free memory pointer
                          let freePtr := mload(0x40)
                          // Prepare the reusable parts of slot computation
                          mstore(0x20, defiInteractionHashes.slot)
                          mstore(0x60, asyncDefiInteractionHashes.slot)
                          for { let i := 0 } lt(i, asyncDefiInteractionHashesLength) { i := add(i, 1) } {
                              // defiInteractionHashesLength[defiInteractionHashesLength + i] = asyncDefiInteractionHashes[i]
                              mstore(0x00, add(defiInteractionHashesLength, i))
                              mstore(0x40, i)
                              sstore(keccak256(0x00, 0x40), sload(keccak256(0x40, 0x40)))
                          }
                          // Restore the free memory pointer
                          mstore(0x40, freePtr)
                          // clear defiInteractionHashesLength in state
                          state := and(not(shl(DEFIINTERACTIONHASHES_BIT_OFFSET, ARRAY_LENGTH_MASK)), state)
                          // write new defiInteractionHashesLength in state
                          state :=
                              or(
                                  shl(
                                      DEFIINTERACTIONHASHES_BIT_OFFSET, add(asyncDefiInteractionHashesLength, defiInteractionHashesLength)
                                  ),
                                  state
                              )
                          // clear asyncDefiInteractionHashesLength in state
                          state := and(not(shl(ASYNCDEFIINTERACTIONHASHES_BIT_OFFSET, ARRAY_LENGTH_MASK)), state)
                          // write new state
                          sstore(rollupState.slot, state)
                      }
                      // now we want to extract the next set of pending defi interaction hashes and calculate their hash to store
                      // for the next rollup
                      (bytes32[] memory hashes, bytes32 nextExpectedHash) = getPendingAndNextExpectedHashes();
                      nextExpectedHashes = hashes;
                      prevDefiInteractionsHash = nextExpectedHash;
                  }
              }
              

              File 10 of 12: Verifier28x32
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              interface IVerifier {
                  function verify(bytes memory _serializedProof, uint256 _publicInputsHash) external returns (bool);
                  function getVerificationKeyHash() external pure returns (bytes32);
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              // gas cost at 5000 optimizer runs 0.8.10: 287,589 (includes 21,000 base cost)
              import {IVerifier} from "../interfaces/IVerifier.sol";
              /**
               * @title Standard Plonk proof verification contract
               * @dev Top level Plonk proof verification contract, which allows Plonk proof to be verified
               */
              abstract contract BaseStandardVerifier is IVerifier {
                  // VERIFICATION KEY MEMORY LOCATIONS
                  uint256 internal constant N_LOC = 0x200 + 0x00;
                  uint256 internal constant NUM_INPUTS_LOC = 0x200 + 0x20;
                  uint256 internal constant OMEGA_LOC = 0x200 + 0x40;
                  uint256 internal constant DOMAIN_INVERSE_LOC = 0x200 + 0x60;
                  uint256 internal constant Q1_X_LOC = 0x200 + 0x80;
                  uint256 internal constant Q1_Y_LOC = 0x200 + 0xa0;
                  uint256 internal constant Q2_X_LOC = 0x200 + 0xc0;
                  uint256 internal constant Q2_Y_LOC = 0x200 + 0xe0;
                  uint256 internal constant Q3_X_LOC = 0x200 + 0x100;
                  uint256 internal constant Q3_Y_LOC = 0x200 + 0x120;
                  uint256 internal constant QM_X_LOC = 0x200 + 0x140;
                  uint256 internal constant QM_Y_LOC = 0x200 + 0x160;
                  uint256 internal constant QC_X_LOC = 0x200 + 0x180;
                  uint256 internal constant QC_Y_LOC = 0x200 + 0x1a0;
                  uint256 internal constant SIGMA1_X_LOC = 0x200 + 0x1c0;
                  uint256 internal constant SIGMA1_Y_LOC = 0x200 + 0x1e0;
                  uint256 internal constant SIGMA2_X_LOC = 0x200 + 0x200;
                  uint256 internal constant SIGMA2_Y_LOC = 0x200 + 0x220;
                  uint256 internal constant SIGMA3_X_LOC = 0x200 + 0x240;
                  uint256 internal constant SIGMA3_Y_LOC = 0x200 + 0x260;
                  uint256 internal constant CONTAINS_RECURSIVE_PROOF_LOC = 0x200 + 0x280;
                  uint256 internal constant RECURSIVE_PROOF_PUBLIC_INPUT_INDICES_LOC = 0x200 + 0x2a0;
                  uint256 internal constant G2X_X0_LOC = 0x200 + 0x2c0;
                  uint256 internal constant G2X_X1_LOC = 0x200 + 0x2e0;
                  uint256 internal constant G2X_Y0_LOC = 0x200 + 0x300;
                  uint256 internal constant G2X_Y1_LOC = 0x200 + 0x320;
                  // 26
                  // ### PROOF DATA MEMORY LOCATIONS
                  uint256 internal constant W1_X_LOC = 0x200 + 0x340 + 0x00;
                  uint256 internal constant W1_Y_LOC = 0x200 + 0x340 + 0x20;
                  uint256 internal constant W2_X_LOC = 0x200 + 0x340 + 0x40;
                  uint256 internal constant W2_Y_LOC = 0x200 + 0x340 + 0x60;
                  uint256 internal constant W3_X_LOC = 0x200 + 0x340 + 0x80;
                  uint256 internal constant W3_Y_LOC = 0x200 + 0x340 + 0xa0;
                  uint256 internal constant Z_X_LOC = 0x200 + 0x340 + 0xc0;
                  uint256 internal constant Z_Y_LOC = 0x200 + 0x340 + 0xe0;
                  uint256 internal constant T1_X_LOC = 0x200 + 0x340 + 0x100;
                  uint256 internal constant T1_Y_LOC = 0x200 + 0x340 + 0x120;
                  uint256 internal constant T2_X_LOC = 0x200 + 0x340 + 0x140;
                  uint256 internal constant T2_Y_LOC = 0x200 + 0x340 + 0x160;
                  uint256 internal constant T3_X_LOC = 0x200 + 0x340 + 0x180;
                  uint256 internal constant T3_Y_LOC = 0x200 + 0x340 + 0x1a0;
                  uint256 internal constant W1_EVAL_LOC = 0x200 + 0x340 + 0x1c0;
                  uint256 internal constant W2_EVAL_LOC = 0x200 + 0x340 + 0x1e0;
                  uint256 internal constant W3_EVAL_LOC = 0x200 + 0x340 + 0x200;
                  uint256 internal constant SIGMA1_EVAL_LOC = 0x200 + 0x340 + 0x220;
                  uint256 internal constant SIGMA2_EVAL_LOC = 0x200 + 0x340 + 0x240;
                  uint256 internal constant Z_OMEGA_EVAL_LOC = 0x200 + 0x340 + 0x260;
                  uint256 internal constant PI_Z_X_LOC = 0x200 + 0x340 + 0x280;
                  uint256 internal constant PI_Z_Y_LOC = 0x200 + 0x340 + 0x2a0;
                  uint256 internal constant PI_Z_OMEGA_X_LOC = 0x200 + 0x340 + 0x2c0;
                  uint256 internal constant PI_Z_OMEGA_Y_LOC = 0x200 + 0x340 + 0x2e0;
                  // 24
                  // ### CHALLENGES MEMORY OFFSETS
                  uint256 internal constant C_BETA_LOC = 0x200 + 0x340 + 0x300 + 0x00;
                  uint256 internal constant C_GAMMA_LOC = 0x200 + 0x340 + 0x300 + 0x20;
                  uint256 internal constant C_ALPHA_LOC = 0x200 + 0x340 + 0x300 + 0x40;
                  uint256 internal constant C_ARITHMETIC_ALPHA_LOC = 0x200 + 0x340 + 0x300 + 0x60;
                  uint256 internal constant C_ZETA_LOC = 0x200 + 0x340 + 0x300 + 0x80;
                  uint256 internal constant C_CURRENT_LOC = 0x200 + 0x340 + 0x300 + 0xa0;
                  uint256 internal constant C_V0_LOC = 0x200 + 0x340 + 0x300 + 0xc0;
                  uint256 internal constant C_V1_LOC = 0x200 + 0x340 + 0x300 + 0xe0;
                  uint256 internal constant C_V2_LOC = 0x200 + 0x340 + 0x300 + 0x100;
                  uint256 internal constant C_V3_LOC = 0x200 + 0x340 + 0x300 + 0x120;
                  uint256 internal constant C_V4_LOC = 0x200 + 0x340 + 0x300 + 0x140;
                  uint256 internal constant C_V5_LOC = 0x200 + 0x340 + 0x300 + 0x160;
                  uint256 internal constant C_U_LOC = 0x200 + 0x340 + 0x300 + 0x180;
                  // 13
                  // ### LOCAL VARIABLES MEMORY OFFSETS
                  uint256 internal constant DELTA_NUMERATOR_LOC = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x00;
                  uint256 internal constant DELTA_DENOMINATOR_LOC = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x20;
                  uint256 internal constant ZETA_POW_N_LOC = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x40;
                  uint256 internal constant PUBLIC_INPUT_DELTA_LOC = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x60;
                  uint256 internal constant ZERO_POLY_LOC = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x80;
                  uint256 internal constant L_START_LOC = 0x200 + 0x340 + 0x300 + 0x1a0 + 0xa0;
                  uint256 internal constant L_END_LOC = 0x200 + 0x340 + 0x300 + 0x1a0 + 0xc0;
                  uint256 internal constant R_ZERO_EVAL_LOC = 0x200 + 0x340 + 0x300 + 0x1a0 + 0xe0;
                  uint256 internal constant ACCUMULATOR_X_LOC = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x100;
                  uint256 internal constant ACCUMULATOR_Y_LOC = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x120;
                  uint256 internal constant ACCUMULATOR2_X_LOC = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x140;
                  uint256 internal constant ACCUMULATOR2_Y_LOC = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x160;
                  uint256 internal constant PAIRING_LHS_X_LOC = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x180;
                  uint256 internal constant PAIRING_LHS_Y_LOC = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x1a0;
                  uint256 internal constant PAIRING_RHS_X_LOC = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x1c0;
                  uint256 internal constant PAIRING_RHS_Y_LOC = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x1e0;
                  // 16
                  // ### SUCCESS FLAG MEMORY LOCATIONS
                  uint256 internal constant GRAND_PRODUCT_SUCCESS_FLAG = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x200 + 0x00;
                  uint256 internal constant ARITHMETIC_TERM_SUCCESS_FLAG = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x200 + 0x20;
                  uint256 internal constant BATCH_OPENING_SUCCESS_FLAG = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x200 + 0x40;
                  uint256 internal constant OPENING_COMMITMENT_SUCCESS_FLAG = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x200 + 0x60;
                  uint256 internal constant PAIRING_PREAMBLE_SUCCESS_FLAG = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x200 + 0x80;
                  uint256 internal constant PAIRING_SUCCESS_FLAG = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x200 + 0xa0;
                  uint256 internal constant RESULT_FLAG = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x200 + 0xc0;
                  // 7
                  // misc stuff
                  uint256 internal constant OMEGA_INVERSE_LOC = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x200 + 0xe0;
                  uint256 internal constant C_ALPHA_SQR_LOC = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x200 + 0xe0 + 0x20;
                  // 2
                  // ### RECURSION VARIABLE MEMORY LOCATIONS
                  uint256 internal constant RECURSIVE_P1_X_LOC = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x200 + 0xe0 + 0x40;
                  uint256 internal constant RECURSIVE_P1_Y_LOC = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x200 + 0xe0 + 0x60;
                  uint256 internal constant RECURSIVE_P2_X_LOC = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x200 + 0xe0 + 0x80;
                  uint256 internal constant RECURSIVE_P2_Y_LOC = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x200 + 0xe0 + 0xa0;
                  uint256 internal constant PUBLIC_INPUTS_HASH_LOCATION = 0x200 + 0x340 + 0x300 + 0x1a0 + 0x200 + 0xe0 + 0xc0;
                  bytes4 internal constant PUBLIC_INPUT_INVALID_BN128_G1_POINT_SELECTOR = 0xeba9f4a6;
                  bytes4 internal constant PUBLIC_INPUT_GE_P_SELECTOR = 0x374a972f;
                  bytes4 internal constant MOD_EXP_FAILURE_SELECTOR = 0xf894a7bc;
                  bytes4 internal constant EC_SCALAR_MUL_FAILURE_SELECTOR = 0xf755f369;
                  bytes4 internal constant PROOF_FAILURE_SELECTOR = 0x0711fcec;
                  error PUBLIC_INPUTS_HASH_VERIFICATION_FAILED(uint256, uint256);
                  error PUBLIC_INPUT_INVALID_BN128_G1_POINT();
                  error PUBLIC_INPUT_GE_P();
                  error MOD_EXP_FAILURE();
                  error EC_SCALAR_MUL_FAILURE();
                  error PROOF_FAILURE();
                  function getVerificationKeyHash() public pure virtual override (IVerifier) returns (bytes32);
                  function loadVerificationKey(uint256 vk, uint256 _omegaInverseLoc) internal pure virtual;
                  /**
                   * @dev Verify a Plonk proof
                   * @param - array of serialized proof data
                   * @param - public input hash as computed from the broadcast data
                   * @return True if proof is valid, reverts otherwise
                   */
                  function verify(bytes calldata, uint256 public_inputs_hash) external view override (IVerifier) returns (bool) {
                      // validate the correctness of the public inputs hash
                      {
                          bool hash_matches_input;
                          uint256 recovered_hash;
                          assembly {
                              recovered_hash := calldataload(add(calldataload(0x04), 0x24))
                              hash_matches_input := eq(recovered_hash, public_inputs_hash)
                          }
                          if (!hash_matches_input) {
                              revert PUBLIC_INPUTS_HASH_VERIFICATION_FAILED(public_inputs_hash, recovered_hash);
                          }
                      }
                      loadVerificationKey(N_LOC, OMEGA_INVERSE_LOC);
                      assembly {
                          let q := 21888242871839275222246405745257275088696311157297823662689037894645226208583 // EC group order
                          let p := 21888242871839275222246405745257275088548364400416034343698204186575808495617 // Prime field order
                          /**
                           * LOAD PROOF FROM CALLDATA
                           */
                          {
                              let data_ptr := add(calldataload(0x04), 0x24)
                              if mload(CONTAINS_RECURSIVE_PROOF_LOC) {
                                  let index_counter := add(mul(mload(RECURSIVE_PROOF_PUBLIC_INPUT_INDICES_LOC), 32), data_ptr)
                                  let x0 := calldataload(index_counter)
                                  x0 := add(x0, shl(68, calldataload(add(index_counter, 0x20))))
                                  x0 := add(x0, shl(136, calldataload(add(index_counter, 0x40))))
                                  x0 := add(x0, shl(204, calldataload(add(index_counter, 0x60))))
                                  let y0 := calldataload(add(index_counter, 0x80))
                                  y0 := add(y0, shl(68, calldataload(add(index_counter, 0xa0))))
                                  y0 := add(y0, shl(136, calldataload(add(index_counter, 0xc0))))
                                  y0 := add(y0, shl(204, calldataload(add(index_counter, 0xe0))))
                                  let x1 := calldataload(add(index_counter, 0x100))
                                  x1 := add(x1, shl(68, calldataload(add(index_counter, 0x120))))
                                  x1 := add(x1, shl(136, calldataload(add(index_counter, 0x140))))
                                  x1 := add(x1, shl(204, calldataload(add(index_counter, 0x160))))
                                  let y1 := calldataload(add(index_counter, 0x180))
                                  y1 := add(y1, shl(68, calldataload(add(index_counter, 0x1a0))))
                                  y1 := add(y1, shl(136, calldataload(add(index_counter, 0x1c0))))
                                  y1 := add(y1, shl(204, calldataload(add(index_counter, 0x1e0))))
                                  mstore(RECURSIVE_P1_X_LOC, x0)
                                  mstore(RECURSIVE_P1_Y_LOC, y0)
                                  mstore(RECURSIVE_P2_X_LOC, x1)
                                  mstore(RECURSIVE_P2_Y_LOC, y1)
                                  // validate these are valid bn128 G1 points
                                  if iszero(and(and(lt(x0, q), lt(x1, q)), and(lt(y0, q), lt(y1, q)))) {
                                      mstore(0x00, PUBLIC_INPUT_INVALID_BN128_G1_POINT_SELECTOR)
                                      revert(0x00, 0x04)
                                  }
                              }
                              let public_input_byte_length := mul(mload(NUM_INPUTS_LOC), 32)
                              data_ptr := add(data_ptr, public_input_byte_length)
                              mstore(W1_X_LOC, mod(calldataload(add(data_ptr, 0x20)), q))
                              mstore(W1_Y_LOC, mod(calldataload(data_ptr), q))
                              mstore(W2_X_LOC, mod(calldataload(add(data_ptr, 0x60)), q))
                              mstore(W2_Y_LOC, mod(calldataload(add(data_ptr, 0x40)), q))
                              mstore(W3_X_LOC, mod(calldataload(add(data_ptr, 0xa0)), q))
                              mstore(W3_Y_LOC, mod(calldataload(add(data_ptr, 0x80)), q))
                              mstore(Z_X_LOC, mod(calldataload(add(data_ptr, 0xe0)), q))
                              mstore(Z_Y_LOC, mod(calldataload(add(data_ptr, 0xc0)), q))
                              mstore(T1_X_LOC, mod(calldataload(add(data_ptr, 0x120)), q))
                              mstore(T1_Y_LOC, mod(calldataload(add(data_ptr, 0x100)), q))
                              mstore(T2_X_LOC, mod(calldataload(add(data_ptr, 0x160)), q))
                              mstore(T2_Y_LOC, mod(calldataload(add(data_ptr, 0x140)), q))
                              mstore(T3_X_LOC, mod(calldataload(add(data_ptr, 0x1a0)), q))
                              mstore(T3_Y_LOC, mod(calldataload(add(data_ptr, 0x180)), q))
                              mstore(W1_EVAL_LOC, mod(calldataload(add(data_ptr, 0x1c0)), p))
                              mstore(W2_EVAL_LOC, mod(calldataload(add(data_ptr, 0x1e0)), p))
                              mstore(W3_EVAL_LOC, mod(calldataload(add(data_ptr, 0x200)), p))
                              mstore(SIGMA1_EVAL_LOC, mod(calldataload(add(data_ptr, 0x220)), p))
                              mstore(SIGMA2_EVAL_LOC, mod(calldataload(add(data_ptr, 0x240)), p))
                              mstore(Z_OMEGA_EVAL_LOC, mod(calldataload(add(data_ptr, 0x260)), p))
                              mstore(PI_Z_X_LOC, mod(calldataload(add(data_ptr, 0x2a0)), q))
                              mstore(PI_Z_Y_LOC, mod(calldataload(add(data_ptr, 0x280)), q))
                              mstore(PI_Z_OMEGA_X_LOC, mod(calldataload(add(data_ptr, 0x2e0)), q))
                              mstore(PI_Z_OMEGA_Y_LOC, mod(calldataload(add(data_ptr, 0x2c0)), q))
                          }
                          {
                              /**
                               * Generate initial challenge
                               *
                               */
                              mstore(0x00, shl(224, mload(N_LOC)))
                              mstore(0x04, shl(224, mload(NUM_INPUTS_LOC)))
                              let challenge := keccak256(0x00, 0x08)
                              /**
                               * Generate beta, gamma challenges
                               */
                              mstore(PUBLIC_INPUTS_HASH_LOCATION, challenge)
                              let inputs_start := add(calldataload(0x04), 0x24)
                              let num_calldata_bytes := add(0xc0, mul(mload(NUM_INPUTS_LOC), 0x20))
                              calldatacopy(add(PUBLIC_INPUTS_HASH_LOCATION, 0x20), inputs_start, num_calldata_bytes)
                              challenge := keccak256(PUBLIC_INPUTS_HASH_LOCATION, add(num_calldata_bytes, 0x20))
                              mstore(C_BETA_LOC, mod(challenge, p))
                              mstore(0x00, challenge)
                              mstore8(0x20, 0x01)
                              challenge := keccak256(0x00, 0x21)
                              mstore(C_GAMMA_LOC, mod(challenge, p))
                              /**
                               * Generate alpha challenge
                               */
                              mstore(0x00, challenge)
                              mstore(0x20, mload(Z_Y_LOC))
                              mstore(0x40, mload(Z_X_LOC))
                              challenge := keccak256(0x00, 0x60)
                              mstore(C_ALPHA_LOC, mod(challenge, p))
                              /**
                               * Generate zeta challenge
                               */
                              mstore(0x00, challenge)
                              mstore(0x20, mload(T1_Y_LOC))
                              mstore(0x40, mload(T1_X_LOC))
                              mstore(0x60, mload(T2_Y_LOC))
                              mstore(0x80, mload(T2_X_LOC))
                              mstore(0xa0, mload(T3_Y_LOC))
                              mstore(0xc0, mload(T3_X_LOC))
                              challenge := keccak256(0x00, 0xe0)
                              mstore(C_ZETA_LOC, mod(challenge, p))
                              mstore(C_CURRENT_LOC, challenge)
                          }
                          /**
                           * EVALUATE FIELD OPERATIONS
                           */
                          /**
                           * COMPUTE PUBLIC INPUT DELTA
                           */
                          {
                              let gamma := mload(C_GAMMA_LOC)
                              let work_root := mload(OMEGA_LOC)
                              let endpoint := sub(mul(mload(NUM_INPUTS_LOC), 0x20), 0x20)
                              let public_inputs
                              let root_1 := mload(C_BETA_LOC)
                              let root_2 := root_1
                              let numerator_value := 1
                              let denominator_value := 1
                              let p_clone := p // move p to the front of the stack
                              let valid := true
                              root_1 := mulmod(root_1, 0x05, p_clone) // k1.beta
                              root_2 := mulmod(root_2, 0x07, p_clone) // 0x05 + 0x07 = 0x0c = external coset generator
                              public_inputs := add(calldataload(0x04), 0x24)
                              endpoint := add(endpoint, public_inputs)
                              for {} lt(public_inputs, endpoint) {} {
                                  let input0 := calldataload(public_inputs)
                                  let N0 := add(root_1, add(input0, gamma))
                                  let D0 := add(root_2, N0) // 4x overloaded
                                  root_1 := mulmod(root_1, work_root, p_clone)
                                  root_2 := mulmod(root_2, work_root, p_clone)
                                  let input1 := calldataload(add(public_inputs, 0x20))
                                  let N1 := add(root_1, add(input1, gamma))
                                  denominator_value := mulmod(mulmod(D0, denominator_value, p_clone), add(N1, root_2), p_clone)
                                  numerator_value := mulmod(mulmod(N1, N0, p_clone), numerator_value, p_clone)
                                  root_1 := mulmod(root_1, work_root, p_clone)
                                  root_2 := mulmod(root_2, work_root, p_clone)
                                  valid := and(valid, and(lt(input0, p_clone), lt(input1, p_clone)))
                                  public_inputs := add(public_inputs, 0x40)
                                  // validate public inputs are field elements (i.e. < p)
                                  if iszero(and(lt(input0, p_clone), lt(input1, p_clone))) {
                                      mstore(0x00, PUBLIC_INPUT_GE_P_SELECTOR)
                                      revert(0x00, 0x04)
                                  }
                              }
                              endpoint := add(endpoint, 0x20)
                              for {} lt(public_inputs, endpoint) { public_inputs := add(public_inputs, 0x20) } {
                                  let input0 := calldataload(public_inputs)
                                  // validate public inputs are field elements (i.e. < p)
                                  if iszero(lt(input0, p_clone)) {
                                      mstore(0x00, PUBLIC_INPUT_GE_P_SELECTOR)
                                      revert(0x00, 0x04)
                                  }
                                  valid := and(valid, lt(input0, p_clone))
                                  let T0 := addmod(input0, gamma, p_clone)
                                  numerator_value :=
                                      mulmod(
                                          numerator_value,
                                          add(root_1, T0), // 0x05 = coset_generator0
                                          p_clone
                                      )
                                  denominator_value :=
                                      mulmod(
                                          denominator_value,
                                          add(add(root_1, root_2), T0), // 0x0c = coset_generator7
                                          p_clone
                                      )
                                  root_1 := mulmod(root_1, work_root, p_clone)
                                  root_2 := mulmod(root_2, work_root, p_clone)
                              }
                              mstore(DELTA_NUMERATOR_LOC, numerator_value)
                              mstore(DELTA_DENOMINATOR_LOC, denominator_value)
                          }
                          /**
                           * Compute lagrange poly and vanishing poly fractions
                           */
                          {
                              let zeta := mload(C_ZETA_LOC)
                              // compute zeta^n, where n is a power of 2
                              let vanishing_numerator := zeta
                              {
                                  // pow_small
                                  let exponent := mload(N_LOC)
                                  let count := 1
                                  for {} lt(count, exponent) { count := add(count, count) } {
                                      vanishing_numerator := mulmod(vanishing_numerator, vanishing_numerator, p)
                                  }
                              }
                              mstore(ZETA_POW_N_LOC, vanishing_numerator)
                              vanishing_numerator := addmod(vanishing_numerator, sub(p, 1), p)
                              let accumulating_root := mload(OMEGA_INVERSE_LOC)
                              let work_root := sub(p, accumulating_root)
                              let domain_inverse := mload(DOMAIN_INVERSE_LOC)
                              let vanishing_denominator := addmod(zeta, work_root, p)
                              work_root := mulmod(work_root, accumulating_root, p)
                              vanishing_denominator := mulmod(vanishing_denominator, addmod(zeta, work_root, p), p)
                              work_root := mulmod(work_root, accumulating_root, p)
                              vanishing_denominator := mulmod(vanishing_denominator, addmod(zeta, work_root, p), p)
                              vanishing_denominator :=
                                  mulmod(vanishing_denominator, addmod(zeta, mulmod(work_root, accumulating_root, p), p), p)
                              work_root := mload(OMEGA_LOC)
                              let lagrange_numerator := mulmod(vanishing_numerator, domain_inverse, p)
                              let l_start_denominator := addmod(zeta, sub(p, 1), p)
                              // l_end_denominator term contains a term \\omega^5 to cut out 5 roots of unity from vanishing poly
                              accumulating_root := mulmod(work_root, work_root, p)
                              let l_end_denominator :=
                                  addmod(
                                      mulmod(mulmod(mulmod(accumulating_root, accumulating_root, p), work_root, p), zeta, p), sub(p, 1), p
                                  )
                              /**
                               * Compute inversions using Montgomery's batch inversion trick
                               */
                              let accumulator := mload(DELTA_DENOMINATOR_LOC)
                              let t0 := accumulator
                              accumulator := mulmod(accumulator, vanishing_denominator, p)
                              let t1 := accumulator
                              accumulator := mulmod(accumulator, l_start_denominator, p)
                              let t2 := accumulator
                              {
                                  mstore(0, 0x20)
                                  mstore(0x20, 0x20)
                                  mstore(0x40, 0x20)
                                  mstore(0x60, mulmod(accumulator, l_end_denominator, p))
                                  mstore(0x80, sub(p, 2))
                                  mstore(0xa0, p)
                                  if iszero(staticcall(gas(), 0x05, 0x00, 0xc0, 0x00, 0x20)) {
                                      mstore(0x0, MOD_EXP_FAILURE_SELECTOR)
                                      revert(0x00, 0x04)
                                  }
                                  accumulator := mload(0x00)
                              }
                              t2 := mulmod(accumulator, t2, p)
                              accumulator := mulmod(accumulator, l_end_denominator, p)
                              t1 := mulmod(accumulator, t1, p)
                              accumulator := mulmod(accumulator, l_start_denominator, p)
                              t0 := mulmod(accumulator, t0, p)
                              accumulator := mulmod(accumulator, vanishing_denominator, p)
                              accumulator := mulmod(mulmod(accumulator, accumulator, p), mload(DELTA_DENOMINATOR_LOC), p)
                              mstore(PUBLIC_INPUT_DELTA_LOC, mulmod(mload(DELTA_NUMERATOR_LOC), accumulator, p))
                              mstore(ZERO_POLY_LOC, mulmod(vanishing_numerator, t0, p))
                              mstore(L_START_LOC, mulmod(lagrange_numerator, t1, p))
                              mstore(L_END_LOC, mulmod(lagrange_numerator, t2, p))
                          }
                          /**
                           * COMPUTE CONSTANT TERM (r_0) OF LINEARISATION POLYNOMIAL
                           */
                          {
                              let alpha := mload(C_ALPHA_LOC)
                              let beta := mload(C_BETA_LOC)
                              let gamma := mload(C_GAMMA_LOC)
                              let r_0 :=
                                  sub(
                                      p,
                                      mulmod(
                                          mulmod(
                                              mulmod(
                                                  add(add(mload(W1_EVAL_LOC), gamma), mulmod(beta, mload(SIGMA1_EVAL_LOC), p)),
                                                  add(add(mload(W2_EVAL_LOC), gamma), mulmod(beta, mload(SIGMA2_EVAL_LOC), p)),
                                                  p
                                              ),
                                              add(mload(W3_EVAL_LOC), gamma),
                                              p
                                          ),
                                          mload(Z_OMEGA_EVAL_LOC),
                                          p
                                      )
                                  )
                              // r_0 = -(ā + βs̄_σ1 + γ)( b̄ + βs̄_σ2 + γ)(c̄ + γ)z̄_ω
                              let alpha_sqr := mulmod(alpha, alpha, p)
                              mstore(C_ALPHA_SQR_LOC, alpha_sqr)
                              mstore(C_ARITHMETIC_ALPHA_LOC, mulmod(alpha_sqr, alpha_sqr, p))
                              mstore(
                                  R_ZERO_EVAL_LOC,
                                  mulmod(
                                      addmod(
                                          addmod(r_0, sub(p, mulmod(mload(L_START_LOC), alpha_sqr, p)), p),
                                          mulmod(
                                              mulmod(mload(L_END_LOC), alpha, p),
                                              addmod(mload(Z_OMEGA_EVAL_LOC), sub(p, mload(PUBLIC_INPUT_DELTA_LOC)), p),
                                              p
                                          ),
                                          p
                                      ),
                                      alpha,
                                      p
                                  )
                              )
                          }
                          /**
                           * GENERATE NU AND SEPARATOR CHALLENGES
                           */
                          {
                              let current_challenge := mload(C_CURRENT_LOC)
                              // get a calldata pointer that points to the start of the data we want to copy
                              let calldata_ptr := add(calldataload(0x04), 0x24)
                              // skip over the public inputs
                              calldata_ptr := add(calldata_ptr, mul(mload(NUM_INPUTS_LOC), 0x20))
                              // There are SEVEN G1 group elements added into the transcript in the `beta` round, that we need to skip over
                              // W1, W2, W3 (W4), Z, T1, T2, T3, (T4)
                              calldata_ptr := add(calldata_ptr, 0x1c0) // 7 * 0x40 = 0x1c0
                              mstore(0x00, current_challenge)
                              calldatacopy(0x20, calldata_ptr, 0xc0) // 6 * 0x20 = 0xc0
                              let challenge := keccak256(0x00, 0xe0) // hash length = 0xe0 (0x20 + num field elements), we include the previous challenge in the hash
                              mstore(C_V0_LOC, mod(challenge, p))
                              mstore(0x00, challenge)
                              mstore8(0x20, 0x01)
                              mstore(C_V1_LOC, mod(keccak256(0x00, 0x21), p))
                              mstore8(0x20, 0x02)
                              mstore(C_V2_LOC, mod(keccak256(0x00, 0x21), p))
                              mstore8(0x20, 0x03)
                              mstore(C_V3_LOC, mod(keccak256(0x00, 0x21), p))
                              mstore8(0x20, 0x04)
                              mstore(C_V4_LOC, mod(keccak256(0x00, 0x21), p))
                              mstore8(0x20, 0x05)
                              challenge := keccak256(0x00, 0x21)
                              mstore(C_V5_LOC, mod(challenge, p))
                              // separator
                              mstore(0x00, challenge)
                              mstore(0x20, mload(PI_Z_Y_LOC))
                              mstore(0x40, mload(PI_Z_X_LOC))
                              mstore(0x60, mload(PI_Z_OMEGA_Y_LOC))
                              mstore(0x80, mload(PI_Z_OMEGA_X_LOC))
                              mstore(C_U_LOC, mod(keccak256(0x00, 0xa0), p))
                          }
                          // mstore(C_ALPHA_BASE_LOC, mload(C_ALPHA_LOC))
                          /**
                           * COMPUTE LINEARISED OPENING TERMS
                           */
                          {
                              // /**
                              //  * COMPUTE GRAND PRODUCT OPENING GROUP ELEMENT
                              //  */
                              let beta := mload(C_BETA_LOC)
                              let zeta := mload(C_ZETA_LOC)
                              let gamma := mload(C_GAMMA_LOC)
                              let alpha := mload(C_ALPHA_LOC)
                              let beta_zeta := mulmod(beta, zeta, p)
                              let witness_term := addmod(mload(W1_EVAL_LOC), gamma, p)
                              let partial_grand_product := addmod(beta_zeta, witness_term, p)
                              let sigma_multiplier := addmod(mulmod(mload(SIGMA1_EVAL_LOC), beta, p), witness_term, p)
                              witness_term := addmod(mload(W2_EVAL_LOC), gamma, p)
                              sigma_multiplier :=
                                  mulmod(sigma_multiplier, addmod(mulmod(mload(SIGMA2_EVAL_LOC), beta, p), witness_term, p), p)
                              let k1_beta_zeta := mulmod(0x05, beta_zeta, p)
                              //  partial_grand_product = mulmod( mulmod( partial_grand_product, w2 + k1.beta.zeta + gamma , p), k2.beta.zeta + gamma + w3, p)
                              partial_grand_product :=
                                  mulmod(
                                      mulmod(
                                          partial_grand_product,
                                          addmod(k1_beta_zeta, witness_term, p), // w2 + k1.beta.zeta + gamma
                                          p
                                      ),
                                      addmod(addmod(add(k1_beta_zeta, beta_zeta), gamma, p), mload(W3_EVAL_LOC), p), // k2.beta.zeta + gamma + w3 where k2 = k1+1
                                      p
                                  )
                              let linear_challenge := alpha // Owing to the simplified Plonk, nu =1, linear_challenge = nu * alpha = alpha
                              mstore(0x00, mload(SIGMA3_X_LOC))
                              mstore(0x20, mload(SIGMA3_Y_LOC))
                              mstore(
                                  0x40,
                                  mulmod(
                                      mulmod(sub(p, mulmod(sigma_multiplier, mload(Z_OMEGA_EVAL_LOC), p)), beta, p),
                                      linear_challenge,
                                      p
                                  )
                              )
                              // Validate Z
                              let success
                              {
                                  let x := mload(Z_X_LOC)
                                  let y := mload(Z_Y_LOC)
                                  let xx := mulmod(x, x, q)
                                  success := eq(mulmod(y, y, q), addmod(mulmod(x, xx, q), 3, q))
                                  mstore(0x60, x)
                                  mstore(0x80, y)
                              }
                              mstore(
                                  0xa0,
                                  addmod(
                                      mulmod(
                                          addmod(partial_grand_product, mulmod(mload(L_START_LOC), mload(C_ALPHA_SQR_LOC), p), p),
                                          linear_challenge,
                                          p
                                      ),
                                      mload(C_U_LOC),
                                      p
                                  )
                              )
                              // 0x00 = SIGMA3_X_LOC,
                              // 0x20 = SIGMA3_Y_LOC,
                              // 0x40 = −(ā + βs̄_σ1 + γ)( b̄ + βs̄_σ2 + γ)αβz̄_ω,
                              // 0x60 = Z_X_LOC,
                              // 0x80 = Z_Y_LOC,
                              // 0xa0 = (ā + βz + γ)( b̄ + βk_1 z + γ)(c̄ + βk_2 z + γ)α + L_1(z)α^3 + u
                              success :=
                                  and(
                                      success,
                                      and(
                                          staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                          // Why ACCUMULATOR_X_LOC := ACCUMULATOR_X_LOC + ACCUMULATOR2_X_LOC? Inner parenthesis is executed before?
                                          and(
                                              staticcall(gas(), 7, 0x60, 0x60, ACCUMULATOR_X_LOC, 0x40),
                                              // [ACCUMULATOR_X_LOC, ACCUMULATOR_X_LOC + 0x40) = ((ā + βz + γ)( b̄ + βk_1 z + γ)(c̄ + βk_2 z + γ)α + L_1(z)α^3 + u)*[z]_1
                                              staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40)
                                          )
                                      )
                                  )
                              // [ACCUMULATOR2_X_LOC, ACCUMULATOR2_X_LOC + 0x40) = −(ā + βs̄_σ1 + γ)( b̄ + βs̄_σ2 + γ)αβz̄_ω * [s_σ3]_1
                              mstore(GRAND_PRODUCT_SUCCESS_FLAG, success)
                          }
                          /**
                           * COMPUTE ARITHMETIC SELECTOR OPENING GROUP ELEMENT
                           */
                          {
                              let linear_challenge := mload(C_ARITHMETIC_ALPHA_LOC) // Owing to simplified Plonk, nu = 1,  linear_challenge = C_ARITHMETIC_ALPHA (= alpha^4)
                              let t1 := mulmod(mload(W1_EVAL_LOC), linear_challenge, p) // reuse this for QM scalar multiplier
                              // Q1
                              mstore(0x00, mload(Q1_X_LOC))
                              mstore(0x20, mload(Q1_Y_LOC))
                              mstore(0x40, t1)
                              // add Q1 scalar mul into grand product scalar mul
                              // Observe that ACCUMULATOR_X_LOC and ACCUMULATOR2_X_LOC are 0x40 bytes apart. Below, ACCUMULATOR2_X_LOC
                              // captures new terms Q1, Q2, and so on and they get accumulated to ACCUMULATOR_X_LOC
                              let success :=
                                  and(
                                      staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                      // [ACCUMULATOR_X_LOC, ACCUMULATOR_X_LOC + 0x40) = ((ā + βz + γ)( b̄ + βk_1 z + γ)(c̄ + βk_2 z + γ)α + L_1(z)α^3 + u)*[z]_1 −(ā + βs̄_σ1 + γ)( b̄ + βs̄_σ2 + γ)αβz̄_ω * [s_σ3]_1
                                      staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40)
                                  )
                              // [ACCUMULATOR2_X_LOC, ACCUMULATOR2_X_LOC + 0x40) = ā * [q_L]_1
                              // Q2
                              mstore(0x00, mload(Q2_X_LOC))
                              mstore(0x20, mload(Q2_Y_LOC))
                              mstore(0x40, mulmod(mload(W2_EVAL_LOC), linear_challenge, p))
                              success :=
                                  and(
                                      success,
                                      and(
                                          staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                          staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40)
                                      )
                                  )
                              // Q3
                              mstore(0x00, mload(Q3_X_LOC))
                              mstore(0x20, mload(Q3_Y_LOC))
                              mstore(0x40, mulmod(mload(W3_EVAL_LOC), linear_challenge, p))
                              success :=
                                  and(
                                      success,
                                      and(
                                          staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                          staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40)
                                      )
                                  )
                              // QM
                              mstore(0x00, mload(QM_X_LOC))
                              mstore(0x20, mload(QM_Y_LOC))
                              mstore(0x40, mulmod(t1, mload(W2_EVAL_LOC), p))
                              success :=
                                  and(
                                      success,
                                      and(
                                          staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                          staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40)
                                      )
                                  )
                              // QC
                              mstore(0x00, mload(QC_X_LOC))
                              mstore(0x20, mload(QC_Y_LOC))
                              mstore(0x40, linear_challenge)
                              success :=
                                  and(
                                      success,
                                      and(
                                          staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                          staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40)
                                      )
                                  )
                              mstore(ARITHMETIC_TERM_SUCCESS_FLAG, success)
                          }
                          /**
                           * COMPUTE BATCH OPENING COMMITMENT
                           */
                          {
                              // previous scalar_multiplier = 1, z^n, z^2n
                              // scalar_multiplier owing to the simplified Plonk = 1 * -Z_H(z), z^n * -Z_H(z), z^2n * -Z_H(z)
                              // VALIDATE T1
                              let success
                              {
                                  let x := mload(T1_X_LOC)
                                  let y := mload(T1_Y_LOC)
                                  let xx := mulmod(x, x, q)
                                  success := eq(mulmod(y, y, q), addmod(mulmod(x, xx, q), 3, q))
                                  mstore(0x00, x)
                                  mstore(0x20, y)
                                  mstore(0x40, sub(p, mload(ZERO_POLY_LOC)))
                                  // mstore(ACCUMULATOR2_X_LOC, x)
                                  // mstore(ACCUMULATOR2_Y_LOC, y)
                              }
                              success :=
                                  and(
                                      success,
                                      and(
                                          staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                          staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40)
                                      )
                                  )
                              // VALIDATE T2
                              let scalar_multiplier := mload(ZETA_POW_N_LOC)
                              {
                                  let x := mload(T2_X_LOC)
                                  let y := mload(T2_Y_LOC)
                                  let xx := mulmod(x, x, q)
                                  success := and(success, eq(mulmod(y, y, q), addmod(mulmod(x, xx, q), 3, q)))
                                  mstore(0x00, x)
                                  mstore(0x20, y)
                              }
                              mstore(0x40, mulmod(scalar_multiplier, sub(p, mload(ZERO_POLY_LOC)), p))
                              success :=
                                  and(
                                      staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                      and(success, staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40))
                                  )
                              // VALIDATE T3
                              {
                                  let x := mload(T3_X_LOC)
                                  let y := mload(T3_Y_LOC)
                                  let xx := mulmod(x, x, q)
                                  success := and(success, eq(mulmod(y, y, q), addmod(mulmod(x, xx, q), 3, q)))
                                  mstore(0x00, x)
                                  mstore(0x20, y)
                              }
                              mstore(0x40, mulmod(scalar_multiplier, mulmod(scalar_multiplier, sub(p, mload(ZERO_POLY_LOC)), p), p))
                              success :=
                                  and(
                                      staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                      and(success, staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40))
                                  )
                              // VALIDATE W1
                              {
                                  let x := mload(W1_X_LOC)
                                  let y := mload(W1_Y_LOC)
                                  let xx := mulmod(x, x, q)
                                  success := and(success, eq(mulmod(y, y, q), addmod(mulmod(x, xx, q), 3, q)))
                                  mstore(0x00, x)
                                  mstore(0x20, y)
                              }
                              mstore(0x40, mload(C_V0_LOC))
                              success :=
                                  and(
                                      staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                      and(success, staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40))
                                  )
                              // VALIDATE W2
                              {
                                  let x := mload(W2_X_LOC)
                                  let y := mload(W2_Y_LOC)
                                  let xx := mulmod(x, x, q)
                                  success := and(success, eq(mulmod(y, y, q), addmod(mulmod(x, xx, q), 3, q)))
                                  mstore(0x00, x)
                                  mstore(0x20, y)
                              }
                              mstore(0x40, mload(C_V1_LOC))
                              success :=
                                  and(
                                      staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                      and(success, staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40))
                                  )
                              // VALIDATE W3
                              {
                                  let x := mload(W3_X_LOC)
                                  let y := mload(W3_Y_LOC)
                                  let xx := mulmod(x, x, q)
                                  success := and(success, eq(mulmod(y, y, q), addmod(mulmod(x, xx, q), 3, q)))
                                  mstore(0x00, x)
                                  mstore(0x20, y)
                              }
                              mstore(0x40, mload(C_V2_LOC))
                              success :=
                                  and(
                                      staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                      and(success, staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40))
                                  )
                              mstore(0x00, mload(SIGMA1_X_LOC))
                              mstore(0x20, mload(SIGMA1_Y_LOC))
                              mstore(0x40, mload(C_V3_LOC))
                              success :=
                                  and(
                                      staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                      and(success, staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40))
                                  )
                              mstore(0x00, mload(SIGMA2_X_LOC))
                              mstore(0x20, mload(SIGMA2_Y_LOC))
                              mstore(0x40, mload(C_V4_LOC))
                              success :=
                                  and(
                                      staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                      and(success, staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40))
                                  )
                              mstore(BATCH_OPENING_SUCCESS_FLAG, success)
                          }
                          /**
                           * COMPUTE BATCH EVALUATION SCALAR MULTIPLIER
                           */
                          {
                              mstore(0x00, 0x01) // [1].x
                              mstore(0x20, 0x02) // [1].y
                              // Yul stack optimizer doing some work here...
                              mstore(
                                  0x40,
                                  sub(
                                      p,
                                      addmod(
                                          mulmod(mload(C_U_LOC), mload(Z_OMEGA_EVAL_LOC), p),
                                          addmod(
                                              sub(p, mload(R_ZERO_EVAL_LOC)), // Change owing to the simplified Plonk
                                              addmod(
                                                  mulmod(mload(C_V4_LOC), mload(SIGMA2_EVAL_LOC), p),
                                                  addmod(
                                                      mulmod(mload(C_V3_LOC), mload(SIGMA1_EVAL_LOC), p),
                                                      addmod(
                                                          mulmod(mload(C_V2_LOC), mload(W3_EVAL_LOC), p),
                                                          addmod(
                                                              mulmod(mload(C_V1_LOC), mload(W2_EVAL_LOC), p),
                                                              mulmod(mload(C_V0_LOC), mload(W1_EVAL_LOC), p),
                                                              p
                                                          ),
                                                          p
                                                      ),
                                                      p
                                                  ),
                                                  p
                                              ),
                                              p
                                          ),
                                          p
                                      )
                                  )
                              )
                              let success :=
                                  and(
                                      staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                      staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40)
                                  )
                              mstore(OPENING_COMMITMENT_SUCCESS_FLAG, success)
                          }
                          /**
                           * PERFORM PAIRING PREAMBLE
                           */
                          {
                              let u := mload(C_U_LOC)
                              let zeta := mload(C_ZETA_LOC)
                              let success
                              // VALIDATE PI_Z
                              {
                                  let x := mload(PI_Z_X_LOC)
                                  let y := mload(PI_Z_Y_LOC)
                                  let xx := mulmod(x, x, q)
                                  success := eq(mulmod(y, y, q), addmod(mulmod(x, xx, q), 3, q))
                                  mstore(0x00, x)
                                  mstore(0x20, y)
                              }
                              // compute zeta.[PI_Z] and add into accumulator
                              mstore(0x40, zeta)
                              success :=
                                  and(
                                      success,
                                      and(
                                          staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, ACCUMULATOR_X_LOC, 0x40),
                                          staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40)
                                      )
                                  )
                              // VALIDATE PI_Z_OMEGA
                              {
                                  let x := mload(PI_Z_OMEGA_X_LOC)
                                  let y := mload(PI_Z_OMEGA_Y_LOC)
                                  let xx := mulmod(x, x, q)
                                  success := and(success, eq(mulmod(y, y, q), addmod(mulmod(x, xx, q), 3, q)))
                                  mstore(0x00, x)
                                  mstore(0x20, y)
                              }
                              // compute u.zeta.omega.[PI_Z_OMEGA] and add into accumulator
                              mstore(0x40, mulmod(mulmod(u, zeta, p), mload(OMEGA_LOC), p))
                              success :=
                                  and(
                                      staticcall(gas(), 6, ACCUMULATOR_X_LOC, 0x80, PAIRING_RHS_X_LOC, 0x40),
                                      and(success, staticcall(gas(), 7, 0x00, 0x60, ACCUMULATOR2_X_LOC, 0x40))
                                  )
                              mstore(0x00, mload(PI_Z_X_LOC))
                              mstore(0x20, mload(PI_Z_Y_LOC))
                              mstore(0x40, mload(PI_Z_OMEGA_X_LOC))
                              mstore(0x60, mload(PI_Z_OMEGA_Y_LOC))
                              mstore(0x80, u)
                              success :=
                                  and(
                                      staticcall(gas(), 6, 0x00, 0x80, PAIRING_LHS_X_LOC, 0x40),
                                      and(success, staticcall(gas(), 7, 0x40, 0x60, 0x40, 0x40))
                                  )
                              // negate lhs y-coordinate
                              mstore(PAIRING_LHS_Y_LOC, sub(q, mload(PAIRING_LHS_Y_LOC)))
                              if mload(CONTAINS_RECURSIVE_PROOF_LOC) {
                                  // VALIDATE RECURSIVE P1
                                  {
                                      let x := mload(RECURSIVE_P1_X_LOC)
                                      let y := mload(RECURSIVE_P1_Y_LOC)
                                      let xx := mulmod(x, x, q)
                                      success := and(success, eq(mulmod(y, y, q), addmod(mulmod(x, xx, q), 3, q)))
                                      mstore(0x00, x)
                                      mstore(0x20, y)
                                  }
                                  // compute u.u.[recursive_p1] and write into 0x60
                                  mstore(0x40, mulmod(u, u, p))
                                  success := and(success, staticcall(gas(), 7, 0x00, 0x60, 0x60, 0x40))
                                  // VALIDATE RECURSIVE P2
                                  {
                                      let x := mload(RECURSIVE_P2_X_LOC)
                                      let y := mload(RECURSIVE_P2_Y_LOC)
                                      let xx := mulmod(x, x, q)
                                      success := and(success, eq(mulmod(y, y, q), addmod(mulmod(x, xx, q), 3, q)))
                                      mstore(0x00, x)
                                      mstore(0x20, y)
                                  }
                                  // compute u.u.[recursive_p2] and write into 0x00
                                  // 0x40 still contains u*u
                                  success := and(success, staticcall(gas(), 7, 0x00, 0x60, 0x00, 0x40))
                                  // compute u.u.[recursiveP1] + rhs and write into rhs
                                  mstore(0xa0, mload(PAIRING_RHS_X_LOC))
                                  mstore(0xc0, mload(PAIRING_RHS_Y_LOC))
                                  success := and(success, staticcall(gas(), 6, 0x60, 0x80, PAIRING_RHS_X_LOC, 0x40))
                                  // compute u.u.[recursiveP2] + lhs and write into lhs
                                  mstore(0x40, mload(PAIRING_LHS_X_LOC))
                                  mstore(0x60, mload(PAIRING_LHS_Y_LOC))
                                  success := and(success, staticcall(gas(), 6, 0x00, 0x80, PAIRING_LHS_X_LOC, 0x40))
                              }
                              if iszero(success) {
                                  mstore(0x0, EC_SCALAR_MUL_FAILURE_SELECTOR)
                                  revert(0x00, 0x04)
                              }
                              mstore(PAIRING_PREAMBLE_SUCCESS_FLAG, success)
                          }
                          /**
                           * PERFORM PAIRING
                           */
                          {
                              // rhs paired with [1]_2
                              // lhs paired with [x]_2
                              mstore(0x00, mload(PAIRING_RHS_X_LOC))
                              mstore(0x20, mload(PAIRING_RHS_Y_LOC))
                              mstore(0x40, 0x198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2) // this is [1]_2
                              mstore(0x60, 0x1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed)
                              mstore(0x80, 0x090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b)
                              mstore(0xa0, 0x12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa)
                              mstore(0xc0, mload(PAIRING_LHS_X_LOC))
                              mstore(0xe0, mload(PAIRING_LHS_Y_LOC))
                              mstore(0x100, mload(G2X_X0_LOC))
                              mstore(0x120, mload(G2X_X1_LOC))
                              mstore(0x140, mload(G2X_Y0_LOC))
                              mstore(0x160, mload(G2X_Y1_LOC))
                              let success := staticcall(gas(), 8, 0x00, 0x180, 0x00, 0x20)
                              mstore(PAIRING_SUCCESS_FLAG, success)
                              mstore(RESULT_FLAG, mload(0x00))
                          }
                          if iszero(
                              and(
                                  and(
                                      and(
                                          and(
                                              and(
                                                  and(mload(PAIRING_SUCCESS_FLAG), mload(RESULT_FLAG)),
                                                  mload(PAIRING_PREAMBLE_SUCCESS_FLAG)
                                              ),
                                              mload(OPENING_COMMITMENT_SUCCESS_FLAG)
                                          ),
                                          mload(BATCH_OPENING_SUCCESS_FLAG)
                                      ),
                                      mload(ARITHMETIC_TERM_SUCCESS_FLAG)
                                  ),
                                  mload(GRAND_PRODUCT_SUCCESS_FLAG)
                              )
                          ) {
                              mstore(0x0, PROOF_FAILURE_SELECTOR)
                              revert(0x00, 0x04)
                          }
                          {
                              mstore(0x00, 0x01)
                              return(0x00, 0x20) // Proof succeeded!
                          }
                      }
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              import {VerificationKey28x32} from "../keys/VerificationKey28x32.sol";
              import {BaseStandardVerifier} from "../BaseStandardVerifier.sol";
              contract Verifier28x32 is BaseStandardVerifier {
                  function getVerificationKeyHash() public pure override (BaseStandardVerifier) returns (bytes32) {
                      return VerificationKey28x32.verificationKeyHash();
                  }
                  function loadVerificationKey(uint256 vk, uint256 _omegaInverseLoc) internal pure virtual override {
                      VerificationKey28x32.loadVerificationKey(vk, _omegaInverseLoc);
                  }
              }
              // Verification Key Hash: 8bb8dcfd02060143443271408d47991c82c9fd631b02b42ef1ec28909631b9a1
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              library VerificationKey28x32 {
                  function verificationKeyHash() internal pure returns (bytes32) {
                      return 0x8bb8dcfd02060143443271408d47991c82c9fd631b02b42ef1ec28909631b9a1;
                  }
                  function loadVerificationKey(uint256 _vk, uint256 _omegaInverseLoc) internal pure {
                      assembly {
                          mstore(add(_vk, 0x00), 0x0000000000000000000000000000000000000000000000000000000000800000) // vk.circuit_size
                          mstore(add(_vk, 0x20), 0x0000000000000000000000000000000000000000000000000000000000000011) // vk.num_inputs
                          mstore(add(_vk, 0x40), 0x0210fe635ab4c74d6b7bcf70bc23a1395680c64022dd991fb54d4506ab80c59d) // vk.work_root
                          mstore(add(_vk, 0x60), 0x30644e121894ba67550ff245e0f5eb5a25832df811e8df9dd100d30c2c14d821) // vk.domain_inverse
                          mstore(add(_vk, 0x80), 0x1d349b8977724e09c86fa578f4735879a9f44c213b0c8ca5102e4c3971408ef1) // vk.Q1.x
                          mstore(add(_vk, 0xa0), 0x24f288f17b6ae11b4b7864ab9594f8b2f4f19ea1d60e17f772974e91844ac462) // vk.Q1.y
                          mstore(add(_vk, 0xc0), 0x0f497062b02badba76b0dcaaab298d98be8065f2c12a0d016722cd4c128fcb6e) // vk.Q2.x
                          mstore(add(_vk, 0xe0), 0x0c35a5c01f13a779a561ee38425a227edbccbb249cbab8b3c67acb6ae4fc1e8f) // vk.Q2.y
                          mstore(add(_vk, 0x100), 0x1da0feb3b521b13e4c0f131fb7e5fe4a4406caa1cee0df757659f2303329c00c) // vk.Q3.x
                          mstore(add(_vk, 0x120), 0x1f964f3a14e19de343a7a8a7ae0fc7b3c44211a9927ebbdb9556fd623177464c) // vk.Q3.y
                          mstore(add(_vk, 0x140), 0x188fa91323b2ba20000d98efb311dc84b27ec60203c6f51301471213bfcc0c93) // vk.QM.x
                          mstore(add(_vk, 0x160), 0x0dec5cadfc71c9c707e8d451f6a87ee63a25769d6ca4b35f84596bc8d163ab13) // vk.QM.y
                          mstore(add(_vk, 0x180), 0x0e18198690edc77d449e2a46b5bffffd1356422c0fa54e3cc011194ba83eb6ed) // vk.QC.x
                          mstore(add(_vk, 0x1a0), 0x1f22be590007dbcd8ce6d51b513bccb91906f3baec495226810856655b7fde35) // vk.QC.y
                          mstore(add(_vk, 0x1c0), 0x1ae57998807b3d1393feec54458002a457f5518b9adc66bb2facf68fd08e6c85) // vk.SIGMA1.x
                          mstore(add(_vk, 0x1e0), 0x078c0f28b8823d267717a4b9903af394feb40e305acd6d5692239b8449c391a3) // vk.SIGMA1.y
                          mstore(add(_vk, 0x200), 0x23a3fa199f93bbdf437853790a5505ec120cb1d311b629342304cb07a77161f3) // vk.SIGMA2.x
                          mstore(add(_vk, 0x220), 0x2e7711ded1fcd544e9f1aa2a82173475cd143f8111628694766546e179f071f7) // vk.SIGMA2.y
                          mstore(add(_vk, 0x240), 0x1e242bd59e58c879d7ac9629be07a5396ac7d95f05496dbc2c9f45627d56c148) // vk.SIGMA3.x
                          mstore(add(_vk, 0x260), 0x239a1f09cab3a4d6524ddb0577a804d883c806a55bf4931e037a0592b5faad7c) // vk.SIGMA3.y
                          mstore(add(_vk, 0x280), 0x01) // vk.contains_recursive_proof
                          mstore(add(_vk, 0x2a0), 1) // vk.recursive_proof_public_input_indices
                          mstore(add(_vk, 0x2c0), 0x260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c1) // vk.g2_x.X.c1
                          mstore(add(_vk, 0x2e0), 0x0118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b0) // vk.g2_x.X.c0
                          mstore(add(_vk, 0x300), 0x04fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe4) // vk.g2_x.Y.c1
                          mstore(add(_vk, 0x320), 0x22febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55) // vk.g2_x.Y.c0
                          mstore(_omegaInverseLoc, 0x2165a1a5bda6792b1dd75c9f4e2b8e61126a786ba1a6eadf811b03e7d69ca83b) // vk.work_root_inverse
                      }
                  }
              }
              

              File 11 of 12: DefiBridgeProxy
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              import {IDefiBridge} from './interfaces/IDefiBridge.sol';
              import {AztecTypes} from './AztecTypes.sol';
              import {TokenTransfers} from './libraries/TokenTransfers.sol';
              contract DefiBridgeProxy {
                  error OUTPUT_A_EXCEEDS_252_BITS(uint256 outputValue);
                  error OUTPUT_B_EXCEEDS_252_BITS(uint256 outputValue);
                  error ASYNC_NONZERO_OUTPUT_VALUES(uint256 outputValueA, uint256 outputValueB);
                  error INSUFFICIENT_ETH_PAYMENT();
                  /**
                   * @dev Use interaction result data to pull tokens into DefiBridgeProxy
                   * @param asset The AztecAsset being targetted
                   * @param outputValue The claimed output value provided by the bridge
                   * @param interactionNonce The defi interaction nonce of the interaction
                   * @param bridgeContract Address of the defi bridge contract
                   * @param ethPaymentsSlot The slot value of the `ethPayments` storage mapping in RollupProcessor.sol!
                   * More details on ethPaymentsSlot are in the comments for the `convert` function
                   */
                  function recoverTokens(
                      AztecTypes.AztecAsset memory asset,
                      uint256 outputValue,
                      uint256 interactionNonce,
                      address bridgeContract,
                      uint256 ethPaymentsSlot
                  ) internal {
                      if (outputValue == 0) {
                          return;
                      }
                      if (asset.assetType == AztecTypes.AztecAssetType.ETH) {
                          uint256 ethPayment;
                          uint256 ethPaymentsSlotBase;
                          assembly {
                              mstore(0x00, interactionNonce)
                              mstore(0x20, ethPaymentsSlot)
                              ethPaymentsSlotBase := keccak256(0x00, 0x40)
                              ethPayment := sload(ethPaymentsSlotBase) // ethPayment = ethPayments[interactionNonce]
                          }
                          if (outputValue > ethPayment) {
                              revert INSUFFICIENT_ETH_PAYMENT();
                          }
                          assembly {
                              sstore(ethPaymentsSlotBase, 0) // ethPayments[interactionNonce] = 0;
                          }
                      } else if (asset.assetType == AztecTypes.AztecAssetType.ERC20) {
                          TokenTransfers.safeTransferFrom(asset.erc20Address, bridgeContract, address(this), outputValue);
                      }
                  }
                  /**
                   * @dev Convert input assets into output assets via calling a defi bridge contract
                   * @param bridgeAddress Address of the defi bridge contract
                   * @param inputAssetA First input asset
                   * @param inputAssetB Second input asset. Is either VIRTUAL or NOT_USED (checked by RollupProcessor)
                   * @param outputAssetA First output asset
                   * @param outputAssetB Second output asset
                   * @param totalInputValue The total amount of inputAssetA to be sent to the bridge
                   * @param interactionNonce Integer that is unique for a given defi interaction
                   * @param auxInputData Optional custom data to be sent to the bridge (defined in the L2 SNARK circuits when creating claim notes)
                   * @param ethPaymentsSlot The slot value of the `ethPayments` storage mapping in RollupProcessor.sol!
                   * @param rollupBeneficiary The address that should be payed any fees / subsidy for executing this bridge.
                   * We assume this contract is called from the RollupProcessor via `delegateCall`,
                   * if not... this contract behaviour is undefined! So don't do that.
                   * The idea here is that, if the defi bridge has returned native ETH, they will do so via calling
                   * `RollupProcessor.receiveEthPayment(uint256 interactionNonce)`.
                   * To summarise the issue, we must solve for the following:
                   * 1. We need to be able to read the `ethPayments` state variable to determine how much Eth has been sent (and reset it)
                   * 2. We must encapsulate the entire defi interaction flow via a 'delegatecall' so that we can safely revert
                   *    all token/eth transfers if the defi interaction fails, *without* throwing the entire rollup transaction
                   * 3. We don't want to directly call `delegateCall` on RollupProcessor.sol to minimise the attack surface against delegatecall re-entrancy exploits
                   *
                   * Solution is to pass the ethPayments.slot storage slot in as a param during the delegateCall and update in assembly via `sstore`
                   * We could achieve the same effect via getters/setters on the function, but that would be expensive as that would trigger additional `call` opcodes.
                   * We could *also* just hard-code the slot value, but that is quite brittle as
                   * any re-ordering of storage variables during development would require updating the hardcoded constant
                   *
                   * @return outputValueA outputvalueB isAsync
                   * outputValueA = the number of outputAssetA tokens we must recover from the bridge
                   * outputValueB = the number of outputAssetB tokens we must recover from the bridge
                   * isAsync describes whether the defi interaction has instantly resolved, or if the interaction must be finalised in a future Eth block
                   * if isAsync == true, outputValueA and outputValueB must both equal 0
                   */
                  function convert(
                      address bridgeAddress,
                      AztecTypes.AztecAsset memory inputAssetA,
                      AztecTypes.AztecAsset memory inputAssetB,
                      AztecTypes.AztecAsset memory outputAssetA,
                      AztecTypes.AztecAsset memory outputAssetB,
                      uint256 totalInputValue,
                      uint256 interactionNonce,
                      uint256 auxInputData, // (auxData)
                      uint256 ethPaymentsSlot,
                      address rollupBeneficiary
                  )
                      external
                      returns (
                          uint256 outputValueA,
                          uint256 outputValueB,
                          bool isAsync
                      )
                  {
                      if (inputAssetA.assetType == AztecTypes.AztecAssetType.ERC20) {
                          // Transfer totalInputValue to the bridge contract if erc20. ETH is sent on call to convert.
                          TokenTransfers.safeTransferTo(inputAssetA.erc20Address, bridgeAddress, totalInputValue);
                      }
                      if (inputAssetB.assetType == AztecTypes.AztecAssetType.ERC20) {
                          // Transfer totalInputValue to the bridge contract if erc20. ETH is sent on call to convert.
                          TokenTransfers.safeTransferTo(inputAssetB.erc20Address, bridgeAddress, totalInputValue);
                      }
                      // Call bridge.convert(), which will return output values for the two output assets.
                      // If input is ETH, send it along with call to convert.
                      uint256 ethValue = (inputAssetA.assetType == AztecTypes.AztecAssetType.ETH ||
                          inputAssetB.assetType == AztecTypes.AztecAssetType.ETH)
                          ? totalInputValue
                          : 0;
                      (outputValueA, outputValueB, isAsync) = IDefiBridge(bridgeAddress).convert{value: ethValue}(
                          inputAssetA,
                          inputAssetB,
                          outputAssetA,
                          outputAssetB,
                          totalInputValue,
                          interactionNonce,
                          uint64(auxInputData),
                          rollupBeneficiary
                      );
                      if (isAsync) {
                          if (outputValueA > 0 || outputValueB > 0) {
                              revert ASYNC_NONZERO_OUTPUT_VALUES(outputValueA, outputValueB);
                          }
                      } else {
                          address bridgeAddressCopy = bridgeAddress; // stack overflow workaround
                          if (outputValueA >= (1 << 252)) {
                              revert OUTPUT_A_EXCEEDS_252_BITS(outputValueA);
                          }
                          if (outputValueB >= (1 << 252)) {
                              revert OUTPUT_B_EXCEEDS_252_BITS(outputValueB);
                          }
                          recoverTokens(outputAssetA, outputValueA, interactionNonce, bridgeAddressCopy, ethPaymentsSlot);
                          recoverTokens(outputAssetB, outputValueB, interactionNonce, bridgeAddressCopy, ethPaymentsSlot);
                      }
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              import {AztecTypes} from '../AztecTypes.sol';
              interface IDefiBridge {
                  function convert(
                      AztecTypes.AztecAsset memory inputAssetA,
                      AztecTypes.AztecAsset memory inputAssetB,
                      AztecTypes.AztecAsset memory outputAssetA,
                      AztecTypes.AztecAsset memory outputAssetB,
                      uint256 totalInputValue,
                      uint256 interactionNonce,
                      uint64 auxData,
                      address rollupBeneficiary
                  )
                      external
                      payable
                      returns (
                          uint256 outputValueA,
                          uint256 outputValueB,
                          bool isAsync
                      );
                  function canFinalise(uint256 interactionNonce) external view returns (bool);
                  function finalise(
                      AztecTypes.AztecAsset memory inputAssetA,
                      AztecTypes.AztecAsset memory inputAssetB,
                      AztecTypes.AztecAsset memory outputAssetA,
                      AztecTypes.AztecAsset memory outputAssetB,
                      uint256 interactionNonce,
                      uint64 auxData
                  )
                      external
                      payable
                      returns (
                          uint256 outputValueA,
                          uint256 outputValueB,
                          bool interactionCompleted
                      );
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              library AztecTypes {
                  enum AztecAssetType {
                      NOT_USED,
                      ETH,
                      ERC20,
                      VIRTUAL
                  }
                  struct AztecAsset {
                      uint256 id;
                      address erc20Address;
                      AztecAssetType assetType;
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              /**
               * @title TokenTransfers
               * @dev Provides functions to safely call `transfer` and `transferFrom` methods on ERC20 tokens,
               * as well as the ability to call `transfer` and `transferFrom` without bubbling up errors
               */
              library TokenTransfers {
                  bytes4 private constant TRANSFER_SELECTOR = 0xa9059cbb; // bytes4(keccak256('transfer(address,uint256)'));
                  bytes4 private constant TRANSFER_FROM_SELECTOR = 0x23b872dd; // bytes4(keccak256('transferFrom(address,address,uint256)'));
                  /**
                   * @dev Safely call ERC20.transfer, handles tokens that do not throw on transfer failure or do not return transfer result
                   * @param tokenAddress Where does the token live?
                   * @param to Who are we sending tokens to?
                   * @param amount How many tokens are we transferring?
                   */
                  function safeTransferTo(
                      address tokenAddress,
                      address to,
                      uint256 amount
                  ) internal {
                      // The ERC20 token standard states that:
                      // 1. failed transfers must throw
                      // 2. the result of the transfer (success/fail) is returned as a boolean
                      // Some token contracts don't implement the spec correctly and will do one of the following:
                      // 1. Contract does not throw if transfer fails, instead returns false
                      // 2. Contract throws if transfer fails, but does not return any boolean value
                      // We can check for these by evaluating the following:
                      // | call succeeds? (c) | return value (v) | returndatasize == 0 (r)| interpreted result |
                      // | ---                | ---              | ---                    | ---                |
                      // | false              | false            | false                  | transfer fails     |
                      // | false              | false            | true                   | transfer fails     |
                      // | false              | true             | false                  | transfer fails     |
                      // | false              | true             | true                   | transfer fails     |
                      // | true               | false            | false                  | transfer fails     |
                      // | true               | false            | true                   | transfer succeeds  |
                      // | true               | true             | false                  | transfer succeeds  |
                      // | true               | true             | true                   | transfer succeeds  |
                      //
                      // i.e. failure state = !(c && (r || v))
                      assembly {
                          let ptr := mload(0x40)
                          mstore(ptr, TRANSFER_SELECTOR)
                          mstore(add(ptr, 0x4), to)
                          mstore(add(ptr, 0x24), amount)
                          let call_success := call(gas(), tokenAddress, 0, ptr, 0x44, 0x00, 0x20)
                          let result_success := or(iszero(returndatasize()), and(mload(0), 1))
                          if iszero(and(call_success, result_success)) {
                              returndatacopy(0, 0, returndatasize())
                              revert(0, returndatasize())
                          }
                      }
                  }
                  /**
                   * @dev Safely call ERC20.transferFrom, handles tokens that do not throw on transfer failure or do not return transfer result
                   * @param tokenAddress Where does the token live?
                   * @param source Who are we transferring tokens from
                   * @param target Who are we transferring tokens to?
                   * @param amount How many tokens are being transferred?
                   */
                  function safeTransferFrom(
                      address tokenAddress,
                      address source,
                      address target,
                      uint256 amount
                  ) internal {
                      assembly {
                          // call tokenAddress.transferFrom(source, target, value)
                          let mPtr := mload(0x40)
                          mstore(mPtr, TRANSFER_FROM_SELECTOR)
                          mstore(add(mPtr, 0x04), source)
                          mstore(add(mPtr, 0x24), target)
                          mstore(add(mPtr, 0x44), amount)
                          let call_success := call(gas(), tokenAddress, 0, mPtr, 0x64, 0x00, 0x20)
                          let result_success := or(iszero(returndatasize()), and(mload(0), 1))
                          if iszero(and(call_success, result_success)) {
                              returndatacopy(0, 0, returndatasize())
                              revert(0, returndatasize())
                          }
                      }
                  }
                  /**
                   * @dev Calls ERC(tokenAddress).transfer(to, amount). Errors are ignored! Use with caution!
                   * @param tokenAddress Where does the token live?
                   * @param to Who are we sending to?
                   * @param amount How many tokens are being transferred?
                   * @param gasToSend Amount of gas to send the contract. If value is 0, function uses gas() instead
                   */
                  function transferToDoNotBubbleErrors(
                      address tokenAddress,
                      address to,
                      uint256 amount,
                      uint256 gasToSend
                  ) internal {
                      assembly {
                          let callGas := gas()
                          if gasToSend {
                              callGas := gasToSend
                          }
                          let ptr := mload(0x40)
                          mstore(ptr, TRANSFER_SELECTOR)
                          mstore(add(ptr, 0x4), to)
                          mstore(add(ptr, 0x24), amount)
                          pop(call(callGas, tokenAddress, 0, ptr, 0x44, 0x00, 0x00))
                      }
                  }
                  /**
                   * @dev Calls ERC(tokenAddress).transferFrom(source, target, amount). Errors are ignored! Use with caution!
                   * @param tokenAddress Where does the token live?
                   * @param source Who are we transferring tokens from
                   * @param target Who are we transferring tokens to?
                   * @param amount How many tokens are being transferred?
                   * @param gasToSend Amount of gas to send the contract. If value is 0, function uses gas() instead
                   */
                  function transferFromDoNotBubbleErrors(
                      address tokenAddress,
                      address source,
                      address target,
                      uint256 amount,
                      uint256 gasToSend
                  ) internal {
                      assembly {
                          let callGas := gas()
                          if gasToSend {
                              callGas := gasToSend
                          }
                          let mPtr := mload(0x40)
                          mstore(mPtr, TRANSFER_FROM_SELECTOR)
                          mstore(add(mPtr, 0x04), source)
                          mstore(add(mPtr, 0x24), target)
                          mstore(add(mPtr, 0x44), amount)
                          pop(call(callGas, tokenAddress, 0, mPtr, 0x64, 0x00, 0x00))
                      }
                  }
              }
              

              File 12 of 12: Subsidy
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec.
              pragma solidity >=0.8.4;
              import {ISubsidy} from "./interfaces/ISubsidy.sol";
              /**
               * @title Subsidy
               * @notice A contract which allows anyone to subsidize a bridge
               * @author Jan Benes
               * @dev The goal of this contract is to allow anyone to subsidize a bridge. How the subsidy works is that when a bridge
               *      is subsidized it can call `claimSubsidy(...)` method and in that method the corresponding subsidy amount
               *      unlocks and can be claimed by the beneficiary. Beneficiary is expected to be the beneficiary address passed as
               *      part of the rollup data by the provider. When sufficient subsidy is present it makes it profitable for
               *      the rollup provider to execute a bridge call even when only a small amounts of user fees can be extracted. This
               *      effectively makes it possible for calls to low-use bridges to be included in a rollup block. Without subsidy,
               *      it might happen that the UX of these bridges would dramatically deteriorate since user might wait for a long
               *      time before her/his bridge call gets processed.
               *
               *      The subsidy is defined by a `gasPerMinute` amount and along with time since last interaction and the current
               *      base fee will be used to compute the amount of Eth that should be paid out to the rollup beneficiary.
               *      The subsidy will only ever grow to `Subsidy.gasUsage` gas. This value is the expected gas usage of the specific
               *      bridge interaction. Since only the base-fee is used, there will practically not be a free bridge interaction
               *      because the priority fee is paid on top. However the fee could be tiny in comparison -> over time user fee goes
               *      toward just paying the priority fee/tip. Making the subsidy payout dependent upon the time since last bridge
               *      call/interaction makes the probability of the bridge call being executed grow with time.
               *
               *      `Subsidy.minGasPerMinute` is used to define minimum acceptable value of `Subsidy.gasPerMinute' when subsidy
               *      is created. This is necessary because only 1 subsidy can be present at one time and not doing the check would
               *      open an opportunity for a griefing attack - attacker setting low subsidy which would take a long time to run
               *      out and effectively making it impossible for a legitimate subsidizer to subsidize a bridge.
               *
               *      Since we want to allow a subsidizer to subsidize specific bridge calls/interactions and not only all
               *      calls/interactions we use a `criteria` to distinguish different calls. The `criteria` value is computed in
               *      the bridge, and may use the inputs to `convert(...)`. It is expected to be different in different bridges
               *      (e.g. Uniswap bridge might compute this value based on `_inputAssetA`, `_outputAssetA` and a path defined in
               *      `_auxData`).
               */
              contract Subsidy is ISubsidy {
                  error ArrayLengthsDoNotMatch();
                  error GasPerMinuteTooLow();
                  error AlreadySubsidized();
                  error GasUsageNotSet();
                  error NotSubsidised();
                  error SubsidyTooLow();
                  error EthTransferFailed();
                  event Subsidized(address indexed bridge, uint256 indexed criteria, uint128 available, uint32 gasPerMinute);
                  event BeneficiaryRegistered(address indexed beneficiary);
                  /**
                   * @notice Container for Beneficiary related information
                   * @member claimable The amount of eth that is owed this beneficiary
                   * @member registered A flag indicating if registered or not. Used to "poke" storage
                   */
                  struct Beneficiary {
                      uint248 claimable;
                      bool registered;
                  }
                  // @dev Using min possible `msg.value` upon subsidizing in order to limit possibility of front running attacks
                  // --> e.g. attacker front-running real subsidy tx by sending 1 wei value tx making the real one revert
                  uint256 public constant override(ISubsidy) MIN_SUBSIDY_VALUE = 1e17;
                  // address bridge => uint256 criteria => Subsidy subsidy
                  mapping(address => mapping(uint256 => Subsidy)) public subsidies;
                  // address beneficiaryAddress => Beneficiary beneficiary
                  mapping(address => Beneficiary) public beneficiaries;
                  /**
                   * @notice Fetch the claimable amount for a specific beneficiary
                   * @param _beneficiary The address of the beneficiary to query
                   * @return The amount of claimable ETH for `_beneficiary`
                   */
                  function claimableAmount(address _beneficiary) external view override(ISubsidy) returns (uint256) {
                      return beneficiaries[_beneficiary].claimable;
                  }
                  /**
                   * @notice Is the `_beneficiary` registered or not
                   * @param _beneficiary The address of the beneficiary to check
                   * @return True if the `_beneficiary` is registered, false otherwise
                   */
                  function isRegistered(address _beneficiary) external view override(ISubsidy) returns (bool) {
                      return beneficiaries[_beneficiary].registered;
                  }
                  /**
                   * @notice Get the data related to a specific subsidy
                   * @param _bridge The address of the bridge getting the subsidy
                   * @param _criteria The criteria of the subsidy
                   * @return The subsidy data object
                   */
                  function getSubsidy(address _bridge, uint256 _criteria) external view override(ISubsidy) returns (Subsidy memory) {
                      return subsidies[_bridge][_criteria];
                  }
                  /**
                   * @notice Sets multiple `Subsidy.gasUsage` values for multiple criteria values
                   * @dev This function has to be called from the bridge
                   * @param _criteria An array of values each defining a specific bridge call
                   * @param _gasUsage An array of gas usage for subsidized bridge calls.
                   *                  at the same index in `_criteria` array
                   * @param _minGasPerMinute An array of minimum amounts of gas per minute that subsidizer has to subsidize for
                   *                         the provided criteria.
                   */
                  function setGasUsageAndMinGasPerMinute(
                      uint256[] calldata _criteria,
                      uint32[] calldata _gasUsage,
                      uint32[] calldata _minGasPerMinute
                  ) external override(ISubsidy) {
                      uint256 criteriasLength = _criteria.length;
                      if (criteriasLength != _gasUsage.length || criteriasLength != _minGasPerMinute.length) {
                          revert ArrayLengthsDoNotMatch();
                      }
                      for (uint256 i; i < criteriasLength; ) {
                          setGasUsageAndMinGasPerMinute(_criteria[i], _gasUsage[i], _minGasPerMinute[i]);
                          unchecked {
                              ++i;
                          }
                      }
                  }
                  /**
                   * @notice Registers address of a beneficiary to receive subsidies
                   * @param _beneficiary Address which is going to receive the subsidy
                   * @dev This registration is necessary in order to have near constant gas costs in the `claimSubsidy(...)` function.
                   *      By writing to the storage slot we make sure that the storage slot is set and later on we pay
                   *      a reliable gas cost when updating it. This is important because it's desirable for the cost of
                   *      IDefiBridge.convert(...) function to be as predictable as possible. If the cost is too variable users would
                   *      overpay since RollupProcessor works with constant gas limits.
                   */
                  function registerBeneficiary(address _beneficiary) external override(ISubsidy) {
                      beneficiaries[_beneficiary].registered = true;
                      emit BeneficiaryRegistered(_beneficiary);
                  }
                  /**
                   * @notice Sets subsidy for a given `_bridge` and `_criteria`
                   * @param _bridge Address of the bridge to subsidize
                   * @param _criteria A value defining the specific bridge call to subsidize
                   * @param _gasPerMinute A value defining the "rate" at which the subsidy will be released
                   * @dev Reverts if any of these is true: 1) `_gasPerMinute` <= `sub.minGasPerMinute`,
                   *                                       2) subsidy funded before and not yet claimed: `subsidy.available` > 0,
                   *                                       3) subsidy.gasUsage not set: `subsidy.gasUsage` == 0,
                   *                                       4) ETH value sent too low: `msg.value` < `MIN_SUBSIDY_VALUE`.
                   */
                  function subsidize(
                      address _bridge,
                      uint256 _criteria,
                      uint32 _gasPerMinute
                  ) external payable override(ISubsidy) {
                      if (msg.value < MIN_SUBSIDY_VALUE) {
                          revert SubsidyTooLow();
                      }
                      // Caching subsidy in order to minimize number of SLOADs and SSTOREs
                      Subsidy memory sub = subsidies[_bridge][_criteria];
                      if (_gasPerMinute < sub.minGasPerMinute) {
                          revert GasPerMinuteTooLow();
                      }
                      if (sub.available > 0) {
                          revert AlreadySubsidized();
                      }
                      if (sub.gasUsage == 0) {
                          revert GasUsageNotSet();
                      }
                      sub.available = uint128(msg.value); // safe as an overflow would require more assets than exists.
                      sub.lastUpdated = uint32(block.timestamp);
                      sub.gasPerMinute = _gasPerMinute;
                      subsidies[_bridge][_criteria] = sub;
                      emit Subsidized(_bridge, _criteria, sub.available, sub.gasPerMinute);
                  }
                  /**
                   * @notice Tops up an existing subsidy corresponding to a given `_bridge` and `_criteria` with `msg.value`
                   * @param _bridge Address of the bridge to subsidize
                   * @param _criteria A value defining the specific bridge call to subsidize
                   * @dev Reverts if `available` is 0.
                   */
                  function topUp(address _bridge, uint256 _criteria) external payable override(ISubsidy) {
                      // Caching subsidy in order to minimize number of SLOADs and SSTOREs
                      Subsidy memory sub = subsidies[_bridge][_criteria];
                      if (sub.available == 0) {
                          revert NotSubsidised();
                      }
                      unchecked {
                          sub.available += uint128(msg.value);
                      }
                      subsidies[_bridge][_criteria] = sub;
                      emit Subsidized(_bridge, _criteria, sub.available, sub.gasPerMinute);
                  }
                  /**
                   * @notice Computes and sends subsidy
                   * @param _criteria A value defining a specific bridge call
                   * @param _beneficiary Address which is going to receive the subsidy
                   * @return subsidy ETH amount which was added to the `_beneficiary` claimable balance
                   */
                  function claimSubsidy(uint256 _criteria, address _beneficiary) external override(ISubsidy) returns (uint256) {
                      if (_beneficiary == address(0)) {
                          return 0;
                      }
                      Beneficiary memory beneficiary = beneficiaries[_beneficiary];
                      if (!beneficiary.registered) {
                          return 0;
                      }
                      // Caching subsidy in order to minimize number of SLOADs and SSTOREs
                      Subsidy memory sub = subsidies[msg.sender][_criteria];
                      if (sub.available == 0) {
                          return 0;
                      }
                      uint256 subsidyAmount = _computeAccumulatedSubsidyAmount(sub);
                      if (subsidyAmount > 0) {
                          // It safe to update only when the value is claimed because this happens only in 3 situations:
                          //      1) Subsidy was already claimed in the same block and is no longer available (dt = 0),
                          //      2) there are no available assets (`sub.available` = 0) --> 0 would be already returned above,
                          //      3) the amount is small and gets rounded down to 0.
                          sub.lastUpdated = uint32(block.timestamp);
                          unchecked {
                              // safe as `subsidyAmount` is bounded by `sub.available`
                              sub.available -= uint128(subsidyAmount);
                              // safe as available is limited to u128
                              beneficiaries[_beneficiary].claimable = beneficiary.claimable + uint248(subsidyAmount);
                          }
                          subsidies[msg.sender][_criteria] = sub;
                      }
                      return subsidyAmount;
                  }
                  /**
                   * @notice Withdraws beneficiary's withdrawable balance
                   * @dev Beware that this can be called by anyone to force a payout to the beneficiary.
                   *      Done like this to support smart-contract beneficiaries that can handle eth, but not make the call itself.
                   * @param _beneficiary Address which is going to receive the subsidy
                   * @return - ETH amount which was sent to the `_beneficiary`
                   */
                  function withdraw(address _beneficiary) external override(ISubsidy) returns (uint256) {
                      uint256 withdrawableBalance = beneficiaries[_beneficiary].claimable;
                      // Immediately updating the balance to avoid re-entrancy attack
                      beneficiaries[_beneficiary].claimable = 0;
                      // Sending 30k gas in a call to allow receiver to be a multi-sig and write to storage
                      /* solhint-disable avoid-low-level-calls */
                      (bool success, ) = _beneficiary.call{value: withdrawableBalance, gas: 30000}("");
                      if (!success) {
                          revert EthTransferFailed();
                      }
                      return withdrawableBalance;
                  }
                  /**
                   * @notice Gets current accumulated subsidy amount for a given `_bridge` and `_criteria`
                   * @param _bridge Address of the subsidized bridge
                   * @param _criteria A value defining a specific bridge call
                   * @return - Accumulated subsidy amount (amount paid out if the bridge called `claimSubsidy(_criteria, ...)`)
                   */
                  function getAccumulatedSubsidyAmount(address _bridge, uint256 _criteria) external view returns (uint256) {
                      Subsidy memory sub = subsidies[_bridge][_criteria];
                      return _computeAccumulatedSubsidyAmount(sub);
                  }
                  /**
                   * @notice Sets `Subsidy.gasUsage` value for a given criteria
                   * @dev This function has to be called from the bridge
                   * @param _criteria A value defining a specific bridge call
                   * @param _gasUsage The gas usage of the subsidized action. Used as upper limit for subsidy.
                   * @param _minGasPerMinute Minimum amount of gas per minute that subsidizer has to subsidize
                   */
                  function setGasUsageAndMinGasPerMinute(
                      uint256 _criteria,
                      uint32 _gasUsage,
                      uint32 _minGasPerMinute
                  ) public override(ISubsidy) {
                      // Loading `sub` first in order to not overwrite `sub.available` in case this function was already called
                      // and a subsidy was set.
                      Subsidy memory sub = subsidies[msg.sender][_criteria];
                      sub.gasUsage = _gasUsage;
                      sub.minGasPerMinute = _minGasPerMinute;
                      subsidies[msg.sender][_criteria] = sub;
                  }
                  /**
                   * @notice Computes accumulated subsidy amount based on Subsidy struct and current block
                   * @param _subsidy Subsidy based on which to compute accumulated subsidy amount
                   * @return - Accumulated subsidy amount (amount paid out if the bridge called `claimSubsidy(_criteria, ...)`)
                   */
                  function _computeAccumulatedSubsidyAmount(Subsidy memory _subsidy) private view returns (uint256) {
                      unchecked {
                          // _sub.lastUpdated only update to block.timestamp, so can never be in the future
                          uint256 dt = block.timestamp - _subsidy.lastUpdated;
                          // time need to have passed for an incentive to have accrued
                          if (dt > 0) {
                              // The following should never overflow due to constraints on values.
                              // But if they do, it is bounded by the available subsidy
                              uint256 gasToCover = (dt * _subsidy.gasPerMinute) / 1 minutes;
                              uint256 ethToCover = (gasToCover < _subsidy.gasUsage ? gasToCover : _subsidy.gasUsage) * block.basefee;
                              return ethToCover < _subsidy.available ? ethToCover : _subsidy.available;
                          }
                      }
                      return 0;
                  }
              }
              // SPDX-License-Identifier: Apache-2.0
              // Copyright 2022 Aztec
              pragma solidity >=0.8.4;
              // @dev documentation of this interface is in its implementation (Subsidy contract)
              interface ISubsidy {
                  /**
                   * @notice Container for Subsidy related information
                   * @member available Amount of ETH remaining to be paid out
                   * @member gasUsage Amount of gas the interaction consumes (used to define max possible payout)
                   * @member minGasPerMinute Minimum amount of gas per minute the subsidizer has to subsidize
                   * @member gasPerMinute Amount of gas per minute the subsidizer is willing to subsidize
                   * @member lastUpdated Last time subsidy was paid out or funded (if not subsidy was yet claimed after funding)
                   */
                  struct Subsidy {
                      uint128 available;
                      uint32 gasUsage;
                      uint32 minGasPerMinute;
                      uint32 gasPerMinute;
                      uint32 lastUpdated;
                  }
                  function setGasUsageAndMinGasPerMinute(
                      uint256 _criteria,
                      uint32 _gasUsage,
                      uint32 _minGasPerMinute
                  ) external;
                  function setGasUsageAndMinGasPerMinute(
                      uint256[] calldata _criteria,
                      uint32[] calldata _gasUsage,
                      uint32[] calldata _minGasPerMinute
                  ) external;
                  function registerBeneficiary(address _beneficiary) external;
                  function subsidize(
                      address _bridge,
                      uint256 _criteria,
                      uint32 _gasPerMinute
                  ) external payable;
                  function topUp(address _bridge, uint256 _criteria) external payable;
                  function claimSubsidy(uint256 _criteria, address _beneficiary) external returns (uint256);
                  function withdraw(address _beneficiary) external returns (uint256);
                  // solhint-disable-next-line
                  function MIN_SUBSIDY_VALUE() external view returns (uint256);
                  function claimableAmount(address _beneficiary) external view returns (uint256);
                  function isRegistered(address _beneficiary) external view returns (bool);
                  function getSubsidy(address _bridge, uint256 _criteria) external view returns (Subsidy memory);
                  function getAccumulatedSubsidyAmount(address _bridge, uint256 _criteria) external view returns (uint256);
              }