{"file_path":"src/contracts/Governance.sol","creation_status":"success","source_code":"// SPDX-License-Identifier: BUSL-1.1\npragma solidity ^0.8.0;\n\nimport {ICrossChainForwarder} from 'aave-delivery-infrastructure/contracts/interfaces/ICrossChainForwarder.sol';\nimport {GovernanceCore, PayloadsControllerUtils} from './GovernanceCore.sol';\nimport {IGovernance, IGovernancePowerStrategy, IGovernanceCore} from '../interfaces/IGovernance.sol';\nimport {Errors} from './libraries/Errors.sol';\n\n/**\n * @title Governance\n * @author BGD Labs\n * @notice this contract contains the logic to communicate with execution chain.\n * @dev This contract implements the abstract contract GovernanceCore\n */\ncontract Governance is GovernanceCore, IGovernance {\n  /// @inheritdoc IGovernance\n  address public immutable CROSS_CHAIN_CONTROLLER;\n\n  // gas limit used for sending the vote result\n  uint256 private _gasLimit;\n\n  /**\n   * @param crossChainController address of current network message controller (cross chain controller or same chain controller)\n   * @param coolDownPeriod time that should pass before proposal will be moved to vote, in seconds\n   * @param cancellationFeeCollector address of the Aave collector to send cancellation fee\n   */\n  constructor(\n    address crossChainController,\n    uint256 coolDownPeriod,\n    address cancellationFeeCollector\n  ) GovernanceCore(coolDownPeriod, cancellationFeeCollector) {\n    require(\n      crossChainController != address(0),\n      Errors.G_INVALID_CROSS_CHAIN_CONTROLLER_ADDRESS\n    );\n    CROSS_CHAIN_CONTROLLER = crossChainController;\n  }\n\n  /// @inheritdoc IGovernance\n  function initializeWithRevision(uint256 gasLimit) external reinitializer(3) {\n    _updateGasLimit(gasLimit);\n    IGovernanceCore.SetVotingConfigInput[]\n      memory votingConfigs = new IGovernanceCore.SetVotingConfigInput[](2);\n\n    SetVotingConfigInput memory level1Config = SetVotingConfigInput({\n      accessLevel: PayloadsControllerUtils.AccessControl.Level_1,\n      coolDownBeforeVotingStart: 1 days,\n      votingDuration: 3 days,\n      yesThreshold: 320_000 ether,\n      yesNoDifferential: 80_000 ether,\n      minPropositionPower: 80_000 ether\n    });\n    votingConfigs[0] = level1Config;\n\n    IGovernanceCore.SetVotingConfigInput memory level2Config = IGovernanceCore\n      .SetVotingConfigInput({\n        accessLevel: PayloadsControllerUtils.AccessControl.Level_2,\n        coolDownBeforeVotingStart: 1 days,\n        votingDuration: 10 days,\n        yesThreshold: 1_040_000 ether,\n        yesNoDifferential: 1_040_000 ether,\n        minPropositionPower: 200_000 ether\n      });\n    votingConfigs[1] = level2Config;\n\n    _setVotingConfigs(votingConfigs);\n  }\n\n  /// @inheritdoc IGovernance\n  function initialize(\n    address owner,\n    address guardian,\n    IGovernancePowerStrategy powerStrategy,\n    IGovernanceCore.SetVotingConfigInput[] calldata votingConfigs,\n    address[] calldata votingPortals,\n    uint256 gasLimit,\n    uint256 cancellationFee\n  ) external initializer {\n    _initializeCore(\n      owner,\n      guardian,\n      powerStrategy,\n      votingConfigs,\n      votingPortals,\n      cancellationFee\n    );\n    _updateGasLimit(gasLimit);\n  }\n\n  /// @inheritdoc IGovernance\n  function getGasLimit() external view returns (uint256) {\n    return _gasLimit;\n  }\n\n  /// @inheritdoc IGovernance\n  function updateGasLimit(uint256 gasLimit) external onlyOwner {\n    _updateGasLimit(gasLimit);\n  }\n\n  /**\n   * @notice method to send a payload to execution chain\n   * @param payload object with the information needed for execution\n   * @param proposalVoteActivationTimestamp proposal vote activation timestamp in seconds\n   */\n  function _forwardPayloadForExecution(\n    PayloadsControllerUtils.Payload memory payload,\n    uint40 proposalVoteActivationTimestamp\n  ) internal override {\n    ICrossChainForwarder(CROSS_CHAIN_CONTROLLER).forwardMessage(\n      payload.chain,\n      payload.payloadsController,\n      _gasLimit,\n      abi.encode(\n        payload.payloadId,\n        payload.accessLevel,\n        proposalVoteActivationTimestamp\n      )\n    );\n  }\n\n  /**\n   * @notice method to update the gasLimit\n   * @param gasLimit the new gas limit\n   */\n  function _updateGasLimit(uint256 gasLimit) internal {\n    _gasLimit = gasLimit;\n\n    emit GasLimitUpdated(gasLimit);\n  }\n}\n","deployed_bytecode":"0x60806040526004361061023a5760003560e01c80638da5cb5b1161012e578063c3b4b661116100ab578063efe61a2f1161006f578063efe61a2f14610784578063f2fde38b146107a4578063f687d12a146107c4578063f6ead0b9146107e4578063fc5253951461080457600080fd5b8063c3b4b661146106cd578063c4956366146106ed578063c7f758a814610721578063e0a8f6f51461074e578063eaf1061c1461076e57600080fd5b8063a3f4df7e116100f2578063a3f4df7e146105d4578063ad6036cf1461061f578063b26ccf4714610662578063b3809b1314610679578063c3a76d921461069957600080fd5b80638da5cb5b146105395780639043ffc31461055d5780639080936f1461057d57806398e527d3146105aa5780639c0401c6146105bf57600080fd5b806338fe05be116101bc5780635ca4d552116101805780635ca4d5521461048457806362af1ed6146104b45780636e99d52f146104d0578063715018a61461050457806371b32bb11461051957600080fd5b806338fe05be146104005780633bec1bfc14610415578063452a93201461042857806346a3d430146104465780634e3523191461046457600080fd5b806319ebdc341161020357806319ebdc34146102f85780631a93d1c3146103185780631aefa2d1146103375780631c84e3211461035757806321916b81146103d357600080fd5b80629927451461023f578063079b1fdd146102615780630d61b519146102815780630f3424bb146102a1578063133539ec146102d8575b600080fd5b34801561024b57600080fd5b5061025f61025a366004613a3c565b610824565b005b34801561026d57600080fd5b5061025f61027c366004613a3c565b6108d5565b34801561028d57600080fd5b5061025f61029c366004613a59565b6108e9565b3480156102ad57600080fd5b506002546001600160a01b03165b6040516001600160a01b0390911681526020015b60405180910390f35b3480156102e457600080fd5b5061025f6102f3366004613a72565b610c94565b34801561030457600080fd5b5061025f610313366004613b33565b610e45565b34801561032457600080fd5b50600b545b6040519081526020016102cf565b34801561034357600080fd5b5061025f610352366004613a59565b610e89565b34801561036357600080fd5b50610377610372366004613b82565b610e9a565b6040516102cf9190600060a08201905062ffffff80845116835280602085015116602084015250604083015166ffffffffffffff8082166040850152806060860151166060850152806080860151166080850152505092915050565b3480156103df57600080fd5b506103f36103ee366004613b9f565b610f5b565b6040516102cf9190613bcb565b34801561040c57600080fd5b50600654610329565b610329610423366004613c18565b610f93565b34801561043457600080fd5b506001546001600160a01b03166102bb565b34801561045257600080fd5b506a0422ca8b0a00a425000000610329565b34801561047057600080fd5b5061025f61047f366004613ce9565b6114ce565b34801561049057600080fd5b506104a461049f366004613a3c565b611531565b60405190151581526020016102cf565b3480156104c057600080fd5b50610329670de0b6b3a764000081565b3480156104dc57600080fd5b506103297f000000000000000000000000000000000000000000000000000000000000000081565b34801561051057600080fd5b5061025f61154f565b34801561052557600080fd5b5061025f610534366004613d3b565b611563565b34801561054557600080fd5b506000546201000090046001600160a01b03166102bb565b34801561056957600080fd5b5061025f610578366004613b33565b611896565b34801561058957600080fd5b5061059d610598366004613a59565b611adf565b6040516102cf9190613da1565b3480156105b657600080fd5b50600354610329565b3480156105cb57600080fd5b50600454610329565b3480156105e057600080fd5b50610612604051806040016040528060128152602001714161766520476f7665726e616e636520763360701b81525081565b6040516102cf9190613dff565b34801561062b57600080fd5b506102bb61063a366004613b9f565b6001600160a01b03918216600090815260096020908152604080832093835292905220541690565b34801561066e57600080fd5b5061032962278d0081565b34801561068557600080fd5b5061025f610694366004613e12565b611afd565b3480156106a557600080fd5b506102bb7f000000000000000000000000464c71f6c2f760dda6093dcb91c24c39e5d6e18c81565b3480156106d957600080fd5b5061025f6106e8366004613b33565b611be1565b3480156106f957600080fd5b506102bb7f000000000000000000000000ed42a7d8559a463722ca4bed50e0cc05a386b0e181565b34801561072d57600080fd5b5061074161073c366004613a59565b611c28565b6040516102cf9190613f50565b34801561075a57600080fd5b5061025f610769366004613a59565b611f04565b34801561077a57600080fd5b506203f480610329565b34801561079057600080fd5b5061025f61079f366004613a59565b612100565b3480156107b057600080fd5b5061025f6107bf366004613a3c565b612302565b3480156107d057600080fd5b5061025f6107df366004613a59565b612378565b3480156107f057600080fd5b5061025f6107ff366004613a59565b612389565b34801561081057600080fd5b5061025f61081f366004613a3c565b6126de565b61082c6126ef565b6006546040805180820190915260018152603160f81b6020820152901561086f5760405162461bcd60e51b81526004016108669190613dff565b60405180910390fd5b506040805160018082528183019092526000916020808301908036833701905050905081816000815181106108a6576108a661409b565b60200260200101906001600160a01b031690816001600160a01b0316815250506108d181600161273c565b5050565b6108dd61287f565b6108e6816128e0565b50565b6000818152600760205260409020600361090282612a0f565b600781111561091357610913613d77565b14604051806040016040528060018152602001603760f81b8152509061094c5760405162461bcd60e51b81526004016108669190613dff565b508054610988907f000000000000000000000000000000000000000000000000000000000000000090600160781b900464ffffffffff166140c7565b42101560405180604001604052806002815260200161031360f41b815250906109c45760405162461bcd60e51b81526004016108669190613dff565b508054610ada90600890600090610100900460ff1660028111156109ea576109ea613d77565b60028111156109fb576109fb613d77565b81526020808201929092526040908101600020815160a081018352905462ffffff808216835263010000008204169382019390935266ffffffffffffff600160301b8404811682840152600160681b840481166060830152600160a01b90930490921660808301526002546001850154915163853bcd0360e01b81526001600160a01b03928316600482015291169063853bcd03906024015b602060405180830381865afa158015610ab1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad591906140da565b612acc565b604051806040016040528060018152602001600d60fa1b81525090610b125760405162461bcd60e51b81526004016108669190613dff565b50805460ff1916600417815560005b6007820154811015610c64576000826007018281548110610b4457610b4461409b565b9060005260206000209060020201604051806080016040529081600082015481526020016001820160009054906101000a900460ff166002811115610b8b57610b8b613d77565b6002811115610b9c57610b9c613d77565b8152600191909101546001600160a01b03610100820416602083015264ffffffffff600160a81b90910481166040909201919091528454919250610bea918391600160501b90910416612af8565b80516040808301516060808501516007880154845164ffffffffff909216825260208201889052938101939093526001600160a01b039091169187917f9c687134d572ff69f3e23f40470562650574c5c7cab9f535268763b2d00da65b910160405180910390a45080610c5c816140f3565b915050610b21565b5060405182907f712ae1383f79ac853f8d882153778e0260ef8f03b504e2866e0593e04d2b291f90600090a25050565b60005b81811015610e40576000838383818110610cb357610cb361409b565b9050604002016020013590506000336001600160a01b0316858585818110610cdd57610cdd61409b565b610cf39260206040909202019081019150613a3c565b6001600160a01b031603610d08576000610d30565b848484818110610d1a57610d1a61409b565b610d309260206040909202019081019150613a3c565b3360009081526009602090815260408083208684529091529020549091506001600160a01b03168015610d8c576001600160a01b0381166000908152600a602090815260408083208684529091529020610d8a9033612bc7565b505b6001600160a01b03821615610dca576001600160a01b0382166000908152600a602090815260408083208684529091529020610dc89033612bdc565b505b33600081815260096020908152604080832087845290915280822080546001600160a01b0319166001600160a01b0387169081179091559051869391927f918b5bd4499a75f73bb64f14ae0254255f5421d0ecc4dd853c7bfdd7cf65e8fd91a45050508080610e38906140f3565b915050610c97565b505050565b610e4d61287f565b6108d18282808060200260200160405190810160405280939291908181526020018383602002808284376000920182905250925061273c915050565b610e9161287f565b6108e681612bf1565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915260086000836002811115610edb57610edb613d77565b6002811115610eec57610eec613d77565b81526020808201929092526040908101600020815160a081018352905462ffffff808216835263010000008204169382019390935266ffffffffffffff600160301b8404811692820192909252600160681b830482166060820152600160a01b90920416608082015292915050565b6001600160a01b0382166000908152600a602090815260408083208484529091529020606090610f8a90612c2c565b90505b92915050565b6040805180820190915260018152601960f91b602082015260009084610fcc5760405162461bcd60e51b81526004016108669190613dff565b50604080518082019091526002815261353960f01b6020820152826110045760405162461bcd60e51b81526004016108669190613dff565b506004543414604051806040016040528060028152602001611c9960f11b815250906110435760405162461bcd60e51b81526004016108669190613dff565b5061104d83611531565b604051806040016040528060018152602001603360f81b815250906110855760405162461bcd60e51b81526004016108669190613dff565b506003805460009182611097836140f3565b909155506000818152600760205260408120919250805b878110156112d05760008989838181106110ca576110ca61409b565b90506080020160200160208101906110e29190613b82565b60028111156110f3576110f3613d77565b1160405180604001604052806002815260200161036360f41b8152509061112d5760405162461bcd60e51b81526004016108669190613dff565b5060008989838181106111425761114261409b565b905060800201604001602081019061115a9190613a3c565b6001600160a01b0316141560405180604001604052806002815260200161363160f01b8152509061119e5760405162461bcd60e51b81526004016108669190613dff565b5060008989838181106111b3576111b361409b565b9050608002016000013511604051806040016040528060028152602001611b1960f11b815250906111f75760405162461bcd60e51b81526004016108669190613dff565b508260070189898381811061120e5761120e61409b565b83546001810185556000948552602090942060809091029290920192600202909101905061123c828261410c565b505081600281111561125057611250613d77565b8989838181106112625761126261409b565b905060800201602001602081019061127a9190613b82565b600281111561128b5761128b613d77565b11156112be578888828181106112a3576112a361409b565b90506080020160200160208101906112bb9190613b82565b91505b806112c8816140f3565b9150506110ae565b506000600860008360028111156112e9576112e9613d77565b60028111156112fa576112fa613d77565b81526020808201929092526040908101600020815160a081018352905462ffffff808216835263010000008204169382019390935266ffffffffffffff600160301b8404811682840152600160681b840481166060830152600160a01b9093049092166080830152600254905163853bcd0360e01b8152336004820181905292935061139c9184916001600160a01b039091169063853bcd0390602401610a94565b604051806040016040528060018152602001600d60fa1b815250906113d45760405162461bcd60e51b81526004016108669190613dff565b508354600160ff1982168117865580860180546001600160a01b0319166001600160a01b0385161790558491869161ffff199091161761010083600281111561141f5761141f613d77565b0217905550600284810180546001600160a01b0319166001600160a01b038b16179055845466ffffffffff00001916620100004264ffffffffff160217855560048501889055346006860155839081111561147c5761147c613d77565b816001600160a01b0316867fcc914becfa276bbc067049bf8db2d34ebbdc1bafa851e4d4936aaed376c08dbe8a6040516114b891815260200190565b60405180910390a4509298975050505050505050565b6114d661287f565b6108d18282808060200260200160405190810160405280939291908181526020016000905b828210156115275761151860c083028601368190038101906141dd565b815260200190600101906114fb565b5050505050612c39565b6001600160a01b031660009081526005602052604090205460ff1690565b61155761287f565b61156160006133c6565b565b600083815260076020526040902060028101546001600160a01b03163381148015611592575061159281611531565b604051806040016040528060018152602001603960f81b815250906115ca5760405162461bcd60e51b81526004016108669190613dff565b5060026115d683612a0f565b60078111156115e7576115e7613d77565b14604051806040016040528060018152602001601b60f91b815250906116205760405162461bcd60e51b81526004016108669190613dff565b50815461164790600160501b810464ffffffffff1690600160381b900462ffffff1661426c565b64ffffffffff16421160405180604001604052806002815260200161343560f01b815250906116895760405162461bcd60e51b81526004016108669190613dff565b5081546000906008908290610100900460ff1660028111156116ad576116ad613d77565b60028111156116be576116be613d77565b81526020808201929092526040908101600020815160a081018352905462ffffff808216835263010000008204169382019390935266ffffffffffffff600160301b8404811682840152600160681b840481166060830152600160a01b90930490921660808301526001600160801b03868116600160801b029088161760058601556002546001860154915163853bcd0360e01b81526001600160a01b03928316600482015292935061177f9284929091169063853bcd0390602401610a94565b8015611799575061179981866001600160801b0316613421565b80156117bd57506117bd81866001600160801b0316866001600160801b0316613444565b1561183d57825473ffffffffff0000000000000000000000000000ff191660ff19600160781b4264ffffffffff160216176003178355604080516001600160801b0387811682528616602082015287917fe39e7fc9f2013b8ab01110f66610f9fb8675d3126e69b3752f0084afc72be19a910160405180910390a261188e565b825460ff19166005178355604080516001600160801b0387811682528616602082015287917f2bed878481293fc7587c48352c8b09aeeca52bed666011d7f916706ec72d6d6d910160405180910390a25b505050505050565b60005b81811015610e40576000600760008585858181106118b9576118b961409b565b905060200201358152602001908152602001600020905060006118db82612a0f565b9050600060068260078111156118f3576118f3613d77565b0361191f57507f000000000000000000000000464c71f6c2f760dda6093dcb91c24c39e5d6e18c61197c565b600482600781111561193357611933613d77565b1061194c575060018201546001600160a01b031661197c565b60408051808201825260028152610e4d60f21b6020820152905162461bcd60e51b81526108669190600401613dff565b6006830154604080518082019091526002815261393360f01b6020820152816119b85760405162461bcd60e51b81526004016108669190613dff565b506000600685018190556040805182815260208101918290526001600160a01b0385169184916119e79161428a565b60006040518083038185875af1925050503d8060008114611a24576040519150601f19603f3d011682016040523d82523d6000602084013e611a29565b606091505b505090508060405180604001604052806002815260200161039360f41b81525090611a675760405162461bcd60e51b81526004016108669190613dff565b50801515836001600160a01b0316898989818110611a8757611a8761409b565b905060200201357fe2470238697bf7475f7230e5f3d01e088062f9610e00bcfb223e3a774949a09a85604051611abf91815260200190565b60405180910390a450505050508080611ad7906140f3565b915050611899565b6000818152600760205260408120611af681612a0f565b9392505050565b600054610100900460ff1615808015611b1d5750600054600160ff909116105b80611b375750303b158015611b37575060005460ff166001145b611b535760405162461bcd60e51b8152600401610866906142a6565b6000805460ff191660011790558015611b76576000805461ff0019166101001790555b611b868a8a8a8a8a8a8a89613486565b611b8f836136ee565b8015611bd5576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050505050565b611be961287f565b6108d18282808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506001925061273c915050565b611caa604080516101e081019091528060008152602001600081526000602082018190526040820181905260608083018290526080830182905260a0830182905260c0830182905260e0830182905261010083018290526101208301829052610140830182905261016083018290526101808301919091526101a09091015290565b600082815260076020819052604080832081516101e08101909252805491929091839160ff90911690811115611ce257611ce2613d77565b6007811115611cf357611cf3613d77565b81528154602090910190610100900460ff166002811115611d1657611d16613d77565b6002811115611d2757611d27613d77565b8152815464ffffffffff620100008204811660208085019190915262ffffff600160381b840416604080860191909152600160501b840483166060860152600160781b840483166080860152600160a01b90930490911660a084015260018401546001600160a01b0390811660c085015260028501541660e08401526003840154610100840152600484015461012084015260058401546001600160801b03808216610140860152600160801b9091041661016084015260068401546101808401526007840180548351818402810184019094528084526101a090940193909160009084015b82821015611eb45783829060005260206000209060020201604051806080016040529081600082015481526020016001820160009054906101000a900460ff166002811115611e5e57611e5e613d77565b6002811115611e6f57611e6f613d77565b815260019182015461010081046001600160a01b0316602080840191909152600160a81b90910464ffffffffff16604090920191909152918352929092019101611e0d565b505050915250506000848152600760205260409020909150611ed590612a0f565b81906007811115611ee857611ee8613d77565b90816007811115611efb57611efb613d77565b90525092915050565b600081815260076020526040812090611f1c82612a0f565b60018301549091506001600160a01b03166000826007811115611f4157611f41613d77565b14158015611f6057506004826007811115611f5e57611f5e613d77565b105b60405180604001604052806002815260200161313160f01b81525090611f995760405162461bcd60e51b81526004016108669190613dff565b506002830154611fb1906001600160a01b0316611531565b8015611fc657506001600160a01b0381163314155b801561209c5750825461209c90600890600090610100900460ff166002811115611ff257611ff2613d77565b600281111561200357612003613d77565b81526020808201929092526040908101600020815160a081018352905462ffffff808216835263010000008204169382019390935266ffffffffffffff600160301b8404811682840152600160681b840481166060830152600160a01b9093049092166080830152600254905163853bcd0360e01b81526001600160a01b0385811660048301529091169063853bcd0390602401610a94565b156120a9576120a96126ef565b825464ffffffffff4216600160a01b0260ff64ffffffffff60a01b011990911617600617835560405184907f789cf55be980739dad1d0699b93b58e806b51c9d96619bfa8fe0a28abaa7b30c90600090a250505050565b600054600390610100900460ff16158015612122575060005460ff8083169116105b61213e5760405162461bcd60e51b8152600401610866906142a6565b6000805461ffff191660ff83161761010017905561215b826136ee565b60408051600280825260608201909252600091816020015b6040805160c08101825260008082526020808301829052928201819052606082018190526080820181905260a082015282526000199092019101816121735750506040805160c081018252600181526201518060208201526203f480918101919091526943c33c1937564800000060608201526910f0cf064dd5920000006080820181905260a0820152815191925090819083906000906122165761221661409b565b602002602001018190525060006040518060c0016040528060028081111561224057612240613d77565b81526020016201518062ffffff168152602001620d2f0062ffffff16815260200169dc3a8351f3d86a000000815260200169dc3a8351f3d86a0000008152602001692a5a058fc295ed000000815250905080836001815181106122a5576122a561409b565b60200260200101819052506122b983612c39565b50506000805461ff00191690555060405160ff821681527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15050565b61230a61287f565b6001600160a01b03811661236f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610866565b6108e6816133c6565b61238061287f565b6108e6816136ee565b600081815260076020526040812080549091906008908290610100900460ff1660028111156123ba576123ba613d77565b60028111156123cb576123cb613d77565b815260208082019290925260409081016000908120825160a081018452905462ffffff8082168352630100000082041694820194909452600160301b840466ffffffffffffff90811693820193909352600160681b840483166060820152600160a01b909304909116608083015283549192506201000090910464ffffffffff16906124586001436142f4565b409050600161246685612a0f565b600781111561247757612477613d77565b14604051806040016040528060018152602001603560f81b815250906124b05760405162461bcd60e51b81526004016108669190613dff565b5060028401546124c8906001600160a01b0316611531565b604051806040016040528060018152602001603360f81b815250906125005760405162461bcd60e51b81526004016108669190613dff565b50825162ffffff1661251964ffffffffff8416426142f4565b11604051806040016040528060018152602001600760fb1b815250906125525760405162461bcd60e51b81526004016108669190613dff565b50600254600185015460405163853bcd0360e01b81526001600160a01b03918216600482015261258e928692169063853bcd0390602401610a94565b604051806040016040528060018152602001600d60fa1b815250906125c65760405162461bcd60e51b81526004016108669190613dff565b50835460038501829055602084015162ffffff908116600160381b90810269ffffff00000000000000196effffffffff000000000000000000ff1990941660ff19600160501b4264ffffffffff1602161760029081179490941617808855928701546040516324fb2b0b60e01b8152600481018a9052602481018690529190930490911660448201526001600160a01b03909116906324fb2b0b90606401600060405180830381600087803b15801561267e57600080fd5b505af1158015612692573d6000803e3d6000fd5b50505060208085015160405162ffffff909116815283925087917f45f1db29750f423920a6edede3a80ea19ceb9de3eabc072078eb539ca348dca0910160405180910390a35050505050565b6126e6613721565b6108e6816137a8565b6001546001600160a01b031633146115615760405162461bcd60e51b815260206004820152601060248201526f27a7262cafa12cafa3aaa0a92224a0a760811b6044820152606401610866565b60005b8251811015610e4057600083828151811061275c5761275c61409b565b6020026020010151905060006001600160a01b0316816001600160a01b0316141560405180604001604052806002815260200161034360f41b815250906127b65760405162461bcd60e51b81526004016108669190613dff565b506001600160a01b03811660009081526005602052604090205483151560ff9091161515036127e5575061286d565b821561280557600680549060006127fb836140f3565b919050555061281b565b6006805490600061281583614307565b91905055505b6001600160a01b038116600081815260056020526040808220805460ff191687151590811790915590519092917f5e1f23fe5aaf4ee57082b5f445e00d5a47343503b24ab1532a6c8cd15ba9700891a3505b80612877816140f3565b91505061273f565b6000546001600160a01b03620100009091041633146115615760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610866565b604080518082019091526002815261343160f01b60208201526001600160a01b0382166129205760405162461bcd60e51b81526004016108669190613dff565b506000816001600160a01b03166369098bd76040518163ffffffff1660e01b8152600401600060405180830381865afa158015612961573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612989919081019061431e565b511160405180604001604052806002815260200161363360f01b815250906129c45760405162461bcd60e51b81526004016108669190613dff565b50600280546001600160a01b0319166001600160a01b0383169081179091556040517ffc61eef8f2b4da4ee7bfb9f335f064e2a35a3f6e8e65c3168eafe813aafe4c5890600090a250565b805460009060ff1681816007811115612a2a57612a2a613d77565b1480612a4857506004816007811115612a4557612a45613d77565b10155b15612a535792915050565b8254600090612a739062278d009062010000900464ffffffffff166140c7565b905080421180612ab657506001826007811115612a9257612a92613d77565b148015612ab6575083548190612ab490600160381b900462ffffff16426140c7565b115b15612ac5575060079392505050565b5092915050565b6000670de0b6b3a7640000836080015166ffffffffffffff16612aef91906143d0565b90911192915050565b7f000000000000000000000000ed42a7d8559a463722ca4bed50e0cc05a386b0e16001600160a01b03166355c4fed483600001518460400151600b548660600151876020015187604051602001612b51939291906143e7565b6040516020818303038152906040526040518563ffffffff1660e01b8152600401612b7f9493929190614415565b60408051808303816000875af1158015612b9d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bc1919061444c565b50505050565b6000610f8a836001600160a01b038416613802565b6000610f8a836001600160a01b0384166138f5565b60048190556040518181527f5b81b8e66a81fbba6ded220cf668cb5da777acaa83cafe789c2699cad0efd8089060200160405180910390a150565b60606000611af683613944565b6000815111604051806040016040528060028152602001611b9b60f11b81525090612c775760405162461bcd60e51b81526004016108669190613dff565b5060005b81518110156131f3576000828281518110612c9857612c9861409b565b6020026020010151600001516002811115612cb557612cb5613d77565b11604051806040016040528060028152602001610d8d60f21b81525090612cef5760405162461bcd60e51b81526004016108669190613dff565b5062278d007f0000000000000000000000000000000000000000000000000000000000000000838381518110612d2757612d2761409b565b602002602001015160400151848481518110612d4557612d4561409b565b602002602001015160200151612d5b9190614470565b62ffffff16612d6a91906140c7565b10604051806040016040528060028152602001610d0d60f21b81525090612da45760405162461bcd60e51b81526004016108669190613dff565b506203f480828281518110612dbb57612dbb61409b565b60200260200101516040015162ffffff16101560405180604001604052806002815260200161363560f01b81525090612e075760405162461bcd60e51b81526004016108669190613dff565b506a0422ca8b0a00a425000000828281518110612e2657612e2661409b565b602002602001015160a00151111560405180604001604052806002815260200161383360f01b81525090612e6d5760405162461bcd60e51b81526004016108669190613dff565b506a0422ca8b0a00a425000000828281518110612e8c57612e8c61409b565b6020026020010151606001511115604051806040016040528060028152602001610e0d60f21b81525090612ed35760405162461bcd60e51b81526004016108669190613dff565b506a0422ca8b0a00a425000000828281518110612ef257612ef261409b565b602002602001015160800151111560405180604001604052806002815260200161383560f01b81525090612f395760405162461bcd60e51b81526004016108669190613dff565b5060006040518060a00160405280848481518110612f5957612f5961409b565b60200260200101516020015162ffffff168152602001848481518110612f8157612f8161409b565b60200260200101516040015162ffffff168152602001612fbd858581518110612fac57612fac61409b565b6020026020010151606001516139a0565b66ffffffffffffff168152602001612ff1858581518110612fe057612fe061409b565b6020026020010151608001516139a0565b66ffffffffffffff1681526020016130258585815181106130145761301461409b565b602002602001015160a001516139a0565b66ffffffffffffff168152509050806008600085858151811061304a5761304a61409b565b602002602001015160000151600281111561306757613067613d77565b600281111561307857613078613d77565b81526020808201929092526040908101600020835181549385015192850151606086015160809096015162ffffff92831665ffffffffffff1990961695909517630100000092909416919091029290921773ffffffffffffffffffffffffffff0000000000001916600160301b66ffffffffffffff9384160266ffffffffffffff60681b191617600160681b948316949094029390931766ffffffffffffff60a01b1916600160a01b9190921602179055825183908390811061313d5761313d61409b565b602002602001015160000151600281111561315a5761315a613d77565b7fa743f6cc30e98a5cb8e1148f36749c33167ec405cf4262bf6c7ae093d2a6c63f826020015183600001518460400151856060015186608001516040516131d895949392919062ffffff958616815293909416602084015266ffffffffffffff91821660408401528116606083015291909116608082015260a00190565b60405180910390a250806131eb816140f3565b915050612c7b565b506040805160a080820183527fad67d757c34507f157cacfa2e3153e9f260a2244f30428821be7be64587ac55f5462ffffff808216845263010000008083048216602086810191909152600160301b80850466ffffffffffffff908116888a0152600160681b80870482166060808b0191909152600160a01b9788900483166080808c0191825260026000819052600888528d519b8c018e527f6add646517a5b0f6793cd5891b7937d28a5b2981a5d88ebc7cd776088fea904154808b168d529889049099168b88015294870484168a8d01529186048316908901529590930483169086018190529351875180890190985292875261383360f01b90870152939492931611156133165760405162461bcd60e51b81526004016108669190613dff565b50806040015166ffffffffffffff16826040015166ffffffffffffff161115604051806040016040528060028152602001610e0d60f21b8152509061336e5760405162461bcd60e51b81526004016108669190613dff565b50806060015166ffffffffffffff16826060015166ffffffffffffff16111560405180604001604052806002815260200161383560f01b81525090612bc15760405162461bcd60e51b81526004016108669190613dff565b600080546001600160a01b038381166201000081810262010000600160b01b0319851617855560405193049190911692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a35050565b6000670de0b6b3a7640000836040015166ffffffffffffff16612aef91906143d0565b600081831015801561347e5750670de0b6b3a7640000846060015166ffffffffffffff1661347291906143d0565b61347c83856142f4565b115b949350505050565b600054610100900460ff16158080156134a65750600054600160ff909116105b806134c05750303b1580156134c0575060005460ff166001145b6134dc5760405162461bcd60e51b8152600401610866906142a6565b6000805460ff1916600117905580156134ff576000805461ff0019166101001790555b604080518082019091526002808252611c1960f11b602083015286146135385760405162461bcd60e51b81526004016108669190613dff565b508585600181811061354c5761354c61409b565b61356292602060c0909202019081019150613b82565b600281111561357357613573613d77565b868660008181106135865761358661409b565b61359c92602060c0909202019081019150613b82565b60028111156135ad576135ad613d77565b141560405180604001604052806002815260200161383760f01b815250906135e85760405162461bcd60e51b81526004016108669190613dff565b506135f2896133c6565b6135fb886137a8565b613604876128e0565b6136558686808060200260200160405190810160405280939291908181526020016000905b828210156115275761364660c083028601368190038101906141dd565b81526020019060010190613629565b6136948484808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506001925061273c915050565b61369d82612bf1565b80156136e3576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050565b600b81905560405181907f3d1394ba0f6fca9c1e344f10a3efe1bfca63bc591232bb0d76755690f409450c90600090a250565b6000546201000090046001600160a01b03166001600160a01b0316336001600160a01b0316148061375c57506001546001600160a01b031633145b6115615760405162461bcd60e51b815260206004820152601960248201527f4f4e4c595f42595f4f574e45525f4f525f475541524449414e000000000000006044820152606401610866565b600180546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f064d28d3d3071c5cbc271a261c10c2f0f0d9e319390397101aa0eb23c6bad90991016122f6565b600081815260018301602052604081205480156138eb5760006138266001836142f4565b855490915060009061383a906001906142f4565b905081811461389f57600086600001828154811061385a5761385a61409b565b906000526020600020015490508087600001848154811061387d5761387d61409b565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806138b0576138b061448c565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610f8d565b6000915050610f8d565b600081815260018301602052604081205461393c57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610f8d565b506000610f8d565b60608160000180548060200260200160405190810160405280929190818152602001828054801561399457602002820191906000526020600020905b815481526020019060010190808311613980575b50505050509050919050565b6000806139b5670de0b6b3a7640000846144a2565b9050611af681600066ffffffffffffff821115613a235760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203560448201526536206269747360d01b6064820152608401610866565b5090565b6001600160a01b03811681146108e657600080fd5b600060208284031215613a4e57600080fd5b8135611af681613a27565b600060208284031215613a6b57600080fd5b5035919050565b60008060208385031215613a8557600080fd5b823567ffffffffffffffff80821115613a9d57600080fd5b818501915085601f830112613ab157600080fd5b813581811115613ac057600080fd5b8660208260061b8501011115613ad557600080fd5b60209290920196919550909350505050565b60008083601f840112613af957600080fd5b50813567ffffffffffffffff811115613b1157600080fd5b6020830191508360208260051b8501011115613b2c57600080fd5b9250929050565b60008060208385031215613b4657600080fd5b823567ffffffffffffffff811115613b5d57600080fd5b613b6985828601613ae7565b90969095509350505050565b600381106108e657600080fd5b600060208284031215613b9457600080fd5b8135611af681613b75565b60008060408385031215613bb257600080fd5b8235613bbd81613a27565b946020939093013593505050565b6020808252825182820181905260009190848201906040850190845b81811015613c0c5783516001600160a01b031683529284019291840191600101613be7565b50909695505050505050565b60008060008060608587031215613c2e57600080fd5b843567ffffffffffffffff80821115613c4657600080fd5b818701915087601f830112613c5a57600080fd5b813581811115613c6957600080fd5b8860208260071b8501011115613c7e57600080fd5b60209283019650945050850135613c9481613a27565b9396929550929360400135925050565b60008083601f840112613cb657600080fd5b50813567ffffffffffffffff811115613cce57600080fd5b60208301915083602060c083028501011115613b2c57600080fd5b60008060208385031215613cfc57600080fd5b823567ffffffffffffffff811115613d1357600080fd5b613b6985828601613ca4565b80356001600160801b0381168114613d3657600080fd5b919050565b600080600060608486031215613d5057600080fd5b83359250613d6060208501613d1f565b9150613d6e60408501613d1f565b90509250925092565b634e487b7160e01b600052602160045260246000fd5b60088110613d9d57613d9d613d77565b9052565b60208101610f8d8284613d8d565b60005b83811015613dca578181015183820152602001613db2565b50506000910152565b60008151808452613deb816020860160208601613daf565b601f01601f19169290920160200192915050565b602081526000610f8a6020830184613dd3565b600080600080600080600080600060e08a8c031215613e3057600080fd5b8935613e3b81613a27565b985060208a0135613e4b81613a27565b975060408a0135613e5b81613a27565b965060608a013567ffffffffffffffff80821115613e7857600080fd5b613e848d838e01613ca4565b909850965060808c0135915080821115613e9d57600080fd5b50613eaa8c828d01613ae7565b9a9d999c50979a96999598959660a08101359660c09091013595509350505050565b60038110613d9d57613d9d613d77565b600081518084526020808501945080840160005b83811015613f455781518051885283810151613f0e858a0182613ecc565b506040818101516001600160a01b03169089015260609081015164ffffffffff169088015260809096019590820190600101613ef0565b509495945050505050565b60208152613f62602082018351613d8d565b60006020830151613f766040840182613ecc565b50604083015164ffffffffff8116606084015250606083015162ffffff8116608084015250608083015164ffffffffff811660a08401525060a083015164ffffffffff811660c08401525060c083015164ffffffffff811660e08401525060e0830151610100613ff0818501836001600160a01b03169052565b840151905061012061400c848201836001600160a01b03169052565b84015161014084810191909152840151610160808501919091528401519050610180614042818501836001600160801b03169052565b84015190506101a061405e848201836001600160801b03169052565b8401516101c0848101919091528401516101e080850152905061347e610200840182613edc565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b80820180821115610f8d57610f8d6140b1565b6000602082840312156140ec57600080fd5b5051919050565b600060018201614105576141056140b1565b5060010190565b8135815560018101602083013561412281613b75565b6003811061413257614132613d77565b8154604085013561414281613a27565b606086013564ffffffffff8116811461415a57600080fd5b60089190911b610100600160a81b03166001600160d01b03199290921660ff93909316929092171760a89190911b64ffffffffff60a81b161790555050565b604051601f8201601f1916810167ffffffffffffffff811182821017156141c2576141c2614085565b604052919050565b803562ffffff81168114613d3657600080fd5b600060c082840312156141ef57600080fd5b60405160c0810181811067ffffffffffffffff8211171561421257614212614085565b604052823561422081613b75565b815261422e602084016141ca565b602082015261423f604084016141ca565b6040820152606083013560608201526080830135608082015260a083013560a08201528091505092915050565b64ffffffffff818116838216019080821115612ac557612ac56140b1565b6000825161429c818460208701613daf565b9190910192915050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b81810381811115610f8d57610f8d6140b1565b600081614316576143166140b1565b506000190190565b6000602080838503121561433157600080fd5b825167ffffffffffffffff8082111561434957600080fd5b818501915085601f83011261435d57600080fd5b81518181111561436f5761436f614085565b8060051b9150614380848301614199565b818152918301840191848101908884111561439a57600080fd5b938501935b838510156143c457845192506143b483613a27565b828252938501939085019061439f565b98975050505050505050565b8082028115828204841417610f8d57610f8d6140b1565b64ffffffffff848116825260608201906144046020840186613ecc565b808416604084015250949350505050565b84815260018060a01b03841660208201528260408201526080606082015260006144426080830184613dd3565b9695505050505050565b6000806040838503121561445f57600080fd5b505080516020909101519092909150565b62ffffff818116838216019080821115612ac557612ac56140b1565b634e487b7160e01b600052603160045260246000fd5b6000826144bf57634e487b7160e01b600052601260045260246000fd5b50049056fea2646970667358221220aae704222234de070df38296fe1b6347eaa8a4ebe1646c846c0df5d2fa96c7f364736f6c63430008130033","optimization_enabled":true,"verified_twin_address_hash":null,"is_verified":true,"compiler_settings":{"evmVersion":"paris","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":true,"runs":200},"remappings":[":@aave/core-v3/=lib/aave-address-book/lib/aave-v3-core/",":@aave/periphery-v3/=lib/aave-address-book/lib/aave-v3-periphery/",":@openzeppelin/=lib/aave-delivery-infrastructure/lib/openzeppelin-contracts/",":aave-address-book/=lib/aave-address-book/src/",":aave-delivery-infrastructure-scripts/=lib/aave-delivery-infrastructure/scripts/",":aave-delivery-infrastructure/=lib/aave-delivery-infrastructure/src/",":aave-token-v2/=lib/aave-token-v3/lib/aave-token-v2/contracts/",":aave-token-v3/=lib/aave-token-v3/src/",":aave-v3-core/=lib/aave-address-book/lib/aave-v3-core/",":aave-v3-periphery/=lib/aave-address-book/lib/aave-v3-periphery/",":ds-test/=lib/forge-std/lib/ds-test/src/",":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",":forge-std/=lib/forge-std/src/",":fx-portal/=lib/aave-delivery-infrastructure/lib/fx-portal/contracts/",":hyperlane-monorepo/=lib/aave-delivery-infrastructure/lib/hyperlane-monorepo/",":nitro-contracts/=lib/aave-delivery-infrastructure/lib/nitro-contracts/src/",":openzeppelin-contracts/=lib/openzeppelin-contracts/",":openzeppelin/=lib/openzeppelin-contracts/contracts/",":solidity-examples/=lib/aave-delivery-infrastructure/lib/solidity-examples/contracts/",":solidity-utils/=lib/solidity-utils/src/"]},"optimization_runs":200,"sourcify_repo_url":"https://repo.sourcify.dev/contracts/full_match/1/0x58BcB647C4beFf253B4B6996c62F737B783f2cDd/","decoded_constructor_args":[["0xEd42a7D8559a463722Ca4beD50E0Cc05a386b0e1",{"internalType":"address","name":"crossChainController","type":"address"}],["0",{"internalType":"uint256","name":"coolDownPeriod","type":"uint256"}],["0x464C71f6c2F760DdA6093dCB91C24c39e5d6e18c",{"internalType":"address","name":"cancellationFeeCollector","type":"address"}]],"compiler_version":"0.8.19+commit.7dd6d404","is_verified_via_verifier_alliance":false,"verified_at":"2024-05-15T16:23:07.327675Z","implementations":[],"proxy_type":null,"external_libraries":[],"creation_bytecode":"0x60e06040523480156200001157600080fd5b5060405162004877380380620048778339810160408190526200003491620002a0565b81816200004062000108565b6200004b33620001c7565b620000563362000222565b604080518082019091526002815261393160f01b60208201526001600160a01b038216620000a25760405162461bcd60e51b8152600401620000999190620002e1565b60405180910390fd5b506001600160a01b0390811660805260a09190915260408051808201909152600281526106a760f31b6020820152908416620000f35760405162461bcd60e51b8152600401620000999190620002e1565b5050506001600160a01b031660c05262000331565b600054610100900460ff1615620001725760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840162000099565b60005460ff9081161015620001c5576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b600080546001600160a01b038381166201000081810262010000600160b01b0319851617855560405193049190911692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a35050565b600180546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f064d28d3d3071c5cbc271a261c10c2f0f0d9e319390397101aa0eb23c6bad909910160405180910390a15050565b80516001600160a01b03811681146200029b57600080fd5b919050565b600080600060608486031215620002b657600080fd5b620002c18462000283565b925060208401519150620002d86040850162000283565b90509250925092565b600060208083528351808285015260005b818110156200031057858101830151858201604001528201620002f2565b506000604082860101526040601f19601f8301168501019250505092915050565b60805160a05160c0516144fa6200037d600039600081816106ff0152612afa0152600081816104e2015281816109550152612cf60152600081816106ab01526118fb01526144fa6000f3fe60806040526004361061023a5760003560e01c80638da5cb5b1161012e578063c3b4b661116100ab578063efe61a2f1161006f578063efe61a2f14610784578063f2fde38b146107a4578063f687d12a146107c4578063f6ead0b9146107e4578063fc5253951461080457600080fd5b8063c3b4b661146106cd578063c4956366146106ed578063c7f758a814610721578063e0a8f6f51461074e578063eaf1061c1461076e57600080fd5b8063a3f4df7e116100f2578063a3f4df7e146105d4578063ad6036cf1461061f578063b26ccf4714610662578063b3809b1314610679578063c3a76d921461069957600080fd5b80638da5cb5b146105395780639043ffc31461055d5780639080936f1461057d57806398e527d3146105aa5780639c0401c6146105bf57600080fd5b806338fe05be116101bc5780635ca4d552116101805780635ca4d5521461048457806362af1ed6146104b45780636e99d52f146104d0578063715018a61461050457806371b32bb11461051957600080fd5b806338fe05be146104005780633bec1bfc14610415578063452a93201461042857806346a3d430146104465780634e3523191461046457600080fd5b806319ebdc341161020357806319ebdc34146102f85780631a93d1c3146103185780631aefa2d1146103375780631c84e3211461035757806321916b81146103d357600080fd5b80629927451461023f578063079b1fdd146102615780630d61b519146102815780630f3424bb146102a1578063133539ec146102d8575b600080fd5b34801561024b57600080fd5b5061025f61025a366004613a3c565b610824565b005b34801561026d57600080fd5b5061025f61027c366004613a3c565b6108d5565b34801561028d57600080fd5b5061025f61029c366004613a59565b6108e9565b3480156102ad57600080fd5b506002546001600160a01b03165b6040516001600160a01b0390911681526020015b60405180910390f35b3480156102e457600080fd5b5061025f6102f3366004613a72565b610c94565b34801561030457600080fd5b5061025f610313366004613b33565b610e45565b34801561032457600080fd5b50600b545b6040519081526020016102cf565b34801561034357600080fd5b5061025f610352366004613a59565b610e89565b34801561036357600080fd5b50610377610372366004613b82565b610e9a565b6040516102cf9190600060a08201905062ffffff80845116835280602085015116602084015250604083015166ffffffffffffff8082166040850152806060860151166060850152806080860151166080850152505092915050565b3480156103df57600080fd5b506103f36103ee366004613b9f565b610f5b565b6040516102cf9190613bcb565b34801561040c57600080fd5b50600654610329565b610329610423366004613c18565b610f93565b34801561043457600080fd5b506001546001600160a01b03166102bb565b34801561045257600080fd5b506a0422ca8b0a00a425000000610329565b34801561047057600080fd5b5061025f61047f366004613ce9565b6114ce565b34801561049057600080fd5b506104a461049f366004613a3c565b611531565b60405190151581526020016102cf565b3480156104c057600080fd5b50610329670de0b6b3a764000081565b3480156104dc57600080fd5b506103297f000000000000000000000000000000000000000000000000000000000000000081565b34801561051057600080fd5b5061025f61154f565b34801561052557600080fd5b5061025f610534366004613d3b565b611563565b34801561054557600080fd5b506000546201000090046001600160a01b03166102bb565b34801561056957600080fd5b5061025f610578366004613b33565b611896565b34801561058957600080fd5b5061059d610598366004613a59565b611adf565b6040516102cf9190613da1565b3480156105b657600080fd5b50600354610329565b3480156105cb57600080fd5b50600454610329565b3480156105e057600080fd5b50610612604051806040016040528060128152602001714161766520476f7665726e616e636520763360701b81525081565b6040516102cf9190613dff565b34801561062b57600080fd5b506102bb61063a366004613b9f565b6001600160a01b03918216600090815260096020908152604080832093835292905220541690565b34801561066e57600080fd5b5061032962278d0081565b34801561068557600080fd5b5061025f610694366004613e12565b611afd565b3480156106a557600080fd5b506102bb7f000000000000000000000000000000000000000000000000000000000000000081565b3480156106d957600080fd5b5061025f6106e8366004613b33565b611be1565b3480156106f957600080fd5b506102bb7f000000000000000000000000000000000000000000000000000000000000000081565b34801561072d57600080fd5b5061074161073c366004613a59565b611c28565b6040516102cf9190613f50565b34801561075a57600080fd5b5061025f610769366004613a59565b611f04565b34801561077a57600080fd5b506203f480610329565b34801561079057600080fd5b5061025f61079f366004613a59565b612100565b3480156107b057600080fd5b5061025f6107bf366004613a3c565b612302565b3480156107d057600080fd5b5061025f6107df366004613a59565b612378565b3480156107f057600080fd5b5061025f6107ff366004613a59565b612389565b34801561081057600080fd5b5061025f61081f366004613a3c565b6126de565b61082c6126ef565b6006546040805180820190915260018152603160f81b6020820152901561086f5760405162461bcd60e51b81526004016108669190613dff565b60405180910390fd5b506040805160018082528183019092526000916020808301908036833701905050905081816000815181106108a6576108a661409b565b60200260200101906001600160a01b031690816001600160a01b0316815250506108d181600161273c565b5050565b6108dd61287f565b6108e6816128e0565b50565b6000818152600760205260409020600361090282612a0f565b600781111561091357610913613d77565b14604051806040016040528060018152602001603760f81b8152509061094c5760405162461bcd60e51b81526004016108669190613dff565b508054610988907f000000000000000000000000000000000000000000000000000000000000000090600160781b900464ffffffffff166140c7565b42101560405180604001604052806002815260200161031360f41b815250906109c45760405162461bcd60e51b81526004016108669190613dff565b508054610ada90600890600090610100900460ff1660028111156109ea576109ea613d77565b60028111156109fb576109fb613d77565b81526020808201929092526040908101600020815160a081018352905462ffffff808216835263010000008204169382019390935266ffffffffffffff600160301b8404811682840152600160681b840481166060830152600160a01b90930490921660808301526002546001850154915163853bcd0360e01b81526001600160a01b03928316600482015291169063853bcd03906024015b602060405180830381865afa158015610ab1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad591906140da565b612acc565b604051806040016040528060018152602001600d60fa1b81525090610b125760405162461bcd60e51b81526004016108669190613dff565b50805460ff1916600417815560005b6007820154811015610c64576000826007018281548110610b4457610b4461409b565b9060005260206000209060020201604051806080016040529081600082015481526020016001820160009054906101000a900460ff166002811115610b8b57610b8b613d77565b6002811115610b9c57610b9c613d77565b8152600191909101546001600160a01b03610100820416602083015264ffffffffff600160a81b90910481166040909201919091528454919250610bea918391600160501b90910416612af8565b80516040808301516060808501516007880154845164ffffffffff909216825260208201889052938101939093526001600160a01b039091169187917f9c687134d572ff69f3e23f40470562650574c5c7cab9f535268763b2d00da65b910160405180910390a45080610c5c816140f3565b915050610b21565b5060405182907f712ae1383f79ac853f8d882153778e0260ef8f03b504e2866e0593e04d2b291f90600090a25050565b60005b81811015610e40576000838383818110610cb357610cb361409b565b9050604002016020013590506000336001600160a01b0316858585818110610cdd57610cdd61409b565b610cf39260206040909202019081019150613a3c565b6001600160a01b031603610d08576000610d30565b848484818110610d1a57610d1a61409b565b610d309260206040909202019081019150613a3c565b3360009081526009602090815260408083208684529091529020549091506001600160a01b03168015610d8c576001600160a01b0381166000908152600a602090815260408083208684529091529020610d8a9033612bc7565b505b6001600160a01b03821615610dca576001600160a01b0382166000908152600a602090815260408083208684529091529020610dc89033612bdc565b505b33600081815260096020908152604080832087845290915280822080546001600160a01b0319166001600160a01b0387169081179091559051869391927f918b5bd4499a75f73bb64f14ae0254255f5421d0ecc4dd853c7bfdd7cf65e8fd91a45050508080610e38906140f3565b915050610c97565b505050565b610e4d61287f565b6108d18282808060200260200160405190810160405280939291908181526020018383602002808284376000920182905250925061273c915050565b610e9161287f565b6108e681612bf1565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915260086000836002811115610edb57610edb613d77565b6002811115610eec57610eec613d77565b81526020808201929092526040908101600020815160a081018352905462ffffff808216835263010000008204169382019390935266ffffffffffffff600160301b8404811692820192909252600160681b830482166060820152600160a01b90920416608082015292915050565b6001600160a01b0382166000908152600a602090815260408083208484529091529020606090610f8a90612c2c565b90505b92915050565b6040805180820190915260018152601960f91b602082015260009084610fcc5760405162461bcd60e51b81526004016108669190613dff565b50604080518082019091526002815261353960f01b6020820152826110045760405162461bcd60e51b81526004016108669190613dff565b506004543414604051806040016040528060028152602001611c9960f11b815250906110435760405162461bcd60e51b81526004016108669190613dff565b5061104d83611531565b604051806040016040528060018152602001603360f81b815250906110855760405162461bcd60e51b81526004016108669190613dff565b506003805460009182611097836140f3565b909155506000818152600760205260408120919250805b878110156112d05760008989838181106110ca576110ca61409b565b90506080020160200160208101906110e29190613b82565b60028111156110f3576110f3613d77565b1160405180604001604052806002815260200161036360f41b8152509061112d5760405162461bcd60e51b81526004016108669190613dff565b5060008989838181106111425761114261409b565b905060800201604001602081019061115a9190613a3c565b6001600160a01b0316141560405180604001604052806002815260200161363160f01b8152509061119e5760405162461bcd60e51b81526004016108669190613dff565b5060008989838181106111b3576111b361409b565b9050608002016000013511604051806040016040528060028152602001611b1960f11b815250906111f75760405162461bcd60e51b81526004016108669190613dff565b508260070189898381811061120e5761120e61409b565b83546001810185556000948552602090942060809091029290920192600202909101905061123c828261410c565b505081600281111561125057611250613d77565b8989838181106112625761126261409b565b905060800201602001602081019061127a9190613b82565b600281111561128b5761128b613d77565b11156112be578888828181106112a3576112a361409b565b90506080020160200160208101906112bb9190613b82565b91505b806112c8816140f3565b9150506110ae565b506000600860008360028111156112e9576112e9613d77565b60028111156112fa576112fa613d77565b81526020808201929092526040908101600020815160a081018352905462ffffff808216835263010000008204169382019390935266ffffffffffffff600160301b8404811682840152600160681b840481166060830152600160a01b9093049092166080830152600254905163853bcd0360e01b8152336004820181905292935061139c9184916001600160a01b039091169063853bcd0390602401610a94565b604051806040016040528060018152602001600d60fa1b815250906113d45760405162461bcd60e51b81526004016108669190613dff565b508354600160ff1982168117865580860180546001600160a01b0319166001600160a01b0385161790558491869161ffff199091161761010083600281111561141f5761141f613d77565b0217905550600284810180546001600160a01b0319166001600160a01b038b16179055845466ffffffffff00001916620100004264ffffffffff160217855560048501889055346006860155839081111561147c5761147c613d77565b816001600160a01b0316867fcc914becfa276bbc067049bf8db2d34ebbdc1bafa851e4d4936aaed376c08dbe8a6040516114b891815260200190565b60405180910390a4509298975050505050505050565b6114d661287f565b6108d18282808060200260200160405190810160405280939291908181526020016000905b828210156115275761151860c083028601368190038101906141dd565b815260200190600101906114fb565b5050505050612c39565b6001600160a01b031660009081526005602052604090205460ff1690565b61155761287f565b61156160006133c6565b565b600083815260076020526040902060028101546001600160a01b03163381148015611592575061159281611531565b604051806040016040528060018152602001603960f81b815250906115ca5760405162461bcd60e51b81526004016108669190613dff565b5060026115d683612a0f565b60078111156115e7576115e7613d77565b14604051806040016040528060018152602001601b60f91b815250906116205760405162461bcd60e51b81526004016108669190613dff565b50815461164790600160501b810464ffffffffff1690600160381b900462ffffff1661426c565b64ffffffffff16421160405180604001604052806002815260200161343560f01b815250906116895760405162461bcd60e51b81526004016108669190613dff565b5081546000906008908290610100900460ff1660028111156116ad576116ad613d77565b60028111156116be576116be613d77565b81526020808201929092526040908101600020815160a081018352905462ffffff808216835263010000008204169382019390935266ffffffffffffff600160301b8404811682840152600160681b840481166060830152600160a01b90930490921660808301526001600160801b03868116600160801b029088161760058601556002546001860154915163853bcd0360e01b81526001600160a01b03928316600482015292935061177f9284929091169063853bcd0390602401610a94565b8015611799575061179981866001600160801b0316613421565b80156117bd57506117bd81866001600160801b0316866001600160801b0316613444565b1561183d57825473ffffffffff0000000000000000000000000000ff191660ff19600160781b4264ffffffffff160216176003178355604080516001600160801b0387811682528616602082015287917fe39e7fc9f2013b8ab01110f66610f9fb8675d3126e69b3752f0084afc72be19a910160405180910390a261188e565b825460ff19166005178355604080516001600160801b0387811682528616602082015287917f2bed878481293fc7587c48352c8b09aeeca52bed666011d7f916706ec72d6d6d910160405180910390a25b505050505050565b60005b81811015610e40576000600760008585858181106118b9576118b961409b565b905060200201358152602001908152602001600020905060006118db82612a0f565b9050600060068260078111156118f3576118f3613d77565b0361191f57507f000000000000000000000000000000000000000000000000000000000000000061197c565b600482600781111561193357611933613d77565b1061194c575060018201546001600160a01b031661197c565b60408051808201825260028152610e4d60f21b6020820152905162461bcd60e51b81526108669190600401613dff565b6006830154604080518082019091526002815261393360f01b6020820152816119b85760405162461bcd60e51b81526004016108669190613dff565b506000600685018190556040805182815260208101918290526001600160a01b0385169184916119e79161428a565b60006040518083038185875af1925050503d8060008114611a24576040519150601f19603f3d011682016040523d82523d6000602084013e611a29565b606091505b505090508060405180604001604052806002815260200161039360f41b81525090611a675760405162461bcd60e51b81526004016108669190613dff565b50801515836001600160a01b0316898989818110611a8757611a8761409b565b905060200201357fe2470238697bf7475f7230e5f3d01e088062f9610e00bcfb223e3a774949a09a85604051611abf91815260200190565b60405180910390a450505050508080611ad7906140f3565b915050611899565b6000818152600760205260408120611af681612a0f565b9392505050565b600054610100900460ff1615808015611b1d5750600054600160ff909116105b80611b375750303b158015611b37575060005460ff166001145b611b535760405162461bcd60e51b8152600401610866906142a6565b6000805460ff191660011790558015611b76576000805461ff0019166101001790555b611b868a8a8a8a8a8a8a89613486565b611b8f836136ee565b8015611bd5576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050505050565b611be961287f565b6108d18282808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506001925061273c915050565b611caa604080516101e081019091528060008152602001600081526000602082018190526040820181905260608083018290526080830182905260a0830182905260c0830182905260e0830182905261010083018290526101208301829052610140830182905261016083018290526101808301919091526101a09091015290565b600082815260076020819052604080832081516101e08101909252805491929091839160ff90911690811115611ce257611ce2613d77565b6007811115611cf357611cf3613d77565b81528154602090910190610100900460ff166002811115611d1657611d16613d77565b6002811115611d2757611d27613d77565b8152815464ffffffffff620100008204811660208085019190915262ffffff600160381b840416604080860191909152600160501b840483166060860152600160781b840483166080860152600160a01b90930490911660a084015260018401546001600160a01b0390811660c085015260028501541660e08401526003840154610100840152600484015461012084015260058401546001600160801b03808216610140860152600160801b9091041661016084015260068401546101808401526007840180548351818402810184019094528084526101a090940193909160009084015b82821015611eb45783829060005260206000209060020201604051806080016040529081600082015481526020016001820160009054906101000a900460ff166002811115611e5e57611e5e613d77565b6002811115611e6f57611e6f613d77565b815260019182015461010081046001600160a01b0316602080840191909152600160a81b90910464ffffffffff16604090920191909152918352929092019101611e0d565b505050915250506000848152600760205260409020909150611ed590612a0f565b81906007811115611ee857611ee8613d77565b90816007811115611efb57611efb613d77565b90525092915050565b600081815260076020526040812090611f1c82612a0f565b60018301549091506001600160a01b03166000826007811115611f4157611f41613d77565b14158015611f6057506004826007811115611f5e57611f5e613d77565b105b60405180604001604052806002815260200161313160f01b81525090611f995760405162461bcd60e51b81526004016108669190613dff565b506002830154611fb1906001600160a01b0316611531565b8015611fc657506001600160a01b0381163314155b801561209c5750825461209c90600890600090610100900460ff166002811115611ff257611ff2613d77565b600281111561200357612003613d77565b81526020808201929092526040908101600020815160a081018352905462ffffff808216835263010000008204169382019390935266ffffffffffffff600160301b8404811682840152600160681b840481166060830152600160a01b9093049092166080830152600254905163853bcd0360e01b81526001600160a01b0385811660048301529091169063853bcd0390602401610a94565b156120a9576120a96126ef565b825464ffffffffff4216600160a01b0260ff64ffffffffff60a01b011990911617600617835560405184907f789cf55be980739dad1d0699b93b58e806b51c9d96619bfa8fe0a28abaa7b30c90600090a250505050565b600054600390610100900460ff16158015612122575060005460ff8083169116105b61213e5760405162461bcd60e51b8152600401610866906142a6565b6000805461ffff191660ff83161761010017905561215b826136ee565b60408051600280825260608201909252600091816020015b6040805160c08101825260008082526020808301829052928201819052606082018190526080820181905260a082015282526000199092019101816121735750506040805160c081018252600181526201518060208201526203f480918101919091526943c33c1937564800000060608201526910f0cf064dd5920000006080820181905260a0820152815191925090819083906000906122165761221661409b565b602002602001018190525060006040518060c0016040528060028081111561224057612240613d77565b81526020016201518062ffffff168152602001620d2f0062ffffff16815260200169dc3a8351f3d86a000000815260200169dc3a8351f3d86a0000008152602001692a5a058fc295ed000000815250905080836001815181106122a5576122a561409b565b60200260200101819052506122b983612c39565b50506000805461ff00191690555060405160ff821681527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15050565b61230a61287f565b6001600160a01b03811661236f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610866565b6108e6816133c6565b61238061287f565b6108e6816136ee565b600081815260076020526040812080549091906008908290610100900460ff1660028111156123ba576123ba613d77565b60028111156123cb576123cb613d77565b815260208082019290925260409081016000908120825160a081018452905462ffffff8082168352630100000082041694820194909452600160301b840466ffffffffffffff90811693820193909352600160681b840483166060820152600160a01b909304909116608083015283549192506201000090910464ffffffffff16906124586001436142f4565b409050600161246685612a0f565b600781111561247757612477613d77565b14604051806040016040528060018152602001603560f81b815250906124b05760405162461bcd60e51b81526004016108669190613dff565b5060028401546124c8906001600160a01b0316611531565b604051806040016040528060018152602001603360f81b815250906125005760405162461bcd60e51b81526004016108669190613dff565b50825162ffffff1661251964ffffffffff8416426142f4565b11604051806040016040528060018152602001600760fb1b815250906125525760405162461bcd60e51b81526004016108669190613dff565b50600254600185015460405163853bcd0360e01b81526001600160a01b03918216600482015261258e928692169063853bcd0390602401610a94565b604051806040016040528060018152602001600d60fa1b815250906125c65760405162461bcd60e51b81526004016108669190613dff565b50835460038501829055602084015162ffffff908116600160381b90810269ffffff00000000000000196effffffffff000000000000000000ff1990941660ff19600160501b4264ffffffffff1602161760029081179490941617808855928701546040516324fb2b0b60e01b8152600481018a9052602481018690529190930490911660448201526001600160a01b03909116906324fb2b0b90606401600060405180830381600087803b15801561267e57600080fd5b505af1158015612692573d6000803e3d6000fd5b50505060208085015160405162ffffff909116815283925087917f45f1db29750f423920a6edede3a80ea19ceb9de3eabc072078eb539ca348dca0910160405180910390a35050505050565b6126e6613721565b6108e6816137a8565b6001546001600160a01b031633146115615760405162461bcd60e51b815260206004820152601060248201526f27a7262cafa12cafa3aaa0a92224a0a760811b6044820152606401610866565b60005b8251811015610e4057600083828151811061275c5761275c61409b565b6020026020010151905060006001600160a01b0316816001600160a01b0316141560405180604001604052806002815260200161034360f41b815250906127b65760405162461bcd60e51b81526004016108669190613dff565b506001600160a01b03811660009081526005602052604090205483151560ff9091161515036127e5575061286d565b821561280557600680549060006127fb836140f3565b919050555061281b565b6006805490600061281583614307565b91905055505b6001600160a01b038116600081815260056020526040808220805460ff191687151590811790915590519092917f5e1f23fe5aaf4ee57082b5f445e00d5a47343503b24ab1532a6c8cd15ba9700891a3505b80612877816140f3565b91505061273f565b6000546001600160a01b03620100009091041633146115615760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610866565b604080518082019091526002815261343160f01b60208201526001600160a01b0382166129205760405162461bcd60e51b81526004016108669190613dff565b506000816001600160a01b03166369098bd76040518163ffffffff1660e01b8152600401600060405180830381865afa158015612961573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612989919081019061431e565b511160405180604001604052806002815260200161363360f01b815250906129c45760405162461bcd60e51b81526004016108669190613dff565b50600280546001600160a01b0319166001600160a01b0383169081179091556040517ffc61eef8f2b4da4ee7bfb9f335f064e2a35a3f6e8e65c3168eafe813aafe4c5890600090a250565b805460009060ff1681816007811115612a2a57612a2a613d77565b1480612a4857506004816007811115612a4557612a45613d77565b10155b15612a535792915050565b8254600090612a739062278d009062010000900464ffffffffff166140c7565b905080421180612ab657506001826007811115612a9257612a92613d77565b148015612ab6575083548190612ab490600160381b900462ffffff16426140c7565b115b15612ac5575060079392505050565b5092915050565b6000670de0b6b3a7640000836080015166ffffffffffffff16612aef91906143d0565b90911192915050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166355c4fed483600001518460400151600b548660600151876020015187604051602001612b51939291906143e7565b6040516020818303038152906040526040518563ffffffff1660e01b8152600401612b7f9493929190614415565b60408051808303816000875af1158015612b9d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bc1919061444c565b50505050565b6000610f8a836001600160a01b038416613802565b6000610f8a836001600160a01b0384166138f5565b60048190556040518181527f5b81b8e66a81fbba6ded220cf668cb5da777acaa83cafe789c2699cad0efd8089060200160405180910390a150565b60606000611af683613944565b6000815111604051806040016040528060028152602001611b9b60f11b81525090612c775760405162461bcd60e51b81526004016108669190613dff565b5060005b81518110156131f3576000828281518110612c9857612c9861409b565b6020026020010151600001516002811115612cb557612cb5613d77565b11604051806040016040528060028152602001610d8d60f21b81525090612cef5760405162461bcd60e51b81526004016108669190613dff565b5062278d007f0000000000000000000000000000000000000000000000000000000000000000838381518110612d2757612d2761409b565b602002602001015160400151848481518110612d4557612d4561409b565b602002602001015160200151612d5b9190614470565b62ffffff16612d6a91906140c7565b10604051806040016040528060028152602001610d0d60f21b81525090612da45760405162461bcd60e51b81526004016108669190613dff565b506203f480828281518110612dbb57612dbb61409b565b60200260200101516040015162ffffff16101560405180604001604052806002815260200161363560f01b81525090612e075760405162461bcd60e51b81526004016108669190613dff565b506a0422ca8b0a00a425000000828281518110612e2657612e2661409b565b602002602001015160a00151111560405180604001604052806002815260200161383360f01b81525090612e6d5760405162461bcd60e51b81526004016108669190613dff565b506a0422ca8b0a00a425000000828281518110612e8c57612e8c61409b565b6020026020010151606001511115604051806040016040528060028152602001610e0d60f21b81525090612ed35760405162461bcd60e51b81526004016108669190613dff565b506a0422ca8b0a00a425000000828281518110612ef257612ef261409b565b602002602001015160800151111560405180604001604052806002815260200161383560f01b81525090612f395760405162461bcd60e51b81526004016108669190613dff565b5060006040518060a00160405280848481518110612f5957612f5961409b565b60200260200101516020015162ffffff168152602001848481518110612f8157612f8161409b565b60200260200101516040015162ffffff168152602001612fbd858581518110612fac57612fac61409b565b6020026020010151606001516139a0565b66ffffffffffffff168152602001612ff1858581518110612fe057612fe061409b565b6020026020010151608001516139a0565b66ffffffffffffff1681526020016130258585815181106130145761301461409b565b602002602001015160a001516139a0565b66ffffffffffffff168152509050806008600085858151811061304a5761304a61409b565b602002602001015160000151600281111561306757613067613d77565b600281111561307857613078613d77565b81526020808201929092526040908101600020835181549385015192850151606086015160809096015162ffffff92831665ffffffffffff1990961695909517630100000092909416919091029290921773ffffffffffffffffffffffffffff0000000000001916600160301b66ffffffffffffff9384160266ffffffffffffff60681b191617600160681b948316949094029390931766ffffffffffffff60a01b1916600160a01b9190921602179055825183908390811061313d5761313d61409b565b602002602001015160000151600281111561315a5761315a613d77565b7fa743f6cc30e98a5cb8e1148f36749c33167ec405cf4262bf6c7ae093d2a6c63f826020015183600001518460400151856060015186608001516040516131d895949392919062ffffff958616815293909416602084015266ffffffffffffff91821660408401528116606083015291909116608082015260a00190565b60405180910390a250806131eb816140f3565b915050612c7b565b506040805160a080820183527fad67d757c34507f157cacfa2e3153e9f260a2244f30428821be7be64587ac55f5462ffffff808216845263010000008083048216602086810191909152600160301b80850466ffffffffffffff908116888a0152600160681b80870482166060808b0191909152600160a01b9788900483166080808c0191825260026000819052600888528d519b8c018e527f6add646517a5b0f6793cd5891b7937d28a5b2981a5d88ebc7cd776088fea904154808b168d529889049099168b88015294870484168a8d01529186048316908901529590930483169086018190529351875180890190985292875261383360f01b90870152939492931611156133165760405162461bcd60e51b81526004016108669190613dff565b50806040015166ffffffffffffff16826040015166ffffffffffffff161115604051806040016040528060028152602001610e0d60f21b8152509061336e5760405162461bcd60e51b81526004016108669190613dff565b50806060015166ffffffffffffff16826060015166ffffffffffffff16111560405180604001604052806002815260200161383560f01b81525090612bc15760405162461bcd60e51b81526004016108669190613dff565b600080546001600160a01b038381166201000081810262010000600160b01b0319851617855560405193049190911692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a35050565b6000670de0b6b3a7640000836040015166ffffffffffffff16612aef91906143d0565b600081831015801561347e5750670de0b6b3a7640000846060015166ffffffffffffff1661347291906143d0565b61347c83856142f4565b115b949350505050565b600054610100900460ff16158080156134a65750600054600160ff909116105b806134c05750303b1580156134c0575060005460ff166001145b6134dc5760405162461bcd60e51b8152600401610866906142a6565b6000805460ff1916600117905580156134ff576000805461ff0019166101001790555b604080518082019091526002808252611c1960f11b602083015286146135385760405162461bcd60e51b81526004016108669190613dff565b508585600181811061354c5761354c61409b565b61356292602060c0909202019081019150613b82565b600281111561357357613573613d77565b868660008181106135865761358661409b565b61359c92602060c0909202019081019150613b82565b60028111156135ad576135ad613d77565b141560405180604001604052806002815260200161383760f01b815250906135e85760405162461bcd60e51b81526004016108669190613dff565b506135f2896133c6565b6135fb886137a8565b613604876128e0565b6136558686808060200260200160405190810160405280939291908181526020016000905b828210156115275761364660c083028601368190038101906141dd565b81526020019060010190613629565b6136948484808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506001925061273c915050565b61369d82612bf1565b80156136e3576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050565b600b81905560405181907f3d1394ba0f6fca9c1e344f10a3efe1bfca63bc591232bb0d76755690f409450c90600090a250565b6000546201000090046001600160a01b03166001600160a01b0316336001600160a01b0316148061375c57506001546001600160a01b031633145b6115615760405162461bcd60e51b815260206004820152601960248201527f4f4e4c595f42595f4f574e45525f4f525f475541524449414e000000000000006044820152606401610866565b600180546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f064d28d3d3071c5cbc271a261c10c2f0f0d9e319390397101aa0eb23c6bad90991016122f6565b600081815260018301602052604081205480156138eb5760006138266001836142f4565b855490915060009061383a906001906142f4565b905081811461389f57600086600001828154811061385a5761385a61409b565b906000526020600020015490508087600001848154811061387d5761387d61409b565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806138b0576138b061448c565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610f8d565b6000915050610f8d565b600081815260018301602052604081205461393c57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610f8d565b506000610f8d565b60608160000180548060200260200160405190810160405280929190818152602001828054801561399457602002820191906000526020600020905b815481526020019060010190808311613980575b50505050509050919050565b6000806139b5670de0b6b3a7640000846144a2565b9050611af681600066ffffffffffffff821115613a235760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203560448201526536206269747360d01b6064820152608401610866565b5090565b6001600160a01b03811681146108e657600080fd5b600060208284031215613a4e57600080fd5b8135611af681613a27565b600060208284031215613a6b57600080fd5b5035919050565b60008060208385031215613a8557600080fd5b823567ffffffffffffffff80821115613a9d57600080fd5b818501915085601f830112613ab157600080fd5b813581811115613ac057600080fd5b8660208260061b8501011115613ad557600080fd5b60209290920196919550909350505050565b60008083601f840112613af957600080fd5b50813567ffffffffffffffff811115613b1157600080fd5b6020830191508360208260051b8501011115613b2c57600080fd5b9250929050565b60008060208385031215613b4657600080fd5b823567ffffffffffffffff811115613b5d57600080fd5b613b6985828601613ae7565b90969095509350505050565b600381106108e657600080fd5b600060208284031215613b9457600080fd5b8135611af681613b75565b60008060408385031215613bb257600080fd5b8235613bbd81613a27565b946020939093013593505050565b6020808252825182820181905260009190848201906040850190845b81811015613c0c5783516001600160a01b031683529284019291840191600101613be7565b50909695505050505050565b60008060008060608587031215613c2e57600080fd5b843567ffffffffffffffff80821115613c4657600080fd5b818701915087601f830112613c5a57600080fd5b813581811115613c6957600080fd5b8860208260071b8501011115613c7e57600080fd5b60209283019650945050850135613c9481613a27565b9396929550929360400135925050565b60008083601f840112613cb657600080fd5b50813567ffffffffffffffff811115613cce57600080fd5b60208301915083602060c083028501011115613b2c57600080fd5b60008060208385031215613cfc57600080fd5b823567ffffffffffffffff811115613d1357600080fd5b613b6985828601613ca4565b80356001600160801b0381168114613d3657600080fd5b919050565b600080600060608486031215613d5057600080fd5b83359250613d6060208501613d1f565b9150613d6e60408501613d1f565b90509250925092565b634e487b7160e01b600052602160045260246000fd5b60088110613d9d57613d9d613d77565b9052565b60208101610f8d8284613d8d565b60005b83811015613dca578181015183820152602001613db2565b50506000910152565b60008151808452613deb816020860160208601613daf565b601f01601f19169290920160200192915050565b602081526000610f8a6020830184613dd3565b600080600080600080600080600060e08a8c031215613e3057600080fd5b8935613e3b81613a27565b985060208a0135613e4b81613a27565b975060408a0135613e5b81613a27565b965060608a013567ffffffffffffffff80821115613e7857600080fd5b613e848d838e01613ca4565b909850965060808c0135915080821115613e9d57600080fd5b50613eaa8c828d01613ae7565b9a9d999c50979a96999598959660a08101359660c09091013595509350505050565b60038110613d9d57613d9d613d77565b600081518084526020808501945080840160005b83811015613f455781518051885283810151613f0e858a0182613ecc565b506040818101516001600160a01b03169089015260609081015164ffffffffff169088015260809096019590820190600101613ef0565b509495945050505050565b60208152613f62602082018351613d8d565b60006020830151613f766040840182613ecc565b50604083015164ffffffffff8116606084015250606083015162ffffff8116608084015250608083015164ffffffffff811660a08401525060a083015164ffffffffff811660c08401525060c083015164ffffffffff811660e08401525060e0830151610100613ff0818501836001600160a01b03169052565b840151905061012061400c848201836001600160a01b03169052565b84015161014084810191909152840151610160808501919091528401519050610180614042818501836001600160801b03169052565b84015190506101a061405e848201836001600160801b03169052565b8401516101c0848101919091528401516101e080850152905061347e610200840182613edc565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b80820180821115610f8d57610f8d6140b1565b6000602082840312156140ec57600080fd5b5051919050565b600060018201614105576141056140b1565b5060010190565b8135815560018101602083013561412281613b75565b6003811061413257614132613d77565b8154604085013561414281613a27565b606086013564ffffffffff8116811461415a57600080fd5b60089190911b610100600160a81b03166001600160d01b03199290921660ff93909316929092171760a89190911b64ffffffffff60a81b161790555050565b604051601f8201601f1916810167ffffffffffffffff811182821017156141c2576141c2614085565b604052919050565b803562ffffff81168114613d3657600080fd5b600060c082840312156141ef57600080fd5b60405160c0810181811067ffffffffffffffff8211171561421257614212614085565b604052823561422081613b75565b815261422e602084016141ca565b602082015261423f604084016141ca565b6040820152606083013560608201526080830135608082015260a083013560a08201528091505092915050565b64ffffffffff818116838216019080821115612ac557612ac56140b1565b6000825161429c818460208701613daf565b9190910192915050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b81810381811115610f8d57610f8d6140b1565b600081614316576143166140b1565b506000190190565b6000602080838503121561433157600080fd5b825167ffffffffffffffff8082111561434957600080fd5b818501915085601f83011261435d57600080fd5b81518181111561436f5761436f614085565b8060051b9150614380848301614199565b818152918301840191848101908884111561439a57600080fd5b938501935b838510156143c457845192506143b483613a27565b828252938501939085019061439f565b98975050505050505050565b8082028115828204841417610f8d57610f8d6140b1565b64ffffffffff848116825260608201906144046020840186613ecc565b808416604084015250949350505050565b84815260018060a01b03841660208201528260408201526080606082015260006144426080830184613dd3565b9695505050505050565b6000806040838503121561445f57600080fd5b505080516020909101519092909150565b62ffffff818116838216019080821115612ac557612ac56140b1565b634e487b7160e01b600052603160045260246000fd5b6000826144bf57634e487b7160e01b600052601260045260246000fd5b50049056fea2646970667358221220aae704222234de070df38296fe1b6347eaa8a4ebe1646c846c0df5d2fa96c7f364736f6c63430008130033000000000000000000000000ed42a7d8559a463722ca4bed50e0cc05a386b0e10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000464c71f6c2f760dda6093dcb91c24c39e5d6e18c","name":"Governance","is_blueprint":false,"license_type":"none","is_fully_verified":true,"is_verified_via_eth_bytecode_db":true,"language":"solidity","evm_version":"paris","can_be_visualized_via_sol2uml":true,"is_verified_via_sourcify":true,"additional_sources":[{"file_path":"lib/aave-delivery-infrastructure/src/contracts/interfaces/IBaseReceiverPortal.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/**\n * @title IBaseReceiverPortal\n * @author BGD Labs\n * @notice interface defining the method that needs to be implemented by all receiving portals, as its the one that\n           will be called when a received message gets confirmed\n */\ninterface IBaseReceiverPortal {\n  /**\n   * @notice method called by CrossChainController when a message has been confirmed\n   * @param originSender address of the sender of the bridged message\n   * @param originChainId id of the chain where the message originated\n   * @param message bytes bridged containing the desired information\n   */\n  function receiveCrossChainMessage(\n    address originSender,\n    uint256 originChainId,\n    bytes memory message\n  ) external;\n}\n"},{"file_path":"lib/aave-delivery-infrastructure/src/contracts/interfaces/ICrossChainForwarder.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.8;\n\nimport {Transaction, Envelope} from '../libs/EncodingUtils.sol';\n\n/**\n * @title ICrossChainForwarder\n * @author BGD Labs\n * @notice interface containing the objects, events and methods definitions of the CrossChainForwarder contract\n */\ninterface ICrossChainForwarder {\n  /**\n   * @notice object storing the connected pair of bridge adapters, on current and destination chain\n   * @param destinationBridgeAdapter address of the bridge adapter on the destination chain\n   * @param currentChainBridgeAdapter address of the bridge adapter deployed on current network\n   */\n  struct ChainIdBridgeConfig {\n    address destinationBridgeAdapter;\n    address currentChainBridgeAdapter;\n  }\n\n  /**\n   * @notice object with the necessary information to remove bridge adapters\n   * @param bridgeAdapter address of the bridge adapter to remove\n   * @param chainIds array of chain ids where the bridge adapter connects\n   */\n  struct BridgeAdapterToDisable {\n    address bridgeAdapter;\n    uint256[] chainIds;\n  }\n\n  /**\n   * @notice object storing the pair bridgeAdapter (current deployed chain) destination chain bridge adapter configuration\n   * @param currentChainBridgeAdapter address of the bridge adapter deployed on current chain\n   * @param destinationBridgeAdapter address of the bridge adapter on the destination chain\n   * @param destinationChainId id of the destination chain using our own nomenclature\n   */\n  struct ForwarderBridgeAdapterConfigInput {\n    address currentChainBridgeAdapter;\n    address destinationBridgeAdapter;\n    uint256 destinationChainId;\n  }\n\n  /**\n   * @notice emitted when a transaction is successfully forwarded through a bridge adapter\n   * @param envelopeId internal id of the envelope\n   * @param envelope the Envelope type data\n   */\n  event EnvelopeRegistered(bytes32 indexed envelopeId, Envelope envelope);\n\n  /**\n   * @notice emitted when a transaction forwarding is attempted through a bridge adapter\n   * @param transactionId id of the forwarded transaction\n   * @param envelopeId internal id of the envelope\n   * @param encodedTransaction object intended to be bridged\n   * @param destinationChainId id of the destination chain in our notation\n   * @param bridgeAdapter address of the bridge adapter that failed (deployed on current network)\n   * @param destinationBridgeAdapter address of the connected bridge adapter on destination chain\n   * @param adapterSuccessful adapter was able to forward the message\n   * @param returnData bytes with error information\n   */\n  event TransactionForwardingAttempted(\n    bytes32 transactionId,\n    bytes32 indexed envelopeId,\n    bytes encodedTransaction,\n    uint256 destinationChainId,\n    address indexed bridgeAdapter,\n    address destinationBridgeAdapter,\n    bool indexed adapterSuccessful,\n    bytes returnData\n  );\n\n  /**\n   * @notice emitted when a bridge adapter has been added to the allowed list\n   * @param destinationChainId id of the destination chain in our notation\n   * @param bridgeAdapter address of the bridge adapter added (deployed on current network)\n   * @param destinationBridgeAdapter address of the connected bridge adapter on destination chain\n   * @param allowed boolean indicating if the bridge adapter is allowed or disallowed\n   */\n  event BridgeAdapterUpdated(\n    uint256 indexed destinationChainId,\n    address indexed bridgeAdapter,\n    address destinationBridgeAdapter,\n    bool indexed allowed\n  );\n\n  /**\n   * @notice emitted when a sender has been updated\n   * @param sender address of the updated sender\n   * @param isApproved boolean that indicates if the sender has been approved or removed\n   */\n  event SenderUpdated(address indexed sender, bool indexed isApproved);\n\n  /**\n   * @notice method to get the current valid envelope nonce\n   * @return the current valid envelope nonce\n   */\n  function getCurrentEnvelopeNonce() external view returns (uint256);\n\n  /**\n   * @notice method to get the current valid transaction nonce\n   * @return the current valid transaction nonce\n   */\n  function getCurrentTransactionNonce() external view returns (uint256);\n\n  /**\n   * @notice method to check if a envelope has been previously forwarded.\n   * @param envelope the Envelope type data\n   * @return boolean indicating if the envelope has been registered\n   */\n  function isEnvelopeRegistered(Envelope memory envelope) external view returns (bool);\n\n  /**\n   * @notice method to check if a envelope has been previously forwarded.\n   * @param envelopeId the hashed id of the envelope\n   * @return boolean indicating if the envelope has been registered\n   */\n  function isEnvelopeRegistered(bytes32 envelopeId) external view returns (bool);\n\n  /**\n   * @notice method to get if a transaction has been forwarded\n   * @param transaction the Transaction type data\n   * @return flag indicating if a transaction has been forwarded\n   */\n  function isTransactionForwarded(Transaction memory transaction) external view returns (bool);\n\n  /**\n   * @notice method to get if a transaction has been forwarded\n   * @param transactionId hashed id of the transaction\n   * @return flag indicating if a transaction has been forwarded\n   */\n  function isTransactionForwarded(bytes32 transactionId) external view returns (bool);\n\n  /**\n   * @notice method called to initiate message forwarding to other networks.\n   * @param destinationChainId id of the destination chain where the message needs to be bridged\n   * @param destination address where the message is intended for\n   * @param gasLimit gas cost on receiving side of the message\n   * @param message bytes that need to be bridged\n   * @return internal id of the envelope and transaction\n   */\n  function forwardMessage(\n    uint256 destinationChainId,\n    address destination,\n    uint256 gasLimit,\n    bytes memory message\n  ) external returns (bytes32, bytes32);\n\n  /**\n   * @notice method called to re forward a previously sent envelope.\n   * @param envelope the Envelope type data\n   * @param gasLimit gas cost on receiving side of the message\n   * @return the transaction id that has the retried envelope\n   * @dev This method will send an existing Envelope using a new Transaction.\n   * @dev This method should be used when the intention is to send the Envelope as if it was a new message. This way on\n          the Receiver side it will start from 0 to count for the required confirmations. (usual use case would be for\n          when an envelope has been invalidated on Receiver side, and needs to be retried as a new message)\n   */\n  function retryEnvelope(Envelope memory envelope, uint256 gasLimit) external returns (bytes32);\n\n  /**\n   * @notice method to retry forwarding an already forwarded transaction\n   * @param encodedTransaction the encoded Transaction data\n   * @param gasLimit limit of gas to spend on forwarding per bridge\n   * @param bridgeAdaptersToRetry list of bridge adapters to be used for the transaction forwarding retry\n   * @dev This method will send an existing Transaction with its Envelope to the specified adapters.\n   * @dev Should be used when some of the bridges on the initial forwarding did not work (out of gas),\n          and we want the Transaction with Envelope to still account for the required confirmations on the Receiver side\n   */\n  function retryTransaction(\n    bytes memory encodedTransaction,\n    uint256 gasLimit,\n    address[] memory bridgeAdaptersToRetry\n  ) external;\n\n  /**\n   * @notice method to enable bridge adapters\n   * @param bridgeAdapters array of new bridge adapter configurations\n   */\n  function enableBridgeAdapters(ForwarderBridgeAdapterConfigInput[] memory bridgeAdapters) external;\n\n  /**\n   * @notice method to disable bridge adapters\n   * @param bridgeAdapters array of bridge adapter addresses to disable\n   */\n  function disableBridgeAdapters(BridgeAdapterToDisable[] memory bridgeAdapters) external;\n\n  /**\n   * @notice method to remove sender addresses\n   * @param senders list of addresses to remove\n   */\n  function removeSenders(address[] memory senders) external;\n\n  /**\n   * @notice method to approve new sender addresses\n   * @param senders list of addresses to approve\n   */\n  function approveSenders(address[] memory senders) external;\n\n  /**\n   * @notice method to get all the forwarder bridge adapters of a chain\n   * @param chainId id of the chain we want to get the adapters from\n   * @return an array of chain configurations where the bridge adapter can communicate\n   */\n  function getForwarderBridgeAdaptersByChain(\n    uint256 chainId\n  ) external view returns (ChainIdBridgeConfig[] memory);\n\n  /**\n   * @notice method to get if a sender is approved\n   * @param sender address that we want to check if approved\n   * @return boolean indicating if the address has been approved as sender\n   */\n  function isSenderApproved(address sender) external view returns (bool);\n}\n"},{"file_path":"lib/aave-delivery-infrastructure/src/contracts/libs/EncodingUtils.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nusing EnvelopeUtils for Envelope global;\nusing TransactionUtils for Transaction global;\n\n/**\n * @notice Object with the necessary information to define a unique envelope\n * @param nonce sequential (unique) numeric indicator of the Envelope creation\n * @param origin address that originated the bridging of a message\n * @param destination address where the message needs to be sent\n * @param originChainId id of the chain where the message originated\n * @param destinationChainId id of the chain where the message needs to be bridged\n * @param message bytes that needs to be bridged\n */\nstruct Envelope {\n  uint256 nonce;\n  address origin;\n  address destination;\n  uint256 originChainId;\n  uint256 destinationChainId;\n  bytes message;\n}\n\n/**\n * @notice Object containing the information of an envelope for internal usage\n * @param data bytes of the encoded envelope\n * @param id hash of the encoded envelope\n */\nstruct EncodedEnvelope {\n  bytes data;\n  bytes32 id;\n}\n\n/**\n * @title EnvelopeUtils library\n * @author BGD Labs\n * @notice Defines utility functions for Envelopes\n */\nlibrary EnvelopeUtils {\n  /**\n   * @notice method that encodes an Envelope and generates its id\n   * @param envelope object with the routing information necessary to send a message to a destination chain\n   * @return object containing the encoded envelope and the envelope id\n   */\n  function encode(Envelope memory envelope) internal pure returns (EncodedEnvelope memory) {\n    EncodedEnvelope memory encodedEnvelope;\n    encodedEnvelope.data = abi.encode(envelope);\n    encodedEnvelope.id = getId(encodedEnvelope.data);\n    return encodedEnvelope;\n  }\n\n  /**\n   * @notice method to decode and encoded envelope to its raw parameters\n   * @param envelope bytes with the encoded envelope data\n   * @return object with the decoded envelope information\n   */\n  function decode(bytes memory envelope) internal pure returns (Envelope memory) {\n    return abi.decode(envelope, (Envelope));\n  }\n\n  /**\n   * @notice method to get an envelope's id\n   * @param envelope object with the routing information necessary to send a message to a destination chain\n   * @return hash id of the envelope\n   */\n  function getId(Envelope memory envelope) internal pure returns (bytes32) {\n    EncodedEnvelope memory encodedEnvelope = encode(envelope);\n    return encodedEnvelope.id;\n  }\n\n  /**\n   * @notice method to get an envelope's id\n   * @param envelope bytes with the encoded envelope data\n   * @return hash id of the envelope\n   */\n  function getId(bytes memory envelope) internal pure returns (bytes32) {\n    return keccak256(envelope);\n  }\n}\n\n/**\n * @notice Object with the necessary information to send an envelope to a bridge\n * @param nonce sequential (unique) numeric indicator of the Transaction creation\n * @param encodedEnvelope bytes of an encoded envelope object\n */\nstruct Transaction {\n  uint256 nonce;\n  bytes encodedEnvelope;\n}\n\n/**\n * @notice Object containing the information of a transaction for internal usage\n * @param data bytes of the encoded transaction\n * @param id hash of the encoded transaction\n */\nstruct EncodedTransaction {\n  bytes data;\n  bytes32 id;\n}\n\n/**\n * @title TransactionUtils library\n * @author BGD Labs\n * @notice Defines utility functions for Transactions\n */\nlibrary TransactionUtils {\n  /**\n   * @notice method that encodes a Transaction and generates its id\n   * @param transaction object with the information necessary to send an envelope to a bridge\n   * @return object containing the encoded transaction and the transaction id\n   */\n  function encode(\n    Transaction memory transaction\n  ) internal pure returns (EncodedTransaction memory) {\n    EncodedTransaction memory encodedTransaction;\n    encodedTransaction.data = abi.encode(transaction);\n    encodedTransaction.id = getId(encodedTransaction.data);\n    return encodedTransaction;\n  }\n\n  /**\n   * @notice method that decodes an encoded transaction (bytes) into a Transaction object\n   * @param transaction encoded transaction object\n   * @return object containing the decoded Transaction object\n   */\n  function decode(bytes memory transaction) internal pure returns (Transaction memory) {\n    return abi.decode(transaction, (Transaction));\n  }\n\n  /**\n   * @notice method to get a transaction id\n   * @param transaction object with the information necessary to send an envelope to a bridge\n   * @return hash id of the transaction\n   */\n  function getId(Transaction memory transaction) internal pure returns (bytes32) {\n    EncodedTransaction memory encodedTransaction = encode(transaction);\n    return encodedTransaction.id;\n  }\n\n  /**\n   * @notice method to get a transaction id\n   * @param transaction encoded transaction object\n   * @return hash id of the transaction\n   */\n  function getId(bytes memory transaction) internal pure returns (bytes32) {\n    return keccak256(transaction);\n  }\n\n  /**\n   * @notice method to get the envelope information from the transaction object\n   * @param transaction object with the information necessary to send an envelope to a bridge\n   * @return object with decoded information of the envelope in the transaction\n   */\n  function getEnvelope(Transaction memory transaction) internal pure returns (Envelope memory) {\n    return EnvelopeUtils.decode(transaction.encodedEnvelope);\n  }\n\n  /**\n   * @notice method to get the envelope id from the transaction object\n   * @param transaction object with the information necessary to send an envelope to a bridge\n   * @return hash id of the envelope on a transaction\n   */\n  function getEnvelopeId(Transaction memory transaction) internal pure returns (bytes32) {\n    return EnvelopeUtils.getId(transaction.encodedEnvelope);\n  }\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/utils/structs/EnumerableSet.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n *     // Add the library methods\n *     using EnumerableSet for EnumerableSet.AddressSet;\n *\n *     // Declare a set state variable\n *     EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n    // To implement this library for multiple types with as little code\n    // repetition as possible, we write it in terms of a generic Set type with\n    // bytes32 values.\n    // The Set implementation uses private functions, and user-facing\n    // implementations (such as AddressSet) are just wrappers around the\n    // underlying Set.\n    // This means that we can only create new EnumerableSets for types that fit\n    // in bytes32.\n\n    struct Set {\n        // Storage of set values\n        bytes32[] _values;\n        // Position of the value in the `values` array, plus 1 because index 0\n        // means a value is not in the set.\n        mapping(bytes32 => uint256) _indexes;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function _add(Set storage set, bytes32 value) private returns (bool) {\n        if (!_contains(set, value)) {\n            set._values.push(value);\n            // The value is stored at length-1, but we add 1 to all indexes\n            // and use 0 as a sentinel value\n            set._indexes[value] = set._values.length;\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function _remove(Set storage set, bytes32 value) private returns (bool) {\n        // We read and store the value's index to prevent multiple reads from the same storage slot\n        uint256 valueIndex = set._indexes[value];\n\n        if (valueIndex != 0) {\n            // Equivalent to contains(set, value)\n            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n            // the array, and then remove the last element (sometimes called as 'swap and pop').\n            // This modifies the order of the array, as noted in {at}.\n\n            uint256 toDeleteIndex = valueIndex - 1;\n            uint256 lastIndex = set._values.length - 1;\n\n            if (lastIndex != toDeleteIndex) {\n                bytes32 lastValue = set._values[lastIndex];\n\n                // Move the last value to the index where the value to delete is\n                set._values[toDeleteIndex] = lastValue;\n                // Update the index for the moved value\n                set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\n            }\n\n            // Delete the slot where the moved value was stored\n            set._values.pop();\n\n            // Delete the index for the deleted slot\n            delete set._indexes[value];\n\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function _contains(Set storage set, bytes32 value) private view returns (bool) {\n        return set._indexes[value] != 0;\n    }\n\n    /**\n     * @dev Returns the number of values on the set. O(1).\n     */\n    function _length(Set storage set) private view returns (uint256) {\n        return set._values.length;\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function _at(Set storage set, uint256 index) private view returns (bytes32) {\n        return set._values[index];\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function _values(Set storage set) private view returns (bytes32[] memory) {\n        return set._values;\n    }\n\n    // Bytes32Set\n\n    struct Bytes32Set {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n        return _add(set._inner, value);\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n        return _remove(set._inner, value);\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n        return _contains(set._inner, value);\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(Bytes32Set storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n        return _at(set._inner, index);\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n        bytes32[] memory store = _values(set._inner);\n        bytes32[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n\n    // AddressSet\n\n    struct AddressSet {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(AddressSet storage set, address value) internal returns (bool) {\n        return _add(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(AddressSet storage set, address value) internal returns (bool) {\n        return _remove(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(AddressSet storage set, address value) internal view returns (bool) {\n        return _contains(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(AddressSet storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(AddressSet storage set, uint256 index) internal view returns (address) {\n        return address(uint160(uint256(_at(set._inner, index))));\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(AddressSet storage set) internal view returns (address[] memory) {\n        bytes32[] memory store = _values(set._inner);\n        address[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n\n    // UintSet\n\n    struct UintSet {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(UintSet storage set, uint256 value) internal returns (bool) {\n        return _add(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(UintSet storage set, uint256 value) internal returns (bool) {\n        return _remove(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n        return _contains(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(UintSet storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n        return uint256(_at(set._inner, index));\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(UintSet storage set) internal view returns (uint256[] memory) {\n        bytes32[] memory store = _values(set._inner);\n        uint256[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n}\n"},{"file_path":"lib/solidity-utils/src/contracts/access-control/OwnableWithGuardian.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.7.0;\n\nimport {IWithGuardian} from './interfaces/IWithGuardian.sol';\nimport {Ownable} from '../oz-common/Ownable.sol';\n\nabstract contract OwnableWithGuardian is Ownable, IWithGuardian {\n  address private _guardian;\n\n  constructor() {\n    _updateGuardian(_msgSender());\n  }\n\n  modifier onlyGuardian() {\n    _checkGuardian();\n    _;\n  }\n\n  modifier onlyOwnerOrGuardian() {\n    _checkOwnerOrGuardian();\n    _;\n  }\n\n  function guardian() public view override returns (address) {\n    return _guardian;\n  }\n\n  /// @inheritdoc IWithGuardian\n  function updateGuardian(address newGuardian) external override onlyOwnerOrGuardian {\n    _updateGuardian(newGuardian);\n  }\n\n  /**\n   * @dev method to update the guardian\n   * @param newGuardian the new guardian address\n   */\n  function _updateGuardian(address newGuardian) internal {\n    address oldGuardian = _guardian;\n    _guardian = newGuardian;\n    emit GuardianUpdated(oldGuardian, newGuardian);\n  }\n\n  function _checkGuardian() internal view {\n    require(guardian() == _msgSender(), 'ONLY_BY_GUARDIAN');\n  }\n\n  function _checkOwnerOrGuardian() internal view {\n    require(_msgSender() == owner() || _msgSender() == guardian(), 'ONLY_BY_OWNER_OR_GUARDIAN');\n  }\n}\n"},{"file_path":"lib/solidity-utils/src/contracts/access-control/interfaces/IWithGuardian.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity >=0.7.0;\n\ninterface IWithGuardian {\n  /**\n   * @dev Event emitted when guardian gets updated\n   * @param oldGuardian address of previous guardian\n   * @param newGuardian address of the new guardian\n   */\n  event GuardianUpdated(address oldGuardian, address newGuardian);\n\n  /**\n   * @dev get guardian address;\n   */\n  function guardian() external view returns (address);\n\n  /**\n   * @dev method to update the guardian\n   * @param newGuardian the new guardian address\n   */\n  function updateGuardian(address newGuardian) external;\n}\n"},{"file_path":"lib/solidity-utils/src/contracts/oz-common/Address.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n// From commit https://github.com/OpenZeppelin/openzeppelin-contracts/commit/8b778fa20d6d76340c5fac1ed66c80273f05b95a\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n  /**\n   * @dev Returns true if `account` is a contract.\n   *\n   * [IMPORTANT]\n   * ====\n   * It is unsafe to assume that an address for which this function returns\n   * false is an externally-owned account (EOA) and not a contract.\n   *\n   * Among others, `isContract` will return false for the following\n   * types of addresses:\n   *\n   *  - an externally-owned account\n   *  - a contract in construction\n   *  - an address where a contract will be created\n   *  - an address where a contract lived, but was destroyed\n   * ====\n   *\n   * [IMPORTANT]\n   * ====\n   * You shouldn't rely on `isContract` to protect against flash loan attacks!\n   *\n   * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n   * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n   * constructor.\n   * ====\n   */\n  function isContract(address account) internal view returns (bool) {\n    // This method relies on extcodesize/address.code.length, which returns 0\n    // for contracts in construction, since the code is only stored at the end\n    // of the constructor execution.\n\n    return account.code.length > 0;\n  }\n\n  /**\n   * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n   * `recipient`, forwarding all available gas and reverting on errors.\n   *\n   * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n   * of certain opcodes, possibly making contracts go over the 2300 gas limit\n   * imposed by `transfer`, making them unable to receive funds via\n   * `transfer`. {sendValue} removes this limitation.\n   *\n   * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n   *\n   * IMPORTANT: because control is transferred to `recipient`, care must be\n   * taken to not create reentrancy vulnerabilities. Consider using\n   * {ReentrancyGuard} or the\n   * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n   */\n  function sendValue(address payable recipient, uint256 amount) internal {\n    require(address(this).balance >= amount, 'Address: insufficient balance');\n\n    (bool success, ) = recipient.call{value: amount}('');\n    require(success, 'Address: unable to send value, recipient may have reverted');\n  }\n\n  /**\n   * @dev Performs a Solidity function call using a low level `call`. A\n   * plain `call` is an unsafe replacement for a function call: use this\n   * function instead.\n   *\n   * If `target` reverts with a revert reason, it is bubbled up by this\n   * function (like regular Solidity function calls).\n   *\n   * Returns the raw returned data. To convert to the expected return value,\n   * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n   *\n   * Requirements:\n   *\n   * - `target` must be a contract.\n   * - calling `target` with `data` must not revert.\n   *\n   * _Available since v3.1._\n   */\n  function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n    return functionCallWithValue(target, data, 0, 'Address: low-level call failed');\n  }\n\n  /**\n   * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n   * `errorMessage` as a fallback revert reason when `target` reverts.\n   *\n   * _Available since v3.1._\n   */\n  function functionCall(\n    address target,\n    bytes memory data,\n    string memory errorMessage\n  ) internal returns (bytes memory) {\n    return functionCallWithValue(target, data, 0, errorMessage);\n  }\n\n  /**\n   * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n   * but also transferring `value` wei to `target`.\n   *\n   * Requirements:\n   *\n   * - the calling contract must have an ETH balance of at least `value`.\n   * - the called Solidity function must be `payable`.\n   *\n   * _Available since v3.1._\n   */\n  function functionCallWithValue(\n    address target,\n    bytes memory data,\n    uint256 value\n  ) internal returns (bytes memory) {\n    return functionCallWithValue(target, data, value, 'Address: low-level call with value failed');\n  }\n\n  /**\n   * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n   * with `errorMessage` as a fallback revert reason when `target` reverts.\n   *\n   * _Available since v3.1._\n   */\n  function functionCallWithValue(\n    address target,\n    bytes memory data,\n    uint256 value,\n    string memory errorMessage\n  ) internal returns (bytes memory) {\n    require(address(this).balance >= value, 'Address: insufficient balance for call');\n    (bool success, bytes memory returndata) = target.call{value: value}(data);\n    return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n  }\n\n  /**\n   * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n   * but performing a static call.\n   *\n   * _Available since v3.3._\n   */\n  function functionStaticCall(\n    address target,\n    bytes memory data\n  ) internal view returns (bytes memory) {\n    return functionStaticCall(target, data, 'Address: low-level static call failed');\n  }\n\n  /**\n   * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n   * but performing a static call.\n   *\n   * _Available since v3.3._\n   */\n  function functionStaticCall(\n    address target,\n    bytes memory data,\n    string memory errorMessage\n  ) internal view returns (bytes memory) {\n    (bool success, bytes memory returndata) = target.staticcall(data);\n    return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n  }\n\n  /**\n   * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n   * but performing a delegate call.\n   *\n   * _Available since v3.4._\n   */\n  function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n    return functionDelegateCall(target, data, 'Address: low-level delegate call failed');\n  }\n\n  /**\n   * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n   * but performing a delegate call.\n   *\n   * _Available since v3.4._\n   */\n  function functionDelegateCall(\n    address target,\n    bytes memory data,\n    string memory errorMessage\n  ) internal returns (bytes memory) {\n    (bool success, bytes memory returndata) = target.delegatecall(data);\n    return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n  }\n\n  /**\n   * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n   * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n   *\n   * _Available since v4.8._\n   */\n  function verifyCallResultFromTarget(\n    address target,\n    bool success,\n    bytes memory returndata,\n    string memory errorMessage\n  ) internal view returns (bytes memory) {\n    if (success) {\n      if (returndata.length == 0) {\n        // only check isContract if the call was successful and the return data is empty\n        // otherwise we already know that it was a contract\n        require(isContract(target), 'Address: call to non-contract');\n      }\n      return returndata;\n    } else {\n      _revert(returndata, errorMessage);\n    }\n  }\n\n  /**\n   * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n   * revert reason or using the provided one.\n   *\n   * _Available since v4.3._\n   */\n  function verifyCallResult(\n    bool success,\n    bytes memory returndata,\n    string memory errorMessage\n  ) internal pure returns (bytes memory) {\n    if (success) {\n      return returndata;\n    } else {\n      _revert(returndata, errorMessage);\n    }\n  }\n\n  function _revert(bytes memory returndata, string memory errorMessage) private pure {\n    // Look for revert reason and bubble it up if present\n    if (returndata.length > 0) {\n      // The easiest way to bubble the revert reason is using memory via assembly\n      /// @solidity memory-safe-assembly\n      assembly {\n        let returndata_size := mload(returndata)\n        revert(add(32, returndata), returndata_size)\n      }\n    } else {\n      revert(errorMessage);\n    }\n  }\n}\n"},{"file_path":"lib/solidity-utils/src/contracts/oz-common/Context.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n// From commit https://github.com/OpenZeppelin/openzeppelin-contracts/commit/8b778fa20d6d76340c5fac1ed66c80273f05b95a\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n  function _msgSender() internal view virtual returns (address) {\n    return msg.sender;\n  }\n\n  function _msgData() internal view virtual returns (bytes calldata) {\n    return msg.data;\n  }\n}\n"},{"file_path":"lib/solidity-utils/src/contracts/oz-common/Ownable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n// From commit https://github.com/OpenZeppelin/openzeppelin-contracts/commit/8b778fa20d6d76340c5fac1ed66c80273f05b95a\n\npragma solidity ^0.8.0;\n\nimport './Context.sol';\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n  address private _owner;\n\n  event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n  /**\n   * @dev Initializes the contract setting the deployer as the initial owner.\n   */\n  constructor() {\n    _transferOwnership(_msgSender());\n  }\n\n  /**\n   * @dev Throws if called by any account other than the owner.\n   */\n  modifier onlyOwner() {\n    _checkOwner();\n    _;\n  }\n\n  /**\n   * @dev Returns the address of the current owner.\n   */\n  function owner() public view virtual returns (address) {\n    return _owner;\n  }\n\n  /**\n   * @dev Throws if the sender is not the owner.\n   */\n  function _checkOwner() internal view virtual {\n    require(owner() == _msgSender(), 'Ownable: caller is not the owner');\n  }\n\n  /**\n   * @dev Leaves the contract without owner. It will not be possible to call\n   * `onlyOwner` functions anymore. Can only be called by the current owner.\n   *\n   * NOTE: Renouncing ownership will leave the contract without an owner,\n   * thereby removing any functionality that is only available to the owner.\n   */\n  function renounceOwnership() public virtual onlyOwner {\n    _transferOwnership(address(0));\n  }\n\n  /**\n   * @dev Transfers ownership of the contract to a new account (`newOwner`).\n   * Can only be called by the current owner.\n   */\n  function transferOwnership(address newOwner) public virtual onlyOwner {\n    require(newOwner != address(0), 'Ownable: new owner is the zero address');\n    _transferOwnership(newOwner);\n  }\n\n  /**\n   * @dev Transfers ownership of the contract to a new account (`newOwner`).\n   * Internal function without access restriction.\n   */\n  function _transferOwnership(address newOwner) internal virtual {\n    address oldOwner = _owner;\n    _owner = newOwner;\n    emit OwnershipTransferred(oldOwner, newOwner);\n  }\n}\n"},{"file_path":"lib/solidity-utils/src/contracts/oz-common/SafeCast.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCast {\n  /**\n   * @dev Returns the downcasted uint248 from uint256, reverting on\n   * overflow (when the input is greater than largest uint248).\n   *\n   * Counterpart to Solidity's `uint248` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 248 bits\n   *\n   * _Available since v4.7._\n   */\n  function toUint248(uint256 value) internal pure returns (uint248) {\n    require(value <= type(uint248).max, \"SafeCast: value doesn't fit in 248 bits\");\n    return uint248(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint240 from uint256, reverting on\n   * overflow (when the input is greater than largest uint240).\n   *\n   * Counterpart to Solidity's `uint240` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 240 bits\n   *\n   * _Available since v4.7._\n   */\n  function toUint240(uint256 value) internal pure returns (uint240) {\n    require(value <= type(uint240).max, \"SafeCast: value doesn't fit in 240 bits\");\n    return uint240(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint232 from uint256, reverting on\n   * overflow (when the input is greater than largest uint232).\n   *\n   * Counterpart to Solidity's `uint232` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 232 bits\n   *\n   * _Available since v4.7._\n   */\n  function toUint232(uint256 value) internal pure returns (uint232) {\n    require(value <= type(uint232).max, \"SafeCast: value doesn't fit in 232 bits\");\n    return uint232(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint224 from uint256, reverting on\n   * overflow (when the input is greater than largest uint224).\n   *\n   * Counterpart to Solidity's `uint224` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 224 bits\n   *\n   * _Available since v4.2._\n   */\n  function toUint224(uint256 value) internal pure returns (uint224) {\n    require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\n    return uint224(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint216 from uint256, reverting on\n   * overflow (when the input is greater than largest uint216).\n   *\n   * Counterpart to Solidity's `uint216` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 216 bits\n   *\n   * _Available since v4.7._\n   */\n  function toUint216(uint256 value) internal pure returns (uint216) {\n    require(value <= type(uint216).max, \"SafeCast: value doesn't fit in 216 bits\");\n    return uint216(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint208 from uint256, reverting on\n   * overflow (when the input is greater than largest uint208).\n   *\n   * Counterpart to Solidity's `uint208` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 208 bits\n   *\n   * _Available since v4.7._\n   */\n  function toUint208(uint256 value) internal pure returns (uint208) {\n    require(value <= type(uint208).max, \"SafeCast: value doesn't fit in 208 bits\");\n    return uint208(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint200 from uint256, reverting on\n   * overflow (when the input is greater than largest uint200).\n   *\n   * Counterpart to Solidity's `uint200` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 200 bits\n   *\n   * _Available since v4.7._\n   */\n  function toUint200(uint256 value) internal pure returns (uint200) {\n    require(value <= type(uint200).max, \"SafeCast: value doesn't fit in 200 bits\");\n    return uint200(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint192 from uint256, reverting on\n   * overflow (when the input is greater than largest uint192).\n   *\n   * Counterpart to Solidity's `uint192` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 192 bits\n   *\n   * _Available since v4.7._\n   */\n  function toUint192(uint256 value) internal pure returns (uint192) {\n    require(value <= type(uint192).max, \"SafeCast: value doesn't fit in 192 bits\");\n    return uint192(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint184 from uint256, reverting on\n   * overflow (when the input is greater than largest uint184).\n   *\n   * Counterpart to Solidity's `uint184` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 184 bits\n   *\n   * _Available since v4.7._\n   */\n  function toUint184(uint256 value) internal pure returns (uint184) {\n    require(value <= type(uint184).max, \"SafeCast: value doesn't fit in 184 bits\");\n    return uint184(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint176 from uint256, reverting on\n   * overflow (when the input is greater than largest uint176).\n   *\n   * Counterpart to Solidity's `uint176` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 176 bits\n   *\n   * _Available since v4.7._\n   */\n  function toUint176(uint256 value) internal pure returns (uint176) {\n    require(value <= type(uint176).max, \"SafeCast: value doesn't fit in 176 bits\");\n    return uint176(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint168 from uint256, reverting on\n   * overflow (when the input is greater than largest uint168).\n   *\n   * Counterpart to Solidity's `uint168` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 168 bits\n   *\n   * _Available since v4.7._\n   */\n  function toUint168(uint256 value) internal pure returns (uint168) {\n    require(value <= type(uint168).max, \"SafeCast: value doesn't fit in 168 bits\");\n    return uint168(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint160 from uint256, reverting on\n   * overflow (when the input is greater than largest uint160).\n   *\n   * Counterpart to Solidity's `uint160` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 160 bits\n   *\n   * _Available since v4.7._\n   */\n  function toUint160(uint256 value) internal pure returns (uint160) {\n    require(value <= type(uint160).max, \"SafeCast: value doesn't fit in 160 bits\");\n    return uint160(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint152 from uint256, reverting on\n   * overflow (when the input is greater than largest uint152).\n   *\n   * Counterpart to Solidity's `uint152` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 152 bits\n   *\n   * _Available since v4.7._\n   */\n  function toUint152(uint256 value) internal pure returns (uint152) {\n    require(value <= type(uint152).max, \"SafeCast: value doesn't fit in 152 bits\");\n    return uint152(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint144 from uint256, reverting on\n   * overflow (when the input is greater than largest uint144).\n   *\n   * Counterpart to Solidity's `uint144` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 144 bits\n   *\n   * _Available since v4.7._\n   */\n  function toUint144(uint256 value) internal pure returns (uint144) {\n    require(value <= type(uint144).max, \"SafeCast: value doesn't fit in 144 bits\");\n    return uint144(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint136 from uint256, reverting on\n   * overflow (when the input is greater than largest uint136).\n   *\n   * Counterpart to Solidity's `uint136` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 136 bits\n   *\n   * _Available since v4.7._\n   */\n  function toUint136(uint256 value) internal pure returns (uint136) {\n    require(value <= type(uint136).max, \"SafeCast: value doesn't fit in 136 bits\");\n    return uint136(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint128 from uint256, reverting on\n   * overflow (when the input is greater than largest uint128).\n   *\n   * Counterpart to Solidity's `uint128` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 128 bits\n   *\n   * _Available since v2.5._\n   */\n  function toUint128(uint256 value) internal pure returns (uint128) {\n    require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\n    return uint128(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint120 from uint256, reverting on\n   * overflow (when the input is greater than largest uint120).\n   *\n   * Counterpart to Solidity's `uint120` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 120 bits\n   *\n   * _Available since v4.7._\n   */\n  function toUint120(uint256 value) internal pure returns (uint120) {\n    require(value <= type(uint120).max, \"SafeCast: value doesn't fit in 120 bits\");\n    return uint120(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint112 from uint256, reverting on\n   * overflow (when the input is greater than largest uint112).\n   *\n   * Counterpart to Solidity's `uint112` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 112 bits\n   *\n   * _Available since v4.7._\n   */\n  function toUint112(uint256 value) internal pure returns (uint112) {\n    require(value <= type(uint112).max, \"SafeCast: value doesn't fit in 112 bits\");\n    return uint112(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint104 from uint256, reverting on\n   * overflow (when the input is greater than largest uint104).\n   *\n   * Counterpart to Solidity's `uint104` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 104 bits\n   *\n   * _Available since v4.7._\n   */\n  function toUint104(uint256 value) internal pure returns (uint104) {\n    require(value <= type(uint104).max, \"SafeCast: value doesn't fit in 104 bits\");\n    return uint104(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint96 from uint256, reverting on\n   * overflow (when the input is greater than largest uint96).\n   *\n   * Counterpart to Solidity's `uint96` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 96 bits\n   *\n   * _Available since v4.2._\n   */\n  function toUint96(uint256 value) internal pure returns (uint96) {\n    require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\n    return uint96(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint88 from uint256, reverting on\n   * overflow (when the input is greater than largest uint88).\n   *\n   * Counterpart to Solidity's `uint88` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 88 bits\n   *\n   * _Available since v4.7._\n   */\n  function toUint88(uint256 value) internal pure returns (uint88) {\n    require(value <= type(uint88).max, \"SafeCast: value doesn't fit in 88 bits\");\n    return uint88(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint80 from uint256, reverting on\n   * overflow (when the input is greater than largest uint80).\n   *\n   * Counterpart to Solidity's `uint80` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 80 bits\n   *\n   * _Available since v4.7._\n   */\n  function toUint80(uint256 value) internal pure returns (uint80) {\n    require(value <= type(uint80).max, \"SafeCast: value doesn't fit in 80 bits\");\n    return uint80(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint72 from uint256, reverting on\n   * overflow (when the input is greater than largest uint72).\n   *\n   * Counterpart to Solidity's `uint72` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 72 bits\n   *\n   * _Available since v4.7._\n   */\n  function toUint72(uint256 value) internal pure returns (uint72) {\n    require(value <= type(uint72).max, \"SafeCast: value doesn't fit in 72 bits\");\n    return uint72(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint64 from uint256, reverting on\n   * overflow (when the input is greater than largest uint64).\n   *\n   * Counterpart to Solidity's `uint64` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 64 bits\n   *\n   * _Available since v2.5._\n   */\n  function toUint64(uint256 value) internal pure returns (uint64) {\n    require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\n    return uint64(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint56 from uint256, reverting on\n   * overflow (when the input is greater than largest uint56).\n   *\n   * Counterpart to Solidity's `uint56` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 56 bits\n   *\n   * _Available since v4.7._\n   */\n  function toUint56(uint256 value) internal pure returns (uint56) {\n    require(value <= type(uint56).max, \"SafeCast: value doesn't fit in 56 bits\");\n    return uint56(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint48 from uint256, reverting on\n   * overflow (when the input is greater than largest uint48).\n   *\n   * Counterpart to Solidity's `uint48` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 48 bits\n   *\n   * _Available since v4.7._\n   */\n  function toUint48(uint256 value) internal pure returns (uint48) {\n    require(value <= type(uint48).max, \"SafeCast: value doesn't fit in 48 bits\");\n    return uint48(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint40 from uint256, reverting on\n   * overflow (when the input is greater than largest uint40).\n   *\n   * Counterpart to Solidity's `uint40` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 40 bits\n   *\n   * _Available since v4.7._\n   */\n  function toUint40(uint256 value) internal pure returns (uint40) {\n    require(value <= type(uint40).max, \"SafeCast: value doesn't fit in 40 bits\");\n    return uint40(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint32 from uint256, reverting on\n   * overflow (when the input is greater than largest uint32).\n   *\n   * Counterpart to Solidity's `uint32` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 32 bits\n   *\n   * _Available since v2.5._\n   */\n  function toUint32(uint256 value) internal pure returns (uint32) {\n    require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\n    return uint32(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint24 from uint256, reverting on\n   * overflow (when the input is greater than largest uint24).\n   *\n   * Counterpart to Solidity's `uint24` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 24 bits\n   *\n   * _Available since v4.7._\n   */\n  function toUint24(uint256 value) internal pure returns (uint24) {\n    require(value <= type(uint24).max, \"SafeCast: value doesn't fit in 24 bits\");\n    return uint24(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint16 from uint256, reverting on\n   * overflow (when the input is greater than largest uint16).\n   *\n   * Counterpart to Solidity's `uint16` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 16 bits\n   *\n   * _Available since v2.5._\n   */\n  function toUint16(uint256 value) internal pure returns (uint16) {\n    require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\n    return uint16(value);\n  }\n\n  /**\n   * @dev Returns the downcasted uint8 from uint256, reverting on\n   * overflow (when the input is greater than largest uint8).\n   *\n   * Counterpart to Solidity's `uint8` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 8 bits\n   *\n   * _Available since v2.5._\n   */\n  function toUint8(uint256 value) internal pure returns (uint8) {\n    require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\n    return uint8(value);\n  }\n\n  /**\n   * @dev Converts a signed int256 into an unsigned uint256.\n   *\n   * Requirements:\n   *\n   * - input must be greater than or equal to 0.\n   *\n   * _Available since v3.0._\n   */\n  function toUint256(int256 value) internal pure returns (uint256) {\n    require(value >= 0, 'SafeCast: value must be positive');\n    return uint256(value);\n  }\n\n  /**\n   * @dev Returns the downcasted int248 from int256, reverting on\n   * overflow (when the input is less than smallest int248 or\n   * greater than largest int248).\n   *\n   * Counterpart to Solidity's `int248` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 248 bits\n   *\n   * _Available since v4.7._\n   */\n  function toInt248(int256 value) internal pure returns (int248 downcasted) {\n    downcasted = int248(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 248 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int240 from int256, reverting on\n   * overflow (when the input is less than smallest int240 or\n   * greater than largest int240).\n   *\n   * Counterpart to Solidity's `int240` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 240 bits\n   *\n   * _Available since v4.7._\n   */\n  function toInt240(int256 value) internal pure returns (int240 downcasted) {\n    downcasted = int240(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 240 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int232 from int256, reverting on\n   * overflow (when the input is less than smallest int232 or\n   * greater than largest int232).\n   *\n   * Counterpart to Solidity's `int232` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 232 bits\n   *\n   * _Available since v4.7._\n   */\n  function toInt232(int256 value) internal pure returns (int232 downcasted) {\n    downcasted = int232(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 232 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int224 from int256, reverting on\n   * overflow (when the input is less than smallest int224 or\n   * greater than largest int224).\n   *\n   * Counterpart to Solidity's `int224` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 224 bits\n   *\n   * _Available since v4.7._\n   */\n  function toInt224(int256 value) internal pure returns (int224 downcasted) {\n    downcasted = int224(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 224 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int216 from int256, reverting on\n   * overflow (when the input is less than smallest int216 or\n   * greater than largest int216).\n   *\n   * Counterpart to Solidity's `int216` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 216 bits\n   *\n   * _Available since v4.7._\n   */\n  function toInt216(int256 value) internal pure returns (int216 downcasted) {\n    downcasted = int216(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 216 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int208 from int256, reverting on\n   * overflow (when the input is less than smallest int208 or\n   * greater than largest int208).\n   *\n   * Counterpart to Solidity's `int208` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 208 bits\n   *\n   * _Available since v4.7._\n   */\n  function toInt208(int256 value) internal pure returns (int208 downcasted) {\n    downcasted = int208(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 208 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int200 from int256, reverting on\n   * overflow (when the input is less than smallest int200 or\n   * greater than largest int200).\n   *\n   * Counterpart to Solidity's `int200` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 200 bits\n   *\n   * _Available since v4.7._\n   */\n  function toInt200(int256 value) internal pure returns (int200 downcasted) {\n    downcasted = int200(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 200 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int192 from int256, reverting on\n   * overflow (when the input is less than smallest int192 or\n   * greater than largest int192).\n   *\n   * Counterpart to Solidity's `int192` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 192 bits\n   *\n   * _Available since v4.7._\n   */\n  function toInt192(int256 value) internal pure returns (int192 downcasted) {\n    downcasted = int192(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 192 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int184 from int256, reverting on\n   * overflow (when the input is less than smallest int184 or\n   * greater than largest int184).\n   *\n   * Counterpart to Solidity's `int184` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 184 bits\n   *\n   * _Available since v4.7._\n   */\n  function toInt184(int256 value) internal pure returns (int184 downcasted) {\n    downcasted = int184(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 184 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int176 from int256, reverting on\n   * overflow (when the input is less than smallest int176 or\n   * greater than largest int176).\n   *\n   * Counterpart to Solidity's `int176` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 176 bits\n   *\n   * _Available since v4.7._\n   */\n  function toInt176(int256 value) internal pure returns (int176 downcasted) {\n    downcasted = int176(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 176 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int168 from int256, reverting on\n   * overflow (when the input is less than smallest int168 or\n   * greater than largest int168).\n   *\n   * Counterpart to Solidity's `int168` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 168 bits\n   *\n   * _Available since v4.7._\n   */\n  function toInt168(int256 value) internal pure returns (int168 downcasted) {\n    downcasted = int168(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 168 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int160 from int256, reverting on\n   * overflow (when the input is less than smallest int160 or\n   * greater than largest int160).\n   *\n   * Counterpart to Solidity's `int160` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 160 bits\n   *\n   * _Available since v4.7._\n   */\n  function toInt160(int256 value) internal pure returns (int160 downcasted) {\n    downcasted = int160(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 160 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int152 from int256, reverting on\n   * overflow (when the input is less than smallest int152 or\n   * greater than largest int152).\n   *\n   * Counterpart to Solidity's `int152` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 152 bits\n   *\n   * _Available since v4.7._\n   */\n  function toInt152(int256 value) internal pure returns (int152 downcasted) {\n    downcasted = int152(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 152 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int144 from int256, reverting on\n   * overflow (when the input is less than smallest int144 or\n   * greater than largest int144).\n   *\n   * Counterpart to Solidity's `int144` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 144 bits\n   *\n   * _Available since v4.7._\n   */\n  function toInt144(int256 value) internal pure returns (int144 downcasted) {\n    downcasted = int144(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 144 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int136 from int256, reverting on\n   * overflow (when the input is less than smallest int136 or\n   * greater than largest int136).\n   *\n   * Counterpart to Solidity's `int136` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 136 bits\n   *\n   * _Available since v4.7._\n   */\n  function toInt136(int256 value) internal pure returns (int136 downcasted) {\n    downcasted = int136(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 136 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int128 from int256, reverting on\n   * overflow (when the input is less than smallest int128 or\n   * greater than largest int128).\n   *\n   * Counterpart to Solidity's `int128` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 128 bits\n   *\n   * _Available since v3.1._\n   */\n  function toInt128(int256 value) internal pure returns (int128 downcasted) {\n    downcasted = int128(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 128 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int120 from int256, reverting on\n   * overflow (when the input is less than smallest int120 or\n   * greater than largest int120).\n   *\n   * Counterpart to Solidity's `int120` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 120 bits\n   *\n   * _Available since v4.7._\n   */\n  function toInt120(int256 value) internal pure returns (int120 downcasted) {\n    downcasted = int120(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 120 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int112 from int256, reverting on\n   * overflow (when the input is less than smallest int112 or\n   * greater than largest int112).\n   *\n   * Counterpart to Solidity's `int112` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 112 bits\n   *\n   * _Available since v4.7._\n   */\n  function toInt112(int256 value) internal pure returns (int112 downcasted) {\n    downcasted = int112(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 112 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int104 from int256, reverting on\n   * overflow (when the input is less than smallest int104 or\n   * greater than largest int104).\n   *\n   * Counterpart to Solidity's `int104` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 104 bits\n   *\n   * _Available since v4.7._\n   */\n  function toInt104(int256 value) internal pure returns (int104 downcasted) {\n    downcasted = int104(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 104 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int96 from int256, reverting on\n   * overflow (when the input is less than smallest int96 or\n   * greater than largest int96).\n   *\n   * Counterpart to Solidity's `int96` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 96 bits\n   *\n   * _Available since v4.7._\n   */\n  function toInt96(int256 value) internal pure returns (int96 downcasted) {\n    downcasted = int96(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 96 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int88 from int256, reverting on\n   * overflow (when the input is less than smallest int88 or\n   * greater than largest int88).\n   *\n   * Counterpart to Solidity's `int88` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 88 bits\n   *\n   * _Available since v4.7._\n   */\n  function toInt88(int256 value) internal pure returns (int88 downcasted) {\n    downcasted = int88(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 88 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int80 from int256, reverting on\n   * overflow (when the input is less than smallest int80 or\n   * greater than largest int80).\n   *\n   * Counterpart to Solidity's `int80` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 80 bits\n   *\n   * _Available since v4.7._\n   */\n  function toInt80(int256 value) internal pure returns (int80 downcasted) {\n    downcasted = int80(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 80 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int72 from int256, reverting on\n   * overflow (when the input is less than smallest int72 or\n   * greater than largest int72).\n   *\n   * Counterpart to Solidity's `int72` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 72 bits\n   *\n   * _Available since v4.7._\n   */\n  function toInt72(int256 value) internal pure returns (int72 downcasted) {\n    downcasted = int72(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 72 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int64 from int256, reverting on\n   * overflow (when the input is less than smallest int64 or\n   * greater than largest int64).\n   *\n   * Counterpart to Solidity's `int64` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 64 bits\n   *\n   * _Available since v3.1._\n   */\n  function toInt64(int256 value) internal pure returns (int64 downcasted) {\n    downcasted = int64(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 64 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int56 from int256, reverting on\n   * overflow (when the input is less than smallest int56 or\n   * greater than largest int56).\n   *\n   * Counterpart to Solidity's `int56` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 56 bits\n   *\n   * _Available since v4.7._\n   */\n  function toInt56(int256 value) internal pure returns (int56 downcasted) {\n    downcasted = int56(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 56 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int48 from int256, reverting on\n   * overflow (when the input is less than smallest int48 or\n   * greater than largest int48).\n   *\n   * Counterpart to Solidity's `int48` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 48 bits\n   *\n   * _Available since v4.7._\n   */\n  function toInt48(int256 value) internal pure returns (int48 downcasted) {\n    downcasted = int48(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 48 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int40 from int256, reverting on\n   * overflow (when the input is less than smallest int40 or\n   * greater than largest int40).\n   *\n   * Counterpart to Solidity's `int40` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 40 bits\n   *\n   * _Available since v4.7._\n   */\n  function toInt40(int256 value) internal pure returns (int40 downcasted) {\n    downcasted = int40(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 40 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int32 from int256, reverting on\n   * overflow (when the input is less than smallest int32 or\n   * greater than largest int32).\n   *\n   * Counterpart to Solidity's `int32` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 32 bits\n   *\n   * _Available since v3.1._\n   */\n  function toInt32(int256 value) internal pure returns (int32 downcasted) {\n    downcasted = int32(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 32 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int24 from int256, reverting on\n   * overflow (when the input is less than smallest int24 or\n   * greater than largest int24).\n   *\n   * Counterpart to Solidity's `int24` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 24 bits\n   *\n   * _Available since v4.7._\n   */\n  function toInt24(int256 value) internal pure returns (int24 downcasted) {\n    downcasted = int24(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 24 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int16 from int256, reverting on\n   * overflow (when the input is less than smallest int16 or\n   * greater than largest int16).\n   *\n   * Counterpart to Solidity's `int16` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 16 bits\n   *\n   * _Available since v3.1._\n   */\n  function toInt16(int256 value) internal pure returns (int16 downcasted) {\n    downcasted = int16(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 16 bits\");\n  }\n\n  /**\n   * @dev Returns the downcasted int8 from int256, reverting on\n   * overflow (when the input is less than smallest int8 or\n   * greater than largest int8).\n   *\n   * Counterpart to Solidity's `int8` operator.\n   *\n   * Requirements:\n   *\n   * - input must fit into 8 bits\n   *\n   * _Available since v3.1._\n   */\n  function toInt8(int256 value) internal pure returns (int8 downcasted) {\n    downcasted = int8(value);\n    require(downcasted == value, \"SafeCast: value doesn't fit in 8 bits\");\n  }\n\n  /**\n   * @dev Converts an unsigned uint256 into a signed int256.\n   *\n   * Requirements:\n   *\n   * - input must be less than or equal to maxInt256.\n   *\n   * _Available since v3.0._\n   */\n  function toInt256(uint256 value) internal pure returns (int256) {\n    // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n    require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n    return int256(value);\n  }\n}\n"},{"file_path":"lib/solidity-utils/src/contracts/transparent-proxy/Initializable.sol","source_code":"// SPDX-License-Identifier: MIT\n\n/**\n * @dev OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\n * From https://github.com/OpenZeppelin/openzeppelin-contracts/tree/8b778fa20d6d76340c5fac1ed66c80273f05b95a\n *\n * BGD Labs adaptations:\n * - Added a constructor disabling initialization for implementation contracts\n * - Linting\n */\n\npragma solidity ^0.8.2;\n\nimport '../oz-common/Address.sol';\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n *     function initialize() initializer public {\n *         __ERC20_init(\"MyToken\", \"MTK\");\n *     }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n *     function initializeV2() reinitializer(2) public {\n *         __ERC20Permit_init(\"MyToken\");\n *     }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n *     _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n  /**\n   * @dev Indicates that the contract has been initialized.\n   * @custom:oz-retyped-from bool\n   */\n  uint8 private _initialized;\n\n  /**\n   * @dev Indicates that the contract is in the process of being initialized.\n   */\n  bool private _initializing;\n\n  /**\n   * @dev Triggered when the contract has been initialized or reinitialized.\n   */\n  event Initialized(uint8 version);\n\n  /**\n   * @dev OPINIONATED. Generally is not a good practise to allow initialization of implementations\n   */\n  constructor() {\n    _disableInitializers();\n  }\n\n  /**\n   * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n   * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.\n   */\n  modifier initializer() {\n    bool isTopLevelCall = !_initializing;\n    require(\n      (isTopLevelCall && _initialized < 1) ||\n        (!Address.isContract(address(this)) && _initialized == 1),\n      'Initializable: contract is already initialized'\n    );\n    _initialized = 1;\n    if (isTopLevelCall) {\n      _initializing = true;\n    }\n    _;\n    if (isTopLevelCall) {\n      _initializing = false;\n      emit Initialized(1);\n    }\n  }\n\n  /**\n   * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n   * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n   * used to initialize parent contracts.\n   *\n   * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\n   * initialization step. This is essential to configure modules that are added through upgrades and that require\n   * initialization.\n   *\n   * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n   * a contract, executing them in the right order is up to the developer or operator.\n   */\n  modifier reinitializer(uint8 version) {\n    require(\n      !_initializing && _initialized < version,\n      'Initializable: contract is already initialized'\n    );\n    _initialized = version;\n    _initializing = true;\n    _;\n    _initializing = false;\n    emit Initialized(version);\n  }\n\n  /**\n   * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n   * {initializer} and {reinitializer} modifiers, directly or indirectly.\n   */\n  modifier onlyInitializing() {\n    require(_initializing, 'Initializable: contract is not initializing');\n    _;\n  }\n\n  /**\n   * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n   * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n   * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n   * through proxies.\n   */\n  function _disableInitializers() internal virtual {\n    require(!_initializing, 'Initializable: contract is initializing');\n    if (_initialized < type(uint8).max) {\n      _initialized = type(uint8).max;\n      emit Initialized(type(uint8).max);\n    }\n  }\n}\n"},{"file_path":"src/contracts/GovernanceCore.sol","source_code":"// SPDX-License-Identifier: BUSL-1.1\npragma solidity ^0.8.0;\n\nimport {Initializable} from 'solidity-utils/contracts/transparent-proxy/Initializable.sol';\nimport {OwnableWithGuardian} from 'solidity-utils/contracts/access-control/OwnableWithGuardian.sol';\nimport {SafeCast} from 'solidity-utils/contracts/oz-common/SafeCast.sol';\nimport {IGovernanceCore, IGovernancePowerStrategy, PayloadsControllerUtils, EnumerableSet} from '../interfaces/IGovernanceCore.sol';\nimport {IVotingPortal} from '../interfaces/IVotingPortal.sol';\nimport {Errors} from './libraries/Errors.sol';\nimport {IVotingMachineWithProofs} from './voting/interfaces/IVotingMachineWithProofs.sol';\nimport {IBaseVotingStrategy} from '../interfaces/IBaseVotingStrategy.sol';\n\n/**\n * @title GovernanceCore\n * @author BGD Labs\n * @notice this contract contains the logic to create proposals and communicate with the voting machine to vote on the\n           proposals and the payloadsController to execute them, being in the same or different network.\n * @dev Abstract contract that is implemented on Governance contract\n * @dev !!!!!!!!!!! CHILD CLASS SHOULD IMPLEMENT initialize() and CALL _initializeCore METHOD FROM THERE !!!!!!!!!!!!\n */\nabstract contract GovernanceCore is\n  IGovernanceCore,\n  Initializable,\n  OwnableWithGuardian\n{\n  using EnumerableSet for EnumerableSet.AddressSet;\n  using SafeCast for uint256;\n\n  // @inheritdoc IGovernanceCore\n  address public immutable CANCELLATION_FEE_COLLECTOR;\n\n  // @inheritdoc IGovernanceCore\n  uint256 public constant PRECISION_DIVIDER = 1 ether;\n\n  // @inheritdoc IGovernanceCore\n  uint256 public constant PROPOSAL_EXPIRATION_TIME = 30 days;\n\n  // @inheritdoc IGovernanceCore\n  uint256 public immutable COOLDOWN_PERIOD;\n\n  IGovernancePowerStrategy internal _powerStrategy;\n\n  uint256 internal _proposalsCount;\n\n  // Fee taken as cancellation insurance to protect against spam attacks.\n  // If the proposal gets cancelled, this will be sent to the Aave Collector, if not,\n  // the proposal creator can claim it back\n  uint256 internal _cancellationFee;\n\n  // (votingPortal => approved) mapping to store the approved voting portals\n  mapping(address => bool) internal _votingPortals;\n\n  // counts the currently active voting portals\n  uint256 internal _votingPortalsCount;\n\n  // (proposalId => Proposal) mapping to store the information of a proposal. indexed by proposalId\n  mapping(uint256 => Proposal) internal _proposals;\n\n  // (accessLevel => VotingConfig) mapping storing the different voting configurations.\n  // Indexed by access level (level 1, level 2)\n  mapping(PayloadsControllerUtils.AccessControl => VotingConfig)\n    internal _votingConfigs;\n\n  // voter => chainId => representative.\n  // Stores the representative of a voter by chain. A representative can vote on behalf of his represented voter\n  mapping(address => mapping(uint256 => address)) internal _representatives;\n\n  // representative => chainId => voters\n  // set with the represented voters of an address\n  mapping(address => mapping(uint256 => EnumerableSet.AddressSet))\n    internal _votersRepresented;\n\n  /// @inheritdoc IGovernanceCore\n  string public constant NAME = 'Aave Governance v3';\n\n  /**\n   * @param coolDownPeriod time that should pass before proposal will be moved to vote, in seconds\n   * @param cancellationFeeCollector address of the Aave collector\n   */\n  constructor(uint256 coolDownPeriod, address cancellationFeeCollector) {\n    require(\n      cancellationFeeCollector != address(0),\n      Errors.INVALID_CANCELLATION_FEE_COLLECTOR\n    );\n    CANCELLATION_FEE_COLLECTOR = cancellationFeeCollector;\n    COOLDOWN_PERIOD = coolDownPeriod;\n  }\n\n  // @inheritdoc IGovernanceCore\n  function ACHIEVABLE_VOTING_PARTICIPATION()\n    public\n    view\n    virtual\n    returns (uint256)\n  {\n    return 5_000_000 ether;\n  }\n\n  // @inheritdoc IGovernanceCore\n  function MIN_VOTING_DURATION() public view virtual returns (uint256) {\n    return 3 days;\n  }\n\n  /**\n   * @notice method to initialize governance v3 core\n   * @param owner address of the new owner of governance\n   * @param guardian address of the new guardian of governance\n   * @param powerStrategy address of the governance chain voting strategy\n   * @param votingConfigs objects containing the information of different voting configurations depending on access level\n   * @param votingPortals objects containing the information of different voting machines depending on chain id\n   * @param cancellationFee fee amount to collateralize against proposal cancellation\n   */\n  function _initializeCore(\n    address owner,\n    address guardian,\n    IGovernancePowerStrategy powerStrategy,\n    SetVotingConfigInput[] calldata votingConfigs,\n    address[] calldata votingPortals,\n    uint256 cancellationFee\n  ) internal initializer {\n    require(votingConfigs.length == 2, Errors.MISSING_VOTING_CONFIGURATIONS);\n    require(\n      votingConfigs[0].accessLevel != votingConfigs[1].accessLevel,\n      Errors.INVALID_INITIAL_VOTING_CONFIGS\n    );\n\n    _transferOwnership(owner);\n    _updateGuardian(guardian);\n    _setPowerStrategy(powerStrategy);\n    _setVotingConfigs(votingConfigs);\n    _updateVotingPortals(votingPortals, true);\n    _updateCancellationFee(cancellationFee);\n  }\n\n  /// @inheritdoc IGovernanceCore\n  function updateCancellationFee(uint256 cancellationFee) external onlyOwner {\n    _updateCancellationFee(cancellationFee);\n  }\n\n  /// @inheritdoc IGovernanceCore\n  function getCancellationFee() external view returns (uint256) {\n    return _cancellationFee;\n  }\n\n  /// @inheritdoc IGovernanceCore\n  function getRepresentedVotersByChain(\n    address representative,\n    uint256 chainId\n  ) external view returns (address[] memory) {\n    return _votersRepresented[representative][chainId].values();\n  }\n\n  /// @inheritdoc IGovernanceCore\n  function getRepresentativeByChain(\n    address voter,\n    uint256 chainId\n  ) external view returns (address) {\n    return _representatives[voter][chainId];\n  }\n\n  /// @inheritdoc IGovernanceCore\n  function updateRepresentativesForChain(\n    RepresentativeInput[] calldata representatives\n  ) external {\n    for (uint256 i = 0; i < representatives.length; i++) {\n      uint256 chainId = representatives[i].chainId;\n      address newRepresentative = representatives[i].representative !=\n        msg.sender\n        ? representatives[i].representative\n        : address(0);\n      address oldRepresentative = _representatives[msg.sender][chainId];\n\n      if (oldRepresentative != address(0)) {\n        _votersRepresented[oldRepresentative][chainId].remove(msg.sender);\n      }\n\n      if (newRepresentative != address(0)) {\n        _votersRepresented[newRepresentative][chainId].add(msg.sender);\n      }\n\n      _representatives[msg.sender][chainId] = newRepresentative;\n\n      emit RepresentativeUpdated(msg.sender, newRepresentative, chainId);\n    }\n  }\n\n  /// @inheritdoc IGovernanceCore\n  function getVotingPortalsCount() external view returns (uint256) {\n    return _votingPortalsCount;\n  }\n\n  /// @inheritdoc IGovernanceCore\n  function getPowerStrategy() external view returns (IGovernancePowerStrategy) {\n    return _powerStrategy;\n  }\n\n  /// @inheritdoc IGovernanceCore\n  function getProposalsCount() external view returns (uint256) {\n    return _proposalsCount;\n  }\n\n  /// @inheritdoc IGovernanceCore\n  function isVotingPortalApproved(\n    address votingPortal\n  ) public view returns (bool) {\n    return _votingPortals[votingPortal];\n  }\n\n  /// @inheritdoc IGovernanceCore\n  function addVotingPortals(\n    address[] calldata votingPortals\n  ) external onlyOwner {\n    _updateVotingPortals(votingPortals, true);\n  }\n\n  /// @inheritdoc IGovernanceCore\n  function rescueVotingPortal(address votingPortal) external onlyGuardian {\n    require(_votingPortalsCount == 0, Errors.VOTING_PORTALS_COUNT_NOT_0);\n\n    address[] memory votingPortals = new address[](1);\n    votingPortals[0] = votingPortal;\n    _updateVotingPortals(votingPortals, true);\n  }\n\n  /// @inheritdoc IGovernanceCore\n  function removeVotingPortals(\n    address[] calldata votingPortals\n  ) external onlyOwner {\n    _updateVotingPortals(votingPortals, false);\n  }\n\n  /// @inheritdoc IGovernanceCore\n  function createProposal(\n    PayloadsControllerUtils.Payload[] calldata payloads,\n    address votingPortal,\n    bytes32 ipfsHash\n  ) external payable returns (uint256) {\n    require(payloads.length != 0, Errors.AT_LEAST_ONE_PAYLOAD);\n    require(ipfsHash != bytes32(0), Errors.G_INVALID_IPFS_HASH);\n    require(\n      msg.value == _cancellationFee,\n      Errors.INVALID_CANCELLATION_FEE_SENT\n    );\n\n    require(\n      isVotingPortalApproved(votingPortal),\n      Errors.VOTING_PORTAL_NOT_APPROVED\n    );\n\n    uint256 proposalId = _proposalsCount++;\n    Proposal storage proposal = _proposals[proposalId];\n\n    PayloadsControllerUtils.AccessControl maximumAccessLevelRequired;\n    for (uint256 i = 0; i < payloads.length; i++) {\n      require(\n        payloads[i].accessLevel >\n          PayloadsControllerUtils.AccessControl.Level_null,\n        Errors.G_INVALID_PAYLOAD_ACCESS_LEVEL\n      );\n      require(\n        payloads[i].payloadsController != address(0),\n        Errors.G_INVALID_PAYLOADS_CONTROLLER\n      );\n      require(payloads[i].chain > 0, Errors.G_INVALID_PAYLOAD_CHAIN);\n      proposal.payloads.push(payloads[i]);\n\n      if (payloads[i].accessLevel > maximumAccessLevelRequired) {\n        maximumAccessLevelRequired = payloads[i].accessLevel;\n      }\n    }\n\n    VotingConfig memory votingConfig = _votingConfigs[\n      maximumAccessLevelRequired\n    ];\n\n    address proposalCreator = msg.sender;\n    require(\n      _isPropositionPowerEnough(\n        votingConfig,\n        _powerStrategy.getFullPropositionPower(proposalCreator)\n      ),\n      Errors.PROPOSITION_POWER_IS_TOO_LOW\n    );\n\n    proposal.state = State.Created;\n    proposal.creator = proposalCreator;\n    proposal.accessLevel = maximumAccessLevelRequired;\n    proposal.votingPortal = votingPortal;\n    proposal.creationTime = uint40(block.timestamp);\n    proposal.ipfsHash = ipfsHash;\n    proposal.cancellationFee = msg.value;\n\n    emit ProposalCreated(\n      proposalId,\n      proposalCreator,\n      maximumAccessLevelRequired,\n      ipfsHash\n    );\n\n    return proposalId;\n  }\n\n  /// @inheritdoc IGovernanceCore\n  function activateVoting(uint256 proposalId) external {\n    Proposal storage proposal = _proposals[proposalId];\n    VotingConfig memory votingConfig = _votingConfigs[proposal.accessLevel];\n\n    uint40 proposalCreationTime = proposal.creationTime;\n    bytes32 blockHash = blockhash(block.number - 1);\n\n    require(\n      _getProposalState(proposal) == State.Created,\n      Errors.PROPOSAL_NOT_IN_CREATED_STATE\n    );\n\n    require(\n      isVotingPortalApproved(proposal.votingPortal),\n      Errors.VOTING_PORTAL_NOT_APPROVED\n    );\n\n    require(\n      block.timestamp - proposalCreationTime >\n        votingConfig.coolDownBeforeVotingStart,\n      Errors.VOTING_START_COOLDOWN_PERIOD_NOT_PASSED\n    );\n\n    require(\n      _isPropositionPowerEnough(\n        votingConfig,\n        _powerStrategy.getFullPropositionPower(proposal.creator)\n      ),\n      Errors.PROPOSITION_POWER_IS_TOO_LOW\n    );\n\n    proposal.votingActivationTime = uint40(block.timestamp);\n    proposal.snapshotBlockHash = blockHash;\n    proposal.state = State.Active;\n    proposal.votingDuration = votingConfig.votingDuration;\n\n    IVotingPortal(proposal.votingPortal).forwardStartVotingMessage(\n      proposalId,\n      blockHash,\n      proposal.votingDuration\n    );\n    emit VotingActivated(proposalId, blockHash, votingConfig.votingDuration);\n  }\n\n  /// @inheritdoc IGovernanceCore\n  function queueProposal(\n    uint256 proposalId,\n    uint128 forVotes,\n    uint128 againstVotes\n  ) external {\n    Proposal storage proposal = _proposals[proposalId];\n    address votingPortal = proposal.votingPortal;\n\n    // only the accepted portal for this proposal can queue it\n    require(\n      msg.sender == votingPortal && isVotingPortalApproved(votingPortal),\n      Errors.CALLER_NOT_A_VALID_VOTING_PORTAL\n    );\n\n    require(\n      _getProposalState(proposal) == State.Active,\n      Errors.PROPOSAL_NOT_IN_ACTIVE_STATE\n    );\n\n    require(\n      block.timestamp > proposal.votingDuration + proposal.votingActivationTime,\n      Errors.VOTING_DURATION_NOT_PASSED\n    );\n\n    VotingConfig memory votingConfig = _votingConfigs[proposal.accessLevel];\n\n    proposal.forVotes = forVotes;\n    proposal.againstVotes = againstVotes;\n\n    if (\n      _isPropositionPowerEnough(\n        votingConfig,\n        _powerStrategy.getFullPropositionPower(proposal.creator)\n      ) &&\n      _isPassingYesThreshold(votingConfig, forVotes) &&\n      _isPassingYesNoDifferential(votingConfig, forVotes, againstVotes)\n    ) {\n      proposal.queuingTime = uint40(block.timestamp);\n      proposal.state = State.Queued;\n      emit ProposalQueued(proposalId, forVotes, againstVotes);\n    } else {\n      proposal.state = State.Failed;\n      emit ProposalFailed(proposalId, forVotes, againstVotes);\n    }\n  }\n\n  /// @inheritdoc IGovernanceCore\n  function executeProposal(uint256 proposalId) external {\n    Proposal storage proposal = _proposals[proposalId];\n    require(\n      _getProposalState(proposal) == State.Queued,\n      Errors.PROPOSAL_NOT_IN_QUEUED_STATE\n    );\n    require(\n      block.timestamp >= proposal.queuingTime + COOLDOWN_PERIOD,\n      Errors.QUEUE_COOLDOWN_PERIOD_NOT_PASSED\n    );\n    require(\n      _isPropositionPowerEnough(\n        _votingConfigs[proposal.accessLevel],\n        _powerStrategy.getFullPropositionPower(proposal.creator)\n      ),\n      Errors.PROPOSITION_POWER_IS_TOO_LOW\n    );\n\n    proposal.state = State.Executed;\n\n    for (uint256 i = 0; i < proposal.payloads.length; i++) {\n      PayloadsControllerUtils.Payload memory payload = proposal.payloads[i];\n\n      // votingActivationTime is sent to PayloadsController to force that the payload voted on the proposal\n      // was registered before the vote happened, ensuring that the voters were able to check the contents\n      // of the payload before emitting the vote.\n      _forwardPayloadForExecution(payload, proposal.votingActivationTime);\n      emit PayloadSent(\n        proposalId,\n        payload.payloadId,\n        payload.payloadsController,\n        payload.chain,\n        i,\n        proposal.payloads.length\n      );\n    }\n\n    emit ProposalExecuted(proposalId);\n  }\n\n  /// @inheritdoc IGovernanceCore\n  function cancelProposal(uint256 proposalId) external {\n    Proposal storage proposal = _proposals[proposalId];\n    State proposalState = _getProposalState(proposal);\n    address proposalCreator = proposal.creator;\n\n    require(\n      proposalState != State.Null &&\n        uint256(proposalState) < uint256(State.Executed),\n      Errors.PROPOSAL_NOT_IN_THE_CORRECT_STATE\n    );\n\n    if (\n      isVotingPortalApproved(proposal.votingPortal) &&\n      proposalCreator != msg.sender &&\n      _isPropositionPowerEnough(\n        _votingConfigs[proposal.accessLevel],\n        _powerStrategy.getFullPropositionPower(proposalCreator)\n      )\n    ) {\n      _checkGuardian();\n    }\n\n    proposal.state = State.Cancelled;\n    proposal.cancelTimestamp = uint40(block.timestamp);\n    emit ProposalCanceled(proposalId);\n  }\n\n  /// @inheritdoc IGovernanceCore\n  function redeemCancellationFee(uint256[] calldata proposalIds) external {\n    for (uint256 i = 0; i < proposalIds.length; i++) {\n      Proposal storage proposal = _proposals[proposalIds[i]];\n      State proposalState = _getProposalState(proposal);\n\n      address to;\n      if (proposalState == State.Cancelled) {\n        to = CANCELLATION_FEE_COLLECTOR;\n      } else if (proposalState >= State.Executed) {\n        to = proposal.creator;\n      } else {\n        revert(Errors.INVALID_STATE_TO_REDEEM_CANCELLATION_FEE);\n      }\n\n      uint256 cancellationFee = proposal.cancellationFee;\n      require(cancellationFee > 0, Errors.CANCELLATION_FEE_ALREADY_REDEEMED);\n\n      proposal.cancellationFee = 0;\n\n      (bool success, ) = to.call{value: cancellationFee}(new bytes(0));\n      require(success, Errors.CANCELLATION_FEE_REDEEM_FAILED);\n\n      emit CancellationFeeRedeemed(\n        proposalIds[i],\n        to,\n        cancellationFee,\n        success\n      );\n    }\n  }\n\n  /// @inheritdoc IGovernanceCore\n  function getProposalState(uint256 proposalId) external view returns (State) {\n    Proposal storage proposal = _proposals[proposalId];\n\n    return _getProposalState(proposal);\n  }\n\n  /// @inheritdoc IGovernanceCore\n  function setVotingConfigs(\n    SetVotingConfigInput[] calldata votingConfigs\n  ) external onlyOwner {\n    _setVotingConfigs(votingConfigs);\n  }\n\n  /// @inheritdoc IGovernanceCore\n  function setPowerStrategy(\n    IGovernancePowerStrategy powerStrategy\n  ) external onlyOwner {\n    _setPowerStrategy(powerStrategy);\n  }\n\n  /// @inheritdoc IGovernanceCore\n  function getProposal(\n    uint256 proposalId\n  ) external view returns (Proposal memory) {\n    Proposal memory proposal = _proposals[proposalId];\n    proposal.state = _getProposalState(_proposals[proposalId]);\n    return proposal;\n  }\n\n  /// @inheritdoc IGovernanceCore\n  function getVotingConfig(\n    PayloadsControllerUtils.AccessControl accessLevel\n  ) external view returns (VotingConfig memory) {\n    return _votingConfigs[accessLevel];\n  }\n\n  /**\n   * @notice method to override that should be in charge of sending payload for execution\n   * @param payload object containing the information necessary for execution\n   * @param proposalVoteActivationTimestamp proposal vote activation timestamp in seconds\n   */\n  function _forwardPayloadForExecution(\n    PayloadsControllerUtils.Payload memory payload,\n    uint40 proposalVoteActivationTimestamp\n  ) internal virtual;\n\n  /**\n   * @notice method to update the cancellation fee amount\n   * @param cancellationFee fee amount for proposal cancellation collateral\n   */\n  function _updateCancellationFee(uint256 cancellationFee) internal {\n    _cancellationFee = cancellationFee;\n\n    emit CancellationFeeUpdated(cancellationFee);\n  }\n\n  /**\n   * @notice method to set the voting configuration for a determined access level\n   * @param votingConfigs object containing configuration for an access level\n   */\n  function _setVotingConfigs(\n    SetVotingConfigInput[] memory votingConfigs\n  ) internal {\n    require(votingConfigs.length > 0, Errors.INVALID_VOTING_CONFIGS);\n\n    for (uint256 i = 0; i < votingConfigs.length; i++) {\n      require(\n        votingConfigs[i].accessLevel >\n          PayloadsControllerUtils.AccessControl.Level_null,\n        Errors.INVALID_VOTING_CONFIG_ACCESS_LEVEL\n      );\n      require(\n        votingConfigs[i].coolDownBeforeVotingStart +\n          votingConfigs[i].votingDuration +\n          COOLDOWN_PERIOD <\n          PROPOSAL_EXPIRATION_TIME,\n        Errors.INVALID_VOTING_DURATION\n      );\n      require(\n        votingConfigs[i].votingDuration >= MIN_VOTING_DURATION(),\n        Errors.VOTING_DURATION_TOO_SMALL\n      );\n      require(\n        votingConfigs[i].minPropositionPower <=\n          ACHIEVABLE_VOTING_PARTICIPATION(),\n        Errors.INVALID_PROPOSITION_POWER\n      );\n      require(\n        votingConfigs[i].yesThreshold <= ACHIEVABLE_VOTING_PARTICIPATION(),\n        Errors.INVALID_YES_THRESHOLD\n      );\n      require(\n        votingConfigs[i].yesNoDifferential <= ACHIEVABLE_VOTING_PARTICIPATION(),\n        Errors.INVALID_YES_NO_DIFFERENTIAL\n      );\n\n      VotingConfig memory votingConfig = VotingConfig({\n        coolDownBeforeVotingStart: votingConfigs[i].coolDownBeforeVotingStart,\n        votingDuration: votingConfigs[i].votingDuration,\n        yesThreshold: _normalize(votingConfigs[i].yesThreshold),\n        yesNoDifferential: _normalize(votingConfigs[i].yesNoDifferential),\n        minPropositionPower: _normalize(votingConfigs[i].minPropositionPower)\n      });\n      _votingConfigs[votingConfigs[i].accessLevel] = votingConfig;\n\n      emit VotingConfigUpdated(\n        votingConfigs[i].accessLevel,\n        votingConfig.votingDuration,\n        votingConfig.coolDownBeforeVotingStart,\n        votingConfig.yesThreshold,\n        votingConfig.yesNoDifferential,\n        votingConfig.minPropositionPower\n      );\n    }\n\n    // validation of the voting configs after change, to make it not possible for lvl2 configuration to have configs\n    // lower than lvl1\n    VotingConfig memory votingConfigL1 = _votingConfigs[\n      PayloadsControllerUtils.AccessControl.Level_1\n    ];\n    VotingConfig memory votingConfigL2 = _votingConfigs[\n      PayloadsControllerUtils.AccessControl.Level_2\n    ];\n    require(\n      votingConfigL1.minPropositionPower <= votingConfigL2.minPropositionPower,\n      Errors.INVALID_PROPOSITION_POWER\n    );\n    require(\n      votingConfigL1.yesThreshold <= votingConfigL2.yesThreshold,\n      Errors.INVALID_YES_THRESHOLD\n    );\n    require(\n      votingConfigL1.yesNoDifferential <= votingConfigL2.yesNoDifferential,\n      Errors.INVALID_YES_NO_DIFFERENTIAL\n    );\n  }\n\n  /**\n   * @notice method to set a new _powerStrategy contract\n   * @param powerStrategy address of the new contract containing the voting a voting strategy\n   */\n  function _setPowerStrategy(IGovernancePowerStrategy powerStrategy) internal {\n    require(\n      address(powerStrategy) != address(0),\n      Errors.INVALID_POWER_STRATEGY\n    );\n    require(\n      IBaseVotingStrategy(address(powerStrategy)).getVotingAssetList().length >\n        0,\n      Errors.POWER_STRATEGY_HAS_NO_TOKENS\n    );\n    _powerStrategy = powerStrategy;\n\n    emit PowerStrategyUpdated(address(powerStrategy));\n  }\n\n  /**\n   * @notice method to know if proposition power is bigger than the minimum expected for the voting configuration set\n         for this access level\n   * @param votingConfig voting configuration from a specific access level, where to check the minimum proposition power\n   * @param propositionPower power to check against the voting config minimum\n   * @return boolean indicating if power is bigger than minimum\n   */\n  function _isPropositionPowerEnough(\n    IGovernanceCore.VotingConfig memory votingConfig,\n    uint256 propositionPower\n  ) internal pure returns (bool) {\n    return\n      propositionPower > votingConfig.minPropositionPower * PRECISION_DIVIDER;\n  }\n\n  /**\n   * @notice method to know if a vote is passing the yes threshold set in the vote configuration. For this it is required\n             for votes to be bigger than configuration yes threshold.\n   * @param votingConfig configuration of this voting, set by access level\n   * @param forVotes votes in favor of passing the proposal\n   * @return boolean indicating the passing of the yes threshold\n   */\n  function _isPassingYesThreshold(\n    VotingConfig memory votingConfig,\n    uint256 forVotes\n  ) internal pure returns (bool) {\n    return forVotes > votingConfig.yesThreshold * PRECISION_DIVIDER;\n  }\n\n  /**\n   * @notice method to know if the votes pass the yes no differential set by the voting configuration\n   * @param votingConfig configuration of this voting, set by access level\n   * @param forVotes votes in favor of passing the proposal\n   * @param againstVotes votes against passing the proposal\n   * @return boolean indicating the passing of the yes no differential\n   */\n  function _isPassingYesNoDifferential(\n    VotingConfig memory votingConfig,\n    uint256 forVotes,\n    uint256 againstVotes\n  ) internal pure returns (bool) {\n    return\n      forVotes >= againstVotes &&\n      forVotes - againstVotes >\n      votingConfig.yesNoDifferential * PRECISION_DIVIDER;\n  }\n\n  /**\n   * @notice method to get the current state of a proposal\n   * @param proposal object with all pertinent proposal information\n   * @return current state of the proposal\n   */\n  function _getProposalState(\n    Proposal storage proposal\n  ) internal view returns (State) {\n    State state = proposal.state;\n    // small shortcut\n    // We can check state >= because we know that Enum state is sequential. If some new State is added / removed check\n    // if condition is still valid\n    if (\n      state == IGovernanceCore.State.Null ||\n      state >= IGovernanceCore.State.Executed\n    ) {\n      return state;\n    }\n\n    uint256 expirationTime = proposal.creationTime + PROPOSAL_EXPIRATION_TIME;\n    if (\n      block.timestamp > expirationTime ||\n      (state == IGovernanceCore.State.Created &&\n        // if current time + duration of the vote is bigger than expiration time, and vote has not been activated,\n        // proposal should be expired as when the vote result returns, proposal will have expired.\n        block.timestamp + proposal.votingDuration > expirationTime)\n    ) {\n      return State.Expired;\n    }\n\n    return state;\n  }\n\n  /**\n   * @notice method to remove specified decimals from a value, as to normalize it.\n   * @param value number to remove decimals from\n   * @return normalized value\n   */\n  function _normalize(uint256 value) internal pure returns (uint56) {\n    uint256 normalizedValue = value / PRECISION_DIVIDER;\n    return normalizedValue.toUint56();\n  }\n\n  /**\n   * @notice method that approves or disapproves voting machines\n   * @param votingPortals list of voting portal addresses\n   * @param state boolean indicating if the list is for approval or disapproval of the voting portal addresses\n   */\n  function _updateVotingPortals(\n    address[] memory votingPortals,\n    bool state\n  ) internal {\n    for (uint256 i = 0; i < votingPortals.length; i++) {\n      address votingPortal = votingPortals[i];\n\n      require(votingPortal != address(0), Errors.INVALID_VOTING_PORTAL_ADDRESS);\n      // if voting portal is already in the target state - just skip\n      if (_votingPortals[votingPortal] == state) {\n        continue;\n      }\n\n      if (state) {\n        _votingPortalsCount++;\n      } else {\n        _votingPortalsCount--;\n      }\n\n      _votingPortals[votingPortal] = state;\n\n      emit VotingPortalUpdated(votingPortal, state);\n    }\n  }\n}\n"},{"file_path":"src/contracts/libraries/Errors.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/**\n * @title Errors library\n * @author BGD Labs\n * @notice Defines the error messages emitted by the different contracts of the Aave Governance V3\n */\nlibrary Errors {\n  string public constant VOTING_PORTALS_COUNT_NOT_0 = '1'; // to be able to rescue voting portals count must be 0\n  string public constant AT_LEAST_ONE_PAYLOAD = '2'; // to create a proposal, it must have at least one payload\n  string public constant VOTING_PORTAL_NOT_APPROVED = '3'; // the voting portal used to vote on proposal must be approved\n  string public constant PROPOSITION_POWER_IS_TOO_LOW = '4'; // proposition power of proposal creator must be equal or higher than the specified threshold for the access level\n  string public constant PROPOSAL_NOT_IN_CREATED_STATE = '5'; // proposal should be in the CREATED state\n  string public constant PROPOSAL_NOT_IN_ACTIVE_STATE = '6'; // proposal must be in an ACTIVE state\n  string public constant PROPOSAL_NOT_IN_QUEUED_STATE = '7'; // proposal must be in a QUEUED state\n  string public constant VOTING_START_COOLDOWN_PERIOD_NOT_PASSED = '8'; // to activate a proposal vote, the cool down delay must pass\n  string public constant CALLER_NOT_A_VALID_VOTING_PORTAL = '9'; // only an allowed voting portal can queue a proposal\n  string public constant QUEUE_COOLDOWN_PERIOD_NOT_PASSED = '10'; // to execute a proposal a cooldown delay must pass\n  string public constant PROPOSAL_NOT_IN_THE_CORRECT_STATE = '11'; // proposal must be created but not executed yet to be able to be canceled\n  string public constant CALLER_NOT_GOVERNANCE = '12'; // caller must be governance\n  string public constant VOTER_ALREADY_VOTED_ON_PROPOSAL = '13'; // voter can only vote once per proposal using voting portal\n  string public constant WRONG_MESSAGE_ORIGIN = '14'; // received message must come from registered source address, chain id, CrossChainController\n  string public constant NO_VOTING_ASSETS = '15'; // Strategy must have voting assets\n  string public constant PROPOSAL_VOTE_ALREADY_CREATED = '16'; // vote on proposal can only be created once\n  string public constant INVALID_SIGNATURE = '17'; // submitted signature is not valid\n  string public constant PROPOSAL_VOTE_NOT_FINISHED = '18'; // proposal vote must be finished\n  string public constant PROPOSAL_VOTE_NOT_IN_ACTIVE_STATE = '19'; // proposal vote must be in active state\n  string public constant PROPOSAL_VOTE_ALREADY_EXISTS = '20'; // proposal vote already exists\n  string public constant VOTE_ONCE_FOR_ASSET = '21'; // an asset can only be used once per vote\n  string public constant USER_BALANCE_DOES_NOT_EXISTS = '22'; // to vote an user must have balance in the token the user is voting with\n  string public constant USER_VOTING_BALANCE_IS_ZERO = '23'; // to vote an user must have some balance between all the tokens selected for voting\n  string public constant MISSING_AAVE_ROOTS = '24'; // must have AAVE roots registered to use strategy\n  string public constant MISSING_STK_AAVE_ROOTS = '25'; // must have stkAAVE roots registered to use strategy\n  string public constant MISSING_STK_AAVE_SLASHING_EXCHANGE_RATE = '26'; // must have stkAAVE slashing exchange rate registered to use strategy\n  string public constant UNPROCESSED_STORAGE_ROOT = '27'; // root must be registered beforehand\n  string public constant NOT_ENOUGH_MSG_VALUE = '28'; // method was not called with enough value to execute the call\n  string public constant FAILED_ACTION_EXECUTION = '29'; // action failed to execute\n  string public constant SHOULD_BE_AT_LEAST_ONE_EXECUTOR = '30'; // at least one executor is needed\n  string public constant INVALID_EMPTY_TARGETS = '31'; // target of the payload execution must not be empty\n  string public constant EXECUTOR_WAS_NOT_SPECIFIED_FOR_REQUESTED_ACCESS_LEVEL =\n    '32'; // payload executor must be registered for the specified payload access level\n  string public constant PAYLOAD_NOT_IN_QUEUED_STATE = '33'; // payload must be en the queued state\n  string public constant TIMELOCK_NOT_FINISHED = '34'; // delay has not passed before execution can be called\n  string public constant PAYLOAD_NOT_IN_THE_CORRECT_STATE = '35'; // payload must be created but not executed yet to be able to be canceled\n  string public constant PAYLOAD_NOT_IN_CREATED_STATE = '36'; // payload must be in the created state\n  string public constant MISSING_A_AAVE_ROOTS = '37'; // must have aAAVE roots registered to use strategy\n  string public constant MISSING_PROPOSAL_BLOCK_HASH = '38'; // block hash for this proposal was not bridged before\n  string public constant PROPOSAL_VOTE_CONFIGURATION_ALREADY_BRIDGED = '39'; // configuration for this proposal bridged already\n  string public constant INVALID_VOTING_PORTAL_ADDRESS = '40'; // voting portal address can't be 0x0\n  string public constant INVALID_POWER_STRATEGY = '41'; // 0x0 is not valid as the power strategy\n  string public constant INVALID_EXECUTOR_ADDRESS = '42'; // executor address can't be 0x0\n  string public constant EXECUTOR_ALREADY_SET_IN_DIFFERENT_LEVEL = '43'; // executor address already being used as executor of a different level\n  string public constant INVALID_VOTING_DURATION = '44'; // voting duration can not be bigger than the time it takes to execute a proposal\n  string public constant VOTING_DURATION_NOT_PASSED = '45'; // at least votingDuration should have passed since voting started for a proposal to be queued\n  string public constant INVALID_PROPOSAL_ACCESS_LEVEL = '46'; // the bridged proposal access level does not correspond with the maximum access level required by the payload\n  string public constant PAYLOAD_NOT_CREATED_BEFORE_PROPOSAL = '47'; // payload must be created before proposal\n  string public constant INVALID_CROSS_CHAIN_CONTROLLER_ADDRESS = '48';\n  string public constant INVALID_MESSAGE_ORIGINATOR_ADDRESS = '49';\n  string public constant INVALID_ORIGIN_CHAIN_ID = '50';\n  string public constant INVALID_ACTION_TARGET = '51';\n  string public constant INVALID_ACTION_ACCESS_LEVEL = '52';\n  string public constant INVALID_EXECUTOR_ACCESS_LEVEL = '53';\n  string public constant INVALID_VOTING_PORTAL_CROSS_CHAIN_CONTROLLER = '54';\n  string public constant INVALID_VOTING_PORTAL_VOTING_MACHINE = '55';\n  string public constant INVALID_VOTING_PORTAL_GOVERNANCE = '56';\n  string public constant INVALID_VOTING_MACHINE_CHAIN_ID = '57';\n  string public constant G_INVALID_CROSS_CHAIN_CONTROLLER_ADDRESS = '58';\n  string public constant G_INVALID_IPFS_HASH = '59';\n  string public constant G_INVALID_PAYLOAD_ACCESS_LEVEL = '60';\n  string public constant G_INVALID_PAYLOADS_CONTROLLER = '61';\n  string public constant G_INVALID_PAYLOAD_CHAIN = '62';\n  string public constant POWER_STRATEGY_HAS_NO_TOKENS = '63'; // power strategy should at least have\n  string public constant INVALID_VOTING_CONFIG_ACCESS_LEVEL = '64';\n  string public constant VOTING_DURATION_TOO_SMALL = '65';\n  string public constant NO_BRIDGED_VOTING_ASSETS = '66';\n  string public constant INVALID_VOTER = '67';\n  string public constant INVALID_DATA_WAREHOUSE = '68';\n  string public constant INVALID_VOTING_MACHINE_CROSS_CHAIN_CONTROLLER = '69';\n  string public constant INVALID_L1_VOTING_PORTAL = '70';\n  string public constant INVALID_VOTING_PORTAL_CHAIN_ID = '71';\n  string public constant INVALID_VOTING_STRATEGY = '72';\n  string public constant INVALID_VOTE_CONFIGURATION_BLOCKHASH = '73';\n  string public constant INVALID_VOTE_CONFIGURATION_VOTING_DURATION = '74';\n  string public constant INVALID_GAS_LIMIT = '75';\n  string public constant INVALID_VOTING_CONFIGS = '76'; // a lvl2 voting configuration must be sent to initializer\n  string public constant INVALID_EXECUTOR_DELAY = '77';\n  string public constant REPEATED_STRATEGY_ASSET = '78';\n  string public constant EMPTY_ASSET_STORAGE_SLOTS = '79';\n  string public constant REPEATED_STRATEGY_ASSET_SLOT = '80';\n  string public constant INVALID_EXECUTION_TARGET = '81';\n  string public constant MISSING_VOTING_CONFIGURATIONS = '82'; // voting configurations for lvl1 and lvl2 must be included on initialization\n  string public constant INVALID_PROPOSITION_POWER = '83';\n  string public constant INVALID_YES_THRESHOLD = '84';\n  string public constant INVALID_YES_NO_DIFFERENTIAL = '85';\n  string public constant ETH_TRANSFER_FAILED = '86';\n  string public constant INVALID_INITIAL_VOTING_CONFIGS = '87'; // initial voting configurations can not be of the same level\n  string public constant INVALID_VOTING_PORTAL_ADDRESS_IN_VOTING_MACHINE = '88';\n  string public constant INVALID_VOTING_PORTAL_OWNER = '89';\n  string public constant CANCELLATION_FEE_REDEEM_FAILED = '90'; // cancellation fee was not able to be redeemed\n  string public constant INVALID_CANCELLATION_FEE_COLLECTOR = '91'; // collector can not be address 0\n  string public constant INVALID_CANCELLATION_FEE_SENT = '92'; // cancellation fee sent does not match the needed amount\n  string public constant CANCELLATION_FEE_ALREADY_REDEEMED = '93'; // cancellation fee already redeemed\n  string public constant INVALID_STATE_TO_REDEEM_CANCELLATION_FEE = '94'; // proposal state is not a valid state to redeem cancellation fee\n  string public constant MISSING_REPRESENTATION_ROOTS = '95'; // to represent a voter the representation roots need to be registered\n  string public constant CALLER_IS_NOT_VOTER_REPRESENTATIVE = '96'; // to represent a voter, caller must be the stored representative\n  string public constant VM_INVALID_GOVERNANCE_ADDRESS = '97'; // governance address can not be 0\n  string public constant ALL_DELEGATION_ACTIONS_FAILED = '98'; // all meta delegation actions failed on MetaDelegateHelper\n}\n"},{"file_path":"src/contracts/payloads/PayloadsControllerUtils.sol","source_code":"// SPDX-License-Identifier: BUSL-1.1\npragma solidity ^0.8.0;\n\nlibrary PayloadsControllerUtils {\n  /// @notice enum with supported access levels\n  enum AccessControl {\n    Level_null, // to not use 0\n    Level_1, // LEVEL_1 - short executor before, listing assets, changes of assets params, updates of the protocol etc\n    Level_2 // LEVEL_2 - long executor before, payloads controller updates\n  }\n\n  /**\n   * @notice Object containing the necessary payload information.\n   * @param chain\n   * @param accessLevel\n   * @param payloadsController\n   * @param payloadId\n   */\n  struct Payload {\n    uint256 chain;\n    AccessControl accessLevel;\n    address payloadsController; // address which holds the logic to execute after success proposal voting\n    uint40 payloadId; // number of the payload placed to payloadsController, max is: ~10¹²\n  }\n}\n"},{"file_path":"src/contracts/voting/interfaces/IDataWarehouse.sol","source_code":"// SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.0;\n\nimport {StateProofVerifier} from '../libs/StateProofVerifier.sol';\n\n/**\n * @title IDataWarehouse\n * @author BGD Labs\n * @notice interface containing the methods definitions of the DataWarehouse contract\n */\ninterface IDataWarehouse {\n  /**\n   * @notice event emitted when a storage root has been processed successfully\n   * @param caller address that called the processStorageRoot method\n   * @param account address where the root is generated\n   * @param blockHash hash of the block where the root was generated\n   */\n  event StorageRootProcessed(\n    address indexed caller,\n    address indexed account,\n    bytes32 indexed blockHash\n  );\n\n  /**\n   * @notice event emitted when a storage root has been processed successfully\n   * @param caller address that called the processStorageSlot method\n   * @param account address where the slot is processed\n   * @param blockHash hash of the block where the storage proof was generated\n   * @param slot storage location to search\n   * @param value storage information on the specified location\n   */\n  event StorageSlotProcessed(\n    address indexed caller,\n    address indexed account,\n    bytes32 indexed blockHash,\n    bytes32 slot,\n    uint256 value\n  );\n\n  /**\n   * @notice method to get the storage roots of an account (token) in a certain block hash\n   * @param account address of the token to get the storage roots from\n   * @param blockHash hash of the block from where the roots are generated\n   * @return state root hash of the account on the block hash specified\n   */\n  function getStorageRoots(\n    address account,\n    bytes32 blockHash\n  ) external view returns (bytes32);\n\n  /**\n   * @notice method to process the storage root from an account on a block hash.\n   * @param account address of the token to get the storage roots from\n   * @param blockHash hash of the block from where the roots are generated\n   * @param blockHeaderRLP rlp encoded block header. At same block where the block hash was taken\n   * @param accountStateProofRLP rlp encoded account state proof, taken in same block as block hash\n   * @return the storage root\n   */\n  function processStorageRoot(\n    address account,\n    bytes32 blockHash,\n    bytes memory blockHeaderRLP,\n    bytes memory accountStateProofRLP\n  ) external returns (bytes32);\n\n  /**\n   * @notice method to get the storage value at a certain slot and block hash for a certain address\n   * @param account address of the token to get the storage roots from\n   * @param blockHash hash of the block from where the roots are generated\n   * @param slot hash of the explicit storage placement where the value to get is found.\n   * @param storageProof generated proof containing the storage, at block hash\n   * @return an object containing the slot value at the specified storage slot\n   */\n  function getStorage(\n    address account,\n    bytes32 blockHash,\n    bytes32 slot,\n    bytes memory storageProof\n  ) external view returns (StateProofVerifier.SlotValue memory);\n\n  /**\n   * @notice method to register the storage value at a certain slot and block hash for a certain address\n   * @param account address of the token to get the storage roots from\n   * @param blockHash hash of the block from where the roots are generated\n   * @param slot hash of the explicit storage placement where the value to get is found.\n   * @param storageProof generated proof containing the storage, at block hash\n   */\n  function processStorageSlot(\n    address account,\n    bytes32 blockHash,\n    bytes32 slot,\n    bytes calldata storageProof\n  ) external;\n\n  /**\n   * @notice method to get the value from storage at a certain block hash, previously registered.\n   * @param blockHash hash of the block from where the roots are generated\n   * @param account address of the token to get the storage roots from\n   * @param slot hash of the explicit storage placement where the value to get is found.\n   * @return numeric slot value of the slot. The value must be decoded to get the actual stored information\n   */\n  function getRegisteredSlot(\n    bytes32 blockHash,\n    address account,\n    bytes32 slot\n  ) external view returns (uint256);\n}\n"},{"file_path":"src/contracts/voting/interfaces/IVotingMachineWithProofs.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {IDataWarehouse} from './IDataWarehouse.sol';\nimport {IVotingStrategy} from './IVotingStrategy.sol';\n\n/**\n * @title IVotingMachine\n * @author BGD Labs\n * @notice interface containing the objects, events and method definitions of the VotingMachine contract\n */\ninterface IVotingMachineWithProofs {\n  /**\n   * @notice Object containing the signature parameters to be able to vote as a representative\n   * @param v v part of the voter signature\n   * @param r r part of the voter signature\n   * @param s s part of the voter signature\n   */\n  struct SignatureParams {\n    uint8 v;\n    bytes32 r;\n    bytes32 s;\n  }\n\n  /**\n   * @notice Object to use over submitVoteBySignature and in case of bridging for protect against wrong roots inclusion\n   * @param underlyingAsset address of the token on L1, used for voting\n   * @param slot base storage position where the balance on underlyingAsset contract resides on L1. (Normally position 0)\n   */\n  struct VotingAssetWithSlot {\n    address underlyingAsset;\n    uint128 slot;\n  }\n\n  /**\n   * @notice object containing the information of a bridged vote\n   * @param support indicates if vote is in favor or against the proposal\n   * @param votingAssetsWithSlots list of token addresses with storage slots, that the voter will use for voting\n   */\n  struct BridgedVote {\n    bool support;\n    VotingAssetWithSlot[] votingAssetsWithSlot;\n  }\n\n  /**\n   * @notice enum delimiting the possible states a proposal can have on the voting machine\n   * @dev ProposalState enum defines the state machine of a proposal being voted, so the order on which the state is\n          defined is important. Check logic correctness if new states are added / removed\n   */\n  enum ProposalState {\n    NotCreated,\n    Active,\n    Finished,\n    SentToGovernance\n  }\n\n  /**\n   * @notice Object with vote information\n   * @param support boolean indicating if the vote is in favor or against a proposal\n   * @param votingPower the power used for voting\n   */\n  struct Vote {\n    bool support;\n    uint248 votingPower;\n  }\n\n  /**\n   * @notice Object containing a proposal information\n   * @param id numeric identification of the proposal\n   * @param sentToGovernance boolean indication if the proposal results have been sent back to L1 governance\n   * @param startTime timestamp of the start of voting on the proposal\n   * @param endTime timestamp when the voting on the proposal finishes (startTime + votingDuration)\n   * @param votingClosedAndSentTimestamp timestamp indicating when the vote has been closed and sent to governance chain\n   * @param forVotes votes cast in favor of the proposal\n   * @param againstVotes votes cast against the proposal\n   * @param creationBlockNumber blockNumber from when the proposal has been created in votingMachine\n   * @param votingClosedAndSentBlockNumber block from when the vote has been closed and sent to governance chain\n   * @param votes mapping indication for every voter of the proposal the information of that vote\n   */\n  struct Proposal {\n    uint256 id;\n    bool sentToGovernance;\n    uint40 startTime;\n    uint40 endTime;\n    uint40 votingClosedAndSentTimestamp;\n    uint128 forVotes;\n    uint128 againstVotes;\n    uint256 creationBlockNumber;\n    uint256 votingClosedAndSentBlockNumber;\n    mapping(address => Vote) votes;\n  }\n\n  /**\n   * @notice Object containing a proposal information\n   * @param id numeric identification of the proposal\n   * @param sentToGovernance boolean indication if the proposal results have been sent back to L1 governance\n   * @param startTime timestamp of the start of voting on the proposal\n   * @param endTime timestamp when the voting on the proposal finishes (startTime + votingDuration)\n   * @param votingClosedAndSentTimestamp timestamp indicating when the vote has been closed and sent to governance chain\n   * @param forVotes votes cast in favor of the proposal\n   * @param againstVotes votes cast against the proposal\n   * @param creationBlockNumber blockNumber from when the proposal has been created in votingMachine\n   * @param votingClosedAndSentBlockNumber block from when the vote has been closed and sent back to governance chain\n   */\n  struct ProposalWithoutVotes {\n    uint256 id;\n    bool sentToGovernance;\n    uint40 startTime;\n    uint40 endTime;\n    uint40 votingClosedAndSentTimestamp;\n    uint128 forVotes;\n    uint128 againstVotes;\n    uint256 creationBlockNumber;\n    uint256 votingClosedAndSentBlockNumber;\n  }\n\n  /**\n   * @notice vote configuration passed from l1\n   * @param votingDuration duration in seconds of the vote for a proposal\n   * @param l1BlockHash hash of the block on L1 from the block when the proposal was activated for voting (sent to voting machine)\n            this block hash is used to delimit from when the voting power is accounted for voting\n   */\n  struct ProposalVoteConfiguration {\n    uint24 votingDuration;\n    bytes32 l1ProposalBlockHash;\n  }\n\n  /**\n   * @notice Object with the necessary information to process a vote\n   * @param underlyingAsset address of the token on L1, used for voting\n   * @param slot base storage position where the balance on underlyingAsset contract resides on L1. (Normally position 0)\n   * @param proof bytes of the generated proof on L1 with the slot information of underlying asset.\n   */\n  struct VotingBalanceProof {\n    address underlyingAsset;\n    uint128 slot;\n    bytes proof;\n  }\n\n  /**\n   * @notice emitted when a proposal is created\n   * @param proposalId numeric id of the created proposal\n   * @param l1BlockHash block hash from the block on l1 from when the proposal was activated for voting\n   * @param startTime timestamp when the proposal was created and ready for voting\n   * @param endTime timestamp of when the voting period ends. (startTime + votingDuration)\n   */\n  event ProposalVoteStarted(\n    uint256 indexed proposalId,\n    bytes32 indexed l1BlockHash,\n    uint256 startTime,\n    uint256 endTime\n  );\n\n  /**\n   * @notice emitted when the results of a vote on a proposal are sent to L1\n   * @param proposalId numeric id of the proposal which results are sent to L1\n   * @param forVotes votes cast in favor of proposal\n   * @param againstVotes votes cast against the proposal\n   */\n  event ProposalResultsSent(\n    uint256 indexed proposalId,\n    uint256 forVotes,\n    uint256 againstVotes\n  );\n\n  /**\n   * @notice emitted when a vote is registered\n   * @param proposalId Id of the proposal\n   * @param voter address of the voter\n   * @param support boolean, true = vote for, false = vote against\n   * @param votingPower Power of the voter/vote\n   */\n  event VoteEmitted(\n    uint256 indexed proposalId,\n    address indexed voter,\n    bool indexed support,\n    uint256 votingPower\n  );\n\n  /**\n   * @notice emitted when a voting configuration of a proposal gets received. Meaning that has been bridged successfully\n   * @param proposalId id of the proposal bridged to start the vote on\n   * @param blockHash hash of the block on L1 when the proposal was activated for voting\n   * @param votingDuration duration in seconds of the vote\n   * @param voteCreated boolean indicating if the vote has been created or not.\n   * @dev the vote will only be created automatically if when the configuration is bridged, all necessary roots\n          have been registered already.\n   */\n  event ProposalVoteConfigurationBridged(\n    uint256 indexed proposalId,\n    bytes32 indexed blockHash,\n    uint24 votingDuration,\n    bool indexed voteCreated\n  );\n\n  /**\n   * @notice method to get the representatives mapping slot in Governance contract\n   * @return representatives slot\n   */\n  function REPRESENTATIVES_SLOT() external view returns (uint256);\n\n  /**\n   * @notice method to get the Governance contract address\n   * @return Governance address\n   */\n  function GOVERNANCE() external view returns (address);\n\n  /**\n   * @notice method to get the voting asset with slot signature\n   * @return signature of the voting asset with slot method\n   */\n  function VOTING_ASSET_WITH_SLOT_RAW() external view returns (string memory);\n\n  /**\n   * @notice method to get the DataWarehouse contract\n   * @return DataWarehouse contract\n   */\n  function DATA_WAREHOUSE() external view returns (IDataWarehouse);\n\n  /**\n   * @notice method to get the VotingStrategy contract\n   * @return VotingStrategy contract\n   */\n  function VOTING_STRATEGY() external view returns (IVotingStrategy);\n\n  /**\n   * @notice Get the v4 compatible domain separator\n   * @dev Return cached value if chainId matches cache, otherwise recomputes separator\n   * @return The domain separator of the token at current chain\n   */\n  function DOMAIN_SEPARATOR() external view returns (bytes32);\n\n  /**\n   * @notice method to get the vote submitted type hash for permits digest\n   * @return hash of vote submitted string\n   */\n  function VOTE_SUBMITTED_TYPEHASH() external view returns (bytes32);\n\n  /**\n   * @notice method to get the vote submitted by representative type hash for permits digest\n   * @return hash of vote submitted by representative string\n   */\n  function VOTE_SUBMITTED_BY_REPRESENTATIVE_TYPEHASH()\n    external\n    view\n    returns (bytes32);\n\n  /**\n   * @notice method to get the voting asset with slot type hash for permits digest\n   * @return hash of vote submitted string\n   */\n  function VOTING_ASSET_WITH_SLOT_TYPEHASH() external view returns (bytes32);\n\n  /**\n   * @notice method to get the contract name for permits digest\n   * @return contract name string\n   */\n  function NAME() external view returns (string memory);\n\n  /**\n   * @notice method to get a proposal information specified by its id\n   * @param proposalId id of the proposal to retrieve\n   * @return the proposal information without the users vote\n   */\n  function getProposalById(\n    uint256 proposalId\n  ) external view returns (ProposalWithoutVotes memory);\n\n  /**\n   * @notice method to get the state of a proposal specified by its id\n   * @param proposalId id of the proposal to retrieve the state of\n   * @return the state of the proposal\n   */\n  function getProposalState(\n    uint256 proposalId\n  ) external view returns (ProposalState);\n\n  /**\n   * @notice method to get the voting configuration of a proposal specified by its id\n   * @param proposalId id of the proposal to retrieve the voting configuration from\n   * @return the proposal vote configuration object\n   */\n  function getProposalVoteConfiguration(\n    uint256 proposalId\n  ) external view returns (ProposalVoteConfiguration memory);\n\n  /**\n  * @notice method to get a paginated list of proposalIds. The proposals are taken from a list of proposals that have\n            received vote configuration from governance chain\n  * @param skip number of proposal ids to skip. from latest in the list of proposal ids with voting configuration\n  * @param size length of proposal ids to ask for.\n  * @return list of proposal ids\n  * @dev This is mainly used to get a list of proposals that require automation in some step of the proposal live cycle.\n  */\n  function getProposalsVoteConfigurationIds(\n    uint256 skip,\n    uint256 size\n  ) external view returns (uint256[] memory);\n\n  /**\n   * @notice method to get the vote set by a user on a proposal specified by its id\n   * @param user address of the user that voted\n   * @param proposalId id of the proposal to retrieve the vote from\n   * @return the vote (support and voting power) emitted\n   */\n  function getUserProposalVote(\n    address user,\n    uint256 proposalId\n  ) external view returns (Vote memory);\n\n  /**\n    * @notice method to start a vote on a proposal specified by its id.\n    * @param proposalId id of the proposal to start the vote on.\n    * @return the id of the proposal that had the vote started on.\n    * @dev this method can be called by anyone, requiring that the appropriate conditions are met.\n           basically that the proper roots have been registered.\n           It can also be called internally when the bridged message is received and the the required roots\n           have been registered\n    */\n  function startProposalVote(uint256 proposalId) external returns (uint256);\n\n  /**\n    * @notice method to cast a vote on a proposal specified by its id\n    * @param proposalId id of the proposal on which the vote will be cast\n    * @param support boolean indicating if the vote is in favor or against the proposal\n    * @param votingBalanceProofs list of objects containing the information necessary to vote using the tokens\n             allowed on the voting strategy.\n    * @dev A vote does not need to use all the tokens allowed, can be a subset\n    */\n  function submitVote(\n    uint256 proposalId,\n    bool support,\n    VotingBalanceProof[] calldata votingBalanceProofs\n  ) external;\n\n  /**\n   * @notice Function to register the vote of user that has voted offchain via signature\n   * @param proposalId id of the proposal\n   * @param voter the voter address\n   * @param support boolean, true = vote for, false = vote against\n   * @param votingBalanceProofs list of voting assets proofs\n   * @param v v part of the voter signature\n   * @param r r part of the voter signature\n   * @param s s part of the voter signature\n   */\n  function submitVoteBySignature(\n    uint256 proposalId,\n    address voter,\n    bool support,\n    VotingBalanceProof[] calldata votingBalanceProofs,\n    uint8 v,\n    bytes32 r,\n    bytes32 s\n  ) external;\n\n  /**\n   * @notice method to close a vote on a proposal specified by its id and send the results back to governance\n   * @param proposalId id of the proposal to close the vote on and send the voting result to governance\n   * @dev This method will trigger the bridging flow\n   */\n  function closeAndSendVote(uint256 proposalId) external;\n\n  /**\n   * @notice Function to register the vote of user as its representative\n   * @param proposalId id of the proposal\n   * @param support boolean, true = vote for, false = vote against\n   * @param voter the voter address\n   * @param proofOfRepresentation proof that can validate that msg.sender is the voter representative\n   * @param votingBalanceProofs list of voting assets proofs\n   */\n  function submitVoteAsRepresentative(\n    uint256 proposalId,\n    bool support,\n    address voter,\n    bytes memory proofOfRepresentation,\n    VotingBalanceProof[] calldata votingBalanceProofs\n  ) external;\n\n  /**\n   * @notice Function to register the vote of user as its representative with a signed message\n   * @param proposalId id of the proposal\n   * @param voter the voter address\n   * @param proofOfRepresentation proof that can validate that msg.sender is the voter representative\n   * @param votingBalanceProofs list of voting assets proofs\n   * @param signatureParams object containing the necessary signature parameters\n   */\n  function submitVoteAsRepresentativeBySignature(\n    uint256 proposalId,\n    address voter,\n    address representative,\n    bool support,\n    bytes memory proofOfRepresentation,\n    VotingBalanceProof[] calldata votingBalanceProofs,\n    SignatureParams memory signatureParams\n  ) external;\n}\n"},{"file_path":"src/contracts/voting/interfaces/IVotingStrategy.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {IDataWarehouse} from './IDataWarehouse.sol';\n\n/**\n * @title IVotingStrategy\n * @author BGD Labs\n * @notice interface containing the methods definitions of the VotingStrategy contract\n */\ninterface IVotingStrategy {\n  /**\n   * @notice method to get the DataWarehouse contract\n   * @return DataWarehouse contract\n   */\n  function DATA_WAREHOUSE() external view returns (IDataWarehouse);\n\n  /**\n   * @notice method to get the exchange rate precision. Taken from stkTokenV3 contract\n   * @return exchange rate precission\n   */\n  function STK_AAVE_SLASHING_EXCHANGE_RATE_PRECISION()\n    external\n    view\n    returns (uint256);\n\n  /**\n   * @notice method to get the slot of the stkAave exchange rate in the stkAave contract\n   * @return stkAave exchange rate slot\n   */\n  function STK_AAVE_SLASHING_EXCHANGE_RATE_SLOT()\n    external\n    view\n    returns (uint256);\n\n  /**\n   * @notice method to get the power scale factor of the delegated balances\n   * @return power scale factor\n   */\n  function POWER_SCALE_FACTOR() external view returns (uint256);\n\n  /**\n   * @notice method to get the power of an asset\n   * @param asset address of the token to get the power\n   * @param storageSlot storage position of the balance mapping\n   * @param power balance of a determined asset to be used for the vote\n   * @param blockHash block hash of when we want to get the power. Optional parameter\n   * @return voting power of the specified asset\n   */\n  function getVotingPower(\n    address asset,\n    uint128 storageSlot,\n    uint256 power,\n    bytes32 blockHash\n  ) external view returns (uint256);\n\n  /**\n   * @notice method to check that the roots for all the tokens in the voting strategy have been registered. Including\n             the registry of the stkAave exchange rate slot\n   * @param blockHash hash of the block from where the roots have been registered.\n   */\n  function hasRequiredRoots(bytes32 blockHash) external view;\n}\n"},{"file_path":"src/contracts/voting/libs/MerklePatriciaProofVerifier.sol","source_code":"// SPDX-License-Identifier: MIT\n\n/**\n * Copied from https://github.com/lidofinance/curve-merkle-oracle/blob/main/contracts/MerklePatriciaProofVerifier.sol\n */\npragma solidity ^0.8.0;\n\nimport {RLPReader} from './RLPReader.sol';\n\nlibrary MerklePatriciaProofVerifier {\n  using RLPReader for RLPReader.RLPItem;\n  using RLPReader for bytes;\n\n  /// @dev Validates a Merkle-Patricia-Trie proof.\n  ///      If the proof proves the inclusion of some key-value pair in the\n  ///      trie, the value is returned. Otherwise, i.e. if the proof proves\n  ///      the exclusion of a key from the trie, an empty byte array is\n  ///      returned.\n  /// @param rootHash is the Keccak-256 hash of the root node of the MPT.\n  /// @param path is the key of the node whose inclusion/exclusion we are\n  ///        proving.\n  /// @param stack is the stack of MPT nodes (starting with the root) that\n  ///        need to be traversed during verification.\n  /// @return value whose inclusion is proved or an empty byte array for\n  ///         a proof of exclusion\n  function extractProofValue(\n    bytes32 rootHash,\n    bytes memory path,\n    RLPReader.RLPItem[] memory stack\n  ) internal pure returns (bytes memory value) {\n    bytes memory mptKey = _decodeNibbles(path, 0);\n    uint256 mptKeyOffset = 0;\n\n    bytes32 nodeHashHash;\n    RLPReader.RLPItem[] memory node;\n\n    RLPReader.RLPItem memory rlpValue;\n\n    if (stack.length == 0) {\n      // Root hash of empty Merkle-Patricia-Trie\n      require(\n        rootHash ==\n          0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\n      );\n      return new bytes(0);\n    }\n\n    // Traverse stack of nodes starting at root.\n    for (uint256 i = 0; i < stack.length; i++) {\n      // We use the fact that an rlp encoded list consists of some\n      // encoding of its length plus the concatenation of its\n      // *rlp-encoded* items.\n\n      // The root node is hashed with Keccak-256 ...\n      if (i == 0 && rootHash != stack[i].rlpBytesKeccak256()) {\n        revert();\n      }\n      // ... whereas all other nodes are hashed with the MPT\n      // hash function.\n      if (i != 0 && nodeHashHash != _mptHashHash(stack[i])) {\n        revert();\n      }\n      // We verified that stack[i] has the correct hash, so we\n      // may safely decode it.\n      node = stack[i].toList();\n\n      if (node.length == 2) {\n        // Extension or Leaf node\n\n        bool isLeaf;\n        bytes memory nodeKey;\n        (isLeaf, nodeKey) = _merklePatriciaCompactDecode(node[0].toBytes());\n\n        uint256 prefixLength = _sharedPrefixLength(\n          mptKeyOffset,\n          mptKey,\n          nodeKey\n        );\n        mptKeyOffset += prefixLength;\n\n        if (prefixLength < nodeKey.length) {\n          // Proof claims divergent extension or leaf. (Only\n          // relevant for proofs of exclusion.)\n          // An Extension/Leaf node is divergent iff it \"skips\" over\n          // the point at which a Branch node should have been had the\n          // excluded key been included in the trie.\n          // Example: Imagine a proof of exclusion for path [1, 4],\n          // where the current node is a Leaf node with\n          // path [1, 3, 3, 7]. For [1, 4] to be included, there\n          // should have been a Branch node at [1] with a child\n          // at 3 and a child at 4.\n\n          // Sanity check\n          if (i < stack.length - 1) {\n            // divergent node must come last in proof\n            revert();\n          }\n\n          return new bytes(0);\n        }\n\n        if (isLeaf) {\n          // Sanity check\n          if (i < stack.length - 1) {\n            // leaf node must come last in proof\n            revert();\n          }\n\n          if (mptKeyOffset < mptKey.length) {\n            return new bytes(0);\n          }\n\n          rlpValue = node[1];\n          return rlpValue.toBytes();\n        } else {\n          // extension\n          // Sanity check\n          if (i == stack.length - 1) {\n            // shouldn't be at last level\n            revert();\n          }\n\n          if (!node[1].isList()) {\n            // rlp(child) was at least 32 bytes. node[1] contains\n            // Keccak256(rlp(child)).\n            nodeHashHash = node[1].payloadKeccak256();\n          } else {\n            // rlp(child) was less than 32 bytes. node[1] contains\n            // rlp(child).\n            nodeHashHash = node[1].rlpBytesKeccak256();\n          }\n        }\n      } else if (node.length == 17) {\n        // Branch node\n\n        if (mptKeyOffset != mptKey.length) {\n          // we haven't consumed the entire path, so we need to look at a child\n          uint8 nibble = uint8(mptKey[mptKeyOffset]);\n          mptKeyOffset += 1;\n          if (nibble >= 16) {\n            // each element of the path has to be a nibble\n            revert();\n          }\n\n          if (_isEmptyBytesequence(node[nibble])) {\n            // Sanity\n            if (i != stack.length - 1) {\n              // leaf node should be at last level\n              revert();\n            }\n\n            return new bytes(0);\n          } else if (!node[nibble].isList()) {\n            nodeHashHash = node[nibble].payloadKeccak256();\n          } else {\n            nodeHashHash = node[nibble].rlpBytesKeccak256();\n          }\n        } else {\n          // we have consumed the entire mptKey, so we need to look at what's contained in this node.\n\n          // Sanity\n          if (i != stack.length - 1) {\n            // should be at last level\n            revert();\n          }\n\n          return node[16].toBytes();\n        }\n      }\n    }\n  }\n\n  /// @dev Computes the hash of the Merkle-Patricia-Trie hash of the RLP item.\n  ///      Merkle-Patricia-Tries use a weird \"hash function\" that outputs\n  ///      *variable-length* hashes: If the item is shorter than 32 bytes,\n  ///      the MPT hash is the item. Otherwise, the MPT hash is the\n  ///      Keccak-256 hash of the item.\n  ///      The easiest way to compare variable-length byte sequences is\n  ///      to compare their Keccak-256 hashes.\n  /// @param item The RLP item to be hashed.\n  /// @return Keccak-256(MPT-hash(item))\n  function _mptHashHash(\n    RLPReader.RLPItem memory item\n  ) private pure returns (bytes32) {\n    if (item.len < 32) {\n      return item.rlpBytesKeccak256();\n    } else {\n      return keccak256(abi.encodePacked(item.rlpBytesKeccak256()));\n    }\n  }\n\n  function _isEmptyBytesequence(\n    RLPReader.RLPItem memory item\n  ) private pure returns (bool) {\n    if (item.len != 1) {\n      return false;\n    }\n    uint8 b;\n    uint256 memPtr = item.memPtr;\n    assembly {\n      b := byte(0, mload(memPtr))\n    }\n    return b == 0x80 /* empty byte string */;\n  }\n\n  function _merklePatriciaCompactDecode(\n    bytes memory compact\n  ) private pure returns (bool isLeaf, bytes memory nibbles) {\n    require(compact.length > 0);\n    uint256 first_nibble = (uint8(compact[0]) >> 4) & 0xF;\n    uint256 skipNibbles;\n    if (first_nibble == 0) {\n      skipNibbles = 2;\n      isLeaf = false;\n    } else if (first_nibble == 1) {\n      skipNibbles = 1;\n      isLeaf = false;\n    } else if (first_nibble == 2) {\n      skipNibbles = 2;\n      isLeaf = true;\n    } else if (first_nibble == 3) {\n      skipNibbles = 1;\n      isLeaf = true;\n    } else {\n      // Not supposed to happen!\n      revert();\n    }\n    return (isLeaf, _decodeNibbles(compact, skipNibbles));\n  }\n\n  function _decodeNibbles(\n    bytes memory compact,\n    uint256 skipNibbles\n  ) private pure returns (bytes memory nibbles) {\n    require(compact.length > 0);\n\n    uint256 length = compact.length * 2;\n    require(skipNibbles <= length);\n    length -= skipNibbles;\n\n    nibbles = new bytes(length);\n    uint256 nibblesLength = 0;\n\n    for (uint256 i = skipNibbles; i < skipNibbles + length; i += 1) {\n      if (i % 2 == 0) {\n        nibbles[nibblesLength] = bytes1((uint8(compact[i / 2]) >> 4) & 0xF);\n      } else {\n        nibbles[nibblesLength] = bytes1((uint8(compact[i / 2]) >> 0) & 0xF);\n      }\n      nibblesLength += 1;\n    }\n\n    assert(nibblesLength == nibbles.length);\n  }\n\n  function _sharedPrefixLength(\n    uint256 xsOffset,\n    bytes memory xs,\n    bytes memory ys\n  ) private pure returns (uint256) {\n    uint256 i;\n    for (i = 0; i + xsOffset < xs.length && i < ys.length; i++) {\n      if (xs[i + xsOffset] != ys[i]) {\n        return i;\n      }\n    }\n    return i;\n  }\n}\n"},{"file_path":"src/contracts/voting/libs/RLPReader.sol","source_code":"// SPDX-License-Identifier: Apache-2.0\n\n/*\n * @author Hamdi Allam hamdi.allam97@gmail.com\n * Please reach out with any questions or concerns\n * Code copied from: https://github.com/hamdiallam/Solidity-RLP/blob/master/contracts/RLPReader.sol\n */\npragma solidity ^0.8.0;\n\nlibrary RLPReader {\n  uint8 constant STRING_SHORT_START = 0x80;\n  uint8 constant STRING_LONG_START = 0xb8;\n  uint8 constant LIST_SHORT_START = 0xc0;\n  uint8 constant LIST_LONG_START = 0xf8;\n  uint8 constant WORD_SIZE = 32;\n\n  struct RLPItem {\n    uint256 len;\n    uint256 memPtr;\n  }\n\n  struct Iterator {\n    RLPItem item; // Item that's being iterated over.\n    uint256 nextPtr; // Position of the next item in the list.\n  }\n\n  /*\n   * @dev Returns the next element in the iteration. Reverts if it has not next element.\n   * @param self The iterator.\n   * @return The next element in the iteration.\n   */\n  function next(Iterator memory self) internal pure returns (RLPItem memory) {\n    require(hasNext(self));\n\n    uint256 ptr = self.nextPtr;\n    uint256 itemLength = _itemLength(ptr);\n    self.nextPtr = ptr + itemLength;\n\n    return RLPItem(itemLength, ptr);\n  }\n\n  /*\n   * @dev Returns true if the iteration has more elements.\n   * @param self The iterator.\n   * @return true if the iteration has more elements.\n   */\n  function hasNext(Iterator memory self) internal pure returns (bool) {\n    RLPItem memory item = self.item;\n    return self.nextPtr < item.memPtr + item.len;\n  }\n\n  /*\n   * @param item RLP encoded bytes\n   */\n  function toRlpItem(bytes memory item) internal pure returns (RLPItem memory) {\n    uint256 memPtr;\n    assembly {\n      memPtr := add(item, 0x20)\n    }\n\n    return RLPItem(item.length, memPtr);\n  }\n\n  /*\n   * @dev Create an iterator. Reverts if item is not a list.\n   * @param self The RLP item.\n   * @return An 'Iterator' over the item.\n   */\n  function iterator(\n    RLPItem memory self\n  ) internal pure returns (Iterator memory) {\n    require(isList(self));\n\n    uint256 ptr = self.memPtr + _payloadOffset(self.memPtr);\n    return Iterator(self, ptr);\n  }\n\n  /*\n   * @param the RLP item.\n   */\n  function rlpLen(RLPItem memory item) internal pure returns (uint256) {\n    return item.len;\n  }\n\n  /*\n   * @param the RLP item.\n   * @return (memPtr, len) pair: location of the item's payload in memory.\n   */\n  function payloadLocation(\n    RLPItem memory item\n  ) internal pure returns (uint256, uint256) {\n    uint256 offset = _payloadOffset(item.memPtr);\n    uint256 memPtr = item.memPtr + offset;\n    uint256 len = item.len - offset; // data length\n    return (memPtr, len);\n  }\n\n  /*\n   * @param the RLP item.\n   */\n  function payloadLen(RLPItem memory item) internal pure returns (uint256) {\n    (, uint256 len) = payloadLocation(item);\n    return len;\n  }\n\n  /*\n   * @param the RLP item containing the encoded list.\n   */\n  function toList(\n    RLPItem memory item\n  ) internal pure returns (RLPItem[] memory) {\n    require(isList(item));\n\n    uint256 items = numItems(item);\n    RLPItem[] memory result = new RLPItem[](items);\n\n    uint256 memPtr = item.memPtr + _payloadOffset(item.memPtr);\n    uint256 dataLen;\n    for (uint256 i = 0; i < items; i++) {\n      dataLen = _itemLength(memPtr);\n      result[i] = RLPItem(dataLen, memPtr);\n      memPtr = memPtr + dataLen;\n    }\n\n    return result;\n  }\n\n  // @return indicator whether encoded payload is a list. negate this function call for isData.\n  function isList(RLPItem memory item) internal pure returns (bool) {\n    if (item.len == 0) return false;\n\n    uint8 byte0;\n    uint256 memPtr = item.memPtr;\n    assembly {\n      byte0 := byte(0, mload(memPtr))\n    }\n\n    if (byte0 < LIST_SHORT_START) return false;\n    return true;\n  }\n\n  /*\n   * @dev A cheaper version of keccak256(toRlpBytes(item)) that avoids copying memory.\n   * @return keccak256 hash of RLP encoded bytes.\n   */\n  function rlpBytesKeccak256(\n    RLPItem memory item\n  ) internal pure returns (bytes32) {\n    uint256 ptr = item.memPtr;\n    uint256 len = item.len;\n    bytes32 result;\n    assembly {\n      result := keccak256(ptr, len)\n    }\n    return result;\n  }\n\n  /*\n   * @dev A cheaper version of keccak256(toBytes(item)) that avoids copying memory.\n   * @return keccak256 hash of the item payload.\n   */\n  function payloadKeccak256(\n    RLPItem memory item\n  ) internal pure returns (bytes32) {\n    (uint256 memPtr, uint256 len) = payloadLocation(item);\n    bytes32 result;\n    assembly {\n      result := keccak256(memPtr, len)\n    }\n    return result;\n  }\n\n  /** RLPItem conversions into data types **/\n\n  // @returns raw rlp encoding in bytes\n  function toRlpBytes(\n    RLPItem memory item\n  ) internal pure returns (bytes memory) {\n    bytes memory result = new bytes(item.len);\n    if (result.length == 0) return result;\n\n    uint256 ptr;\n    assembly {\n      ptr := add(0x20, result)\n    }\n\n    copy(item.memPtr, ptr, item.len);\n    return result;\n  }\n\n  // any non-zero byte except \"0x80\" is considered true\n  function toBoolean(RLPItem memory item) internal pure returns (bool) {\n    require(item.len == 1);\n    uint256 result;\n    uint256 memPtr = item.memPtr;\n    assembly {\n      result := byte(0, mload(memPtr))\n    }\n\n    // SEE Github Issue #5.\n    // Summary: Most commonly used RLP libraries (i.e Geth) will encode\n    // \"0\" as \"0x80\" instead of as \"0\". We handle this edge case explicitly\n    // here.\n    if (result == 0 || result == STRING_SHORT_START) {\n      return false;\n    } else {\n      return true;\n    }\n  }\n\n  function toAddress(RLPItem memory item) internal pure returns (address) {\n    // 1 byte for the length prefix\n    require(item.len == 21);\n\n    return address(uint160(toUint(item)));\n  }\n\n  function toUint(RLPItem memory item) internal pure returns (uint256) {\n    require(item.len > 0 && item.len <= 33);\n\n    (uint256 memPtr, uint256 len) = payloadLocation(item);\n\n    uint256 result;\n    assembly {\n      result := mload(memPtr)\n\n      // shift to the correct location if neccesary\n      if lt(len, 32) {\n        result := div(result, exp(256, sub(32, len)))\n      }\n    }\n\n    return result;\n  }\n\n  // enforces 32 byte length\n  function toUintStrict(RLPItem memory item) internal pure returns (uint256) {\n    // one byte prefix\n    require(item.len == 33);\n\n    uint256 result;\n    uint256 memPtr = item.memPtr + 1;\n    assembly {\n      result := mload(memPtr)\n    }\n\n    return result;\n  }\n\n  function toBytes(RLPItem memory item) internal pure returns (bytes memory) {\n    require(item.len > 0);\n\n    (uint256 memPtr, uint256 len) = payloadLocation(item);\n    bytes memory result = new bytes(len);\n\n    uint256 destPtr;\n    assembly {\n      destPtr := add(0x20, result)\n    }\n\n    copy(memPtr, destPtr, len);\n    return result;\n  }\n\n  /*\n   * Private Helpers\n   */\n\n  // @return number of payload items inside an encoded list.\n  function numItems(RLPItem memory item) private pure returns (uint256) {\n    if (item.len == 0) return 0;\n\n    uint256 count = 0;\n    uint256 currPtr = item.memPtr + _payloadOffset(item.memPtr);\n    uint256 endPtr = item.memPtr + item.len;\n    while (currPtr < endPtr) {\n      currPtr = currPtr + _itemLength(currPtr); // skip over an item\n      count++;\n    }\n\n    return count;\n  }\n\n  // @return entire rlp item byte length\n  function _itemLength(uint256 memPtr) private pure returns (uint256) {\n    uint256 itemLen;\n    uint256 byte0;\n    assembly {\n      byte0 := byte(0, mload(memPtr))\n    }\n\n    if (byte0 < STRING_SHORT_START) {\n      itemLen = 1;\n    } else if (byte0 < STRING_LONG_START) {\n      itemLen = byte0 - STRING_SHORT_START + 1;\n    } else if (byte0 < LIST_SHORT_START) {\n      assembly {\n        let byteLen := sub(byte0, 0xb7) // # of bytes the actual length is\n        memPtr := add(memPtr, 1) // skip over the first byte\n\n        /* 32 byte word size */\n        let dataLen := div(mload(memPtr), exp(256, sub(32, byteLen))) // right shifting to get the len\n        itemLen := add(dataLen, add(byteLen, 1))\n      }\n    } else if (byte0 < LIST_LONG_START) {\n      itemLen = byte0 - LIST_SHORT_START + 1;\n    } else {\n      assembly {\n        let byteLen := sub(byte0, 0xf7)\n        memPtr := add(memPtr, 1)\n\n        let dataLen := div(mload(memPtr), exp(256, sub(32, byteLen))) // right shifting to the correct length\n        itemLen := add(dataLen, add(byteLen, 1))\n      }\n    }\n\n    return itemLen;\n  }\n\n  // @return number of bytes until the data\n  function _payloadOffset(uint256 memPtr) private pure returns (uint256) {\n    uint256 byte0;\n    assembly {\n      byte0 := byte(0, mload(memPtr))\n    }\n\n    if (byte0 < STRING_SHORT_START) {\n      return 0;\n    } else if (\n      byte0 < STRING_LONG_START ||\n      (byte0 >= LIST_SHORT_START && byte0 < LIST_LONG_START)\n    ) {\n      return 1;\n    } else if (byte0 < LIST_SHORT_START) {\n      // being explicit\n      return byte0 - (STRING_LONG_START - 1) + 1;\n    } else {\n      return byte0 - (LIST_LONG_START - 1) + 1;\n    }\n  }\n\n  /*\n   * @param src Pointer to source\n   * @param dest Pointer to destination\n   * @param len Amount of memory to copy from the source\n   */\n  function copy(uint256 src, uint256 dest, uint256 len) private pure {\n    if (len == 0) return;\n\n    // copy as many word sizes as possible\n    for (; len >= WORD_SIZE; len -= WORD_SIZE) {\n      assembly {\n        mstore(dest, mload(src))\n      }\n\n      src += WORD_SIZE;\n      dest += WORD_SIZE;\n    }\n\n    if (len > 0) {\n      // left over bytes. Mask is used to remove unwanted bytes from the word\n      uint256 mask = 256 ** (WORD_SIZE - len) - 1;\n      assembly {\n        let srcpart := and(mload(src), not(mask)) // zero out src\n        let destpart := and(mload(dest), mask) // retrieve the bytes\n        mstore(dest, or(destpart, srcpart))\n      }\n    }\n  }\n}\n"},{"file_path":"src/contracts/voting/libs/StateProofVerifier.sol","source_code":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport {RLPReader} from './RLPReader.sol';\nimport {MerklePatriciaProofVerifier} from './MerklePatriciaProofVerifier.sol';\n\n/**\n * @title A helper library for verification of Merkle Patricia account and state proofs.\n */\nlibrary StateProofVerifier {\n  using RLPReader for RLPReader.RLPItem;\n  using RLPReader for bytes;\n\n  uint256 constant HEADER_STATE_ROOT_INDEX = 3;\n  uint256 constant HEADER_NUMBER_INDEX = 8;\n  uint256 constant HEADER_TIMESTAMP_INDEX = 11;\n\n  struct BlockHeader {\n    bytes32 hash;\n    bytes32 stateRootHash;\n    uint256 number;\n    uint256 timestamp;\n  }\n\n  struct Account {\n    bool exists;\n    uint256 nonce;\n    uint256 balance;\n    bytes32 storageRoot;\n    bytes32 codeHash;\n  }\n\n  struct SlotValue {\n    bool exists;\n    uint256 value;\n  }\n\n  /**\n   * @notice Parses block header and verifies its presence onchain within the latest 256 blocks.\n   * @param _headerRlpBytes RLP-encoded block header.\n   */\n  function verifyBlockHeader(\n    bytes memory _headerRlpBytes,\n    bytes32 _blockHash\n  ) internal pure returns (BlockHeader memory) {\n    BlockHeader memory header = parseBlockHeader(_headerRlpBytes);\n    require(header.hash == _blockHash, 'blockhash mismatch');\n    return header;\n  }\n\n  /**\n   * @notice Parses RLP-encoded block header.\n   * @param _headerRlpBytes RLP-encoded block header.\n   */\n  function parseBlockHeader(\n    bytes memory _headerRlpBytes\n  ) internal pure returns (BlockHeader memory) {\n    BlockHeader memory result;\n    RLPReader.RLPItem[] memory headerFields = _headerRlpBytes\n      .toRlpItem()\n      .toList();\n\n    require(headerFields.length > HEADER_TIMESTAMP_INDEX);\n\n    result.stateRootHash = bytes32(\n      headerFields[HEADER_STATE_ROOT_INDEX].toUint()\n    );\n    result.number = headerFields[HEADER_NUMBER_INDEX].toUint();\n    result.timestamp = headerFields[HEADER_TIMESTAMP_INDEX].toUint();\n    result.hash = keccak256(_headerRlpBytes);\n\n    return result;\n  }\n\n  /**\n   * @notice Verifies Merkle Patricia proof of an account and extracts the account fields.\n   *\n   * @param _addressHash Keccak256 hash of the address corresponding to the account.\n   * @param _stateRootHash MPT root hash of the Ethereum state trie.\n   */\n  function extractAccountFromProof(\n    bytes32 _addressHash, // keccak256(abi.encodePacked(address))\n    bytes32 _stateRootHash,\n    RLPReader.RLPItem[] memory _proof\n  ) internal pure returns (Account memory) {\n    bytes memory acctRlpBytes = MerklePatriciaProofVerifier.extractProofValue(\n      _stateRootHash,\n      abi.encodePacked(_addressHash),\n      _proof\n    );\n    Account memory account;\n\n    if (acctRlpBytes.length == 0) {\n      return account;\n    }\n\n    RLPReader.RLPItem[] memory acctFields = acctRlpBytes.toRlpItem().toList();\n    require(acctFields.length == 4);\n\n    account.exists = true;\n    account.nonce = acctFields[0].toUint();\n    account.balance = acctFields[1].toUint();\n    account.storageRoot = bytes32(acctFields[2].toUint());\n    account.codeHash = bytes32(acctFields[3].toUint());\n\n    return account;\n  }\n\n  /**\n   * @notice Verifies Merkle Patricia proof of a slot and extracts the slot's value.\n   *\n   * @param _slotHash Keccak256 hash of the slot position.\n   * @param _storageRootHash MPT root hash of the account's storage trie.\n   */\n  function extractSlotValueFromProof(\n    bytes32 _slotHash,\n    bytes32 _storageRootHash,\n    RLPReader.RLPItem[] memory _proof\n  ) internal pure returns (SlotValue memory) {\n    bytes memory valueRlpBytes = MerklePatriciaProofVerifier.extractProofValue(\n      _storageRootHash,\n      abi.encodePacked(_slotHash),\n      _proof\n    );\n\n    SlotValue memory value;\n\n    if (valueRlpBytes.length != 0) {\n      value.exists = true;\n      value.value = valueRlpBytes.toRlpItem().toUint();\n    }\n\n    return value;\n  }\n}\n"},{"file_path":"src/interfaces/IBaseVotingStrategy.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/**\n * @title IBaseVotingStrategy\n * @author BGD Labs\n * @notice interface containing the objects, events and method definitions of the BaseVotingStrategy contract\n */\ninterface IBaseVotingStrategy {\n  /**\n   * @notice object storing the information of the asset used for the voting strategy\n   * @param storageSlots list of slots for the balance of the specified token.\n            From that slot, by adding the address of the user, the correct balance can be taken.\n   */\n  struct VotingAssetConfig {\n    uint128[] storageSlots;\n  }\n\n  /**\n   * @notice emitted when an asset is added for the voting strategy\n   * @param asset address of the token to be added\n   * @param storageSlots array of storage positions of the balance mapping\n   */\n  event VotingAssetAdd(address indexed asset, uint128[] storageSlots);\n\n  /**\n   * @notice method to get the AAVE token address\n   * @return AAVE token contract address\n   */\n  function AAVE() external view returns (address);\n\n  /**\n   * @notice method to get the A_AAVE token address\n   * @return A_AAVE token contract address\n   */\n  function A_AAVE() external view returns (address);\n\n  /**\n   * @notice method to get the stkAAVE token address\n   * @return stkAAVE token contract address\n   */\n  function STK_AAVE() external view returns (address);\n\n  /**\n   * @notice method to get the slot of the balance of the AAVE and stkAAVE\n   * @return AAVE and stkAAVE base balance slot\n   */\n  function BASE_BALANCE_SLOT() external view returns (uint128);\n\n  /**\n   * @notice method to get the slot of the balance of the AAVE aToken\n   * @return AAVE aToken base balance slot\n   */\n  function A_AAVE_BASE_BALANCE_SLOT() external view returns (uint128);\n\n  /**\n   * @notice method to get the slot of the AAVE aToken delegation state\n   * @return AAVE aToken delegation state slot\n   */\n  function A_AAVE_DELEGATED_STATE_SLOT() external view returns (uint128);\n\n  /**\n   * @notice method to check if a token and slot combination is accepted\n   * @param token address of the token to check\n   * @param slot number of the token slot\n   * @return flag indicating if the token slot is accepted\n   */\n  function isTokenSlotAccepted(\n    address token,\n    uint128 slot\n  ) external view returns (bool);\n\n  /**\n   * @notice method to get the addresses of the assets that can be used for voting\n   * @return list of addresses of assets\n   */\n  function getVotingAssetList() external view returns (address[] memory);\n\n  /**\n   * @notice method to get the configuration for voting of an asset\n   * @param asset address of the asset to get the configuration from\n   * @return object with the asset configuration containing the list of storage slots\n   */\n  function getVotingAssetConfig(\n    address asset\n  ) external view returns (VotingAssetConfig memory);\n}\n"},{"file_path":"src/interfaces/IGovernance.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {IGovernancePowerStrategy} from './IGovernancePowerStrategy.sol';\nimport {IGovernanceCore} from './IGovernanceCore.sol';\n\n/**\n * @title IGovernance\n * @author BGD Labs\n * @notice interface containing the objects, events and methods definitions of the Governance contract\n */\ninterface IGovernance {\n  /**\n   * @notice emitted when gas limit gets updated\n   * @param gasLimit the new gas limit\n   */\n  event GasLimitUpdated(uint256 indexed gasLimit);\n\n  /**\n   * @notice method to get the CrossChainController contract address of the currently deployed address\n   * @return address of CrossChainController contract\n   */\n  function CROSS_CHAIN_CONTROLLER() external view returns (address);\n\n  /**\n   * @notice method to initialize governance v3 on first deploy\n   * @param owner address of the new owner of governance\n   * @param guardian address of the new guardian of governance\n   * @param powerStrategy address of the governance chain voting strategy\n   * @param votingConfigs objects containing the information of different voting configurations depending on access level\n   * @param votingPortals objects containing the information of different voting machines depending on chain id\n   * @param gasLimit gas needed to send a payload for execution\n   * @param cancellationFee fee amount to collateralize against proposal cancellation\n   */\n  function initialize(\n    address owner,\n    address guardian,\n    IGovernancePowerStrategy powerStrategy,\n    IGovernanceCore.SetVotingConfigInput[] calldata votingConfigs,\n    address[] calldata votingPortals,\n    uint256 gasLimit,\n    uint256 cancellationFee\n  ) external;\n\n  /**\n   * @notice method to initialize revision 3 of governance v3\n   * @param gasLimit updated gas limit needed for payload execution on PayloadsController\n   */\n  function initializeWithRevision(uint256 gasLimit) external;\n\n  /**\n   * @notice method to update the gasLimit\n   * @param gasLimit the new gas limit\n   * @dev this method should have a owner gated permission. But responsibility is relegated to inheritance\n   */\n  function updateGasLimit(uint256 gasLimit) external;\n\n  /**\n   * @notice method to get the gasLimit\n   * @return gasLimit the new gas limit\n   */\n  function getGasLimit() external view returns (uint256);\n}\n"},{"file_path":"src/interfaces/IGovernanceCore.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {PayloadsControllerUtils} from '../contracts/payloads/PayloadsControllerUtils.sol';\nimport {IGovernancePowerStrategy} from './IGovernancePowerStrategy.sol';\nimport {IVotingMachineWithProofs} from '../contracts/voting/interfaces/IVotingMachineWithProofs.sol';\nimport {EnumerableSet} from 'openzeppelin-contracts/contracts/utils/structs/EnumerableSet.sol';\n\n/**\n * @title IGovernanceCore\n * @author BGD Labs\n * @notice interface containing the objects, events and methods definitions of the GovernanceCore contract\n */\ninterface IGovernanceCore {\n  /**\n   * @notice Object with the necessary information of a representative\n   * @param representative address that represents the voter\n   * @param chainId id of the chain where the representative is on\n   */\n  struct RepresentativeInput {\n    address representative;\n    uint256 chainId;\n  }\n\n  /**\n   * @notice Object storing the vote configuration for a specific access level\n   * @param coolDownBeforeVotingStart number of seconds indicating how much time should pass before proposal will be moved to vote\n   * @param votingDuration number of seconds indicating the duration of a vote\n   * @param yesThreshold minimum number of yes votes needed for a proposal to pass.\n            FOR VOTES > YES THRESHOLD\n            we consider that this param in case of AAVE don't need decimal places\n   * @param yesNoDifferential number of for votes that need to be bigger than against votes to pass a proposal.\n            FOR VOTES - AGAINST VOTES > YES NO DIFFERENTIAL\n            we consider that this param in case of AAVE don't need decimal places\n   * @param minPropositionPower the minimum needed power to create a proposal.\n            we consider that this param in case of AAVE don't need decimal places\n   */\n  struct VotingConfig {\n    uint24 coolDownBeforeVotingStart;\n    uint24 votingDuration;\n    uint56 yesThreshold;\n    uint56 yesNoDifferential;\n    uint56 minPropositionPower;\n  }\n\n  /**\n   * @notice object storing the input parameters of a voting configuration\n   * @param accessLevel number of access level needed to execute a proposal in this settings\n   * @param coolDownBeforeVotingStart number of seconds indicating the time that must pass from proposal creation for\n            the voting to be activated\n   * @param votingDuration number of seconds indicating the duration of a vote\n   * @param yesThreshold minimum number of yes votes needed for a proposal to pass.\n            FOR VOTES > YES THRESHOLD\n            in normal units with 18 decimals\n   * @param yesNoDifferential number of for votes that need to be bigger than against votes to pass a proposal.\n            FOR VOTES - AGAINST VOTES > YES NO DIFFERENTIAL\n            in normal units with 18 decimals\n   * @param minPropositionPower the minimum needed power to create a proposal.\n            in normal units with 18 decimals\n   */\n  struct SetVotingConfigInput {\n    PayloadsControllerUtils.AccessControl accessLevel;\n    uint24 coolDownBeforeVotingStart;\n    uint24 votingDuration;\n    uint256 yesThreshold;\n    uint256 yesNoDifferential;\n    uint256 minPropositionPower;\n  }\n\n  /**\n   * @notice enum storing the different states of a proposal\n   * @dev State enum defines the state machine of a proposal so the order on which the state is defined is important.\n          Check logic correctness if new states are added / removed\n   */\n  enum State {\n    Null, // proposal does not exists\n    Created, // created, waiting for a cooldown to initiate the balances snapshot\n    Active, // balances snapshot set, voting in progress\n    Queued, // voting results submitted, but proposal is under grace period when guardian can cancel it\n    Executed, // results sent to the execution chain(s)\n    Failed, // voting was not successful\n    Cancelled, // got cancelled by guardian, or because proposition power of creator dropped below allowed minimum\n    Expired\n  }\n\n  /**\n   * @notice object storing all the information of a proposal including the different states in time that can have\n   * @param state current state of the proposal\n   * @param accessLevel minimum level needed to be able to execute this proposal\n   * @param votingDuration number of seconds indicating the duration of a vote. max is: 16'777'216 (ie 194.18 days)\n   * @param creationTime timestamp in seconds of when the proposal was created. max is: 1.099511628×10¹² (ie 34'865 years)\n   * @param votingActivationTime timestamp in seconds of when the voting activates for the proposal\n   * @param queuingTime timestamp in seconds of when the proposal was queued\n   * @param cancelTimestamp timestamp in seconds of when the proposal was canceled\n   * @param creator address of the creator of the proposal\n   * @param votingPortal address of the votingPortal used to communicate with the voting chain\n   * @param snapshotBlockHash block hash of when the proposal was created, as to be able to get the correct balances on this specific block\n   * @param ipfsHash ipfs has containing the proposal metadata information\n   * @param forVotes number of votes in favor of the proposal\n   * @param againstVotes number of votes against the proposal\n   * @param cancellationFee amount in eth that will be retained if proposal is cancelled\n   * @param payloads list of objects containing the payload information necessary for execution\n   */\n  struct Proposal {\n    State state;\n    PayloadsControllerUtils.AccessControl accessLevel;\n    uint40 creationTime;\n    uint24 votingDuration;\n    uint40 votingActivationTime;\n    uint40 queuingTime;\n    uint40 cancelTimestamp;\n    address creator;\n    address votingPortal;\n    bytes32 snapshotBlockHash;\n    bytes32 ipfsHash;\n    uint128 forVotes;\n    uint128 againstVotes;\n    uint256 cancellationFee;\n    PayloadsControllerUtils.Payload[] payloads;\n  }\n\n  /**\n   * @notice emitted when powerStrategy got updated\n   * @param newPowerStrategy address of the new powerStrategy\n   */\n  event PowerStrategyUpdated(address indexed newPowerStrategy);\n\n  /**\n   * @notice emitted when one of the _votingConfigs got updated\n   * @param accessLevel minimum level needed to be able to execute this proposal\n   * @param votingDuration duration of the voting period in seconds\n   * @param coolDownBeforeVotingStart time in seconds between proposal creation and voting activation\n   * @param yesThreshold min amount of yes votes needed to pass a proposal\n   * @param yesNoDifferential minimal difference between you and no votes for proposal to pass\n   * @param minPropositionPower minimal proposition power of a user to be able to create proposal\n   */\n  event VotingConfigUpdated(\n    PayloadsControllerUtils.AccessControl indexed accessLevel,\n    uint24 votingDuration,\n    uint24 coolDownBeforeVotingStart,\n    uint256 yesThreshold,\n    uint256 yesNoDifferential,\n    uint256 minPropositionPower\n  );\n\n  /**\n   * @notice emitted when a proposal is created.\n   * @param proposalId id of the proposal\n   * @param creator address of the creator of the proposal\n   * @param accessLevel minimum level needed to be able to execute this proposal\n   * @param ipfsHash ipfs has containing the proposal metadata information\n   */\n  event ProposalCreated(\n    uint256 indexed proposalId,\n    address indexed creator,\n    PayloadsControllerUtils.AccessControl indexed accessLevel,\n    bytes32 ipfsHash\n  );\n  /**\n   * @notice emitted when voting is activated. Meaning that the vote configuration will be sent to voting machine\n   * @param proposalId id of the proposal\n   * @param snapshotBlockHash block hash of when the proposal was created, as to be able to get the correct balances on this specific block\n   * @param votingDuration duration of the voting period in seconds\n   */\n  event VotingActivated(\n    uint256 indexed proposalId,\n    bytes32 indexed snapshotBlockHash,\n    uint24 votingDuration\n  );\n\n  /**\n   * @notice emitted when proposal change state to Queued\n   * @param proposalId id of the proposal\n   * @param votesFor votes for proposal\n   * @param votesAgainst votes against proposal\n   */\n  event ProposalQueued(\n    uint256 indexed proposalId,\n    uint128 votesFor,\n    uint128 votesAgainst\n  );\n\n  /**\n   * @notice emitted when proposal change state to Executed\n   * @param proposalId id of the proposal\n   */\n  event ProposalExecuted(uint256 indexed proposalId);\n\n  /**\n   * @notice emitted when proposal change state to Canceled\n   * @param proposalId id of the proposal\n   */\n  event ProposalCanceled(uint256 indexed proposalId);\n\n  /**\n   * @notice emitted when proposal change state to Failed\n   * @param proposalId id of the proposal\n   * @param votesFor votes for proposal\n   * @param votesAgainst votes against proposal\n   */\n  event ProposalFailed(\n    uint256 indexed proposalId,\n    uint128 votesFor,\n    uint128 votesAgainst\n  );\n\n  /**\n   * @notice emitted when a voting machine gets updated\n   * @param votingPortal address of the voting portal updated\n   * @param approved boolean indicating if a voting portal has been added or removed\n   */\n  event VotingPortalUpdated(\n    address indexed votingPortal,\n    bool indexed approved\n  );\n\n  /**\n   * @notice emitted when a payload is successfully sent to the execution chain\n   * @param proposalId id of the proposal containing the payload sent for execution\n   * @param payloadId id of the payload sent for execution\n   * @param payloadsController address of the payloads controller on the execution chain\n   * @param chainId id of the execution chain\n   * @param payloadNumberOnProposal number of payload sent for execution, from the number of payloads contained in proposal\n   * @param numberOfPayloadsOnProposal number of payloads that are in the proposal\n   */\n  event PayloadSent(\n    uint256 indexed proposalId,\n    uint40 payloadId,\n    address indexed payloadsController,\n    uint256 indexed chainId,\n    uint256 payloadNumberOnProposal,\n    uint256 numberOfPayloadsOnProposal\n  );\n\n  /**\n   * @notice emitted when a vote is successfully sent to voting chain\n   * @param proposalId id of the proposal the vote is for\n   * @param voter address that wants to vote on a proposal\n   * @param support indicates if vote is in favor or against the proposal\n   * @param votingAssetsWithSlot list of token addresses with the base storage slot to use for the vote\n   */\n  event VoteForwarded(\n    uint256 indexed proposalId,\n    address indexed voter,\n    bool indexed support,\n    IVotingMachineWithProofs.VotingAssetWithSlot[] votingAssetsWithSlot\n  );\n\n  /**\n   * @notice emitted when the cancellation fee is updated\n   * @param cancellationFee amount of the new cancellation fee\n   */\n  event CancellationFeeUpdated(uint256 cancellationFee);\n\n  /**\n   * @notice emitted when the cancellation fee is redeemed\n   * @param proposalId id of the proposal the fee was redeemed from\n   * @param to address that will receive the cancellation fee\n   * @param cancellationFee amount of the cancellation fee redeemed\n   * @param success flag indicating if the transfer was successful or not\n   */\n  event CancellationFeeRedeemed(\n    uint256 indexed proposalId,\n    address indexed to,\n    uint256 cancellationFee,\n    bool indexed success\n  );\n\n  /**\n   * @notice emitted when a voter updates its representative\n   * @param voter address of the voter that updates\n   * @param representative address of the chosen representative\n   * @param chainId id of the chain where representative is representing the voter on\n   */\n  event RepresentativeUpdated(\n    address indexed voter,\n    address indexed representative,\n    uint256 indexed chainId\n  );\n\n  /**\n   * @notice method to get the Cancellation Fee Collector address\n   * @return cancellation fee collector address\n   */\n  function CANCELLATION_FEE_COLLECTOR() external view returns (address);\n\n  /**\n   * @notice method to update the cancellation fee\n   * @param cancellationFee the fee amount to collateralize against a proposal cancellation\n   */\n  function updateCancellationFee(uint256 cancellationFee) external;\n\n  /**\n   * @notice method to get the cancellation fee\n   * @return cancellation fee amount\n   */\n  function getCancellationFee() external view returns (uint256);\n\n  /**\n   * @notice method to redeem the cancellation fee from a proposal\n   * @param proposalIds array of ids of the proposals to redeem the cancellation fee from\n   */\n  function redeemCancellationFee(uint256[] calldata proposalIds) external;\n\n  /**\n   * @notice method to get the number of registered voting portals\n   * @return number of registered voting portals\n   */\n  function getVotingPortalsCount() external view returns (uint256);\n\n  /**\n   * @notice method to approve new voting machines\n   * @param votingPortals array of voting portal addresses to approve\n   */\n  function addVotingPortals(address[] calldata votingPortals) external;\n\n  /**\n   * @notice method to add a new voting portal\n   * @param votingPortal address of the new voting portal\n   * @dev This method is only callable by the Guardian.\n   * @dev This method is only callable when there are no voting portals registered. Its rationale is for the Guardian\n          to be able to \"rescue\" the system in case all voting portals were removed by mistake. This is needed because\n          to add a new voting portal a full governance flow is required, and without the portal, the system would be bricked.\n          To limit the Guardian's power, can only happen if there are no voting portals registered, and the guardian\n          could only add one voting portal.\n   */\n  function rescueVotingPortal(address votingPortal) external;\n\n  /**\n   * @notice method to remove an accepted voting portal.\n   * @param votingPortals list of addresses of the voting machines that are no longer valid\n   * @dev removing a voting portal effectively removes a voting machine\n   */\n  function removeVotingPortals(address[] calldata votingPortals) external;\n\n  /**\n   * @notice creates a proposal, with configuration specified in VotingConfig corresponding to the accessLevel\n   * @param payloads which user propose to vote for\n   * @param votingPortal address of the contract which will bootstrap voting, and provide results in the end\n   * @param ipfsHash ipfs hash of a document with proposal description\n   * @return created proposal ID\n   */\n  function createProposal(\n    PayloadsControllerUtils.Payload[] calldata payloads,\n    address votingPortal,\n    bytes32 ipfsHash\n  ) external payable returns (uint256);\n\n  /**\n   * @notice executes a proposal, can be called by anyone if proposal in Queued state\n   * @notice and passed more then COOLDOWN_PERIOD seconds after proposal entered this state\n   * @param proposalId id of the proposal\n   */\n  function executeProposal(uint256 proposalId) external;\n\n  /**\n   * @notice cancels a proposal, can be initiated by guardian,\n   * @notice or if proposition power of proposal creator will go below minPropositionPower specified in VotingConfig\n   * @param proposalId id of the proposal\n   */\n  function cancelProposal(uint256 proposalId) external;\n\n  /**\n   * @notice gets the state of a proposal\n   * @param proposalId id of the proposal\n   * @return state of the proposal\n   */\n  function getProposalState(uint256 proposalId) external view returns (State);\n\n  /**\n   * @notice method to set a new powerStrategy contract\n   * @param newPowerStrategy address of the new contract containing the voting a voting strategy\n   */\n\n  function setPowerStrategy(IGovernancePowerStrategy newPowerStrategy) external;\n\n  /**\n   * @notice method to set the voting configuration for a determined access level\n   * @param votingConfigs object containing configuration for an access level\n   */\n  function setVotingConfigs(\n    SetVotingConfigInput[] calldata votingConfigs\n  ) external;\n\n  /**\n   * @notice method to get the voting configuration from an access level\n   * @param accessLevel level for which to get the configuration of a vote\n   * @return the voting configuration assigned to the specified accessLevel\n   */\n  function getVotingConfig(\n    PayloadsControllerUtils.AccessControl accessLevel\n  ) external view returns (VotingConfig memory);\n\n  /**\n   * @notice method to get the reasonably achievable voting participation, taking into total supply, and market situation\n   * @return maximum voting participation in wei\n   */\n  function ACHIEVABLE_VOTING_PARTICIPATION() external view returns (uint256);\n\n  /**\n   * @notice method to get the cool down period between queuing and execution\n   * @return time in seconds\n   */\n  function COOLDOWN_PERIOD() external view returns (uint256);\n\n  /**\n   * @notice method to get the minimum voting duration time in seconds\n   * @return time in seconds\n   */\n  function MIN_VOTING_DURATION() external view returns (uint256);\n\n  /**\n   * @notice method to get the precision divider used to remove unneeded decimals\n   * @return decimals of 1 ether (18)\n   */\n  function PRECISION_DIVIDER() external view returns (uint256);\n\n  /**\n   * @notice method to get the expiration time from creation from which the proposal will be invalid\n   * @return time in seconds\n   */\n  function PROPOSAL_EXPIRATION_TIME() external view returns (uint256);\n\n  /**\n   * @notice method to get the name of the contract\n   * @return name string\n   */\n  function NAME() external view returns (string memory);\n\n  /**\n   * @notice method to get the proposal identified by passed id\n   * @param proposalId id of the proposal to get the information of\n   * @return proposal object containing all the information\n   */\n  function getProposal(\n    uint256 proposalId\n  ) external view returns (Proposal memory);\n\n  /**\n   * @notice address of the current voting strategy to use on the governance\n   * @return address of the voting strategy\n   */\n  function getPowerStrategy() external view returns (IGovernancePowerStrategy);\n\n  /**\n   * @notice proposals counter.\n   * @return the current number proposals created\n   */\n  function getProposalsCount() external view returns (uint256);\n\n  /**\n   * @notice method to get if a voting portal is approved by the governance\n   * @param votingPortal address of the voting portal to check if approved\n   * @return flag indicating the approval status of the voting portal\n   */\n  function isVotingPortalApproved(\n    address votingPortal\n  ) external view returns (bool);\n\n  /**\n   * @notice method to queue a proposal for execution\n   * @param proposalId the id of the proposal to queue\n   * @param forVotes number of votes in favor of the proposal\n   * @param againstVotes number of votes against of the proposal\n   */\n  function queueProposal(\n    uint256 proposalId,\n    uint128 forVotes,\n    uint128 againstVotes\n  ) external;\n\n  /**\n   * @notice method to send proposal to votingMachine\n   * @param proposalId id of the proposal to start the voting on\n   */\n  function activateVoting(uint256 proposalId) external;\n\n  /**\n   * @notice method to get the representative of a voter on a chain\n   * @param voter address of the voter\n   * @param chainId id of the chain to get the representative from\n   * @return address of the representative of the voter on chainId\n   */\n  function getRepresentativeByChain(\n    address voter,\n    uint256 chainId\n  ) external view returns (address);\n\n  /**\n   * @notice method to update the representative of a voter on certain chain.\n   * @param representatives Array of objects with the representative information\n   */\n  function updateRepresentativesForChain(\n    RepresentativeInput[] calldata representatives\n  ) external;\n\n  /**\n   * @notice method to get the voters a representative is representing\n   * @param representative address of the representative\n   * @param chainId id of the chain to search for represented voters\n   */\n  function getRepresentedVotersByChain(\n    address representative,\n    uint256 chainId\n  ) external view returns (address[] memory);\n}\n"},{"file_path":"src/interfaces/IGovernancePowerStrategy.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/**\n * @title IGovernancePowerStrategy\n * @author BGD Labs\n * @notice interface containing the methods definitions of the GovernancePowerStrategy contract\n */\ninterface IGovernancePowerStrategy {\n  /**\n * @notice method to get the full voting power of an user. This method is only use for consulting purposes.\n             As its not used for voting calculations, it is not needed to force blockNumber - 1 to protect against\n             FlashLoan attacks.\n   * @param user address where we want to get the power from\n   * @return full voting power of a user\n   */\n  function getFullVotingPower(address user) external view returns (uint256);\n\n  /**\n   * @notice method to get the full proposal power of an user. It is not needed to protect against FlashLoan\n             attacks because once user returns the tokens (power) the proposal will get canceled as proposal creator\n             will loose the proposition power.\n   * @param user address where we want to get the power from\n   * @return full proposition power of a user\n   */\n  function getFullPropositionPower(\n    address user\n  ) external view returns (uint256);\n}\n"},{"file_path":"src/interfaces/IVotingPortal.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {IBaseReceiverPortal} from 'aave-delivery-infrastructure/contracts/interfaces/IBaseReceiverPortal.sol';\nimport {IVotingMachineWithProofs} from '../contracts/voting/interfaces/IVotingMachineWithProofs.sol';\n\n/**\n * @title IVotingPortal\n * @author BGD Labs\n * @notice interface containing the objects, events and methods definitions of the VotingPortal contract\n */\ninterface IVotingPortal is IBaseReceiverPortal {\n  /**\n   * @notice enum containing the different type of messages that can be bridged\n   * @param Null empty state\n   * @param Proposal indicates that the message is to bridge a proposal configuration\n   */\n  enum MessageType {\n    Null,\n    Proposal\n  }\n\n  /**\n   * @notice emitted when \"Start voting\" gas limit gets updated\n   * @param gasLimit the new gas limit\n   */\n  event StartVotingGasLimitUpdated(uint128 gasLimit);\n\n  /**\n   * @notice emitted when a vote message is received\n   * @param originSender address that sent the message on the origin chain\n   * @param originChainId id of the chain where the message originated\n   * @param delivered flag indicating if message has been delivered\n   * @param message bytes containing the necessary information to queue the bridged proposal id\n   * @param reason bytes with the revert information\n   */\n  event VoteMessageReceived(\n    address indexed originSender,\n    uint256 indexed originChainId,\n    bool indexed delivered,\n    bytes message,\n    bytes reason\n  );\n\n  /**\n   * @notice get the chain id where the voting machine which is deployed\n   * @return network id\n   */\n  function VOTING_MACHINE_CHAIN_ID() external view returns (uint256);\n\n  /**\n   * @notice gets the address of the voting machine on the destination network\n   * @return voting machine address\n   */\n  function VOTING_MACHINE() external view returns (address);\n\n  /**\n   * @notice gets the address of the connected governance\n   * @return governance address\n   */\n  function GOVERNANCE() external view returns (address);\n\n  /**\n   * @notice gets the address of the CrossChainController deployed on current network\n   * @return CrossChainController address\n   */\n  function CROSS_CHAIN_CONTROLLER() external view returns (address);\n\n  /**\n   * @notice method to set the gas limit for \"Start voting\" bridging tx\n   * @param gasLimit the new gas limit\n   */\n  function setStartVotingGasLimit(uint128 gasLimit) external;\n\n  /**\n   * @notice method to get the gas limit for \"Start voting\" bridging tx\n   * @return the gas limit\n   */\n  function getStartVotingGasLimit() external view returns (uint128);\n\n  /**\n   * @notice method to bridge the vote configuration to voting chain, so a vote can be started.\n   * @param proposalId id of the proposal bridged to start the vote on\n   * @param blockHash hash of the block on L1 when the proposal was activated for voting\n   * @param votingDuration duration in seconds of the vote\n   */\n  function forwardStartVotingMessage(\n    uint256 proposalId,\n    bytes32 blockHash,\n    uint24 votingDuration\n  ) external;\n\n  /**\n   * @notice method to decode a message from from voting machine chain\n   * @param message encoded message with message type\n   * @return proposalId, forVotes, againstVotes from the decoded message\n   */\n  function decodeMessage(\n    bytes memory message\n  ) external pure returns (uint256, uint128, uint128);\n}\n"}],"certified":false,"conflicting_implementations":null,"abi":[{"inputs":[{"internalType":"address","name":"crossChainController","type":"address"},{"internalType":"uint256","name":"coolDownPeriod","type":"uint256"},{"internalType":"address","name":"cancellationFeeCollector","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"proposalId","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"cancellationFee","type":"uint256"},{"indexed":true,"internalType":"bool","name":"success","type":"bool"}],"name":"CancellationFeeRedeemed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"cancellationFee","type":"uint256"}],"name":"CancellationFeeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"gasLimit","type":"uint256"}],"name":"GasLimitUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldGuardian","type":"address"},{"indexed":false,"internalType":"address","name":"newGuardian","type":"address"}],"name":"GuardianUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"proposalId","type":"uint256"},{"indexed":false,"internalType":"uint40","name":"payloadId","type":"uint40"},{"indexed":true,"internalType":"address","name":"payloadsController","type":"address"},{"indexed":true,"internalType":"uint256","name":"chainId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"payloadNumberOnProposal","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"numberOfPayloadsOnProposal","type":"uint256"}],"name":"PayloadSent","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newPowerStrategy","type":"address"}],"name":"PowerStrategyUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"proposalId","type":"uint256"}],"name":"ProposalCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"proposalId","type":"uint256"},{"indexed":true,"internalType":"address","name":"creator","type":"address"},{"indexed":true,"internalType":"enum PayloadsControllerUtils.AccessControl","name":"accessLevel","type":"uint8"},{"indexed":false,"internalType":"bytes32","name":"ipfsHash","type":"bytes32"}],"name":"ProposalCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"proposalId","type":"uint256"}],"name":"ProposalExecuted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"proposalId","type":"uint256"},{"indexed":false,"internalType":"uint128","name":"votesFor","type":"uint128"},{"indexed":false,"internalType":"uint128","name":"votesAgainst","type":"uint128"}],"name":"ProposalFailed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"proposalId","type":"uint256"},{"indexed":false,"internalType":"uint128","name":"votesFor","type":"uint128"},{"indexed":false,"internalType":"uint128","name":"votesAgainst","type":"uint128"}],"name":"ProposalQueued","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"voter","type":"address"},{"indexed":true,"internalType":"address","name":"representative","type":"address"},{"indexed":true,"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"RepresentativeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"proposalId","type":"uint256"},{"indexed":true,"internalType":"address","name":"voter","type":"address"},{"indexed":true,"internalType":"bool","name":"support","type":"bool"},{"components":[{"internalType":"address","name":"underlyingAsset","type":"address"},{"internalType":"uint128","name":"slot","type":"uint128"}],"indexed":false,"internalType":"struct IVotingMachineWithProofs.VotingAssetWithSlot[]","name":"votingAssetsWithSlot","type":"tuple[]"}],"name":"VoteForwarded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"proposalId","type":"uint256"},{"indexed":true,"internalType":"bytes32","name":"snapshotBlockHash","type":"bytes32"},{"indexed":false,"internalType":"uint24","name":"votingDuration","type":"uint24"}],"name":"VotingActivated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"enum PayloadsControllerUtils.AccessControl","name":"accessLevel","type":"uint8"},{"indexed":false,"internalType":"uint24","name":"votingDuration","type":"uint24"},{"indexed":false,"internalType":"uint24","name":"coolDownBeforeVotingStart","type":"uint24"},{"indexed":false,"internalType":"uint256","name":"yesThreshold","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"yesNoDifferential","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"minPropositionPower","type":"uint256"}],"name":"VotingConfigUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"votingPortal","type":"address"},{"indexed":true,"internalType":"bool","name":"approved","type":"bool"}],"name":"VotingPortalUpdated","type":"event"},{"inputs":[],"name":"ACHIEVABLE_VOTING_PARTICIPATION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CANCELLATION_FEE_COLLECTOR","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"COOLDOWN_PERIOD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CROSS_CHAIN_CONTROLLER","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_VOTING_DURATION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NAME","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PRECISION_DIVIDER","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PROPOSAL_EXPIRATION_TIME","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalId","type":"uint256"}],"name":"activateVoting","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"votingPortals","type":"address[]"}],"name":"addVotingPortals","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalId","type":"uint256"}],"name":"cancelProposal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"chain","type":"uint256"},{"internalType":"enum PayloadsControllerUtils.AccessControl","name":"accessLevel","type":"uint8"},{"internalType":"address","name":"payloadsController","type":"address"},{"internalType":"uint40","name":"payloadId","type":"uint40"}],"internalType":"struct PayloadsControllerUtils.Payload[]","name":"payloads","type":"tuple[]"},{"internalType":"address","name":"votingPortal","type":"address"},{"internalType":"bytes32","name":"ipfsHash","type":"bytes32"}],"name":"createProposal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalId","type":"uint256"}],"name":"executeProposal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getCancellationFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getGasLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPowerStrategy","outputs":[{"internalType":"contract IGovernancePowerStrategy","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalId","type":"uint256"}],"name":"getProposal","outputs":[{"components":[{"internalType":"enum IGovernanceCore.State","name":"state","type":"uint8"},{"internalType":"enum PayloadsControllerUtils.AccessControl","name":"accessLevel","type":"uint8"},{"internalType":"uint40","name":"creationTime","type":"uint40"},{"internalType":"uint24","name":"votingDuration","type":"uint24"},{"internalType":"uint40","name":"votingActivationTime","type":"uint40"},{"internalType":"uint40","name":"queuingTime","type":"uint40"},{"internalType":"uint40","name":"cancelTimestamp","type":"uint40"},{"internalType":"address","name":"creator","type":"address"},{"internalType":"address","name":"votingPortal","type":"address"},{"internalType":"bytes32","name":"snapshotBlockHash","type":"bytes32"},{"internalType":"bytes32","name":"ipfsHash","type":"bytes32"},{"internalType":"uint128","name":"forVotes","type":"uint128"},{"internalType":"uint128","name":"againstVotes","type":"uint128"},{"internalType":"uint256","name":"cancellationFee","type":"uint256"},{"components":[{"internalType":"uint256","name":"chain","type":"uint256"},{"internalType":"enum PayloadsControllerUtils.AccessControl","name":"accessLevel","type":"uint8"},{"internalType":"address","name":"payloadsController","type":"address"},{"internalType":"uint40","name":"payloadId","type":"uint40"}],"internalType":"struct PayloadsControllerUtils.Payload[]","name":"payloads","type":"tuple[]"}],"internalType":"struct IGovernanceCore.Proposal","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalId","type":"uint256"}],"name":"getProposalState","outputs":[{"internalType":"enum IGovernanceCore.State","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getProposalsCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"voter","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getRepresentativeByChain","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"representative","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getRepresentedVotersByChain","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"enum PayloadsControllerUtils.AccessControl","name":"accessLevel","type":"uint8"}],"name":"getVotingConfig","outputs":[{"components":[{"internalType":"uint24","name":"coolDownBeforeVotingStart","type":"uint24"},{"internalType":"uint24","name":"votingDuration","type":"uint24"},{"internalType":"uint56","name":"yesThreshold","type":"uint56"},{"internalType":"uint56","name":"yesNoDifferential","type":"uint56"},{"internalType":"uint56","name":"minPropositionPower","type":"uint56"}],"internalType":"struct IGovernanceCore.VotingConfig","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVotingPortalsCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"guardian","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"guardian","type":"address"},{"internalType":"contract IGovernancePowerStrategy","name":"powerStrategy","type":"address"},{"components":[{"internalType":"enum PayloadsControllerUtils.AccessControl","name":"accessLevel","type":"uint8"},{"internalType":"uint24","name":"coolDownBeforeVotingStart","type":"uint24"},{"internalType":"uint24","name":"votingDuration","type":"uint24"},{"internalType":"uint256","name":"yesThreshold","type":"uint256"},{"internalType":"uint256","name":"yesNoDifferential","type":"uint256"},{"internalType":"uint256","name":"minPropositionPower","type":"uint256"}],"internalType":"struct IGovernanceCore.SetVotingConfigInput[]","name":"votingConfigs","type":"tuple[]"},{"internalType":"address[]","name":"votingPortals","type":"address[]"},{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"uint256","name":"cancellationFee","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"gasLimit","type":"uint256"}],"name":"initializeWithRevision","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"votingPortal","type":"address"}],"name":"isVotingPortalApproved","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalId","type":"uint256"},{"internalType":"uint128","name":"forVotes","type":"uint128"},{"internalType":"uint128","name":"againstVotes","type":"uint128"}],"name":"queueProposal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"proposalIds","type":"uint256[]"}],"name":"redeemCancellationFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"votingPortals","type":"address[]"}],"name":"removeVotingPortals","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"votingPortal","type":"address"}],"name":"rescueVotingPortal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IGovernancePowerStrategy","name":"powerStrategy","type":"address"}],"name":"setPowerStrategy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"enum PayloadsControllerUtils.AccessControl","name":"accessLevel","type":"uint8"},{"internalType":"uint24","name":"coolDownBeforeVotingStart","type":"uint24"},{"internalType":"uint24","name":"votingDuration","type":"uint24"},{"internalType":"uint256","name":"yesThreshold","type":"uint256"},{"internalType":"uint256","name":"yesNoDifferential","type":"uint256"},{"internalType":"uint256","name":"minPropositionPower","type":"uint256"}],"internalType":"struct IGovernanceCore.SetVotingConfigInput[]","name":"votingConfigs","type":"tuple[]"}],"name":"setVotingConfigs","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"cancellationFee","type":"uint256"}],"name":"updateCancellationFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"gasLimit","type":"uint256"}],"name":"updateGasLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newGuardian","type":"address"}],"name":"updateGuardian","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"representative","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"internalType":"struct IGovernanceCore.RepresentativeInput[]","name":"representatives","type":"tuple[]"}],"name":"updateRepresentativesForChain","outputs":[],"stateMutability":"nonpayable","type":"function"}],"is_changed_bytecode":false,"is_partially_verified":false,"constructor_args":"000000000000000000000000ed42a7d8559a463722ca4bed50e0cc05a386b0e10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000464c71f6c2f760dda6093dcb91c24c39e5d6e18c"}