{"file_path":"contracts/morpho/MorphoAdapterV1_2.sol","creation_status":"success","source_code":"// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity ^0.8.20;\n\nimport {Math} from '@openzeppelin/contracts/utils/math/Math.sol';\n\nimport {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';\nimport {SafeERC20} from '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';\n\nimport {RewardDistributionV1, Stablecoin} from '../reward/RewardDistributionV1.sol';\n\nimport {IMetaMorphoV1_1} from './helpers/IMetaMorphoV1_1.sol';\n\n/**\n * @title MorphoAdapterV1_2\n * @author @samclassix <samclassix@proton.me>, @wrytlabs <wrytlabs@proton.me>\n * @notice This is an adapter for interacting with Morpho to mint liquidity straight into the market.\n */\ncontract MorphoAdapterV1_2 is RewardDistributionV1 {\n\tusing Math for uint256;\n\tusing SafeERC20 for Stablecoin;\n\tusing SafeERC20 for IMetaMorphoV1_1;\n\n\tIMetaMorphoV1_1 public immutable core;\n\n\tuint256 public totalMinted;\n\tuint256 public totalRevenue;\n\n\t// ---------------------------------------------------------------------------------------\n\n\tevent Deposit(uint256 amount, uint256 sharesCore, uint256 totalMinted);\n\tevent Redeem(uint256 amount, uint256 sharesCore, uint256 totalMinted);\n\tevent Revenue(uint256 amount, uint256 totalRevenue, uint256 totalMinted);\n\n\t// ---------------------------------------------------------------------------------------\n\n\terror NothingToReconcile(uint256 assets, uint256 minted);\n\n\t// ---------------------------------------------------------------------------------------\n\n\tconstructor(\n\t\tStablecoin _stable,\n\t\tIMetaMorphoV1_1 _core,\n\t\taddress[5] memory _receivers,\n\t\tuint32[5] memory _weights\n\t) RewardDistributionV1(_stable, _receivers, _weights) {\n\t\tcore = _core;\n\t}\n\n\t// ---------------------------------------------------------------------------------------\n\n\tfunction totalAssets() public view returns (uint256) {\n\t\t// this will use `_accruedFeeAndAssets`\n\t\treturn core.convertToAssets(core.balanceOf(address(this)));\n\t}\n\n\t// ---------------------------------------------------------------------------------------\n\n\tfunction deposit(uint256 amount) external onlyCurator {\n\t\t// mint stables\n\t\tstable.mintModule(address(this), amount);\n\t\ttotalMinted += amount;\n\n\t\t// approve stable for deposit into core vault\n\t\tstable.forceApprove(address(core), amount);\n\t\tuint256 sharesCore = core.deposit(amount, address(this));\n\n\t\temit Deposit(amount, sharesCore, totalMinted);\n\t}\n\n\t// ---------------------------------------------------------------------------------------\n\n\tfunction redeem(uint256 sharesCore) external onlyCurator {\n\t\t// reconcile, triggers `_accruedFeeAndAssets` in vault\n\t\t_reconcile(totalAssets(), true);\n\n\t\t// redeem core shares from core vault\n\t\tuint256 amount = core.redeem(sharesCore, address(this), address(this));\n\n\t\t// reduce minted amount\n\t\tif (totalMinted >= amount) {\n\t\t\tstable.burn(amount);\n\t\t\ttotalMinted -= amount;\n\t\t} else {\n\t\t\t// fallback, burn existing totalMinted if available\n\t\t\tif (totalMinted > 0) {\n\t\t\t\tstable.burn(totalMinted);\n\t\t\t\ttotalMinted = 0;\n\t\t\t}\n\n\t\t\t// fallback, distribute remaining balance\n\t\t\t_distribute();\n\t\t}\n\n\t\temit Redeem(amount, sharesCore, totalMinted);\n\t}\n\n\t// ---------------------------------------------------------------------------------------\n\n\tfunction reconcile() external {\n\t\t_reconcile(totalAssets(), false);\n\t}\n\n\tfunction _reconcile(uint256 assets, bool allowPassing) internal returns (uint256) {\n\t\tif (assets > totalMinted) {\n\t\t\t// calc revenue\n\t\t\tuint256 mintToReconcile = assets - totalMinted;\n\t\t\ttotalRevenue += mintToReconcile;\n\n\t\t\t// mint revenue to reconcile\n\t\t\tstable.mintModule(address(this), mintToReconcile);\n\t\t\ttotalMinted += mintToReconcile;\n\t\t\temit Revenue(mintToReconcile, totalRevenue, totalMinted);\n\n\t\t\t// distribute balance\n\t\t\t_distribute();\n\n\t\t\treturn mintToReconcile;\n\t\t} else {\n\t\t\tif (allowPassing) {\n\t\t\t\treturn 0;\n\t\t\t} else {\n\t\t\t\trevert NothingToReconcile(assets, totalMinted);\n\t\t\t}\n\t\t}\n\t}\n}\n","deployed_bytecode":"0x608060405234801561001057600080fd5b506004361061010b5760003560e01c8063a2309ff8116100a2578063bfd772fc11610071578063bfd772fc1461020b578063c5d3b7151461021e578063db006a7514610227578063ef4087a31461023a578063f2f4eb261461024257600080fd5b8063a2309ff8146101d3578063b5f163ff146101dc578063b6b55f25146101ef578063bf2d9e0b1461020257600080fd5b80633fdd9b82116100de5780633fdd9b82146101925780638338350a1461019a5780638f0d7e35146101c2578063926323d5146101ca57600080fd5b806301e1d11414610110578063206daf311461012b57806322be3de11461014057806329aa00251461017f575b600080fd5b610118610269565b6040519081526020015b60405180910390f35b61013e6101393660046114a8565b610360565b005b6101677f000000000000000000000000dde3ec717f220fc6a29d6a4be73f91da5b718e5581565b6040516001600160a01b039091168152602001610122565b61016761018d3660046114de565b610567565b61013e610587565b6101ad6101a83660046114de565b610668565b60405163ffffffff9091168152602001610122565b61013e610698565b61011860065481565b610118600e5481565b6101ad6101ea3660046114de565b6106aa565b61013e6101fd3660046114de565b6106ba565b610118600f5481565b6101676102193660046114de565b61090e565b610118600d5481565b61013e6102353660046114de565b61091e565b61013e610bcb565b6101677f000000000000000000000000ce22b5fb17ccbc0c5d87dc2e0df47dd71e3adc0a81565b6040516370a0823160e01b81523060048201526000907f000000000000000000000000ce22b5fb17ccbc0c5d87dc2e0df47dd71e3adc0a6001600160a01b0316906307a2d13a9082906370a0823190602401602060405180830381865afa1580156102d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102fc91906114f7565b6040518263ffffffff1660e01b815260040161031a91815260200190565b602060405180830381865afa158015610337573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061035b91906114f7565b905090565b6001600160a01b037f000000000000000000000000dde3ec717f220fc6a29d6a4be73f91da5b718e551663e1487a8c336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260240160006040518083038186803b1580156103cf57600080fd5b505afa1580156103e3573d6000803e3d6000fd5b50505050600d5460001461040a576040516324d9026760e11b815260040160405180910390fd5b6000546001600160a01b0316610471576040805160a081810190925261046d9184906005908390839080828437600092019190915250506040805160a0818101909252915084906005908390839080828437600092019190915250610cca915050565b5050565b61047e60078360056112ed565b5061048c600c826005611343565b507f000000000000000000000000dde3ec717f220fc6a29d6a4be73f91da5b718e556001600160a01b031663d33219b46040518163ffffffff1660e01b8152600401602060405180830381865afa1580156104eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061050f91906114f7565b610519904261153c565b600d55336001600160a01b03167f281992c4893624a98b0dd2363058366a77210bc570ab81a92f2fb5a9620fa9138383600d5460405161055b9392919061154f565b60405180910390a25050565b6007816005811061057757600080fd5b01546001600160a01b0316905081565b600d54806000036105ab5760405163e5f408a560e01b815260040160405180910390fd5b804210156105cc5760405163333bd2cb60e11b815260040160405180910390fd5b6040805160a08101918290526106659160079060059082845b81546001600160a01b031681526001909101906020018083116105e55750506040805160a08101918290529350600c925060059150826000855b82829054906101000a900463ffffffff1663ffffffff168152602001906004019060208260030104928301926001038202915080841161061f5790505050505050610cca565b50565b600c816005811061067857600080fd5b60089182820401919006600402915054906101000a900463ffffffff1681565b6106656106a3610269565b6000610dc9565b6005816005811061067857600080fd5b6001600160a01b037f000000000000000000000000dde3ec717f220fc6a29d6a4be73f91da5b718e551663e1487a8c336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260240160006040518083038186803b15801561072957600080fd5b505afa15801561073d573d6000803e3d6000fd5b5050604051631bf8922760e11b8152306004820152602481018490527f000000000000000000000000dde3ec717f220fc6a29d6a4be73f91da5b718e556001600160a01b031692506337f1244e9150604401600060405180830381600087803b1580156107a957600080fd5b505af11580156107bd573d6000803e3d6000fd5b5050505080600e60008282546107d3919061153c565b9091555061082d90506001600160a01b037f000000000000000000000000dde3ec717f220fc6a29d6a4be73f91da5b718e55167f000000000000000000000000ce22b5fb17ccbc0c5d87dc2e0df47dd71e3adc0a83610f2d565b604051636e553f6560e01b8152600481018290523060248201526000907f000000000000000000000000ce22b5fb17ccbc0c5d87dc2e0df47dd71e3adc0a6001600160a01b031690636e553f65906044016020604051808303816000875af115801561089d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108c191906114f7565b600e546040805185815260208101849052908101919091529091507f33da4f9b82b3e18a281ca2cabbe2f076925692abb593b7ea3f850009e8ec9770906060015b60405180910390a15050565b6000816005811061057757600080fd5b6001600160a01b037f000000000000000000000000dde3ec717f220fc6a29d6a4be73f91da5b718e551663e1487a8c336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260240160006040518083038186803b15801561098d57600080fd5b505afa1580156109a1573d6000803e3d6000fd5b505050506109b76109b0610269565b6001610dc9565b50604051635d043b2960e11b815260048101829052306024820181905260448201526000907f000000000000000000000000ce22b5fb17ccbc0c5d87dc2e0df47dd71e3adc0a6001600160a01b03169063ba087652906064016020604051808303816000875af1158015610a2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a5391906114f7565b905080600e5410610af557604051630852cd8d60e31b8152600481018290527f000000000000000000000000dde3ec717f220fc6a29d6a4be73f91da5b718e556001600160a01b0316906342966c6890602401600060405180830381600087803b158015610ac057600080fd5b505af1158015610ad4573d6000803e3d6000fd5b5050505080600e6000828254610aea91906115e1565b90915550610b899050565b600e5415610b8157600e54604051630852cd8d60e31b815260048101919091527f000000000000000000000000dde3ec717f220fc6a29d6a4be73f91da5b718e556001600160a01b0316906342966c6890602401600060405180830381600087803b158015610b6357600080fd5b505af1158015610b77573d6000803e3d6000fd5b50506000600e5550505b610b89610fe7565b600e546040805183815260208101859052908101919091527f70d4d13dc6a7ecab4daf04ef8818b27210ec56ba0fa05d767b00f95c3080df9190606001610902565b6001600160a01b037f000000000000000000000000dde3ec717f220fc6a29d6a4be73f91da5b718e551663d6900a54336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260240160006040518083038186803b158015610c3a57600080fd5b505afa158015610c4e573d6000803e3d6000fd5b50505050600d54600003610c755760405163e5f408a560e01b815260040160405180910390fd5b60405133907f0d77b8ec4f035b07683b8c222653c321da1049b00e82006b1190ee5d94bddfdf90600090a2610cc86000600781905560088190556009819055600a819055600b556000600c556000600d55565b565b600060068190555b60058163ffffffff161015610d5a5760008363ffffffff831660058110610cfb57610cfb611510565b60200201516001600160a01b031614610d4857818163ffffffff1660058110610d2657610d26611510565b602002015163ffffffff1660066000828254610d42919061153c565b90915550505b80610d52816115f4565b915050610cd2565b50610d6860008360056113e0565b50610d7560058281611428565b5060405133907ff085c57737528946971c505b4c9d6f7ca7ab5925b0cee78d8cb75797f36f362890600090a261046d6000600781905560088190556009819055600a819055600b556000600c556000600d55565b6000600e54831115610ee9576000600e5484610de591906115e1565b905080600f6000828254610df9919061153c565b9091555050604051631bf8922760e11b8152306004820152602481018290527f000000000000000000000000dde3ec717f220fc6a29d6a4be73f91da5b718e556001600160a01b0316906337f1244e90604401600060405180830381600087803b158015610e6657600080fd5b505af1158015610e7a573d6000803e3d6000fd5b5050505080600e6000828254610e90919061153c565b9091555050600f54600e546040805184815260208101939093528201527f704210ad0e772a9d53df2583519901ff427ae202d6faf3d36e4432740c7112449060600160405180910390a1610ee2610fe7565b9050610f27565b8115610ef757506000610f27565b600e5460405163454717e360e01b8152610f1e918591600401918252602082015260400190565b60405180910390fd5b92915050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052610f7e848261122d565b610fe157604080516001600160a01b038516602482015260006044808301919091528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052610fd790859061127c565b610fe1848261127c565b50505050565b6040516370a0823160e01b81523060048201526000907f000000000000000000000000dde3ec717f220fc6a29d6a4be73f91da5b718e556001600160a01b0316906370a0823190602401602060405180830381865afa15801561104e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061107291906114f7565b905060065460001480611083575080155b1561108b5750565b60005b600581101561046d5760008082600581106110ab576110ab611510565b01546001600160a01b0316905060006005838181106110cc576110cc611510565b60088104919091015460079091166004026101000a900463ffffffff1690506001600160a01b0382166110ff5750505050565b60065460009061110f8684611617565b611119919061162e565b60405163a9059cbb60e01b81526001600160a01b038581166004830152602482018390529192507f000000000000000000000000dde3ec717f220fc6a29d6a4be73f91da5b718e559091169063a9059cbb906044016020604051808303816000875af115801561118d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111b19190611650565b50826001600160a01b03167fa8ee3e5c0b1fd681042265199e8b28cf463b81bc21f6658d4c73e741aeabd3f58260065485670de0b6b3a76400006111f59190611617565b6111ff919061162e565b6040805192835260208301919091520160405180910390a2505050808061122590611679565b91505061108e565b6000806000806020600086516020880160008a5af192503d91506000519050828015611272575081156112635780600114611272565b6000866001600160a01b03163b115b9695505050505050565b600080602060008451602086016000885af18061129f576040513d6000823e3d81fd5b50506000513d915081156112b75780600114156112c4565b6001600160a01b0384163b155b15610fe157604051635274afe760e01b81526001600160a01b0385166004820152602401610f1e565b8260058101928215611333579160200282015b828111156113335781546001600160a01b0319166001600160a01b03843516178255602090920191600190910190611300565b5061133f929150611482565b5090565b6001830191839082156113335791602002820160005b838211156113a357833563ffffffff1683826101000a81548163ffffffff021916908363ffffffff1602179055509260200192600401602081600301049283019260010302611359565b80156113d35782816101000a81549063ffffffff02191690556004016020816003010492830192600103026113a3565b505061133f929150611482565b8260058101928215611333579160200282015b8281111561133357825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906113f3565b6001830191839082156113335791602002820160005b838211156113a357835183826101000a81548163ffffffff021916908363ffffffff160217905550926020019260040160208160030104928301926001030261143e565b5b8082111561133f5760008155600101611483565b8060a08101831015610f2757600080fd5b60008061014083850312156114bc57600080fd5b6114c68484611497565b91506114d58460a08501611497565b90509250929050565b6000602082840312156114f057600080fd5b5035919050565b60006020828403121561150957600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b80820180821115610f2757610f27611526565b6101608101818560005b60058110156115905781356001600160a01b03811680821461157a57600080fd5b8452506020928301929190910190600101611559565b50505060a082018460005b60058110156115cf57813563ffffffff81168082146115b957600080fd5b845250602092830192919091019060010161159b565b50505082610140830152949350505050565b81810381811115610f2757610f27611526565b600063ffffffff80831681810361160d5761160d611526565b6001019392505050565b8082028115828204841417610f2757610f27611526565b60008261164b57634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561166257600080fd5b8151801515811461167257600080fd5b9392505050565b60006001820161168b5761168b611526565b506001019056fea2646970667358221220beef017fa8af0f8612f445e0a0ba357db9cfcceb813a23206221147fa411843964736f6c63430008140033","optimization_enabled":true,"verified_twin_address_hash":null,"is_verified":true,"compiler_settings":{"evmVersion":"paris","libraries":{},"metadata":{"useLiteralContent":true},"optimizer":{"enabled":true,"runs":200},"outputSelection":{"*":{"":["*"],"*":["*"]}}},"optimization_runs":200,"sourcify_repo_url":null,"decoded_constructor_args":[["0xdde3eC717f220Fc6A29D6a4Be73F91DA5b718e55",{"internalType":"contract Stablecoin","name":"_stable","type":"address"}],["0xcE22b5Fb17ccbc0C5d87DC2e0dF47DD71E3AdC0a",{"internalType":"contract IMetaMorphoV1_1","name":"_core","type":"address"}],[["0x9fe66037c44236c87D9Ac8345F489b4413fDFf06","0x0000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000"],{"internalType":"address[5]","name":"_receivers","type":"address[5]"}],[["1000000","0","0","0","0"],{"internalType":"uint32[5]","name":"_weights","type":"uint32[5]"}]],"compiler_version":"v0.8.20+commit.a1b79de6","is_verified_via_verifier_alliance":false,"verified_at":"2026-08-06T12:41:56.721024Z","implementations":[],"proxy_type":null,"external_libraries":[],"creation_bytecode":"0x60c06040523480156200001157600080fd5b5060405162001bad38038062001bad8339810160408190526200003491620002dd565b6001600160a01b0384166080528382826200005082826200006b565b5050506001600160a01b0390921660a052506200044f915050565b600060068190555b60058163ffffffff161015620001085760008363ffffffff831660058110620000a057620000a0620003e1565b60200201516001600160a01b031614620000f357818163ffffffff1660058110620000cf57620000cf620003e1565b602002015163ffffffff1660066000828254620000ed91906200040d565b90915550505b80620000ff8162000429565b91505062000073565b5062000118600083600562000180565b506200012760058281620001dd565b5060405133907ff085c57737528946971c505b4c9d6f7ca7ab5925b0cee78d8cb75797f36f362890600090a26200017c6000600781905560088190556009819055600a819055600b556000600c556000600d55565b5050565b8260058101928215620001cb579160200282015b82811115620001cb57825182546001600160a01b0319166001600160a01b0390911617825560209092019160019091019062000194565b50620001d992915062000276565b5090565b600183019183908215620001cb5791602002820160005b838211156200023a57835183826101000a81548163ffffffff021916908363ffffffff1602179055509260200192600401602081600301049283019260010302620001f4565b80156200026c5782816101000a81549063ffffffff02191690556004016020816003010492830192600103026200023a565b5050620001d99291505b5b80821115620001d9576000815560010162000277565b6001600160a01b0381168114620002a357600080fd5b50565b60405160a081016001600160401b0381118282101715620002d757634e487b7160e01b600052604160045260246000fd5b60405290565b600080600080610180808688031215620002f657600080fd5b855162000303816200028d565b8095505060208087015162000318816200028d565b9450605f870188136200032a57600080fd5b62000334620002a6565b8060e089018a8111156200034757600080fd5b60408a015b818110156200037057805162000362816200028d565b84529284019284016200034c565b508196508a60ff8b01126200038457600080fd5b6200038e620002a6565b948a019492508291508a851115620003a557600080fd5b84811015620003d257805163ffffffff81168114620003c45760008081fd5b8352918301918301620003a5565b50969995985093965050505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b80820180821115620004235762000423620003f7565b92915050565b600063ffffffff808316818103620004455762000445620003f7565b6001019392505050565b60805160a0516116c8620004e56000396000818161024701528181610281015281816108080152818161084c01526109de0152600081816101450152818161036a0152818161048f015281816106c40152818161075b015281816107e60152818161092801528181610a7401528181610b1701528181610bd501528181610e1a01528181610fff015261114201526116c86000f3fe608060405234801561001057600080fd5b506004361061010b5760003560e01c8063a2309ff8116100a2578063bfd772fc11610071578063bfd772fc1461020b578063c5d3b7151461021e578063db006a7514610227578063ef4087a31461023a578063f2f4eb261461024257600080fd5b8063a2309ff8146101d3578063b5f163ff146101dc578063b6b55f25146101ef578063bf2d9e0b1461020257600080fd5b80633fdd9b82116100de5780633fdd9b82146101925780638338350a1461019a5780638f0d7e35146101c2578063926323d5146101ca57600080fd5b806301e1d11414610110578063206daf311461012b57806322be3de11461014057806329aa00251461017f575b600080fd5b610118610269565b6040519081526020015b60405180910390f35b61013e6101393660046114a8565b610360565b005b6101677f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610122565b61016761018d3660046114de565b610567565b61013e610587565b6101ad6101a83660046114de565b610668565b60405163ffffffff9091168152602001610122565b61013e610698565b61011860065481565b610118600e5481565b6101ad6101ea3660046114de565b6106aa565b61013e6101fd3660046114de565b6106ba565b610118600f5481565b6101676102193660046114de565b61090e565b610118600d5481565b61013e6102353660046114de565b61091e565b61013e610bcb565b6101677f000000000000000000000000000000000000000000000000000000000000000081565b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906307a2d13a9082906370a0823190602401602060405180830381865afa1580156102d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102fc91906114f7565b6040518263ffffffff1660e01b815260040161031a91815260200190565b602060405180830381865afa158015610337573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061035b91906114f7565b905090565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663e1487a8c336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260240160006040518083038186803b1580156103cf57600080fd5b505afa1580156103e3573d6000803e3d6000fd5b50505050600d5460001461040a576040516324d9026760e11b815260040160405180910390fd5b6000546001600160a01b0316610471576040805160a081810190925261046d9184906005908390839080828437600092019190915250506040805160a0818101909252915084906005908390839080828437600092019190915250610cca915050565b5050565b61047e60078360056112ed565b5061048c600c826005611343565b507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d33219b46040518163ffffffff1660e01b8152600401602060405180830381865afa1580156104eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061050f91906114f7565b610519904261153c565b600d55336001600160a01b03167f281992c4893624a98b0dd2363058366a77210bc570ab81a92f2fb5a9620fa9138383600d5460405161055b9392919061154f565b60405180910390a25050565b6007816005811061057757600080fd5b01546001600160a01b0316905081565b600d54806000036105ab5760405163e5f408a560e01b815260040160405180910390fd5b804210156105cc5760405163333bd2cb60e11b815260040160405180910390fd5b6040805160a08101918290526106659160079060059082845b81546001600160a01b031681526001909101906020018083116105e55750506040805160a08101918290529350600c925060059150826000855b82829054906101000a900463ffffffff1663ffffffff168152602001906004019060208260030104928301926001038202915080841161061f5790505050505050610cca565b50565b600c816005811061067857600080fd5b60089182820401919006600402915054906101000a900463ffffffff1681565b6106656106a3610269565b6000610dc9565b6005816005811061067857600080fd5b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663e1487a8c336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260240160006040518083038186803b15801561072957600080fd5b505afa15801561073d573d6000803e3d6000fd5b5050604051631bf8922760e11b8152306004820152602481018490527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031692506337f1244e9150604401600060405180830381600087803b1580156107a957600080fd5b505af11580156107bd573d6000803e3d6000fd5b5050505080600e60008282546107d3919061153c565b9091555061082d90506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000167f000000000000000000000000000000000000000000000000000000000000000083610f2d565b604051636e553f6560e01b8152600481018290523060248201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636e553f65906044016020604051808303816000875af115801561089d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108c191906114f7565b600e546040805185815260208101849052908101919091529091507f33da4f9b82b3e18a281ca2cabbe2f076925692abb593b7ea3f850009e8ec9770906060015b60405180910390a15050565b6000816005811061057757600080fd5b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663e1487a8c336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260240160006040518083038186803b15801561098d57600080fd5b505afa1580156109a1573d6000803e3d6000fd5b505050506109b76109b0610269565b6001610dc9565b50604051635d043b2960e11b815260048101829052306024820181905260448201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063ba087652906064016020604051808303816000875af1158015610a2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a5391906114f7565b905080600e5410610af557604051630852cd8d60e31b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906342966c6890602401600060405180830381600087803b158015610ac057600080fd5b505af1158015610ad4573d6000803e3d6000fd5b5050505080600e6000828254610aea91906115e1565b90915550610b899050565b600e5415610b8157600e54604051630852cd8d60e31b815260048101919091527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906342966c6890602401600060405180830381600087803b158015610b6357600080fd5b505af1158015610b77573d6000803e3d6000fd5b50506000600e5550505b610b89610fe7565b600e546040805183815260208101859052908101919091527f70d4d13dc6a7ecab4daf04ef8818b27210ec56ba0fa05d767b00f95c3080df9190606001610902565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663d6900a54336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260240160006040518083038186803b158015610c3a57600080fd5b505afa158015610c4e573d6000803e3d6000fd5b50505050600d54600003610c755760405163e5f408a560e01b815260040160405180910390fd5b60405133907f0d77b8ec4f035b07683b8c222653c321da1049b00e82006b1190ee5d94bddfdf90600090a2610cc86000600781905560088190556009819055600a819055600b556000600c556000600d55565b565b600060068190555b60058163ffffffff161015610d5a5760008363ffffffff831660058110610cfb57610cfb611510565b60200201516001600160a01b031614610d4857818163ffffffff1660058110610d2657610d26611510565b602002015163ffffffff1660066000828254610d42919061153c565b90915550505b80610d52816115f4565b915050610cd2565b50610d6860008360056113e0565b50610d7560058281611428565b5060405133907ff085c57737528946971c505b4c9d6f7ca7ab5925b0cee78d8cb75797f36f362890600090a261046d6000600781905560088190556009819055600a819055600b556000600c556000600d55565b6000600e54831115610ee9576000600e5484610de591906115e1565b905080600f6000828254610df9919061153c565b9091555050604051631bf8922760e11b8152306004820152602481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906337f1244e90604401600060405180830381600087803b158015610e6657600080fd5b505af1158015610e7a573d6000803e3d6000fd5b5050505080600e6000828254610e90919061153c565b9091555050600f54600e546040805184815260208101939093528201527f704210ad0e772a9d53df2583519901ff427ae202d6faf3d36e4432740c7112449060600160405180910390a1610ee2610fe7565b9050610f27565b8115610ef757506000610f27565b600e5460405163454717e360e01b8152610f1e918591600401918252602082015260400190565b60405180910390fd5b92915050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052610f7e848261122d565b610fe157604080516001600160a01b038516602482015260006044808301919091528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052610fd790859061127c565b610fe1848261127c565b50505050565b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa15801561104e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061107291906114f7565b905060065460001480611083575080155b1561108b5750565b60005b600581101561046d5760008082600581106110ab576110ab611510565b01546001600160a01b0316905060006005838181106110cc576110cc611510565b60088104919091015460079091166004026101000a900463ffffffff1690506001600160a01b0382166110ff5750505050565b60065460009061110f8684611617565b611119919061162e565b60405163a9059cbb60e01b81526001600160a01b038581166004830152602482018390529192507f00000000000000000000000000000000000000000000000000000000000000009091169063a9059cbb906044016020604051808303816000875af115801561118d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111b19190611650565b50826001600160a01b03167fa8ee3e5c0b1fd681042265199e8b28cf463b81bc21f6658d4c73e741aeabd3f58260065485670de0b6b3a76400006111f59190611617565b6111ff919061162e565b6040805192835260208301919091520160405180910390a2505050808061122590611679565b91505061108e565b6000806000806020600086516020880160008a5af192503d91506000519050828015611272575081156112635780600114611272565b6000866001600160a01b03163b115b9695505050505050565b600080602060008451602086016000885af18061129f576040513d6000823e3d81fd5b50506000513d915081156112b75780600114156112c4565b6001600160a01b0384163b155b15610fe157604051635274afe760e01b81526001600160a01b0385166004820152602401610f1e565b8260058101928215611333579160200282015b828111156113335781546001600160a01b0319166001600160a01b03843516178255602090920191600190910190611300565b5061133f929150611482565b5090565b6001830191839082156113335791602002820160005b838211156113a357833563ffffffff1683826101000a81548163ffffffff021916908363ffffffff1602179055509260200192600401602081600301049283019260010302611359565b80156113d35782816101000a81549063ffffffff02191690556004016020816003010492830192600103026113a3565b505061133f929150611482565b8260058101928215611333579160200282015b8281111561133357825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906113f3565b6001830191839082156113335791602002820160005b838211156113a357835183826101000a81548163ffffffff021916908363ffffffff160217905550926020019260040160208160030104928301926001030261143e565b5b8082111561133f5760008155600101611483565b8060a08101831015610f2757600080fd5b60008061014083850312156114bc57600080fd5b6114c68484611497565b91506114d58460a08501611497565b90509250929050565b6000602082840312156114f057600080fd5b5035919050565b60006020828403121561150957600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b80820180821115610f2757610f27611526565b6101608101818560005b60058110156115905781356001600160a01b03811680821461157a57600080fd5b8452506020928301929190910190600101611559565b50505060a082018460005b60058110156115cf57813563ffffffff81168082146115b957600080fd5b845250602092830192919091019060010161159b565b50505082610140830152949350505050565b81810381811115610f2757610f27611526565b600063ffffffff80831681810361160d5761160d611526565b6001019392505050565b8082028115828204841417610f2757610f27611526565b60008261164b57634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561166257600080fd5b8151801515811461167257600080fd5b9392505050565b60006001820161168b5761168b611526565b506001019056fea2646970667358221220beef017fa8af0f8612f445e0a0ba357db9cfcceb813a23206221147fa411843964736f6c63430008140033000000000000000000000000dde3ec717f220fc6a29d6a4be73f91da5b718e55000000000000000000000000ce22b5fb17ccbc0c5d87dc2e0df47dd71e3adc0a0000000000000000000000009fe66037c44236c87d9ac8345f489b4413fdff06000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f42400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","name":"MorphoAdapterV1_2","is_blueprint":false,"license_type":"none","is_fully_verified":true,"is_verified_via_eth_bytecode_db":false,"language":"solidity","evm_version":"paris","can_be_visualized_via_sol2uml":true,"is_verified_via_sourcify":false,"additional_sources":[{"file_path":"@openzeppelin/contracts/interfaces/IERC20.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../token/ERC20/IERC20.sol\";\n"},{"file_path":"@openzeppelin/contracts/utils/cryptography/EIP712.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/cryptography/EIP712.sol)\n\npragma solidity ^0.8.20;\n\nimport {MessageHashUtils} from \"./MessageHashUtils.sol\";\nimport {ShortStrings, ShortString} from \"../ShortStrings.sol\";\nimport {IERC5267} from \"../../interfaces/IERC5267.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP-712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose\n * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract\n * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to\n * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP-712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain\n * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the\n * separator from the immutable values, which is cheaper than accessing a cached version in cold storage.\n *\n * @custom:oz-upgrades-unsafe-allow state-variable-immutable\n */\nabstract contract EIP712 is IERC5267 {\n    using ShortStrings for *;\n\n    bytes32 private constant TYPE_HASH =\n        keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n    // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n    // invalidate the cached domain separator if the chain id changes.\n    bytes32 private immutable _cachedDomainSeparator;\n    uint256 private immutable _cachedChainId;\n    address private immutable _cachedThis;\n\n    bytes32 private immutable _hashedName;\n    bytes32 private immutable _hashedVersion;\n\n    ShortString private immutable _name;\n    ShortString private immutable _version;\n    string private _nameFallback;\n    string private _versionFallback;\n\n    /**\n     * @dev Initializes the domain separator and parameter caches.\n     *\n     * The meaning of `name` and `version` is specified in\n     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP-712]:\n     *\n     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n     * - `version`: the current major version of the signing domain.\n     *\n     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n     * contract upgrade].\n     */\n    constructor(string memory name, string memory version) {\n        _name = name.toShortStringWithFallback(_nameFallback);\n        _version = version.toShortStringWithFallback(_versionFallback);\n        _hashedName = keccak256(bytes(name));\n        _hashedVersion = keccak256(bytes(version));\n\n        _cachedChainId = block.chainid;\n        _cachedDomainSeparator = _buildDomainSeparator();\n        _cachedThis = address(this);\n    }\n\n    /**\n     * @dev Returns the domain separator for the current chain.\n     */\n    function _domainSeparatorV4() internal view returns (bytes32) {\n        if (address(this) == _cachedThis && block.chainid == _cachedChainId) {\n            return _cachedDomainSeparator;\n        } else {\n            return _buildDomainSeparator();\n        }\n    }\n\n    function _buildDomainSeparator() private view returns (bytes32) {\n        return keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this)));\n    }\n\n    /**\n     * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n     * function returns the hash of the fully encoded EIP712 message for this domain.\n     *\n     * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n     *\n     * ```solidity\n     * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n     *     keccak256(\"Mail(address to,string contents)\"),\n     *     mailTo,\n     *     keccak256(bytes(mailContents))\n     * )));\n     * address signer = ECDSA.recover(digest, signature);\n     * ```\n     */\n    function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n        return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash);\n    }\n\n    /**\n     * @dev See {IERC-5267}.\n     */\n    function eip712Domain()\n        public\n        view\n        virtual\n        returns (\n            bytes1 fields,\n            string memory name,\n            string memory version,\n            uint256 chainId,\n            address verifyingContract,\n            bytes32 salt,\n            uint256[] memory extensions\n        )\n    {\n        return (\n            hex\"0f\", // 01111\n            _EIP712Name(),\n            _EIP712Version(),\n            block.chainid,\n            address(this),\n            bytes32(0),\n            new uint256[](0)\n        );\n    }\n\n    /**\n     * @dev The name parameter for the EIP712 domain.\n     *\n     * NOTE: By default this function reads _name which is an immutable value.\n     * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function _EIP712Name() internal view returns (string memory) {\n        return _name.toStringWithFallback(_nameFallback);\n    }\n\n    /**\n     * @dev The version parameter for the EIP712 domain.\n     *\n     * NOTE: By default this function reads _version which is an immutable value.\n     * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function _EIP712Version() internal view returns (string memory) {\n        return _version.toStringWithFallback(_versionFallback);\n    }\n}\n"},{"file_path":"contracts/stablecoin/libraries/ErrorsLib.sol","source_code":"// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity ^0.8.20;\n\nlibrary ErrorsLib {\n\t/// @notice Thrown when the caller doesn't have the curator role.\n\terror NotCuratorRole(address account);\n\n\t/// @notice Thrown when the caller doesn't have the guardian role.\n\terror NotGuardianRole(address account);\n\n\t/// @notice Thrown when the caller doesn't have the curator nor the guardian role.\n\terror NotCuratorNorGuardianRole(address account);\n\n\terror NotModuleRole(address account);\n\n\terror NotValidModuleRole(address account);\n\n\t// ---------------------------------------------------------------------------------------\n\n\t/// @notice Thrown when there's no pending value to set.\n\terror NoPendingValue();\n\n\t/// @notice Thrown when the value is already set.\n\terror AlreadySet();\n\n\t/// @notice Thrown when a value is already pending.\n\terror AlreadyPending();\n\n\t// ---------------------------------------------------------------------------------------\n\n\t/// @notice Thrown when the submitted timelock is above the max timelock.\n\terror AboveMaxTimelock();\n\n\t/// @notice Thrown when the submitted timelock is below the min timelock.\n\terror BelowMinTimelock();\n\n\t/// @notice Thrown when the timelock is not elapsed.\n\terror TimelockNotElapsed();\n\n\t// ---------------------------------------------------------------------------------------\n\n\terror ProposalFeeToLow(uint256 minimum);\n\n\terror AccountFreezed(address account, uint256 since);\n}\n"},{"file_path":"@openzeppelin/contracts/utils/Address.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/Address.sol)\n\npragma solidity ^0.8.20;\n\nimport {Errors} from \"./Errors.sol\";\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n    /**\n     * @dev There's no code at `target` (it is not a contract).\n     */\n    error AddressEmptyCode(address target);\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://consensys.net/diligence/blog/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.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        if (address(this).balance < amount) {\n            revert Errors.InsufficientBalance(address(this).balance, amount);\n        }\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        if (!success) {\n            revert Errors.FailedCall();\n        }\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 or custom error, it is bubbled\n     * up by this function (like regular Solidity function calls). However, if\n     * the call reverted with no returned reason, this function reverts with a\n     * {Errors.FailedCall} error.\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    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0);\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    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n        if (address(this).balance < value) {\n            revert Errors.InsufficientBalance(address(this).balance, value);\n        }\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResultFromTarget(target, success, returndata);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResultFromTarget(target, success, returndata);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResultFromTarget(target, success, returndata);\n    }\n\n    /**\n     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n     * was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case\n     * of an unsuccessful call.\n     */\n    function verifyCallResultFromTarget(\n        address target,\n        bool success,\n        bytes memory returndata\n    ) internal view returns (bytes memory) {\n        if (!success) {\n            _revert(returndata);\n        } else {\n            // only check if target is a contract if the call was successful and the return data is empty\n            // otherwise we already know that it was a contract\n            if (returndata.length == 0 && target.code.length == 0) {\n                revert AddressEmptyCode(target);\n            }\n            return returndata;\n        }\n    }\n\n    /**\n     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n     * revert reason or with a default {Errors.FailedCall} error.\n     */\n    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n        if (!success) {\n            _revert(returndata);\n        } else {\n            return returndata;\n        }\n    }\n\n    /**\n     * @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}.\n     */\n    function _revert(bytes memory returndata) 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            assembly (\"memory-safe\") {\n                let returndata_size := mload(returndata)\n                revert(add(32, returndata), returndata_size)\n            }\n        } else {\n            revert Errors.FailedCall();\n        }\n    }\n}\n"},{"file_path":"@openzeppelin/contracts/interfaces/IERC5267.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol)\n\npragma solidity ^0.8.20;\n\ninterface IERC5267 {\n    /**\n     * @dev MAY be emitted to signal that the domain could have changed.\n     */\n    event EIP712DomainChanged();\n\n    /**\n     * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712\n     * signature.\n     */\n    function eip712Domain()\n        external\n        view\n        returns (\n            bytes1 fields,\n            string memory name,\n            string memory version,\n            uint256 chainId,\n            address verifyingContract,\n            bytes32 salt,\n            uint256[] memory extensions\n        );\n}\n"},{"file_path":"@openzeppelin/contracts/utils/cryptography/ECDSA.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n    enum RecoverError {\n        NoError,\n        InvalidSignature,\n        InvalidSignatureLength,\n        InvalidSignatureS\n    }\n\n    /**\n     * @dev The signature derives the `address(0)`.\n     */\n    error ECDSAInvalidSignature();\n\n    /**\n     * @dev The signature has an invalid length.\n     */\n    error ECDSAInvalidSignatureLength(uint256 length);\n\n    /**\n     * @dev The signature has an S value that is in the upper half order.\n     */\n    error ECDSAInvalidSignatureS(bytes32 s);\n\n    /**\n     * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not\n     * return address(0) without also returning an error description. Errors are documented using an enum (error type)\n     * and a bytes32 providing additional information about the error.\n     *\n     * If no error is returned, then the address can be used for verification purposes.\n     *\n     * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n     * this function rejects them by requiring the `s` value to be in the lower\n     * half order, and the `v` value to be either 27 or 28.\n     *\n     * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n     * verification to be secure: it is possible to craft signatures that\n     * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n     * this is by receiving a hash of the original message (which may otherwise\n     * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n     *\n     * Documentation for signature generation:\n     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n     */\n    function tryRecover(\n        bytes32 hash,\n        bytes memory signature\n    ) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {\n        if (signature.length == 65) {\n            bytes32 r;\n            bytes32 s;\n            uint8 v;\n            // ecrecover takes the signature parameters, and the only way to get them\n            // currently is to use assembly.\n            assembly (\"memory-safe\") {\n                r := mload(add(signature, 0x20))\n                s := mload(add(signature, 0x40))\n                v := byte(0, mload(add(signature, 0x60)))\n            }\n            return tryRecover(hash, v, r, s);\n        } else {\n            return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));\n        }\n    }\n\n    /**\n     * @dev Returns the address that signed a hashed message (`hash`) with\n     * `signature`. This address can then be used for verification purposes.\n     *\n     * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n     * this function rejects them by requiring the `s` value to be in the lower\n     * half order, and the `v` value to be either 27 or 28.\n     *\n     * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n     * verification to be secure: it is possible to craft signatures that\n     * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n     * this is by receiving a hash of the original message (which may otherwise\n     * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n     */\n    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);\n        _throwError(error, errorArg);\n        return recovered;\n    }\n\n    /**\n     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n     *\n     * See https://eips.ethereum.org/EIPS/eip-2098[ERC-2098 short signatures]\n     */\n    function tryRecover(\n        bytes32 hash,\n        bytes32 r,\n        bytes32 vs\n    ) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {\n        unchecked {\n            bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n            // We do not check for an overflow here since the shift operation results in 0 or 1.\n            uint8 v = uint8((uint256(vs) >> 255) + 27);\n            return tryRecover(hash, v, r, s);\n        }\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n     */\n    function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {\n        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);\n        _throwError(error, errorArg);\n        return recovered;\n    }\n\n    /**\n     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     */\n    function tryRecover(\n        bytes32 hash,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {\n        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n        // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n        //\n        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n        // these malleable signatures as well.\n        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n            return (address(0), RecoverError.InvalidSignatureS, s);\n        }\n\n        // If the signature is valid (and not malleable), return the signer address\n        address signer = ecrecover(hash, v, r, s);\n        if (signer == address(0)) {\n            return (address(0), RecoverError.InvalidSignature, bytes32(0));\n        }\n\n        return (signer, RecoverError.NoError, bytes32(0));\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     */\n    function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\n        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);\n        _throwError(error, errorArg);\n        return recovered;\n    }\n\n    /**\n     * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.\n     */\n    function _throwError(RecoverError error, bytes32 errorArg) private pure {\n        if (error == RecoverError.NoError) {\n            return; // no error: do nothing\n        } else if (error == RecoverError.InvalidSignature) {\n            revert ECDSAInvalidSignature();\n        } else if (error == RecoverError.InvalidSignatureLength) {\n            revert ECDSAInvalidSignatureLength(uint256(errorArg));\n        } else if (error == RecoverError.InvalidSignatureS) {\n            revert ECDSAInvalidSignatureS(errorArg);\n        }\n    }\n}\n"},{"file_path":"@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/ERC20Permit.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20Permit} from \"./IERC20Permit.sol\";\nimport {ERC20} from \"../ERC20.sol\";\nimport {ECDSA} from \"../../../utils/cryptography/ECDSA.sol\";\nimport {EIP712} from \"../../../utils/cryptography/EIP712.sol\";\nimport {Nonces} from \"../../../utils/Nonces.sol\";\n\n/**\n * @dev Implementation of the ERC-20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[ERC-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC-20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\nabstract contract ERC20Permit is ERC20, IERC20Permit, EIP712, Nonces {\n    bytes32 private constant PERMIT_TYPEHASH =\n        keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n\n    /**\n     * @dev Permit deadline has expired.\n     */\n    error ERC2612ExpiredSignature(uint256 deadline);\n\n    /**\n     * @dev Mismatched signature.\n     */\n    error ERC2612InvalidSigner(address signer, address owner);\n\n    /**\n     * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n     *\n     * It's a good idea to use the same `name` that is defined as the ERC-20 token name.\n     */\n    constructor(string memory name) EIP712(name, \"1\") {}\n\n    /**\n     * @inheritdoc IERC20Permit\n     */\n    function permit(\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) public virtual {\n        if (block.timestamp > deadline) {\n            revert ERC2612ExpiredSignature(deadline);\n        }\n\n        bytes32 structHash = keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n        bytes32 hash = _hashTypedDataV4(structHash);\n\n        address signer = ECDSA.recover(hash, v, r, s);\n        if (signer != owner) {\n            revert ERC2612InvalidSigner(signer, owner);\n        }\n\n        _approve(owner, spender, value);\n    }\n\n    /**\n     * @inheritdoc IERC20Permit\n     */\n    function nonces(address owner) public view virtual override(IERC20Permit, Nonces) returns (uint256) {\n        return super.nonces(owner);\n    }\n\n    /**\n     * @inheritdoc IERC20Permit\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function DOMAIN_SEPARATOR() external view virtual returns (bytes32) {\n        return _domainSeparatorV4();\n    }\n}\n"},{"file_path":"@openzeppelin/contracts/interfaces/IERC1363Receiver.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363Receiver.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @title IERC1363Receiver\n * @dev Interface for any contract that wants to support `transferAndCall` or `transferFromAndCall`\n * from ERC-1363 token contracts.\n */\ninterface IERC1363Receiver {\n    /**\n     * @dev Whenever ERC-1363 tokens are transferred to this contract via `transferAndCall` or `transferFromAndCall`\n     * by `operator` from `from`, this function is called.\n     *\n     * NOTE: To accept the transfer, this must return\n     * `bytes4(keccak256(\"onTransferReceived(address,address,uint256,bytes)\"))`\n     * (i.e. 0x88a7ca5c, or its own function selector).\n     *\n     * @param operator The address which called `transferAndCall` or `transferFromAndCall` function.\n     * @param from The address which the tokens are transferred from.\n     * @param value The amount of tokens transferred.\n     * @param data Additional data with no specified format.\n     * @return `bytes4(keccak256(\"onTransferReceived(address,address,uint256,bytes)\"))` if transfer is allowed unless throwing.\n     */\n    function onTransferReceived(\n        address operator,\n        address from,\n        uint256 value,\n        bytes calldata data\n    ) external returns (bytes4);\n}\n"},{"file_path":"@openzeppelin/contracts/utils/math/SafeCast.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX/bool 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 */\nlibrary SafeCast {\n    /**\n     * @dev Value doesn't fit in an uint of `bits` size.\n     */\n    error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);\n\n    /**\n     * @dev An int value doesn't fit in an uint of `bits` size.\n     */\n    error SafeCastOverflowedIntToUint(int256 value);\n\n    /**\n     * @dev Value doesn't fit in an int of `bits` size.\n     */\n    error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);\n\n    /**\n     * @dev An uint value doesn't fit in an int of `bits` size.\n     */\n    error SafeCastOverflowedUintToInt(uint256 value);\n\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    function toUint248(uint256 value) internal pure returns (uint248) {\n        if (value > type(uint248).max) {\n            revert SafeCastOverflowedUintDowncast(248, value);\n        }\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    function toUint240(uint256 value) internal pure returns (uint240) {\n        if (value > type(uint240).max) {\n            revert SafeCastOverflowedUintDowncast(240, value);\n        }\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    function toUint232(uint256 value) internal pure returns (uint232) {\n        if (value > type(uint232).max) {\n            revert SafeCastOverflowedUintDowncast(232, value);\n        }\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    function toUint224(uint256 value) internal pure returns (uint224) {\n        if (value > type(uint224).max) {\n            revert SafeCastOverflowedUintDowncast(224, value);\n        }\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    function toUint216(uint256 value) internal pure returns (uint216) {\n        if (value > type(uint216).max) {\n            revert SafeCastOverflowedUintDowncast(216, value);\n        }\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    function toUint208(uint256 value) internal pure returns (uint208) {\n        if (value > type(uint208).max) {\n            revert SafeCastOverflowedUintDowncast(208, value);\n        }\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    function toUint200(uint256 value) internal pure returns (uint200) {\n        if (value > type(uint200).max) {\n            revert SafeCastOverflowedUintDowncast(200, value);\n        }\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    function toUint192(uint256 value) internal pure returns (uint192) {\n        if (value > type(uint192).max) {\n            revert SafeCastOverflowedUintDowncast(192, value);\n        }\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    function toUint184(uint256 value) internal pure returns (uint184) {\n        if (value > type(uint184).max) {\n            revert SafeCastOverflowedUintDowncast(184, value);\n        }\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    function toUint176(uint256 value) internal pure returns (uint176) {\n        if (value > type(uint176).max) {\n            revert SafeCastOverflowedUintDowncast(176, value);\n        }\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    function toUint168(uint256 value) internal pure returns (uint168) {\n        if (value > type(uint168).max) {\n            revert SafeCastOverflowedUintDowncast(168, value);\n        }\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    function toUint160(uint256 value) internal pure returns (uint160) {\n        if (value > type(uint160).max) {\n            revert SafeCastOverflowedUintDowncast(160, value);\n        }\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    function toUint152(uint256 value) internal pure returns (uint152) {\n        if (value > type(uint152).max) {\n            revert SafeCastOverflowedUintDowncast(152, value);\n        }\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    function toUint144(uint256 value) internal pure returns (uint144) {\n        if (value > type(uint144).max) {\n            revert SafeCastOverflowedUintDowncast(144, value);\n        }\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    function toUint136(uint256 value) internal pure returns (uint136) {\n        if (value > type(uint136).max) {\n            revert SafeCastOverflowedUintDowncast(136, value);\n        }\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    function toUint128(uint256 value) internal pure returns (uint128) {\n        if (value > type(uint128).max) {\n            revert SafeCastOverflowedUintDowncast(128, value);\n        }\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    function toUint120(uint256 value) internal pure returns (uint120) {\n        if (value > type(uint120).max) {\n            revert SafeCastOverflowedUintDowncast(120, value);\n        }\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    function toUint112(uint256 value) internal pure returns (uint112) {\n        if (value > type(uint112).max) {\n            revert SafeCastOverflowedUintDowncast(112, value);\n        }\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    function toUint104(uint256 value) internal pure returns (uint104) {\n        if (value > type(uint104).max) {\n            revert SafeCastOverflowedUintDowncast(104, value);\n        }\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    function toUint96(uint256 value) internal pure returns (uint96) {\n        if (value > type(uint96).max) {\n            revert SafeCastOverflowedUintDowncast(96, value);\n        }\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    function toUint88(uint256 value) internal pure returns (uint88) {\n        if (value > type(uint88).max) {\n            revert SafeCastOverflowedUintDowncast(88, value);\n        }\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    function toUint80(uint256 value) internal pure returns (uint80) {\n        if (value > type(uint80).max) {\n            revert SafeCastOverflowedUintDowncast(80, value);\n        }\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    function toUint72(uint256 value) internal pure returns (uint72) {\n        if (value > type(uint72).max) {\n            revert SafeCastOverflowedUintDowncast(72, value);\n        }\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    function toUint64(uint256 value) internal pure returns (uint64) {\n        if (value > type(uint64).max) {\n            revert SafeCastOverflowedUintDowncast(64, value);\n        }\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    function toUint56(uint256 value) internal pure returns (uint56) {\n        if (value > type(uint56).max) {\n            revert SafeCastOverflowedUintDowncast(56, value);\n        }\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    function toUint48(uint256 value) internal pure returns (uint48) {\n        if (value > type(uint48).max) {\n            revert SafeCastOverflowedUintDowncast(48, value);\n        }\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    function toUint40(uint256 value) internal pure returns (uint40) {\n        if (value > type(uint40).max) {\n            revert SafeCastOverflowedUintDowncast(40, value);\n        }\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    function toUint32(uint256 value) internal pure returns (uint32) {\n        if (value > type(uint32).max) {\n            revert SafeCastOverflowedUintDowncast(32, value);\n        }\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    function toUint24(uint256 value) internal pure returns (uint24) {\n        if (value > type(uint24).max) {\n            revert SafeCastOverflowedUintDowncast(24, value);\n        }\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    function toUint16(uint256 value) internal pure returns (uint16) {\n        if (value > type(uint16).max) {\n            revert SafeCastOverflowedUintDowncast(16, value);\n        }\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    function toUint8(uint256 value) internal pure returns (uint8) {\n        if (value > type(uint8).max) {\n            revert SafeCastOverflowedUintDowncast(8, value);\n        }\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    function toUint256(int256 value) internal pure returns (uint256) {\n        if (value < 0) {\n            revert SafeCastOverflowedIntToUint(value);\n        }\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    function toInt248(int256 value) internal pure returns (int248 downcasted) {\n        downcasted = int248(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(248, value);\n        }\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    function toInt240(int256 value) internal pure returns (int240 downcasted) {\n        downcasted = int240(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(240, value);\n        }\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    function toInt232(int256 value) internal pure returns (int232 downcasted) {\n        downcasted = int232(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(232, value);\n        }\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    function toInt224(int256 value) internal pure returns (int224 downcasted) {\n        downcasted = int224(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(224, value);\n        }\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    function toInt216(int256 value) internal pure returns (int216 downcasted) {\n        downcasted = int216(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(216, value);\n        }\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    function toInt208(int256 value) internal pure returns (int208 downcasted) {\n        downcasted = int208(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(208, value);\n        }\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    function toInt200(int256 value) internal pure returns (int200 downcasted) {\n        downcasted = int200(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(200, value);\n        }\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    function toInt192(int256 value) internal pure returns (int192 downcasted) {\n        downcasted = int192(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(192, value);\n        }\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    function toInt184(int256 value) internal pure returns (int184 downcasted) {\n        downcasted = int184(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(184, value);\n        }\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    function toInt176(int256 value) internal pure returns (int176 downcasted) {\n        downcasted = int176(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(176, value);\n        }\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    function toInt168(int256 value) internal pure returns (int168 downcasted) {\n        downcasted = int168(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(168, value);\n        }\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    function toInt160(int256 value) internal pure returns (int160 downcasted) {\n        downcasted = int160(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(160, value);\n        }\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    function toInt152(int256 value) internal pure returns (int152 downcasted) {\n        downcasted = int152(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(152, value);\n        }\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    function toInt144(int256 value) internal pure returns (int144 downcasted) {\n        downcasted = int144(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(144, value);\n        }\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    function toInt136(int256 value) internal pure returns (int136 downcasted) {\n        downcasted = int136(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(136, value);\n        }\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    function toInt128(int256 value) internal pure returns (int128 downcasted) {\n        downcasted = int128(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(128, value);\n        }\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    function toInt120(int256 value) internal pure returns (int120 downcasted) {\n        downcasted = int120(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(120, value);\n        }\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    function toInt112(int256 value) internal pure returns (int112 downcasted) {\n        downcasted = int112(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(112, value);\n        }\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    function toInt104(int256 value) internal pure returns (int104 downcasted) {\n        downcasted = int104(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(104, value);\n        }\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    function toInt96(int256 value) internal pure returns (int96 downcasted) {\n        downcasted = int96(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(96, value);\n        }\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    function toInt88(int256 value) internal pure returns (int88 downcasted) {\n        downcasted = int88(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(88, value);\n        }\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    function toInt80(int256 value) internal pure returns (int80 downcasted) {\n        downcasted = int80(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(80, value);\n        }\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    function toInt72(int256 value) internal pure returns (int72 downcasted) {\n        downcasted = int72(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(72, value);\n        }\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    function toInt64(int256 value) internal pure returns (int64 downcasted) {\n        downcasted = int64(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(64, value);\n        }\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    function toInt56(int256 value) internal pure returns (int56 downcasted) {\n        downcasted = int56(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(56, value);\n        }\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    function toInt48(int256 value) internal pure returns (int48 downcasted) {\n        downcasted = int48(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(48, value);\n        }\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    function toInt40(int256 value) internal pure returns (int40 downcasted) {\n        downcasted = int40(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(40, value);\n        }\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    function toInt32(int256 value) internal pure returns (int32 downcasted) {\n        downcasted = int32(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(32, value);\n        }\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    function toInt24(int256 value) internal pure returns (int24 downcasted) {\n        downcasted = int24(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(24, value);\n        }\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    function toInt16(int256 value) internal pure returns (int16 downcasted) {\n        downcasted = int16(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(16, value);\n        }\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    function toInt8(int256 value) internal pure returns (int8 downcasted) {\n        downcasted = int8(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(8, value);\n        }\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    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        if (value > uint256(type(int256).max)) {\n            revert SafeCastOverflowedUintToInt(value);\n        }\n        return int256(value);\n    }\n\n    /**\n     * @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.\n     */\n    function toUint(bool b) internal pure returns (uint256 u) {\n        assembly (\"memory-safe\") {\n            u := iszero(iszero(b))\n        }\n    }\n}\n"},{"file_path":"@openzeppelin/contracts/token/ERC20/ERC20.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"./IERC20.sol\";\nimport {IERC20Metadata} from \"./extensions/IERC20Metadata.sol\";\nimport {Context} from \"../../utils/Context.sol\";\nimport {IERC20Errors} from \"../../interfaces/draft-IERC6093.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * The default value of {decimals} is 18. To change this, you should override\n * this function so it returns a different value.\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC-20\n * applications.\n */\nabstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {\n    mapping(address account => uint256) private _balances;\n\n    mapping(address account => mapping(address spender => uint256)) private _allowances;\n\n    uint256 private _totalSupply;\n\n    string private _name;\n    string private _symbol;\n\n    /**\n     * @dev Sets the values for {name} and {symbol}.\n     *\n     * All two of these values are immutable: they can only be set once during\n     * construction.\n     */\n    constructor(string memory name_, string memory symbol_) {\n        _name = name_;\n        _symbol = symbol_;\n    }\n\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() public view virtual returns (string memory) {\n        return _name;\n    }\n\n    /**\n     * @dev Returns the symbol of the token, usually a shorter version of the\n     * name.\n     */\n    function symbol() public view virtual returns (string memory) {\n        return _symbol;\n    }\n\n    /**\n     * @dev Returns the number of decimals used to get its user representation.\n     * For example, if `decimals` equals `2`, a balance of `505` tokens should\n     * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n     *\n     * Tokens usually opt for a value of 18, imitating the relationship between\n     * Ether and Wei. This is the default value returned by this function, unless\n     * it's overridden.\n     *\n     * NOTE: This information is only used for _display_ purposes: it in\n     * no way affects any of the arithmetic of the contract, including\n     * {IERC20-balanceOf} and {IERC20-transfer}.\n     */\n    function decimals() public view virtual returns (uint8) {\n        return 18;\n    }\n\n    /**\n     * @dev See {IERC20-totalSupply}.\n     */\n    function totalSupply() public view virtual returns (uint256) {\n        return _totalSupply;\n    }\n\n    /**\n     * @dev See {IERC20-balanceOf}.\n     */\n    function balanceOf(address account) public view virtual returns (uint256) {\n        return _balances[account];\n    }\n\n    /**\n     * @dev See {IERC20-transfer}.\n     *\n     * Requirements:\n     *\n     * - `to` cannot be the zero address.\n     * - the caller must have a balance of at least `value`.\n     */\n    function transfer(address to, uint256 value) public virtual returns (bool) {\n        address owner = _msgSender();\n        _transfer(owner, to, value);\n        return true;\n    }\n\n    /**\n     * @dev See {IERC20-allowance}.\n     */\n    function allowance(address owner, address spender) public view virtual returns (uint256) {\n        return _allowances[owner][spender];\n    }\n\n    /**\n     * @dev See {IERC20-approve}.\n     *\n     * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on\n     * `transferFrom`. This is semantically equivalent to an infinite approval.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     */\n    function approve(address spender, uint256 value) public virtual returns (bool) {\n        address owner = _msgSender();\n        _approve(owner, spender, value);\n        return true;\n    }\n\n    /**\n     * @dev See {IERC20-transferFrom}.\n     *\n     * Skips emitting an {Approval} event indicating an allowance update. This is not\n     * required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve].\n     *\n     * NOTE: Does not update the allowance if the current allowance\n     * is the maximum `uint256`.\n     *\n     * Requirements:\n     *\n     * - `from` and `to` cannot be the zero address.\n     * - `from` must have a balance of at least `value`.\n     * - the caller must have allowance for ``from``'s tokens of at least\n     * `value`.\n     */\n    function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {\n        address spender = _msgSender();\n        _spendAllowance(from, spender, value);\n        _transfer(from, to, value);\n        return true;\n    }\n\n    /**\n     * @dev Moves a `value` amount of tokens from `from` to `to`.\n     *\n     * This internal function is equivalent to {transfer}, and can be used to\n     * e.g. implement automatic token fees, slashing mechanisms, etc.\n     *\n     * Emits a {Transfer} event.\n     *\n     * NOTE: This function is not virtual, {_update} should be overridden instead.\n     */\n    function _transfer(address from, address to, uint256 value) internal {\n        if (from == address(0)) {\n            revert ERC20InvalidSender(address(0));\n        }\n        if (to == address(0)) {\n            revert ERC20InvalidReceiver(address(0));\n        }\n        _update(from, to, value);\n    }\n\n    /**\n     * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`\n     * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding\n     * this function.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _update(address from, address to, uint256 value) internal virtual {\n        if (from == address(0)) {\n            // Overflow check required: The rest of the code assumes that totalSupply never overflows\n            _totalSupply += value;\n        } else {\n            uint256 fromBalance = _balances[from];\n            if (fromBalance < value) {\n                revert ERC20InsufficientBalance(from, fromBalance, value);\n            }\n            unchecked {\n                // Overflow not possible: value <= fromBalance <= totalSupply.\n                _balances[from] = fromBalance - value;\n            }\n        }\n\n        if (to == address(0)) {\n            unchecked {\n                // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.\n                _totalSupply -= value;\n            }\n        } else {\n            unchecked {\n                // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.\n                _balances[to] += value;\n            }\n        }\n\n        emit Transfer(from, to, value);\n    }\n\n    /**\n     * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).\n     * Relies on the `_update` mechanism\n     *\n     * Emits a {Transfer} event with `from` set to the zero address.\n     *\n     * NOTE: This function is not virtual, {_update} should be overridden instead.\n     */\n    function _mint(address account, uint256 value) internal {\n        if (account == address(0)) {\n            revert ERC20InvalidReceiver(address(0));\n        }\n        _update(address(0), account, value);\n    }\n\n    /**\n     * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.\n     * Relies on the `_update` mechanism.\n     *\n     * Emits a {Transfer} event with `to` set to the zero address.\n     *\n     * NOTE: This function is not virtual, {_update} should be overridden instead\n     */\n    function _burn(address account, uint256 value) internal {\n        if (account == address(0)) {\n            revert ERC20InvalidSender(address(0));\n        }\n        _update(account, address(0), value);\n    }\n\n    /**\n     * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.\n     *\n     * This internal function is equivalent to `approve`, and can be used to\n     * e.g. set automatic allowances for certain subsystems, etc.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `owner` cannot be the zero address.\n     * - `spender` cannot be the zero address.\n     *\n     * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.\n     */\n    function _approve(address owner, address spender, uint256 value) internal {\n        _approve(owner, spender, value, true);\n    }\n\n    /**\n     * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.\n     *\n     * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by\n     * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any\n     * `Approval` event during `transferFrom` operations.\n     *\n     * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to\n     * true using the following override:\n     *\n     * ```solidity\n     * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {\n     *     super._approve(owner, spender, value, true);\n     * }\n     * ```\n     *\n     * Requirements are the same as {_approve}.\n     */\n    function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {\n        if (owner == address(0)) {\n            revert ERC20InvalidApprover(address(0));\n        }\n        if (spender == address(0)) {\n            revert ERC20InvalidSpender(address(0));\n        }\n        _allowances[owner][spender] = value;\n        if (emitEvent) {\n            emit Approval(owner, spender, value);\n        }\n    }\n\n    /**\n     * @dev Updates `owner` s allowance for `spender` based on spent `value`.\n     *\n     * Does not update the allowance value in case of infinite allowance.\n     * Revert if not enough allowance is available.\n     *\n     * Does not emit an {Approval} event.\n     */\n    function _spendAllowance(address owner, address spender, uint256 value) internal virtual {\n        uint256 currentAllowance = allowance(owner, spender);\n        if (currentAllowance != type(uint256).max) {\n            if (currentAllowance < value) {\n                revert ERC20InsufficientAllowance(spender, currentAllowance, value);\n            }\n            unchecked {\n                _approve(owner, spender, currentAllowance - value, false);\n            }\n        }\n    }\n}\n"},{"file_path":"@openzeppelin/contracts/utils/Errors.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Collection of common custom errors used in multiple contracts\n *\n * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.\n * It is recommended to avoid relying on the error API for critical functionality.\n *\n * _Available since v5.1._\n */\nlibrary Errors {\n    /**\n     * @dev The ETH balance of the account is not enough to perform the operation.\n     */\n    error InsufficientBalance(uint256 balance, uint256 needed);\n\n    /**\n     * @dev A call to an address target failed. The target may have reverted.\n     */\n    error FailedCall();\n\n    /**\n     * @dev The deployment failed.\n     */\n    error FailedDeployment();\n\n    /**\n     * @dev A necessary precompile is missing.\n     */\n    error MissingPrecompile(address);\n}\n"},{"file_path":"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../IERC20.sol\";\nimport {IERC1363} from \"../../../interfaces/IERC1363.sol\";\nimport {Address} from \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC-20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n    /**\n     * @dev An operation with an ERC-20 token failed.\n     */\n    error SafeERC20FailedOperation(address token);\n\n    /**\n     * @dev Indicates a failed `decreaseAllowance` request.\n     */\n    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);\n\n    /**\n     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeTransfer(IERC20 token, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));\n    }\n\n    /**\n     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n     */\n    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));\n    }\n\n    /**\n     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     *\n     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the \"client\"\n     * smart contract uses ERC-7674 to set temporary allowances, then the \"client\" smart contract should avoid using\n     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract\n     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.\n     */\n    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n        uint256 oldAllowance = token.allowance(address(this), spender);\n        forceApprove(token, spender, oldAllowance + value);\n    }\n\n    /**\n     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no\n     * value, non-reverting calls are assumed to be successful.\n     *\n     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the \"client\"\n     * smart contract uses ERC-7674 to set temporary allowances, then the \"client\" smart contract should avoid using\n     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract\n     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.\n     */\n    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {\n        unchecked {\n            uint256 currentAllowance = token.allowance(address(this), spender);\n            if (currentAllowance < requestedDecrease) {\n                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);\n            }\n            forceApprove(token, spender, currentAllowance - requestedDecrease);\n        }\n    }\n\n    /**\n     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n     * to be set to zero before setting it to a non-zero value, such as USDT.\n     *\n     * NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function\n     * only sets the \"standard\" allowance. Any temporary allowance will remain active, in addition to the value being\n     * set here.\n     */\n    function forceApprove(IERC20 token, address spender, uint256 value) internal {\n        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));\n\n        if (!_callOptionalReturnBool(token, approvalCall)) {\n            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));\n            _callOptionalReturn(token, approvalCall);\n        }\n    }\n\n    /**\n     * @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no\n     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when\n     * targeting contracts.\n     *\n     * Reverts if the returned value is other than `true`.\n     */\n    function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {\n        if (to.code.length == 0) {\n            safeTransfer(token, to, value);\n        } else if (!token.transferAndCall(to, value, data)) {\n            revert SafeERC20FailedOperation(address(token));\n        }\n    }\n\n    /**\n     * @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target\n     * has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when\n     * targeting contracts.\n     *\n     * Reverts if the returned value is other than `true`.\n     */\n    function transferFromAndCallRelaxed(\n        IERC1363 token,\n        address from,\n        address to,\n        uint256 value,\n        bytes memory data\n    ) internal {\n        if (to.code.length == 0) {\n            safeTransferFrom(token, from, to, value);\n        } else if (!token.transferFromAndCall(from, to, value, data)) {\n            revert SafeERC20FailedOperation(address(token));\n        }\n    }\n\n    /**\n     * @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no\n     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when\n     * targeting contracts.\n     *\n     * NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.\n     * Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}\n     * once without retrying, and relies on the returned value to be true.\n     *\n     * Reverts if the returned value is other than `true`.\n     */\n    function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {\n        if (to.code.length == 0) {\n            forceApprove(token, to, value);\n        } else if (!token.approveAndCall(to, value, data)) {\n            revert SafeERC20FailedOperation(address(token));\n        }\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     *\n     * This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.\n     */\n    function _callOptionalReturn(IERC20 token, bytes memory data) private {\n        uint256 returnSize;\n        uint256 returnValue;\n        assembly (\"memory-safe\") {\n            let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)\n            // bubble errors\n            if iszero(success) {\n                let ptr := mload(0x40)\n                returndatacopy(ptr, 0, returndatasize())\n                revert(ptr, returndatasize())\n            }\n            returnSize := returndatasize()\n            returnValue := mload(0)\n        }\n\n        if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {\n            revert SafeERC20FailedOperation(address(token));\n        }\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     *\n     * This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.\n     */\n    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\n        bool success;\n        uint256 returnSize;\n        uint256 returnValue;\n        assembly (\"memory-safe\") {\n            success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)\n            returnSize := returndatasize()\n            returnValue := mload(0)\n        }\n        return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);\n    }\n}\n"},{"file_path":"contracts/stablecoin/Stablecoin.sol","source_code":"// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity ^0.8.20;\n\nimport {Math} from '@openzeppelin/contracts/utils/math/Math.sol';\n\nimport {ERC20} from '@openzeppelin/contracts/token/ERC20/ERC20.sol';\nimport {SafeERC20} from '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';\nimport {ERC20Permit} from '@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol';\nimport {ERC1363} from '@openzeppelin/contracts/token/ERC20/extensions/ERC1363.sol';\n\nimport {ConstantsLib} from './libraries/ConstantsLib.sol';\nimport {ErrorsLib} from './libraries/ErrorsLib.sol';\nimport {EventsLib} from './libraries/EventsLib.sol';\nimport {PendingLib, PendingUint192, PendingAddress} from './libraries/PendingLib.sol';\n\nimport {IStablecoin, IERC20} from './IStablecoin.sol';\n\n/// @title Stablecoin\n/// @author @samclassix <samclassix@proton.me>, @wrytlabs <wrytlabs@proton.me>\n/// @notice A stablecoin implementation built on top of Morpho, utilizing a role-based access control system\n/// with curator and guardian roles for secure management and governance.\ncontract Stablecoin is IStablecoin, ERC20, ERC20Permit, ERC1363 {\n\tusing Math for uint256;\n\tusing SafeERC20 for ERC20;\n\tusing PendingLib for PendingUint192;\n\tusing PendingLib for PendingAddress;\n\n\taddress public curator;\n\tPendingAddress public pendingCurator;\n\n\taddress public guardian;\n\tPendingAddress public pendingGuardian;\n\n\tuint256 public timelock;\n\tPendingUint192 public pendingTimelock;\n\n\tmapping(address module => uint256) public modules;\n\tmapping(address module => PendingUint192) public pendingModules;\n\n\tmapping(address account => uint256) public unfreeze;\n\tmapping(address account => PendingUint192) public pendingUnfreeze;\n\n\t// ---------------------------------------------------------------------------------------\n\n\tmodifier onlyCurator() {\n\t\tverifyCurator(_msgSender());\n\t\t_;\n\t}\n\n\tmodifier onlyGuardian() {\n\t\tverifyGuardian(_msgSender());\n\t\t_;\n\t}\n\n\tmodifier onlyCuratorOrGuardian() {\n\t\tverifyCuratorOrGuardian(_msgSender());\n\t\t_;\n\t}\n\n\tmodifier onlyModule() {\n\t\tverifyModule(_msgSender());\n\t\t_;\n\t}\n\n\tmodifier validModule() {\n\t\tverifyValidModule(_msgSender());\n\t\t_;\n\t}\n\n\tmodifier afterTimelock(uint256 validAt) {\n\t\tif (validAt == 0) revert ErrorsLib.NoPendingValue();\n\t\tif (block.timestamp < validAt) revert ErrorsLib.TimelockNotElapsed();\n\t\t_;\n\t}\n\n\tmodifier claimPublicFee(uint256 fee, uint256 min) {\n\t\tif (fee < min) revert ErrorsLib.ProposalFeeToLow(min);\n\t\t_transfer(_msgSender(), curator, fee);\n\t\t_;\n\t}\n\n\t// ---------------------------------------------------------------------------------------\n\n\tconstructor(string memory _name, string memory _symbol, address _curator) ERC20(_name, _symbol) ERC20Permit(_name) {\n\t\tcurator = _curator;\n\t}\n\n\t// ---------------------------------------------------------------------------------------\n\n\tfunction supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n\t\treturn\n\t\t\tinterfaceId == type(IERC20).interfaceId ||\n\t\t\tinterfaceId == type(ERC20Permit).interfaceId ||\n\t\t\tinterfaceId == type(IStablecoin).interfaceId ||\n\t\t\tsuper.supportsInterface(interfaceId);\n\t}\n\n\t// ---------------------------------------------------------------------------------------\n\t// check role functions with public visibility\n\n\t/// @inheritdoc IStablecoin\n\tfunction checkCurator(address account) public view returns (bool) {\n\t\treturn account == curator;\n\t}\n\n\t/// @inheritdoc IStablecoin\n\tfunction checkGuardian(address account) public view returns (bool) {\n\t\treturn account == guardian;\n\t}\n\n\t/// @inheritdoc IStablecoin\n\tfunction checkCuratorOrGuardian(address account) public view returns (bool) {\n\t\treturn (account == curator || account == guardian);\n\t}\n\n\t/// @inheritdoc IStablecoin\n\tfunction checkModule(address account) public view returns (bool) {\n\t\treturn modules[account] != 0;\n\t}\n\n\t/// @inheritdoc IStablecoin\n\tfunction checkValidModule(address account) public view returns (bool) {\n\t\treturn modules[account] > block.timestamp;\n\t}\n\n\t// ---------------------------------------------------------------------------------------\n\t// verify role functions with public visibility\n\n\t/// @inheritdoc IStablecoin\n\tfunction verifyCurator(address account) public view {\n\t\tif (checkCurator(account) == false) revert ErrorsLib.NotCuratorRole(account);\n\t}\n\n\t/// @inheritdoc IStablecoin\n\tfunction verifyGuardian(address account) public view {\n\t\tif (checkGuardian(account) == false) revert ErrorsLib.NotGuardianRole(account);\n\t}\n\n\t/// @inheritdoc IStablecoin\n\tfunction verifyCuratorOrGuardian(address account) public view {\n\t\tif (checkCuratorOrGuardian(account) == false) revert ErrorsLib.NotCuratorNorGuardianRole(account);\n\t}\n\n\t/// @inheritdoc IStablecoin\n\tfunction verifyModule(address account) public view {\n\t\tif (checkModule(account) == false) revert ErrorsLib.NotModuleRole(account);\n\t}\n\n\t/// @inheritdoc IStablecoin\n\tfunction verifyValidModule(address account) public view {\n\t\tif (checkValidModule(account) == false) revert ErrorsLib.NotValidModuleRole(account);\n\t}\n\n\t// ---------------------------------------------------------------------------------------\n\t// allowance and update ERC20 modifications\n\n\t/// @inheritdoc ERC20\n\tfunction allowance(address owner, address spender) public view virtual override(ERC20, IERC20) returns (uint256) {\n\t\tif (checkValidModule(_msgSender())) return type(uint256).max;\n\t\treturn super.allowance(owner, spender);\n\t}\n\n\t/// @inheritdoc ERC20\n\tfunction _update(address from, address to, uint256 value) internal virtual override {\n\t\tuint256 since = unfreeze[from];\n\t\tif (since != 0 && since <= block.timestamp) revert ErrorsLib.AccountFreezed(from, since);\n\t\tsuper._update(from, to, value);\n\t}\n\n\t// ---------------------------------------------------------------------------------------\n\t// allow minting modules to mint and burnFrom. allow anyone to burn tokens\n\n\t/// @inheritdoc IStablecoin\n\tfunction mintModule(address to, uint256 value) external validModule {\n\t\t_mint(to, value);\n\t}\n\n\t/// @inheritdoc IStablecoin\n\tfunction burnModule(address from, uint256 amount) external onlyModule {\n\t\t_burn(from, amount);\n\t}\n\n\t/// @inheritdoc IStablecoin\n\tfunction burn(uint256 amount) external {\n\t\t_burn(_msgSender(), amount);\n\t}\n\n\t// ---------------------------------------------------------------------------------------\n\t// curator management\n\n\t/// @inheritdoc IStablecoin\n\tfunction setCurator(address newCurator) external onlyCurator {\n\t\tif (curator == newCurator) revert ErrorsLib.AlreadySet();\n\t\tif (pendingCurator.validAt != 0) revert ErrorsLib.AlreadyPending();\n\t\tpendingCurator.update(newCurator, timelock);\n\t\temit EventsLib.SubmitCurator(_msgSender(), newCurator, timelock);\n\t}\n\n\t/// @inheritdoc IStablecoin\n\tfunction setCuratorPublic(address newCurator, uint256 fee) external claimPublicFee(fee, ConstantsLib.PUBLIC_FEE * 10) {\n\t\tif (curator == newCurator) revert ErrorsLib.AlreadySet();\n\t\tif (pendingCurator.validAt != 0) revert ErrorsLib.AlreadyPending();\n\t\tpendingCurator.update(newCurator, timelock * 2);\n\t\temit EventsLib.SubmitCurator(_msgSender(), newCurator, timelock * 2);\n\t}\n\n\t/// @inheritdoc IStablecoin\n\tfunction revokePendingCurator() external onlyCuratorOrGuardian {\n\t\tif (pendingCurator.validAt == 0) revert ErrorsLib.NoPendingValue();\n\t\temit EventsLib.RevokePendingCurator(_msgSender(), pendingCurator.value);\n\t\tdelete pendingCurator;\n\t}\n\n\t/// @inheritdoc IStablecoin\n\tfunction acceptCurator() external afterTimelock(pendingCurator.validAt) {\n\t\tif (pendingCurator.value != _msgSender()) revert ErrorsLib.NotCuratorRole(_msgSender());\n\t\tcurator = pendingCurator.value;\n\t\temit EventsLib.SetCurator(_msgSender(), curator);\n\t\tdelete pendingCurator;\n\t}\n\n\t// ---------------------------------------------------------------------------------------\n\t// guardian management\n\n\t/// @inheritdoc IStablecoin\n\tfunction setGuardian(address newGuardian) external onlyCurator {\n\t\tif (guardian == newGuardian) revert ErrorsLib.AlreadySet();\n\t\tif (pendingGuardian.validAt != 0) revert ErrorsLib.AlreadyPending();\n\n\t\tif (guardian == address(0)) {\n\t\t\t_setGuardian(newGuardian);\n\t\t} else {\n\t\t\tpendingGuardian.update(newGuardian, timelock);\n\t\t\temit EventsLib.SubmitGuardian(_msgSender(), newGuardian, timelock);\n\t\t}\n\t}\n\n\t/// @inheritdoc IStablecoin\n\tfunction revokePendingGuardian() external onlyCuratorOrGuardian {\n\t\tif (pendingGuardian.validAt == 0) revert ErrorsLib.NoPendingValue();\n\t\temit EventsLib.RevokePendingGuardian(_msgSender(), pendingGuardian.value);\n\t\tdelete pendingGuardian;\n\t}\n\n\t/// @inheritdoc IStablecoin\n\tfunction acceptGuardian() external afterTimelock(pendingGuardian.validAt) {\n\t\t_setGuardian(pendingGuardian.value);\n\t}\n\n\tfunction _setGuardian(address newGuardian) internal {\n\t\tguardian = newGuardian;\n\t\temit EventsLib.SetGuardian(_msgSender(), guardian);\n\t\tdelete pendingGuardian;\n\t}\n\n\t// ---------------------------------------------------------------------------------------\n\t// timelock management\n\n\t/// @inheritdoc IStablecoin\n\tfunction setTimelock(uint256 newTimelock) external onlyCurator {\n\t\tif (timelock == newTimelock) revert ErrorsLib.AlreadySet();\n\t\tif (pendingTimelock.validAt != 0) revert ErrorsLib.AlreadyPending();\n\t\t_checkTimelockBounds(newTimelock);\n\n\t\tif (newTimelock > timelock) {\n\t\t\t_setTimelock(newTimelock);\n\t\t} else {\n\t\t\t// Safe \"unchecked\" cast because newTimelock <= MAX_TIMELOCK.\n\t\t\tpendingTimelock.update(uint184(newTimelock), timelock);\n\t\t\temit EventsLib.SubmitTimelock(_msgSender(), newTimelock, timelock);\n\t\t}\n\t}\n\n\t/// @inheritdoc IStablecoin\n\tfunction revokePendingTimelock() external onlyCuratorOrGuardian {\n\t\tif (pendingTimelock.validAt == 0) revert ErrorsLib.NoPendingValue();\n\t\temit EventsLib.RevokePendingTimelock(_msgSender(), pendingTimelock.value);\n\t\tdelete pendingTimelock;\n\t}\n\n\t/// @inheritdoc IStablecoin\n\tfunction acceptTimelock() external afterTimelock(pendingTimelock.validAt) {\n\t\t_setTimelock(pendingTimelock.value);\n\t}\n\n\t/// @dev Reverts if `newTimelock` is not within the bounds.\n\tfunction _checkTimelockBounds(uint256 newTimelock) internal pure {\n\t\tif (newTimelock > ConstantsLib.MAX_TIMELOCK) revert ErrorsLib.AboveMaxTimelock();\n\t\tif (newTimelock < ConstantsLib.MIN_TIMELOCK) revert ErrorsLib.BelowMinTimelock();\n\t}\n\n\t/// @dev Sets `timelock` to `newTimelock`.\n\tfunction _setTimelock(uint256 newTimelock) internal {\n\t\ttimelock = newTimelock;\n\t\temit EventsLib.SetTimelock(_msgSender(), newTimelock);\n\t\tdelete pendingTimelock;\n\t}\n\n\t// ---------------------------------------------------------------------------------------\n\t// module managment\n\n\t/// @inheritdoc IStablecoin\n\tfunction setModule(address module, uint256 expiredAt, string calldata message) external onlyCurator {\n\t\tif (modules[module] == expiredAt) revert ErrorsLib.AlreadySet();\n\t\tif (pendingModules[module].validAt != 0) revert ErrorsLib.AlreadyPending();\n\n\t\tif (totalSupply() == 0) {\n\t\t\t_setModule(module, expiredAt);\n\t\t} else {\n\t\t\tpendingModules[module].update(uint184(expiredAt), timelock);\n\t\t\temit EventsLib.SubmitModule(_msgSender(), module, expiredAt, message, timelock);\n\t\t}\n\t}\n\n\t/// @inheritdoc IStablecoin\n\tfunction setModulePublic(address module, uint256 expiredAt, string calldata message, uint256 fee) external claimPublicFee(fee, ConstantsLib.PUBLIC_FEE) {\n\t\tif (modules[module] == expiredAt) revert ErrorsLib.AlreadySet();\n\t\tif (pendingModules[module].validAt != 0) revert ErrorsLib.AlreadyPending();\n\n\t\tpendingModules[module].update(uint184(expiredAt), timelock * 2);\n\t\temit EventsLib.SubmitModule(_msgSender(), module, expiredAt, message, timelock * 2);\n\t}\n\n\t/// @inheritdoc IStablecoin\n\tfunction revokePendingModule(address module, string calldata message) external onlyCuratorOrGuardian {\n\t\tif (pendingModules[module].validAt == 0) revert ErrorsLib.NoPendingValue();\n\t\temit EventsLib.RevokePendingModule(_msgSender(), module, message);\n\t\tdelete pendingModules[module];\n\t}\n\n\t/// @inheritdoc IStablecoin\n\tfunction acceptModule(address module) external afterTimelock(pendingModules[module].validAt) {\n\t\t_setModule(module, pendingModules[module].value);\n\t}\n\n\tfunction _setModule(address module, uint256 expiredAt) internal {\n\t\tmodules[module] = expiredAt;\n\t\temit EventsLib.SetModule(_msgSender(), module);\n\t\tdelete pendingModules[module];\n\t}\n\n\t// ---------------------------------------------------------------------------------------\n\t// account freeze and unfreeze management\n\n\t/// @inheritdoc IStablecoin\n\tfunction setFreeze(address account, string calldata message) external onlyCurator {\n\t\tif (unfreeze[account] != 0) revert ErrorsLib.AlreadySet();\n\t\tunfreeze[account] = block.timestamp;\n\t\temit EventsLib.SetFreeze(_msgSender(), account, message);\n\t}\n\n\t// ---------------------------------------------------------------------------------------\n\n\t/// @inheritdoc IStablecoin\n\tfunction setUnfreeze(address account, string calldata message) external onlyCuratorOrGuardian {\n\t\tif (unfreeze[account] == 0) revert ErrorsLib.AlreadySet();\n\t\tif (pendingUnfreeze[account].validAt != 0) revert ErrorsLib.AlreadyPending();\n\n\t\tpendingUnfreeze[account].update(uint184(0), timelock * 2);\n\t\temit EventsLib.SubmitUnfreeze(_msgSender(), account, message, timelock * 2);\n\t}\n\n\t/// @inheritdoc IStablecoin\n\tfunction revokePendingUnfreeze(address account, string calldata message) external onlyCuratorOrGuardian {\n\t\tif (pendingUnfreeze[account].validAt == 0) revert ErrorsLib.NoPendingValue();\n\t\temit EventsLib.RevokeUnfreeze(_msgSender(), account, message);\n\t\tdelete pendingUnfreeze[account];\n\t}\n\n\t/// @inheritdoc IStablecoin\n\tfunction acceptUnfreeze(address account) external afterTimelock(pendingUnfreeze[account].validAt) {\n\t\tunfreeze[account] = 0;\n\t\temit EventsLib.SetUnfreeze(_msgSender(), account);\n\t\tdelete pendingUnfreeze[account];\n\t}\n}\n"},{"file_path":"@openzeppelin/contracts/utils/ShortStrings.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/ShortStrings.sol)\n\npragma solidity ^0.8.20;\n\nimport {StorageSlot} from \"./StorageSlot.sol\";\n\n// | string  | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA   |\n// | length  | 0x                                                              BB |\ntype ShortString is bytes32;\n\n/**\n * @dev This library provides functions to convert short memory strings\n * into a `ShortString` type that can be used as an immutable variable.\n *\n * Strings of arbitrary length can be optimized using this library if\n * they are short enough (up to 31 bytes) by packing them with their\n * length (1 byte) in a single EVM word (32 bytes). Additionally, a\n * fallback mechanism can be used for every other case.\n *\n * Usage example:\n *\n * ```solidity\n * contract Named {\n *     using ShortStrings for *;\n *\n *     ShortString private immutable _name;\n *     string private _nameFallback;\n *\n *     constructor(string memory contractName) {\n *         _name = contractName.toShortStringWithFallback(_nameFallback);\n *     }\n *\n *     function name() external view returns (string memory) {\n *         return _name.toStringWithFallback(_nameFallback);\n *     }\n * }\n * ```\n */\nlibrary ShortStrings {\n    // Used as an identifier for strings longer than 31 bytes.\n    bytes32 private constant FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;\n\n    error StringTooLong(string str);\n    error InvalidShortString();\n\n    /**\n     * @dev Encode a string of at most 31 chars into a `ShortString`.\n     *\n     * This will trigger a `StringTooLong` error is the input string is too long.\n     */\n    function toShortString(string memory str) internal pure returns (ShortString) {\n        bytes memory bstr = bytes(str);\n        if (bstr.length > 31) {\n            revert StringTooLong(str);\n        }\n        return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));\n    }\n\n    /**\n     * @dev Decode a `ShortString` back to a \"normal\" string.\n     */\n    function toString(ShortString sstr) internal pure returns (string memory) {\n        uint256 len = byteLength(sstr);\n        // using `new string(len)` would work locally but is not memory safe.\n        string memory str = new string(32);\n        assembly (\"memory-safe\") {\n            mstore(str, len)\n            mstore(add(str, 0x20), sstr)\n        }\n        return str;\n    }\n\n    /**\n     * @dev Return the length of a `ShortString`.\n     */\n    function byteLength(ShortString sstr) internal pure returns (uint256) {\n        uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;\n        if (result > 31) {\n            revert InvalidShortString();\n        }\n        return result;\n    }\n\n    /**\n     * @dev Encode a string into a `ShortString`, or write it to storage if it is too long.\n     */\n    function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) {\n        if (bytes(value).length < 32) {\n            return toShortString(value);\n        } else {\n            StorageSlot.getStringSlot(store).value = value;\n            return ShortString.wrap(FALLBACK_SENTINEL);\n        }\n    }\n\n    /**\n     * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}.\n     */\n    function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {\n        if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {\n            return toString(value);\n        } else {\n            return store;\n        }\n    }\n\n    /**\n     * @dev Return the length of a string that was encoded to `ShortString` or written to storage using\n     * {setWithFallback}.\n     *\n     * WARNING: This will return the \"byte length\" of the string. This may not reflect the actual length in terms of\n     * actual characters as the UTF-8 encoding of a single character can span over multiple bytes.\n     */\n    function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {\n        if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {\n            return byteLength(value);\n        } else {\n            return bytes(store).length;\n        }\n    }\n}\n"},{"file_path":"@openzeppelin/contracts/interfaces/IERC1363Spender.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363Spender.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @title IERC1363Spender\n * @dev Interface for any contract that wants to support `approveAndCall`\n * from ERC-1363 token contracts.\n */\ninterface IERC1363Spender {\n    /**\n     * @dev Whenever an ERC-1363 token `owner` approves this contract via `approveAndCall`\n     * to spend their tokens, this function is called.\n     *\n     * NOTE: To accept the approval, this must return\n     * `bytes4(keccak256(\"onApprovalReceived(address,uint256,bytes)\"))`\n     * (i.e. 0x7b04a2d0, or its own function selector).\n     *\n     * @param owner The address which called `approveAndCall` function and previously owned the tokens.\n     * @param value The amount of tokens to be spent.\n     * @param data Additional data with no specified format.\n     * @return `bytes4(keccak256(\"onApprovalReceived(address,uint256,bytes)\"))` if approval is allowed unless throwing.\n     */\n    function onApprovalReceived(address owner, uint256 value, bytes calldata data) external returns (bytes4);\n}\n"},{"file_path":"@openzeppelin/contracts/utils/introspection/ERC165.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n        return interfaceId == type(IERC165).interfaceId;\n    }\n}\n"},{"file_path":"@openzeppelin/contracts/interfaces/IERC1363.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"./IERC20.sol\";\nimport {IERC165} from \"./IERC165.sol\";\n\n/**\n * @title IERC1363\n * @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].\n *\n * Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract\n * after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.\n */\ninterface IERC1363 is IERC20, IERC165 {\n    /*\n     * Note: the ERC-165 identifier for this interface is 0xb0202a11.\n     * 0xb0202a11 ===\n     *   bytes4(keccak256('transferAndCall(address,uint256)')) ^\n     *   bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^\n     *   bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^\n     *   bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^\n     *   bytes4(keccak256('approveAndCall(address,uint256)')) ^\n     *   bytes4(keccak256('approveAndCall(address,uint256,bytes)'))\n     */\n\n    /**\n     * @dev Moves a `value` amount of tokens from the caller's account to `to`\n     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.\n     * @param to The address which you want to transfer to.\n     * @param value The amount of tokens to be transferred.\n     * @return A boolean value indicating whether the operation succeeded unless throwing.\n     */\n    function transferAndCall(address to, uint256 value) external returns (bool);\n\n    /**\n     * @dev Moves a `value` amount of tokens from the caller's account to `to`\n     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.\n     * @param to The address which you want to transfer to.\n     * @param value The amount of tokens to be transferred.\n     * @param data Additional data with no specified format, sent in call to `to`.\n     * @return A boolean value indicating whether the operation succeeded unless throwing.\n     */\n    function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);\n\n    /**\n     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism\n     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.\n     * @param from The address which you want to send tokens from.\n     * @param to The address which you want to transfer to.\n     * @param value The amount of tokens to be transferred.\n     * @return A boolean value indicating whether the operation succeeded unless throwing.\n     */\n    function transferFromAndCall(address from, address to, uint256 value) external returns (bool);\n\n    /**\n     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism\n     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.\n     * @param from The address which you want to send tokens from.\n     * @param to The address which you want to transfer to.\n     * @param value The amount of tokens to be transferred.\n     * @param data Additional data with no specified format, sent in call to `to`.\n     * @return A boolean value indicating whether the operation succeeded unless throwing.\n     */\n    function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);\n\n    /**\n     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.\n     * @param spender The address which will spend the funds.\n     * @param value The amount of tokens to be spent.\n     * @return A boolean value indicating whether the operation succeeded unless throwing.\n     */\n    function approveAndCall(address spender, uint256 value) external returns (bool);\n\n    /**\n     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.\n     * @param spender The address which will spend the funds.\n     * @param value The amount of tokens to be spent.\n     * @param data Additional data with no specified format, sent in call to `spender`.\n     * @return A boolean value indicating whether the operation succeeded unless throwing.\n     */\n    function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);\n}\n"},{"file_path":"@openzeppelin/contracts/utils/StorageSlot.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol)\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC-1967 implementation slot:\n * ```solidity\n * contract ERC1967 {\n *     // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.\n *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n *     function _getImplementation() internal view returns (address) {\n *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n *     }\n *\n *     function _setImplementation(address newImplementation) internal {\n *         require(newImplementation.code.length > 0);\n *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n *     }\n * }\n * ```\n *\n * TIP: Consider using this library along with {SlotDerivation}.\n */\nlibrary StorageSlot {\n    struct AddressSlot {\n        address value;\n    }\n\n    struct BooleanSlot {\n        bool value;\n    }\n\n    struct Bytes32Slot {\n        bytes32 value;\n    }\n\n    struct Uint256Slot {\n        uint256 value;\n    }\n\n    struct Int256Slot {\n        int256 value;\n    }\n\n    struct StringSlot {\n        string value;\n    }\n\n    struct BytesSlot {\n        bytes value;\n    }\n\n    /**\n     * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n     */\n    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n        assembly (\"memory-safe\") {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns a `BooleanSlot` with member `value` located at `slot`.\n     */\n    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n        assembly (\"memory-safe\") {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns a `Bytes32Slot` with member `value` located at `slot`.\n     */\n    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n        assembly (\"memory-safe\") {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns a `Uint256Slot` with member `value` located at `slot`.\n     */\n    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n        assembly (\"memory-safe\") {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns a `Int256Slot` with member `value` located at `slot`.\n     */\n    function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {\n        assembly (\"memory-safe\") {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns a `StringSlot` with member `value` located at `slot`.\n     */\n    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {\n        assembly (\"memory-safe\") {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.\n     */\n    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {\n        assembly (\"memory-safe\") {\n            r.slot := store.slot\n        }\n    }\n\n    /**\n     * @dev Returns a `BytesSlot` with member `value` located at `slot`.\n     */\n    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {\n        assembly (\"memory-safe\") {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.\n     */\n    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {\n        assembly (\"memory-safe\") {\n            r.slot := store.slot\n        }\n    }\n}\n"},{"file_path":"@openzeppelin/contracts/token/ERC20/utils/ERC1363Utils.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/utils/ERC1363Utils.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC1363Receiver} from \"../../../interfaces/IERC1363Receiver.sol\";\nimport {IERC1363Spender} from \"../../../interfaces/IERC1363Spender.sol\";\n\n/**\n * @dev Library that provides common ERC-1363 utility functions.\n *\n * See https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].\n */\nlibrary ERC1363Utils {\n    /**\n     * @dev Indicates a failure with the token `receiver`. Used in transfers.\n     * @param receiver Address to which tokens are being transferred.\n     */\n    error ERC1363InvalidReceiver(address receiver);\n\n    /**\n     * @dev Indicates a failure with the token `spender`. Used in approvals.\n     * @param spender Address that may be allowed to operate on tokens without being their owner.\n     */\n    error ERC1363InvalidSpender(address spender);\n\n    /**\n     * @dev Performs a call to {IERC1363Receiver-onTransferReceived} on a target address.\n     *\n     * Requirements:\n     *\n     * - The target has code (i.e. is a contract).\n     * - The target `to` must implement the {IERC1363Receiver} interface.\n     * - The target must return the {IERC1363Receiver-onTransferReceived} selector to accept the transfer.\n     */\n    function checkOnERC1363TransferReceived(\n        address operator,\n        address from,\n        address to,\n        uint256 value,\n        bytes memory data\n    ) internal {\n        if (to.code.length == 0) {\n            revert ERC1363InvalidReceiver(to);\n        }\n\n        try IERC1363Receiver(to).onTransferReceived(operator, from, value, data) returns (bytes4 retval) {\n            if (retval != IERC1363Receiver.onTransferReceived.selector) {\n                revert ERC1363InvalidReceiver(to);\n            }\n        } catch (bytes memory reason) {\n            if (reason.length == 0) {\n                revert ERC1363InvalidReceiver(to);\n            } else {\n                assembly (\"memory-safe\") {\n                    revert(add(32, reason), mload(reason))\n                }\n            }\n        }\n    }\n\n    /**\n     * @dev Performs a call to {IERC1363Spender-onApprovalReceived} on a target address.\n     *\n     * Requirements:\n     *\n     * - The target has code (i.e. is a contract).\n     * - The target `spender` must implement the {IERC1363Spender} interface.\n     * - The target must return the {IERC1363Spender-onApprovalReceived} selector to accept the approval.\n     */\n    function checkOnERC1363ApprovalReceived(\n        address operator,\n        address spender,\n        uint256 value,\n        bytes memory data\n    ) internal {\n        if (spender.code.length == 0) {\n            revert ERC1363InvalidSpender(spender);\n        }\n\n        try IERC1363Spender(spender).onApprovalReceived(operator, value, data) returns (bytes4 retval) {\n            if (retval != IERC1363Spender.onApprovalReceived.selector) {\n                revert ERC1363InvalidSpender(spender);\n            }\n        } catch (bytes memory reason) {\n            if (reason.length == 0) {\n                revert ERC1363InvalidSpender(spender);\n            } else {\n                assembly (\"memory-safe\") {\n                    revert(add(32, reason), mload(reason))\n                }\n            }\n        }\n    }\n}\n"},{"file_path":"@openzeppelin/contracts/utils/Strings.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/Strings.sol)\n\npragma solidity ^0.8.20;\n\nimport {Math} from \"./math/Math.sol\";\nimport {SignedMath} from \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n    bytes16 private constant HEX_DIGITS = \"0123456789abcdef\";\n    uint8 private constant ADDRESS_LENGTH = 20;\n\n    /**\n     * @dev The `value` string doesn't fit in the specified `length`.\n     */\n    error StringsInsufficientHexLength(uint256 value, uint256 length);\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n     */\n    function toString(uint256 value) internal pure returns (string memory) {\n        unchecked {\n            uint256 length = Math.log10(value) + 1;\n            string memory buffer = new string(length);\n            uint256 ptr;\n            assembly (\"memory-safe\") {\n                ptr := add(buffer, add(32, length))\n            }\n            while (true) {\n                ptr--;\n                assembly (\"memory-safe\") {\n                    mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))\n                }\n                value /= 10;\n                if (value == 0) break;\n            }\n            return buffer;\n        }\n    }\n\n    /**\n     * @dev Converts a `int256` to its ASCII `string` decimal representation.\n     */\n    function toStringSigned(int256 value) internal pure returns (string memory) {\n        return string.concat(value < 0 ? \"-\" : \"\", toString(SignedMath.abs(value)));\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n     */\n    function toHexString(uint256 value) internal pure returns (string memory) {\n        unchecked {\n            return toHexString(value, Math.log256(value) + 1);\n        }\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n     */\n    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n        uint256 localValue = value;\n        bytes memory buffer = new bytes(2 * length + 2);\n        buffer[0] = \"0\";\n        buffer[1] = \"x\";\n        for (uint256 i = 2 * length + 1; i > 1; --i) {\n            buffer[i] = HEX_DIGITS[localValue & 0xf];\n            localValue >>= 4;\n        }\n        if (localValue != 0) {\n            revert StringsInsufficientHexLength(value, length);\n        }\n        return string(buffer);\n    }\n\n    /**\n     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal\n     * representation.\n     */\n    function toHexString(address addr) internal pure returns (string memory) {\n        return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);\n    }\n\n    /**\n     * @dev Converts an `address` with fixed length of 20 bytes to its checksummed ASCII `string` hexadecimal\n     * representation, according to EIP-55.\n     */\n    function toChecksumHexString(address addr) internal pure returns (string memory) {\n        bytes memory buffer = bytes(toHexString(addr));\n\n        // hash the hex part of buffer (skip length + 2 bytes, length 40)\n        uint256 hashValue;\n        assembly (\"memory-safe\") {\n            hashValue := shr(96, keccak256(add(buffer, 0x22), 40))\n        }\n\n        for (uint256 i = 41; i > 1; --i) {\n            // possible values for buffer[i] are 48 (0) to 57 (9) and 97 (a) to 102 (f)\n            if (hashValue & 0xf > 7 && uint8(buffer[i]) > 96) {\n                // case shift by xoring with 0x20\n                buffer[i] ^= 0x20;\n            }\n            hashValue >>= 4;\n        }\n        return string(buffer);\n    }\n\n    /**\n     * @dev Returns true if the two strings are equal.\n     */\n    function equal(string memory a, string memory b) internal pure returns (bool) {\n        return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));\n    }\n}\n"},{"file_path":"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC-20 standard.\n */\ninterface IERC20Metadata is IERC20 {\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() external view returns (string memory);\n\n    /**\n     * @dev Returns the symbol of the token.\n     */\n    function symbol() external view returns (string memory);\n\n    /**\n     * @dev Returns the decimals places of the token.\n     */\n    function decimals() external view returns (uint8);\n}\n"},{"file_path":"@openzeppelin/contracts/token/ERC20/extensions/ERC1363.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/ERC1363.sol)\n\npragma solidity ^0.8.20;\n\nimport {ERC20} from \"../ERC20.sol\";\nimport {IERC165, ERC165} from \"../../../utils/introspection/ERC165.sol\";\nimport {IERC1363} from \"../../../interfaces/IERC1363.sol\";\nimport {ERC1363Utils} from \"../utils/ERC1363Utils.sol\";\n\n/**\n * @title ERC1363\n * @dev Extension of {ERC20} tokens that adds support for code execution after transfers and approvals\n * on recipient contracts. Calls after transfers are enabled through the {ERC1363-transferAndCall} and\n * {ERC1363-transferFromAndCall} methods while calls after approvals can be made with {ERC1363-approveAndCall}\n *\n * _Available since v5.1._\n */\nabstract contract ERC1363 is ERC20, ERC165, IERC1363 {\n    /**\n     * @dev Indicates a failure within the {transfer} part of a transferAndCall operation.\n     * @param receiver Address to which tokens are being transferred.\n     * @param value Amount of tokens to be transferred.\n     */\n    error ERC1363TransferFailed(address receiver, uint256 value);\n\n    /**\n     * @dev Indicates a failure within the {transferFrom} part of a transferFromAndCall operation.\n     * @param sender Address from which to send tokens.\n     * @param receiver Address to which tokens are being transferred.\n     * @param value Amount of tokens to be transferred.\n     */\n    error ERC1363TransferFromFailed(address sender, address receiver, uint256 value);\n\n    /**\n     * @dev Indicates a failure within the {approve} part of a approveAndCall operation.\n     * @param spender Address which will spend the funds.\n     * @param value Amount of tokens to be spent.\n     */\n    error ERC1363ApproveFailed(address spender, uint256 value);\n\n    /**\n     * @inheritdoc IERC165\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n        return interfaceId == type(IERC1363).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @dev Moves a `value` amount of tokens from the caller's account to `to`\n     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.\n     *\n     * Requirements:\n     *\n     * - The target has code (i.e. is a contract).\n     * - The target `to` must implement the {IERC1363Receiver} interface.\n     * - The target must return the {IERC1363Receiver-onTransferReceived} selector to accept the transfer.\n     * - The internal {transfer} must succeed (returned `true`).\n     */\n    function transferAndCall(address to, uint256 value) public returns (bool) {\n        return transferAndCall(to, value, \"\");\n    }\n\n    /**\n     * @dev Variant of {transferAndCall} that accepts an additional `data` parameter with\n     * no specified format.\n     */\n    function transferAndCall(address to, uint256 value, bytes memory data) public virtual returns (bool) {\n        if (!transfer(to, value)) {\n            revert ERC1363TransferFailed(to, value);\n        }\n        ERC1363Utils.checkOnERC1363TransferReceived(_msgSender(), _msgSender(), to, value, data);\n        return true;\n    }\n\n    /**\n     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism\n     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.\n     *\n     * Requirements:\n     *\n     * - The target has code (i.e. is a contract).\n     * - The target `to` must implement the {IERC1363Receiver} interface.\n     * - The target must return the {IERC1363Receiver-onTransferReceived} selector to accept the transfer.\n     * - The internal {transferFrom} must succeed (returned `true`).\n     */\n    function transferFromAndCall(address from, address to, uint256 value) public returns (bool) {\n        return transferFromAndCall(from, to, value, \"\");\n    }\n\n    /**\n     * @dev Variant of {transferFromAndCall} that accepts an additional `data` parameter with\n     * no specified format.\n     */\n    function transferFromAndCall(\n        address from,\n        address to,\n        uint256 value,\n        bytes memory data\n    ) public virtual returns (bool) {\n        if (!transferFrom(from, to, value)) {\n            revert ERC1363TransferFromFailed(from, to, value);\n        }\n        ERC1363Utils.checkOnERC1363TransferReceived(_msgSender(), from, to, value, data);\n        return true;\n    }\n\n    /**\n     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.\n     *\n     * Requirements:\n     *\n     * - The target has code (i.e. is a contract).\n     * - The target `spender` must implement the {IERC1363Spender} interface.\n     * - The target must return the {IERC1363Spender-onApprovalReceived} selector to accept the approval.\n     * - The internal {approve} must succeed (returned `true`).\n     */\n    function approveAndCall(address spender, uint256 value) public returns (bool) {\n        return approveAndCall(spender, value, \"\");\n    }\n\n    /**\n     * @dev Variant of {approveAndCall} that accepts an additional `data` parameter with\n     * no specified format.\n     */\n    function approveAndCall(address spender, uint256 value, bytes memory data) public virtual returns (bool) {\n        if (!approve(spender, value)) {\n            revert ERC1363ApproveFailed(spender, value);\n        }\n        ERC1363Utils.checkOnERC1363ApprovalReceived(_msgSender(), spender, value, data);\n        return true;\n    }\n}\n"},{"file_path":"contracts/morpho/helpers/IMorpho.sol","source_code":"// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\ntype Id is bytes32;\n\nstruct MarketParams {\n\taddress loanToken;\n\taddress collateralToken;\n\taddress oracle;\n\taddress irm;\n\tuint256 lltv;\n}\n\n/// @dev Warning: For `feeRecipient`, `supplyShares` does not contain the accrued shares since the last interest\n/// accrual.\nstruct Position {\n\tuint256 supplyShares;\n\tuint128 borrowShares;\n\tuint128 collateral;\n}\n\n/// @dev Warning: `totalSupplyAssets` does not contain the accrued interest since the last interest accrual.\n/// @dev Warning: `totalBorrowAssets` does not contain the accrued interest since the last interest accrual.\n/// @dev Warning: `totalSupplyShares` does not contain the additional shares accrued by `feeRecipient` since the last\n/// interest accrual.\nstruct Market {\n\tuint128 totalSupplyAssets;\n\tuint128 totalSupplyShares;\n\tuint128 totalBorrowAssets;\n\tuint128 totalBorrowShares;\n\tuint128 lastUpdate;\n\tuint128 fee;\n}\n\nstruct Authorization {\n\taddress authorizer;\n\taddress authorized;\n\tbool isAuthorized;\n\tuint256 nonce;\n\tuint256 deadline;\n}\n\nstruct Signature {\n\tuint8 v;\n\tbytes32 r;\n\tbytes32 s;\n}\n\n/// @dev This interface is used for factorizing IMorphoStaticTyping and IMorpho.\n/// @dev Consider using the IMorpho interface instead of this one.\ninterface IMorphoBase {\n\t/// @notice The EIP-712 domain separator.\n\t/// @dev Warning: Every EIP-712 signed message based on this domain separator can be reused on chains sharing the\n\t/// same chain id and on forks because the domain separator would be the same.\n\tfunction DOMAIN_SEPARATOR() external view returns (bytes32);\n\n\t/// @notice The owner of the contract.\n\t/// @dev It has the power to change the owner.\n\t/// @dev It has the power to set fees on markets and set the fee recipient.\n\t/// @dev It has the power to enable but not disable IRMs and LLTVs.\n\tfunction owner() external view returns (address);\n\n\t/// @notice The fee recipient of all markets.\n\t/// @dev The recipient receives the fees of a given market through a supply position on that market.\n\tfunction feeRecipient() external view returns (address);\n\n\t/// @notice Whether the `irm` is enabled.\n\tfunction isIrmEnabled(address irm) external view returns (bool);\n\n\t/// @notice Whether the `lltv` is enabled.\n\tfunction isLltvEnabled(uint256 lltv) external view returns (bool);\n\n\t/// @notice Whether `authorized` is authorized to modify `authorizer`'s position on all markets.\n\t/// @dev Anyone is authorized to modify their own positions, regardless of this variable.\n\tfunction isAuthorized(address authorizer, address authorized) external view returns (bool);\n\n\t/// @notice The `authorizer`'s current nonce. Used to prevent replay attacks with EIP-712 signatures.\n\tfunction nonce(address authorizer) external view returns (uint256);\n\n\t/// @notice Sets `newOwner` as `owner` of the contract.\n\t/// @dev Warning: No two-step transfer ownership.\n\t/// @dev Warning: The owner can be set to the zero address.\n\tfunction setOwner(address newOwner) external;\n\n\t/// @notice Enables `irm` as a possible IRM for market creation.\n\t/// @dev Warning: It is not possible to disable an IRM.\n\tfunction enableIrm(address irm) external;\n\n\t/// @notice Enables `lltv` as a possible LLTV for market creation.\n\t/// @dev Warning: It is not possible to disable a LLTV.\n\tfunction enableLltv(uint256 lltv) external;\n\n\t/// @notice Sets the `newFee` for the given market `marketParams`.\n\t/// @param newFee The new fee, scaled by WAD.\n\t/// @dev Warning: The recipient can be the zero address.\n\tfunction setFee(MarketParams memory marketParams, uint256 newFee) external;\n\n\t/// @notice Sets `newFeeRecipient` as `feeRecipient` of the fee.\n\t/// @dev Warning: If the fee recipient is set to the zero address, fees will accrue there and will be lost.\n\t/// @dev Modifying the fee recipient will allow the new recipient to claim any pending fees not yet accrued. To\n\t/// ensure that the current recipient receives all due fees, accrue interest manually prior to making any changes.\n\tfunction setFeeRecipient(address newFeeRecipient) external;\n\n\t/// @notice Creates the market `marketParams`.\n\t/// @dev Here is the list of assumptions on the market's dependencies (tokens, IRM and oracle) that guarantees\n\t/// Morpho behaves as expected:\n\t/// - The token should be ERC-20 compliant, except that it can omit return values on `transfer` and `transferFrom`.\n\t/// - The token balance of Morpho should only decrease on `transfer` and `transferFrom`. In particular, tokens with\n\t/// burn functions are not supported.\n\t/// - The token should not re-enter Morpho on `transfer` nor `transferFrom`.\n\t/// - The token balance of the sender (resp. receiver) should decrease (resp. increase) by exactly the given amount\n\t/// on `transfer` and `transferFrom`. In particular, tokens with fees on transfer are not supported.\n\t/// - The IRM should not re-enter Morpho.\n\t/// - The oracle should return a price with the correct scaling.\n\t/// @dev Here is a list of assumptions on the market's dependencies which, if broken, could break Morpho's liveness\n\t/// properties (funds could get stuck):\n\t/// - The token should not revert on `transfer` and `transferFrom` if balances and approvals are right.\n\t/// - The amount of assets supplied and borrowed should not go above ~1e35 (otherwise the computation of\n\t/// `toSharesUp` and `toSharesDown` can overflow).\n\t/// - The IRM should not revert on `borrowRate`.\n\t/// - The IRM should not return a very high borrow rate (otherwise the computation of `interest` in\n\t/// `_accrueInterest` can overflow).\n\t/// - The oracle should not revert `price`.\n\t/// - The oracle should not return a very high price (otherwise the computation of `maxBorrow` in `_isHealthy` or of\n\t/// `assetsRepaid` in `liquidate` can overflow).\n\t/// @dev The borrow share price of a market with less than 1e4 assets borrowed can be decreased by manipulations, to\n\t/// the point where `totalBorrowShares` is very large and borrowing overflows.\n\tfunction createMarket(MarketParams memory marketParams) external;\n\n\t/// @notice Supplies `assets` or `shares` on behalf of `onBehalf`, optionally calling back the caller's\n\t/// `onMorphoSupply` function with the given `data`.\n\t/// @dev Either `assets` or `shares` should be zero. Most use cases should rely on `assets` as an input so the\n\t/// caller is guaranteed to have `assets` tokens pulled from their balance, but the possibility to mint a specific\n\t/// amount of shares is given for full compatibility and precision.\n\t/// @dev Supplying a large amount can revert for overflow.\n\t/// @dev Supplying an amount of shares may lead to supply more or fewer assets than expected due to slippage.\n\t/// Consider using the `assets` parameter to avoid this.\n\t/// @param marketParams The market to supply assets to.\n\t/// @param assets The amount of assets to supply.\n\t/// @param shares The amount of shares to mint.\n\t/// @param onBehalf The address that will own the increased supply position.\n\t/// @param data Arbitrary data to pass to the `onMorphoSupply` callback. Pass empty data if not needed.\n\t/// @return assetsSupplied The amount of assets supplied.\n\t/// @return sharesSupplied The amount of shares minted.\n\tfunction supply(\n\t\tMarketParams memory marketParams,\n\t\tuint256 assets,\n\t\tuint256 shares,\n\t\taddress onBehalf,\n\t\tbytes memory data\n\t) external returns (uint256 assetsSupplied, uint256 sharesSupplied);\n\n\t/// @notice Withdraws `assets` or `shares` on behalf of `onBehalf` and sends the assets to `receiver`.\n\t/// @dev Either `assets` or `shares` should be zero. To withdraw max, pass the `shares`'s balance of `onBehalf`.\n\t/// @dev `msg.sender` must be authorized to manage `onBehalf`'s positions.\n\t/// @dev Withdrawing an amount corresponding to more shares than supplied will revert for underflow.\n\t/// @dev It is advised to use the `shares` input when withdrawing the full position to avoid reverts due to\n\t/// conversion roundings between shares and assets.\n\t/// @param marketParams The market to withdraw assets from.\n\t/// @param assets The amount of assets to withdraw.\n\t/// @param shares The amount of shares to burn.\n\t/// @param onBehalf The address of the owner of the supply position.\n\t/// @param receiver The address that will receive the withdrawn assets.\n\t/// @return assetsWithdrawn The amount of assets withdrawn.\n\t/// @return sharesWithdrawn The amount of shares burned.\n\tfunction withdraw(\n\t\tMarketParams memory marketParams,\n\t\tuint256 assets,\n\t\tuint256 shares,\n\t\taddress onBehalf,\n\t\taddress receiver\n\t) external returns (uint256 assetsWithdrawn, uint256 sharesWithdrawn);\n\n\t/// @notice Borrows `assets` or `shares` on behalf of `onBehalf` and sends the assets to `receiver`.\n\t/// @dev Either `assets` or `shares` should be zero. Most use cases should rely on `assets` as an input so the\n\t/// caller is guaranteed to borrow `assets` of tokens, but the possibility to mint a specific amount of shares is\n\t/// given for full compatibility and precision.\n\t/// @dev `msg.sender` must be authorized to manage `onBehalf`'s positions.\n\t/// @dev Borrowing a large amount can revert for overflow.\n\t/// @dev Borrowing an amount of shares may lead to borrow fewer assets than expected due to slippage.\n\t/// Consider using the `assets` parameter to avoid this.\n\t/// @param marketParams The market to borrow assets from.\n\t/// @param assets The amount of assets to borrow.\n\t/// @param shares The amount of shares to mint.\n\t/// @param onBehalf The address that will own the increased borrow position.\n\t/// @param receiver The address that will receive the borrowed assets.\n\t/// @return assetsBorrowed The amount of assets borrowed.\n\t/// @return sharesBorrowed The amount of shares minted.\n\tfunction borrow(\n\t\tMarketParams memory marketParams,\n\t\tuint256 assets,\n\t\tuint256 shares,\n\t\taddress onBehalf,\n\t\taddress receiver\n\t) external returns (uint256 assetsBorrowed, uint256 sharesBorrowed);\n\n\t/// @notice Repays `assets` or `shares` on behalf of `onBehalf`, optionally calling back the caller's\n\t/// `onMorphoRepay` function with the given `data`.\n\t/// @dev Either `assets` or `shares` should be zero. To repay max, pass the `shares`'s balance of `onBehalf`.\n\t/// @dev Repaying an amount corresponding to more shares than borrowed will revert for underflow.\n\t/// @dev It is advised to use the `shares` input when repaying the full position to avoid reverts due to conversion\n\t/// roundings between shares and assets.\n\t/// @dev An attacker can front-run a repay with a small repay making the transaction revert for underflow.\n\t/// @param marketParams The market to repay assets to.\n\t/// @param assets The amount of assets to repay.\n\t/// @param shares The amount of shares to burn.\n\t/// @param onBehalf The address of the owner of the debt position.\n\t/// @param data Arbitrary data to pass to the `onMorphoRepay` callback. Pass empty data if not needed.\n\t/// @return assetsRepaid The amount of assets repaid.\n\t/// @return sharesRepaid The amount of shares burned.\n\tfunction repay(\n\t\tMarketParams memory marketParams,\n\t\tuint256 assets,\n\t\tuint256 shares,\n\t\taddress onBehalf,\n\t\tbytes memory data\n\t) external returns (uint256 assetsRepaid, uint256 sharesRepaid);\n\n\t/// @notice Supplies `assets` of collateral on behalf of `onBehalf`, optionally calling back the caller's\n\t/// `onMorphoSupplyCollateral` function with the given `data`.\n\t/// @dev Interest are not accrued since it's not required and it saves gas.\n\t/// @dev Supplying a large amount can revert for overflow.\n\t/// @param marketParams The market to supply collateral to.\n\t/// @param assets The amount of collateral to supply.\n\t/// @param onBehalf The address that will own the increased collateral position.\n\t/// @param data Arbitrary data to pass to the `onMorphoSupplyCollateral` callback. Pass empty data if not needed.\n\tfunction supplyCollateral(\n\t\tMarketParams memory marketParams,\n\t\tuint256 assets,\n\t\taddress onBehalf,\n\t\tbytes memory data\n\t) external;\n\n\t/// @notice Withdraws `assets` of collateral on behalf of `onBehalf` and sends the assets to `receiver`.\n\t/// @dev `msg.sender` must be authorized to manage `onBehalf`'s positions.\n\t/// @dev Withdrawing an amount corresponding to more collateral than supplied will revert for underflow.\n\t/// @param marketParams The market to withdraw collateral from.\n\t/// @param assets The amount of collateral to withdraw.\n\t/// @param onBehalf The address of the owner of the collateral position.\n\t/// @param receiver The address that will receive the collateral assets.\n\tfunction withdrawCollateral(\n\t\tMarketParams memory marketParams,\n\t\tuint256 assets,\n\t\taddress onBehalf,\n\t\taddress receiver\n\t) external;\n\n\t/// @notice Liquidates the given `repaidShares` of debt asset or seize the given `seizedAssets` of collateral on the\n\t/// given market `marketParams` of the given `borrower`'s position, optionally calling back the caller's\n\t/// `onMorphoLiquidate` function with the given `data`.\n\t/// @dev Either `seizedAssets` or `repaidShares` should be zero.\n\t/// @dev Seizing more than the collateral balance will underflow and revert without any error message.\n\t/// @dev Repaying more than the borrow balance will underflow and revert without any error message.\n\t/// @dev An attacker can front-run a liquidation with a small repay making the transaction revert for underflow.\n\t/// @param marketParams The market of the position.\n\t/// @param borrower The owner of the position.\n\t/// @param seizedAssets The amount of collateral to seize.\n\t/// @param repaidShares The amount of shares to repay.\n\t/// @param data Arbitrary data to pass to the `onMorphoLiquidate` callback. Pass empty data if not needed.\n\t/// @return The amount of assets seized.\n\t/// @return The amount of assets repaid.\n\tfunction liquidate(\n\t\tMarketParams memory marketParams,\n\t\taddress borrower,\n\t\tuint256 seizedAssets,\n\t\tuint256 repaidShares,\n\t\tbytes memory data\n\t) external returns (uint256, uint256);\n\n\t/// @notice Executes a flash loan.\n\t/// @dev Flash loans have access to the whole balance of the contract (the liquidity and deposited collateral of all\n\t/// markets combined, plus donations).\n\t/// @dev Warning: Not ERC-3156 compliant but compatibility is easily reached:\n\t/// - `flashFee` is zero.\n\t/// - `maxFlashLoan` is the token's balance of this contract.\n\t/// - The receiver of `assets` is the caller.\n\t/// @param token The token to flash loan.\n\t/// @param assets The amount of assets to flash loan.\n\t/// @param data Arbitrary data to pass to the `onMorphoFlashLoan` callback.\n\tfunction flashLoan(address token, uint256 assets, bytes calldata data) external;\n\n\t/// @notice Sets the authorization for `authorized` to manage `msg.sender`'s positions.\n\t/// @param authorized The authorized address.\n\t/// @param newIsAuthorized The new authorization status.\n\tfunction setAuthorization(address authorized, bool newIsAuthorized) external;\n\n\t/// @notice Sets the authorization for `authorization.authorized` to manage `authorization.authorizer`'s positions.\n\t/// @dev Warning: Reverts if the signature has already been submitted.\n\t/// @dev The signature is malleable, but it has no impact on the security here.\n\t/// @dev The nonce is passed as argument to be able to revert with a different error message.\n\t/// @param authorization The `Authorization` struct.\n\t/// @param signature The signature.\n\tfunction setAuthorizationWithSig(Authorization calldata authorization, Signature calldata signature) external;\n\n\t/// @notice Accrues interest for the given market `marketParams`.\n\tfunction accrueInterest(MarketParams memory marketParams) external;\n\n\t/// @notice Returns the data stored on the different `slots`.\n\tfunction extSloads(bytes32[] memory slots) external view returns (bytes32[] memory);\n}\n\n/// @dev This interface is inherited by Morpho so that function signatures are checked by the compiler.\n/// @dev Consider using the IMorpho interface instead of this one.\ninterface IMorphoStaticTyping is IMorphoBase {\n\t/// @notice The state of the position of `user` on the market corresponding to `id`.\n\t/// @dev Warning: For `feeRecipient`, `supplyShares` does not contain the accrued shares since the last interest\n\t/// accrual.\n\tfunction position(\n\t\tId id,\n\t\taddress user\n\t) external view returns (uint256 supplyShares, uint128 borrowShares, uint128 collateral);\n\n\t/// @notice The state of the market corresponding to `id`.\n\t/// @dev Warning: `totalSupplyAssets` does not contain the accrued interest since the last interest accrual.\n\t/// @dev Warning: `totalBorrowAssets` does not contain the accrued interest since the last interest accrual.\n\t/// @dev Warning: `totalSupplyShares` does not contain the accrued shares by `feeRecipient` since the last interest\n\t/// accrual.\n\tfunction market(\n\t\tId id\n\t)\n\t\texternal\n\t\tview\n\t\treturns (\n\t\t\tuint128 totalSupplyAssets,\n\t\t\tuint128 totalSupplyShares,\n\t\t\tuint128 totalBorrowAssets,\n\t\t\tuint128 totalBorrowShares,\n\t\t\tuint128 lastUpdate,\n\t\t\tuint128 fee\n\t\t);\n\n\t/// @notice The market params corresponding to `id`.\n\t/// @dev This mapping is not used in Morpho. It is there to enable reducing the cost associated to calldata on layer\n\t/// 2s by creating a wrapper contract with functions that take `id` as input instead of `marketParams`.\n\tfunction idToMarketParams(\n\t\tId id\n\t) external view returns (address loanToken, address collateralToken, address oracle, address irm, uint256 lltv);\n}\n\n/// @title IMorpho\n/// @author Morpho Labs\n/// @custom:contact security@morpho.org\n/// @dev Use this interface for Morpho to have access to all the functions with the appropriate function signatures.\ninterface IMorpho is IMorphoBase {\n\t/// @notice The state of the position of `user` on the market corresponding to `id`.\n\t/// @dev Warning: For `feeRecipient`, `p.supplyShares` does not contain the accrued shares since the last interest\n\t/// accrual.\n\tfunction position(Id id, address user) external view returns (Position memory p);\n\n\t/// @notice The state of the market corresponding to `id`.\n\t/// @dev Warning: `m.totalSupplyAssets` does not contain the accrued interest since the last interest accrual.\n\t/// @dev Warning: `m.totalBorrowAssets` does not contain the accrued interest since the last interest accrual.\n\t/// @dev Warning: `m.totalSupplyShares` does not contain the accrued shares by `feeRecipient` since the last\n\t/// interest accrual.\n\tfunction market(Id id) external view returns (Market memory m);\n\n\t/// @notice The market params corresponding to `id`.\n\t/// @dev This mapping is not used in Morpho. It is there to enable reducing the cost associated to calldata on layer\n\t/// 2s by creating a wrapper contract with functions that take `id` as input instead of `marketParams`.\n\tfunction idToMarketParams(Id id) external view returns (MarketParams memory);\n}\n"},{"file_path":"contracts/stablecoin/libraries/EventsLib.sol","source_code":"// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity ^0.8.20;\n\nlibrary EventsLib {\n\t/// @notice Emitted when a pending `newCurator` is submitted.\n\tevent SubmitCurator(address indexed caller, address indexed newCurator, uint256 timelock);\n\n\t/// @notice Emitted when a `pendingGuardian` is revoked.\n\tevent RevokePendingCurator(address indexed caller, address indexed pendingGuardian);\n\n\t/// @notice Emitted when `guardian` is set to `newCurator`.\n\tevent SetCurator(address indexed caller, address indexed guardian);\n\n\t// ---------------------------------------------------------------------------------------\n\n\t/// @notice Emitted when a pending `newGuardian` is submitted.\n\tevent SubmitGuardian(address indexed caller, address indexed newGuardian, uint256 timelock);\n\n\t/// @notice Emitted when a `pendingGuardian` is revoked.\n\tevent RevokePendingGuardian(address indexed caller, address indexed pendingGuardian);\n\n\t/// @notice Emitted when `guardian` is set to `newGuardian`.\n\tevent SetGuardian(address indexed caller, address indexed guardian);\n\n\t// ---------------------------------------------------------------------------------------\n\n\t/// @notice Emitted when a pending `newTimelock` is submitted.\n\tevent SubmitTimelock(address indexed caller, uint256 newTimelock, uint256 timelock);\n\n\t/// @notice Emitted when a `pendingTimelock` is revoked.\n\tevent RevokePendingTimelock(address indexed caller, uint256 pendingTimelock);\n\n\t/// @notice Emitted when `timelock` is set to `newTimelock`.\n\tevent SetTimelock(address indexed caller, uint256 newTimelock);\n\n\t// ---------------------------------------------------------------------------------------\n\n\t/// @notice Emitted when a new `newModule` is submitted.\n\tevent SubmitModule(address indexed caller, address indexed newModule, uint256 expiredAt, string message, uint256 timelock);\n\n\t/// @notice Emitted when a `pendingModule` is revoked.\n\tevent RevokePendingModule(address indexed caller, address indexed module, string message);\n\n\t/// @notice Emitted when `Module` is set to `newModule`.\n\tevent SetModule(address indexed caller, address indexed newModule);\n\n\t// ---------------------------------------------------------------------------------------\n\n\t/// @notice Emitted when an account is frozen by the curator.\n\t/// @param caller The address that triggered the freeze.\n\t/// @param account The address being frozen.\n\t/// @param message A message explaining the reason for freezing.\n\tevent SetFreeze(address indexed caller, address indexed account, string message);\n\n\t// ---------------------------------------------------------------------------------------\n\n\t/// @notice Emitted when an unfreeze request is submitted.\n\t/// @param caller The address that submitted the unfreeze request.\n\t/// @param account The address requested to be unfrozen.\n\t/// @param message A message explaining the reason for unfreezing.\n\t/// @param timelock The timestamp after which the unfreeze can be accepted.\n\tevent SubmitUnfreeze(address indexed caller, address indexed account, string message, uint256 timelock);\n\n\t/// @notice Emitted when a pending unfreeze request is revoked.\n\t/// @param caller The address that revoked the unfreeze request.\n\t/// @param account The address whose unfreeze was revoked.\n\t/// @param message A message explaining the reason for revocation.\n\tevent RevokeUnfreeze(address indexed caller, address indexed account, string message);\n\n\t/// @notice Emitted when an unfreeze request is accepted and finalized.\n\t/// @param caller The address that finalized the unfreeze.\n\t/// @param account The address that was unfrozen.\n\tevent SetUnfreeze(address indexed caller, address indexed account);\n}\n"},{"file_path":"@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC-20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[ERC-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC-20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * ==== Security Considerations\n *\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\n * generally recommended is:\n *\n * ```solidity\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\n *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\n *     doThing(..., value);\n * }\n *\n * function doThing(..., uint256 value) public {\n *     token.safeTransferFrom(msg.sender, address(this), value);\n *     ...\n * }\n * ```\n *\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\n * {SafeERC20-safeTransferFrom}).\n *\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\n * contracts should have entry points that don't rely on permit.\n */\ninterface IERC20Permit {\n    /**\n     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n     * given ``owner``'s signed approval.\n     *\n     * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n     * ordering also apply here.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `deadline` must be a timestamp in the future.\n     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n     * over the EIP712-formatted function arguments.\n     * - the signature must use ``owner``'s current nonce (see {nonces}).\n     *\n     * For more information on the signature format, see the\n     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n     * section].\n     *\n     * CAUTION: See Security Considerations above.\n     */\n    function permit(\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external;\n\n    /**\n     * @dev Returns the current nonce for `owner`. This value must be\n     * included whenever a signature is generated for {permit}.\n     *\n     * Every successful call to {permit} increases ``owner``'s nonce by one. This\n     * prevents a signature from being used multiple times.\n     */\n    function nonces(address owner) external view returns (uint256);\n\n    /**\n     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n"},{"file_path":"contracts/stablecoin/libraries/ConstantsLib.sol","source_code":"// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity ^0.8.20;\n\nlibrary ConstantsLib {\n\t/// @dev The minimum delay of a timelock.\n\tuint256 internal constant MIN_TIMELOCK = 7 days;\n\n\t/// @dev The maximum delay of a timelock.\n\tuint256 internal constant MAX_TIMELOCK = 4 weeks;\n\n\t/// @dev The fee to pay for public proposals\n\tuint256 internal constant PUBLIC_FEE = 10000 ether;\n}\n"},{"file_path":"contracts/morpho/helpers/PendingLib.sol","source_code":"// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity ^0.8.0;\n\nstruct MarketConfig {\n\t/// @notice The maximum amount of assets that can be allocated to the market.\n\tuint184 cap;\n\t/// @notice Whether the market is in the withdraw queue.\n\tbool enabled;\n\t/// @notice The timestamp at which the market can be instantly removed from the withdraw queue.\n\tuint64 removableAt;\n}\n\nstruct PendingUint192 {\n\t/// @notice The pending value to set.\n\tuint192 value;\n\t/// @notice The timestamp at which the pending value becomes valid.\n\tuint64 validAt;\n}\n\nstruct PendingAddress {\n\t/// @notice The pending value to set.\n\taddress value;\n\t/// @notice The timestamp at which the pending value becomes valid.\n\tuint64 validAt;\n}\n\n/// @title PendingLib\n/// @author Morpho Labs\n/// @custom:contact security@morpho.org\n/// @notice Library to manage pending values and their validity timestamp.\nlibrary PendingLib {\n\t/// @dev Updates `pending`'s value to `newValue` and its corresponding `validAt` timestamp.\n\t/// @dev Assumes `timelock` <= `MAX_TIMELOCK`.\n\tfunction update(PendingUint192 storage pending, uint184 newValue, uint256 timelock) internal {\n\t\tpending.value = newValue;\n\t\t// Safe \"unchecked\" cast because timelock <= MAX_TIMELOCK.\n\t\tpending.validAt = uint64(block.timestamp + timelock);\n\t}\n\n\t/// @dev Updates `pending`'s value to `newValue` and its corresponding `validAt` timestamp.\n\t/// @dev Assumes `timelock` <= `MAX_TIMELOCK`.\n\tfunction update(PendingAddress storage pending, address newValue, uint256 timelock) internal {\n\t\tpending.value = newValue;\n\t\t// Safe \"unchecked\" cast because timelock <= MAX_TIMELOCK.\n\t\tpending.validAt = uint64(block.timestamp + timelock);\n\t}\n}\n"},{"file_path":"@openzeppelin/contracts/utils/Context.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\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    function _contextSuffixLength() internal view virtual returns (uint256) {\n        return 0;\n    }\n}\n"},{"file_path":"@openzeppelin/contracts/interfaces/draft-IERC6093.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC6093.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard ERC-20 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.\n */\ninterface IERC20Errors {\n    /**\n     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n     * @param sender Address whose tokens are being transferred.\n     * @param balance Current balance for the interacting account.\n     * @param needed Minimum amount required to perform a transfer.\n     */\n    error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);\n\n    /**\n     * @dev Indicates a failure with the token `sender`. Used in transfers.\n     * @param sender Address whose tokens are being transferred.\n     */\n    error ERC20InvalidSender(address sender);\n\n    /**\n     * @dev Indicates a failure with the token `receiver`. Used in transfers.\n     * @param receiver Address to which tokens are being transferred.\n     */\n    error ERC20InvalidReceiver(address receiver);\n\n    /**\n     * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.\n     * @param spender Address that may be allowed to operate on tokens without being their owner.\n     * @param allowance Amount of tokens a `spender` is allowed to operate with.\n     * @param needed Minimum amount required to perform a transfer.\n     */\n    error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);\n\n    /**\n     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n     * @param approver Address initiating an approval operation.\n     */\n    error ERC20InvalidApprover(address approver);\n\n    /**\n     * @dev Indicates a failure with the `spender` to be approved. Used in approvals.\n     * @param spender Address that may be allowed to operate on tokens without being their owner.\n     */\n    error ERC20InvalidSpender(address spender);\n}\n\n/**\n * @dev Standard ERC-721 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.\n */\ninterface IERC721Errors {\n    /**\n     * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20.\n     * Used in balance queries.\n     * @param owner Address of the current owner of a token.\n     */\n    error ERC721InvalidOwner(address owner);\n\n    /**\n     * @dev Indicates a `tokenId` whose `owner` is the zero address.\n     * @param tokenId Identifier number of a token.\n     */\n    error ERC721NonexistentToken(uint256 tokenId);\n\n    /**\n     * @dev Indicates an error related to the ownership over a particular token. Used in transfers.\n     * @param sender Address whose tokens are being transferred.\n     * @param tokenId Identifier number of a token.\n     * @param owner Address of the current owner of a token.\n     */\n    error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);\n\n    /**\n     * @dev Indicates a failure with the token `sender`. Used in transfers.\n     * @param sender Address whose tokens are being transferred.\n     */\n    error ERC721InvalidSender(address sender);\n\n    /**\n     * @dev Indicates a failure with the token `receiver`. Used in transfers.\n     * @param receiver Address to which tokens are being transferred.\n     */\n    error ERC721InvalidReceiver(address receiver);\n\n    /**\n     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n     * @param operator Address that may be allowed to operate on tokens without being their owner.\n     * @param tokenId Identifier number of a token.\n     */\n    error ERC721InsufficientApproval(address operator, uint256 tokenId);\n\n    /**\n     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n     * @param approver Address initiating an approval operation.\n     */\n    error ERC721InvalidApprover(address approver);\n\n    /**\n     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n     * @param operator Address that may be allowed to operate on tokens without being their owner.\n     */\n    error ERC721InvalidOperator(address operator);\n}\n\n/**\n * @dev Standard ERC-1155 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.\n */\ninterface IERC1155Errors {\n    /**\n     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n     * @param sender Address whose tokens are being transferred.\n     * @param balance Current balance for the interacting account.\n     * @param needed Minimum amount required to perform a transfer.\n     * @param tokenId Identifier number of a token.\n     */\n    error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);\n\n    /**\n     * @dev Indicates a failure with the token `sender`. Used in transfers.\n     * @param sender Address whose tokens are being transferred.\n     */\n    error ERC1155InvalidSender(address sender);\n\n    /**\n     * @dev Indicates a failure with the token `receiver`. Used in transfers.\n     * @param receiver Address to which tokens are being transferred.\n     */\n    error ERC1155InvalidReceiver(address receiver);\n\n    /**\n     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n     * @param operator Address that may be allowed to operate on tokens without being their owner.\n     * @param owner Address of the current owner of a token.\n     */\n    error ERC1155MissingApprovalForAll(address operator, address owner);\n\n    /**\n     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n     * @param approver Address initiating an approval operation.\n     */\n    error ERC1155InvalidApprover(address approver);\n\n    /**\n     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n     * @param operator Address that may be allowed to operate on tokens without being their owner.\n     */\n    error ERC1155InvalidOperator(address operator);\n\n    /**\n     * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.\n     * Used in batch transfers.\n     * @param idsLength Length of the array of token identifiers\n     * @param valuesLength Length of the array of token amounts\n     */\n    error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);\n}\n"},{"file_path":"contracts/stablecoin/IStablecoinModifier.sol","source_code":"// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity ^0.8.20;\n\nimport {Context} from '@openzeppelin/contracts/utils/Context.sol';\n\nimport {Stablecoin} from './Stablecoin.sol';\nimport {ErrorsLib} from './libraries/ErrorsLib.sol';\n\nabstract contract IStablecoinModifier is Context {\n\tStablecoin public immutable stable;\n\n\tmodifier onlyCurator() {\n\t\tstable.verifyCurator(_msgSender());\n\t\t_;\n\t}\n\n\tmodifier onlyGuardian() {\n\t\tstable.verifyGuardian(_msgSender());\n\t\t_;\n\t}\n\n\tmodifier onlyCuratorOrGuardian() {\n\t\tstable.verifyCuratorOrGuardian(_msgSender());\n\t\t_;\n\t}\n\n\tmodifier onlyModule() {\n\t\tstable.verifyModule(_msgSender());\n\t\t_;\n\t}\n\n\tmodifier validModule() {\n\t\tstable.verifyValidModule(_msgSender());\n\t\t_;\n\t}\n\n\tmodifier afterTimelock(uint256 validAt) {\n\t\tif (validAt == 0) revert ErrorsLib.NoPendingValue();\n\t\tif (block.timestamp < validAt) revert ErrorsLib.TimelockNotElapsed();\n\t\t_;\n\t}\n\n\tmodifier claimPublicFee(uint256 fee, uint256 min) {\n\t\tif (fee < min) revert ErrorsLib.ProposalFeeToLow(min);\n\t\tstable.transferFrom(_msgSender(), stable.curator(), fee);\n\t\t_;\n\t}\n\n\tconstructor(Stablecoin _stable) {\n\t\tstable = _stable;\n\t}\n}\n"},{"file_path":"@openzeppelin/contracts/utils/Panic.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Helper library for emitting standardized panic codes.\n *\n * ```solidity\n * contract Example {\n *      using Panic for uint256;\n *\n *      // Use any of the declared internal constants\n *      function foo() { Panic.GENERIC.panic(); }\n *\n *      // Alternatively\n *      function foo() { Panic.panic(Panic.GENERIC); }\n * }\n * ```\n *\n * Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].\n *\n * _Available since v5.1._\n */\n// slither-disable-next-line unused-state\nlibrary Panic {\n    /// @dev generic / unspecified error\n    uint256 internal constant GENERIC = 0x00;\n    /// @dev used by the assert() builtin\n    uint256 internal constant ASSERT = 0x01;\n    /// @dev arithmetic underflow or overflow\n    uint256 internal constant UNDER_OVERFLOW = 0x11;\n    /// @dev division or modulo by zero\n    uint256 internal constant DIVISION_BY_ZERO = 0x12;\n    /// @dev enum conversion error\n    uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;\n    /// @dev invalid encoding in storage\n    uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;\n    /// @dev empty array pop\n    uint256 internal constant EMPTY_ARRAY_POP = 0x31;\n    /// @dev array out of bounds access\n    uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;\n    /// @dev resource error (too large allocation or too large array)\n    uint256 internal constant RESOURCE_ERROR = 0x41;\n    /// @dev calling invalid internal function\n    uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;\n\n    /// @dev Reverts with a panic code. Recommended to use with\n    /// the internal constants with predefined codes.\n    function panic(uint256 code) internal pure {\n        assembly (\"memory-safe\") {\n            mstore(0x00, 0x4e487b71)\n            mstore(0x20, code)\n            revert(0x1c, 0x24)\n        }\n    }\n}\n"},{"file_path":"@openzeppelin/contracts/token/ERC20/IERC20.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC-20 standard as defined in the ERC.\n */\ninterface IERC20 {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the value of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the value of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves a `value` amount of tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 value) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n     * caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 value) external returns (bool);\n\n    /**\n     * @dev Moves a `value` amount of tokens from `from` to `to` using the\n     * allowance mechanism. `value` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n"},{"file_path":"@openzeppelin/contracts/utils/math/SignedMath.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.20;\n\nimport {SafeCast} from \"./SafeCast.sol\";\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n    /**\n     * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.\n     *\n     * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.\n     * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute\n     * one branch when needed, making this function more expensive.\n     */\n    function ternary(bool condition, int256 a, int256 b) internal pure returns (int256) {\n        unchecked {\n            // branchless ternary works because:\n            // b ^ (a ^ b) == a\n            // b ^ 0 == b\n            return b ^ ((a ^ b) * int256(SafeCast.toUint(condition)));\n        }\n    }\n\n    /**\n     * @dev Returns the largest of two signed numbers.\n     */\n    function max(int256 a, int256 b) internal pure returns (int256) {\n        return ternary(a > b, a, b);\n    }\n\n    /**\n     * @dev Returns the smallest of two signed numbers.\n     */\n    function min(int256 a, int256 b) internal pure returns (int256) {\n        return ternary(a < b, a, b);\n    }\n\n    /**\n     * @dev Returns the average of two signed numbers without overflow.\n     * The result is rounded towards zero.\n     */\n    function average(int256 a, int256 b) internal pure returns (int256) {\n        // Formula from the book \"Hacker's Delight\"\n        int256 x = (a & b) + ((a ^ b) >> 1);\n        return x + (int256(uint256(x) >> 255) & (a ^ b));\n    }\n\n    /**\n     * @dev Returns the absolute unsigned value of a signed value.\n     */\n    function abs(int256 n) internal pure returns (uint256) {\n        unchecked {\n            // Formula from the \"Bit Twiddling Hacks\" by Sean Eron Anderson.\n            // Since `n` is a signed integer, the generated bytecode will use the SAR opcode to perform the right shift,\n            // taking advantage of the most significant (or \"sign\" bit) in two's complement representation.\n            // This opcode adds new most significant bits set to the value of the previous most significant bit. As a result,\n            // the mask will either be `bytes32(0)` (if n is positive) or `~bytes32(0)` (if n is negative).\n            int256 mask = n >> 255;\n\n            // A `bytes32(0)` mask leaves the input unchanged, while a `~bytes32(0)` mask complements it.\n            return uint256((n + mask) ^ mask);\n        }\n    }\n}\n"},{"file_path":"contracts/morpho/helpers/IMetaMorphoV1_1.sol","source_code":"// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\nimport {IMorpho, Id, MarketParams} from './IMorpho.sol';\nimport {IERC4626} from '@openzeppelin/contracts/interfaces/IERC4626.sol';\nimport {IERC20Permit} from '@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol';\n\nimport {MarketConfig, PendingUint192, PendingAddress} from './PendingLib.sol';\n\nstruct MarketAllocation {\n\t/// @notice The market to allocate.\n\tMarketParams marketParams;\n\t/// @notice The amount of assets to allocate.\n\tuint256 assets;\n}\n\ninterface IMulticall {\n\tfunction multicall(bytes[] calldata) external returns (bytes[] memory);\n}\n\ninterface IOwnable {\n\tfunction owner() external view returns (address);\n\n\tfunction transferOwnership(address) external;\n\n\tfunction renounceOwnership() external;\n\n\tfunction acceptOwnership() external;\n\n\tfunction pendingOwner() external view returns (address);\n}\n\n/// @dev This interface is used for factorizing IMetaMorphoV1_1StaticTyping and IMetaMorphoV1_1.\n/// @dev Consider using the IMetaMorphoV1_1 interface instead of this one.\ninterface IMetaMorphoV1_1Base {\n\t/// @notice The address of the Morpho contract.\n\tfunction MORPHO() external view returns (IMorpho);\n\n\t/// @notice OpenZeppelin decimals offset used by the ERC4626 implementation.\n\t/// @dev Calculated to be max(0, 18 - underlyingDecimals).\n\t/// @dev When equal to zero (<=> token decimals >= 18), the protection against the inflation front-running attack on\n\t/// empty vault is low (see https://docs.openzeppelin.com/contracts/5.x/erc4626#inflation-attack). To protect\n\t/// against this attack, vault deployers should make an initial deposit of a non-trivial amount in the vault or\n\t/// depositors should check that the share price does not exceed a certain limit.\n\tfunction DECIMALS_OFFSET() external view returns (uint8);\n\n\t/// @notice The address of the curator.\n\tfunction curator() external view returns (address);\n\n\t/// @notice Stores whether an address is an allocator or not.\n\tfunction isAllocator(address target) external view returns (bool);\n\n\t/// @notice The current guardian. Can be set even without the timelock set.\n\tfunction guardian() external view returns (address);\n\n\t/// @notice The current fee.\n\tfunction fee() external view returns (uint96);\n\n\t/// @notice The fee recipient.\n\tfunction feeRecipient() external view returns (address);\n\n\t/// @notice The skim recipient.\n\tfunction skimRecipient() external view returns (address);\n\n\t/// @notice The current timelock.\n\tfunction timelock() external view returns (uint256);\n\n\t/// @dev Stores the order of markets on which liquidity is supplied upon deposit.\n\t/// @dev Can contain any market. A market is skipped as soon as its supply cap is reached.\n\tfunction supplyQueue(uint256) external view returns (Id);\n\n\t/// @notice Returns the length of the supply queue.\n\tfunction supplyQueueLength() external view returns (uint256);\n\n\t/// @dev Stores the order of markets from which liquidity is withdrawn upon withdrawal.\n\t/// @dev Always contain all non-zero cap markets as well as all markets on which the vault supplies liquidity,\n\t/// without duplicate.\n\tfunction withdrawQueue(uint256) external view returns (Id);\n\n\t/// @notice Returns the length of the withdraw queue.\n\tfunction withdrawQueueLength() external view returns (uint256);\n\n\t/// @notice Stores the total assets managed by this vault when the fee was last accrued.\n\tfunction lastTotalAssets() external view returns (uint256);\n\n\t/// @notice Stores the missing assets due to realized bad debt or forced market removal.\n\t/// @dev In order to cover those lost assets, it is advised to supply on behalf of address(1) on the vault\n\t/// (canonical method).\n\tfunction lostAssets() external view returns (uint256);\n\n\t/// @notice Submits a `newTimelock`.\n\t/// @dev Warning: Reverts if a timelock is already pending. Revoke the pending timelock to overwrite it.\n\t/// @dev In case the new timelock is higher than the current one, the timelock is set immediately.\n\tfunction submitTimelock(uint256 newTimelock) external;\n\n\t/// @notice Accepts the pending timelock.\n\tfunction acceptTimelock() external;\n\n\t/// @notice Revokes the pending timelock.\n\t/// @dev Does not revert if there is no pending timelock.\n\tfunction revokePendingTimelock() external;\n\n\t/// @notice Submits a `newSupplyCap` for the market defined by `marketParams`.\n\t/// @dev Warning: Reverts if a cap is already pending. Revoke the pending cap to overwrite it.\n\t/// @dev Warning: Reverts if a market removal is pending.\n\t/// @dev In case the new cap is lower than the current one, the cap is set immediately.\n\tfunction submitCap(MarketParams memory marketParams, uint256 newSupplyCap) external;\n\n\t/// @notice Accepts the pending cap of the market defined by `marketParams`.\n\tfunction acceptCap(MarketParams memory marketParams) external;\n\n\t/// @notice Revokes the pending cap of the market defined by `id`.\n\t/// @dev Does not revert if there is no pending cap.\n\tfunction revokePendingCap(Id id) external;\n\n\t/// @notice Submits a forced market removal from the vault, eventually losing all funds supplied to the market.\n\t/// @notice This forced removal is expected to be used as an emergency process in case a market constantly reverts.\n\t/// To softly remove a sane market, the curator role is expected to bundle a reallocation that empties the market\n\t/// first (using `reallocate`), followed by the removal of the market (using `updateWithdrawQueue`).\n\t/// @dev Warning: Reverts for non-zero cap or if there is a pending cap. Successfully submitting a zero cap will\n\t/// prevent such reverts.\n\tfunction submitMarketRemoval(MarketParams memory marketParams) external;\n\n\t/// @notice Revokes the pending removal of the market defined by `id`.\n\t/// @dev Does not revert if there is no pending market removal.\n\tfunction revokePendingMarketRemoval(Id id) external;\n\n\t/// @notice Sets the name of the vault.\n\tfunction setName(string memory newName) external;\n\n\t/// @notice Sets the symbol of the vault.\n\tfunction setSymbol(string memory newSymbol) external;\n\n\t/// @notice Submits a `newGuardian`.\n\t/// @notice Warning: a malicious guardian could disrupt the vault's operation, and would have the power to revoke\n\t/// any pending guardian.\n\t/// @dev In case there is no guardian, the gardian is set immediately.\n\t/// @dev Warning: Submitting a gardian will overwrite the current pending gardian.\n\tfunction submitGuardian(address newGuardian) external;\n\n\t/// @notice Accepts the pending guardian.\n\tfunction acceptGuardian() external;\n\n\t/// @notice Revokes the pending guardian.\n\tfunction revokePendingGuardian() external;\n\n\t/// @notice Skims the vault `token` balance to `skimRecipient`.\n\tfunction skim(address) external;\n\n\t/// @notice Sets `newAllocator` as an allocator or not (`newIsAllocator`).\n\tfunction setIsAllocator(address newAllocator, bool newIsAllocator) external;\n\n\t/// @notice Sets `curator` to `newCurator`.\n\tfunction setCurator(address newCurator) external;\n\n\t/// @notice Sets the `fee` to `newFee`.\n\tfunction setFee(uint256 newFee) external;\n\n\t/// @notice Sets `feeRecipient` to `newFeeRecipient`.\n\tfunction setFeeRecipient(address newFeeRecipient) external;\n\n\t/// @notice Sets `skimRecipient` to `newSkimRecipient`.\n\tfunction setSkimRecipient(address newSkimRecipient) external;\n\n\t/// @notice Sets `supplyQueue` to `newSupplyQueue`.\n\t/// @param newSupplyQueue is an array of enabled markets, and can contain duplicate markets, but it would only\n\t/// increase the cost of depositing to the vault.\n\tfunction setSupplyQueue(Id[] calldata newSupplyQueue) external;\n\n\t/// @notice Updates the withdraw queue. Some markets can be removed, but no market can be added.\n\t/// @notice Removing a market requires the vault to have 0 supply on it, or to have previously submitted a removal\n\t/// for this market (with the function `submitMarketRemoval`).\n\t/// @notice Warning: Anyone can supply on behalf of the vault so the call to `updateWithdrawQueue` that expects a\n\t/// market to be empty can be griefed by a front-run. To circumvent this, the allocator can simply bundle a\n\t/// reallocation that withdraws max from this market with a call to `updateWithdrawQueue`.\n\t/// @dev Warning: Removing a market with supply will decrease the fee accrued until one of the functions updating\n\t/// `lastTotalAssets` is triggered (deposit/mint/withdraw/redeem/setFee/setFeeRecipient).\n\t/// @dev Warning: `updateWithdrawQueue` is not idempotent. Submitting twice the same tx will change the queue twice.\n\t/// @param indexes The indexes of each market in the previous withdraw queue, in the new withdraw queue's order.\n\tfunction updateWithdrawQueue(uint256[] calldata indexes) external;\n\n\t/// @notice Reallocates the vault's liquidity so as to reach a given allocation of assets on each given market.\n\t/// @dev The behavior of the reallocation can be altered by state changes, including:\n\t/// - Deposits on the vault that supplies to markets that are expected to be supplied to during reallocation.\n\t/// - Withdrawals from the vault that withdraws from markets that are expected to be withdrawn from during\n\t/// reallocation.\n\t/// - Donations to the vault on markets that are expected to be supplied to during reallocation.\n\t/// - Withdrawals from markets that are expected to be withdrawn from during reallocation.\n\t/// @dev Sender is expected to pass `assets = type(uint256).max` with the last MarketAllocation of `allocations` to\n\t/// supply all the remaining withdrawn liquidity, which would ensure that `totalWithdrawn` = `totalSupplied`.\n\t/// @dev A supply in a reallocation step will make the reallocation revert if the amount is greater than the net\n\t/// amount from previous steps (i.e. total withdrawn minus total supplied).\n\tfunction reallocate(MarketAllocation[] calldata allocations) external;\n}\n\n/// @dev This interface is inherited by MetaMorphoV1_1 so that function signatures are checked by the compiler.\n/// @dev Consider using the IMetaMorphoV1_1 interface instead of this one.\ninterface IMetaMorphoV1_1StaticTyping is IMetaMorphoV1_1Base {\n\t/// @notice Returns the current configuration of each market.\n\tfunction config(Id) external view returns (uint184 cap, bool enabled, uint64 removableAt);\n\n\t/// @notice Returns the pending guardian.\n\tfunction pendingGuardian() external view returns (address guardian, uint64 validAt);\n\n\t/// @notice Returns the pending cap for each market.\n\tfunction pendingCap(Id) external view returns (uint192 value, uint64 validAt);\n\n\t/// @notice Returns the pending timelock.\n\tfunction pendingTimelock() external view returns (uint192 value, uint64 validAt);\n}\n\n/// @title IMetaMorphoV1_1\n/// @author Morpho Labs\n/// @custom:contact security@morpho.org\n/// @dev Use this interface for MetaMorphoV1_1 to have access to all the functions with the appropriate function\n/// signatures.\ninterface IMetaMorphoV1_1 is IMetaMorphoV1_1Base, IERC4626, IERC20Permit, IOwnable, IMulticall {\n\t/// @notice Returns the current configuration of each market.\n\tfunction config(Id) external view returns (MarketConfig memory);\n\n\t/// @notice Returns the pending guardian.\n\tfunction pendingGuardian() external view returns (PendingAddress memory);\n\n\t/// @notice Returns the pending cap for each market.\n\tfunction pendingCap(Id) external view returns (PendingUint192 memory);\n\n\t/// @notice Returns the pending timelock.\n\tfunction pendingTimelock() external view returns (PendingUint192 memory);\n}\n"},{"file_path":"@openzeppelin/contracts/interfaces/IERC4626.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC4626.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../token/ERC20/IERC20.sol\";\nimport {IERC20Metadata} from \"../token/ERC20/extensions/IERC20Metadata.sol\";\n\n/**\n * @dev Interface of the ERC-4626 \"Tokenized Vault Standard\", as defined in\n * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].\n */\ninterface IERC4626 is IERC20, IERC20Metadata {\n    event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);\n\n    event Withdraw(\n        address indexed sender,\n        address indexed receiver,\n        address indexed owner,\n        uint256 assets,\n        uint256 shares\n    );\n\n    /**\n     * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.\n     *\n     * - MUST be an ERC-20 token contract.\n     * - MUST NOT revert.\n     */\n    function asset() external view returns (address assetTokenAddress);\n\n    /**\n     * @dev Returns the total amount of the underlying asset that is “managed” by Vault.\n     *\n     * - SHOULD include any compounding that occurs from yield.\n     * - MUST be inclusive of any fees that are charged against assets in the Vault.\n     * - MUST NOT revert.\n     */\n    function totalAssets() external view returns (uint256 totalManagedAssets);\n\n    /**\n     * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal\n     * scenario where all the conditions are met.\n     *\n     * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\n     * - MUST NOT show any variations depending on the caller.\n     * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\n     * - MUST NOT revert.\n     *\n     * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the\n     * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and\n     * from.\n     */\n    function convertToShares(uint256 assets) external view returns (uint256 shares);\n\n    /**\n     * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal\n     * scenario where all the conditions are met.\n     *\n     * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\n     * - MUST NOT show any variations depending on the caller.\n     * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\n     * - MUST NOT revert.\n     *\n     * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the\n     * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and\n     * from.\n     */\n    function convertToAssets(uint256 shares) external view returns (uint256 assets);\n\n    /**\n     * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,\n     * through a deposit call.\n     *\n     * - MUST return a limited value if receiver is subject to some deposit limit.\n     * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.\n     * - MUST NOT revert.\n     */\n    function maxDeposit(address receiver) external view returns (uint256 maxAssets);\n\n    /**\n     * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given\n     * current on-chain conditions.\n     *\n     * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit\n     *   call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called\n     *   in the same transaction.\n     * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the\n     *   deposit would be accepted, regardless if the user has enough tokens approved, etc.\n     * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\n     * - MUST NOT revert.\n     *\n     * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in\n     * share price or some other type of condition, meaning the depositor will lose assets by depositing.\n     */\n    function previewDeposit(uint256 assets) external view returns (uint256 shares);\n\n    /**\n     * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.\n     *\n     * - MUST emit the Deposit event.\n     * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n     *   deposit execution, and are accounted for during deposit.\n     * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not\n     *   approving enough underlying tokens to the Vault contract, etc).\n     *\n     * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.\n     */\n    function deposit(uint256 assets, address receiver) external returns (uint256 shares);\n\n    /**\n     * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.\n     * - MUST return a limited value if receiver is subject to some mint limit.\n     * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.\n     * - MUST NOT revert.\n     */\n    function maxMint(address receiver) external view returns (uint256 maxShares);\n\n    /**\n     * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given\n     * current on-chain conditions.\n     *\n     * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call\n     *   in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the\n     *   same transaction.\n     * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint\n     *   would be accepted, regardless if the user has enough tokens approved, etc.\n     * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\n     * - MUST NOT revert.\n     *\n     * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in\n     * share price or some other type of condition, meaning the depositor will lose assets by minting.\n     */\n    function previewMint(uint256 shares) external view returns (uint256 assets);\n\n    /**\n     * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.\n     *\n     * - MUST emit the Deposit event.\n     * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint\n     *   execution, and are accounted for during mint.\n     * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not\n     *   approving enough underlying tokens to the Vault contract, etc).\n     *\n     * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.\n     */\n    function mint(uint256 shares, address receiver) external returns (uint256 assets);\n\n    /**\n     * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the\n     * Vault, through a withdraw call.\n     *\n     * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\n     * - MUST NOT revert.\n     */\n    function maxWithdraw(address owner) external view returns (uint256 maxAssets);\n\n    /**\n     * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,\n     * given current on-chain conditions.\n     *\n     * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw\n     *   call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if\n     *   called\n     *   in the same transaction.\n     * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though\n     *   the withdrawal would be accepted, regardless if the user has enough shares, etc.\n     * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\n     * - MUST NOT revert.\n     *\n     * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in\n     * share price or some other type of condition, meaning the depositor will lose assets by depositing.\n     */\n    function previewWithdraw(uint256 assets) external view returns (uint256 shares);\n\n    /**\n     * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.\n     *\n     * - MUST emit the Withdraw event.\n     * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n     *   withdraw execution, and are accounted for during withdraw.\n     * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner\n     *   not having enough shares, etc).\n     *\n     * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\n     * Those methods should be performed separately.\n     */\n    function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);\n\n    /**\n     * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,\n     * through a redeem call.\n     *\n     * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\n     * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.\n     * - MUST NOT revert.\n     */\n    function maxRedeem(address owner) external view returns (uint256 maxShares);\n\n    /**\n     * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,\n     * given current on-chain conditions.\n     *\n     * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call\n     *   in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the\n     *   same transaction.\n     * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the\n     *   redemption would be accepted, regardless if the user has enough shares, etc.\n     * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\n     * - MUST NOT revert.\n     *\n     * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in\n     * share price or some other type of condition, meaning the depositor will lose assets by redeeming.\n     */\n    function previewRedeem(uint256 shares) external view returns (uint256 assets);\n\n    /**\n     * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.\n     *\n     * - MUST emit the Withdraw event.\n     * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n     *   redeem execution, and are accounted for during redeem.\n     * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner\n     *   not having enough shares, etc).\n     *\n     * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\n     * Those methods should be performed separately.\n     */\n    function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);\n}\n"},{"file_path":"@openzeppelin/contracts/utils/Nonces.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Nonces.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides tracking nonces for addresses. Nonces will only increment.\n */\nabstract contract Nonces {\n    /**\n     * @dev The nonce used for an `account` is not the expected current nonce.\n     */\n    error InvalidAccountNonce(address account, uint256 currentNonce);\n\n    mapping(address account => uint256) private _nonces;\n\n    /**\n     * @dev Returns the next unused nonce for an address.\n     */\n    function nonces(address owner) public view virtual returns (uint256) {\n        return _nonces[owner];\n    }\n\n    /**\n     * @dev Consumes a nonce.\n     *\n     * Returns the current value and increments nonce.\n     */\n    function _useNonce(address owner) internal virtual returns (uint256) {\n        // For each account, the nonce has an initial value of 0, can only be incremented by one, and cannot be\n        // decremented or reset. This guarantees that the nonce never overflows.\n        unchecked {\n            // It is important to do x++ and not ++x here.\n            return _nonces[owner]++;\n        }\n    }\n\n    /**\n     * @dev Same as {_useNonce} but checking that `nonce` is the next valid for `owner`.\n     */\n    function _useCheckedNonce(address owner, uint256 nonce) internal virtual {\n        uint256 current = _useNonce(owner);\n        if (nonce != current) {\n            revert InvalidAccountNonce(owner, current);\n        }\n    }\n}\n"},{"file_path":"@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/cryptography/MessageHashUtils.sol)\n\npragma solidity ^0.8.20;\n\nimport {Strings} from \"../Strings.sol\";\n\n/**\n * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.\n *\n * The library provides methods for generating a hash of a message that conforms to the\n * https://eips.ethereum.org/EIPS/eip-191[ERC-191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]\n * specifications.\n */\nlibrary MessageHashUtils {\n    /**\n     * @dev Returns the keccak256 digest of an ERC-191 signed data with version\n     * `0x45` (`personal_sign` messages).\n     *\n     * The digest is calculated by prefixing a bytes32 `messageHash` with\n     * `\"\\x19Ethereum Signed Message:\\n32\"` and hashing the result. It corresponds with the\n     * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n     *\n     * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with\n     * keccak256, although any bytes32 value can be safely used because the final digest will\n     * be re-hashed.\n     *\n     * See {ECDSA-recover}.\n     */\n    function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {\n        assembly (\"memory-safe\") {\n            mstore(0x00, \"\\x19Ethereum Signed Message:\\n32\") // 32 is the bytes-length of messageHash\n            mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix\n            digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)\n        }\n    }\n\n    /**\n     * @dev Returns the keccak256 digest of an ERC-191 signed data with version\n     * `0x45` (`personal_sign` messages).\n     *\n     * The digest is calculated by prefixing an arbitrary `message` with\n     * `\"\\x19Ethereum Signed Message:\\n\" + len(message)` and hashing the result. It corresponds with the\n     * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n     *\n     * See {ECDSA-recover}.\n     */\n    function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {\n        return\n            keccak256(bytes.concat(\"\\x19Ethereum Signed Message:\\n\", bytes(Strings.toString(message.length)), message));\n    }\n\n    /**\n     * @dev Returns the keccak256 digest of an ERC-191 signed data with version\n     * `0x00` (data with intended validator).\n     *\n     * The digest is calculated by prefixing an arbitrary `data` with `\"\\x19\\x00\"` and the intended\n     * `validator` address. Then hashing the result.\n     *\n     * See {ECDSA-recover}.\n     */\n    function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {\n        return keccak256(abi.encodePacked(hex\"19_00\", validator, data));\n    }\n\n    /**\n     * @dev Returns the keccak256 digest of an EIP-712 typed data (ERC-191 version `0x01`).\n     *\n     * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with\n     * `\\x19\\x01` and hashing the result. It corresponds to the hash signed by the\n     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.\n     *\n     * See {ECDSA-recover}.\n     */\n    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {\n        assembly (\"memory-safe\") {\n            let ptr := mload(0x40)\n            mstore(ptr, hex\"19_01\")\n            mstore(add(ptr, 0x02), domainSeparator)\n            mstore(add(ptr, 0x22), structHash)\n            digest := keccak256(ptr, 0x42)\n        }\n    }\n}\n"},{"file_path":"contracts/reward/RewardDistributionV1.sol","source_code":"// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity ^0.8.20;\n\nimport {Math} from '@openzeppelin/contracts/utils/math/Math.sol';\n\nimport {IStablecoinModifier, Stablecoin} from '../stablecoin/IStablecoinModifier.sol';\nimport {ErrorsLib} from '../stablecoin/libraries/ErrorsLib.sol';\n\nabstract contract RewardDistributionV1 is IStablecoinModifier {\n\tusing Math for uint256;\n\n\taddress[5] public receivers;\n\tuint32[5] public weights;\n\tuint256 public totalWeights;\n\n\taddress[5] public pendingReceivers;\n\tuint32[5] public pendingWeights;\n\tuint256 public pendingValidAt;\n\n\t// ---------------------------------------------------------------------------------------\n\n\tevent SubmitDistribution(address indexed caller, address[5] receivers, uint32[5] weights, uint256 timelock);\n\tevent RevokeDistribution(address indexed caller);\n\tevent SetDistribution(address indexed caller);\n\tevent Distribution(address indexed receiver, uint256 amount, uint256 ratio);\n\n\t// ---------------------------------------------------------------------------------------\n\n\tconstructor(Stablecoin _stable, address[5] memory _receivers, uint32[5] memory _weights) IStablecoinModifier(_stable) {\n\t\t_setDistribution(_receivers, _weights);\n\t}\n\n\t// ---------------------------------------------------------------------------------------\n\n\tfunction setDistribution(address[5] calldata _receivers, uint32[5] calldata _weights) external onlyCurator {\n\t\tif (pendingValidAt != 0) revert ErrorsLib.AlreadyPending();\n\n\t\tif (receivers[0] == address(0)) {\n\t\t\t_setDistribution(_receivers, _weights);\n\t\t} else {\n\t\t\tpendingReceivers = _receivers;\n\t\t\tpendingWeights = _weights;\n\t\t\tpendingValidAt = block.timestamp + stable.timelock();\n\t\t\temit SubmitDistribution(_msgSender(), _receivers, _weights, pendingValidAt);\n\t\t}\n\t}\n\n\tfunction revokePendingDistribution() external onlyCuratorOrGuardian {\n\t\tif (pendingValidAt == 0) revert ErrorsLib.NoPendingValue();\n\t\temit RevokeDistribution(_msgSender());\n\t\t_cleanUpPending();\n\t}\n\n\tfunction applyDistribution() external afterTimelock(pendingValidAt) {\n\t\t_setDistribution(pendingReceivers, pendingWeights);\n\t}\n\n\tfunction _setDistribution(address[5] memory _receivers, uint32[5] memory _weights) internal {\n\t\t// reset totalWeights\n\t\ttotalWeights = 0;\n\n\t\t// update total weight\n\t\tfor (uint32 i = 0; i < 5; i++) {\n\t\t\tif (_receivers[i] == address(0)) continue;\n\t\t\ttotalWeights += _weights[i];\n\t\t}\n\n\t\t// update distribution\n\t\treceivers = _receivers;\n\t\tweights = _weights;\n\n\t\t// emit event\n\t\temit SetDistribution(_msgSender());\n\n\t\t_cleanUpPending();\n\t}\n\n\tfunction _cleanUpPending() internal {\n\t\tdelete pendingReceivers;\n\t\tdelete pendingWeights;\n\t\tdelete pendingValidAt;\n\t}\n\n\t// ---------------------------------------------------------------------------------------\n\n\tfunction _distribute() internal {\n\t\t// distribute all stables\n\t\tuint256 amount = stable.balanceOf(address(this));\n\n\t\t// distribution is not available\n\t\tif (totalWeights == 0 || amount == 0) return;\n\n\t\tfor (uint256 i = 0; i < 5; i++) {\n\t\t\taddress receiver = receivers[i];\n\t\t\tuint256 weight = weights[i];\n\n\t\t\t// end distribution\n\t\t\tif (receiver == address(0)) return;\n\n\t\t\t// distribute weighted split\n\t\t\tuint256 split = (weight * amount) / totalWeights;\n\n\t\t\t// distribute revenue split\n\t\t\tstable.transfer(receiver, split);\n\n\t\t\t// last weighted ratio might be inconsistant, due to remaining assets distribution\n\t\t\temit Distribution(receiver, split, (weight * 1 ether) / totalWeights);\n\t\t}\n\t}\n}\n"},{"file_path":"contracts/stablecoin/libraries/PendingLib.sol","source_code":"// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity ^0.8.20;\n\nstruct PendingUint192 {\n\t/// @notice The pending value to set.\n\tuint192 value;\n\t/// @notice The timestamp at which the pending value becomes valid.\n\tuint64 validAt;\n}\n\nstruct PendingAddress {\n\t/// @notice The pending value to set.\n\taddress value;\n\t/// @notice The timestamp at which the pending value becomes valid.\n\tuint64 validAt;\n}\n\n/// @title PendingLib\n/// @author Morpho Labs\n/// @custom:contact security@morpho.org\n/// @notice Library to manage pending values and their validity timestamp.\nlibrary PendingLib {\n\t/// @dev Updates `pending`'s value to `newValue` and its corresponding `validAt` timestamp.\n\t/// @dev Assumes `timelock` <= `MAX_TIMELOCK`.\n\tfunction update(PendingUint192 storage pending, uint184 newValue, uint256 timelock) internal {\n\t\tpending.value = newValue;\n\t\t// Safe \"unchecked\" cast because timelock <= MAX_TIMELOCK.\n\t\tpending.validAt = uint64(block.timestamp + timelock);\n\t}\n\n\t/// @dev Updates `pending`'s value to `newValue` and its corresponding `validAt` timestamp.\n\t/// @dev Assumes `timelock` <= `MAX_TIMELOCK`.\n\tfunction update(PendingAddress storage pending, address newValue, uint256 timelock) internal {\n\t\tpending.value = newValue;\n\t\t// Safe \"unchecked\" cast because timelock <= MAX_TIMELOCK.\n\t\tpending.validAt = uint64(block.timestamp + timelock);\n\t}\n}\n"},{"file_path":"@openzeppelin/contracts/utils/math/Math.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.20;\n\nimport {Panic} from \"../Panic.sol\";\nimport {SafeCast} from \"./SafeCast.sol\";\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n    enum Rounding {\n        Floor, // Toward negative infinity\n        Ceil, // Toward positive infinity\n        Trunc, // Toward zero\n        Expand // Away from zero\n    }\n\n    /**\n     * @dev Returns the addition of two unsigned integers, with an success flag (no overflow).\n     */\n    function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n        unchecked {\n            uint256 c = a + b;\n            if (c < a) return (false, 0);\n            return (true, c);\n        }\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, with an success flag (no overflow).\n     */\n    function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n        unchecked {\n            if (b > a) return (false, 0);\n            return (true, a - b);\n        }\n    }\n\n    /**\n     * @dev Returns the multiplication of two unsigned integers, with an success flag (no overflow).\n     */\n    function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n        unchecked {\n            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n            // benefit is lost if 'b' is also tested.\n            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n            if (a == 0) return (true, 0);\n            uint256 c = a * b;\n            if (c / a != b) return (false, 0);\n            return (true, c);\n        }\n    }\n\n    /**\n     * @dev Returns the division of two unsigned integers, with a success flag (no division by zero).\n     */\n    function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n        unchecked {\n            if (b == 0) return (false, 0);\n            return (true, a / b);\n        }\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).\n     */\n    function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n        unchecked {\n            if (b == 0) return (false, 0);\n            return (true, a % b);\n        }\n    }\n\n    /**\n     * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.\n     *\n     * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.\n     * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute\n     * one branch when needed, making this function more expensive.\n     */\n    function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {\n        unchecked {\n            // branchless ternary works because:\n            // b ^ (a ^ b) == a\n            // b ^ 0 == b\n            return b ^ ((a ^ b) * SafeCast.toUint(condition));\n        }\n    }\n\n    /**\n     * @dev Returns the largest of two numbers.\n     */\n    function max(uint256 a, uint256 b) internal pure returns (uint256) {\n        return ternary(a > b, a, b);\n    }\n\n    /**\n     * @dev Returns the smallest of two numbers.\n     */\n    function min(uint256 a, uint256 b) internal pure returns (uint256) {\n        return ternary(a < b, a, b);\n    }\n\n    /**\n     * @dev Returns the average of two numbers. The result is rounded towards\n     * zero.\n     */\n    function average(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b) / 2 can overflow.\n        return (a & b) + (a ^ b) / 2;\n    }\n\n    /**\n     * @dev Returns the ceiling of the division of two numbers.\n     *\n     * This differs from standard division with `/` in that it rounds towards infinity instead\n     * of rounding towards zero.\n     */\n    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n        if (b == 0) {\n            // Guarantee the same behavior as in a regular Solidity division.\n            Panic.panic(Panic.DIVISION_BY_ZERO);\n        }\n\n        // The following calculation ensures accurate ceiling division without overflow.\n        // Since a is non-zero, (a - 1) / b will not overflow.\n        // The largest possible result occurs when (a - 1) / b is type(uint256).max,\n        // but the largest value we can obtain is type(uint256).max - 1, which happens\n        // when a = type(uint256).max and b = 1.\n        unchecked {\n            return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);\n        }\n    }\n\n    /**\n     * @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or\n     * denominator == 0.\n     *\n     * Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by\n     * Uniswap Labs also under MIT license.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n        unchecked {\n            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2²⁵⁶ and mod 2²⁵⁶ - 1, then use\n            // the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n            // variables such that product = prod1 * 2²⁵⁶ + prod0.\n            uint256 prod0 = x * y; // Least significant 256 bits of the product\n            uint256 prod1; // Most significant 256 bits of the product\n            assembly {\n                let mm := mulmod(x, y, not(0))\n                prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n            }\n\n            // Handle non-overflow cases, 256 by 256 division.\n            if (prod1 == 0) {\n                // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n                // The surrounding unchecked block does not change this fact.\n                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n                return prod0 / denominator;\n            }\n\n            // Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0.\n            if (denominator <= prod1) {\n                Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));\n            }\n\n            ///////////////////////////////////////////////\n            // 512 by 256 division.\n            ///////////////////////////////////////////////\n\n            // Make division exact by subtracting the remainder from [prod1 prod0].\n            uint256 remainder;\n            assembly {\n                // Compute remainder using mulmod.\n                remainder := mulmod(x, y, denominator)\n\n                // Subtract 256 bit number from 512 bit number.\n                prod1 := sub(prod1, gt(remainder, prod0))\n                prod0 := sub(prod0, remainder)\n            }\n\n            // Factor powers of two out of denominator and compute largest power of two divisor of denominator.\n            // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.\n\n            uint256 twos = denominator & (0 - denominator);\n            assembly {\n                // Divide denominator by twos.\n                denominator := div(denominator, twos)\n\n                // Divide [prod1 prod0] by twos.\n                prod0 := div(prod0, twos)\n\n                // Flip twos such that it is 2²⁵⁶ / twos. If twos is zero, then it becomes one.\n                twos := add(div(sub(0, twos), twos), 1)\n            }\n\n            // Shift in bits from prod1 into prod0.\n            prod0 |= prod1 * twos;\n\n            // Invert denominator mod 2²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such\n            // that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for\n            // four bits. That is, denominator * inv ≡ 1 mod 2⁴.\n            uint256 inverse = (3 * denominator) ^ 2;\n\n            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also\n            // works in modular arithmetic, doubling the correct bits in each step.\n            inverse *= 2 - denominator * inverse; // inverse mod 2⁸\n            inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶\n            inverse *= 2 - denominator * inverse; // inverse mod 2³²\n            inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴\n            inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸\n            inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶\n\n            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n            // This will give us the correct result modulo 2²⁵⁶. Since the preconditions guarantee that the outcome is\n            // less than 2²⁵⁶, this is the final result. We don't need to compute the high bits of the result and prod1\n            // is no longer required.\n            result = prod0 * inverse;\n            return result;\n        }\n    }\n\n    /**\n     * @dev Calculates x * y / denominator with full precision, following the selected rounding direction.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n        return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);\n    }\n\n    /**\n     * @dev Calculate the modular multiplicative inverse of a number in Z/nZ.\n     *\n     * If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.\n     * If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.\n     *\n     * If the input value is not inversible, 0 is returned.\n     *\n     * NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the\n     * inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.\n     */\n    function invMod(uint256 a, uint256 n) internal pure returns (uint256) {\n        unchecked {\n            if (n == 0) return 0;\n\n            // The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)\n            // Used to compute integers x and y such that: ax + ny = gcd(a, n).\n            // When the gcd is 1, then the inverse of a modulo n exists and it's x.\n            // ax + ny = 1\n            // ax = 1 + (-y)n\n            // ax ≡ 1 (mod n) # x is the inverse of a modulo n\n\n            // If the remainder is 0 the gcd is n right away.\n            uint256 remainder = a % n;\n            uint256 gcd = n;\n\n            // Therefore the initial coefficients are:\n            // ax + ny = gcd(a, n) = n\n            // 0a + 1n = n\n            int256 x = 0;\n            int256 y = 1;\n\n            while (remainder != 0) {\n                uint256 quotient = gcd / remainder;\n\n                (gcd, remainder) = (\n                    // The old remainder is the next gcd to try.\n                    remainder,\n                    // Compute the next remainder.\n                    // Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd\n                    // where gcd is at most n (capped to type(uint256).max)\n                    gcd - remainder * quotient\n                );\n\n                (x, y) = (\n                    // Increment the coefficient of a.\n                    y,\n                    // Decrement the coefficient of n.\n                    // Can overflow, but the result is casted to uint256 so that the\n                    // next value of y is \"wrapped around\" to a value between 0 and n - 1.\n                    x - y * int256(quotient)\n                );\n            }\n\n            if (gcd != 1) return 0; // No inverse exists.\n            return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.\n        }\n    }\n\n    /**\n     * @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.\n     *\n     * From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is\n     * prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that\n     * `a**(p-2)` is the modular multiplicative inverse of a in Fp.\n     *\n     * NOTE: this function does NOT check that `p` is a prime greater than `2`.\n     */\n    function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {\n        unchecked {\n            return Math.modExp(a, p - 2, p);\n        }\n    }\n\n    /**\n     * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)\n     *\n     * Requirements:\n     * - modulus can't be zero\n     * - underlying staticcall to precompile must succeed\n     *\n     * IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make\n     * sure the chain you're using it on supports the precompiled contract for modular exponentiation\n     * at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,\n     * the underlying function will succeed given the lack of a revert, but the result may be incorrectly\n     * interpreted as 0.\n     */\n    function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {\n        (bool success, uint256 result) = tryModExp(b, e, m);\n        if (!success) {\n            Panic.panic(Panic.DIVISION_BY_ZERO);\n        }\n        return result;\n    }\n\n    /**\n     * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).\n     * It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying\n     * to operate modulo 0 or if the underlying precompile reverted.\n     *\n     * IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain\n     * you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in\n     * https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack\n     * of a revert, but the result may be incorrectly interpreted as 0.\n     */\n    function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {\n        if (m == 0) return (false, 0);\n        assembly (\"memory-safe\") {\n            let ptr := mload(0x40)\n            // | Offset    | Content    | Content (Hex)                                                      |\n            // |-----------|------------|--------------------------------------------------------------------|\n            // | 0x00:0x1f | size of b  | 0x0000000000000000000000000000000000000000000000000000000000000020 |\n            // | 0x20:0x3f | size of e  | 0x0000000000000000000000000000000000000000000000000000000000000020 |\n            // | 0x40:0x5f | size of m  | 0x0000000000000000000000000000000000000000000000000000000000000020 |\n            // | 0x60:0x7f | value of b | 0x<.............................................................b> |\n            // | 0x80:0x9f | value of e | 0x<.............................................................e> |\n            // | 0xa0:0xbf | value of m | 0x<.............................................................m> |\n            mstore(ptr, 0x20)\n            mstore(add(ptr, 0x20), 0x20)\n            mstore(add(ptr, 0x40), 0x20)\n            mstore(add(ptr, 0x60), b)\n            mstore(add(ptr, 0x80), e)\n            mstore(add(ptr, 0xa0), m)\n\n            // Given the result < m, it's guaranteed to fit in 32 bytes,\n            // so we can use the memory scratch space located at offset 0.\n            success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)\n            result := mload(0x00)\n        }\n    }\n\n    /**\n     * @dev Variant of {modExp} that supports inputs of arbitrary length.\n     */\n    function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {\n        (bool success, bytes memory result) = tryModExp(b, e, m);\n        if (!success) {\n            Panic.panic(Panic.DIVISION_BY_ZERO);\n        }\n        return result;\n    }\n\n    /**\n     * @dev Variant of {tryModExp} that supports inputs of arbitrary length.\n     */\n    function tryModExp(\n        bytes memory b,\n        bytes memory e,\n        bytes memory m\n    ) internal view returns (bool success, bytes memory result) {\n        if (_zeroBytes(m)) return (false, new bytes(0));\n\n        uint256 mLen = m.length;\n\n        // Encode call args in result and move the free memory pointer\n        result = abi.encodePacked(b.length, e.length, mLen, b, e, m);\n\n        assembly (\"memory-safe\") {\n            let dataPtr := add(result, 0x20)\n            // Write result on top of args to avoid allocating extra memory.\n            success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)\n            // Overwrite the length.\n            // result.length > returndatasize() is guaranteed because returndatasize() == m.length\n            mstore(result, mLen)\n            // Set the memory pointer after the returned data.\n            mstore(0x40, add(dataPtr, mLen))\n        }\n    }\n\n    /**\n     * @dev Returns whether the provided byte array is zero.\n     */\n    function _zeroBytes(bytes memory byteArray) private pure returns (bool) {\n        for (uint256 i = 0; i < byteArray.length; ++i) {\n            if (byteArray[i] != 0) {\n                return false;\n            }\n        }\n        return true;\n    }\n\n    /**\n     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded\n     * towards zero.\n     *\n     * This method is based on Newton's method for computing square roots; the algorithm is restricted to only\n     * using integer operations.\n     */\n    function sqrt(uint256 a) internal pure returns (uint256) {\n        unchecked {\n            // Take care of easy edge cases when a == 0 or a == 1\n            if (a <= 1) {\n                return a;\n            }\n\n            // In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a\n            // sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between\n            // the current value as `ε_n = | x_n - sqrt(a) |`.\n            //\n            // For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root\n            // of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is\n            // bigger than any uint256.\n            //\n            // By noticing that\n            // `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`\n            // we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar\n            // to the msb function.\n            uint256 aa = a;\n            uint256 xn = 1;\n\n            if (aa >= (1 << 128)) {\n                aa >>= 128;\n                xn <<= 64;\n            }\n            if (aa >= (1 << 64)) {\n                aa >>= 64;\n                xn <<= 32;\n            }\n            if (aa >= (1 << 32)) {\n                aa >>= 32;\n                xn <<= 16;\n            }\n            if (aa >= (1 << 16)) {\n                aa >>= 16;\n                xn <<= 8;\n            }\n            if (aa >= (1 << 8)) {\n                aa >>= 8;\n                xn <<= 4;\n            }\n            if (aa >= (1 << 4)) {\n                aa >>= 4;\n                xn <<= 2;\n            }\n            if (aa >= (1 << 2)) {\n                xn <<= 1;\n            }\n\n            // We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).\n            //\n            // We can refine our estimation by noticing that the middle of that interval minimizes the error.\n            // If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).\n            // This is going to be our x_0 (and ε_0)\n            xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)\n\n            // From here, Newton's method give us:\n            // x_{n+1} = (x_n + a / x_n) / 2\n            //\n            // One should note that:\n            // x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a\n            //              = ((x_n² + a) / (2 * x_n))² - a\n            //              = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a\n            //              = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)\n            //              = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)\n            //              = (x_n² - a)² / (2 * x_n)²\n            //              = ((x_n² - a) / (2 * x_n))²\n            //              ≥ 0\n            // Which proves that for all n ≥ 1, sqrt(a) ≤ x_n\n            //\n            // This gives us the proof of quadratic convergence of the sequence:\n            // ε_{n+1} = | x_{n+1} - sqrt(a) |\n            //         = | (x_n + a / x_n) / 2 - sqrt(a) |\n            //         = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |\n            //         = | (x_n - sqrt(a))² / (2 * x_n) |\n            //         = | ε_n² / (2 * x_n) |\n            //         = ε_n² / | (2 * x_n) |\n            //\n            // For the first iteration, we have a special case where x_0 is known:\n            // ε_1 = ε_0² / | (2 * x_0) |\n            //     ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))\n            //     ≤ 2**(2*e-4) / (3 * 2**(e-1))\n            //     ≤ 2**(e-3) / 3\n            //     ≤ 2**(e-3-log2(3))\n            //     ≤ 2**(e-4.5)\n            //\n            // For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:\n            // ε_{n+1} = ε_n² / | (2 * x_n) |\n            //         ≤ (2**(e-k))² / (2 * 2**(e-1))\n            //         ≤ 2**(2*e-2*k) / 2**e\n            //         ≤ 2**(e-2*k)\n            xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5)  -- special case, see above\n            xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9)    -- general case with k = 4.5\n            xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18)   -- general case with k = 9\n            xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36)   -- general case with k = 18\n            xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72)   -- general case with k = 36\n            xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144)  -- general case with k = 72\n\n            // Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision\n            // ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either\n            // sqrt(a) or sqrt(a) + 1.\n            return xn - SafeCast.toUint(xn > a / xn);\n        }\n    }\n\n    /**\n     * @dev Calculates sqrt(a), following the selected rounding direction.\n     */\n    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = sqrt(a);\n            return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 2 of a positive value rounded towards zero.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        uint256 exp;\n        unchecked {\n            exp = 128 * SafeCast.toUint(value > (1 << 128) - 1);\n            value >>= exp;\n            result += exp;\n\n            exp = 64 * SafeCast.toUint(value > (1 << 64) - 1);\n            value >>= exp;\n            result += exp;\n\n            exp = 32 * SafeCast.toUint(value > (1 << 32) - 1);\n            value >>= exp;\n            result += exp;\n\n            exp = 16 * SafeCast.toUint(value > (1 << 16) - 1);\n            value >>= exp;\n            result += exp;\n\n            exp = 8 * SafeCast.toUint(value > (1 << 8) - 1);\n            value >>= exp;\n            result += exp;\n\n            exp = 4 * SafeCast.toUint(value > (1 << 4) - 1);\n            value >>= exp;\n            result += exp;\n\n            exp = 2 * SafeCast.toUint(value > (1 << 2) - 1);\n            value >>= exp;\n            result += exp;\n\n            result += SafeCast.toUint(value > 1);\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log2(value);\n            return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 10 of a positive value rounded towards zero.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >= 10 ** 64) {\n                value /= 10 ** 64;\n                result += 64;\n            }\n            if (value >= 10 ** 32) {\n                value /= 10 ** 32;\n                result += 32;\n            }\n            if (value >= 10 ** 16) {\n                value /= 10 ** 16;\n                result += 16;\n            }\n            if (value >= 10 ** 8) {\n                value /= 10 ** 8;\n                result += 8;\n            }\n            if (value >= 10 ** 4) {\n                value /= 10 ** 4;\n                result += 4;\n            }\n            if (value >= 10 ** 2) {\n                value /= 10 ** 2;\n                result += 2;\n            }\n            if (value >= 10 ** 1) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log10(value);\n            return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 256 of a positive value rounded towards zero.\n     * Returns 0 if given 0.\n     *\n     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n     */\n    function log256(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        uint256 isGt;\n        unchecked {\n            isGt = SafeCast.toUint(value > (1 << 128) - 1);\n            value >>= isGt * 128;\n            result += isGt * 16;\n\n            isGt = SafeCast.toUint(value > (1 << 64) - 1);\n            value >>= isGt * 64;\n            result += isGt * 8;\n\n            isGt = SafeCast.toUint(value > (1 << 32) - 1);\n            value >>= isGt * 32;\n            result += isGt * 4;\n\n            isGt = SafeCast.toUint(value > (1 << 16) - 1);\n            value >>= isGt * 16;\n            result += isGt * 2;\n\n            result += SafeCast.toUint(value > (1 << 8) - 1);\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log256(value);\n            return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);\n        }\n    }\n\n    /**\n     * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.\n     */\n    function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\n        return uint8(rounding) % 2 == 1;\n    }\n}\n"},{"file_path":"contracts/stablecoin/IStablecoin.sol","source_code":"// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity ^0.8.20;\n\nimport {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';\n\ninterface IStablecoin is IERC20 {\n\t// ---------------------------------------------------------------------------------------\n\n\t/// @notice Checks if the given account has the curator role.\n\t/// @param account The address to check.\n\t/// @return True if the account is a curator, false otherwise.\n\tfunction checkCurator(address account) external view returns (bool);\n\n\t/// @notice Checks if the given account has the guardian role.\n\t/// @param account The address to check.\n\t/// @return True if the account is a guardian, false otherwise.\n\tfunction checkGuardian(address account) external view returns (bool);\n\n\t/// @notice Checks if the given account is either a curator or a guardian.\n\t/// @param account The address to check.\n\t/// @return True if the account is a curator or a guardian, false otherwise.\n\tfunction checkCuratorOrGuardian(address account) external view returns (bool);\n\n\t/// @notice Checks if the given account has any module role (active or expired).\n\t/// @param account The address to check.\n\t/// @return True if the account is a module, false otherwise.\n\tfunction checkModule(address account) external view returns (bool);\n\n\t/// @notice Checks if the given account is a valid (non-expired) module.\n\t/// @param account The address to check.\n\t/// @return True if the account is a valid module, false otherwise.\n\tfunction checkValidModule(address account) external view returns (bool);\n\n\t// ---------------------------------------------------------------------------------------\n\n\t/// @notice Verifies that the given account is a curator.\n\t/// @dev Reverts if the account is not a curator.\n\t/// @param account The address to verify.\n\tfunction verifyCurator(address account) external view;\n\n\t/// @notice Verifies that the given account is a guardian.\n\t/// @dev Reverts if the account is not a guardian.\n\t/// @param account The address to verify.\n\tfunction verifyGuardian(address account) external view;\n\n\t/// @notice Verifies that the given account is either a curator or a guardian.\n\t/// @dev Reverts if the account is neither a curator nor a guardian.\n\t/// @param account The address to verify.\n\tfunction verifyCuratorOrGuardian(address account) external view;\n\n\t/// @notice Verifies that the given account has a module role (active or expired).\n\t/// @dev Reverts if the account is not a module.\n\t/// @param account The address to verify.\n\tfunction verifyModule(address account) external view;\n\n\t/// @notice Verifies that the given account is a valid (non-expired) module.\n\t/// @dev Reverts if the account is not a valid module.\n\t/// @param account The address to verify.\n\tfunction verifyValidModule(address account) external view;\n\n\t// ---------------------------------------------------------------------------------------\n\n\t/// @notice Mints `value` tokens to address `to`.\n\t/// @dev Callable only by addresses with the `validModule` role.\n\t/// @param to The address receiving the minted tokens.\n\t/// @param value The amount of tokens to mint.\n\t/// @custom:role validModule\n\tfunction mintModule(address to, uint256 value) external;\n\n\t/// @notice Burns `amount` tokens from address `from`.\n\t/// @dev Callable only by addresses with the `onlyModule` role.\n\t/// @param from The address whose tokens will be burned.\n\t/// @param amount The amount of tokens to burn.\n\t/// @custom:role onlyModule\n\tfunction burnModule(address from, uint256 amount) external;\n\n\t/// @notice Burns `amount` tokens from the caller's balance.\n\t/// @dev Publicly accessible by any user with sufficient balance.\n\t/// @param amount The amount of tokens to burn.\n\t/// @custom:role public\n\tfunction burn(uint256 amount) external;\n\n\t// ---------------------------------------------------------------------------------------\n\n\t/// @notice Sets a new curator for the contract.\n\t/// @dev Callable only by the current curator.\n\t/// @param newCurator The address to assign as the new curator.\n\t/// @custom:role onlyCurator\n\tfunction setCurator(address newCurator) external;\n\n\t/// @notice Publicly initiates a curator change by paying a fee.\n\t/// @dev Caller must pay `fee`, which must be at least `ConstantsLib.PUBLIC_FEE * 10`.\n\t/// @dev Applies a timelock that is twice as long\n\t/// @param newCurator The address to be proposed as the new curator.\n\t/// @param fee The fee amount submitted with the transaction.\n\t/// @custom:rule claimPublicFee(fee, ConstantsLib.PUBLIC_FEE * 10)\n\tfunction setCuratorPublic(address newCurator, uint256 fee) external;\n\n\t/// @notice Cancels a pending curator proposal.\n\t/// @dev Callable by either the current curator or a guardian.\n\t/// @custom:role onlyCuratorOrGuardian\n\tfunction revokePendingCurator() external;\n\n\t/// @notice Accepts the curator role after the timelock period.\n\t/// @dev Only new curator can accept the new role.\n\t/// @dev Callable only after `pendingCurator.validAt` timestamp has passed.\n\t/// @custom:rule afterTimelock(pendingCurator.validAt)\n\tfunction acceptCurator() external;\n\n\t// ---------------------------------------------------------------------------------------\n\n\t/// @notice Sets a new guardian for the contract.\n\t/// @dev Callable only by the current curator.\n\t/// @param newGuardian The address to assign as the new guardian.\n\t/// @custom:role onlyCurator\n\tfunction setGuardian(address newGuardian) external;\n\n\t/// @notice Cancels a pending guardian proposal.\n\t/// @dev Callable by either the current curator or the current guardian.\n\t/// @custom:role onlyCuratorOrGuardian\n\tfunction revokePendingGuardian() external;\n\n\t/// @notice Accepts the guardian role after the timelock period.\n\t/// @dev Callable only after `pendingGuardian.validAt` timestamp has passed.\n\t/// @custom:rule afterTimelock(pendingGuardian.validAt)\n\tfunction acceptGuardian() external;\n\n\t// ---------------------------------------------------------------------------------------\n\n\t/// @notice Proposes a new timelock duration for sensitive actions.\n\t/// @dev Callable only by the current curator.\n\t/// @param newTimelock The new timelock duration (typically in seconds).\n\t/// @custom:role onlyCurator\n\tfunction setTimelock(uint256 newTimelock) external;\n\n\t/// @notice Cancels a pending timelock change.\n\t/// @dev Callable by either the curator or the guardian.\n\t/// @custom:role onlyCuratorOrGuardian\n\tfunction revokePendingTimelock() external;\n\n\t/// @notice Finalizes the timelock change after the delay period.\n\t/// @dev Callable only after `pendingTimelock.validAt` has passed.\n\t/// @custom:rule afterTimelock(pendingTimelock.validAt)\n\tfunction acceptTimelock() external;\n\n\t// ---------------------------------------------------------------------------------------\n\n\t/// @notice Proposes a new module with an expiration time and message.\n\t/// @dev Callable only by the curator.\n\t/// @param module The address of the module to config.\n\t/// @param expiredAt The timestamp when the module should expire.\n\t/// @param message A message describing the module purpose or context.\n\t/// @custom:role onlyCurator\n\tfunction setModule(address module, uint256 expiredAt, string calldata message) external;\n\n\t/// @notice Publicly proposes a new module by paying a fee.\n\t/// @dev Requires a fee at least equal to `ConstantsLib.PUBLIC_FEE`.\n\t/// @dev Applies a timelock that is twice as long\n\t/// @param module The address of the module to config.\n\t/// @param expiredAt The timestamp when the module should expire.\n\t/// @param message A message describing the module purpose or context.\n\t/// @param fee The fee amount submitted with the transaction.\n\t/// @custom:rule claimPublicFee(fee, ConstantsLib.PUBLIC_FEE)\n\tfunction setModulePublic(address module, uint256 expiredAt, string calldata message, uint256 fee) external;\n\n\t/// @notice Cancels a pending module proposal.\n\t/// @dev Callable by either the curator or the guardian.\n\t/// @param module The address of the module to revoke.\n\t/// @param message A message explaining the revocation.\n\t/// @custom:role onlyCuratorOrGuardian\n\tfunction revokePendingModule(address module, string calldata message) external;\n\n\t/// @notice Finalizes the addition of a module after the timelock period.\n\t/// @dev Callable only after `pendingModules[module].validAt` has passed.\n\t/// @param module The address of the module to accept.\n\t/// @custom:rule afterTimelock(pendingModules[module].validAt)\n\tfunction acceptModule(address module) external;\n\n\t// ---------------------------------------------------------------------------------------\n\n\t/// @notice Freezes the specified account, typically to restrict actions like transfers or module usage.\n\t/// @dev Callable only by the curator.\n\t/// @param account The address to be frozen.\n\t/// @param message A message explaining the reason for freezing the account.\n\t/// @custom:role onlyCurator\n\tfunction setFreeze(address account, string calldata message) external;\n\n\t// ---------------------------------------------------------------------------------------\n\n\t/// @notice Initiates the unfreezing of a frozen account.\n\t/// @dev Callable by either the curator or the guardian.\n\t/// @param account The address to be unfrozen.\n\t/// @param message A message explaining the reason for unfreezing.\n\t/// @custom:role onlyCuratorOrGuardian\n\tfunction setUnfreeze(address account, string calldata message) external;\n\n\t/// @notice Cancels a pending unfreeze request.\n\t/// @dev Callable by either the curator or the guardian.\n\t/// @param account The address whose unfreeze request is being revoked.\n\t/// @param message A message explaining the revocation.\n\t/// @custom:role onlyCuratorOrGuardian\n\tfunction revokePendingUnfreeze(address account, string calldata message) external;\n\n\t/// @notice Finalizes the unfreezing of an account after the timelock period.\n\t/// @dev Callable only after `pendingUnfreeze[account].validAt` has passed.\n\t/// @param account The address to unfreeze.\n\t/// @custom:rule afterTimelock(pendingUnfreeze[account].validAt)\n\tfunction acceptUnfreeze(address account) external;\n\n\t// ---------------------------------------------------------------------------------------\n}\n"},{"file_path":"@openzeppelin/contracts/interfaces/IERC165.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"../utils/introspection/IERC165.sol\";\n"},{"file_path":"@openzeppelin/contracts/utils/introspection/IERC165.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC-165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[ERC].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n    /**\n     * @dev Returns true if this contract implements the interface defined by\n     * `interfaceId`. See the corresponding\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"}],"certified":false,"conflicting_implementations":null,"abi":[{"inputs":[{"internalType":"contract Stablecoin","name":"_stable","type":"address"},{"internalType":"contract IMetaMorphoV1_1","name":"_core","type":"address"},{"internalType":"address[5]","name":"_receivers","type":"address[5]"},{"internalType":"uint32[5]","name":"_weights","type":"uint32[5]"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AlreadyPending","type":"error"},{"inputs":[],"name":"NoPendingValue","type":"error"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"uint256","name":"minted","type":"uint256"}],"name":"NothingToReconcile","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"TimelockNotElapsed","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"sharesCore","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalMinted","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"ratio","type":"uint256"}],"name":"Distribution","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"sharesCore","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalMinted","type":"uint256"}],"name":"Redeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalRevenue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalMinted","type":"uint256"}],"name":"Revenue","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"}],"name":"RevokeDistribution","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"}],"name":"SetDistribution","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"address[5]","name":"receivers","type":"address[5]"},{"indexed":false,"internalType":"uint32[5]","name":"weights","type":"uint32[5]"},{"indexed":false,"internalType":"uint256","name":"timelock","type":"uint256"}],"name":"SubmitDistribution","type":"event"},{"inputs":[],"name":"applyDistribution","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"core","outputs":[{"internalType":"contract IMetaMorphoV1_1","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"pendingReceivers","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingValidAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"pendingWeights","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"receivers","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"reconcile","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"sharesCore","type":"uint256"}],"name":"redeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"revokePendingDistribution","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[5]","name":"_receivers","type":"address[5]"},{"internalType":"uint32[5]","name":"_weights","type":"uint32[5]"}],"name":"setDistribution","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stable","outputs":[{"internalType":"contract Stablecoin","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAssets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalMinted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalRevenue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalWeights","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"weights","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"}],"is_changed_bytecode":false,"is_partially_verified":false,"constructor_args":"0x000000000000000000000000dde3ec717f220fc6a29d6a4be73f91da5b718e55000000000000000000000000ce22b5fb17ccbc0c5d87dc2e0df47dd71e3adc0a0000000000000000000000009fe66037c44236c87d9ac8345f489b4413fdff06000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f42400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"}