diff --git a/.env.example b/.env.example index c87f2eb60..ecad5818e 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,22 @@ MAINNET_NODE_URL= -ROPSTEN_NODE_URL= -KOVAN_NODE_URL= +ARBITRUM_NODE_URL= +OPTIMISM_NODE_URL= +BASE_NODE_URL= + GOERLI_NODE_URL= -PRIVATE_KEY_MAINNET= +OPTIMISM_GOERLI_NODE_URL= +ARBITRUM_GOERLI_NODE_URL= +BASE_GOERLI_NODE_URL= + PRIVATE_KEY_TESTNET= -ETHERSCAN_API_KEY= +PRIVATE_KEY= + +ETHERSCAN_API_KEY_MAINNET= +ETHERSCAN_API_KEY_OPTIMISM= +ETHERSCAN_API_KEY_ARBITRUM= +ETHERSCAN_API_KEY_BASE= + +ETHEREUM_GRAPH_URL= +ARBITRUM_GRAPH_URL= + +COINMARKETCAP_API_KEY= diff --git a/packages/perennial-extensions/README.md b/packages/perennial-extensions/README.md index 7be82e5d6..ffbb4863b 100644 --- a/packages/perennial-extensions/README.md +++ b/packages/perennial-extensions/README.md @@ -1,13 +1,62 @@ -# Sample Hardhat Project +# Perennial V2 Extensions -This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a script that deploys that contract. +Extension systems for the Perennial V2 Protocol -Try running some of the following tasks: +## Usage -```shell -npx hardhat help -npx hardhat test -REPORT_GAS=true npx hardhat test -npx hardhat node -npx hardhat run scripts/deploy.ts +### Pre Requisites + +Before running any command, make sure to install dependencies. Run this in the root workspace as well to capture package patches: + +```sh +$ yarn +``` + +### Compile + +Compile the smart contracts with Hardhat: + +```sh +$ yarn compile +``` + +This also generates the Typechain types + +### Test + +Run the Mocha tests: + +```sh +$ yarn test +``` + +To run tests against a Mainnet fork, set your `MAINNET_NODE_URL` in the root `.env` and run + +```sh +$ yarn test:integration ``` + +### Gas Report + +To get a gas report based on unit test calls: + +```sh +$ yarn gasReport +``` + +### Deploy contract to netowrk (requires Mnemonic and infura API key) + +``` +npx hardhat run --network rinkeby ./scripts/deploy.ts +``` + +### Validate a contract with etherscan (requires API ke) + +``` +npx hardhat verify --network "Constructor argument 1" +``` + +### Added plugins + +- Gas reporter [hardhat-gas-reporter](https://hardhat.org/plugins/hardhat-gas-reporter.html) +- Etherscan [hardhat-etherscan](https://hardhat.org/plugins/nomiclabs-hardhat-etherscan.html) diff --git a/packages/perennial-oracle/README.md b/packages/perennial-oracle/README.md index d21db57d3..b32220106 100644 --- a/packages/perennial-oracle/README.md +++ b/packages/perennial-oracle/README.md @@ -1,24 +1,12 @@ -# Solidity Template +# Perennial V2 Oracle -Uses - -- [Hardhat](https://github.com/nomiclabs/hardhat): compile and run the smart contracts on a local development network -- [TypeChain](https://github.com/ethereum-ts/TypeChain): generate TypeScript types for smart contracts -- [Ethers](https://github.com/ethers-io/ethers.js/): Ethereum library and wallet implementation -- [Waffle](https://github.com/EthWorks/Waffle): tooling for writing comprehensive smart contract tests -- [Solhint](https://github.com/protofire/solhint): Solidity linter -- [Prettier Plugin Solidity](https://github.com/prettier-solidity/prettier-plugin-solidity): code formatter - -This is a GitHub template, which means you can reuse it as many times as you want. You can do that by clicking the "Use this -template" button at the top of the page. +Oracle systems for the Perennial V2 Protocol ## Usage ### Pre Requisites -This repo works best with Node.js v16.x.x, this is preconfigured for users of [asdf](https://asdf-vm.com/). - -Before running any command, make sure to install dependencies: +Before running any command, make sure to install dependencies. Run this in the root workspace as well to capture package patches: ```sh $ yarn @@ -42,13 +30,14 @@ Run the Mocha tests: $ yarn test ``` -To run tests against a Mainnet fork, set your `ALCHEMY_KEY` in `.env` and run +To run tests against a Mainnet fork, set your `MAINNET_NODE_URL` in the root `.env` and run ```sh -$ yarn test-integration +$ yarn test:integration ``` ### Gas Report + To get a gas report based on unit test calls: ```sh @@ -61,7 +50,7 @@ $ yarn gasReport npx hardhat run --network rinkeby ./scripts/deploy.ts ``` -### Validate a contract with etherscan (requires API key) +### Validate a contract with etherscan (requires API ke) ``` npx hardhat verify --network "Constructor argument 1" @@ -69,6 +58,5 @@ npx hardhat verify --network "Constructor ### Added plugins -- Contract Sizer [hardhat-contract-sizer](https://github.com/ItsNickBarry/hardhat-contract-sizer) - Gas reporter [hardhat-gas-reporter](https://hardhat.org/plugins/hardhat-gas-reporter.html) - Etherscan [hardhat-etherscan](https://hardhat.org/plugins/nomiclabs-hardhat-etherscan.html) diff --git a/packages/perennial-payoff/README.md b/packages/perennial-payoff/README.md index d21db57d3..a58cf0c9c 100644 --- a/packages/perennial-payoff/README.md +++ b/packages/perennial-payoff/README.md @@ -1,24 +1,12 @@ -# Solidity Template +# Perennial V2 Payoff -Uses - -- [Hardhat](https://github.com/nomiclabs/hardhat): compile and run the smart contracts on a local development network -- [TypeChain](https://github.com/ethereum-ts/TypeChain): generate TypeScript types for smart contracts -- [Ethers](https://github.com/ethers-io/ethers.js/): Ethereum library and wallet implementation -- [Waffle](https://github.com/EthWorks/Waffle): tooling for writing comprehensive smart contract tests -- [Solhint](https://github.com/protofire/solhint): Solidity linter -- [Prettier Plugin Solidity](https://github.com/prettier-solidity/prettier-plugin-solidity): code formatter - -This is a GitHub template, which means you can reuse it as many times as you want. You can do that by clicking the "Use this -template" button at the top of the page. +Payoff functions for the Perennial V2 Protocol ## Usage ### Pre Requisites -This repo works best with Node.js v16.x.x, this is preconfigured for users of [asdf](https://asdf-vm.com/). - -Before running any command, make sure to install dependencies: +Before running any command, make sure to install dependencies. Run this in the root workspace as well to capture package patches: ```sh $ yarn @@ -42,13 +30,14 @@ Run the Mocha tests: $ yarn test ``` -To run tests against a Mainnet fork, set your `ALCHEMY_KEY` in `.env` and run +To run tests against a Mainnet fork, set your `MAINNET_NODE_URL` in the root `.env` and run ```sh -$ yarn test-integration +$ yarn test:integration ``` ### Gas Report + To get a gas report based on unit test calls: ```sh @@ -61,7 +50,7 @@ $ yarn gasReport npx hardhat run --network rinkeby ./scripts/deploy.ts ``` -### Validate a contract with etherscan (requires API key) +### Validate a contract with etherscan (requires API ke) ``` npx hardhat verify --network "Constructor argument 1" @@ -69,6 +58,5 @@ npx hardhat verify --network "Constructor ### Added plugins -- Contract Sizer [hardhat-contract-sizer](https://github.com/ItsNickBarry/hardhat-contract-sizer) - Gas reporter [hardhat-gas-reporter](https://hardhat.org/plugins/hardhat-gas-reporter.html) - Etherscan [hardhat-etherscan](https://hardhat.org/plugins/nomiclabs-hardhat-etherscan.html) diff --git a/packages/perennial-vault/README.md b/packages/perennial-vault/README.md index d21db57d3..1688fed25 100644 --- a/packages/perennial-vault/README.md +++ b/packages/perennial-vault/README.md @@ -1,24 +1,12 @@ -# Solidity Template +# Perennial V2 Vault -Uses - -- [Hardhat](https://github.com/nomiclabs/hardhat): compile and run the smart contracts on a local development network -- [TypeChain](https://github.com/ethereum-ts/TypeChain): generate TypeScript types for smart contracts -- [Ethers](https://github.com/ethers-io/ethers.js/): Ethereum library and wallet implementation -- [Waffle](https://github.com/EthWorks/Waffle): tooling for writing comprehensive smart contract tests -- [Solhint](https://github.com/protofire/solhint): Solidity linter -- [Prettier Plugin Solidity](https://github.com/prettier-solidity/prettier-plugin-solidity): code formatter - -This is a GitHub template, which means you can reuse it as many times as you want. You can do that by clicking the "Use this -template" button at the top of the page. +Vault for the Perennial V2 Protocol ## Usage ### Pre Requisites -This repo works best with Node.js v16.x.x, this is preconfigured for users of [asdf](https://asdf-vm.com/). - -Before running any command, make sure to install dependencies: +Before running any command, make sure to install dependencies. Run this in the root workspace as well to capture package patches: ```sh $ yarn @@ -42,13 +30,14 @@ Run the Mocha tests: $ yarn test ``` -To run tests against a Mainnet fork, set your `ALCHEMY_KEY` in `.env` and run +To run tests against a Mainnet fork, set your `MAINNET_NODE_URL` in the root `.env` and run ```sh -$ yarn test-integration +$ yarn test:integration ``` ### Gas Report + To get a gas report based on unit test calls: ```sh @@ -61,7 +50,7 @@ $ yarn gasReport npx hardhat run --network rinkeby ./scripts/deploy.ts ``` -### Validate a contract with etherscan (requires API key) +### Validate a contract with etherscan (requires API ke) ``` npx hardhat verify --network "Constructor argument 1" @@ -69,6 +58,5 @@ npx hardhat verify --network "Constructor ### Added plugins -- Contract Sizer [hardhat-contract-sizer](https://github.com/ItsNickBarry/hardhat-contract-sizer) - Gas reporter [hardhat-gas-reporter](https://hardhat.org/plugins/hardhat-gas-reporter.html) - Etherscan [hardhat-etherscan](https://hardhat.org/plugins/nomiclabs-hardhat-etherscan.html) diff --git a/packages/perennial/README.md b/packages/perennial/README.md index 3a9b7bd25..bec04433b 100644 --- a/packages/perennial/README.md +++ b/packages/perennial/README.md @@ -1,4 +1,4 @@ -# Perennial Protocol +# Perennial V2 Protocol Perpetual synthetics protocol. @@ -6,7 +6,7 @@ Perpetual synthetics protocol. ### Pre Requisites -Before running any command, make sure to install dependencies: +Before running any command, make sure to install dependencies. Run this in the root workspace as well to capture package patches: ```sh $ yarn @@ -30,10 +30,10 @@ Run the Mocha tests: $ yarn test ``` -To run tests against a Mainnet fork, set your `ALCHEMY_KEY` in `.env` and run +To run tests against a Mainnet fork, set your `MAINNET_NODE_URL` in the root `.env` and run ```sh -$ yarn test-integration +$ yarn test:integration ``` ### Gas Report diff --git a/packages/perennial/deployments/goerli/.chainId b/packages/perennial/deployments/goerli/.chainId deleted file mode 100644 index 7813681f5..000000000 --- a/packages/perennial/deployments/goerli/.chainId +++ /dev/null @@ -1 +0,0 @@ -5 \ No newline at end of file diff --git a/packages/perennial/deployments/goerli/Collateral_Impl.json b/packages/perennial/deployments/goerli/Collateral_Impl.json deleted file mode 100644 index f455cf997..000000000 --- a/packages/perennial/deployments/goerli/Collateral_Impl.json +++ /dev/null @@ -1,865 +0,0 @@ -{ - "address": "0xfB9df7AE9C30cB7Eb8A232f6ae90780a37b30022", - "abi": [ - { - "inputs": [ - { - "internalType": "Token18", - "name": "token_", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "totalMaintenance", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "totalCollateral", - "type": "uint256" - } - ], - "name": "CollateralCantLiquidate", - "type": "error" - }, - { - "inputs": [], - "name": "CollateralInsufficientCollateralError", - "type": "error" - }, - { - "inputs": [], - "name": "CollateralUnderLimitError", - "type": "error" - }, - { - "inputs": [], - "name": "CollateralZeroAddressError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Fixed18OverflowError", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidControllerError", - "type": "error" - }, - { - "inputs": [], - "name": "NotCollateralError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - } - ], - "name": "NotOwnerError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "NotProductError", - "type": "error" - }, - { - "inputs": [], - "name": "PausedError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "version", - "type": "uint256" - } - ], - "name": "UInitializableAlreadyInitializedError", - "type": "error" - }, - { - "inputs": [], - "name": "UInitializableNotInitializingError", - "type": "error" - }, - { - "inputs": [], - "name": "UInitializableZeroVersionError", - "type": "error" - }, - { - "inputs": [], - "name": "UReentrancyGuardReentrantCallError", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": false, - "internalType": "Fixed18", - "name": "amount", - "type": "int256" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "newShortfall", - "type": "uint256" - } - ], - "name": "AccountSettle", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "user", - "type": "address" - }, - { - "indexed": true, - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "Deposit", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "FeeClaim", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "version", - "type": "uint256" - } - ], - "name": "Initialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "user", - "type": "address" - }, - { - "indexed": true, - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "liquidator", - "type": "address" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "fee", - "type": "uint256" - } - ], - "name": "Liquidation", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "protocolFee", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "productFee", - "type": "uint256" - } - ], - "name": "ProductSettle", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "ShortfallResolution", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "user", - "type": "address" - }, - { - "indexed": true, - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "Withdrawal", - "type": "event" - }, - { - "inputs": [], - "name": "claimFee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "collateral", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "collateral", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "controller", - "outputs": [ - { - "internalType": "contract IController", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "depositTo", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "fees", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IController", - "name": "controller_", - "type": "address" - } - ], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "liquidatable", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "liquidatableNext", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "liquidate", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "resolveShortfall", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "Fixed18", - "name": "amount", - "type": "int256" - } - ], - "name": "settleAccount", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "settleProduct", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "shortfall", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "token", - "outputs": [ - { - "internalType": "Token18", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "withdrawTo", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } - ], - "transactionHash": "0x971e08d6b53e228e25c1834e97e54f285ead7fa0d4d95a57676699f7acf9ca8c", - "receipt": { - "to": null, - "from": "0x66a7fDB96C583c59597de16d8b2B989231415339", - "contractAddress": "0xfB9df7AE9C30cB7Eb8A232f6ae90780a37b30022", - "transactionIndex": 56, - "gasUsed": "2462146", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x53f25246116dd83fa777c71d55de4399a146601388f44095719aa3f159108a9e", - "transactionHash": "0x971e08d6b53e228e25c1834e97e54f285ead7fa0d4d95a57676699f7acf9ca8c", - "logs": [], - "blockNumber": 7681105, - "cumulativeGasUsed": "20354568", - "status": 1, - "byzantium": true - }, - "args": ["0x237D7a40d3A28aA5dAAb786570d3d8bf8496e497"], - "numDeployments": 1, - "solcInputHash": "b6ff42633a62e1bc6c97d8ccad85444b", - "metadata": "{\"compiler\":{\"version\":\"0.8.15+commit.e14f2714\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"Token18\",\"name\":\"token_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"totalMaintenance\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"totalCollateral\",\"type\":\"uint256\"}],\"name\":\"CollateralCantLiquidate\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CollateralInsufficientCollateralError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CollateralUnderLimitError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CollateralZeroAddressError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Fixed18OverflowError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidControllerError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotCollateralError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"}],\"name\":\"NotOwnerError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"NotProductError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"PausedError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"UInitializableAlreadyInitializedError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UInitializableNotInitializingError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UInitializableZeroVersionError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UReentrancyGuardReentrantCallError\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"Fixed18\",\"name\":\"amount\",\"type\":\"int256\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"newShortfall\",\"type\":\"uint256\"}],\"name\":\"AccountSettle\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Deposit\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"FeeClaim\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"liquidator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"fee\",\"type\":\"uint256\"}],\"name\":\"Liquidation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"protocolFee\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"productFee\",\"type\":\"uint256\"}],\"name\":\"ProductSettle\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"ShortfallResolution\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Withdrawal\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"claimFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"collateral\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"collateral\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"controller\",\"outputs\":[{\"internalType\":\"contract IController\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"depositTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"fees\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IController\",\"name\":\"controller_\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"liquidatable\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"liquidatableNext\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"liquidate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"resolveShortfall\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"Fixed18\",\"name\":\"amount\",\"type\":\"int256\"}],\"name\":\"settleAccount\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"settleProduct\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"shortfall\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"token\",\"outputs\":[{\"internalType\":\"Token18\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"withdrawTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"collateral(address)\":{\"params\":{\"product\":\"Product to return for\"},\"returns\":{\"_0\":\"The total balance of collateral in the product\"}},\"collateral(address,address)\":{\"params\":{\"account\":\"Account to return for\",\"product\":\"Product to return for\"},\"returns\":{\"_0\":\"The balance of the collateral account\"}},\"constructor\":{\"details\":\"Called at implementation instantiate and constant for that implementation.\",\"params\":{\"token_\":\"Collateral ERC20 stablecoin address\"}},\"depositTo(address,address,uint256)\":{\"params\":{\"account\":\"Account to deposit the collateral for\",\"amount\":\"Amount of collateral to deposit\",\"product\":\"Product to credit the collateral to\"}},\"initialize(address)\":{\"details\":\"Must be called atomically as part of the upgradeable proxy deployment to avoid front-running\",\"params\":{\"controller_\":\"Factory contract address\"}},\"liquidatable(address,address)\":{\"params\":{\"account\":\"Account to return for\",\"product\":\"Product to return for\"},\"returns\":{\"_0\":\"Whether the account can be liquidated\"}},\"liquidatableNext(address,address)\":{\"details\":\"Takes into account the current pre-position on the account\",\"params\":{\"account\":\"Account to return for\",\"product\":\"Product to return for\"},\"returns\":{\"_0\":\"Whether the account can be liquidated\"}},\"liquidate(address,address)\":{\"details\":\"Account must be under-collateralized, fee returned immediately to `msg.sender`\",\"params\":{\"account\":\"Account to liquidate\",\"product\":\"Product to liquidate for\"}},\"resolveShortfall(address,uint256)\":{\"details\":\"Shortfall is a measure of settled insolvency in the market This hook can be used by the product owner or an insurance fund to re-capitalize an insolvent market\",\"params\":{\"amount\":\"Amount of shortfall to resolve\",\"product\":\"Product to resolve shortfall for\"}},\"settleAccount(address,int256)\":{\"details\":\"Callable only by the corresponding product as part of the settlement flywheel. Moves collateral within a product, any collateral leaving the product due to fees has already been accounted for in the settleProduct flywheel. Debits in excess of the account balance get recorded as shortfall, and can be resolved by the product owner as needed.\",\"params\":{\"account\":\"Account to credit\",\"amount\":\"Amount to credit the account (can be negative)\"}},\"settleProduct(uint256)\":{\"details\":\"Callable only by the corresponding product as part of the settlement flywheel Removes collateral from the product as fees.\",\"params\":{\"amount\":\"Amount to debit from the account\"}},\"shortfall(address)\":{\"params\":{\"product\":\"Product to return for\"},\"returns\":{\"_0\":\"The current shortfall of the product\"}},\"withdrawTo(address,address,uint256)\":{\"params\":{\"account\":\"Account to withdraw the collateral to\",\"amount\":\"Amount of collateral to withdraw\",\"product\":\"Product to withdraw the collateral from\"}}},\"stateVariables\":{\"_products\":{\"details\":\"Per product collateral state\"},\"fees\":{\"details\":\"Protocol and product fees collected, but not yet claimed\"},\"token\":{\"details\":\"ERC20 stablecoin for collateral\"}},\"title\":\"Collateral\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"claimFee()\":{\"notice\":\"Claims all of `msg.sender`'s fees\"},\"collateral(address)\":{\"notice\":\"Returns the total balance of `product`'s collateral\"},\"collateral(address,address)\":{\"notice\":\"Returns the balance of `account`'s `product` collateral account\"},\"constructor\":{\"notice\":\"Initializes the immutable contract state\"},\"depositTo(address,address,uint256)\":{\"notice\":\"Deposits `amount` collateral from `msg.sender` to `account`'s `product` account\"},\"initialize(address)\":{\"notice\":\"Initializes the contract state\"},\"liquidatable(address,address)\":{\"notice\":\"Returns whether `account`'s `product` collateral account can be liquidated\"},\"liquidatableNext(address,address)\":{\"notice\":\"Returns whether `account`'s `product` collateral account can be liquidated after the next oracle version settlement\"},\"liquidate(address,address)\":{\"notice\":\"Liquidates `account`'s `product` collateral account\"},\"resolveShortfall(address,uint256)\":{\"notice\":\"Injects additional collateral into a product to resolve shortfall\"},\"settleAccount(address,int256)\":{\"notice\":\"Credits `amount` to `account`'s collateral account\"},\"settleProduct(uint256)\":{\"notice\":\"Debits `amount` from product's total collateral account\"},\"shortfall(address)\":{\"notice\":\"Returns the current shortfall of `product`'s collateral\"},\"withdrawTo(address,address,uint256)\":{\"notice\":\"Withdraws `amount` collateral from `msg.sender`'s `product` account and sends it to `account`\"}},\"notice\":\"Manages logic and state for all collateral accounts in the protocol.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/collateral/Collateral.sol\":\"Collateral\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\n\\ninterface IOracleProvider {\\n /// @dev A singular oracle version with its corresponding data\\n struct OracleVersion {\\n /// @dev The iterative version\\n uint256 version;\\n\\n /// @dev the timestamp of the oracle update\\n uint256 timestamp;\\n\\n /// @dev The oracle price of the corresponding version\\n Fixed18 price;\\n }\\n\\n function sync() external returns (OracleVersion memory);\\n function currentVersion() external view returns (OracleVersion memory);\\n function atVersion(uint256 oracleVersion) external view returns (OracleVersion memory);\\n}\\n\",\"keccak256\":\"0xde0f20d468ba8b91addfc356e13f2c74a4dc8abe68be323942217c723775d9c1\",\"license\":\"Apache-2.0\"},\"@equilibria/root/control/unstructured/UInitializable.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/Address.sol\\\";\\nimport \\\"../../storage/UStorage.sol\\\";\\n\\n/**\\n * @title UInitializable\\n * @notice Library to manage the initialization lifecycle of upgradeable contracts\\n * @dev `UInitializable` allows the creation of pseudo-constructors for upgradeable contracts. One\\n * `initializer` should be declared per top-level contract. Child contracts can use the `onlyInitializer`\\n * modifier to tag their internal initialization functions to ensure that they can only be called\\n * from a top-level `initializer` or a constructor.\\n */\\nabstract contract UInitializable {\\n error UInitializableZeroVersionError();\\n error UInitializableAlreadyInitializedError(uint256 version);\\n error UInitializableNotInitializingError();\\n\\n event Initialized(uint256 version);\\n\\n /// @dev The initialized flag\\n Uint256Storage private constant _version = Uint256Storage.wrap(keccak256(\\\"equilibria.root.UInitializable.version\\\"));\\n\\n /// @dev The initializing flag\\n BoolStorage private constant _initializing = BoolStorage.wrap(keccak256(\\\"equilibria.root.UInitializable.initializing\\\"));\\n\\n /// @dev Can only be called once per version, `version` is 1-indexed\\n modifier initializer(uint256 version) {\\n if (version == 0) revert UInitializableZeroVersionError();\\n if (_version.read() >= version) revert UInitializableAlreadyInitializedError(version);\\n\\n _version.store(version);\\n _initializing.store(true);\\n\\n _;\\n\\n _initializing.store(false);\\n emit Initialized(version);\\n }\\n\\n /// @dev Can only be called from an initializer or constructor\\n modifier onlyInitializer() {\\n if (!_constructing() && !_initializing.read()) revert UInitializableNotInitializingError();\\n _;\\n }\\n\\n /**\\n * @notice Returns whether the contract is currently being constructed\\n * @dev {Address.isContract} returns false for contracts currently in the process of being constructed\\n * @return Whether the contract is currently being constructed\\n */\\n function _constructing() private view returns (bool) {\\n return !Address.isContract(address(this));\\n }\\n}\\n\",\"keccak256\":\"0xd2743d8fcc220ed2ccdc0bba1db0a3e107741bd5c0cac47ca8c0b5a00ba2fd7f\",\"license\":\"Apache-2.0\"},\"@equilibria/root/control/unstructured/UReentrancyGuard.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"./UInitializable.sol\\\";\\nimport \\\"../../storage/UStorage.sol\\\";\\n\\n/**\\n * @dev Contract module that helps prevent reentrant calls to a function.\\n *\\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\\n * available, which can be applied to functions to make sure there are no nested\\n * (reentrant) calls to them.\\n *\\n * Note that because there is a single `nonReentrant` guard, functions marked as\\n * `nonReentrant` may not call one another. This can be worked around by making\\n * those functions `private`, and then adding `external` `nonReentrant` entry\\n * points to them.\\n *\\n * TIP: If you would like to learn more about reentrancy and alternative ways\\n * to protect against it, check out our blog post\\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\\n *\\n * NOTE: This contract has been extended from the Open Zeppelin library to include an\\n * unstructured storage pattern, so that it can be safely mixed in with upgradeable\\n * contracts without affecting their storage patterns through inheritance.\\n */\\nabstract contract UReentrancyGuard is UInitializable {\\n error UReentrancyGuardReentrantCallError();\\n\\n uint256 private constant _NOT_ENTERED = 1;\\n uint256 private constant _ENTERED = 2;\\n\\n /**\\n * @dev unstructured storage slot for the reentrancy status\\n */\\n Uint256Storage private constant _status = Uint256Storage.wrap(keccak256(\\\"equilibria.root.UReentrancyGuard.status\\\"));\\n\\n /**\\n * @dev Initializes the contract setting the status to _NOT_ENTERED.\\n */\\n function __UReentrancyGuard__initialize() internal onlyInitializer {\\n _status.store(_NOT_ENTERED);\\n }\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n * Calling a `nonReentrant` function from another `nonReentrant`\\n * function is not supported. It is possible to prevent this from happening\\n * by making the `nonReentrant` function external, and make it call a\\n * `private` function that does the actual work.\\n */\\n modifier nonReentrant() {\\n // On the first call to nonReentrant, _notEntered will be true\\n if (_status.read() == _ENTERED) revert UReentrancyGuardReentrantCallError();\\n\\n // Any calls to nonReentrant after this point will fail\\n _status.store(_ENTERED);\\n\\n _;\\n\\n // By storing the original value once again, a refund is triggered (see\\n // https://eips.ethereum.org/EIPS/eip-2200)\\n _status.store(_NOT_ENTERED);\\n }\\n}\\n\",\"keccak256\":\"0x4962245ca8fdda3dc40c0f942a3568d90fb69428a6927b058018b01c90eb9fc9\",\"license\":\"Apache-2.0\"},\"@equilibria/root/curve/CurveMath.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"../number/types/UFixed18.sol\\\";\\nimport \\\"../number/types/Fixed18.sol\\\";\\n\\n/**\\n * @title CurveMath\\n * @notice Library for managing math operations for utilization curves.\\n */\\nlibrary CurveMath {\\n error CurveMathOutOfBoundsError();\\n\\n /**\\n * @notice Computes a linear interpolation between two points\\n * @param startX First point's x-coordinate\\n * @param startY First point's y-coordinate\\n * @param endX Second point's x-coordinate\\n * @param endY Second point's y-coordinate\\n * @param targetX x-coordinate to interpolate\\n * @return y-coordinate for `targetX` along the line from (`startX`, `startY`) -> (`endX`, `endY`)\\n */\\n function linearInterpolation(\\n UFixed18 startX,\\n Fixed18 startY,\\n UFixed18 endX,\\n Fixed18 endY,\\n UFixed18 targetX\\n ) internal pure returns (Fixed18) {\\n if (targetX.lt(startX) || targetX.gt(endX)) revert CurveMathOutOfBoundsError();\\n\\n UFixed18 xRange = endX.sub(startX);\\n Fixed18 yRange = endY.sub(startY);\\n UFixed18 xRatio = targetX.sub(startX).div(xRange);\\n return yRange.mul(Fixed18Lib.from(xRatio)).add(startY);\\n }\\n}\\n\",\"keccak256\":\"0x60d159f9ddf0dbe81124ecad58bba734b4cf82877637ff8d9d7f3e92f2da4ded\",\"license\":\"Apache-2.0\"},\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"../CurveMath.sol\\\";\\nimport \\\"../../number/types/PackedUFixed18.sol\\\";\\nimport \\\"../../number/types/PackedFixed18.sol\\\";\\n\\n/// @dev JumpRateUtilizationCurve type\\nstruct JumpRateUtilizationCurve {\\n PackedFixed18 minRate;\\n PackedFixed18 maxRate;\\n PackedFixed18 targetRate;\\n PackedUFixed18 targetUtilization;\\n}\\nusing JumpRateUtilizationCurveLib for JumpRateUtilizationCurve global;\\ntype JumpRateUtilizationCurveStorage is bytes32;\\nusing JumpRateUtilizationCurveStorageLib for JumpRateUtilizationCurveStorage global;\\n\\n/**\\n * @title JumpRateUtilizationCurveLib\\n * @notice Library for the Jump Rate utilization curve type\\n */\\nlibrary JumpRateUtilizationCurveLib {\\n /**\\n * @notice Computes the corresponding rate for a utilization ratio\\n * @param utilization The utilization ratio\\n * @return The corresponding rate\\n */\\n function compute(JumpRateUtilizationCurve memory self, UFixed18 utilization) internal pure returns (Fixed18) {\\n UFixed18 targetUtilization = self.targetUtilization.unpack();\\n if (utilization.lt(targetUtilization)) {\\n return CurveMath.linearInterpolation(\\n UFixed18Lib.ZERO,\\n self.minRate.unpack(),\\n targetUtilization,\\n self.targetRate.unpack(),\\n utilization\\n );\\n }\\n if (utilization.lt(UFixed18Lib.ONE)) {\\n return CurveMath.linearInterpolation(\\n targetUtilization,\\n self.targetRate.unpack(),\\n UFixed18Lib.ONE,\\n self.maxRate.unpack(),\\n utilization\\n );\\n }\\n return self.maxRate.unpack();\\n }\\n}\\n\\nlibrary JumpRateUtilizationCurveStorageLib {\\n function read(JumpRateUtilizationCurveStorage self) internal view returns (JumpRateUtilizationCurve memory) {\\n return _storagePointer(self);\\n }\\n\\n function store(JumpRateUtilizationCurveStorage self, JumpRateUtilizationCurve memory value) internal {\\n JumpRateUtilizationCurve storage storagePointer = _storagePointer(self);\\n\\n storagePointer.minRate = value.minRate;\\n storagePointer.maxRate = value.maxRate;\\n storagePointer.targetRate = value.targetRate;\\n storagePointer.targetUtilization = value.targetUtilization;\\n }\\n\\n function _storagePointer(JumpRateUtilizationCurveStorage self)\\n private pure returns (JumpRateUtilizationCurve storage pointer) {\\n assembly { pointer.slot := self }\\n }\\n}\",\"keccak256\":\"0xae202813874bc306d51b3dab8194c86f6483bb20bf1f673ddaee16aa8de567ff\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/Fixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SignedMath.sol\\\";\\nimport \\\"./UFixed18.sol\\\";\\nimport \\\"./PackedFixed18.sol\\\";\\n\\n/// @dev Fixed18 type\\ntype Fixed18 is int256;\\nusing Fixed18Lib for Fixed18 global;\\ntype Fixed18Storage is bytes32;\\nusing Fixed18StorageLib for Fixed18Storage global;\\n\\n/**\\n * @title Fixed18Lib\\n * @notice Library for the signed fixed-decimal type.\\n */\\nlibrary Fixed18Lib {\\n error Fixed18OverflowError(uint256 value);\\n error Fixed18PackingOverflowError(int256 value);\\n error Fixed18PackingUnderflowError(int256 value);\\n\\n int256 private constant BASE = 1e18;\\n Fixed18 public constant ZERO = Fixed18.wrap(0);\\n Fixed18 public constant ONE = Fixed18.wrap(BASE);\\n Fixed18 public constant NEG_ONE = Fixed18.wrap(-1 * BASE);\\n Fixed18 public constant MAX = Fixed18.wrap(type(int256).max);\\n Fixed18 public constant MIN = Fixed18.wrap(type(int256).min);\\n\\n /**\\n * @notice Creates a signed fixed-decimal from an unsigned fixed-decimal\\n * @param a Unsigned fixed-decimal\\n * @return New signed fixed-decimal\\n */\\n function from(UFixed18 a) internal pure returns (Fixed18) {\\n uint256 value = UFixed18.unwrap(a);\\n if (value > uint256(type(int256).max)) revert Fixed18OverflowError(value);\\n return Fixed18.wrap(int256(value));\\n }\\n\\n /**\\n * @notice Creates a signed fixed-decimal from a sign and an unsigned fixed-decimal\\n * @param s Sign\\n * @param m Unsigned fixed-decimal magnitude\\n * @return New signed fixed-decimal\\n */\\n function from(int256 s, UFixed18 m) internal pure returns (Fixed18) {\\n if (s > 0) return from(m);\\n if (s < 0) return Fixed18.wrap(-1 * Fixed18.unwrap(from(m)));\\n return ZERO;\\n }\\n\\n /**\\n * @notice Creates a signed fixed-decimal from a signed integer\\n * @param a Signed number\\n * @return New signed fixed-decimal\\n */\\n function from(int256 a) internal pure returns (Fixed18) {\\n return Fixed18.wrap(a * BASE);\\n }\\n\\n /**\\n * @notice Creates a packed signed fixed-decimal from an signed fixed-decimal\\n * @param a signed fixed-decimal\\n * @return New packed signed fixed-decimal\\n */\\n function pack(Fixed18 a) internal pure returns (PackedFixed18) {\\n int256 value = Fixed18.unwrap(a);\\n if (value > type(int128).max) revert Fixed18PackingOverflowError(value);\\n if (value < type(int128).min) revert Fixed18PackingUnderflowError(value);\\n return PackedFixed18.wrap(int128(value));\\n }\\n\\n /**\\n * @notice Returns whether the signed fixed-decimal is equal to zero.\\n * @param a Signed fixed-decimal\\n * @return Whether the signed fixed-decimal is zero.\\n */\\n function isZero(Fixed18 a) internal pure returns (bool) {\\n return Fixed18.unwrap(a) == 0;\\n }\\n\\n /**\\n * @notice Adds two signed fixed-decimals `a` and `b` together\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Resulting summed signed fixed-decimal\\n */\\n function add(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) + Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Subtracts signed fixed-decimal `b` from `a`\\n * @param a Signed fixed-decimal to subtract from\\n * @param b Signed fixed-decimal to subtract\\n * @return Resulting subtracted signed fixed-decimal\\n */\\n function sub(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) - Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Multiplies two signed fixed-decimals `a` and `b` together\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Resulting multiplied signed fixed-decimal\\n */\\n function mul(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / BASE);\\n }\\n\\n /**\\n * @notice Divides signed fixed-decimal `a` by `b`\\n * @param a Signed fixed-decimal to divide\\n * @param b Signed fixed-decimal to divide by\\n * @return Resulting divided signed fixed-decimal\\n */\\n function div(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * BASE / Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0`, `MAX` for `n/0`, and `MIN` for `-n/0`.\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function unsafeDiv(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n if (isZero(b)) {\\n if (gt(a, ZERO)) return MAX;\\n if (lt(a, ZERO)) return MIN;\\n return ONE;\\n } else {\\n return div(a, b);\\n }\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First signed fixed-decimal\\n * @param b Signed number to multiply by\\n * @param c Signed number to divide by\\n * @return Resulting computation\\n */\\n function muldiv(Fixed18 a, int256 b, int256 c) internal pure returns (Fixed18) {\\n return muldiv(a, Fixed18.wrap(b), Fixed18.wrap(c));\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First signed fixed-decimal\\n * @param b Signed fixed-decimal to multiply by\\n * @param c Signed fixed-decimal to divide by\\n * @return Resulting computation\\n */\\n function muldiv(Fixed18 a, Fixed18 b, Fixed18 c) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / Fixed18.unwrap(c));\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is equal to `b`\\n */\\n function eq(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 1;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is greater than `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is greater than `b`\\n */\\n function gt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 2;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is less than `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is less than `b`\\n */\\n function lt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 0;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is greater than or equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is greater than or equal to `b`\\n */\\n function gte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return gt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is less than or equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is less than or equal to `b`\\n */\\n function lte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return lt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Compares the signed fixed-decimals `a` and `b`\\n * @dev Returns: 2 for greater than\\n * 1 for equal to\\n * 0 for less than\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Compare result of `a` and `b`\\n */\\n function compare(Fixed18 a, Fixed18 b) internal pure returns (uint256) {\\n (int256 au, int256 bu) = (Fixed18.unwrap(a), Fixed18.unwrap(b));\\n if (au > bu) return 2;\\n if (au < bu) return 0;\\n return 1;\\n }\\n\\n /**\\n * @notice Returns a signed fixed-decimal representing the ratio of `a` over `b`\\n * @param a First signed number\\n * @param b Second signed number\\n * @return Ratio of `a` over `b`\\n */\\n function ratio(int256 a, int256 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(a * BASE / b);\\n }\\n\\n /**\\n * @notice Returns the minimum of signed fixed-decimals `a` and `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Minimum of `a` and `b`\\n */\\n function min(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(SignedMath.min(Fixed18.unwrap(a), Fixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Returns the maximum of signed fixed-decimals `a` and `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Maximum of `a` and `b`\\n */\\n function max(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(SignedMath.max(Fixed18.unwrap(a), Fixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Converts the signed fixed-decimal into an integer, truncating any decimal portion\\n * @param a Signed fixed-decimal\\n * @return Truncated signed number\\n */\\n function truncate(Fixed18 a) internal pure returns (int256) {\\n return Fixed18.unwrap(a) / BASE;\\n }\\n\\n /**\\n * @notice Returns the sign of the signed fixed-decimal\\n * @dev Returns: -1 for negative\\n * 0 for zero\\n * 1 for positive\\n * @param a Signed fixed-decimal\\n * @return Sign of the signed fixed-decimal\\n */\\n function sign(Fixed18 a) internal pure returns (int256) {\\n if (Fixed18.unwrap(a) > 0) return 1;\\n if (Fixed18.unwrap(a) < 0) return -1;\\n return 0;\\n }\\n\\n /**\\n * @notice Returns the absolute value of the signed fixed-decimal\\n * @param a Signed fixed-decimal\\n * @return Absolute value of the signed fixed-decimal\\n */\\n function abs(Fixed18 a) internal pure returns (UFixed18) {\\n return UFixed18.wrap(SignedMath.abs(Fixed18.unwrap(a)));\\n }\\n}\\n\\nlibrary Fixed18StorageLib {\\n function read(Fixed18Storage self) internal view returns (Fixed18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(Fixed18Storage self, Fixed18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x613587461ef3437ef33229cdda7d34ea746278721baf06e20b2e43977f43174d\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/PackedFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"./Fixed18.sol\\\";\\n\\n/// @dev PackedFixed18 type\\ntype PackedFixed18 is int128;\\nusing PackedFixed18Lib for PackedFixed18 global;\\n\\n/**\\n * @title PackedFixed18Lib\\n * @dev A packed version of the Fixed18 which takes up half the storage space (two PackedFixed18 can be packed\\n * into a single slot). Only valid within the range -1.7014118e+20 <= x <= 1.7014118e+20.\\n * @notice Library for the packed signed fixed-decimal type.\\n */\\nlibrary PackedFixed18Lib {\\n PackedFixed18 public constant MAX = PackedFixed18.wrap(type(int128).max);\\n PackedFixed18 public constant MIN = PackedFixed18.wrap(type(int128).min);\\n\\n /**\\n * @notice Creates an unpacked signed fixed-decimal from a packed signed fixed-decimal\\n * @param self packed signed fixed-decimal\\n * @return New unpacked signed fixed-decimal\\n */\\n function unpack(PackedFixed18 self) internal pure returns (Fixed18) {\\n return Fixed18.wrap(int256(PackedFixed18.unwrap(self)));\\n }\\n}\\n\",\"keccak256\":\"0xb52960cc8e3132e45d342bbbb1c6a96219022cd8557997933bd8250170268b64\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/PackedUFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"./UFixed18.sol\\\";\\n\\n/// @dev PackedUFixed18 type\\ntype PackedUFixed18 is uint128;\\nusing PackedUFixed18Lib for PackedUFixed18 global;\\n\\n/**\\n * @title PackedUFixed18Lib\\n * @dev A packed version of the UFixed18 which takes up half the storage space (two PackedUFixed18 can be packed\\n * into a single slot). Only valid within the range 0 <= x <= 3.4028237e+20.\\n * @notice Library for the packed unsigned fixed-decimal type.\\n */\\nlibrary PackedUFixed18Lib {\\n PackedUFixed18 public constant MAX = PackedUFixed18.wrap(type(uint128).max);\\n\\n /**\\n * @notice Creates an unpacked unsigned fixed-decimal from a packed unsigned fixed-decimal\\n * @param self packed unsigned fixed-decimal\\n * @return New unpacked unsigned fixed-decimal\\n */\\n function unpack(PackedUFixed18 self) internal pure returns (UFixed18) {\\n return UFixed18.wrap(uint256(PackedUFixed18.unwrap(self)));\\n }\\n}\\n\",\"keccak256\":\"0xb5c5cd32d6530b2fe75228b6be32ebcb7762f6d7988b85a6b85a289ce8256d51\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/UFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"./Fixed18.sol\\\";\\nimport \\\"./PackedUFixed18.sol\\\";\\n\\n/// @dev UFixed18 type\\ntype UFixed18 is uint256;\\nusing UFixed18Lib for UFixed18 global;\\ntype UFixed18Storage is bytes32;\\nusing UFixed18StorageLib for UFixed18Storage global;\\n\\n/**\\n * @title UFixed18Lib\\n * @notice Library for the unsigned fixed-decimal type.\\n */\\nlibrary UFixed18Lib {\\n error UFixed18UnderflowError(int256 value);\\n error UFixed18PackingOverflowError(uint256 value);\\n\\n uint256 private constant BASE = 1e18;\\n UFixed18 public constant ZERO = UFixed18.wrap(0);\\n UFixed18 public constant ONE = UFixed18.wrap(BASE);\\n UFixed18 public constant MAX = UFixed18.wrap(type(uint256).max);\\n\\n /**\\n * @notice Creates a unsigned fixed-decimal from a signed fixed-decimal\\n * @param a Signed fixed-decimal\\n * @return New unsigned fixed-decimal\\n */\\n function from(Fixed18 a) internal pure returns (UFixed18) {\\n int256 value = Fixed18.unwrap(a);\\n if (value < 0) revert UFixed18UnderflowError(value);\\n return UFixed18.wrap(uint256(value));\\n }\\n\\n /**\\n * @notice Creates a unsigned fixed-decimal from a unsigned integer\\n * @param a Unsigned number\\n * @return New unsigned fixed-decimal\\n */\\n function from(uint256 a) internal pure returns (UFixed18) {\\n return UFixed18.wrap(a * BASE);\\n }\\n\\n /**\\n * @notice Creates a packed unsigned fixed-decimal from an unsigned fixed-decimal\\n * @param a unsigned fixed-decimal\\n * @return New packed unsigned fixed-decimal\\n */\\n function pack(UFixed18 a) internal pure returns (PackedUFixed18) {\\n uint256 value = UFixed18.unwrap(a);\\n if (value > type(uint128).max) revert UFixed18PackingOverflowError(value);\\n return PackedUFixed18.wrap(uint128(value));\\n }\\n\\n /**\\n * @notice Returns whether the unsigned fixed-decimal is equal to zero.\\n * @param a Unsigned fixed-decimal\\n * @return Whether the unsigned fixed-decimal is zero.\\n */\\n function isZero(UFixed18 a) internal pure returns (bool) {\\n return UFixed18.unwrap(a) == 0;\\n }\\n\\n /**\\n * @notice Adds two unsigned fixed-decimals `a` and `b` together\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Resulting summed unsigned fixed-decimal\\n */\\n function add(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) + UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Subtracts unsigned fixed-decimal `b` from `a`\\n * @param a Unsigned fixed-decimal to subtract from\\n * @param b Unsigned fixed-decimal to subtract\\n * @return Resulting subtracted unsigned fixed-decimal\\n */\\n function sub(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) - UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Multiplies two unsigned fixed-decimals `a` and `b` together\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Resulting multiplied unsigned fixed-decimal\\n */\\n function mul(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / BASE);\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function div(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * BASE / UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0` and `MAX` for `n/0`.\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function unsafeDiv(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n if (isZero(b)) {\\n return isZero(a) ? ONE : MAX;\\n } else {\\n return div(a, b);\\n }\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First unsigned fixed-decimal\\n * @param b Unsigned number to multiply by\\n * @param c Unsigned number to divide by\\n * @return Resulting computation\\n */\\n function muldiv(UFixed18 a, uint256 b, uint256 c) internal pure returns (UFixed18) {\\n return muldiv(a, UFixed18.wrap(b), UFixed18.wrap(c));\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First unsigned fixed-decimal\\n * @param b Unsigned fixed-decimal to multiply by\\n * @param c Unsigned fixed-decimal to divide by\\n * @return Resulting computation\\n */\\n function muldiv(UFixed18 a, UFixed18 b, UFixed18 c) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / UFixed18.unwrap(c));\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is equal to `b`\\n */\\n function eq(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 1;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is greater than `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is greater than `b`\\n */\\n function gt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 2;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is less than `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is less than `b`\\n */\\n function lt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 0;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is greater than or equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is greater than or equal to `b`\\n */\\n function gte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return gt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is less than or equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is less than or equal to `b`\\n */\\n function lte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return lt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Compares the unsigned fixed-decimals `a` and `b`\\n * @dev Returns: 2 for greater than\\n * 1 for equal to\\n * 0 for less than\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Compare result of `a` and `b`\\n */\\n function compare(UFixed18 a, UFixed18 b) internal pure returns (uint256) {\\n (uint256 au, uint256 bu) = (UFixed18.unwrap(a), UFixed18.unwrap(b));\\n if (au > bu) return 2;\\n if (au < bu) return 0;\\n return 1;\\n }\\n\\n /**\\n * @notice Returns a unsigned fixed-decimal representing the ratio of `a` over `b`\\n * @param a First unsigned number\\n * @param b Second unsigned number\\n * @return Ratio of `a` over `b`\\n */\\n function ratio(uint256 a, uint256 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(a * BASE / b);\\n }\\n\\n /**\\n * @notice Returns the minimum of unsigned fixed-decimals `a` and `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Minimum of `a` and `b`\\n */\\n function min(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(Math.min(UFixed18.unwrap(a), UFixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Returns the maximum of unsigned fixed-decimals `a` and `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Maximum of `a` and `b`\\n */\\n function max(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(Math.max(UFixed18.unwrap(a), UFixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Converts the unsigned fixed-decimal into an integer, truncating any decimal portion\\n * @param a Unsigned fixed-decimal\\n * @return Truncated unsigned number\\n */\\n function truncate(UFixed18 a) internal pure returns (uint256) {\\n return UFixed18.unwrap(a) / BASE;\\n }\\n}\\n\\nlibrary UFixed18StorageLib {\\n function read(UFixed18Storage self) internal view returns (UFixed18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(UFixed18Storage self, UFixed18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x8ebef1e6c717f565b9ed545a876b5692b4007e6485c99f39d363f7405e591792\",\"license\":\"Apache-2.0\"},\"@equilibria/root/storage/UStorage.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"../number/types/UFixed18.sol\\\";\\n\\n/// @dev Stored boolean slot\\ntype BoolStorage is bytes32;\\nusing BoolStorageLib for BoolStorage global;\\n\\n/// @dev Stored uint256 slot\\ntype Uint256Storage is bytes32;\\nusing Uint256StorageLib for Uint256Storage global;\\n\\n/// @dev Stored int256 slot\\ntype Int256Storage is bytes32;\\nusing Int256StorageLib for Int256Storage global;\\n\\n/// @dev Stored address slot\\ntype AddressStorage is bytes32;\\nusing AddressStorageLib for AddressStorage global;\\n\\n/// @dev Stored bytes32 slot\\ntype Bytes32Storage is bytes32;\\nusing Bytes32StorageLib for Bytes32Storage global;\\n\\n/**\\n * @title BoolStorageLib\\n * @notice Library to manage storage and retrival of a boolean at a fixed storage slot\\n */\\nlibrary BoolStorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored bool value\\n */\\n function read(BoolStorage self) internal view returns (bool value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value boolean value to store\\n */\\n function store(BoolStorage self, bool value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\\n/**\\n * @title Uint256StorageLib\\n * @notice Library to manage storage and retrival of an uint256 at a fixed storage slot\\n */\\nlibrary Uint256StorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored uint256 value\\n */\\n function read(Uint256Storage self) internal view returns (uint256 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value uint256 value to store\\n */\\n function store(Uint256Storage self, uint256 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\\n/**\\n * @title Int256StorageLib\\n * @notice Library to manage storage and retrival of an int256 at a fixed storage slot\\n */\\nlibrary Int256StorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored int256 value\\n */\\n function read(Int256Storage self) internal view returns (int256 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value int256 value to store\\n */\\n function store(Int256Storage self, int256 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\\n/**\\n * @title AddressStorageLib\\n * @notice Library to manage storage and retrival of an address at a fixed storage slot\\n */\\nlibrary AddressStorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored address value\\n */\\n function read(AddressStorage self) internal view returns (address value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value address value to store\\n */\\n function store(AddressStorage self, address value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\\n/**\\n * @title Bytes32StorageLib\\n * @notice Library to manage storage and retrival of a bytes32 at a fixed storage slot\\n */\\nlibrary Bytes32StorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored bytes32 value\\n */\\n function read(Bytes32Storage self) internal view returns (bytes32 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value bytes32 value to store\\n */\\n function store(Bytes32Storage self, bytes32 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0xe2b8491d1b5aa93f7e059e1a8f156b0ab37fef9ed973be97a64f2eabfc2cc172\",\"license\":\"Apache-2.0\"},\"@equilibria/root/token/types/Token18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"../../number/types/UFixed18.sol\\\";\\n\\n/// @dev Token18\\ntype Token18 is address;\\nusing Token18Lib for Token18 global;\\ntype Token18Storage is bytes32;\\nusing Token18StorageLib for Token18Storage global;\\n\\n/**\\n * @title Token18Lib\\n * @notice Library to manage 18-decimal ERC20s that is compliant with the fixed-decimal types.\\n * @dev Maintains significant gas savings over other Token implementations since no conversion take place\\n */\\nlibrary Token18Lib {\\n using SafeERC20 for IERC20;\\n\\n Token18 public constant ZERO = Token18.wrap(address(0));\\n\\n /**\\n * @notice Returns whether a token is the zero address\\n * @param self Token to check for\\n * @return Whether the token is the zero address\\n */\\n function isZero(Token18 self) internal pure returns (bool) {\\n return Token18.unwrap(self) == Token18.unwrap(ZERO);\\n }\\n\\n /**\\n * @notice Returns whether the two tokens are equal\\n * @param a First token to compare\\n * @param b Second token to compare\\n * @return Whether the two tokens are equal\\n */\\n function eq(Token18 a, Token18 b) internal pure returns (bool) {\\n return Token18.unwrap(a) == Token18.unwrap(b);\\n }\\n\\n /**\\n * @notice Approves `grantee` to spend infinite tokens from the caller\\n * @param self Token to transfer\\n * @param grantee Address to allow spending\\n */\\n function approve(Token18 self, address grantee) internal {\\n IERC20(Token18.unwrap(self)).safeApprove(grantee, type(uint256).max);\\n }\\n\\n /**\\n * @notice Approves `grantee` to spend `amount` tokens from the caller\\n * @dev There are important race conditions to be aware of when using this function\\n with values other than 0. This will revert if moving from non-zero to non-zero amounts\\n See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/a55b7d13722e7ce850b626da2313f3e66ca1d101/contracts/token/ERC20/IERC20.sol#L57\\n * @param self Token to transfer\\n * @param grantee Address to allow spending\\n * @param amount Amount of tokens to approve to spend\\n */\\n function approve(Token18 self, address grantee, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeApprove(grantee, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers all held tokens from the caller to the `recipient`\\n * @param self Token to transfer\\n * @param recipient Address to receive the tokens\\n */\\n function push(Token18 self, address recipient) internal {\\n push(self, recipient, balanceOf(self, address(this)));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the caller to the `recipient`\\n * @param self Token to transfer\\n * @param recipient Address to transfer tokens to\\n * @param amount Amount of tokens to transfer\\n */\\n function push(Token18 self, address recipient, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransfer(recipient, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the `benefactor` to the caller\\n * @dev Reverts if trying to pull Ether\\n * @param self Token to transfer\\n * @param benefactor Address to transfer tokens from\\n * @param amount Amount of tokens to transfer\\n */\\n function pull(Token18 self, address benefactor, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, address(this), UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the `benefactor` to `recipient`\\n * @dev Reverts if trying to pull Ether\\n * @param self Token to transfer\\n * @param benefactor Address to transfer tokens from\\n * @param recipient Address to transfer tokens to\\n * @param amount Amount of tokens to transfer\\n */\\n function pullTo(Token18 self, address benefactor, address recipient, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, recipient, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Returns the name of the token\\n * @param self Token to check for\\n * @return Token name\\n */\\n function name(Token18 self) internal view returns (string memory) {\\n return IERC20Metadata(Token18.unwrap(self)).name();\\n }\\n\\n /**\\n * @notice Returns the symbol of the token\\n * @param self Token to check for\\n * @return Token symbol\\n */\\n function symbol(Token18 self) internal view returns (string memory) {\\n return IERC20Metadata(Token18.unwrap(self)).symbol();\\n }\\n\\n /**\\n * @notice Returns the `self` token balance of the caller\\n * @param self Token to check for\\n * @return Token balance of the caller\\n */\\n function balanceOf(Token18 self) internal view returns (UFixed18) {\\n return balanceOf(self, address(this));\\n }\\n\\n /**\\n * @notice Returns the `self` token balance of `account`\\n * @param self Token to check for\\n * @param account Account to check\\n * @return Token balance of the account\\n */\\n function balanceOf(Token18 self, address account) internal view returns (UFixed18) {\\n return UFixed18.wrap(IERC20(Token18.unwrap(self)).balanceOf(account));\\n }\\n}\\n\\nlibrary Token18StorageLib {\\n function read(Token18Storage self) internal view returns (Token18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(Token18Storage self, Token18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x6b12afaece814f0ab186200a4729e93eb685a21d3e9b5a3372ff283a7ad5dc23\",\"license\":\"Apache-2.0\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\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 amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` 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(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\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\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 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 using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\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 function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc3d946432c0ddbb1f846a0d3985be71299df331b91d06732152117f62f0be2b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // 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\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return 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 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 up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a / b + (a % b == 0 ? 0 : 1);\\n }\\n}\\n\",\"keccak256\":\"0xc995bddbca1ae19788db9f8b61e63385edd3fddf89693b612d5abd1a275974d2\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SignedMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/SignedMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard signed math utilities missing in the Solidity language.\\n */\\nlibrary SignedMath {\\n /**\\n * @dev Returns the largest of two signed numbers.\\n */\\n function max(int256 a, int256 b) internal pure returns (int256) {\\n return 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 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 // must be unchecked in order to support `n = type(int256).min`\\n return uint256(n >= 0 ? n : -n);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb3ebde1c8d27576db912d87c3560dab14adfb9cd001be95890ec4ba035e652e7\",\"license\":\"MIT\"},\"contracts/collateral/Collateral.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"@equilibria/root/control/unstructured/UInitializable.sol\\\";\\nimport \\\"@equilibria/root/control/unstructured/UReentrancyGuard.sol\\\";\\nimport \\\"../interfaces/ICollateral.sol\\\";\\nimport \\\"./types/OptimisticLedger.sol\\\";\\nimport \\\"../controller/UControllerProvider.sol\\\";\\n\\n/**\\n * @title Collateral\\n * @notice Manages logic and state for all collateral accounts in the protocol.\\n */\\ncontract Collateral is ICollateral, UInitializable, UControllerProvider, UReentrancyGuard {\\n /// @dev ERC20 stablecoin for collateral\\n Token18 public immutable token;\\n\\n /// @dev Per product collateral state\\n mapping(IProduct => OptimisticLedger) private _products;\\n\\n /// @dev Protocol and product fees collected, but not yet claimed\\n mapping(address => UFixed18) public fees;\\n\\n /**\\n * @notice Initializes the immutable contract state\\n * @dev Called at implementation instantiate and constant for that implementation.\\n * @param token_ Collateral ERC20 stablecoin address\\n */\\n constructor(Token18 token_) {\\n token = token_;\\n }\\n\\n /**\\n * @notice Initializes the contract state\\n * @dev Must be called atomically as part of the upgradeable proxy deployment to\\n * avoid front-running\\n * @param controller_ Factory contract address\\n */\\n function initialize(IController controller_) external initializer(1) {\\n __UControllerProvider__initialize(controller_);\\n __UReentrancyGuard__initialize();\\n }\\n\\n /**\\n * @notice Deposits `amount` collateral from `msg.sender` to `account`'s `product`\\n * account\\n * @param account Account to deposit the collateral for\\n * @param product Product to credit the collateral to\\n * @param amount Amount of collateral to deposit\\n */\\n function depositTo(address account, IProduct product, UFixed18 amount)\\n external\\n nonReentrant\\n notPaused\\n notZeroAddress(account)\\n isProduct(product)\\n collateralInvariant(account, product)\\n {\\n _products[product].creditAccount(account, amount);\\n token.pull(msg.sender, amount);\\n\\n emit Deposit(account, product, amount);\\n }\\n\\n /**\\n * @notice Withdraws `amount` collateral from `msg.sender`'s `product` account\\n * and sends it to `account`\\n * @param account Account to withdraw the collateral to\\n * @param product Product to withdraw the collateral from\\n * @param amount Amount of collateral to withdraw\\n */\\n function withdrawTo(address account, IProduct product, UFixed18 amount)\\n external\\n nonReentrant\\n notPaused\\n notZeroAddress(account)\\n isProduct(product)\\n settleForAccount(msg.sender, product)\\n collateralInvariant(msg.sender, product)\\n maintenanceInvariant(msg.sender, product)\\n {\\n amount = amount.eq(UFixed18Lib.MAX) ? collateral(msg.sender, product) : amount;\\n _products[product].debitAccount(msg.sender, amount);\\n token.push(account, amount);\\n\\n emit Withdrawal(msg.sender, product, amount);\\n }\\n\\n /**\\n * @notice Liquidates `account`'s `product` collateral account\\n * @dev Account must be under-collateralized, fee returned immediately to `msg.sender`\\n * @param account Account to liquidate\\n * @param product Product to liquidate for\\n */\\n function liquidate(address account, IProduct product)\\n external\\n nonReentrant\\n notPaused\\n isProduct(product)\\n settleForAccount(account, product)\\n {\\n UFixed18 totalMaintenance = product.maintenance(account);\\n UFixed18 totalCollateral = collateral(account, product);\\n\\n if (!totalMaintenance.gt(totalCollateral))\\n revert CollateralCantLiquidate(totalMaintenance, totalCollateral);\\n\\n product.closeAll(account);\\n\\n // claim fee\\n UFixed18 liquidationFee = controller().liquidationFee();\\n UFixed18 fee = UFixed18Lib.min(totalCollateral, totalMaintenance.mul(liquidationFee));\\n\\n _products[product].debitAccount(account, fee);\\n token.push(msg.sender, fee);\\n\\n emit Liquidation(account, product, msg.sender, fee);\\n }\\n\\n /**\\n * @notice Credits `amount` to `account`'s collateral account\\n * @dev Callable only by the corresponding product as part of the settlement flywheel.\\n * Moves collateral within a product, any collateral leaving the product due to\\n * fees has already been accounted for in the settleProduct flywheel.\\n * Debits in excess of the account balance get recorded as shortfall, and can be\\n * resolved by the product owner as needed.\\n * @param account Account to credit\\n * @param amount Amount to credit the account (can be negative)\\n */\\n function settleAccount(address account, Fixed18 amount) external onlyProduct {\\n IProduct product = IProduct(msg.sender);\\n\\n UFixed18 newShortfall = _products[product].settleAccount(account, amount);\\n\\n emit AccountSettle(product, account, amount, newShortfall);\\n }\\n\\n /**\\n * @notice Debits `amount` from product's total collateral account\\n * @dev Callable only by the corresponding product as part of the settlement flywheel\\n * Removes collateral from the product as fees.\\n * @param amount Amount to debit from the account\\n */\\n function settleProduct(UFixed18 amount) external onlyProduct {\\n (IProduct product, IController controller) = (IProduct(msg.sender), controller());\\n\\n address protocolTreasury = controller.treasury();\\n address productTreasury = controller.treasury(product);\\n\\n UFixed18 protocolFee = amount.mul(controller.protocolFee());\\n UFixed18 productFee = amount.sub(protocolFee);\\n\\n _products[product].debit(amount);\\n fees[protocolTreasury] = fees[protocolTreasury].add(protocolFee);\\n fees[productTreasury] = fees[productTreasury].add(productFee);\\n\\n emit ProductSettle(product, protocolFee, productFee);\\n }\\n\\n /**\\n * @notice Returns the balance of `account`'s `product` collateral account\\n * @param account Account to return for\\n * @param product Product to return for\\n * @return The balance of the collateral account\\n */\\n function collateral(address account, IProduct product) public view returns (UFixed18) {\\n return _products[product].balances[account];\\n }\\n\\n /**\\n * @notice Returns the total balance of `product`'s collateral\\n * @param product Product to return for\\n * @return The total balance of collateral in the product\\n */\\n function collateral(IProduct product) external view returns (UFixed18) {\\n return _products[product].total;\\n }\\n\\n /**\\n * @notice Returns the current shortfall of `product`'s collateral\\n * @param product Product to return for\\n * @return The current shortfall of the product\\n */\\n function shortfall(IProduct product) external view returns (UFixed18) {\\n return _products[product].shortfall;\\n }\\n\\n /**\\n * @notice Returns whether `account`'s `product` collateral account can be liquidated\\n * @param account Account to return for\\n * @param product Product to return for\\n * @return Whether the account can be liquidated\\n */\\n function liquidatable(address account, IProduct product) external view returns (bool) {\\n return product.maintenance(account).gt(collateral(account, product));\\n }\\n\\n /**\\n * @notice Returns whether `account`'s `product` collateral account can be liquidated\\n * after the next oracle version settlement\\n * @dev Takes into account the current pre-position on the account\\n * @param account Account to return for\\n * @param product Product to return for\\n * @return Whether the account can be liquidated\\n */\\n function liquidatableNext(address account, IProduct product) external view returns (bool) {\\n return product.maintenanceNext(account).gt(collateral(account, product));\\n }\\n\\n /**\\n * @notice Injects additional collateral into a product to resolve shortfall\\n * @dev Shortfall is a measure of settled insolvency in the market\\n * This hook can be used by the product owner or an insurance fund to re-capitalize an insolvent market\\n * @param product Product to resolve shortfall for\\n * @param amount Amount of shortfall to resolve\\n */\\n function resolveShortfall(IProduct product, UFixed18 amount) external isProduct(product) notPaused {\\n _products[product].resolve(amount);\\n token.pull(msg.sender, amount);\\n\\n emit ShortfallResolution(product, amount);\\n }\\n\\n /**\\n * @notice Claims all of `msg.sender`'s fees\\n */\\n function claimFee() external notPaused {\\n UFixed18 amount = fees[msg.sender];\\n\\n fees[msg.sender] = UFixed18Lib.ZERO;\\n token.push(msg.sender, amount);\\n\\n emit FeeClaim(msg.sender, amount);\\n }\\n\\n /// @dev Ensure that the address is non-zero\\n modifier notZeroAddress(address account) {\\n if (account == address(0)) revert CollateralZeroAddressError();\\n\\n _;\\n }\\n\\n /// @dev Ensure that the user has sufficient margin for both current and next maintenance\\n modifier maintenanceInvariant(address account, IProduct product) {\\n _;\\n\\n UFixed18 maintenance = product.maintenance(account);\\n UFixed18 maintenanceNext = product.maintenanceNext(account);\\n\\n if (UFixed18Lib.max(maintenance, maintenanceNext).gt(collateral(account, product)))\\n revert CollateralInsufficientCollateralError();\\n }\\n\\n /// @dev Ensure that the account is either empty or above the collateral minimum\\n modifier collateralInvariant(address account, IProduct product) {\\n _;\\n\\n UFixed18 accountCollateral = collateral(account, product);\\n if (!accountCollateral.isZero() && accountCollateral.lt(controller().minCollateral()))\\n revert CollateralUnderLimitError();\\n }\\n\\n /// @dev Helper to fully settle an account's state\\n modifier settleForAccount(address account, IProduct product) {\\n product.settleAccount(account);\\n\\n _;\\n }\\n}\\n\",\"keccak256\":\"0x0edef6aaba1aad7829da49892c5549d0ff91d2f085ca7b438f0488ebab00bf83\",\"license\":\"Apache-2.0\"},\"contracts/collateral/types/OptimisticLedger.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\n\\n/// @dev OptimisticLedger type\\nstruct OptimisticLedger {\\n /// @dev Individual account collateral balances\\n mapping(address => UFixed18) balances;\\n\\n /// @dev Total ledger collateral balance\\n UFixed18 total;\\n\\n /// @dev Total ledger collateral shortfall\\n UFixed18 shortfall;\\n}\\nusing OptimisticLedgerLib for OptimisticLedger global;\\n\\n/**\\n * @title OptimisticLedgerLib\\n * @notice Library that manages a global vs account ledger where the global ledger is settled separately,\\n * and ahead of, the user-level accounts.\\n * @dev Ensures that no more collateral leaves the ledger than goes it, while allowing user-level accounts\\n * to settle as a follow up step. Overdrafts on the user-level are accounted as \\\"shortall\\\". Shortfall\\n * in the system is the quantity of insolvency that can be optionally resolved by the ledger owner.\\n * Until the shortfall is resolved, collateral may be withdrawn from the ledger on a FCFS basis. However\\n * once the ledger total has been depleted, users will not be able to withdraw even if they have non-zero\\n * user level balances until the shortfall is resolved, recapitalizing the ledger.\\n */\\nlibrary OptimisticLedgerLib {\\n /**\\n * @notice Credits `account` with `amount` collateral\\n * @param self The struct to operate on\\n * @param account Account to credit collateral to\\n * @param amount Amount of collateral to credit\\n */\\n function creditAccount(OptimisticLedger storage self, address account, UFixed18 amount) internal {\\n self.balances[account] = self.balances[account].add(amount);\\n self.total = self.total.add(amount);\\n }\\n\\n /**\\n * @notice Debits `account` `amount` collateral\\n * @param self The struct to operate on\\n * @param account Account to debit collateral from\\n * @param amount Amount of collateral to debit\\n */\\n function debitAccount(OptimisticLedger storage self, address account, UFixed18 amount) internal {\\n self.balances[account] = self.balances[account].sub(amount);\\n self.total = self.total.sub(amount);\\n }\\n\\n /**\\n * @notice Credits `account` with `amount` collateral\\n * @dev Funds come from inside the product, not totals are updated\\n * Shortfall is created if more funds are debited from an account than exist\\n * @param self The struct to operate on\\n * @param account Account to credit collateral to\\n * @param amount Amount of collateral to credit\\n * @return newShortfall Any new shortfall incurred during this settlement\\n */\\n function settleAccount(OptimisticLedger storage self, address account, Fixed18 amount)\\n internal returns (UFixed18 newShortfall) {\\n Fixed18 newBalance = Fixed18Lib.from(self.balances[account]).add(amount);\\n\\n if (newBalance.sign() == -1) {\\n newShortfall = newBalance.abs();\\n newBalance = Fixed18Lib.ZERO;\\n }\\n\\n self.balances[account] = newBalance.abs();\\n self.shortfall = self.shortfall.add(newShortfall);\\n }\\n\\n /**\\n * @notice Debits ledger globally `amount` collateral\\n * @dev Removes balance from total that is accounted for elsewhere (e.g. product-level accumulators)\\n * @param self The struct to operate on\\n * @param amount Amount of collateral to debit\\n */\\n function debit(OptimisticLedger storage self, UFixed18 amount) internal {\\n self.total = self.total.sub(amount);\\n }\\n\\n /**\\n * @notice Reduces the amount of collateral shortfall in the ledger\\n * @param self The struct to operate on\\n * @param amount Amount of shortfall to resolve\\n */\\n function resolve(OptimisticLedger storage self, UFixed18 amount) internal {\\n self.shortfall = self.shortfall.sub(amount);\\n self.total = self.total.add(amount);\\n }\\n}\\n\",\"keccak256\":\"0xb0cd6ded1435a956c2f3f8d9f9dd7fa21da1f3e300d4111f8575c51eba41d03d\",\"license\":\"Apache-2.0\"},\"contracts/controller/UControllerProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"@equilibria/root/control/unstructured/UInitializable.sol\\\";\\nimport \\\"@equilibria/root/storage/UStorage.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/Address.sol\\\";\\nimport \\\"../interfaces/IController.sol\\\";\\nimport \\\"../interfaces/IProduct.sol\\\";\\n\\n/**\\n * @title UControllerProvider\\n * @notice Mix-in that manages a controller pointer and associated permissioning modifiers.\\n * @dev Uses unstructured storage so that it is safe to mix-in to upgreadable contracts without modifying\\n * their storage layout.\\n */\\nabstract contract UControllerProvider is UInitializable {\\n error NotOwnerError(uint256 coordinatorId);\\n error NotProductError(IProduct product);\\n error NotCollateralError();\\n error PausedError();\\n error InvalidControllerError();\\n\\n /// @dev The controller contract address\\n AddressStorage private constant _controller = AddressStorage.wrap(keccak256(\\\"equilibria.perennial.UControllerProvider.controller\\\"));\\n function controller() public view returns (IController) { return IController(_controller.read()); }\\n\\n /**\\n * @notice Initializes the contract state\\n * @param controller_ Protocol Controller contract address\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function __UControllerProvider__initialize(IController controller_) internal onlyInitializer {\\n if (!Address.isContract(address(controller_))) revert InvalidControllerError();\\n _controller.store(address(controller_));\\n }\\n\\n /// @dev Only allow a valid product contract to call\\n modifier onlyProduct {\\n if (!controller().isProduct(IProduct(msg.sender))) revert NotProductError(IProduct(msg.sender));\\n\\n _;\\n }\\n\\n /// @dev Verify that `product` is a valid product contract\\n modifier isProduct(IProduct product) {\\n if (!controller().isProduct(product)) revert NotProductError(product);\\n\\n _;\\n }\\n\\n /// @dev Only allow the Collateral contract to call\\n modifier onlyCollateral {\\n if (msg.sender != address(controller().collateral())) revert NotCollateralError();\\n\\n _;\\n }\\n\\n /// @dev Only allow the coordinator owner to call\\n modifier onlyOwner(uint256 coordinatorId) {\\n if (msg.sender != controller().owner(coordinatorId)) revert NotOwnerError(coordinatorId);\\n\\n _;\\n }\\n\\n /// @dev Only allow if the protocol is currently unpaused\\n modifier notPaused() {\\n if (controller().paused()) revert PausedError();\\n\\n _;\\n }\\n}\\n\",\"keccak256\":\"0x10c6f4ae1a3a511aad470e40c61de5b2171f4151e2dea000acd2ffbd26dcbc2a\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/ICollateral.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"./IController.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\n\\ninterface ICollateral {\\n event Deposit(address indexed user, IProduct indexed product, UFixed18 amount);\\n event Withdrawal(address indexed user, IProduct indexed product, UFixed18 amount);\\n event AccountSettle(IProduct indexed product, address indexed account, Fixed18 amount, UFixed18 newShortfall);\\n event ProductSettle(IProduct indexed product, UFixed18 protocolFee, UFixed18 productFee);\\n event Liquidation(address indexed user, IProduct indexed product, address liquidator, UFixed18 fee);\\n event ShortfallResolution(IProduct indexed product, UFixed18 amount);\\n event FeeClaim(address indexed account, UFixed18 amount);\\n\\n error CollateralCantLiquidate(UFixed18 totalMaintenance, UFixed18 totalCollateral);\\n error CollateralInsufficientCollateralError();\\n error CollateralUnderLimitError();\\n error CollateralZeroAddressError();\\n\\n function token() external view returns (Token18);\\n function fees(address account) external view returns (UFixed18);\\n function initialize(IController controller_) external;\\n function depositTo(address account, IProduct product, UFixed18 amount) external;\\n function withdrawTo(address account, IProduct product, UFixed18 amount) external;\\n function liquidate(address account, IProduct product) external;\\n function settleAccount(address account, Fixed18 amount) external;\\n function settleProduct(UFixed18 amount) external;\\n function collateral(address account, IProduct product) external view returns (UFixed18);\\n function collateral(IProduct product) external view returns (UFixed18);\\n function shortfall(IProduct product) external view returns (UFixed18);\\n function liquidatable(address account, IProduct product) external view returns (bool);\\n function liquidatableNext(address account, IProduct product) external view returns (bool);\\n function resolveShortfall(IProduct product, UFixed18 amount) external;\\n function claimFee() external;\\n}\\n\",\"keccak256\":\"0xa5e7fdda92702f748e6eb8701e522450035a98a05e5fc1cf66d51c52e397d914\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IContractPayoffProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\n\\ninterface IContractPayoffProvider {\\n function payoff(Fixed18 price) external view returns (Fixed18 payoff);\\n}\\n\",\"keccak256\":\"0xd73df106d032e976fd959ee6713240e36f54277ce5f215eaec8d5a2c6720a86b\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IController.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\\\";\\nimport \\\"./ICollateral.sol\\\";\\nimport \\\"./IIncentivizer.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\n\\ninterface IController {\\n /// @dev Coordinator of a one or many products\\n struct Coordinator {\\n /// @dev Pending owner of the product, can accept ownership\\n address pendingOwner;\\n\\n /// @dev Owner of the product, allowed to update select parameters\\n address owner;\\n\\n /// @dev Treasury of the product, collects fees\\n address treasury;\\n }\\n\\n event CollateralUpdated(ICollateral newCollateral);\\n event IncentivizerUpdated(IIncentivizer newIncentivizer);\\n event ProductBeaconUpdated(IBeacon newProductBeacon);\\n event ProtocolFeeUpdated(UFixed18 newProtocolFee);\\n event MinFundingFeeUpdated(UFixed18 newMinFundingFee);\\n event LiquidationFeeUpdated(UFixed18 newLiquidationFee);\\n event IncentivizationFeeUpdated(UFixed18 newIncentivizationFee);\\n event MinCollateralUpdated(UFixed18 newMinCollateral);\\n event ProgramsPerProductUpdated(uint256 newProgramsPerProduct);\\n event PauserUpdated(address newPauser);\\n event PausedUpdated(bool newPaused);\\n event CoordinatorPendingOwnerUpdated(uint256 indexed coordinatorId, address newPendingOwner);\\n event CoordinatorOwnerUpdated(uint256 indexed coordinatorId, address newOwner);\\n event CoordinatorTreasuryUpdated(uint256 indexed coordinatorId, address newTreasury);\\n event CoordinatorCreated(uint256 indexed coordinatorId, address owner);\\n event ProductCreated(IProduct indexed product, IProduct.ProductInfo productInfo);\\n\\n error ControllerNoZeroCoordinatorError();\\n error ControllerNotPauserError();\\n error ControllerNotOwnerError(uint256 controllerId);\\n error ControllerNotPendingOwnerError(uint256 controllerId);\\n error ControllerInvalidProtocolFeeError();\\n error ControllerInvalidMinFundingFeeError();\\n error ControllerInvalidLiquidationFeeError();\\n error ControllerInvalidIncentivizationFeeError();\\n error ControllerNotContractAddressError();\\n\\n function collateral() external view returns (ICollateral);\\n function incentivizer() external view returns (IIncentivizer);\\n function productBeacon() external view returns (IBeacon);\\n function coordinators(uint256 collateralId) external view returns (Coordinator memory);\\n function coordinatorFor(IProduct product) external view returns (uint256);\\n function protocolFee() external view returns (UFixed18);\\n function minFundingFee() external view returns (UFixed18);\\n function liquidationFee() external view returns (UFixed18);\\n function incentivizationFee() external view returns (UFixed18);\\n function minCollateral() external view returns (UFixed18);\\n function programsPerProduct() external view returns (uint256);\\n function pauser() external view returns (address);\\n function paused() external view returns (bool);\\n function initialize(ICollateral collateral_, IIncentivizer incentivizer_, IBeacon productBeacon_) external;\\n function createCoordinator() external returns (uint256);\\n function updateCoordinatorPendingOwner(uint256 coordinatorId, address newPendingOwner) external;\\n function acceptCoordinatorOwner(uint256 coordinatorId) external;\\n function updateCoordinatorTreasury(uint256 coordinatorId, address newTreasury) external;\\n function createProduct(uint256 coordinatorId, IProduct.ProductInfo calldata productInfo) external returns (IProduct);\\n function updateCollateral(ICollateral newCollateral) external;\\n function updateIncentivizer(IIncentivizer newIncentivizer) external;\\n function updateProductBeacon(IBeacon newProductBeacon) external;\\n function updateProtocolFee(UFixed18 newProtocolFee) external;\\n function updateMinFundingFee(UFixed18 newMinFundingFee) external;\\n function updateLiquidationFee(UFixed18 newLiquidationFee) external;\\n function updateIncentivizationFee(UFixed18 newIncentivizationFee) external;\\n function updateMinCollateral(UFixed18 newMinCollateral) external;\\n function updateProgramsPerProduct(uint256 newProductsPerProduct) external;\\n function updatePauser(address newPauser) external;\\n function updatePaused(bool newPaused) external;\\n function isProduct(IProduct product) external view returns (bool);\\n function owner() external view returns (address);\\n function owner(uint256 coordinatorId) external view returns (address);\\n function owner(IProduct product) external view returns (address);\\n function treasury() external view returns (address);\\n function treasury(uint256 coordinatorId) external view returns (address);\\n function treasury(IProduct product) external view returns (address);\\n}\\n\",\"keccak256\":\"0xaabd3740f2265499eea7aad9bd94f9892f53241e5dccce9a50c0e43ed2a6a7cc\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IIncentivizer.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./types/ProgramInfo.sol\\\";\\nimport \\\"./IController.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\n\\ninterface IIncentivizer {\\n event ProgramCreated(IProduct indexed product, uint256 indexed programId, ProgramInfo programInfo, UFixed18 programFeeAmount);\\n event ProgramStarted(IProduct indexed product, uint256 indexed programId, uint256 version);\\n event ProgramComplete(IProduct indexed product, uint256 indexed programId, uint256 version);\\n event Claim(IProduct indexed product, address indexed account, uint256 indexed programId, UFixed18 amount);\\n event FeeClaim(Token18 indexed token, UFixed18 amount);\\n\\n error IncentivizerNotAllowedError(IProduct product);\\n error IncentivizerTooManyProgramsError();\\n error IncentivizerNotProgramOwnerError(IProduct product, uint256 programId);\\n error IncentivizerInvalidProgramError(IProduct product, uint256 programId);\\n error IncentivizerBatchClaimArgumentMismatchError();\\n\\n function programInfos(IProduct product, uint256 programId) external view returns (ProgramInfo memory);\\n function fees(Token18 token) external view returns (UFixed18);\\n function initialize(IController controller_) external;\\n function create(IProduct product, ProgramInfo calldata info) external returns (uint256);\\n function complete(IProduct product, uint256 programId) external;\\n function sync(IOracleProvider.OracleVersion memory currentOracleVersion) external;\\n function syncAccount(address account, IOracleProvider.OracleVersion memory currentOracleVersion) external;\\n function claim(IProduct product, uint256[] calldata programIds) external;\\n function claim(IProduct[] calldata products, uint256[][] calldata programIds) external;\\n function claimFee(Token18[] calldata tokens) external;\\n function active(IProduct product) external view returns (uint256);\\n function count(IProduct product) external view returns (uint256);\\n function unclaimed(IProduct product, address account, uint256 programId) external view returns (UFixed18);\\n function available(IProduct product, uint256 programId) external view returns (UFixed18);\\n function versionStarted(IProduct product, uint256 programId) external view returns (uint256);\\n function versionComplete(IProduct product, uint256 programId) external view returns (uint256);\\n function owner(IProduct product, uint256 programId) external view returns (address);\\n function treasury(IProduct product, uint256 programId) external view returns (address);\\n}\\n\",\"keccak256\":\"0x2f95de90dbb3ad35dbfef304f765a622bffff9229868d2898eca8d49c78e8c2c\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IParamProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\\\";\\n\\ninterface IParamProvider {\\n event MaintenanceUpdated(UFixed18 newMaintenance);\\n event FundingFeeUpdated(UFixed18 newFundingFee);\\n event MakerFeeUpdated(UFixed18 newMakerFee);\\n event TakerFeeUpdated(UFixed18 newTakerFee);\\n event MakerLimitUpdated(UFixed18 newMakerLimit);\\n event JumpRateUtilizationCurveUpdated(\\n Fixed18 minRate,\\n Fixed18 maxRate,\\n Fixed18 targetRate,\\n UFixed18 targetUtilization\\n );\\n\\n error ParamProviderInvalidMakerFee();\\n error ParamProviderInvalidTakerFee();\\n error ParamProviderInvalidFundingFee();\\n \\n function maintenance() external view returns (UFixed18);\\n function updateMaintenance(UFixed18 newMaintenance) external;\\n function fundingFee() external view returns (UFixed18);\\n function updateFundingFee(UFixed18 newFundingFee) external;\\n function makerFee() external view returns (UFixed18);\\n function updateMakerFee(UFixed18 newMakerFee) external;\\n function takerFee() external view returns (UFixed18);\\n function updateTakerFee(UFixed18 newTakerFee) external;\\n function makerLimit() external view returns (UFixed18);\\n function updateMakerLimit(UFixed18 newMakerLimit) external;\\n function utilizationCurve() external view returns (JumpRateUtilizationCurve memory);\\n function updateUtilizationCurve(JumpRateUtilizationCurve memory newUtilizationCurve) external;\\n}\\n\",\"keccak256\":\"0x2e2d40d0cf55f167118867e41f740b9b40614d05da50fc9bc33a8cede3eaf03e\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IPayoffProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\n\\ninterface IPayoffProvider {\\n error PayoffProviderInvalidOracle();\\n error PayoffProviderInvalidPayoffDefinitionError();\\n\\n function oracle() external view returns (IOracleProvider);\\n function payoffDefinition() external view returns (PayoffDefinition memory);\\n function currentVersion() external view returns (IOracleProvider.OracleVersion memory);\\n function atVersion(uint256 oracleVersion) external view returns (IOracleProvider.OracleVersion memory);\\n}\\n\",\"keccak256\":\"0xb83d80d624aa9431763f80ecb4bf0214803e25334a7419d954f929e5d0ee7467\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IProduct.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\\\";\\nimport \\\"./IPayoffProvider.sol\\\";\\nimport \\\"./IParamProvider.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\nimport \\\"./types/Position.sol\\\";\\nimport \\\"./types/PrePosition.sol\\\";\\nimport \\\"./types/Accumulator.sol\\\";\\n\\ninterface IProduct is IPayoffProvider, IParamProvider {\\n /// @dev Product Creation parameters\\n struct ProductInfo {\\n /// @dev name of the product\\n string name;\\n\\n /// @dev symbol of the product\\n string symbol;\\n\\n /// @dev product payoff definition\\n PayoffDefinition payoffDefinition;\\n\\n /// @dev oracle address\\n IOracleProvider oracle;\\n\\n /// @dev product maintenance ratio\\n UFixed18 maintenance;\\n\\n /// @dev product funding fee\\n UFixed18 fundingFee;\\n\\n /// @dev product maker fee\\n UFixed18 makerFee;\\n\\n /// @dev product taker fee\\n UFixed18 takerFee;\\n\\n /// @dev product maker limit\\n UFixed18 makerLimit;\\n\\n /// @dev utulization curve definition\\n JumpRateUtilizationCurve utilizationCurve;\\n }\\n\\n event Settle(uint256 preVersion, uint256 toVersion);\\n event AccountSettle(address indexed account, uint256 preVersion, uint256 toVersion);\\n event MakeOpened(address indexed account, uint256 version, UFixed18 amount);\\n event TakeOpened(address indexed account, uint256 version, UFixed18 amount);\\n event MakeClosed(address indexed account, uint256 version, UFixed18 amount);\\n event TakeClosed(address indexed account, uint256 version, UFixed18 amount);\\n event ClosedUpdated(bool indexed newClosed, uint256 version);\\n\\n error ProductInsufficientLiquidityError(UFixed18 socializationFactor);\\n error ProductDoubleSidedError();\\n error ProductOverClosedError();\\n error ProductInsufficientCollateralError();\\n error ProductInLiquidationError();\\n error ProductMakerOverLimitError();\\n error ProductOracleBootstrappingError();\\n error ProductNotOwnerError();\\n error ProductInvalidOracle();\\n error ProductClosedError();\\n\\n function name() external view returns (string memory);\\n function symbol() external view returns (string memory);\\n function initialize(ProductInfo calldata productInfo_) external;\\n function settle() external;\\n function settleAccount(address account) external;\\n function openTake(UFixed18 amount) external;\\n function closeTake(UFixed18 amount) external;\\n function openMake(UFixed18 amount) external;\\n function closeMake(UFixed18 amount) external;\\n function closeAll(address account) external;\\n function maintenance(address account) external view returns (UFixed18);\\n function maintenanceNext(address account) external view returns (UFixed18);\\n function isClosed(address account) external view returns (bool);\\n function isLiquidating(address account) external view returns (bool);\\n function position(address account) external view returns (Position memory);\\n function pre(address account) external view returns (PrePosition memory);\\n function latestVersion() external view returns (uint256);\\n function positionAtVersion(uint256 oracleVersion) external view returns (Position memory);\\n function pre() external view returns (PrePosition memory);\\n function valueAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\\n function shareAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\\n function latestVersion(address account) external view returns (uint256);\\n function rate(Position memory position) external view returns (Fixed18);\\n function closed() external view returns (bool);\\n function updateClosed(bool newClosed) external;\\n}\\n\",\"keccak256\":\"0xe1e80b818eadf4cdb070362e40c7cf3863b50c4f944816af27848e319f587241\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/Accumulator.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"./PackedAccumulator.sol\\\";\\n\\n/// @dev Accumulator type\\nstruct Accumulator {\\n /// @dev maker accumulator per share\\n Fixed18 maker;\\n /// @dev taker accumulator per share\\n Fixed18 taker;\\n}\\nusing AccumulatorLib for Accumulator global;\\n\\n/**\\n * @title AccountAccumulatorLib\\n * @notice Library that surfaces math operations for the Accumulator type.\\n * @dev Accumulators track the cumulative change in position value over time for the maker and taker positions\\n * respectively. Account-level accumulators can then use two of these values `a` and `a'` to compute the\\n * change in position value since last sync. This change in value is then used to compute P&L and fees.\\n */\\nlibrary AccumulatorLib {\\n /**\\n * @notice Creates a packed accumulator from an accumulator\\n * @param self an accumulator\\n * @return New packed accumulator\\n */\\n function pack(Accumulator memory self) internal pure returns (PackedAccumulator memory) {\\n return PackedAccumulator({maker: self.maker.pack(), taker: self.taker.pack()});\\n }\\n\\n /**\\n * @notice Adds two accumulators together\\n * @param a The first accumulator to sum\\n * @param b The second accumulator to sum\\n * @return The resulting summed accumulator\\n */\\n function add(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\\n }\\n\\n /**\\n * @notice Subtracts accumulator `b` from `a`\\n * @param a The accumulator to subtract from\\n * @param b The accumulator to subtract\\n * @return The resulting subtracted accumulator\\n */\\n function sub(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\\n }\\n\\n /**\\n * @notice Multiplies two accumulators together\\n * @param a The first accumulator to multiply\\n * @param b The second accumulator to multiply\\n * @return The resulting multiplied accumulator\\n */\\n function mul(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.mul(b.maker), taker: a.taker.mul(b.taker)});\\n }\\n\\n /**\\n * @notice Sums the maker and taker together from a single accumulator\\n * @param self The struct to operate on\\n * @return The sum of its maker and taker\\n */\\n function sum(Accumulator memory self) internal pure returns (Fixed18) {\\n return self.maker.add(self.taker);\\n }\\n}\\n\",\"keccak256\":\"0x7ccd0a72aa593cefb9f4337cf312799f357b82fcb3f0379de0dc503d1cb7e387\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PackedAccumulator.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/PackedFixed18.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\n\\n/// @dev PackedAccumulator type\\nstruct PackedAccumulator {\\n /// @dev maker accumulator per share\\n PackedFixed18 maker;\\n /// @dev taker accumulator per share\\n PackedFixed18 taker;\\n}\\nusing PackedAccumulatorLib for PackedAccumulator global;\\n\\n/**\\n * @title PackedAccumulatorLib\\n * @dev A packed version of the Accumulator which takes up a single storage slot using `PackedFixed18` values.\\n * @notice Library for the packed Accumulator type.\\n */\\nlibrary PackedAccumulatorLib {\\n /**\\n * @notice Creates an accumulator from a packed accumulator\\n * @param self packed accumulator\\n * @return New accumulator\\n */\\n function unpack(PackedAccumulator memory self) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: self.maker.unpack(), taker: self.taker.unpack()});\\n }\\n}\\n\",\"keccak256\":\"0xd83f2822d4f6c818087a232b54007730992c34ff77377fc307a282f886e7cf65\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PackedPosition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/PackedUFixed18.sol\\\";\\nimport \\\"./Position.sol\\\";\\n\\n/// @dev PackedPosition type\\nstruct PackedPosition {\\n /// @dev Quantity of the maker position\\n PackedUFixed18 maker;\\n /// @dev Quantity of the taker position\\n PackedUFixed18 taker;\\n}\\nusing PackedPositionLib for PackedPosition global;\\n\\n/**\\n * @title PackedPositionLib\\n * @dev A packed version of the Position which takes up a single storage slot using `PackedFixed18` values.\\n * @notice Library for the packed Position type.\\n */\\nlibrary PackedPositionLib {\\n /**\\n * @notice Creates an position from a packed position\\n * @param self packed position\\n * @return New position\\n */\\n function unpack(PackedPosition memory self) internal pure returns (Position memory) {\\n return Position({maker: self.maker.unpack(), taker: self.taker.unpack()});\\n }\\n}\\n\",\"keccak256\":\"0x04968e6794f6244cb3415cea111d640273a81faea957872988d0cb580f45df1e\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PayoffDefinition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"@openzeppelin/contracts/utils/Address.sol\\\";\\nimport \\\"../../interfaces/IContractPayoffProvider.sol\\\";\\n\\n/// @dev PayoffDefinition tyoe\\nstruct PayoffDefinition {\\n PayoffDefinitionLib.PayoffType payoffType;\\n PayoffDefinitionLib.PayoffDirection payoffDirection;\\n bytes30 data;\\n}\\nusing PayoffDefinitionLib for PayoffDefinition global;\\ntype PayoffDefinitionStorage is bytes32;\\nusing PayoffDefinitionStorageLib for PayoffDefinitionStorage global;\\n\\n/**\\n * @title PayoffDefinitionLib\\n * @dev Library that surfaces logic for PayoffDefinition type functionality\\n * @notice Library for the PayoffDefinition type. Performs validity and price transformation\\n based on the payoff definition type.\\n */\\nlibrary PayoffDefinitionLib {\\n using Address for address;\\n\\n error PayoffDefinitionUnsupportedTransform(PayoffType payoffType, PayoffDirection payoffDirection);\\n error PayoffDefinitionNotContract(PayoffType payoffType, bytes30 data);\\n\\n /// @dev Payoff function type enum\\n enum PayoffType { PASSTHROUGH, CONTRACT }\\n enum PayoffDirection { LONG, SHORT }\\n\\n /**\\n * @notice Checks validity of the payoff definition\\n * @param self a payoff definition\\n * @return Whether the payoff definition is valid for it's given type\\n */\\n function valid(PayoffDefinition memory self) internal view returns (bool) {\\n if (self.payoffType == PayoffType.CONTRACT) return address(_providerContract(self)).isContract();\\n\\n // All other payoff types should have no data\\n return uint(bytes32(self.data)) == 0;\\n }\\n\\n /**\\n * @notice Transforms a price based on the payoff definition\\n * @param self a payoff definition\\n * @param price raw oracle price\\n * @return Price transformed by the payoff definition function\\n */\\n function transform(\\n PayoffDefinition memory self,\\n Fixed18 price\\n ) internal view returns (Fixed18) {\\n PayoffType payoffType = self.payoffType;\\n PayoffDirection payoffDirection = self.payoffDirection;\\n Fixed18 transformedPrice;\\n\\n // First get the price depending on the type\\n if (payoffType == PayoffType.PASSTHROUGH) transformedPrice = price;\\n else if (payoffType == PayoffType.CONTRACT) transformedPrice = _payoffFromContract(self, price);\\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\\n\\n // Then transform it depending on the direction flag\\n if (self.payoffDirection == PayoffDirection.LONG) return transformedPrice;\\n else if (self.payoffDirection == PayoffDirection.SHORT) return transformedPrice.mul(Fixed18Lib.NEG_ONE);\\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\\n }\\n\\n /**\\n * @notice Parses the data field into an address\\n * @dev Reverts if payoffType is not CONTRACT\\n * @param self a payoff definition\\n * @return IContractPayoffProvider address\\n */\\n function _providerContract(\\n PayoffDefinition memory self\\n ) private pure returns (IContractPayoffProvider) {\\n if (self.payoffType != PayoffType.CONTRACT) revert PayoffDefinitionNotContract(self.payoffType, self.data);\\n // Shift to pull the last 20 bytes, then cast to an address\\n return IContractPayoffProvider(address(bytes20(self.data << 80)));\\n }\\n\\n /**\\n * @notice Performs a price transformation by calling the underlying payoff contract\\n * @param self a payoff definition\\n * @param price raw oracle price\\n * @return Price transformed by the payoff definition function on the contract\\n */\\n function _payoffFromContract(\\n PayoffDefinition memory self,\\n Fixed18 price\\n ) private view returns (Fixed18) {\\n bytes memory ret = address(_providerContract(self)).functionStaticCall(\\n abi.encodeCall(IContractPayoffProvider.payoff, price)\\n );\\n return Fixed18.wrap(abi.decode(ret, (int256)));\\n }\\n}\\n\\n/**\\n * @title PayoffDefinitionStorageLib\\n * @notice Library that surfaces storage read and writes for the PayoffDefinition type\\n */\\nlibrary PayoffDefinitionStorageLib {\\n function read(PayoffDefinitionStorage self) internal view returns (PayoffDefinition memory) {\\n return _storagePointer(self);\\n }\\n\\n function store(PayoffDefinitionStorage self, PayoffDefinition memory value) internal {\\n PayoffDefinition storage storagePointer = _storagePointer(self);\\n\\n storagePointer.payoffType = value.payoffType;\\n storagePointer.payoffDirection = value.payoffDirection;\\n storagePointer.data = value.data;\\n }\\n\\n function _storagePointer(\\n PayoffDefinitionStorage self\\n ) private pure returns (PayoffDefinition storage pointer) {\\n assembly { pointer.slot := self }\\n }\\n}\\n\",\"keccak256\":\"0x4d3897f408f77381c5ae9990391465c8fd511ddf6ff3b39f6cb69d8c2bd554df\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/Position.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\nimport \\\"./PrePosition.sol\\\";\\nimport \\\"./PackedPosition.sol\\\";\\n\\n/// @dev Position type\\nstruct Position {\\n /// @dev Quantity of the maker position\\n UFixed18 maker;\\n /// @dev Quantity of the taker position\\n UFixed18 taker;\\n}\\nusing PositionLib for Position global;\\n\\n/**\\n * @title PositionLib\\n * @notice Library that surfaces math and settlement computations for the Position type.\\n * @dev Positions track the current quantity of the account's maker and taker positions respectively\\n * denominated as a unit of the product's payoff function.\\n */\\nlibrary PositionLib {\\n /**\\n * @notice Creates a packed position from an position\\n * @param self A position\\n * @return New packed position\\n */\\n function pack(Position memory self) internal pure returns (PackedPosition memory) {\\n return PackedPosition({maker: self.maker.pack(), taker: self.taker.pack()});\\n }\\n\\n /**\\n * @notice Returns whether the position is fully empty\\n * @param self A position\\n * @return Whether the position is empty\\n */\\n function isEmpty(Position memory self) internal pure returns (bool) {\\n return self.maker.isZero() && self.taker.isZero();\\n }\\n\\n /**\\n * @notice Adds position `a` and `b` together, returning the result\\n * @param a The first position to sum\\n * @param b The second position to sum\\n * @return Resulting summed position\\n */\\n function add(Position memory a, Position memory b) internal pure returns (Position memory) {\\n return Position({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\\n }\\n\\n /**\\n * @notice Subtracts position `b` from `a`, returning the result\\n * @param a The position to subtract from\\n * @param b The position to subtract\\n * @return Resulting subtracted position\\n */\\n function sub(Position memory a, Position memory b) internal pure returns (Position memory) {\\n return Position({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\\n }\\n\\n /**\\n * @notice Multiplies position `self` by accumulator `accumulator` and returns the resulting accumulator\\n * @param self The Position to operate on\\n * @param accumulator The accumulator to multiply by\\n * @return Resulting multiplied accumulator\\n */\\n function mul(Position memory self, Accumulator memory accumulator) internal pure returns (Accumulator memory) {\\n return Accumulator({\\n maker: Fixed18Lib.from(self.maker).mul(accumulator.maker),\\n taker: Fixed18Lib.from(self.taker).mul(accumulator.taker)\\n });\\n }\\n\\n /**\\n * @notice Scales position `self` by fixed-decimal `scale` and returns the resulting position\\n * @param self The Position to operate on\\n * @param scale The Fixed-decimal to scale by\\n * @return Resulting scaled position\\n */\\n function mul(Position memory self, UFixed18 scale) internal pure returns (Position memory) {\\n return Position({maker: self.maker.mul(scale), taker: self.taker.mul(scale)});\\n }\\n\\n /**\\n * @notice Divides position `self` by `b` and returns the resulting accumulator\\n * @param self The Position to operate on\\n * @param b The number to divide by\\n * @return Resulting divided accumulator\\n */\\n function div(Position memory self, uint256 b) internal pure returns (Accumulator memory) {\\n return Accumulator({\\n maker: Fixed18Lib.from(self.maker).div(Fixed18Lib.from(UFixed18Lib.from(b))),\\n taker: Fixed18Lib.from(self.taker).div(Fixed18Lib.from(UFixed18Lib.from(b)))\\n });\\n }\\n\\n /**\\n * @notice Returns the maximum of `self`'s maker and taker values\\n * @param self The struct to operate on\\n * @return Resulting maximum value\\n */\\n function max(Position memory self) internal pure returns (UFixed18) {\\n return UFixed18Lib.max(self.maker, self.taker);\\n }\\n\\n /**\\n * @notice Sums the maker and taker together from a single position\\n * @param self The struct to operate on\\n * @return The sum of its maker and taker\\n */\\n function sum(Position memory self) internal pure returns (UFixed18) {\\n return self.maker.add(self.taker);\\n }\\n\\n /**\\n * @notice Computes the next position after the pending-settlement position delta is included\\n * @param self The current Position\\n * @param pre The pending-settlement position delta\\n * @return Next Position\\n */\\n function next(Position memory self, PrePosition memory pre) internal pure returns (Position memory) {\\n return sub(add(self, pre.openPosition), pre.closePosition);\\n }\\n\\n /**\\n * @notice Returns the settled position at oracle version `toOracleVersion`\\n * @dev Checks if a new position is ready to be settled based on the provided `toOracleVersion`\\n * and `pre` and returns accordingly\\n * @param self The current Position\\n * @param pre The pending-settlement position delta\\n * @param toOracleVersion The oracle version to settle to\\n * @return Settled position at oracle version\\n * @return Fee accrued from opening or closing the position\\n * @return Whether a new position was settled\\n */\\n function settled(\\n Position memory self,\\n PrePosition memory pre,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal view returns (Position memory, UFixed18, bool) {\\n return pre.canSettle(toOracleVersion) ? (next(self, pre), pre.computeFee(toOracleVersion), true) : (self, UFixed18Lib.ZERO, false);\\n }\\n\\n /**\\n * @notice Returns the socialization factor for the current position\\n * @dev Socialization account for the case where `taker` > `maker` temporarily due to a liquidation\\n * on the maker side. This dampens the taker's exposure pro-rata to ensure that the maker side\\n * is never exposed over 1 x short.\\n * @param self The Position to operate on\\n * @return Socialization factor\\n */\\n function socializationFactor(Position memory self) internal pure returns (UFixed18) {\\n return self.taker.isZero() ? UFixed18Lib.ONE : UFixed18Lib.min(UFixed18Lib.ONE, self.maker.div(self.taker));\\n }\\n}\\n\",\"keccak256\":\"0x027fe392c4f56bf012ba2ca462fcf23e69f2c3b9d283c14089771813437af991\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PrePosition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./Position.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\n\\n/// @dev PrePosition type\\nstruct PrePosition {\\n /// @dev Oracle version at which the new position delta was recorded\\n uint256 oracleVersion;\\n\\n /// @dev Size of position to open at oracle version\\n Position openPosition;\\n\\n /// @dev Size of position to close at oracle version\\n Position closePosition;\\n}\\nusing PrePositionLib for PrePosition global;\\n\\n/**\\n * @title PrePositionLib\\n * @notice Library that manages a pre-settlement position delta.\\n * @dev PrePositions track the currently awaiting-settlement deltas to a settled Position. These are\\n * Primarily necessary to introduce lag into the settlement system such that oracle lag cannot be\\n * gamed to a user's advantage. When a user opens or closes a new position, it sits as a PrePosition\\n * for one oracle version until it's settle into the Position, making it then effective. PrePositions\\n * are automatically settled at the correct oracle version even if a flywheel call doesn't happen until\\n * several version into the future by using the historical version lookups in the corresponding \\\"Versioned\\\"\\n * global state types.\\n */\\nlibrary PrePositionLib {\\n /**\\n * @notice Returns whether there is no pending-settlement position delta\\n * @dev Can be \\\"empty\\\" even with a non-zero oracleVersion if a position is opened and\\n * closed in the same version netting out to a zero position delta\\n * @param self The struct to operate on\\n * @return Whether the pending-settlement position delta is empty\\n */\\n function isEmpty(PrePosition memory self) internal pure returns (bool) {\\n return self.openPosition.isEmpty() && self.closePosition.isEmpty();\\n }\\n\\n /**\\n * @notice Increments the maker side of the open position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The position amount to open\\n */\\n function openMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.openPosition.maker = self.openPosition.maker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netMake(self);\\n }\\n\\n /**\\n * @notice Increments the maker side of the close position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The maker position amount to close\\n */\\n function closeMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.closePosition.maker = self.closePosition.maker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netMake(self);\\n }\\n\\n /**\\n * @notice Increments the taker side of the open position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The taker position amount to open\\n */\\n function openTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.openPosition.taker = self.openPosition.taker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netTake(self);\\n }\\n\\n /**\\n * @notice Increments the taker side of the close position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The taker position amount to close\\n */\\n function closeTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.closePosition.taker = self.closePosition.taker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netTake(self);\\n }\\n\\n /**\\n * @notice Nets out the open and close on the maker side of the position delta\\n * @param self The struct to operate on\\n */\\n function _netMake(PrePosition storage self) private {\\n if (self.openPosition.maker.gt(self.closePosition.maker)) {\\n self.openPosition.maker = self.openPosition.maker.sub(self.closePosition.maker);\\n self.closePosition.maker = UFixed18Lib.ZERO;\\n } else {\\n self.closePosition.maker = self.closePosition.maker.sub(self.openPosition.maker);\\n self.openPosition.maker = UFixed18Lib.ZERO;\\n }\\n }\\n\\n /**\\n * @notice Nets out the open and close on the taker side of the position delta\\n * @param self The struct to operate on\\n */\\n function _netTake(PrePosition storage self) private {\\n if (self.openPosition.taker.gt(self.closePosition.taker)) {\\n self.openPosition.taker = self.openPosition.taker.sub(self.closePosition.taker);\\n self.closePosition.taker = UFixed18Lib.ZERO;\\n } else {\\n self.closePosition.taker = self.closePosition.taker.sub(self.openPosition.taker);\\n self.openPosition.taker = UFixed18Lib.ZERO;\\n }\\n }\\n\\n /**\\n * @notice Returns whether the the pending position delta can be settled at version `toOracleVersion`\\n * @dev Pending-settlement positions deltas can be settled (1) oracle version after they are recorded\\n * @param self The struct to operate on\\n * @param toOracleVersion The potential oracle version to settle\\n * @return Whether the position delta can be settled\\n */\\n function canSettle(\\n PrePosition memory self,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal pure returns (bool) {\\n return !isEmpty(self) && toOracleVersion.version > self.oracleVersion;\\n }\\n\\n /**\\n * @notice Computes the fee incurred for opening or closing the pending-settlement position\\n * @dev Must be called from a valid product to get the proper fee amounts\\n * @param self The struct to operate on\\n * @param toOracleVersion The oracle version at which settlement takes place\\n * @return positionFee The maker / taker fee incurred\\n */\\n function computeFee(\\n PrePosition memory self,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal view returns (UFixed18) {\\n Position memory positionDelta = self.openPosition.add(self.closePosition);\\n\\n (UFixed18 makerNotional, UFixed18 takerNotional) = (\\n Fixed18Lib.from(positionDelta.maker).mul(toOracleVersion.price).abs(),\\n Fixed18Lib.from(positionDelta.taker).mul(toOracleVersion.price).abs()\\n );\\n\\n IProduct product = IProduct(address(this));\\n return makerNotional.mul(product.makerFee()).add(takerNotional.mul(product.takerFee()));\\n }\\n\\n /**\\n * @notice Computes the next oracle version to settle\\n * @dev - If there is no pending-settlement position delta, returns the current oracle version\\n * - Otherwise returns the oracle version at which the pending-settlement position delta can be first settled\\n *\\n * Corresponds to point (b) in the Position settlement flow\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @return Next oracle version to settle\\n */\\n function settleVersion(PrePosition storage self, uint256 currentVersion) internal view returns (uint256) {\\n uint256 _oracleVersion = self.oracleVersion;\\n return _oracleVersion == 0 ? currentVersion : _oracleVersion + 1;\\n }\\n}\\n\",\"keccak256\":\"0xa6f83f7b5f8139ec874235c406debd086a152977493c08b7f280df6f1737fb96\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/ProgramInfo.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\nimport \\\"./Position.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\n\\n/// @dev ProgramInfo type\\nstruct ProgramInfo {\\n /// @dev Coordinator for this program\\n uint256 coordinatorId;\\n\\n /// @dev Amount of total maker and taker rewards\\n Position amount;\\n\\n /// @dev start timestamp of the program\\n uint256 start;\\n\\n /// @dev duration of the program (in seconds)\\n uint256 duration;\\n\\n /**\\n * @dev Reward ERC20 token contract\\n * @notice Perennial does not support non-standard ERC20s as reward tokens for incentive programs, including,\\n but not limited to: fee on transfer and rebase tokens. Using such a non-standard token will likely\\n result in loss of funds.\\n */\\n Token18 token;\\n}\\nusing ProgramInfoLib for ProgramInfo global;\\n\\n/**\\n * @title ProgramInfoLib\\n * @notice Library that snapshots the static information for a single program.\\n * @dev This information does not change during the operation of a program.\\n */\\nlibrary ProgramInfoLib {\\n uint256 private constant MIN_DURATION = 1 days;\\n uint256 private constant MAX_DURATION = 2 * 365 days;\\n\\n error ProgramInvalidStartError();\\n error ProgramInvalidDurationError();\\n\\n /**\\n * @notice Validates and creates a new Program\\n * @dev Reverts for invalid programInfos\\n * @param programInfo Un-sanitized static program information\\n */\\n function validate(ProgramInfo memory programInfo) internal view {\\n if (isStarted(programInfo, block.timestamp)) revert ProgramInvalidStartError();\\n if (programInfo.duration < MIN_DURATION || programInfo.duration > MAX_DURATION) revert ProgramInvalidDurationError();\\n }\\n\\n /**\\n * @notice Computes a new program info with the fee taken out of the amount\\n * @param programInfo Original program info\\n * @param incentivizationFee The incentivization fee\\n * @return New program info\\n * @return Fee amount\\n */\\n function deductFee(ProgramInfo memory programInfo, UFixed18 incentivizationFee)\\n internal pure returns (ProgramInfo memory, UFixed18) {\\n Position memory newProgramAmount = programInfo.amount.mul(UFixed18Lib.ONE.sub(incentivizationFee));\\n UFixed18 programFeeAmount = programInfo.amount.sub(newProgramAmount).sum();\\n programInfo.amount = newProgramAmount;\\n return (programInfo, programFeeAmount);\\n }\\n\\n /**\\n * @notice Returns the maker and taker amounts per position share\\n * @param self The ProgramInfo to operate on\\n * @return programFee Amounts per share\\n */\\n function amountPerShare(ProgramInfo memory self) internal pure returns (Accumulator memory) {\\n return self.amount.div(self.duration);\\n }\\n\\n /**\\n * @notice Returns whether the program has started by timestamp `timestamp`\\n * @param self The ProgramInfo to operate on\\n * @param timestamp Timestamp to check for\\n * @return Whether the program has started\\n */\\n function isStarted(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\\n return timestamp >= self.start;\\n }\\n\\n /**\\n * @notice Returns whether the program is completed by timestamp `timestamp`\\n * @param self The ProgramInfo to operate on\\n * @param timestamp Timestamp to check for\\n * @return Whether the program is completed\\n */\\n function isComplete(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\\n return timestamp >= (self.start + self.duration);\\n }\\n}\\n\",\"keccak256\":\"0x280fcaf931b49abaec46b95ccbabaaf856a4b8e8d036413c9c3b3af25585d161\",\"license\":\"Apache-2.0\"}},\"version\":1}", - "bytecode": "0x60a06040523480156200001157600080fd5b5060405162002c9338038062002c93833981016040819052620000349162000046565b6001600160a01b031660805262000078565b6000602082840312156200005957600080fd5b81516001600160a01b03811681146200007157600080fd5b9392505050565b608051612bdc620000b7600039600081816102e601528181610c7301528181610df701528181611216015281816119c20152611d800152612bdc6000f3fe608060405234801561001057600080fd5b50600436106101005760003560e01c8063c9cb48de11610097578063f213159c11610066578063f213159c14610281578063f77c479114610294578063faaebd21146102c1578063fc0c546a146102e157600080fd5b8063c9cb48de14610203578063ca70d30014610216578063cc218ece14610229578063e41191801461026e57600080fd5b8063a5fdc5de116100d3578063a5fdc5de1461015d578063b4d6f781146101a4578063c3b35a7e146101dd578063c4d66de8146101f057600080fd5b80637f3dd53b1461010557806382df39de1461011a57806386b9d81f1461014257806399d32fc414610155575b600080fd5b61011861011336600461286d565b610308565b005b61012d6101283660046128a8565b61068e565b60405190151581526020015b60405180910390f35b6101186101503660046128a8565b610765565b610118610d2f565b61019661016b3660046128e1565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090206001015490565b604051908152602001610139565b6101966101b23660046128e1565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090206002015490565b6101186101eb3660046128fe565b610e6b565b6101186101fe3660046128e1565b611563565b61011861021136600461293f565b611681565b61011861022436600461293f565b6117e3565b6101966102373660046128a8565b73ffffffffffffffffffffffffffffffffffffffff8082166000908152602081815260408083209386168352929052205492915050565b61012d61027c3660046128a8565b611a3e565b61011861028f3660046128fe565b611ac9565b61029c611ec4565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610139565b6101966102cf3660046128e1565b60016020526000908152604090205481565b61029c7f000000000000000000000000000000000000000000000000000000000000000081565b610310611ec4565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff9190911690637fd2919290602401602060405180830381865afa15801561037c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103a0919061296b565b6103dd576040517f4d5325650000000000000000000000000000000000000000000000000000000081523360048201526024015b60405180910390fd5b600080336103e9611ec4565b9150915060008173ffffffffffffffffffffffffffffffffffffffff166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561043a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061045e919061298d565b6040517f2d809cb600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8581166004830152919250600091841690632d809cb690602401602060405180830381865afa1580156104d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104f4919061298d565b905060006105718473ffffffffffffffffffffffffffffffffffffffff1663b0e21e8a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610546573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061056a91906129aa565b8790611ef3565b9050600061057f8783611f12565b73ffffffffffffffffffffffffffffffffffffffff871660009081526020819052604090209091506105b19088611f1e565b73ffffffffffffffffffffffffffffffffffffffff84166000908152600160205260409020546105e19083611f39565b73ffffffffffffffffffffffffffffffffffffffff808616600090815260016020526040808220939093559085168152205461061d9082611f39565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260016020908152604091829020939093558051858152928301849052908816917fbb1fb7280f9f082e1804d5dc09e8cd7c89debd6b303542f604bcdf7696d9579d910160405180910390a250505050505050565b73ffffffffffffffffffffffffffffffffffffffff80821660009081526020818152604080832093861683529290529081205461075c906040517f9168902400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff86811660048301528516906391689024906024015b602060405180830381865afa158015610732573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061075691906129aa565b90611f45565b90505b92915050565b600261078f7f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b036107c6576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7556107f2611ec4565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561083c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610860919061296b565b15610897576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806108a0611ec4565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301529190911690637fd2919290602401602060405180830381865afa15801561090e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610932919061296b565b610980576040517f4d53256500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016103d4565b6040517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80851660048301528491849182169063f667f89790602401600060405180830381600087803b1580156109ed57600080fd5b505af1158015610a01573d6000803e3d6000fd5b50506040517f9168902400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88811660048301526000935087169150639168902490602401602060405180830381865afa158015610a74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9891906129aa565b73ffffffffffffffffffffffffffffffffffffffff868116600090815260208181526040808320938b1683529290522054909150610ad68282611f45565b610b16576040517f8b9b0bf800000000000000000000000000000000000000000000000000000000815260048101839052602481018290526044016103d4565b6040517ff6b3200800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff888116600483015287169063f6b3200890602401600060405180830381600087803b158015610b7f57600080fd5b505af1158015610b93573d6000803e3d6000fd5b505050506000610ba1611ec4565b73ffffffffffffffffffffffffffffffffffffffff1663a36a36306040518163ffffffff1660e01b8152600401602060405180830381865afa158015610beb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c0f91906129aa565b90506000610c2683610c218685611ef3565b611f5f565b73ffffffffffffffffffffffffffffffffffffffff89166000908152602081905260409020909150610c59908a83611f6b565b610c9a73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000163383611fdd565b604080513381526020810183905273ffffffffffffffffffffffffffffffffffffffff808b1692908c16917f76f1c54646947e8e8df3eab8141bb3d115d07da2520f8e41b208a17d138a8959910160405180910390a350505050505050610d2b60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7611f5b90919063ffffffff16565b5050565b610d37611ec4565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da5919061296b565b15610ddc576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336000818152600160205260408120805491905590610e33907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169083611fdd565b60405181815233907f10df095d1434aed409b2f33d2a6a8456f8b0824633cc12a1b43032085aadc41d9060200160405180910390a250565b6002610e957f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03610ecc576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755610ef8611ec4565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f66919061296b565b15610f9d576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff8116610feb576040517f94c3555f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82610ff4611ec4565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301529190911690637fd2919290602401602060405180830381865afa158015611062573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611086919061296b565b6110d4576040517f4d53256500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016103d4565b6040517ff667f897000000000000000000000000000000000000000000000000000000008152336004820181905290859073ffffffffffffffffffffffffffffffffffffffff82169063f667f89790602401600060405180830381600087803b15801561114057600080fd5b505af1158015611154573d6000803e3d6000fd5b505050503386338861118f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8a611ffe90919063ffffffff16565b61119957886111c9565b73ffffffffffffffffffffffffffffffffffffffff8a166000908152602081815260408083203384529091529020545b73ffffffffffffffffffffffffffffffffffffffff8b1660009081526020819052604090209099506111fc90338b611f6b565b61123d73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168c8b611fdd565b60405189815273ffffffffffffffffffffffffffffffffffffffff8b169033907f2717ead6b9200dd235aad468c9809ea400fe33ac69b5bfaa6d3e90fc922b63989060200160405180910390a36040517f9168902400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff838116600483015260009190831690639168902490602401602060405180830381865afa1580156112fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061131e91906129aa565b6040517fab582f2900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff858116600483015291925060009184169063ab582f2990602401602060405180830381865afa158015611390573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b491906129aa565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260208181526040808320938916835292905220549091506113f6906107568484612014565b1561142d576040517f40e2812c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505073ffffffffffffffffffffffffffffffffffffffff8181166000908152602081815260408083209386168352929052205480158015906114ec57506114ec611477611ec4565b73ffffffffffffffffffffffffffffffffffffffff1663ba2de9bc6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114e591906129aa565b8290612020565b15611523576040517f410d976900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505050505061155e60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7611f5b90919063ffffffff16565b505050565b60018061158e7f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b5490565b106115c8576040517f1e7a9d95000000000000000000000000000000000000000000000000000000008152600481018290526024016103d4565b6115f17f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b829055565b60017fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c5561161e82612034565b611626612114565b60007fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c556040518181527fbe9b076dc5b65990cca9dd9d7366682482e7817a6f6bc7f4faf4dc32af497f329060200160405180910390a15050565b611689611ec4565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff9190911690637fd2919290602401602060405180830381865afa1580156116f5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611719919061296b565b611751576040517f4d5325650000000000000000000000000000000000000000000000000000000081523360048201526024016103d4565b33600081815260208190526040812061176b9085856121a0565b90508373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f40957a7f26dd9f9d628b1aba01d4a3db4c38008974c79a62f6cf0f273a78b3a885846040516117d5929190918252602082015260400190565b60405180910390a350505050565b816117ec611ec4565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301529190911690637fd2919290602401602060405180830381865afa15801561185a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061187e919061296b565b6118cc576040517f4d53256500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016103d4565b6118d4611ec4565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561191e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611942919061296b565b15611979576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090206119a8908361224b565b6119e973ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016338461226e565b8273ffffffffffffffffffffffffffffffffffffffff167f8ae4dab3d718e6b7019e16378795bb41b3046b9117483430a39f7af4ab9bb89383604051611a3191815260200190565b60405180910390a2505050565b73ffffffffffffffffffffffffffffffffffffffff80821660009081526020818152604080832093861683529290529081205461075c906040517fab582f2900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff868116600483015285169063ab582f2990602401610715565b6002611af37f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03611b2a576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755611b56611ec4565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ba0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bc4919061296b565b15611bfb576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff8116611c49576040517f94c3555f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82611c52611ec4565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301529190911690637fd2919290602401602060405180830381865afa158015611cc0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ce4919061296b565b611d32576040517f4d53256500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016103d4565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260208190526040902085908590611d66908387612290565b611da773ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016338761226e565b8573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167f5548c837ab068cf56a2c2479df0882a4922fd203edb7517321831d95078c5f6287604051611e0691815260200190565b60405180910390a373ffffffffffffffffffffffffffffffffffffffff818116600090815260208181526040808320938616835292905220548015801590611e545750611e54611477611ec4565b15611e8b576040517f410d976900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050505061155e60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7611f5b90919063ffffffff16565b6000611eee7f0e555410d8128dff796eab5d29b97dd593ce9cab44a71b64c08244579ea605335490565b905090565b6000670de0b6b3a7640000611f0883856129f2565b61075c9190612a2f565b600061075c8284612a6a565b6001820154611f2d9082611f12565b82600101819055505050565b600061075c8284612a81565b6000611f5183836122f5565b6002149392505050565b9055565b600061075c838361232a565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260208490526040902054611f9b9082611f12565b73ffffffffffffffffffffffffffffffffffffffff83166000908152602085905260409020556001830154611fd09082611f12565b8360010181905550505050565b61155e73ffffffffffffffffffffffffffffffffffffffff84168383612340565b600061200a83836122f5565b6001149392505050565b600061075c8383612414565b600061202c83836122f5565b159392505050565b303b1515801561206357507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b1561209a576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff81163b6120e8576040517f14878b6900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6121117f0e555410d8128dff796eab5d29b97dd593ce9cab44a71b64c08244579ea60533829055565b50565b303b1515801561214357507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b1561217a576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020849052604081205481906121dd9084906121d790612424565b90612483565b90506121e88161248f565b196121fd576121f6816124d9565b9150600090505b612206816124d9565b73ffffffffffffffffffffffffffffffffffffffff8516600090815260208790526040902055600285015461223b9083611f39565b8560020181905550509392505050565b600282015461225a9082611f12565b60028301556001820154611f2d9082611f39565b61155e73ffffffffffffffffffffffffffffffffffffffff84168330846124e4565b73ffffffffffffffffffffffffffffffffffffffff82166000908152602084905260409020546122c09082611f39565b73ffffffffffffffffffffffffffffffffffffffff83166000908152602085905260409020556001830154611fd09082611f39565b600082828082111561230c5760029250505061075f565b8082101561231f5760009250505061075f565b506001949350505050565b6000818310612339578161075c565b5090919050565b60405173ffffffffffffffffffffffffffffffffffffffff831660248201526044810182905261155e9084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152612548565b600081831015612339578161075c565b6000817f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81111561075f576040517ea07eb5000000000000000000000000000000000000000000000000000000008152600481018290526024016103d4565b600061075c8284612a99565b6000808213156124a157506001919050565b60008212156124d157507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff919050565b506000919050565b600061075f82612654565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526125429085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401612392565b50505050565b60006125aa826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661266b9092919063ffffffff16565b80519091501561155e57808060200190518101906125c8919061296b565b61155e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016103d4565b600080821215612667578160000361075f565b5090565b606061267a8484600085612684565b90505b9392505050565b606082471015612716576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016103d4565b73ffffffffffffffffffffffffffffffffffffffff85163b612794576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103d4565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516127bd9190612b39565b60006040518083038185875af1925050503d80600081146127fa576040519150601f19603f3d011682016040523d82523d6000602084013e6127ff565b606091505b509150915061280f82828661281a565b979650505050505050565b6060831561282957508161267d565b8251156128395782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103d49190612b55565b60006020828403121561287f57600080fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff8116811461211157600080fd5b600080604083850312156128bb57600080fd5b82356128c681612886565b915060208301356128d681612886565b809150509250929050565b6000602082840312156128f357600080fd5b813561267d81612886565b60008060006060848603121561291357600080fd5b833561291e81612886565b9250602084013561292e81612886565b929592945050506040919091013590565b6000806040838503121561295257600080fd5b823561295d81612886565b946020939093013593505050565b60006020828403121561297d57600080fd5b8151801515811461267d57600080fd5b60006020828403121561299f57600080fd5b815161267d81612886565b6000602082840312156129bc57600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612a2a57612a2a6129c3565b500290565b600082612a65577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600082821015612a7c57612a7c6129c3565b500390565b60008219821115612a9457612a946129c3565b500190565b6000808212827f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03841381151615612ad357612ad36129c3565b827f8000000000000000000000000000000000000000000000000000000000000000038412811615612b0757612b076129c3565b50500190565b60005b83811015612b28578181015183820152602001612b10565b838111156125425750506000910152565b60008251612b4b818460208701612b0d565b9190910192915050565b6020815260008251806020840152612b74816040850160208701612b0d565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fea264697066735822122038850e053e69a9af35622637417e9deb9b9695fcb64537d3ef55d2ea84396cbd64736f6c634300080f0033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101005760003560e01c8063c9cb48de11610097578063f213159c11610066578063f213159c14610281578063f77c479114610294578063faaebd21146102c1578063fc0c546a146102e157600080fd5b8063c9cb48de14610203578063ca70d30014610216578063cc218ece14610229578063e41191801461026e57600080fd5b8063a5fdc5de116100d3578063a5fdc5de1461015d578063b4d6f781146101a4578063c3b35a7e146101dd578063c4d66de8146101f057600080fd5b80637f3dd53b1461010557806382df39de1461011a57806386b9d81f1461014257806399d32fc414610155575b600080fd5b61011861011336600461286d565b610308565b005b61012d6101283660046128a8565b61068e565b60405190151581526020015b60405180910390f35b6101186101503660046128a8565b610765565b610118610d2f565b61019661016b3660046128e1565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090206001015490565b604051908152602001610139565b6101966101b23660046128e1565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090206002015490565b6101186101eb3660046128fe565b610e6b565b6101186101fe3660046128e1565b611563565b61011861021136600461293f565b611681565b61011861022436600461293f565b6117e3565b6101966102373660046128a8565b73ffffffffffffffffffffffffffffffffffffffff8082166000908152602081815260408083209386168352929052205492915050565b61012d61027c3660046128a8565b611a3e565b61011861028f3660046128fe565b611ac9565b61029c611ec4565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610139565b6101966102cf3660046128e1565b60016020526000908152604090205481565b61029c7f000000000000000000000000000000000000000000000000000000000000000081565b610310611ec4565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff9190911690637fd2919290602401602060405180830381865afa15801561037c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103a0919061296b565b6103dd576040517f4d5325650000000000000000000000000000000000000000000000000000000081523360048201526024015b60405180910390fd5b600080336103e9611ec4565b9150915060008173ffffffffffffffffffffffffffffffffffffffff166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561043a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061045e919061298d565b6040517f2d809cb600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8581166004830152919250600091841690632d809cb690602401602060405180830381865afa1580156104d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104f4919061298d565b905060006105718473ffffffffffffffffffffffffffffffffffffffff1663b0e21e8a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610546573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061056a91906129aa565b8790611ef3565b9050600061057f8783611f12565b73ffffffffffffffffffffffffffffffffffffffff871660009081526020819052604090209091506105b19088611f1e565b73ffffffffffffffffffffffffffffffffffffffff84166000908152600160205260409020546105e19083611f39565b73ffffffffffffffffffffffffffffffffffffffff808616600090815260016020526040808220939093559085168152205461061d9082611f39565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260016020908152604091829020939093558051858152928301849052908816917fbb1fb7280f9f082e1804d5dc09e8cd7c89debd6b303542f604bcdf7696d9579d910160405180910390a250505050505050565b73ffffffffffffffffffffffffffffffffffffffff80821660009081526020818152604080832093861683529290529081205461075c906040517f9168902400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff86811660048301528516906391689024906024015b602060405180830381865afa158015610732573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061075691906129aa565b90611f45565b90505b92915050565b600261078f7f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b036107c6576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7556107f2611ec4565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561083c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610860919061296b565b15610897576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806108a0611ec4565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301529190911690637fd2919290602401602060405180830381865afa15801561090e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610932919061296b565b610980576040517f4d53256500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016103d4565b6040517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80851660048301528491849182169063f667f89790602401600060405180830381600087803b1580156109ed57600080fd5b505af1158015610a01573d6000803e3d6000fd5b50506040517f9168902400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88811660048301526000935087169150639168902490602401602060405180830381865afa158015610a74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9891906129aa565b73ffffffffffffffffffffffffffffffffffffffff868116600090815260208181526040808320938b1683529290522054909150610ad68282611f45565b610b16576040517f8b9b0bf800000000000000000000000000000000000000000000000000000000815260048101839052602481018290526044016103d4565b6040517ff6b3200800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff888116600483015287169063f6b3200890602401600060405180830381600087803b158015610b7f57600080fd5b505af1158015610b93573d6000803e3d6000fd5b505050506000610ba1611ec4565b73ffffffffffffffffffffffffffffffffffffffff1663a36a36306040518163ffffffff1660e01b8152600401602060405180830381865afa158015610beb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c0f91906129aa565b90506000610c2683610c218685611ef3565b611f5f565b73ffffffffffffffffffffffffffffffffffffffff89166000908152602081905260409020909150610c59908a83611f6b565b610c9a73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000163383611fdd565b604080513381526020810183905273ffffffffffffffffffffffffffffffffffffffff808b1692908c16917f76f1c54646947e8e8df3eab8141bb3d115d07da2520f8e41b208a17d138a8959910160405180910390a350505050505050610d2b60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7611f5b90919063ffffffff16565b5050565b610d37611ec4565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da5919061296b565b15610ddc576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336000818152600160205260408120805491905590610e33907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169083611fdd565b60405181815233907f10df095d1434aed409b2f33d2a6a8456f8b0824633cc12a1b43032085aadc41d9060200160405180910390a250565b6002610e957f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03610ecc576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755610ef8611ec4565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f66919061296b565b15610f9d576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff8116610feb576040517f94c3555f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82610ff4611ec4565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301529190911690637fd2919290602401602060405180830381865afa158015611062573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611086919061296b565b6110d4576040517f4d53256500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016103d4565b6040517ff667f897000000000000000000000000000000000000000000000000000000008152336004820181905290859073ffffffffffffffffffffffffffffffffffffffff82169063f667f89790602401600060405180830381600087803b15801561114057600080fd5b505af1158015611154573d6000803e3d6000fd5b505050503386338861118f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8a611ffe90919063ffffffff16565b61119957886111c9565b73ffffffffffffffffffffffffffffffffffffffff8a166000908152602081815260408083203384529091529020545b73ffffffffffffffffffffffffffffffffffffffff8b1660009081526020819052604090209099506111fc90338b611f6b565b61123d73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168c8b611fdd565b60405189815273ffffffffffffffffffffffffffffffffffffffff8b169033907f2717ead6b9200dd235aad468c9809ea400fe33ac69b5bfaa6d3e90fc922b63989060200160405180910390a36040517f9168902400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff838116600483015260009190831690639168902490602401602060405180830381865afa1580156112fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061131e91906129aa565b6040517fab582f2900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff858116600483015291925060009184169063ab582f2990602401602060405180830381865afa158015611390573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b491906129aa565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260208181526040808320938916835292905220549091506113f6906107568484612014565b1561142d576040517f40e2812c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505073ffffffffffffffffffffffffffffffffffffffff8181166000908152602081815260408083209386168352929052205480158015906114ec57506114ec611477611ec4565b73ffffffffffffffffffffffffffffffffffffffff1663ba2de9bc6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114e591906129aa565b8290612020565b15611523576040517f410d976900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505050505061155e60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7611f5b90919063ffffffff16565b505050565b60018061158e7f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b5490565b106115c8576040517f1e7a9d95000000000000000000000000000000000000000000000000000000008152600481018290526024016103d4565b6115f17f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b829055565b60017fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c5561161e82612034565b611626612114565b60007fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c556040518181527fbe9b076dc5b65990cca9dd9d7366682482e7817a6f6bc7f4faf4dc32af497f329060200160405180910390a15050565b611689611ec4565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff9190911690637fd2919290602401602060405180830381865afa1580156116f5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611719919061296b565b611751576040517f4d5325650000000000000000000000000000000000000000000000000000000081523360048201526024016103d4565b33600081815260208190526040812061176b9085856121a0565b90508373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f40957a7f26dd9f9d628b1aba01d4a3db4c38008974c79a62f6cf0f273a78b3a885846040516117d5929190918252602082015260400190565b60405180910390a350505050565b816117ec611ec4565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301529190911690637fd2919290602401602060405180830381865afa15801561185a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061187e919061296b565b6118cc576040517f4d53256500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016103d4565b6118d4611ec4565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561191e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611942919061296b565b15611979576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090206119a8908361224b565b6119e973ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016338461226e565b8273ffffffffffffffffffffffffffffffffffffffff167f8ae4dab3d718e6b7019e16378795bb41b3046b9117483430a39f7af4ab9bb89383604051611a3191815260200190565b60405180910390a2505050565b73ffffffffffffffffffffffffffffffffffffffff80821660009081526020818152604080832093861683529290529081205461075c906040517fab582f2900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff868116600483015285169063ab582f2990602401610715565b6002611af37f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03611b2a576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755611b56611ec4565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ba0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bc4919061296b565b15611bfb576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff8116611c49576040517f94c3555f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82611c52611ec4565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301529190911690637fd2919290602401602060405180830381865afa158015611cc0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ce4919061296b565b611d32576040517f4d53256500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016103d4565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260208190526040902085908590611d66908387612290565b611da773ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016338761226e565b8573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167f5548c837ab068cf56a2c2479df0882a4922fd203edb7517321831d95078c5f6287604051611e0691815260200190565b60405180910390a373ffffffffffffffffffffffffffffffffffffffff818116600090815260208181526040808320938616835292905220548015801590611e545750611e54611477611ec4565b15611e8b576040517f410d976900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050505061155e60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7611f5b90919063ffffffff16565b6000611eee7f0e555410d8128dff796eab5d29b97dd593ce9cab44a71b64c08244579ea605335490565b905090565b6000670de0b6b3a7640000611f0883856129f2565b61075c9190612a2f565b600061075c8284612a6a565b6001820154611f2d9082611f12565b82600101819055505050565b600061075c8284612a81565b6000611f5183836122f5565b6002149392505050565b9055565b600061075c838361232a565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260208490526040902054611f9b9082611f12565b73ffffffffffffffffffffffffffffffffffffffff83166000908152602085905260409020556001830154611fd09082611f12565b8360010181905550505050565b61155e73ffffffffffffffffffffffffffffffffffffffff84168383612340565b600061200a83836122f5565b6001149392505050565b600061075c8383612414565b600061202c83836122f5565b159392505050565b303b1515801561206357507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b1561209a576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff81163b6120e8576040517f14878b6900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6121117f0e555410d8128dff796eab5d29b97dd593ce9cab44a71b64c08244579ea60533829055565b50565b303b1515801561214357507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b1561217a576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020849052604081205481906121dd9084906121d790612424565b90612483565b90506121e88161248f565b196121fd576121f6816124d9565b9150600090505b612206816124d9565b73ffffffffffffffffffffffffffffffffffffffff8516600090815260208790526040902055600285015461223b9083611f39565b8560020181905550509392505050565b600282015461225a9082611f12565b60028301556001820154611f2d9082611f39565b61155e73ffffffffffffffffffffffffffffffffffffffff84168330846124e4565b73ffffffffffffffffffffffffffffffffffffffff82166000908152602084905260409020546122c09082611f39565b73ffffffffffffffffffffffffffffffffffffffff83166000908152602085905260409020556001830154611fd09082611f39565b600082828082111561230c5760029250505061075f565b8082101561231f5760009250505061075f565b506001949350505050565b6000818310612339578161075c565b5090919050565b60405173ffffffffffffffffffffffffffffffffffffffff831660248201526044810182905261155e9084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152612548565b600081831015612339578161075c565b6000817f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81111561075f576040517ea07eb5000000000000000000000000000000000000000000000000000000008152600481018290526024016103d4565b600061075c8284612a99565b6000808213156124a157506001919050565b60008212156124d157507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff919050565b506000919050565b600061075f82612654565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526125429085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401612392565b50505050565b60006125aa826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661266b9092919063ffffffff16565b80519091501561155e57808060200190518101906125c8919061296b565b61155e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016103d4565b600080821215612667578160000361075f565b5090565b606061267a8484600085612684565b90505b9392505050565b606082471015612716576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016103d4565b73ffffffffffffffffffffffffffffffffffffffff85163b612794576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103d4565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516127bd9190612b39565b60006040518083038185875af1925050503d80600081146127fa576040519150601f19603f3d011682016040523d82523d6000602084013e6127ff565b606091505b509150915061280f82828661281a565b979650505050505050565b6060831561282957508161267d565b8251156128395782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103d49190612b55565b60006020828403121561287f57600080fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff8116811461211157600080fd5b600080604083850312156128bb57600080fd5b82356128c681612886565b915060208301356128d681612886565b809150509250929050565b6000602082840312156128f357600080fd5b813561267d81612886565b60008060006060848603121561291357600080fd5b833561291e81612886565b9250602084013561292e81612886565b929592945050506040919091013590565b6000806040838503121561295257600080fd5b823561295d81612886565b946020939093013593505050565b60006020828403121561297d57600080fd5b8151801515811461267d57600080fd5b60006020828403121561299f57600080fd5b815161267d81612886565b6000602082840312156129bc57600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612a2a57612a2a6129c3565b500290565b600082612a65577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600082821015612a7c57612a7c6129c3565b500390565b60008219821115612a9457612a946129c3565b500190565b6000808212827f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03841381151615612ad357612ad36129c3565b827f8000000000000000000000000000000000000000000000000000000000000000038412811615612b0757612b076129c3565b50500190565b60005b83811015612b28578181015183820152602001612b10565b838111156125425750506000910152565b60008251612b4b818460208701612b0d565b9190910192915050565b6020815260008251806020840152612b74816040850160208701612b0d565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fea264697066735822122038850e053e69a9af35622637417e9deb9b9695fcb64537d3ef55d2ea84396cbd64736f6c634300080f0033", - "devdoc": { - "kind": "dev", - "methods": { - "collateral(address)": { - "params": { - "product": "Product to return for" - }, - "returns": { - "_0": "The total balance of collateral in the product" - } - }, - "collateral(address,address)": { - "params": { - "account": "Account to return for", - "product": "Product to return for" - }, - "returns": { - "_0": "The balance of the collateral account" - } - }, - "constructor": { - "details": "Called at implementation instantiate and constant for that implementation.", - "params": { - "token_": "Collateral ERC20 stablecoin address" - } - }, - "depositTo(address,address,uint256)": { - "params": { - "account": "Account to deposit the collateral for", - "amount": "Amount of collateral to deposit", - "product": "Product to credit the collateral to" - } - }, - "initialize(address)": { - "details": "Must be called atomically as part of the upgradeable proxy deployment to avoid front-running", - "params": { - "controller_": "Factory contract address" - } - }, - "liquidatable(address,address)": { - "params": { - "account": "Account to return for", - "product": "Product to return for" - }, - "returns": { - "_0": "Whether the account can be liquidated" - } - }, - "liquidatableNext(address,address)": { - "details": "Takes into account the current pre-position on the account", - "params": { - "account": "Account to return for", - "product": "Product to return for" - }, - "returns": { - "_0": "Whether the account can be liquidated" - } - }, - "liquidate(address,address)": { - "details": "Account must be under-collateralized, fee returned immediately to `msg.sender`", - "params": { - "account": "Account to liquidate", - "product": "Product to liquidate for" - } - }, - "resolveShortfall(address,uint256)": { - "details": "Shortfall is a measure of settled insolvency in the market This hook can be used by the product owner or an insurance fund to re-capitalize an insolvent market", - "params": { - "amount": "Amount of shortfall to resolve", - "product": "Product to resolve shortfall for" - } - }, - "settleAccount(address,int256)": { - "details": "Callable only by the corresponding product as part of the settlement flywheel. Moves collateral within a product, any collateral leaving the product due to fees has already been accounted for in the settleProduct flywheel. Debits in excess of the account balance get recorded as shortfall, and can be resolved by the product owner as needed.", - "params": { - "account": "Account to credit", - "amount": "Amount to credit the account (can be negative)" - } - }, - "settleProduct(uint256)": { - "details": "Callable only by the corresponding product as part of the settlement flywheel Removes collateral from the product as fees.", - "params": { - "amount": "Amount to debit from the account" - } - }, - "shortfall(address)": { - "params": { - "product": "Product to return for" - }, - "returns": { - "_0": "The current shortfall of the product" - } - }, - "withdrawTo(address,address,uint256)": { - "params": { - "account": "Account to withdraw the collateral to", - "amount": "Amount of collateral to withdraw", - "product": "Product to withdraw the collateral from" - } - } - }, - "stateVariables": { - "_products": { - "details": "Per product collateral state" - }, - "fees": { - "details": "Protocol and product fees collected, but not yet claimed" - }, - "token": { - "details": "ERC20 stablecoin for collateral" - } - }, - "title": "Collateral", - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": { - "claimFee()": { - "notice": "Claims all of `msg.sender`'s fees" - }, - "collateral(address)": { - "notice": "Returns the total balance of `product`'s collateral" - }, - "collateral(address,address)": { - "notice": "Returns the balance of `account`'s `product` collateral account" - }, - "constructor": { - "notice": "Initializes the immutable contract state" - }, - "depositTo(address,address,uint256)": { - "notice": "Deposits `amount` collateral from `msg.sender` to `account`'s `product` account" - }, - "initialize(address)": { - "notice": "Initializes the contract state" - }, - "liquidatable(address,address)": { - "notice": "Returns whether `account`'s `product` collateral account can be liquidated" - }, - "liquidatableNext(address,address)": { - "notice": "Returns whether `account`'s `product` collateral account can be liquidated after the next oracle version settlement" - }, - "liquidate(address,address)": { - "notice": "Liquidates `account`'s `product` collateral account" - }, - "resolveShortfall(address,uint256)": { - "notice": "Injects additional collateral into a product to resolve shortfall" - }, - "settleAccount(address,int256)": { - "notice": "Credits `amount` to `account`'s collateral account" - }, - "settleProduct(uint256)": { - "notice": "Debits `amount` from product's total collateral account" - }, - "shortfall(address)": { - "notice": "Returns the current shortfall of `product`'s collateral" - }, - "withdrawTo(address,address,uint256)": { - "notice": "Withdraws `amount` collateral from `msg.sender`'s `product` account and sends it to `account`" - } - }, - "notice": "Manages logic and state for all collateral accounts in the protocol.", - "version": 1 - }, - "storageLayout": { - "storage": [ - { - "astId": 10414, - "contract": "contracts/collateral/Collateral.sol:Collateral", - "label": "_products", - "offset": 0, - "slot": "0", - "type": "t_mapping(t_contract(IProduct)16214,t_struct(OptimisticLedger)11099_storage)" - }, - { - "astId": 10420, - "contract": "contracts/collateral/Collateral.sol:Collateral", - "label": "fees", - "offset": 0, - "slot": "1", - "type": "t_mapping(t_address,t_userDefinedValueType(UFixed18)3224)" - } - ], - "types": { - "t_address": { - "encoding": "inplace", - "label": "address", - "numberOfBytes": "20" - }, - "t_contract(IProduct)16214": { - "encoding": "inplace", - "label": "contract IProduct", - "numberOfBytes": "20" - }, - "t_mapping(t_address,t_userDefinedValueType(UFixed18)3224)": { - "encoding": "mapping", - "key": "t_address", - "label": "mapping(address => UFixed18)", - "numberOfBytes": "32", - "value": "t_userDefinedValueType(UFixed18)3224" - }, - "t_mapping(t_contract(IProduct)16214,t_struct(OptimisticLedger)11099_storage)": { - "encoding": "mapping", - "key": "t_contract(IProduct)16214", - "label": "mapping(contract IProduct => struct OptimisticLedger)", - "numberOfBytes": "32", - "value": "t_struct(OptimisticLedger)11099_storage" - }, - "t_struct(OptimisticLedger)11099_storage": { - "encoding": "inplace", - "label": "struct OptimisticLedger", - "members": [ - { - "astId": 11090, - "contract": "contracts/collateral/Collateral.sol:Collateral", - "label": "balances", - "offset": 0, - "slot": "0", - "type": "t_mapping(t_address,t_userDefinedValueType(UFixed18)3224)" - }, - { - "astId": 11094, - "contract": "contracts/collateral/Collateral.sol:Collateral", - "label": "total", - "offset": 0, - "slot": "1", - "type": "t_userDefinedValueType(UFixed18)3224" - }, - { - "astId": 11098, - "contract": "contracts/collateral/Collateral.sol:Collateral", - "label": "shortfall", - "offset": 0, - "slot": "2", - "type": "t_userDefinedValueType(UFixed18)3224" - } - ], - "numberOfBytes": "96" - }, - "t_userDefinedValueType(UFixed18)3224": { - "encoding": "inplace", - "label": "UFixed18", - "numberOfBytes": "32" - } - } - } -} diff --git a/packages/perennial/deployments/goerli/Collateral_Proxy.json b/packages/perennial/deployments/goerli/Collateral_Proxy.json deleted file mode 100644 index cac02b62a..000000000 --- a/packages/perennial/deployments/goerli/Collateral_Proxy.json +++ /dev/null @@ -1,229 +0,0 @@ -{ - "address": "0x741FC06B5DE25AC5b31F54B92eE3Bf1C97bf8666", - "abi": [ - { - "inputs": [ - { - "internalType": "address", - "name": "_logic", - "type": "address" - }, - { - "internalType": "address", - "name": "admin_", - "type": "address" - }, - { - "internalType": "bytes", - "name": "_data", - "type": "bytes" - } - ], - "stateMutability": "payable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "previousAdmin", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "newAdmin", - "type": "address" - } - ], - "name": "AdminChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "beacon", - "type": "address" - } - ], - "name": "BeaconUpgraded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "implementation", - "type": "address" - } - ], - "name": "Upgraded", - "type": "event" - }, - { - "stateMutability": "payable", - "type": "fallback" - }, - { - "inputs": [], - "name": "admin", - "outputs": [ - { - "internalType": "address", - "name": "admin_", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newAdmin", - "type": "address" - } - ], - "name": "changeAdmin", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "implementation", - "outputs": [ - { - "internalType": "address", - "name": "implementation_", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newImplementation", - "type": "address" - } - ], - "name": "upgradeTo", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newImplementation", - "type": "address" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "upgradeToAndCall", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "stateMutability": "payable", - "type": "receive" - } - ], - "transactionHash": "0x810703aa9e71132b6829d8d4ce10936f456e55275a8e0aa8c9f8b8e70a5c4878", - "receipt": { - "to": null, - "from": "0x66a7fDB96C583c59597de16d8b2B989231415339", - "contractAddress": "0x741FC06B5DE25AC5b31F54B92eE3Bf1C97bf8666", - "transactionIndex": 54, - "gasUsed": "690585", - "logsBloom": "0x00000000000000000000000000000000420000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000001000000000000000000000000000000000000000000000020000000000000000000000000000000000400000000000000200000000000000000000000000000000000000000000400000000000000800000000002", - "blockHash": "0x80d721d1e7b8f1b08f62e7503c43ad2b59be1736f07e7242415cde52cadb4259", - "transactionHash": "0x810703aa9e71132b6829d8d4ce10936f456e55275a8e0aa8c9f8b8e70a5c4878", - "logs": [ - { - "transactionIndex": 54, - "blockNumber": 7681147, - "transactionHash": "0x810703aa9e71132b6829d8d4ce10936f456e55275a8e0aa8c9f8b8e70a5c4878", - "address": "0x741FC06B5DE25AC5b31F54B92eE3Bf1C97bf8666", - "topics": [ - "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x000000000000000000000000fb9df7ae9c30cb7eb8a232f6ae90780a37b30022" - ], - "data": "0x", - "logIndex": 178, - "blockHash": "0x80d721d1e7b8f1b08f62e7503c43ad2b59be1736f07e7242415cde52cadb4259" - }, - { - "transactionIndex": 54, - "blockNumber": 7681147, - "transactionHash": "0x810703aa9e71132b6829d8d4ce10936f456e55275a8e0aa8c9f8b8e70a5c4878", - "address": "0x741FC06B5DE25AC5b31F54B92eE3Bf1C97bf8666", - "topics": ["0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f"], - "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000085b75de34c7328625b8c394769d98d64c74febca", - "logIndex": 179, - "blockHash": "0x80d721d1e7b8f1b08f62e7503c43ad2b59be1736f07e7242415cde52cadb4259" - } - ], - "blockNumber": 7681147, - "cumulativeGasUsed": "26326879", - "status": 1, - "byzantium": true - }, - "args": ["0xfB9df7AE9C30cB7Eb8A232f6ae90780a37b30022", "0x85b75DE34c7328625b8c394769D98d64C74fEBCa", "0x"], - "numDeployments": 1, - "solcInputHash": "b6ff42633a62e1bc6c97d8ccad85444b", - "metadata": "{\"compiler\":{\"version\":\"0.8.15+commit.e14f2714\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // 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\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\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 ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\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(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\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 /**\\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 {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x60806040526040516200112838038062001128833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b600080516020620010e1833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b600080516020620010c183398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b6200028c1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e98383604051806060016040528060278152602001620011016027913962000381565b9392505050565b60006200021a600080516020620010c183398151915260001b6200046760201b6200022e1760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd600080516020620010c183398151915260001b6200046760201b6200022e1760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b620002b81760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd600080516020620010e183398151915260001b6200046760201b6200022e1760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610a2980620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b610090366004610895565b610135565b61006b6100a33660046108b0565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b610101366004610895565b610231565b34801561011257600080fd5b506100bd61025e565b6101236102d4565b61013361012e6103ab565b6103b5565b565b61013d6103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481604051806020016040528060008152506000610419565b50565b61017461011b565b6101876103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610419915050565b505050565b6101e661011b565b60006101fd6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103ab565b905090565b61022e61011b565b90565b6102396103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481610444565b60006102686103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103d9565b60606102b183836040518060600160405280602781526020016109cd602791396104a5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6102dc6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102216105cd565b3660008037600080366000845af43d6000803e8080156103d4573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b610422836105f5565b60008251118061042f5750805b156101e65761043e838361028c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61046d6103d9565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161017481610642565b606073ffffffffffffffffffffffffffffffffffffffff84163b61054b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103a2565b6000808573ffffffffffffffffffffffffffffffffffffffff1685604051610573919061095f565b600060405180830381855af49150503d80600081146105ae576040519150601f19603f3d011682016040523d82523d6000602084013e6105b3565b606091505b50915091506105c382828661074e565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103fd565b6105fe816107a1565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff81166106e5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103a2565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060831561075d5750816102b1565b82511561076d5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a2919061097b565b73ffffffffffffffffffffffffffffffffffffffff81163b610845576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103a2565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610708565b803573ffffffffffffffffffffffffffffffffffffffff8116811461089057600080fd5b919050565b6000602082840312156108a757600080fd5b6102b18261086c565b6000806000604084860312156108c557600080fd5b6108ce8461086c565b9250602084013567ffffffffffffffff808211156108eb57600080fd5b818601915086601f8301126108ff57600080fd5b81358181111561090e57600080fd5b87602082850101111561092057600080fd5b6020830194508093505050509250925092565b60005b8381101561094e578181015183820152602001610936565b8381111561043e5750506000910152565b60008251610971818460208701610933565b9190910192915050565b602081526000825180602084015261099a816040850160208701610933565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a4b930408c511c08d53f1ec84bb13fe259938b06e5d586d6adc4fc27200abe6c64736f6c634300080f0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", - "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b610090366004610895565b610135565b61006b6100a33660046108b0565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b610101366004610895565b610231565b34801561011257600080fd5b506100bd61025e565b6101236102d4565b61013361012e6103ab565b6103b5565b565b61013d6103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481604051806020016040528060008152506000610419565b50565b61017461011b565b6101876103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610419915050565b505050565b6101e661011b565b60006101fd6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103ab565b905090565b61022e61011b565b90565b6102396103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481610444565b60006102686103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103d9565b60606102b183836040518060600160405280602781526020016109cd602791396104a5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6102dc6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102216105cd565b3660008037600080366000845af43d6000803e8080156103d4573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b610422836105f5565b60008251118061042f5750805b156101e65761043e838361028c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61046d6103d9565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161017481610642565b606073ffffffffffffffffffffffffffffffffffffffff84163b61054b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103a2565b6000808573ffffffffffffffffffffffffffffffffffffffff1685604051610573919061095f565b600060405180830381855af49150503d80600081146105ae576040519150601f19603f3d011682016040523d82523d6000602084013e6105b3565b606091505b50915091506105c382828661074e565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103fd565b6105fe816107a1565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff81166106e5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103a2565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060831561075d5750816102b1565b82511561076d5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a2919061097b565b73ffffffffffffffffffffffffffffffffffffffff81163b610845576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103a2565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610708565b803573ffffffffffffffffffffffffffffffffffffffff8116811461089057600080fd5b919050565b6000602082840312156108a757600080fd5b6102b18261086c565b6000806000604084860312156108c557600080fd5b6108ce8461086c565b9250602084013567ffffffffffffffff808211156108eb57600080fd5b818601915086601f8301126108ff57600080fd5b81358181111561090e57600080fd5b87602082850101111561092057600080fd5b6020830194508093505050509250925092565b60005b8381101561094e578181015183820152602001610936565b8381111561043e5750506000910152565b60008251610971818460208701610933565b9190910192915050565b602081526000825180602084015261099a816040850160208701610933565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a4b930408c511c08d53f1ec84bb13fe259938b06e5d586d6adc4fc27200abe6c64736f6c634300080f0033", - "devdoc": { - "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", - "kind": "dev", - "methods": { - "admin()": { - "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" - }, - "changeAdmin(address)": { - "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." - }, - "constructor": { - "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." - }, - "implementation()": { - "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" - }, - "upgradeTo(address)": { - "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." - }, - "upgradeToAndCall(address,bytes)": { - "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." - } - }, - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": {}, - "version": 1 - }, - "storageLayout": { - "storage": [], - "types": null - } -} diff --git a/packages/perennial/deployments/goerli/Controller_Impl.json b/packages/perennial/deployments/goerli/Controller_Impl.json deleted file mode 100644 index 29f676c2f..000000000 --- a/packages/perennial/deployments/goerli/Controller_Impl.json +++ /dev/null @@ -1,1531 +0,0 @@ -{ - "address": "0x1c7ee3aBC60751Dd4069d1b19438a4Df92f4EB3a", - "abi": [ - { - "inputs": [], - "name": "ControllerInvalidIncentivizationFeeError", - "type": "error" - }, - { - "inputs": [], - "name": "ControllerInvalidLiquidationFeeError", - "type": "error" - }, - { - "inputs": [], - "name": "ControllerInvalidMinFundingFeeError", - "type": "error" - }, - { - "inputs": [], - "name": "ControllerInvalidProtocolFeeError", - "type": "error" - }, - { - "inputs": [], - "name": "ControllerNoZeroCoordinatorError", - "type": "error" - }, - { - "inputs": [], - "name": "ControllerNotContractAddressError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "controllerId", - "type": "uint256" - } - ], - "name": "ControllerNotOwnerError", - "type": "error" - }, - { - "inputs": [], - "name": "ControllerNotPauserError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "controllerId", - "type": "uint256" - } - ], - "name": "ControllerNotPendingOwnerError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "version", - "type": "uint256" - } - ], - "name": "UInitializableAlreadyInitializedError", - "type": "error" - }, - { - "inputs": [], - "name": "UInitializableNotInitializingError", - "type": "error" - }, - { - "inputs": [], - "name": "UInitializableZeroVersionError", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "contract ICollateral", - "name": "newCollateral", - "type": "address" - } - ], - "name": "CollateralUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "name": "CoordinatorCreated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "CoordinatorOwnerUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "newPendingOwner", - "type": "address" - } - ], - "name": "CoordinatorPendingOwnerUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "newTreasury", - "type": "address" - } - ], - "name": "CoordinatorTreasuryUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "UFixed18", - "name": "newIncentivizationFee", - "type": "uint256" - } - ], - "name": "IncentivizationFeeUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "contract IIncentivizer", - "name": "newIncentivizer", - "type": "address" - } - ], - "name": "IncentivizerUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "version", - "type": "uint256" - } - ], - "name": "Initialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "UFixed18", - "name": "newLiquidationFee", - "type": "uint256" - } - ], - "name": "LiquidationFeeUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "UFixed18", - "name": "newMinCollateral", - "type": "uint256" - } - ], - "name": "MinCollateralUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "UFixed18", - "name": "newMinFundingFee", - "type": "uint256" - } - ], - "name": "MinFundingFeeUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bool", - "name": "newPaused", - "type": "bool" - } - ], - "name": "PausedUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "newPauser", - "type": "address" - } - ], - "name": "PauserUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "contract IBeacon", - "name": "newProductBeacon", - "type": "address" - } - ], - "name": "ProductBeaconUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "components": [ - { - "internalType": "string", - "name": "name", - "type": "string" - }, - { - "internalType": "string", - "name": "symbol", - "type": "string" - }, - { - "components": [ - { - "internalType": "enum PayoffDefinitionLib.PayoffType", - "name": "payoffType", - "type": "uint8" - }, - { - "internalType": "enum PayoffDefinitionLib.PayoffDirection", - "name": "payoffDirection", - "type": "uint8" - }, - { - "internalType": "bytes30", - "name": "data", - "type": "bytes30" - } - ], - "internalType": "struct PayoffDefinition", - "name": "payoffDefinition", - "type": "tuple" - }, - { - "internalType": "contract IOracleProvider", - "name": "oracle", - "type": "address" - }, - { - "internalType": "UFixed18", - "name": "maintenance", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "fundingFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "makerFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "takerFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "makerLimit", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "PackedFixed18", - "name": "minRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "maxRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "targetRate", - "type": "int128" - }, - { - "internalType": "PackedUFixed18", - "name": "targetUtilization", - "type": "uint128" - } - ], - "internalType": "struct JumpRateUtilizationCurve", - "name": "utilizationCurve", - "type": "tuple" - } - ], - "indexed": false, - "internalType": "struct IProduct.ProductInfo", - "name": "productInfo", - "type": "tuple" - } - ], - "name": "ProductCreated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "newProgramsPerProduct", - "type": "uint256" - } - ], - "name": "ProgramsPerProductUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "UFixed18", - "name": "newProtocolFee", - "type": "uint256" - } - ], - "name": "ProtocolFeeUpdated", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - } - ], - "name": "acceptCoordinatorOwner", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "collateral", - "outputs": [ - { - "internalType": "contract ICollateral", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "", - "type": "address" - } - ], - "name": "coordinatorFor", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - } - ], - "name": "coordinators", - "outputs": [ - { - "components": [ - { - "internalType": "address", - "name": "pendingOwner", - "type": "address" - }, - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "address", - "name": "treasury", - "type": "address" - } - ], - "internalType": "struct IController.Coordinator", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "createCoordinator", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "string", - "name": "name", - "type": "string" - }, - { - "internalType": "string", - "name": "symbol", - "type": "string" - }, - { - "components": [ - { - "internalType": "enum PayoffDefinitionLib.PayoffType", - "name": "payoffType", - "type": "uint8" - }, - { - "internalType": "enum PayoffDefinitionLib.PayoffDirection", - "name": "payoffDirection", - "type": "uint8" - }, - { - "internalType": "bytes30", - "name": "data", - "type": "bytes30" - } - ], - "internalType": "struct PayoffDefinition", - "name": "payoffDefinition", - "type": "tuple" - }, - { - "internalType": "contract IOracleProvider", - "name": "oracle", - "type": "address" - }, - { - "internalType": "UFixed18", - "name": "maintenance", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "fundingFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "makerFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "takerFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "makerLimit", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "PackedFixed18", - "name": "minRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "maxRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "targetRate", - "type": "int128" - }, - { - "internalType": "PackedUFixed18", - "name": "targetUtilization", - "type": "uint128" - } - ], - "internalType": "struct JumpRateUtilizationCurve", - "name": "utilizationCurve", - "type": "tuple" - } - ], - "internalType": "struct IProduct.ProductInfo", - "name": "productInfo", - "type": "tuple" - } - ], - "name": "createProduct", - "outputs": [ - { - "internalType": "contract IProduct", - "name": "", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "incentivizationFee", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "incentivizer", - "outputs": [ - { - "internalType": "contract IIncentivizer", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract ICollateral", - "name": "collateral_", - "type": "address" - }, - { - "internalType": "contract IIncentivizer", - "name": "incentivizer_", - "type": "address" - }, - { - "internalType": "contract IBeacon", - "name": "productBeacon_", - "type": "address" - } - ], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "isProduct", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "liquidationFee", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "minCollateral", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "minFundingFee", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - } - ], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "paused", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "pauser", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - } - ], - "name": "pendingOwner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "pendingOwner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "productBeacon", - "outputs": [ - { - "internalType": "contract IBeacon", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "programsPerProduct", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "protocolFee", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "treasury", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - } - ], - "name": "treasury", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "treasury", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract ICollateral", - "name": "newCollateral", - "type": "address" - } - ], - "name": "updateCollateral", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - }, - { - "internalType": "address", - "name": "newPendingOwner", - "type": "address" - } - ], - "name": "updateCoordinatorPendingOwner", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - }, - { - "internalType": "address", - "name": "newTreasury", - "type": "address" - } - ], - "name": "updateCoordinatorTreasury", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "newIncentivizationFee", - "type": "uint256" - } - ], - "name": "updateIncentivizationFee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IIncentivizer", - "name": "newIncentivizer", - "type": "address" - } - ], - "name": "updateIncentivizer", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "newLiquidationFee", - "type": "uint256" - } - ], - "name": "updateLiquidationFee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "newMinCollateral", - "type": "uint256" - } - ], - "name": "updateMinCollateral", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "newMinFundingFee", - "type": "uint256" - } - ], - "name": "updateMinFundingFee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bool", - "name": "newPaused", - "type": "bool" - } - ], - "name": "updatePaused", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newPauser", - "type": "address" - } - ], - "name": "updatePauser", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IBeacon", - "name": "newProductBeacon", - "type": "address" - } - ], - "name": "updateProductBeacon", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "newProgramsPerProduct", - "type": "uint256" - } - ], - "name": "updateProgramsPerProduct", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "newProtocolFee", - "type": "uint256" - } - ], - "name": "updateProtocolFee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } - ], - "transactionHash": "0xe9ba7a8119eabe028352dbfdd349a76e6b25d5ee168d53555987576e1a7b5ac9", - "receipt": { - "to": null, - "from": "0x66a7fDB96C583c59597de16d8b2B989231415339", - "contractAddress": "0x1c7ee3aBC60751Dd4069d1b19438a4Df92f4EB3a", - "transactionIndex": 7, - "gasUsed": "2574331", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xe8fe10db0aac19b7af1276f2a3e546611299d42677dc1fb82975e52e72fe7347", - "transactionHash": "0xe9ba7a8119eabe028352dbfdd349a76e6b25d5ee168d53555987576e1a7b5ac9", - "logs": [], - "blockNumber": 7681139, - "cumulativeGasUsed": "3403493", - "status": 1, - "byzantium": true - }, - "args": [], - "numDeployments": 1, - "solcInputHash": "b6ff42633a62e1bc6c97d8ccad85444b", - "metadata": "{\"compiler\":{\"version\":\"0.8.15+commit.e14f2714\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"ControllerInvalidIncentivizationFeeError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ControllerInvalidLiquidationFeeError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ControllerInvalidMinFundingFeeError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ControllerInvalidProtocolFeeError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ControllerNoZeroCoordinatorError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ControllerNotContractAddressError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"controllerId\",\"type\":\"uint256\"}],\"name\":\"ControllerNotOwnerError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ControllerNotPauserError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"controllerId\",\"type\":\"uint256\"}],\"name\":\"ControllerNotPendingOwnerError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"UInitializableAlreadyInitializedError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UInitializableNotInitializingError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UInitializableZeroVersionError\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract ICollateral\",\"name\":\"newCollateral\",\"type\":\"address\"}],\"name\":\"CollateralUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"CoordinatorCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"CoordinatorOwnerUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newPendingOwner\",\"type\":\"address\"}],\"name\":\"CoordinatorPendingOwnerUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newTreasury\",\"type\":\"address\"}],\"name\":\"CoordinatorTreasuryUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"newIncentivizationFee\",\"type\":\"uint256\"}],\"name\":\"IncentivizationFeeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IIncentivizer\",\"name\":\"newIncentivizer\",\"type\":\"address\"}],\"name\":\"IncentivizerUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"newLiquidationFee\",\"type\":\"uint256\"}],\"name\":\"LiquidationFeeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"newMinCollateral\",\"type\":\"uint256\"}],\"name\":\"MinCollateralUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"newMinFundingFee\",\"type\":\"uint256\"}],\"name\":\"MinFundingFeeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"newPaused\",\"type\":\"bool\"}],\"name\":\"PausedUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newPauser\",\"type\":\"address\"}],\"name\":\"PauserUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IBeacon\",\"name\":\"newProductBeacon\",\"type\":\"address\"}],\"name\":\"ProductBeaconUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"},{\"components\":[{\"internalType\":\"enum PayoffDefinitionLib.PayoffType\",\"name\":\"payoffType\",\"type\":\"uint8\"},{\"internalType\":\"enum PayoffDefinitionLib.PayoffDirection\",\"name\":\"payoffDirection\",\"type\":\"uint8\"},{\"internalType\":\"bytes30\",\"name\":\"data\",\"type\":\"bytes30\"}],\"internalType\":\"struct PayoffDefinition\",\"name\":\"payoffDefinition\",\"type\":\"tuple\"},{\"internalType\":\"contract IOracleProvider\",\"name\":\"oracle\",\"type\":\"address\"},{\"internalType\":\"UFixed18\",\"name\":\"maintenance\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"fundingFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"makerFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"takerFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"makerLimit\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"PackedFixed18\",\"name\":\"minRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"maxRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"targetRate\",\"type\":\"int128\"},{\"internalType\":\"PackedUFixed18\",\"name\":\"targetUtilization\",\"type\":\"uint128\"}],\"internalType\":\"struct JumpRateUtilizationCurve\",\"name\":\"utilizationCurve\",\"type\":\"tuple\"}],\"indexed\":false,\"internalType\":\"struct IProduct.ProductInfo\",\"name\":\"productInfo\",\"type\":\"tuple\"}],\"name\":\"ProductCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newProgramsPerProduct\",\"type\":\"uint256\"}],\"name\":\"ProgramsPerProductUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"newProtocolFee\",\"type\":\"uint256\"}],\"name\":\"ProtocolFeeUpdated\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"}],\"name\":\"acceptCoordinatorOwner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"collateral\",\"outputs\":[{\"internalType\":\"contract ICollateral\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"coordinatorFor\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"}],\"name\":\"coordinators\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"pendingOwner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"treasury\",\"type\":\"address\"}],\"internalType\":\"struct IController.Coordinator\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"createCoordinator\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"},{\"components\":[{\"internalType\":\"enum PayoffDefinitionLib.PayoffType\",\"name\":\"payoffType\",\"type\":\"uint8\"},{\"internalType\":\"enum PayoffDefinitionLib.PayoffDirection\",\"name\":\"payoffDirection\",\"type\":\"uint8\"},{\"internalType\":\"bytes30\",\"name\":\"data\",\"type\":\"bytes30\"}],\"internalType\":\"struct PayoffDefinition\",\"name\":\"payoffDefinition\",\"type\":\"tuple\"},{\"internalType\":\"contract IOracleProvider\",\"name\":\"oracle\",\"type\":\"address\"},{\"internalType\":\"UFixed18\",\"name\":\"maintenance\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"fundingFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"makerFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"takerFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"makerLimit\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"PackedFixed18\",\"name\":\"minRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"maxRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"targetRate\",\"type\":\"int128\"},{\"internalType\":\"PackedUFixed18\",\"name\":\"targetUtilization\",\"type\":\"uint128\"}],\"internalType\":\"struct JumpRateUtilizationCurve\",\"name\":\"utilizationCurve\",\"type\":\"tuple\"}],\"internalType\":\"struct IProduct.ProductInfo\",\"name\":\"productInfo\",\"type\":\"tuple\"}],\"name\":\"createProduct\",\"outputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"incentivizationFee\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"incentivizer\",\"outputs\":[{\"internalType\":\"contract IIncentivizer\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ICollateral\",\"name\":\"collateral_\",\"type\":\"address\"},{\"internalType\":\"contract IIncentivizer\",\"name\":\"incentivizer_\",\"type\":\"address\"},{\"internalType\":\"contract IBeacon\",\"name\":\"productBeacon_\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"isProduct\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"liquidationFee\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minCollateral\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minFundingFee\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"}],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"paused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pauser\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"}],\"name\":\"pendingOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"productBeacon\",\"outputs\":[{\"internalType\":\"contract IBeacon\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"programsPerProduct\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"protocolFee\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"treasury\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"}],\"name\":\"treasury\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"treasury\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ICollateral\",\"name\":\"newCollateral\",\"type\":\"address\"}],\"name\":\"updateCollateral\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"newPendingOwner\",\"type\":\"address\"}],\"name\":\"updateCoordinatorPendingOwner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"newTreasury\",\"type\":\"address\"}],\"name\":\"updateCoordinatorTreasury\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"newIncentivizationFee\",\"type\":\"uint256\"}],\"name\":\"updateIncentivizationFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IIncentivizer\",\"name\":\"newIncentivizer\",\"type\":\"address\"}],\"name\":\"updateIncentivizer\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"newLiquidationFee\",\"type\":\"uint256\"}],\"name\":\"updateLiquidationFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"newMinCollateral\",\"type\":\"uint256\"}],\"name\":\"updateMinCollateral\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"newMinFundingFee\",\"type\":\"uint256\"}],\"name\":\"updateMinFundingFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"newPaused\",\"type\":\"bool\"}],\"name\":\"updatePaused\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newPauser\",\"type\":\"address\"}],\"name\":\"updatePauser\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IBeacon\",\"name\":\"newProductBeacon\",\"type\":\"address\"}],\"name\":\"updateProductBeacon\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newProgramsPerProduct\",\"type\":\"uint256\"}],\"name\":\"updateProgramsPerProduct\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"newProtocolFee\",\"type\":\"uint256\"}],\"name\":\"updateProtocolFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"acceptCoordinatorOwner(uint256)\":{\"details\":\"Must be called by the coordinator's pending owner\",\"params\":{\"coordinatorId\":\"Coordinator to update\"}},\"coordinators(uint256)\":{\"params\":{\"coordinatorId\":\"Coordinator to return for\"},\"returns\":{\"_0\":\"Coordinator state\"}},\"createCoordinator()\":{\"details\":\"Can only be called by the protocol owner\",\"returns\":{\"_0\":\"New coordinator ID\"}},\"createProduct(uint256,(string,string,(uint8,uint8,bytes30),address,uint256,uint256,uint256,uint256,uint256,(int128,int128,int128,uint128)))\":{\"details\":\"Can only be called by the coordinator owner\",\"params\":{\"coordinatorId\":\"Coordinator that will own the product\",\"productInfo\":\"Product params used to initialize the product\"},\"returns\":{\"_0\":\"New product contract address\"}},\"initialize(address,address,address)\":{\"details\":\"Must be called atomically as part of the upgradeable proxy deployment to avoid front-running\",\"params\":{\"collateral_\":\"Collateral contract address\",\"incentivizer_\":\"Incentivizer contract address\",\"productBeacon_\":\"Product implementation beacon address\"}},\"isProduct(address)\":{\"params\":{\"product\":\"Contract address to check\"},\"returns\":{\"_0\":\"Whether a contract is a product\"}},\"owner()\":{\"returns\":{\"_0\":\"Owner of the protocol\"}},\"owner(address)\":{\"params\":{\"product\":\"Product to return for\"},\"returns\":{\"_0\":\"Owner of the product\"}},\"owner(uint256)\":{\"params\":{\"coordinatorId\":\"Coordinator to return for\"},\"returns\":{\"_0\":\"Owner of the coordinator\"}},\"pendingOwner()\":{\"returns\":{\"_0\":\"Owner of the protocol\"}},\"pendingOwner(uint256)\":{\"params\":{\"coordinatorId\":\"Coordinator to return for\"},\"returns\":{\"_0\":\"Pending owner of the coordinator\"}},\"treasury()\":{\"details\":\"Defaults to the `owner` when `treasury` is unset\",\"returns\":{\"_0\":\"Treasury of the protocol\"}},\"treasury(address)\":{\"details\":\"Defaults to the `owner` when `treasury` is unset\",\"params\":{\"product\":\"Product to return for\"},\"returns\":{\"_0\":\"Treasury of the product\"}},\"treasury(uint256)\":{\"details\":\"Defaults to the `owner` when `treasury` is unset\",\"params\":{\"coordinatorId\":\"Coordinator to return for\"},\"returns\":{\"_0\":\"Treasury of the coordinator\"}},\"updateCollateral(address)\":{\"params\":{\"newCollateral\":\"New Collateral contract address\"}},\"updateCoordinatorPendingOwner(uint256,address)\":{\"details\":\"Must be called by the coordinator's current owner\",\"params\":{\"coordinatorId\":\"Coordinator to update\",\"newPendingOwner\":\"New pending owner address\"}},\"updateCoordinatorTreasury(uint256,address)\":{\"details\":\"Must be called by the coordinator's current owner. Defaults to the coordinator `owner` if set to address(0)\",\"params\":{\"coordinatorId\":\"Coordinator to update\",\"newTreasury\":\"New treasury address\"}},\"updateIncentivizationFee(uint256)\":{\"params\":{\"newIncentivizationFee\":\"New incentivization fee\"}},\"updateIncentivizer(address)\":{\"params\":{\"newIncentivizer\":\"New Incentivizer contract address\"}},\"updateLiquidationFee(uint256)\":{\"params\":{\"newLiquidationFee\":\"New liquidation fee\"}},\"updateMinCollateral(uint256)\":{\"params\":{\"newMinCollateral\":\"New minimum allowed collateral amount\"}},\"updateMinFundingFee(uint256)\":{\"params\":{\"newMinFundingFee\":\"New minimum allowed funding fee\"}},\"updatePaused(bool)\":{\"params\":{\"newPaused\":\"New protocol paused state\"}},\"updatePauser(address)\":{\"params\":{\"newPauser\":\"New protocol pauser address\"}},\"updateProductBeacon(address)\":{\"params\":{\"newProductBeacon\":\"New Product implementation beacon address\"}},\"updateProgramsPerProduct(uint256)\":{\"params\":{\"newProgramsPerProduct\":\"New maximum incentivization programs per product allowed\"}},\"updateProtocolFee(uint256)\":{\"params\":{\"newProtocolFee\":\"New protocol-product fee split\"}}},\"stateVariables\":{\"_collateral\":{\"details\":\"Collateral contract address for the protocol\"},\"_coordinators\":{\"details\":\"List of product coordinators\"},\"_incentivizationFee\":{\"details\":\"Fee on incentivization programs\"},\"_incentivizer\":{\"details\":\"Incentivizer contract address for the protocol\"},\"_liquidationFee\":{\"details\":\"Fee on maintenance for liquidation\"},\"_minCollateral\":{\"details\":\"Minimum allowable collateral amount per user account\"},\"_minFundingFee\":{\"details\":\"Minimum allowable funding fee for a product\"},\"_paused\":{\"details\":\"The paused status of the protocol\"},\"_pauser\":{\"details\":\"Protocol pauser address. address(0) defaults to owner(0)\"},\"_productBeacon\":{\"details\":\"Product implementation beacon address for the protocol\"},\"_programsPerProduct\":{\"details\":\"Maximum incentivization programs per product allowed\"},\"_protocolFee\":{\"details\":\"Percent of collected fees that go to the protocol treasury vs the product treasury\"},\"coordinatorFor\":{\"details\":\"Mapping of the coordinator for each product\"}},\"title\":\"Controller\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"acceptCoordinatorOwner(uint256)\":{\"notice\":\"Accepts ownership over an existing coordinator\"},\"coordinators(uint256)\":{\"notice\":\"Returns coordinator state for coordinator `coordinatorId`\"},\"createCoordinator()\":{\"notice\":\"Creates a new coordinator with `msg.sender` as the owner\"},\"createProduct(uint256,(string,string,(uint8,uint8,bytes30),address,uint256,uint256,uint256,uint256,uint256,(int128,int128,int128,uint128)))\":{\"notice\":\"Creates a new product market with `provider`\"},\"initialize(address,address,address)\":{\"notice\":\"Initializes the contract state\"},\"isProduct(address)\":{\"notice\":\"Returns whether a contract is a product\"},\"owner()\":{\"notice\":\"Returns the owner of the protocol\"},\"owner(address)\":{\"notice\":\"Returns the owner of the product `product`\"},\"owner(uint256)\":{\"notice\":\"Returns the owner of the coordinator `coordinatorId`\"},\"pendingOwner()\":{\"notice\":\"Returns the pending owner of the protocol\"},\"pendingOwner(uint256)\":{\"notice\":\"Returns the pending owner of the coordinator `coordinatorId`\"},\"treasury()\":{\"notice\":\"Returns the treasury of the protocol\"},\"treasury(address)\":{\"notice\":\"Returns the treasury of the product `product`\"},\"treasury(uint256)\":{\"notice\":\"Returns the treasury of the coordinator `coordinatorId`\"},\"updateCollateral(address)\":{\"notice\":\"Updates the Collateral contract address\"},\"updateCoordinatorPendingOwner(uint256,address)\":{\"notice\":\"Updates the pending owner of an existing coordinator\"},\"updateCoordinatorTreasury(uint256,address)\":{\"notice\":\"Updates the treasury of an existing coordinator\"},\"updateIncentivizationFee(uint256)\":{\"notice\":\"Updates the incentivization fee\"},\"updateIncentivizer(address)\":{\"notice\":\"Updates the Incentivizer contract address\"},\"updateLiquidationFee(uint256)\":{\"notice\":\"Updates the liquidation fee\"},\"updateMinCollateral(uint256)\":{\"notice\":\"Updates the minimum allowed collateral amount per user account\"},\"updateMinFundingFee(uint256)\":{\"notice\":\"Updates the minimum allowed funding fee\"},\"updatePaused(bool)\":{\"notice\":\"Updates the protocol paused state\"},\"updatePauser(address)\":{\"notice\":\"Updates the protocol pauser address. Zero address defaults to owner(0)\"},\"updateProductBeacon(address)\":{\"notice\":\"Updates the Product implementation beacon address\"},\"updateProgramsPerProduct(uint256)\":{\"notice\":\"Updates the maximum incentivization programs per product allowed\"},\"updateProtocolFee(uint256)\":{\"notice\":\"Updates the protocol-product fee split\"}},\"notice\":\"Manages creating new products and global protocol parameters.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/controller/Controller.sol\":\"Controller\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\n\\ninterface IOracleProvider {\\n /// @dev A singular oracle version with its corresponding data\\n struct OracleVersion {\\n /// @dev The iterative version\\n uint256 version;\\n\\n /// @dev the timestamp of the oracle update\\n uint256 timestamp;\\n\\n /// @dev The oracle price of the corresponding version\\n Fixed18 price;\\n }\\n\\n function sync() external returns (OracleVersion memory);\\n function currentVersion() external view returns (OracleVersion memory);\\n function atVersion(uint256 oracleVersion) external view returns (OracleVersion memory);\\n}\\n\",\"keccak256\":\"0xde0f20d468ba8b91addfc356e13f2c74a4dc8abe68be323942217c723775d9c1\",\"license\":\"Apache-2.0\"},\"@equilibria/root/control/unstructured/UInitializable.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/Address.sol\\\";\\nimport \\\"../../storage/UStorage.sol\\\";\\n\\n/**\\n * @title UInitializable\\n * @notice Library to manage the initialization lifecycle of upgradeable contracts\\n * @dev `UInitializable` allows the creation of pseudo-constructors for upgradeable contracts. One\\n * `initializer` should be declared per top-level contract. Child contracts can use the `onlyInitializer`\\n * modifier to tag their internal initialization functions to ensure that they can only be called\\n * from a top-level `initializer` or a constructor.\\n */\\nabstract contract UInitializable {\\n error UInitializableZeroVersionError();\\n error UInitializableAlreadyInitializedError(uint256 version);\\n error UInitializableNotInitializingError();\\n\\n event Initialized(uint256 version);\\n\\n /// @dev The initialized flag\\n Uint256Storage private constant _version = Uint256Storage.wrap(keccak256(\\\"equilibria.root.UInitializable.version\\\"));\\n\\n /// @dev The initializing flag\\n BoolStorage private constant _initializing = BoolStorage.wrap(keccak256(\\\"equilibria.root.UInitializable.initializing\\\"));\\n\\n /// @dev Can only be called once per version, `version` is 1-indexed\\n modifier initializer(uint256 version) {\\n if (version == 0) revert UInitializableZeroVersionError();\\n if (_version.read() >= version) revert UInitializableAlreadyInitializedError(version);\\n\\n _version.store(version);\\n _initializing.store(true);\\n\\n _;\\n\\n _initializing.store(false);\\n emit Initialized(version);\\n }\\n\\n /// @dev Can only be called from an initializer or constructor\\n modifier onlyInitializer() {\\n if (!_constructing() && !_initializing.read()) revert UInitializableNotInitializingError();\\n _;\\n }\\n\\n /**\\n * @notice Returns whether the contract is currently being constructed\\n * @dev {Address.isContract} returns false for contracts currently in the process of being constructed\\n * @return Whether the contract is currently being constructed\\n */\\n function _constructing() private view returns (bool) {\\n return !Address.isContract(address(this));\\n }\\n}\\n\",\"keccak256\":\"0xd2743d8fcc220ed2ccdc0bba1db0a3e107741bd5c0cac47ca8c0b5a00ba2fd7f\",\"license\":\"Apache-2.0\"},\"@equilibria/root/curve/CurveMath.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"../number/types/UFixed18.sol\\\";\\nimport \\\"../number/types/Fixed18.sol\\\";\\n\\n/**\\n * @title CurveMath\\n * @notice Library for managing math operations for utilization curves.\\n */\\nlibrary CurveMath {\\n error CurveMathOutOfBoundsError();\\n\\n /**\\n * @notice Computes a linear interpolation between two points\\n * @param startX First point's x-coordinate\\n * @param startY First point's y-coordinate\\n * @param endX Second point's x-coordinate\\n * @param endY Second point's y-coordinate\\n * @param targetX x-coordinate to interpolate\\n * @return y-coordinate for `targetX` along the line from (`startX`, `startY`) -> (`endX`, `endY`)\\n */\\n function linearInterpolation(\\n UFixed18 startX,\\n Fixed18 startY,\\n UFixed18 endX,\\n Fixed18 endY,\\n UFixed18 targetX\\n ) internal pure returns (Fixed18) {\\n if (targetX.lt(startX) || targetX.gt(endX)) revert CurveMathOutOfBoundsError();\\n\\n UFixed18 xRange = endX.sub(startX);\\n Fixed18 yRange = endY.sub(startY);\\n UFixed18 xRatio = targetX.sub(startX).div(xRange);\\n return yRange.mul(Fixed18Lib.from(xRatio)).add(startY);\\n }\\n}\\n\",\"keccak256\":\"0x60d159f9ddf0dbe81124ecad58bba734b4cf82877637ff8d9d7f3e92f2da4ded\",\"license\":\"Apache-2.0\"},\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"../CurveMath.sol\\\";\\nimport \\\"../../number/types/PackedUFixed18.sol\\\";\\nimport \\\"../../number/types/PackedFixed18.sol\\\";\\n\\n/// @dev JumpRateUtilizationCurve type\\nstruct JumpRateUtilizationCurve {\\n PackedFixed18 minRate;\\n PackedFixed18 maxRate;\\n PackedFixed18 targetRate;\\n PackedUFixed18 targetUtilization;\\n}\\nusing JumpRateUtilizationCurveLib for JumpRateUtilizationCurve global;\\ntype JumpRateUtilizationCurveStorage is bytes32;\\nusing JumpRateUtilizationCurveStorageLib for JumpRateUtilizationCurveStorage global;\\n\\n/**\\n * @title JumpRateUtilizationCurveLib\\n * @notice Library for the Jump Rate utilization curve type\\n */\\nlibrary JumpRateUtilizationCurveLib {\\n /**\\n * @notice Computes the corresponding rate for a utilization ratio\\n * @param utilization The utilization ratio\\n * @return The corresponding rate\\n */\\n function compute(JumpRateUtilizationCurve memory self, UFixed18 utilization) internal pure returns (Fixed18) {\\n UFixed18 targetUtilization = self.targetUtilization.unpack();\\n if (utilization.lt(targetUtilization)) {\\n return CurveMath.linearInterpolation(\\n UFixed18Lib.ZERO,\\n self.minRate.unpack(),\\n targetUtilization,\\n self.targetRate.unpack(),\\n utilization\\n );\\n }\\n if (utilization.lt(UFixed18Lib.ONE)) {\\n return CurveMath.linearInterpolation(\\n targetUtilization,\\n self.targetRate.unpack(),\\n UFixed18Lib.ONE,\\n self.maxRate.unpack(),\\n utilization\\n );\\n }\\n return self.maxRate.unpack();\\n }\\n}\\n\\nlibrary JumpRateUtilizationCurveStorageLib {\\n function read(JumpRateUtilizationCurveStorage self) internal view returns (JumpRateUtilizationCurve memory) {\\n return _storagePointer(self);\\n }\\n\\n function store(JumpRateUtilizationCurveStorage self, JumpRateUtilizationCurve memory value) internal {\\n JumpRateUtilizationCurve storage storagePointer = _storagePointer(self);\\n\\n storagePointer.minRate = value.minRate;\\n storagePointer.maxRate = value.maxRate;\\n storagePointer.targetRate = value.targetRate;\\n storagePointer.targetUtilization = value.targetUtilization;\\n }\\n\\n function _storagePointer(JumpRateUtilizationCurveStorage self)\\n private pure returns (JumpRateUtilizationCurve storage pointer) {\\n assembly { pointer.slot := self }\\n }\\n}\",\"keccak256\":\"0xae202813874bc306d51b3dab8194c86f6483bb20bf1f673ddaee16aa8de567ff\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/Fixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SignedMath.sol\\\";\\nimport \\\"./UFixed18.sol\\\";\\nimport \\\"./PackedFixed18.sol\\\";\\n\\n/// @dev Fixed18 type\\ntype Fixed18 is int256;\\nusing Fixed18Lib for Fixed18 global;\\ntype Fixed18Storage is bytes32;\\nusing Fixed18StorageLib for Fixed18Storage global;\\n\\n/**\\n * @title Fixed18Lib\\n * @notice Library for the signed fixed-decimal type.\\n */\\nlibrary Fixed18Lib {\\n error Fixed18OverflowError(uint256 value);\\n error Fixed18PackingOverflowError(int256 value);\\n error Fixed18PackingUnderflowError(int256 value);\\n\\n int256 private constant BASE = 1e18;\\n Fixed18 public constant ZERO = Fixed18.wrap(0);\\n Fixed18 public constant ONE = Fixed18.wrap(BASE);\\n Fixed18 public constant NEG_ONE = Fixed18.wrap(-1 * BASE);\\n Fixed18 public constant MAX = Fixed18.wrap(type(int256).max);\\n Fixed18 public constant MIN = Fixed18.wrap(type(int256).min);\\n\\n /**\\n * @notice Creates a signed fixed-decimal from an unsigned fixed-decimal\\n * @param a Unsigned fixed-decimal\\n * @return New signed fixed-decimal\\n */\\n function from(UFixed18 a) internal pure returns (Fixed18) {\\n uint256 value = UFixed18.unwrap(a);\\n if (value > uint256(type(int256).max)) revert Fixed18OverflowError(value);\\n return Fixed18.wrap(int256(value));\\n }\\n\\n /**\\n * @notice Creates a signed fixed-decimal from a sign and an unsigned fixed-decimal\\n * @param s Sign\\n * @param m Unsigned fixed-decimal magnitude\\n * @return New signed fixed-decimal\\n */\\n function from(int256 s, UFixed18 m) internal pure returns (Fixed18) {\\n if (s > 0) return from(m);\\n if (s < 0) return Fixed18.wrap(-1 * Fixed18.unwrap(from(m)));\\n return ZERO;\\n }\\n\\n /**\\n * @notice Creates a signed fixed-decimal from a signed integer\\n * @param a Signed number\\n * @return New signed fixed-decimal\\n */\\n function from(int256 a) internal pure returns (Fixed18) {\\n return Fixed18.wrap(a * BASE);\\n }\\n\\n /**\\n * @notice Creates a packed signed fixed-decimal from an signed fixed-decimal\\n * @param a signed fixed-decimal\\n * @return New packed signed fixed-decimal\\n */\\n function pack(Fixed18 a) internal pure returns (PackedFixed18) {\\n int256 value = Fixed18.unwrap(a);\\n if (value > type(int128).max) revert Fixed18PackingOverflowError(value);\\n if (value < type(int128).min) revert Fixed18PackingUnderflowError(value);\\n return PackedFixed18.wrap(int128(value));\\n }\\n\\n /**\\n * @notice Returns whether the signed fixed-decimal is equal to zero.\\n * @param a Signed fixed-decimal\\n * @return Whether the signed fixed-decimal is zero.\\n */\\n function isZero(Fixed18 a) internal pure returns (bool) {\\n return Fixed18.unwrap(a) == 0;\\n }\\n\\n /**\\n * @notice Adds two signed fixed-decimals `a` and `b` together\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Resulting summed signed fixed-decimal\\n */\\n function add(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) + Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Subtracts signed fixed-decimal `b` from `a`\\n * @param a Signed fixed-decimal to subtract from\\n * @param b Signed fixed-decimal to subtract\\n * @return Resulting subtracted signed fixed-decimal\\n */\\n function sub(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) - Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Multiplies two signed fixed-decimals `a` and `b` together\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Resulting multiplied signed fixed-decimal\\n */\\n function mul(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / BASE);\\n }\\n\\n /**\\n * @notice Divides signed fixed-decimal `a` by `b`\\n * @param a Signed fixed-decimal to divide\\n * @param b Signed fixed-decimal to divide by\\n * @return Resulting divided signed fixed-decimal\\n */\\n function div(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * BASE / Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0`, `MAX` for `n/0`, and `MIN` for `-n/0`.\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function unsafeDiv(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n if (isZero(b)) {\\n if (gt(a, ZERO)) return MAX;\\n if (lt(a, ZERO)) return MIN;\\n return ONE;\\n } else {\\n return div(a, b);\\n }\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First signed fixed-decimal\\n * @param b Signed number to multiply by\\n * @param c Signed number to divide by\\n * @return Resulting computation\\n */\\n function muldiv(Fixed18 a, int256 b, int256 c) internal pure returns (Fixed18) {\\n return muldiv(a, Fixed18.wrap(b), Fixed18.wrap(c));\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First signed fixed-decimal\\n * @param b Signed fixed-decimal to multiply by\\n * @param c Signed fixed-decimal to divide by\\n * @return Resulting computation\\n */\\n function muldiv(Fixed18 a, Fixed18 b, Fixed18 c) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / Fixed18.unwrap(c));\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is equal to `b`\\n */\\n function eq(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 1;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is greater than `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is greater than `b`\\n */\\n function gt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 2;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is less than `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is less than `b`\\n */\\n function lt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 0;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is greater than or equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is greater than or equal to `b`\\n */\\n function gte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return gt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is less than or equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is less than or equal to `b`\\n */\\n function lte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return lt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Compares the signed fixed-decimals `a` and `b`\\n * @dev Returns: 2 for greater than\\n * 1 for equal to\\n * 0 for less than\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Compare result of `a` and `b`\\n */\\n function compare(Fixed18 a, Fixed18 b) internal pure returns (uint256) {\\n (int256 au, int256 bu) = (Fixed18.unwrap(a), Fixed18.unwrap(b));\\n if (au > bu) return 2;\\n if (au < bu) return 0;\\n return 1;\\n }\\n\\n /**\\n * @notice Returns a signed fixed-decimal representing the ratio of `a` over `b`\\n * @param a First signed number\\n * @param b Second signed number\\n * @return Ratio of `a` over `b`\\n */\\n function ratio(int256 a, int256 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(a * BASE / b);\\n }\\n\\n /**\\n * @notice Returns the minimum of signed fixed-decimals `a` and `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Minimum of `a` and `b`\\n */\\n function min(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(SignedMath.min(Fixed18.unwrap(a), Fixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Returns the maximum of signed fixed-decimals `a` and `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Maximum of `a` and `b`\\n */\\n function max(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(SignedMath.max(Fixed18.unwrap(a), Fixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Converts the signed fixed-decimal into an integer, truncating any decimal portion\\n * @param a Signed fixed-decimal\\n * @return Truncated signed number\\n */\\n function truncate(Fixed18 a) internal pure returns (int256) {\\n return Fixed18.unwrap(a) / BASE;\\n }\\n\\n /**\\n * @notice Returns the sign of the signed fixed-decimal\\n * @dev Returns: -1 for negative\\n * 0 for zero\\n * 1 for positive\\n * @param a Signed fixed-decimal\\n * @return Sign of the signed fixed-decimal\\n */\\n function sign(Fixed18 a) internal pure returns (int256) {\\n if (Fixed18.unwrap(a) > 0) return 1;\\n if (Fixed18.unwrap(a) < 0) return -1;\\n return 0;\\n }\\n\\n /**\\n * @notice Returns the absolute value of the signed fixed-decimal\\n * @param a Signed fixed-decimal\\n * @return Absolute value of the signed fixed-decimal\\n */\\n function abs(Fixed18 a) internal pure returns (UFixed18) {\\n return UFixed18.wrap(SignedMath.abs(Fixed18.unwrap(a)));\\n }\\n}\\n\\nlibrary Fixed18StorageLib {\\n function read(Fixed18Storage self) internal view returns (Fixed18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(Fixed18Storage self, Fixed18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x613587461ef3437ef33229cdda7d34ea746278721baf06e20b2e43977f43174d\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/PackedFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"./Fixed18.sol\\\";\\n\\n/// @dev PackedFixed18 type\\ntype PackedFixed18 is int128;\\nusing PackedFixed18Lib for PackedFixed18 global;\\n\\n/**\\n * @title PackedFixed18Lib\\n * @dev A packed version of the Fixed18 which takes up half the storage space (two PackedFixed18 can be packed\\n * into a single slot). Only valid within the range -1.7014118e+20 <= x <= 1.7014118e+20.\\n * @notice Library for the packed signed fixed-decimal type.\\n */\\nlibrary PackedFixed18Lib {\\n PackedFixed18 public constant MAX = PackedFixed18.wrap(type(int128).max);\\n PackedFixed18 public constant MIN = PackedFixed18.wrap(type(int128).min);\\n\\n /**\\n * @notice Creates an unpacked signed fixed-decimal from a packed signed fixed-decimal\\n * @param self packed signed fixed-decimal\\n * @return New unpacked signed fixed-decimal\\n */\\n function unpack(PackedFixed18 self) internal pure returns (Fixed18) {\\n return Fixed18.wrap(int256(PackedFixed18.unwrap(self)));\\n }\\n}\\n\",\"keccak256\":\"0xb52960cc8e3132e45d342bbbb1c6a96219022cd8557997933bd8250170268b64\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/PackedUFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"./UFixed18.sol\\\";\\n\\n/// @dev PackedUFixed18 type\\ntype PackedUFixed18 is uint128;\\nusing PackedUFixed18Lib for PackedUFixed18 global;\\n\\n/**\\n * @title PackedUFixed18Lib\\n * @dev A packed version of the UFixed18 which takes up half the storage space (two PackedUFixed18 can be packed\\n * into a single slot). Only valid within the range 0 <= x <= 3.4028237e+20.\\n * @notice Library for the packed unsigned fixed-decimal type.\\n */\\nlibrary PackedUFixed18Lib {\\n PackedUFixed18 public constant MAX = PackedUFixed18.wrap(type(uint128).max);\\n\\n /**\\n * @notice Creates an unpacked unsigned fixed-decimal from a packed unsigned fixed-decimal\\n * @param self packed unsigned fixed-decimal\\n * @return New unpacked unsigned fixed-decimal\\n */\\n function unpack(PackedUFixed18 self) internal pure returns (UFixed18) {\\n return UFixed18.wrap(uint256(PackedUFixed18.unwrap(self)));\\n }\\n}\\n\",\"keccak256\":\"0xb5c5cd32d6530b2fe75228b6be32ebcb7762f6d7988b85a6b85a289ce8256d51\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/UFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"./Fixed18.sol\\\";\\nimport \\\"./PackedUFixed18.sol\\\";\\n\\n/// @dev UFixed18 type\\ntype UFixed18 is uint256;\\nusing UFixed18Lib for UFixed18 global;\\ntype UFixed18Storage is bytes32;\\nusing UFixed18StorageLib for UFixed18Storage global;\\n\\n/**\\n * @title UFixed18Lib\\n * @notice Library for the unsigned fixed-decimal type.\\n */\\nlibrary UFixed18Lib {\\n error UFixed18UnderflowError(int256 value);\\n error UFixed18PackingOverflowError(uint256 value);\\n\\n uint256 private constant BASE = 1e18;\\n UFixed18 public constant ZERO = UFixed18.wrap(0);\\n UFixed18 public constant ONE = UFixed18.wrap(BASE);\\n UFixed18 public constant MAX = UFixed18.wrap(type(uint256).max);\\n\\n /**\\n * @notice Creates a unsigned fixed-decimal from a signed fixed-decimal\\n * @param a Signed fixed-decimal\\n * @return New unsigned fixed-decimal\\n */\\n function from(Fixed18 a) internal pure returns (UFixed18) {\\n int256 value = Fixed18.unwrap(a);\\n if (value < 0) revert UFixed18UnderflowError(value);\\n return UFixed18.wrap(uint256(value));\\n }\\n\\n /**\\n * @notice Creates a unsigned fixed-decimal from a unsigned integer\\n * @param a Unsigned number\\n * @return New unsigned fixed-decimal\\n */\\n function from(uint256 a) internal pure returns (UFixed18) {\\n return UFixed18.wrap(a * BASE);\\n }\\n\\n /**\\n * @notice Creates a packed unsigned fixed-decimal from an unsigned fixed-decimal\\n * @param a unsigned fixed-decimal\\n * @return New packed unsigned fixed-decimal\\n */\\n function pack(UFixed18 a) internal pure returns (PackedUFixed18) {\\n uint256 value = UFixed18.unwrap(a);\\n if (value > type(uint128).max) revert UFixed18PackingOverflowError(value);\\n return PackedUFixed18.wrap(uint128(value));\\n }\\n\\n /**\\n * @notice Returns whether the unsigned fixed-decimal is equal to zero.\\n * @param a Unsigned fixed-decimal\\n * @return Whether the unsigned fixed-decimal is zero.\\n */\\n function isZero(UFixed18 a) internal pure returns (bool) {\\n return UFixed18.unwrap(a) == 0;\\n }\\n\\n /**\\n * @notice Adds two unsigned fixed-decimals `a` and `b` together\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Resulting summed unsigned fixed-decimal\\n */\\n function add(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) + UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Subtracts unsigned fixed-decimal `b` from `a`\\n * @param a Unsigned fixed-decimal to subtract from\\n * @param b Unsigned fixed-decimal to subtract\\n * @return Resulting subtracted unsigned fixed-decimal\\n */\\n function sub(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) - UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Multiplies two unsigned fixed-decimals `a` and `b` together\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Resulting multiplied unsigned fixed-decimal\\n */\\n function mul(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / BASE);\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function div(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * BASE / UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0` and `MAX` for `n/0`.\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function unsafeDiv(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n if (isZero(b)) {\\n return isZero(a) ? ONE : MAX;\\n } else {\\n return div(a, b);\\n }\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First unsigned fixed-decimal\\n * @param b Unsigned number to multiply by\\n * @param c Unsigned number to divide by\\n * @return Resulting computation\\n */\\n function muldiv(UFixed18 a, uint256 b, uint256 c) internal pure returns (UFixed18) {\\n return muldiv(a, UFixed18.wrap(b), UFixed18.wrap(c));\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First unsigned fixed-decimal\\n * @param b Unsigned fixed-decimal to multiply by\\n * @param c Unsigned fixed-decimal to divide by\\n * @return Resulting computation\\n */\\n function muldiv(UFixed18 a, UFixed18 b, UFixed18 c) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / UFixed18.unwrap(c));\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is equal to `b`\\n */\\n function eq(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 1;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is greater than `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is greater than `b`\\n */\\n function gt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 2;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is less than `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is less than `b`\\n */\\n function lt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 0;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is greater than or equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is greater than or equal to `b`\\n */\\n function gte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return gt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is less than or equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is less than or equal to `b`\\n */\\n function lte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return lt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Compares the unsigned fixed-decimals `a` and `b`\\n * @dev Returns: 2 for greater than\\n * 1 for equal to\\n * 0 for less than\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Compare result of `a` and `b`\\n */\\n function compare(UFixed18 a, UFixed18 b) internal pure returns (uint256) {\\n (uint256 au, uint256 bu) = (UFixed18.unwrap(a), UFixed18.unwrap(b));\\n if (au > bu) return 2;\\n if (au < bu) return 0;\\n return 1;\\n }\\n\\n /**\\n * @notice Returns a unsigned fixed-decimal representing the ratio of `a` over `b`\\n * @param a First unsigned number\\n * @param b Second unsigned number\\n * @return Ratio of `a` over `b`\\n */\\n function ratio(uint256 a, uint256 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(a * BASE / b);\\n }\\n\\n /**\\n * @notice Returns the minimum of unsigned fixed-decimals `a` and `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Minimum of `a` and `b`\\n */\\n function min(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(Math.min(UFixed18.unwrap(a), UFixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Returns the maximum of unsigned fixed-decimals `a` and `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Maximum of `a` and `b`\\n */\\n function max(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(Math.max(UFixed18.unwrap(a), UFixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Converts the unsigned fixed-decimal into an integer, truncating any decimal portion\\n * @param a Unsigned fixed-decimal\\n * @return Truncated unsigned number\\n */\\n function truncate(UFixed18 a) internal pure returns (uint256) {\\n return UFixed18.unwrap(a) / BASE;\\n }\\n}\\n\\nlibrary UFixed18StorageLib {\\n function read(UFixed18Storage self) internal view returns (UFixed18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(UFixed18Storage self, UFixed18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x8ebef1e6c717f565b9ed545a876b5692b4007e6485c99f39d363f7405e591792\",\"license\":\"Apache-2.0\"},\"@equilibria/root/storage/UStorage.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"../number/types/UFixed18.sol\\\";\\n\\n/// @dev Stored boolean slot\\ntype BoolStorage is bytes32;\\nusing BoolStorageLib for BoolStorage global;\\n\\n/// @dev Stored uint256 slot\\ntype Uint256Storage is bytes32;\\nusing Uint256StorageLib for Uint256Storage global;\\n\\n/// @dev Stored int256 slot\\ntype Int256Storage is bytes32;\\nusing Int256StorageLib for Int256Storage global;\\n\\n/// @dev Stored address slot\\ntype AddressStorage is bytes32;\\nusing AddressStorageLib for AddressStorage global;\\n\\n/// @dev Stored bytes32 slot\\ntype Bytes32Storage is bytes32;\\nusing Bytes32StorageLib for Bytes32Storage global;\\n\\n/**\\n * @title BoolStorageLib\\n * @notice Library to manage storage and retrival of a boolean at a fixed storage slot\\n */\\nlibrary BoolStorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored bool value\\n */\\n function read(BoolStorage self) internal view returns (bool value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value boolean value to store\\n */\\n function store(BoolStorage self, bool value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\\n/**\\n * @title Uint256StorageLib\\n * @notice Library to manage storage and retrival of an uint256 at a fixed storage slot\\n */\\nlibrary Uint256StorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored uint256 value\\n */\\n function read(Uint256Storage self) internal view returns (uint256 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value uint256 value to store\\n */\\n function store(Uint256Storage self, uint256 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\\n/**\\n * @title Int256StorageLib\\n * @notice Library to manage storage and retrival of an int256 at a fixed storage slot\\n */\\nlibrary Int256StorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored int256 value\\n */\\n function read(Int256Storage self) internal view returns (int256 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value int256 value to store\\n */\\n function store(Int256Storage self, int256 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\\n/**\\n * @title AddressStorageLib\\n * @notice Library to manage storage and retrival of an address at a fixed storage slot\\n */\\nlibrary AddressStorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored address value\\n */\\n function read(AddressStorage self) internal view returns (address value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value address value to store\\n */\\n function store(AddressStorage self, address value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\\n/**\\n * @title Bytes32StorageLib\\n * @notice Library to manage storage and retrival of a bytes32 at a fixed storage slot\\n */\\nlibrary Bytes32StorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored bytes32 value\\n */\\n function read(Bytes32Storage self) internal view returns (bytes32 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value bytes32 value to store\\n */\\n function store(Bytes32Storage self, bytes32 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0xe2b8491d1b5aa93f7e059e1a8f156b0ab37fef9ed973be97a64f2eabfc2cc172\",\"license\":\"Apache-2.0\"},\"@equilibria/root/token/types/Token18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"../../number/types/UFixed18.sol\\\";\\n\\n/// @dev Token18\\ntype Token18 is address;\\nusing Token18Lib for Token18 global;\\ntype Token18Storage is bytes32;\\nusing Token18StorageLib for Token18Storage global;\\n\\n/**\\n * @title Token18Lib\\n * @notice Library to manage 18-decimal ERC20s that is compliant with the fixed-decimal types.\\n * @dev Maintains significant gas savings over other Token implementations since no conversion take place\\n */\\nlibrary Token18Lib {\\n using SafeERC20 for IERC20;\\n\\n Token18 public constant ZERO = Token18.wrap(address(0));\\n\\n /**\\n * @notice Returns whether a token is the zero address\\n * @param self Token to check for\\n * @return Whether the token is the zero address\\n */\\n function isZero(Token18 self) internal pure returns (bool) {\\n return Token18.unwrap(self) == Token18.unwrap(ZERO);\\n }\\n\\n /**\\n * @notice Returns whether the two tokens are equal\\n * @param a First token to compare\\n * @param b Second token to compare\\n * @return Whether the two tokens are equal\\n */\\n function eq(Token18 a, Token18 b) internal pure returns (bool) {\\n return Token18.unwrap(a) == Token18.unwrap(b);\\n }\\n\\n /**\\n * @notice Approves `grantee` to spend infinite tokens from the caller\\n * @param self Token to transfer\\n * @param grantee Address to allow spending\\n */\\n function approve(Token18 self, address grantee) internal {\\n IERC20(Token18.unwrap(self)).safeApprove(grantee, type(uint256).max);\\n }\\n\\n /**\\n * @notice Approves `grantee` to spend `amount` tokens from the caller\\n * @dev There are important race conditions to be aware of when using this function\\n with values other than 0. This will revert if moving from non-zero to non-zero amounts\\n See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/a55b7d13722e7ce850b626da2313f3e66ca1d101/contracts/token/ERC20/IERC20.sol#L57\\n * @param self Token to transfer\\n * @param grantee Address to allow spending\\n * @param amount Amount of tokens to approve to spend\\n */\\n function approve(Token18 self, address grantee, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeApprove(grantee, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers all held tokens from the caller to the `recipient`\\n * @param self Token to transfer\\n * @param recipient Address to receive the tokens\\n */\\n function push(Token18 self, address recipient) internal {\\n push(self, recipient, balanceOf(self, address(this)));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the caller to the `recipient`\\n * @param self Token to transfer\\n * @param recipient Address to transfer tokens to\\n * @param amount Amount of tokens to transfer\\n */\\n function push(Token18 self, address recipient, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransfer(recipient, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the `benefactor` to the caller\\n * @dev Reverts if trying to pull Ether\\n * @param self Token to transfer\\n * @param benefactor Address to transfer tokens from\\n * @param amount Amount of tokens to transfer\\n */\\n function pull(Token18 self, address benefactor, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, address(this), UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the `benefactor` to `recipient`\\n * @dev Reverts if trying to pull Ether\\n * @param self Token to transfer\\n * @param benefactor Address to transfer tokens from\\n * @param recipient Address to transfer tokens to\\n * @param amount Amount of tokens to transfer\\n */\\n function pullTo(Token18 self, address benefactor, address recipient, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, recipient, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Returns the name of the token\\n * @param self Token to check for\\n * @return Token name\\n */\\n function name(Token18 self) internal view returns (string memory) {\\n return IERC20Metadata(Token18.unwrap(self)).name();\\n }\\n\\n /**\\n * @notice Returns the symbol of the token\\n * @param self Token to check for\\n * @return Token symbol\\n */\\n function symbol(Token18 self) internal view returns (string memory) {\\n return IERC20Metadata(Token18.unwrap(self)).symbol();\\n }\\n\\n /**\\n * @notice Returns the `self` token balance of the caller\\n * @param self Token to check for\\n * @return Token balance of the caller\\n */\\n function balanceOf(Token18 self) internal view returns (UFixed18) {\\n return balanceOf(self, address(this));\\n }\\n\\n /**\\n * @notice Returns the `self` token balance of `account`\\n * @param self Token to check for\\n * @param account Account to check\\n * @return Token balance of the account\\n */\\n function balanceOf(Token18 self, address account) internal view returns (UFixed18) {\\n return UFixed18.wrap(IERC20(Token18.unwrap(self)).balanceOf(account));\\n }\\n}\\n\\nlibrary Token18StorageLib {\\n function read(Token18Storage self) internal view returns (Token18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(Token18Storage self, Token18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x6b12afaece814f0ab186200a4729e93eb685a21d3e9b5a3372ff283a7ad5dc23\",\"license\":\"Apache-2.0\"},\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/BeaconProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IBeacon.sol\\\";\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"../ERC1967/ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that gets the implementation address for each call from a {UpgradeableBeacon}.\\n *\\n * The beacon address is stored in storage slot `uint256(keccak256('eip1967.proxy.beacon')) - 1`, so that it doesn't\\n * conflict with the storage layout of the implementation behind the proxy.\\n *\\n * _Available since v3.4._\\n */\\ncontract BeaconProxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the proxy with `beacon`.\\n *\\n * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This\\n * will typically be an encoded function call, and allows initializating the storage of the proxy like a Solidity\\n * constructor.\\n *\\n * Requirements:\\n *\\n * - `beacon` must be a contract with the interface {IBeacon}.\\n */\\n constructor(address beacon, bytes memory data) payable {\\n assert(_BEACON_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.beacon\\\")) - 1));\\n _upgradeBeaconToAndCall(beacon, data, false);\\n }\\n\\n /**\\n * @dev Returns the current beacon address.\\n */\\n function _beacon() internal view virtual returns (address) {\\n return _getBeacon();\\n }\\n\\n /**\\n * @dev Returns the current implementation address of the associated beacon.\\n */\\n function _implementation() internal view virtual override returns (address) {\\n return IBeacon(_getBeacon()).implementation();\\n }\\n\\n /**\\n * @dev Changes the proxy to use a new beacon. Deprecated: see {_upgradeBeaconToAndCall}.\\n *\\n * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon.\\n *\\n * Requirements:\\n *\\n * - `beacon` must be a contract.\\n * - The implementation returned by `beacon` must be a contract.\\n */\\n function _setBeacon(address beacon, bytes memory data) internal virtual {\\n _upgradeBeaconToAndCall(beacon, data, false);\\n }\\n}\\n\",\"keccak256\":\"0x54878f0d2f40b5e13f84977bcd3c71d4c38581414e7efb4909cb16dd3ace392f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\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 amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` 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(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\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\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 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 using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\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 function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc3d946432c0ddbb1f846a0d3985be71299df331b91d06732152117f62f0be2b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // 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\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\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 ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\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(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\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 /**\\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 {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return 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 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 up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a / b + (a % b == 0 ? 0 : 1);\\n }\\n}\\n\",\"keccak256\":\"0xc995bddbca1ae19788db9f8b61e63385edd3fddf89693b612d5abd1a275974d2\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SignedMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/SignedMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard signed math utilities missing in the Solidity language.\\n */\\nlibrary SignedMath {\\n /**\\n * @dev Returns the largest of two signed numbers.\\n */\\n function max(int256 a, int256 b) internal pure returns (int256) {\\n return 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 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 // must be unchecked in order to support `n = type(int256).min`\\n return uint256(n >= 0 ? n : -n);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb3ebde1c8d27576db912d87c3560dab14adfb9cd001be95890ec4ba035e652e7\",\"license\":\"MIT\"},\"contracts/controller/Controller.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"@equilibria/root/control/unstructured/UInitializable.sol\\\";\\nimport \\\"@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol\\\";\\nimport \\\"../interfaces/IController.sol\\\";\\nimport \\\"../interfaces/ICollateral.sol\\\";\\nimport \\\"../interfaces/IIncentivizer.sol\\\";\\nimport \\\"../interfaces/IProduct.sol\\\";\\n\\n/**\\n * @title Controller\\n * @notice Manages creating new products and global protocol parameters.\\n */\\ncontract Controller is IController, UInitializable {\\n /// @dev Collateral contract address for the protocol\\n AddressStorage private constant _collateral = AddressStorage.wrap(keccak256(\\\"equilibria.perennial.Controller.collateral\\\"));\\n function collateral() public view returns (ICollateral) { return ICollateral(_collateral.read()); }\\n\\n /// @dev Incentivizer contract address for the protocol\\n AddressStorage private constant _incentivizer = AddressStorage.wrap(keccak256(\\\"equilibria.perennial.Controller.incentivizer\\\"));\\n function incentivizer() public view returns (IIncentivizer) { return IIncentivizer(_incentivizer.read()); }\\n\\n /// @dev Product implementation beacon address for the protocol\\n AddressStorage private constant _productBeacon = AddressStorage.wrap(keccak256(\\\"equilibria.perennial.Controller.productBeacon\\\"));\\n function productBeacon() public view returns (IBeacon) { return IBeacon(_productBeacon.read()); }\\n\\n /// @dev Percent of collected fees that go to the protocol treasury vs the product treasury\\n UFixed18Storage private constant _protocolFee = UFixed18Storage.wrap(keccak256(\\\"equilibria.perennial.Controller.protocolFee\\\"));\\n function protocolFee() public view returns (UFixed18) { return _protocolFee.read(); }\\n\\n /// @dev Minimum allowable funding fee for a product\\n UFixed18Storage private constant _minFundingFee = UFixed18Storage.wrap(keccak256(\\\"equilibria.perennial.Controller.minFundingFee\\\"));\\n function minFundingFee() public view returns (UFixed18) { return _minFundingFee.read(); }\\n\\n /// @dev Fee on maintenance for liquidation\\n UFixed18Storage private constant _liquidationFee = UFixed18Storage.wrap(keccak256(\\\"equilibria.perennial.Controller.liquidationFee\\\"));\\n function liquidationFee() public view returns (UFixed18) { return _liquidationFee.read(); }\\n\\n /// @dev Fee on incentivization programs\\n UFixed18Storage private constant _incentivizationFee = UFixed18Storage.wrap(keccak256(\\\"equilibria.perennial.Controller.incentivizationFee\\\"));\\n function incentivizationFee() public view returns (UFixed18) { return _incentivizationFee.read(); }\\n\\n /// @dev Minimum allowable collateral amount per user account\\n UFixed18Storage private constant _minCollateral = UFixed18Storage.wrap(keccak256(\\\"equilibria.perennial.Controller.minCollateral\\\"));\\n function minCollateral() public view returns (UFixed18) { return _minCollateral.read(); }\\n\\n /// @dev Maximum incentivization programs per product allowed\\n Uint256Storage private constant _programsPerProduct = Uint256Storage.wrap(keccak256(\\\"equilibria.perennial.Controller.programsPerProduct\\\"));\\n function programsPerProduct() public view returns (uint256) { return _programsPerProduct.read(); }\\n\\n /// @dev Protocol pauser address. address(0) defaults to owner(0)\\n AddressStorage private constant _pauser = AddressStorage.wrap(keccak256(\\\"equilibria.perennial.Controller.pauser\\\"));\\n function pauser() public view returns (address) {\\n address pauser_ = _pauser.read();\\n return pauser_ == address(0) ? owner() : pauser_;\\n }\\n\\n /// @dev The paused status of the protocol\\n BoolStorage private constant _paused = BoolStorage.wrap(keccak256(\\\"equilibria.perennial.Controller.paused\\\"));\\n function paused() public view returns (bool) { return _paused.read(); }\\n\\n /// @dev List of product coordinators\\n Coordinator[] private _coordinators;\\n\\n /// @dev Mapping of the coordinator for each product\\n mapping(IProduct => uint256) public coordinatorFor;\\n\\n /**\\n * @notice Initializes the contract state\\n * @dev Must be called atomically as part of the upgradeable proxy deployment to\\n * avoid front-running\\n * @param collateral_ Collateral contract address\\n * @param incentivizer_ Incentivizer contract address\\n * @param productBeacon_ Product implementation beacon address\\n */\\n function initialize(\\n ICollateral collateral_,\\n IIncentivizer incentivizer_,\\n IBeacon productBeacon_\\n ) external initializer(1) {\\n _createCoordinator();\\n\\n updateCollateral(collateral_);\\n updateIncentivizer(incentivizer_);\\n updateProductBeacon(productBeacon_);\\n }\\n\\n /**\\n * @notice Creates a new coordinator with `msg.sender` as the owner\\n * @dev Can only be called by the protocol owner\\n * @return New coordinator ID\\n */\\n function createCoordinator() external returns (uint256) {\\n return _createCoordinator();\\n }\\n\\n /**\\n * @notice Creates a new coordinator with `msg.sender` as the owner\\n * @dev `treasury` and `pauser` initialize as the 0-address, defaulting to the `owner`\\n * @return New coordinator ID\\n */\\n function _createCoordinator() private returns (uint256) {\\n uint256 coordinatorId = _coordinators.length;\\n\\n _coordinators.push(Coordinator({\\n pendingOwner: address(0),\\n owner: msg.sender,\\n treasury: address(0)\\n }));\\n\\n emit CoordinatorCreated(coordinatorId, msg.sender);\\n\\n return coordinatorId;\\n }\\n\\n /**\\n * @notice Updates the pending owner of an existing coordinator\\n * @dev Must be called by the coordinator's current owner\\n * @param coordinatorId Coordinator to update\\n * @param newPendingOwner New pending owner address\\n */\\n function updateCoordinatorPendingOwner(uint256 coordinatorId, address newPendingOwner) external onlyOwner(coordinatorId) {\\n _coordinators[coordinatorId].pendingOwner = newPendingOwner;\\n emit CoordinatorPendingOwnerUpdated(coordinatorId, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts ownership over an existing coordinator\\n * @dev Must be called by the coordinator's pending owner\\n * @param coordinatorId Coordinator to update\\n */\\n function acceptCoordinatorOwner(uint256 coordinatorId) external {\\n Coordinator storage coordinator = _coordinators[coordinatorId];\\n address newPendingOwner = coordinator.pendingOwner;\\n\\n if (msg.sender != newPendingOwner) revert ControllerNotPendingOwnerError(coordinatorId);\\n\\n coordinator.pendingOwner = address(0);\\n coordinator.owner = newPendingOwner;\\n emit CoordinatorOwnerUpdated(coordinatorId, newPendingOwner);\\n }\\n\\n /**\\n * @notice Updates the treasury of an existing coordinator\\n * @dev Must be called by the coordinator's current owner. Defaults to the coordinator `owner` if set to address(0)\\n * @param coordinatorId Coordinator to update\\n * @param newTreasury New treasury address\\n */\\n function updateCoordinatorTreasury(uint256 coordinatorId, address newTreasury) external onlyOwner(coordinatorId) {\\n _coordinators[coordinatorId].treasury = newTreasury;\\n emit CoordinatorTreasuryUpdated(coordinatorId, newTreasury);\\n }\\n\\n /**\\n * @notice Creates a new product market with `provider`\\n * @dev Can only be called by the coordinator owner\\n * @param coordinatorId Coordinator that will own the product\\n * @param productInfo Product params used to initialize the product\\n * @return New product contract address\\n */\\n function createProduct(uint256 coordinatorId, IProduct.ProductInfo calldata productInfo)\\n external onlyOwner(coordinatorId) returns (IProduct) {\\n if (coordinatorId == 0) revert ControllerNoZeroCoordinatorError();\\n\\n BeaconProxy newProductProxy = new BeaconProxy(address(productBeacon()), abi.encodeCall(IProduct.initialize, productInfo));\\n IProduct newProduct = IProduct(address(newProductProxy));\\n coordinatorFor[newProduct] = coordinatorId;\\n emit ProductCreated(newProduct, productInfo);\\n\\n return newProduct;\\n }\\n\\n /**\\n * @notice Updates the Collateral contract address\\n * @param newCollateral New Collateral contract address\\n */\\n function updateCollateral(ICollateral newCollateral) public onlyOwner(0) {\\n if (!Address.isContract(address(newCollateral))) revert ControllerNotContractAddressError();\\n _collateral.store(address(newCollateral));\\n emit CollateralUpdated(newCollateral);\\n }\\n\\n /**\\n * @notice Updates the Incentivizer contract address\\n * @param newIncentivizer New Incentivizer contract address\\n */\\n function updateIncentivizer(IIncentivizer newIncentivizer) public onlyOwner(0) {\\n if (!Address.isContract(address(newIncentivizer))) revert ControllerNotContractAddressError();\\n _incentivizer.store(address(newIncentivizer));\\n emit IncentivizerUpdated(newIncentivizer);\\n }\\n\\n /**\\n * @notice Updates the Product implementation beacon address\\n * @param newProductBeacon New Product implementation beacon address\\n */\\n function updateProductBeacon(IBeacon newProductBeacon) public onlyOwner(0) {\\n if (!Address.isContract(address(newProductBeacon))) revert ControllerNotContractAddressError();\\n _productBeacon.store(address(newProductBeacon));\\n emit ProductBeaconUpdated(newProductBeacon);\\n }\\n\\n /**\\n * @notice Updates the protocol-product fee split\\n * @param newProtocolFee New protocol-product fee split\\n */\\n function updateProtocolFee(UFixed18 newProtocolFee) public onlyOwner(0) {\\n if (newProtocolFee.gt(UFixed18Lib.ONE)) revert ControllerInvalidProtocolFeeError();\\n\\n _protocolFee.store(newProtocolFee);\\n emit ProtocolFeeUpdated(newProtocolFee);\\n }\\n\\n /**\\n * @notice Updates the minimum allowed funding fee\\n * @param newMinFundingFee New minimum allowed funding fee\\n */\\n function updateMinFundingFee(UFixed18 newMinFundingFee) public onlyOwner(0) {\\n if (newMinFundingFee.gt(UFixed18Lib.ONE)) revert ControllerInvalidMinFundingFeeError();\\n\\n _minFundingFee.store(newMinFundingFee);\\n emit MinFundingFeeUpdated(newMinFundingFee);\\n }\\n\\n /**\\n * @notice Updates the liquidation fee\\n * @param newLiquidationFee New liquidation fee\\n */\\n function updateLiquidationFee(UFixed18 newLiquidationFee) public onlyOwner(0) {\\n if (newLiquidationFee.gt(UFixed18Lib.ONE)) revert ControllerInvalidLiquidationFeeError();\\n\\n _liquidationFee.store(newLiquidationFee);\\n emit LiquidationFeeUpdated(newLiquidationFee);\\n }\\n\\n /**\\n * @notice Updates the incentivization fee\\n * @param newIncentivizationFee New incentivization fee\\n */\\n function updateIncentivizationFee(UFixed18 newIncentivizationFee) public onlyOwner(0) {\\n if (newIncentivizationFee.gt(UFixed18Lib.ONE)) revert ControllerInvalidIncentivizationFeeError();\\n\\n _incentivizationFee.store(newIncentivizationFee);\\n emit IncentivizationFeeUpdated(newIncentivizationFee);\\n }\\n\\n /**\\n * @notice Updates the minimum allowed collateral amount per user account\\n * @param newMinCollateral New minimum allowed collateral amount\\n */\\n function updateMinCollateral(UFixed18 newMinCollateral) public onlyOwner(0) {\\n _minCollateral.store(newMinCollateral);\\n emit MinCollateralUpdated(newMinCollateral);\\n }\\n\\n /**\\n * @notice Updates the maximum incentivization programs per product allowed\\n * @param newProgramsPerProduct New maximum incentivization programs per product allowed\\n */\\n function updateProgramsPerProduct(uint256 newProgramsPerProduct) public onlyOwner(0) {\\n _programsPerProduct.store(newProgramsPerProduct);\\n emit ProgramsPerProductUpdated(newProgramsPerProduct);\\n }\\n\\n /**\\n * @notice Updates the protocol pauser address. Zero address defaults to owner(0)\\n * @param newPauser New protocol pauser address\\n */\\n function updatePauser(address newPauser) public onlyOwner(0) {\\n _pauser.store(newPauser);\\n emit PauserUpdated(newPauser);\\n }\\n\\n /**\\n * @notice Updates the protocol paused state\\n * @param newPaused New protocol paused state\\n */\\n function updatePaused(bool newPaused) public onlyPauser {\\n _paused.store(newPaused);\\n emit PausedUpdated(newPaused);\\n }\\n\\n /**\\n * @notice Returns whether a contract is a product\\n * @param product Contract address to check\\n * @return Whether a contract is a product\\n */\\n function isProduct(IProduct product) external view returns (bool) {\\n return coordinatorFor[product] != 0;\\n }\\n\\n /**\\n * @notice Returns coordinator state for coordinator `coordinatorId`\\n * @param coordinatorId Coordinator to return for\\n * @return Coordinator state\\n */\\n function coordinators(uint256 coordinatorId) external view returns (Coordinator memory) {\\n return _coordinators[coordinatorId];\\n }\\n\\n /**\\n * @notice Returns the pending owner of the protocol\\n * @return Owner of the protocol\\n */\\n function pendingOwner() public view returns (address) {\\n return pendingOwner(0);\\n }\\n\\n /**\\n * @notice Returns the pending owner of the coordinator `coordinatorId`\\n * @param coordinatorId Coordinator to return for\\n * @return Pending owner of the coordinator\\n */\\n function pendingOwner(uint256 coordinatorId) public view returns (address) {\\n return _coordinators[coordinatorId].pendingOwner;\\n }\\n\\n /**\\n * @notice Returns the owner of the protocol\\n * @return Owner of the protocol\\n */\\n function owner() public view returns (address) {\\n return owner(0);\\n }\\n\\n /**\\n * @notice Returns the owner of the coordinator `coordinatorId`\\n * @param coordinatorId Coordinator to return for\\n * @return Owner of the coordinator\\n */\\n function owner(uint256 coordinatorId) public view returns (address) {\\n return _coordinators[coordinatorId].owner;\\n }\\n\\n /**\\n * @notice Returns the owner of the product `product`\\n * @param product Product to return for\\n * @return Owner of the product\\n */\\n function owner(IProduct product) external view returns (address) {\\n return owner(coordinatorFor[product]);\\n }\\n\\n /**\\n * @notice Returns the treasury of the protocol\\n * @dev Defaults to the `owner` when `treasury` is unset\\n * @return Treasury of the protocol\\n */\\n function treasury() external view returns (address) {\\n return treasury(0);\\n }\\n\\n /**\\n * @notice Returns the treasury of the coordinator `coordinatorId`\\n * @dev Defaults to the `owner` when `treasury` is unset\\n * @param coordinatorId Coordinator to return for\\n * @return Treasury of the coordinator\\n */\\n function treasury(uint256 coordinatorId) public view returns (address) {\\n address _treasury = _coordinators[coordinatorId].treasury;\\n return _treasury == address(0) ? owner(coordinatorId) : _treasury;\\n }\\n\\n /**\\n * @notice Returns the treasury of the product `product`\\n * @dev Defaults to the `owner` when `treasury` is unset\\n * @param product Product to return for\\n * @return Treasury of the product\\n */\\n function treasury(IProduct product) external view returns (address) {\\n return treasury(coordinatorFor[product]);\\n }\\n\\n /// @dev Only allow owner of `coordinatorId` to call\\n modifier onlyOwner(uint256 coordinatorId) {\\n if (msg.sender != owner(coordinatorId)) revert ControllerNotOwnerError(coordinatorId);\\n\\n _;\\n }\\n\\n /// @dev Only allow the pauser to call\\n modifier onlyPauser {\\n if (msg.sender != pauser()) revert ControllerNotPauserError();\\n\\n _;\\n }\\n}\\n\",\"keccak256\":\"0x40cde49450e3c3e476490d5eddd34e5ad96956de89e7a18cfa900da5ab5696d4\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/ICollateral.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"./IController.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\n\\ninterface ICollateral {\\n event Deposit(address indexed user, IProduct indexed product, UFixed18 amount);\\n event Withdrawal(address indexed user, IProduct indexed product, UFixed18 amount);\\n event AccountSettle(IProduct indexed product, address indexed account, Fixed18 amount, UFixed18 newShortfall);\\n event ProductSettle(IProduct indexed product, UFixed18 protocolFee, UFixed18 productFee);\\n event Liquidation(address indexed user, IProduct indexed product, address liquidator, UFixed18 fee);\\n event ShortfallResolution(IProduct indexed product, UFixed18 amount);\\n event FeeClaim(address indexed account, UFixed18 amount);\\n\\n error CollateralCantLiquidate(UFixed18 totalMaintenance, UFixed18 totalCollateral);\\n error CollateralInsufficientCollateralError();\\n error CollateralUnderLimitError();\\n error CollateralZeroAddressError();\\n\\n function token() external view returns (Token18);\\n function fees(address account) external view returns (UFixed18);\\n function initialize(IController controller_) external;\\n function depositTo(address account, IProduct product, UFixed18 amount) external;\\n function withdrawTo(address account, IProduct product, UFixed18 amount) external;\\n function liquidate(address account, IProduct product) external;\\n function settleAccount(address account, Fixed18 amount) external;\\n function settleProduct(UFixed18 amount) external;\\n function collateral(address account, IProduct product) external view returns (UFixed18);\\n function collateral(IProduct product) external view returns (UFixed18);\\n function shortfall(IProduct product) external view returns (UFixed18);\\n function liquidatable(address account, IProduct product) external view returns (bool);\\n function liquidatableNext(address account, IProduct product) external view returns (bool);\\n function resolveShortfall(IProduct product, UFixed18 amount) external;\\n function claimFee() external;\\n}\\n\",\"keccak256\":\"0xa5e7fdda92702f748e6eb8701e522450035a98a05e5fc1cf66d51c52e397d914\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IContractPayoffProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\n\\ninterface IContractPayoffProvider {\\n function payoff(Fixed18 price) external view returns (Fixed18 payoff);\\n}\\n\",\"keccak256\":\"0xd73df106d032e976fd959ee6713240e36f54277ce5f215eaec8d5a2c6720a86b\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IController.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\\\";\\nimport \\\"./ICollateral.sol\\\";\\nimport \\\"./IIncentivizer.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\n\\ninterface IController {\\n /// @dev Coordinator of a one or many products\\n struct Coordinator {\\n /// @dev Pending owner of the product, can accept ownership\\n address pendingOwner;\\n\\n /// @dev Owner of the product, allowed to update select parameters\\n address owner;\\n\\n /// @dev Treasury of the product, collects fees\\n address treasury;\\n }\\n\\n event CollateralUpdated(ICollateral newCollateral);\\n event IncentivizerUpdated(IIncentivizer newIncentivizer);\\n event ProductBeaconUpdated(IBeacon newProductBeacon);\\n event ProtocolFeeUpdated(UFixed18 newProtocolFee);\\n event MinFundingFeeUpdated(UFixed18 newMinFundingFee);\\n event LiquidationFeeUpdated(UFixed18 newLiquidationFee);\\n event IncentivizationFeeUpdated(UFixed18 newIncentivizationFee);\\n event MinCollateralUpdated(UFixed18 newMinCollateral);\\n event ProgramsPerProductUpdated(uint256 newProgramsPerProduct);\\n event PauserUpdated(address newPauser);\\n event PausedUpdated(bool newPaused);\\n event CoordinatorPendingOwnerUpdated(uint256 indexed coordinatorId, address newPendingOwner);\\n event CoordinatorOwnerUpdated(uint256 indexed coordinatorId, address newOwner);\\n event CoordinatorTreasuryUpdated(uint256 indexed coordinatorId, address newTreasury);\\n event CoordinatorCreated(uint256 indexed coordinatorId, address owner);\\n event ProductCreated(IProduct indexed product, IProduct.ProductInfo productInfo);\\n\\n error ControllerNoZeroCoordinatorError();\\n error ControllerNotPauserError();\\n error ControllerNotOwnerError(uint256 controllerId);\\n error ControllerNotPendingOwnerError(uint256 controllerId);\\n error ControllerInvalidProtocolFeeError();\\n error ControllerInvalidMinFundingFeeError();\\n error ControllerInvalidLiquidationFeeError();\\n error ControllerInvalidIncentivizationFeeError();\\n error ControllerNotContractAddressError();\\n\\n function collateral() external view returns (ICollateral);\\n function incentivizer() external view returns (IIncentivizer);\\n function productBeacon() external view returns (IBeacon);\\n function coordinators(uint256 collateralId) external view returns (Coordinator memory);\\n function coordinatorFor(IProduct product) external view returns (uint256);\\n function protocolFee() external view returns (UFixed18);\\n function minFundingFee() external view returns (UFixed18);\\n function liquidationFee() external view returns (UFixed18);\\n function incentivizationFee() external view returns (UFixed18);\\n function minCollateral() external view returns (UFixed18);\\n function programsPerProduct() external view returns (uint256);\\n function pauser() external view returns (address);\\n function paused() external view returns (bool);\\n function initialize(ICollateral collateral_, IIncentivizer incentivizer_, IBeacon productBeacon_) external;\\n function createCoordinator() external returns (uint256);\\n function updateCoordinatorPendingOwner(uint256 coordinatorId, address newPendingOwner) external;\\n function acceptCoordinatorOwner(uint256 coordinatorId) external;\\n function updateCoordinatorTreasury(uint256 coordinatorId, address newTreasury) external;\\n function createProduct(uint256 coordinatorId, IProduct.ProductInfo calldata productInfo) external returns (IProduct);\\n function updateCollateral(ICollateral newCollateral) external;\\n function updateIncentivizer(IIncentivizer newIncentivizer) external;\\n function updateProductBeacon(IBeacon newProductBeacon) external;\\n function updateProtocolFee(UFixed18 newProtocolFee) external;\\n function updateMinFundingFee(UFixed18 newMinFundingFee) external;\\n function updateLiquidationFee(UFixed18 newLiquidationFee) external;\\n function updateIncentivizationFee(UFixed18 newIncentivizationFee) external;\\n function updateMinCollateral(UFixed18 newMinCollateral) external;\\n function updateProgramsPerProduct(uint256 newProductsPerProduct) external;\\n function updatePauser(address newPauser) external;\\n function updatePaused(bool newPaused) external;\\n function isProduct(IProduct product) external view returns (bool);\\n function owner() external view returns (address);\\n function owner(uint256 coordinatorId) external view returns (address);\\n function owner(IProduct product) external view returns (address);\\n function treasury() external view returns (address);\\n function treasury(uint256 coordinatorId) external view returns (address);\\n function treasury(IProduct product) external view returns (address);\\n}\\n\",\"keccak256\":\"0xaabd3740f2265499eea7aad9bd94f9892f53241e5dccce9a50c0e43ed2a6a7cc\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IIncentivizer.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./types/ProgramInfo.sol\\\";\\nimport \\\"./IController.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\n\\ninterface IIncentivizer {\\n event ProgramCreated(IProduct indexed product, uint256 indexed programId, ProgramInfo programInfo, UFixed18 programFeeAmount);\\n event ProgramStarted(IProduct indexed product, uint256 indexed programId, uint256 version);\\n event ProgramComplete(IProduct indexed product, uint256 indexed programId, uint256 version);\\n event Claim(IProduct indexed product, address indexed account, uint256 indexed programId, UFixed18 amount);\\n event FeeClaim(Token18 indexed token, UFixed18 amount);\\n\\n error IncentivizerNotAllowedError(IProduct product);\\n error IncentivizerTooManyProgramsError();\\n error IncentivizerNotProgramOwnerError(IProduct product, uint256 programId);\\n error IncentivizerInvalidProgramError(IProduct product, uint256 programId);\\n error IncentivizerBatchClaimArgumentMismatchError();\\n\\n function programInfos(IProduct product, uint256 programId) external view returns (ProgramInfo memory);\\n function fees(Token18 token) external view returns (UFixed18);\\n function initialize(IController controller_) external;\\n function create(IProduct product, ProgramInfo calldata info) external returns (uint256);\\n function complete(IProduct product, uint256 programId) external;\\n function sync(IOracleProvider.OracleVersion memory currentOracleVersion) external;\\n function syncAccount(address account, IOracleProvider.OracleVersion memory currentOracleVersion) external;\\n function claim(IProduct product, uint256[] calldata programIds) external;\\n function claim(IProduct[] calldata products, uint256[][] calldata programIds) external;\\n function claimFee(Token18[] calldata tokens) external;\\n function active(IProduct product) external view returns (uint256);\\n function count(IProduct product) external view returns (uint256);\\n function unclaimed(IProduct product, address account, uint256 programId) external view returns (UFixed18);\\n function available(IProduct product, uint256 programId) external view returns (UFixed18);\\n function versionStarted(IProduct product, uint256 programId) external view returns (uint256);\\n function versionComplete(IProduct product, uint256 programId) external view returns (uint256);\\n function owner(IProduct product, uint256 programId) external view returns (address);\\n function treasury(IProduct product, uint256 programId) external view returns (address);\\n}\\n\",\"keccak256\":\"0x2f95de90dbb3ad35dbfef304f765a622bffff9229868d2898eca8d49c78e8c2c\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IParamProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\\\";\\n\\ninterface IParamProvider {\\n event MaintenanceUpdated(UFixed18 newMaintenance);\\n event FundingFeeUpdated(UFixed18 newFundingFee);\\n event MakerFeeUpdated(UFixed18 newMakerFee);\\n event TakerFeeUpdated(UFixed18 newTakerFee);\\n event MakerLimitUpdated(UFixed18 newMakerLimit);\\n event JumpRateUtilizationCurveUpdated(\\n Fixed18 minRate,\\n Fixed18 maxRate,\\n Fixed18 targetRate,\\n UFixed18 targetUtilization\\n );\\n\\n error ParamProviderInvalidMakerFee();\\n error ParamProviderInvalidTakerFee();\\n error ParamProviderInvalidFundingFee();\\n \\n function maintenance() external view returns (UFixed18);\\n function updateMaintenance(UFixed18 newMaintenance) external;\\n function fundingFee() external view returns (UFixed18);\\n function updateFundingFee(UFixed18 newFundingFee) external;\\n function makerFee() external view returns (UFixed18);\\n function updateMakerFee(UFixed18 newMakerFee) external;\\n function takerFee() external view returns (UFixed18);\\n function updateTakerFee(UFixed18 newTakerFee) external;\\n function makerLimit() external view returns (UFixed18);\\n function updateMakerLimit(UFixed18 newMakerLimit) external;\\n function utilizationCurve() external view returns (JumpRateUtilizationCurve memory);\\n function updateUtilizationCurve(JumpRateUtilizationCurve memory newUtilizationCurve) external;\\n}\\n\",\"keccak256\":\"0x2e2d40d0cf55f167118867e41f740b9b40614d05da50fc9bc33a8cede3eaf03e\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IPayoffProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\n\\ninterface IPayoffProvider {\\n error PayoffProviderInvalidOracle();\\n error PayoffProviderInvalidPayoffDefinitionError();\\n\\n function oracle() external view returns (IOracleProvider);\\n function payoffDefinition() external view returns (PayoffDefinition memory);\\n function currentVersion() external view returns (IOracleProvider.OracleVersion memory);\\n function atVersion(uint256 oracleVersion) external view returns (IOracleProvider.OracleVersion memory);\\n}\\n\",\"keccak256\":\"0xb83d80d624aa9431763f80ecb4bf0214803e25334a7419d954f929e5d0ee7467\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IProduct.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\\\";\\nimport \\\"./IPayoffProvider.sol\\\";\\nimport \\\"./IParamProvider.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\nimport \\\"./types/Position.sol\\\";\\nimport \\\"./types/PrePosition.sol\\\";\\nimport \\\"./types/Accumulator.sol\\\";\\n\\ninterface IProduct is IPayoffProvider, IParamProvider {\\n /// @dev Product Creation parameters\\n struct ProductInfo {\\n /// @dev name of the product\\n string name;\\n\\n /// @dev symbol of the product\\n string symbol;\\n\\n /// @dev product payoff definition\\n PayoffDefinition payoffDefinition;\\n\\n /// @dev oracle address\\n IOracleProvider oracle;\\n\\n /// @dev product maintenance ratio\\n UFixed18 maintenance;\\n\\n /// @dev product funding fee\\n UFixed18 fundingFee;\\n\\n /// @dev product maker fee\\n UFixed18 makerFee;\\n\\n /// @dev product taker fee\\n UFixed18 takerFee;\\n\\n /// @dev product maker limit\\n UFixed18 makerLimit;\\n\\n /// @dev utulization curve definition\\n JumpRateUtilizationCurve utilizationCurve;\\n }\\n\\n event Settle(uint256 preVersion, uint256 toVersion);\\n event AccountSettle(address indexed account, uint256 preVersion, uint256 toVersion);\\n event MakeOpened(address indexed account, uint256 version, UFixed18 amount);\\n event TakeOpened(address indexed account, uint256 version, UFixed18 amount);\\n event MakeClosed(address indexed account, uint256 version, UFixed18 amount);\\n event TakeClosed(address indexed account, uint256 version, UFixed18 amount);\\n event ClosedUpdated(bool indexed newClosed, uint256 version);\\n\\n error ProductInsufficientLiquidityError(UFixed18 socializationFactor);\\n error ProductDoubleSidedError();\\n error ProductOverClosedError();\\n error ProductInsufficientCollateralError();\\n error ProductInLiquidationError();\\n error ProductMakerOverLimitError();\\n error ProductOracleBootstrappingError();\\n error ProductNotOwnerError();\\n error ProductInvalidOracle();\\n error ProductClosedError();\\n\\n function name() external view returns (string memory);\\n function symbol() external view returns (string memory);\\n function initialize(ProductInfo calldata productInfo_) external;\\n function settle() external;\\n function settleAccount(address account) external;\\n function openTake(UFixed18 amount) external;\\n function closeTake(UFixed18 amount) external;\\n function openMake(UFixed18 amount) external;\\n function closeMake(UFixed18 amount) external;\\n function closeAll(address account) external;\\n function maintenance(address account) external view returns (UFixed18);\\n function maintenanceNext(address account) external view returns (UFixed18);\\n function isClosed(address account) external view returns (bool);\\n function isLiquidating(address account) external view returns (bool);\\n function position(address account) external view returns (Position memory);\\n function pre(address account) external view returns (PrePosition memory);\\n function latestVersion() external view returns (uint256);\\n function positionAtVersion(uint256 oracleVersion) external view returns (Position memory);\\n function pre() external view returns (PrePosition memory);\\n function valueAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\\n function shareAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\\n function latestVersion(address account) external view returns (uint256);\\n function rate(Position memory position) external view returns (Fixed18);\\n function closed() external view returns (bool);\\n function updateClosed(bool newClosed) external;\\n}\\n\",\"keccak256\":\"0xe1e80b818eadf4cdb070362e40c7cf3863b50c4f944816af27848e319f587241\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/Accumulator.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"./PackedAccumulator.sol\\\";\\n\\n/// @dev Accumulator type\\nstruct Accumulator {\\n /// @dev maker accumulator per share\\n Fixed18 maker;\\n /// @dev taker accumulator per share\\n Fixed18 taker;\\n}\\nusing AccumulatorLib for Accumulator global;\\n\\n/**\\n * @title AccountAccumulatorLib\\n * @notice Library that surfaces math operations for the Accumulator type.\\n * @dev Accumulators track the cumulative change in position value over time for the maker and taker positions\\n * respectively. Account-level accumulators can then use two of these values `a` and `a'` to compute the\\n * change in position value since last sync. This change in value is then used to compute P&L and fees.\\n */\\nlibrary AccumulatorLib {\\n /**\\n * @notice Creates a packed accumulator from an accumulator\\n * @param self an accumulator\\n * @return New packed accumulator\\n */\\n function pack(Accumulator memory self) internal pure returns (PackedAccumulator memory) {\\n return PackedAccumulator({maker: self.maker.pack(), taker: self.taker.pack()});\\n }\\n\\n /**\\n * @notice Adds two accumulators together\\n * @param a The first accumulator to sum\\n * @param b The second accumulator to sum\\n * @return The resulting summed accumulator\\n */\\n function add(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\\n }\\n\\n /**\\n * @notice Subtracts accumulator `b` from `a`\\n * @param a The accumulator to subtract from\\n * @param b The accumulator to subtract\\n * @return The resulting subtracted accumulator\\n */\\n function sub(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\\n }\\n\\n /**\\n * @notice Multiplies two accumulators together\\n * @param a The first accumulator to multiply\\n * @param b The second accumulator to multiply\\n * @return The resulting multiplied accumulator\\n */\\n function mul(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.mul(b.maker), taker: a.taker.mul(b.taker)});\\n }\\n\\n /**\\n * @notice Sums the maker and taker together from a single accumulator\\n * @param self The struct to operate on\\n * @return The sum of its maker and taker\\n */\\n function sum(Accumulator memory self) internal pure returns (Fixed18) {\\n return self.maker.add(self.taker);\\n }\\n}\\n\",\"keccak256\":\"0x7ccd0a72aa593cefb9f4337cf312799f357b82fcb3f0379de0dc503d1cb7e387\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PackedAccumulator.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/PackedFixed18.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\n\\n/// @dev PackedAccumulator type\\nstruct PackedAccumulator {\\n /// @dev maker accumulator per share\\n PackedFixed18 maker;\\n /// @dev taker accumulator per share\\n PackedFixed18 taker;\\n}\\nusing PackedAccumulatorLib for PackedAccumulator global;\\n\\n/**\\n * @title PackedAccumulatorLib\\n * @dev A packed version of the Accumulator which takes up a single storage slot using `PackedFixed18` values.\\n * @notice Library for the packed Accumulator type.\\n */\\nlibrary PackedAccumulatorLib {\\n /**\\n * @notice Creates an accumulator from a packed accumulator\\n * @param self packed accumulator\\n * @return New accumulator\\n */\\n function unpack(PackedAccumulator memory self) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: self.maker.unpack(), taker: self.taker.unpack()});\\n }\\n}\\n\",\"keccak256\":\"0xd83f2822d4f6c818087a232b54007730992c34ff77377fc307a282f886e7cf65\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PackedPosition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/PackedUFixed18.sol\\\";\\nimport \\\"./Position.sol\\\";\\n\\n/// @dev PackedPosition type\\nstruct PackedPosition {\\n /// @dev Quantity of the maker position\\n PackedUFixed18 maker;\\n /// @dev Quantity of the taker position\\n PackedUFixed18 taker;\\n}\\nusing PackedPositionLib for PackedPosition global;\\n\\n/**\\n * @title PackedPositionLib\\n * @dev A packed version of the Position which takes up a single storage slot using `PackedFixed18` values.\\n * @notice Library for the packed Position type.\\n */\\nlibrary PackedPositionLib {\\n /**\\n * @notice Creates an position from a packed position\\n * @param self packed position\\n * @return New position\\n */\\n function unpack(PackedPosition memory self) internal pure returns (Position memory) {\\n return Position({maker: self.maker.unpack(), taker: self.taker.unpack()});\\n }\\n}\\n\",\"keccak256\":\"0x04968e6794f6244cb3415cea111d640273a81faea957872988d0cb580f45df1e\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PayoffDefinition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"@openzeppelin/contracts/utils/Address.sol\\\";\\nimport \\\"../../interfaces/IContractPayoffProvider.sol\\\";\\n\\n/// @dev PayoffDefinition tyoe\\nstruct PayoffDefinition {\\n PayoffDefinitionLib.PayoffType payoffType;\\n PayoffDefinitionLib.PayoffDirection payoffDirection;\\n bytes30 data;\\n}\\nusing PayoffDefinitionLib for PayoffDefinition global;\\ntype PayoffDefinitionStorage is bytes32;\\nusing PayoffDefinitionStorageLib for PayoffDefinitionStorage global;\\n\\n/**\\n * @title PayoffDefinitionLib\\n * @dev Library that surfaces logic for PayoffDefinition type functionality\\n * @notice Library for the PayoffDefinition type. Performs validity and price transformation\\n based on the payoff definition type.\\n */\\nlibrary PayoffDefinitionLib {\\n using Address for address;\\n\\n error PayoffDefinitionUnsupportedTransform(PayoffType payoffType, PayoffDirection payoffDirection);\\n error PayoffDefinitionNotContract(PayoffType payoffType, bytes30 data);\\n\\n /// @dev Payoff function type enum\\n enum PayoffType { PASSTHROUGH, CONTRACT }\\n enum PayoffDirection { LONG, SHORT }\\n\\n /**\\n * @notice Checks validity of the payoff definition\\n * @param self a payoff definition\\n * @return Whether the payoff definition is valid for it's given type\\n */\\n function valid(PayoffDefinition memory self) internal view returns (bool) {\\n if (self.payoffType == PayoffType.CONTRACT) return address(_providerContract(self)).isContract();\\n\\n // All other payoff types should have no data\\n return uint(bytes32(self.data)) == 0;\\n }\\n\\n /**\\n * @notice Transforms a price based on the payoff definition\\n * @param self a payoff definition\\n * @param price raw oracle price\\n * @return Price transformed by the payoff definition function\\n */\\n function transform(\\n PayoffDefinition memory self,\\n Fixed18 price\\n ) internal view returns (Fixed18) {\\n PayoffType payoffType = self.payoffType;\\n PayoffDirection payoffDirection = self.payoffDirection;\\n Fixed18 transformedPrice;\\n\\n // First get the price depending on the type\\n if (payoffType == PayoffType.PASSTHROUGH) transformedPrice = price;\\n else if (payoffType == PayoffType.CONTRACT) transformedPrice = _payoffFromContract(self, price);\\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\\n\\n // Then transform it depending on the direction flag\\n if (self.payoffDirection == PayoffDirection.LONG) return transformedPrice;\\n else if (self.payoffDirection == PayoffDirection.SHORT) return transformedPrice.mul(Fixed18Lib.NEG_ONE);\\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\\n }\\n\\n /**\\n * @notice Parses the data field into an address\\n * @dev Reverts if payoffType is not CONTRACT\\n * @param self a payoff definition\\n * @return IContractPayoffProvider address\\n */\\n function _providerContract(\\n PayoffDefinition memory self\\n ) private pure returns (IContractPayoffProvider) {\\n if (self.payoffType != PayoffType.CONTRACT) revert PayoffDefinitionNotContract(self.payoffType, self.data);\\n // Shift to pull the last 20 bytes, then cast to an address\\n return IContractPayoffProvider(address(bytes20(self.data << 80)));\\n }\\n\\n /**\\n * @notice Performs a price transformation by calling the underlying payoff contract\\n * @param self a payoff definition\\n * @param price raw oracle price\\n * @return Price transformed by the payoff definition function on the contract\\n */\\n function _payoffFromContract(\\n PayoffDefinition memory self,\\n Fixed18 price\\n ) private view returns (Fixed18) {\\n bytes memory ret = address(_providerContract(self)).functionStaticCall(\\n abi.encodeCall(IContractPayoffProvider.payoff, price)\\n );\\n return Fixed18.wrap(abi.decode(ret, (int256)));\\n }\\n}\\n\\n/**\\n * @title PayoffDefinitionStorageLib\\n * @notice Library that surfaces storage read and writes for the PayoffDefinition type\\n */\\nlibrary PayoffDefinitionStorageLib {\\n function read(PayoffDefinitionStorage self) internal view returns (PayoffDefinition memory) {\\n return _storagePointer(self);\\n }\\n\\n function store(PayoffDefinitionStorage self, PayoffDefinition memory value) internal {\\n PayoffDefinition storage storagePointer = _storagePointer(self);\\n\\n storagePointer.payoffType = value.payoffType;\\n storagePointer.payoffDirection = value.payoffDirection;\\n storagePointer.data = value.data;\\n }\\n\\n function _storagePointer(\\n PayoffDefinitionStorage self\\n ) private pure returns (PayoffDefinition storage pointer) {\\n assembly { pointer.slot := self }\\n }\\n}\\n\",\"keccak256\":\"0x4d3897f408f77381c5ae9990391465c8fd511ddf6ff3b39f6cb69d8c2bd554df\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/Position.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\nimport \\\"./PrePosition.sol\\\";\\nimport \\\"./PackedPosition.sol\\\";\\n\\n/// @dev Position type\\nstruct Position {\\n /// @dev Quantity of the maker position\\n UFixed18 maker;\\n /// @dev Quantity of the taker position\\n UFixed18 taker;\\n}\\nusing PositionLib for Position global;\\n\\n/**\\n * @title PositionLib\\n * @notice Library that surfaces math and settlement computations for the Position type.\\n * @dev Positions track the current quantity of the account's maker and taker positions respectively\\n * denominated as a unit of the product's payoff function.\\n */\\nlibrary PositionLib {\\n /**\\n * @notice Creates a packed position from an position\\n * @param self A position\\n * @return New packed position\\n */\\n function pack(Position memory self) internal pure returns (PackedPosition memory) {\\n return PackedPosition({maker: self.maker.pack(), taker: self.taker.pack()});\\n }\\n\\n /**\\n * @notice Returns whether the position is fully empty\\n * @param self A position\\n * @return Whether the position is empty\\n */\\n function isEmpty(Position memory self) internal pure returns (bool) {\\n return self.maker.isZero() && self.taker.isZero();\\n }\\n\\n /**\\n * @notice Adds position `a` and `b` together, returning the result\\n * @param a The first position to sum\\n * @param b The second position to sum\\n * @return Resulting summed position\\n */\\n function add(Position memory a, Position memory b) internal pure returns (Position memory) {\\n return Position({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\\n }\\n\\n /**\\n * @notice Subtracts position `b` from `a`, returning the result\\n * @param a The position to subtract from\\n * @param b The position to subtract\\n * @return Resulting subtracted position\\n */\\n function sub(Position memory a, Position memory b) internal pure returns (Position memory) {\\n return Position({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\\n }\\n\\n /**\\n * @notice Multiplies position `self` by accumulator `accumulator` and returns the resulting accumulator\\n * @param self The Position to operate on\\n * @param accumulator The accumulator to multiply by\\n * @return Resulting multiplied accumulator\\n */\\n function mul(Position memory self, Accumulator memory accumulator) internal pure returns (Accumulator memory) {\\n return Accumulator({\\n maker: Fixed18Lib.from(self.maker).mul(accumulator.maker),\\n taker: Fixed18Lib.from(self.taker).mul(accumulator.taker)\\n });\\n }\\n\\n /**\\n * @notice Scales position `self` by fixed-decimal `scale` and returns the resulting position\\n * @param self The Position to operate on\\n * @param scale The Fixed-decimal to scale by\\n * @return Resulting scaled position\\n */\\n function mul(Position memory self, UFixed18 scale) internal pure returns (Position memory) {\\n return Position({maker: self.maker.mul(scale), taker: self.taker.mul(scale)});\\n }\\n\\n /**\\n * @notice Divides position `self` by `b` and returns the resulting accumulator\\n * @param self The Position to operate on\\n * @param b The number to divide by\\n * @return Resulting divided accumulator\\n */\\n function div(Position memory self, uint256 b) internal pure returns (Accumulator memory) {\\n return Accumulator({\\n maker: Fixed18Lib.from(self.maker).div(Fixed18Lib.from(UFixed18Lib.from(b))),\\n taker: Fixed18Lib.from(self.taker).div(Fixed18Lib.from(UFixed18Lib.from(b)))\\n });\\n }\\n\\n /**\\n * @notice Returns the maximum of `self`'s maker and taker values\\n * @param self The struct to operate on\\n * @return Resulting maximum value\\n */\\n function max(Position memory self) internal pure returns (UFixed18) {\\n return UFixed18Lib.max(self.maker, self.taker);\\n }\\n\\n /**\\n * @notice Sums the maker and taker together from a single position\\n * @param self The struct to operate on\\n * @return The sum of its maker and taker\\n */\\n function sum(Position memory self) internal pure returns (UFixed18) {\\n return self.maker.add(self.taker);\\n }\\n\\n /**\\n * @notice Computes the next position after the pending-settlement position delta is included\\n * @param self The current Position\\n * @param pre The pending-settlement position delta\\n * @return Next Position\\n */\\n function next(Position memory self, PrePosition memory pre) internal pure returns (Position memory) {\\n return sub(add(self, pre.openPosition), pre.closePosition);\\n }\\n\\n /**\\n * @notice Returns the settled position at oracle version `toOracleVersion`\\n * @dev Checks if a new position is ready to be settled based on the provided `toOracleVersion`\\n * and `pre` and returns accordingly\\n * @param self The current Position\\n * @param pre The pending-settlement position delta\\n * @param toOracleVersion The oracle version to settle to\\n * @return Settled position at oracle version\\n * @return Fee accrued from opening or closing the position\\n * @return Whether a new position was settled\\n */\\n function settled(\\n Position memory self,\\n PrePosition memory pre,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal view returns (Position memory, UFixed18, bool) {\\n return pre.canSettle(toOracleVersion) ? (next(self, pre), pre.computeFee(toOracleVersion), true) : (self, UFixed18Lib.ZERO, false);\\n }\\n\\n /**\\n * @notice Returns the socialization factor for the current position\\n * @dev Socialization account for the case where `taker` > `maker` temporarily due to a liquidation\\n * on the maker side. This dampens the taker's exposure pro-rata to ensure that the maker side\\n * is never exposed over 1 x short.\\n * @param self The Position to operate on\\n * @return Socialization factor\\n */\\n function socializationFactor(Position memory self) internal pure returns (UFixed18) {\\n return self.taker.isZero() ? UFixed18Lib.ONE : UFixed18Lib.min(UFixed18Lib.ONE, self.maker.div(self.taker));\\n }\\n}\\n\",\"keccak256\":\"0x027fe392c4f56bf012ba2ca462fcf23e69f2c3b9d283c14089771813437af991\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PrePosition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./Position.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\n\\n/// @dev PrePosition type\\nstruct PrePosition {\\n /// @dev Oracle version at which the new position delta was recorded\\n uint256 oracleVersion;\\n\\n /// @dev Size of position to open at oracle version\\n Position openPosition;\\n\\n /// @dev Size of position to close at oracle version\\n Position closePosition;\\n}\\nusing PrePositionLib for PrePosition global;\\n\\n/**\\n * @title PrePositionLib\\n * @notice Library that manages a pre-settlement position delta.\\n * @dev PrePositions track the currently awaiting-settlement deltas to a settled Position. These are\\n * Primarily necessary to introduce lag into the settlement system such that oracle lag cannot be\\n * gamed to a user's advantage. When a user opens or closes a new position, it sits as a PrePosition\\n * for one oracle version until it's settle into the Position, making it then effective. PrePositions\\n * are automatically settled at the correct oracle version even if a flywheel call doesn't happen until\\n * several version into the future by using the historical version lookups in the corresponding \\\"Versioned\\\"\\n * global state types.\\n */\\nlibrary PrePositionLib {\\n /**\\n * @notice Returns whether there is no pending-settlement position delta\\n * @dev Can be \\\"empty\\\" even with a non-zero oracleVersion if a position is opened and\\n * closed in the same version netting out to a zero position delta\\n * @param self The struct to operate on\\n * @return Whether the pending-settlement position delta is empty\\n */\\n function isEmpty(PrePosition memory self) internal pure returns (bool) {\\n return self.openPosition.isEmpty() && self.closePosition.isEmpty();\\n }\\n\\n /**\\n * @notice Increments the maker side of the open position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The position amount to open\\n */\\n function openMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.openPosition.maker = self.openPosition.maker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netMake(self);\\n }\\n\\n /**\\n * @notice Increments the maker side of the close position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The maker position amount to close\\n */\\n function closeMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.closePosition.maker = self.closePosition.maker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netMake(self);\\n }\\n\\n /**\\n * @notice Increments the taker side of the open position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The taker position amount to open\\n */\\n function openTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.openPosition.taker = self.openPosition.taker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netTake(self);\\n }\\n\\n /**\\n * @notice Increments the taker side of the close position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The taker position amount to close\\n */\\n function closeTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.closePosition.taker = self.closePosition.taker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netTake(self);\\n }\\n\\n /**\\n * @notice Nets out the open and close on the maker side of the position delta\\n * @param self The struct to operate on\\n */\\n function _netMake(PrePosition storage self) private {\\n if (self.openPosition.maker.gt(self.closePosition.maker)) {\\n self.openPosition.maker = self.openPosition.maker.sub(self.closePosition.maker);\\n self.closePosition.maker = UFixed18Lib.ZERO;\\n } else {\\n self.closePosition.maker = self.closePosition.maker.sub(self.openPosition.maker);\\n self.openPosition.maker = UFixed18Lib.ZERO;\\n }\\n }\\n\\n /**\\n * @notice Nets out the open and close on the taker side of the position delta\\n * @param self The struct to operate on\\n */\\n function _netTake(PrePosition storage self) private {\\n if (self.openPosition.taker.gt(self.closePosition.taker)) {\\n self.openPosition.taker = self.openPosition.taker.sub(self.closePosition.taker);\\n self.closePosition.taker = UFixed18Lib.ZERO;\\n } else {\\n self.closePosition.taker = self.closePosition.taker.sub(self.openPosition.taker);\\n self.openPosition.taker = UFixed18Lib.ZERO;\\n }\\n }\\n\\n /**\\n * @notice Returns whether the the pending position delta can be settled at version `toOracleVersion`\\n * @dev Pending-settlement positions deltas can be settled (1) oracle version after they are recorded\\n * @param self The struct to operate on\\n * @param toOracleVersion The potential oracle version to settle\\n * @return Whether the position delta can be settled\\n */\\n function canSettle(\\n PrePosition memory self,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal pure returns (bool) {\\n return !isEmpty(self) && toOracleVersion.version > self.oracleVersion;\\n }\\n\\n /**\\n * @notice Computes the fee incurred for opening or closing the pending-settlement position\\n * @dev Must be called from a valid product to get the proper fee amounts\\n * @param self The struct to operate on\\n * @param toOracleVersion The oracle version at which settlement takes place\\n * @return positionFee The maker / taker fee incurred\\n */\\n function computeFee(\\n PrePosition memory self,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal view returns (UFixed18) {\\n Position memory positionDelta = self.openPosition.add(self.closePosition);\\n\\n (UFixed18 makerNotional, UFixed18 takerNotional) = (\\n Fixed18Lib.from(positionDelta.maker).mul(toOracleVersion.price).abs(),\\n Fixed18Lib.from(positionDelta.taker).mul(toOracleVersion.price).abs()\\n );\\n\\n IProduct product = IProduct(address(this));\\n return makerNotional.mul(product.makerFee()).add(takerNotional.mul(product.takerFee()));\\n }\\n\\n /**\\n * @notice Computes the next oracle version to settle\\n * @dev - If there is no pending-settlement position delta, returns the current oracle version\\n * - Otherwise returns the oracle version at which the pending-settlement position delta can be first settled\\n *\\n * Corresponds to point (b) in the Position settlement flow\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @return Next oracle version to settle\\n */\\n function settleVersion(PrePosition storage self, uint256 currentVersion) internal view returns (uint256) {\\n uint256 _oracleVersion = self.oracleVersion;\\n return _oracleVersion == 0 ? currentVersion : _oracleVersion + 1;\\n }\\n}\\n\",\"keccak256\":\"0xa6f83f7b5f8139ec874235c406debd086a152977493c08b7f280df6f1737fb96\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/ProgramInfo.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\nimport \\\"./Position.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\n\\n/// @dev ProgramInfo type\\nstruct ProgramInfo {\\n /// @dev Coordinator for this program\\n uint256 coordinatorId;\\n\\n /// @dev Amount of total maker and taker rewards\\n Position amount;\\n\\n /// @dev start timestamp of the program\\n uint256 start;\\n\\n /// @dev duration of the program (in seconds)\\n uint256 duration;\\n\\n /**\\n * @dev Reward ERC20 token contract\\n * @notice Perennial does not support non-standard ERC20s as reward tokens for incentive programs, including,\\n but not limited to: fee on transfer and rebase tokens. Using such a non-standard token will likely\\n result in loss of funds.\\n */\\n Token18 token;\\n}\\nusing ProgramInfoLib for ProgramInfo global;\\n\\n/**\\n * @title ProgramInfoLib\\n * @notice Library that snapshots the static information for a single program.\\n * @dev This information does not change during the operation of a program.\\n */\\nlibrary ProgramInfoLib {\\n uint256 private constant MIN_DURATION = 1 days;\\n uint256 private constant MAX_DURATION = 2 * 365 days;\\n\\n error ProgramInvalidStartError();\\n error ProgramInvalidDurationError();\\n\\n /**\\n * @notice Validates and creates a new Program\\n * @dev Reverts for invalid programInfos\\n * @param programInfo Un-sanitized static program information\\n */\\n function validate(ProgramInfo memory programInfo) internal view {\\n if (isStarted(programInfo, block.timestamp)) revert ProgramInvalidStartError();\\n if (programInfo.duration < MIN_DURATION || programInfo.duration > MAX_DURATION) revert ProgramInvalidDurationError();\\n }\\n\\n /**\\n * @notice Computes a new program info with the fee taken out of the amount\\n * @param programInfo Original program info\\n * @param incentivizationFee The incentivization fee\\n * @return New program info\\n * @return Fee amount\\n */\\n function deductFee(ProgramInfo memory programInfo, UFixed18 incentivizationFee)\\n internal pure returns (ProgramInfo memory, UFixed18) {\\n Position memory newProgramAmount = programInfo.amount.mul(UFixed18Lib.ONE.sub(incentivizationFee));\\n UFixed18 programFeeAmount = programInfo.amount.sub(newProgramAmount).sum();\\n programInfo.amount = newProgramAmount;\\n return (programInfo, programFeeAmount);\\n }\\n\\n /**\\n * @notice Returns the maker and taker amounts per position share\\n * @param self The ProgramInfo to operate on\\n * @return programFee Amounts per share\\n */\\n function amountPerShare(ProgramInfo memory self) internal pure returns (Accumulator memory) {\\n return self.amount.div(self.duration);\\n }\\n\\n /**\\n * @notice Returns whether the program has started by timestamp `timestamp`\\n * @param self The ProgramInfo to operate on\\n * @param timestamp Timestamp to check for\\n * @return Whether the program has started\\n */\\n function isStarted(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\\n return timestamp >= self.start;\\n }\\n\\n /**\\n * @notice Returns whether the program is completed by timestamp `timestamp`\\n * @param self The ProgramInfo to operate on\\n * @param timestamp Timestamp to check for\\n * @return Whether the program is completed\\n */\\n function isComplete(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\\n return timestamp >= (self.start + self.duration);\\n }\\n}\\n\",\"keccak256\":\"0x280fcaf931b49abaec46b95ccbabaaf856a4b8e8d036413c9c3b3af25585d161\",\"license\":\"Apache-2.0\"}},\"version\":1}", - "bytecode": "0x608060405234801561001057600080fd5b50612de7806100206000396000f3fe60806040523480156200001157600080fd5b5060043610620002e45760003560e01c80637a7da0041162000199578063a36a363011620000e9578063d809aa611162000097578063e30c3978116200007a578063e30c39781462000638578063e975c0c31462000642578063f8dfc2cc146200064c57600080fd5b8063d809aa611462000617578063d8dfeb45146200062e57600080fd5b8063b0e21e8a11620000cc578063b0e21e8a14620005ec578063ba2de9bc14620005f6578063c0c53b8b146200060057600080fd5b8063a36a363014620005cb578063af2757b714620005d557600080fd5b80638da5cb5b11620001475780639fd0506d116200012a5780639fd0506d1462000593578063a123c33e146200059d578063a1eef78e14620005b457600080fd5b80638da5cb5b14620005725780638fbf1803146200057c57600080fd5b80637d254e66116200017c5780637d254e66146200050a5780637d49c1b7146200052d5780637fd29192146200053757600080fd5b80637a7da00414620004dc5780637c01369014620004f357600080fd5b80634c5430a0116200025557806365e821e5116200020357806366c0623911620001e657806366c0623914620004b15780636fc6407c14620004bb57806375907f2814620004c557600080fd5b806365e821e51462000483578063666e1b39146200049a57600080fd5b80635c975abb11620002385780635c975abb14620004075780635f1cc005146200042257806361d027b3146200047957600080fd5b80634c5430a014620003d9578063554bab3c14620003f057600080fd5b80632d809cb611620002b35780633ceda01111620002965780633ceda01114620003925780634256dd7814620003ab578063478739ca14620003c257600080fd5b80632d809cb61462000371578063391d0c9c146200038857600080fd5b806308cdc2a814620002e95780630d57036114620003025780632933d89114620003435780632b800e3b146200035a575b600080fd5b62000300620002fa36600462001df6565b62000663565b005b620003196200031336600462001e1a565b62000734565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b620003006200035436600462001e6c565b62000926565b620003196200036b36600462001e6c565b620009fe565b620003196200038236600462001eac565b62000a42565b6200031962000a79565b6200039c62000aa9565b6040519081526020016200033a565b62000300620003bc36600462001e6c565b62000ad4565b62000300620003d336600462001e6c565b62000bf1565b62000319620003ea36600462001e6c565b62000d0e565b620003006200040136600462001eac565b62000d73565b6200041162000e5a565b60405190151581526020016200033a565b620004396200043336600462001e6c565b62000e85565b60408051825173ffffffffffffffffffffffffffffffffffffffff908116825260208085015182169083015292820151909216908201526060016200033a565b6200031962000f13565b620003006200049436600462001eac565b62000f21565b62000319620004ab36600462001eac565b62001057565b6200039c62001088565b6200031962001094565b62000300620004d636600462001e6c565b620010bf565b62000300620004ed36600462001eac565b620011dc565b620003006200050436600462001eac565b62001312565b6200039c6200051b36600462001eac565b60016020526000908152604090205481565b6200039c62001448565b620004116200054836600462001eac565b73ffffffffffffffffffffffffffffffffffffffff16600090815260016020526040902054151590565b6200031962001473565b620003006200058d36600462001e6c565b62001481565b6200031962001587565b62000319620005ae36600462001e6c565b620015e9565b62000300620005c536600462001e6c565b62001630565b6200039c62001701565b62000300620005e636600462001ecc565b6200172c565b6200039c6200183c565b6200039c62001867565b620003006200061136600462001ef4565b62001892565b620003006200062836600462001e6c565b620019d1565b6200031962001aee565b6200031962001b19565b6200039c62001b27565b620003006200065d36600462001ecc565b62001b52565b6200066d62001587565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614620006d2576040517f84f8637600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620006fc7ff201e8b56b5ea8f1176ce6f2699cbe9659ba7491e9460c9d358ddf61400b5de3829055565b60405181151581527f31311016d7204faff81880133e3db244ae8a8b9ce15e83e2432258226d15f9429060200160405180910390a150565b6000826200074281620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614620007af576040517ff0a882b5000000000000000000000000000000000000000000000000000000008152600481018290526024015b60405180910390fd5b83600003620007ea576040517f7244bc7800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000620007f662000a79565b8460405160240162000809919062002150565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167ff0b4095900000000000000000000000000000000000000000000000000000000179052516200088b9062001de8565b620008989291906200225b565b604051809103906000f080158015620008b5573d6000803e3d6000fd5b5073ffffffffffffffffffffffffffffffffffffffff8116600081815260016020526040908190208890555191925082917f09d535073bc2dc21c8fd680a2141218a65fb0acc46e88b9e5d96f114b734b004906200091590889062002150565b60405180910390a295945050505050565b60006200093381620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146200099c576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b620009c67f2859911faffd405cbcc22bdad2f67b54a86355c092452044dbab4f656aec3dc9839055565b6040518281527fd19fe8ad9152af12b174a60210fb798db0767d63973ebb97298dc44d67a5c82d906020015b60405180910390a15050565b600080828154811062000a155762000a15620022ef565b600091825260209091206003909102015473ffffffffffffffffffffffffffffffffffffffff1692915050565b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604081205462000a739062000d0e565b92915050565b600062000aa47f81565bc82d6e7196d38320713fd94f897c0e1a4c83974a2fbbbf9fbb55a6d8a75490565b905090565b600062000aa47f1f7147efa84c5ef8ccb713891d25247c732a9d5765ebc3bb6cb30d1f17d277f05490565b600062000ae181620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462000b4a576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b62000b5e82670de0b6b3a764000062001c65565b1562000b96576040517f3c5df10400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000bc07f7b1a264a02657d43e78b10f2a591a99a0fdf8a165fb72bbf762d965e9973f64e839055565b6040518281527fd10d75876659a287a59a6ccfa2e3fff42f84d94b542837acd30bc184d562de4090602001620009f2565b600062000bfe81620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462000c67576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b62000c7b82670de0b6b3a764000062001c65565b1562000cb3576040517f0c6b0ec800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000cdd7f6f35922f1b8609c81847a86ce8bb2528f73d722df88772b050ac89d3bc48707d839055565b6040518281527fdf7e6bc55eeb2668bd338e44a5abb721b1f98ad51f7a00baaa1b62f9383862d790602001620009f2565b6000806000838154811062000d275762000d27620022ef565b600091825260209091206002600390920201015473ffffffffffffffffffffffffffffffffffffffff169050801562000d61578062000d6c565b62000d6c83620015e9565b9392505050565b600062000d8081620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462000de9576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b62000e137fc641ae699093d5be5b0b167620fe782b911b5015c8c9f6e14207530ddda0d020839055565b60405173ffffffffffffffffffffffffffffffffffffffff831681527fa4336c0cb1e245b95ad204faed7e940d6dc999684fd8b5e1ff597a0c4efca8ab90602001620009f2565b600062000aa47ff201e8b56b5ea8f1176ce6f2699cbe9659ba7491e9460c9d358ddf61400b5de35490565b60408051606081018252600080825260208201819052918101919091526000828154811062000eb85762000eb8620022ef565b6000918252602091829020604080516060810182526003909302909101805473ffffffffffffffffffffffffffffffffffffffff90811684526001820154811694840194909452600201549092169181019190915292915050565b600062000aa4600062000d0e565b600062000f2e81620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462000f97576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b73ffffffffffffffffffffffffffffffffffffffff82163b62000fe6576040517fe939acbc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620010107fcbd1a41d9e21eb02a3acb8d57f9495422d3837dd84bf5dfbc51964fe540cff41839055565b60405173ffffffffffffffffffffffffffffffffffffffff831681527f18c973e70eca8db74eab2a3e0de3c4bffcc46c45f6f17f600e2d4d4f744e2a2b90602001620009f2565b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604081205462000a7390620015e9565b600062000aa462001c7d565b600062000aa47fcbd1a41d9e21eb02a3acb8d57f9495422d3837dd84bf5dfbc51964fe540cff415490565b6000620010cc81620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462001135576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b6200114982670de0b6b3a764000062001c65565b1562001181576040517fb4c4f79900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620011ab7fdf23e6978beb49efbffd02ffd26ec2f120b1e5be191aa5749bafaa170026fb09839055565b6040518281527f1a35ca75fc5ab34ae3487b3507e7453b6e4c15a69f2392939fbbcf8f64558ad190602001620009f2565b6000620011e981620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462001252576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b73ffffffffffffffffffffffffffffffffffffffff82163b620012a1576040517fe939acbc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620012cb7f9a67237eef0f801c1f3a0e6be772257326890fecbd39f68c5f7bb69ca7c408c3839055565b60405173ffffffffffffffffffffffffffffffffffffffff831681527fa0fe5cb0e8843811ca9f6123983dcdfd45a33b61892b9b8f380ed444078e299a90602001620009f2565b60006200131f81620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462001388576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b73ffffffffffffffffffffffffffffffffffffffff82163b620013d7576040517fe939acbc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620014017f81565bc82d6e7196d38320713fd94f897c0e1a4c83974a2fbbbf9fbb55a6d8a7839055565b60405173ffffffffffffffffffffffffffffffffffffffff831681527f36466d973cc33c9b726f867d2fc1f8cd56d58de206993f62ccba543a3429ea6290602001620009f2565b600062000aa47fd665791d8a3246c9a2360cb3de854da1c9536240e0380f1f5c2dd0e6b8b7c8605490565b600062000aa46000620015e9565b6000808281548110620014985762001498620022ef565b60009182526020909120600390910201805490915073ffffffffffffffffffffffffffffffffffffffff1633811462001501576040517f07f41a5f00000000000000000000000000000000000000000000000000000000815260048101849052602401620007a6565b81547fffffffffffffffffffffffff0000000000000000000000000000000000000000908116835560018301805473ffffffffffffffffffffffffffffffffffffffff841692168217905560405190815283907f87c983c6a4d6d9a68e6d99934d1fb50f760858298c06f8ed6b316f534e06faf4906020015b60405180910390a2505050565b600080620015b37fc641ae699093d5be5b0b167620fe782b911b5015c8c9f6e14207530ddda0d0205490565b905073ffffffffffffffffffffffffffffffffffffffff811615620015d95780620015e3565b620015e362001473565b91505090565b6000808281548110620016005762001600620022ef565b600091825260209091206001600390920201015473ffffffffffffffffffffffffffffffffffffffff1692915050565b60006200163d81620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614620016a6576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b620016d07fd665791d8a3246c9a2360cb3de854da1c9536240e0380f1f5c2dd0e6b8b7c860839055565b6040518281527f7e6452dce5202ad16be30ea14955296f7157b95e4ca48b73fc54d54601185adf90602001620009f2565b600062000aa47fdf23e6978beb49efbffd02ffd26ec2f120b1e5be191aa5749bafaa170026fb095490565b816200173881620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614620017a1576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b8160008481548110620017b857620017b8620022ef565b60009182526020918290206003919091020180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff938416179055604051918416825284917f0bffd4439c17923ee1b2b093be5394c42dcab0d9394e349a8d6a059c239ba60391016200157a565b600062000aa47f7b1a264a02657d43e78b10f2a591a99a0fdf8a165fb72bbf762d965e9973f64e5490565b600062000aa47f2859911faffd405cbcc22bdad2f67b54a86355c092452044dbab4f656aec3dc95490565b600180620018be7f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b5490565b10620018fa576040517f1e7a9d9500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b620019247f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b829055565b60017fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c556200195262001c7d565b506200195e84620011dc565b620019698362000f21565b620019748262001312565b60007fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c556040518181527fbe9b076dc5b65990cca9dd9d7366682482e7817a6f6bc7f4faf4dc32af497f329060200160405180910390a150505050565b6000620019de81620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462001a47576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b62001a5b82670de0b6b3a764000062001c65565b1562001a93576040517f7c3ceda900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62001abd7f1f7147efa84c5ef8ccb713891d25247c732a9d5765ebc3bb6cb30d1f17d277f0839055565b6040518281527f852c049e335a49416ecbcb0128935cc3832c307d450d206f0a2d0bf2b28ba2db90602001620009f2565b600062000aa47f9a67237eef0f801c1f3a0e6be772257326890fecbd39f68c5f7bb69ca7c408c35490565b600062000aa46000620009fe565b600062000aa47f6f35922f1b8609c81847a86ce8bb2528f73d722df88772b050ac89d3bc48707d5490565b8162001b5e81620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462001bc7576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b816000848154811062001bde5762001bde620022ef565b60009182526020918290206003919091020160020180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff938416179055604051918416825284917fffd31ccade46a73a57d8efd7d740bbf6aa67e50a158c98ad82a06ad31556cef491016200157a565b600062001c73838362001daf565b6002149392505050565b600080546040805160608101825283815233602080830182815283850187815260018701885587805293517f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5636003880290810180547fffffffffffffffffffffffff000000000000000000000000000000000000000090811673ffffffffffffffffffffffffffffffffffffffff9485161790915592517f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e56482018054851691841691909117905594517f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5659095018054909216941693909317909255915191825282917f645c9ae30d6a6aa6b2dace770fa0cfac2d8d44b9b036510e0a16aab39e6b5931910160405180910390a2919050565b600082828082111562001dc85760029250505062000a73565b8082101562001ddd5760009250505062000a73565b506001949350505050565b610a93806200231f83390190565b60006020828403121562001e0957600080fd5b8135801515811462000d6c57600080fd5b6000806040838503121562001e2e57600080fd5b82359150602083013567ffffffffffffffff81111562001e4d57600080fd5b83016101e0818603121562001e6157600080fd5b809150509250929050565b60006020828403121562001e7f57600080fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff8116811462001ea957600080fd5b50565b60006020828403121562001ebf57600080fd5b813562000d6c8162001e86565b6000806040838503121562001ee057600080fd5b82359150602083013562001e618162001e86565b60008060006060848603121562001f0a57600080fd5b833562001f178162001e86565b9250602084013562001f298162001e86565b9150604084013562001f3b8162001e86565b809150509250925092565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811262001f7c57600080fd5b830160208101925035905067ffffffffffffffff81111562001f9d57600080fd5b80360382131562001fad57600080fd5b9250929050565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b6002811062001ea957600080fd5b6002811062001ea9577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b8035620020508162001ffd565b6200205b816200200b565b825260208101356200206d8162001ffd565b62002078816200200b565b602083015260408101357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00008116808214620020b257600080fd5b80604085015250505050565b8035620020cb8162001e86565b919050565b8035600f81900b8114620020cb57600080fd5b620020ee81620020d0565b600f0b82526200210160208201620020d0565b600f0b60208301526200211760408201620020d0565b600f0b604083015260608101356fffffffffffffffffffffffffffffffff81168082146200214457600080fd5b80606085015250505050565b60208152600062002162838462001f46565b6101e060208501526200217b6102008501828462001fb4565b9150506200218d602085018562001f46565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0858403016040860152620021c483828462001fb4565b92505050620021da606084016040860162002043565b620021e860a08501620020be565b73ffffffffffffffffffffffffffffffffffffffff811660c08501525060c084013560e084015261010060e085013581850152610120818601358186015261014091508086013582860152506101608186013581860152620022516101808601828801620020e3565b5090949350505050565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b81811015620022a75785810183015185820160600152820162002289565b81811115620022ba576000606083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01692909201606001949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fdfe608060405260405162000a9338038062000a938339810160408190526200002691620004c6565b6200005360017fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d5162000594565b60008051602062000a4c83398151915214620000735762000073620005ba565b620000818282600062000089565b505062000641565b62000094836200015e565b6040516001600160a01b038416907f1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e90600090a2600082511180620000d65750805b15620001595762000157836001600160a01b0316635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200011f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001459190620005d0565b83620002ff60201b620000291760201c565b505b505050565b62000174816200032e60201b620000551760201c565b620001d45760405162461bcd60e51b815260206004820152602560248201527f455243313936373a206e657720626561636f6e206973206e6f74206120636f6e6044820152641d1c9858dd60da1b60648201526084015b60405180910390fd5b6200024e816001600160a01b0316635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000217573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200023d9190620005d0565b6200032e60201b620000551760201c565b620002b55760405162461bcd60e51b815260206004820152603060248201527f455243313936373a20626561636f6e20696d706c656d656e746174696f6e206960448201526f1cc81b9bdd08184818dbdb9d1c9858dd60821b6064820152608401620001cb565b80620002de60008051602062000a4c83398151915260001b6200033d60201b620000711760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b606062000327838360405180606001604052806027815260200162000a6c6027913962000340565b9392505050565b6001600160a01b03163b151590565b90565b60606001600160a01b0384163b620003aa5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401620001cb565b600080856001600160a01b031685604051620003c79190620005ee565b600060405180830381855af49150503d806000811462000404576040519150601f19603f3d011682016040523d82523d6000602084013e62000409565b606091505b5090925090506200041c82828662000426565b9695505050505050565b606083156200043757508162000327565b825115620004485782518084602001fd5b8160405162461bcd60e51b8152600401620001cb91906200060c565b80516001600160a01b03811681146200047c57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b83811015620004b45781810151838201526020016200049a565b83811115620001575750506000910152565b60008060408385031215620004da57600080fd5b620004e58362000464565b60208401519092506001600160401b03808211156200050357600080fd5b818501915085601f8301126200051857600080fd5b8151818111156200052d576200052d62000481565b604051601f8201601f19908116603f0116810190838211818310171562000558576200055862000481565b816040528281528860208487010111156200057257600080fd5b6200058583602083016020880162000497565b80955050505050509250929050565b600082821015620005b557634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b600060208284031215620005e357600080fd5b620003278262000464565b600082516200060281846020870162000497565b9190910192915050565b60208152600082518060208401526200062d81604085016020870162000497565b601f01601f19169190910160400192915050565b6103fb80620006516000396000f3fe60806040523661001357610011610017565b005b6100115b610027610022610074565b610127565b565b606061004e838360405180606001604052806027815260200161039f6027913961014b565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b90565b60006100b47fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d505473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff16635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156100fe573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061012291906102cb565b905090565b3660008037600080366000845af43d6000803e808015610146573d6000f35b3d6000fd5b606073ffffffffffffffffffffffffffffffffffffffff84163b6101f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6000808573ffffffffffffffffffffffffffffffffffffffff168560405161021e9190610331565b600060405180830381855af49150503d8060008114610259576040519150601f19603f3d011682016040523d82523d6000602084013e61025e565b606091505b509150915061026e828286610278565b9695505050505050565b6060831561028757508161004e565b8251156102975782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101ed919061034d565b6000602082840312156102dd57600080fd5b815173ffffffffffffffffffffffffffffffffffffffff8116811461004e57600080fd5b60005b8381101561031c578181015183820152602001610304565b8381111561032b576000848401525b50505050565b60008251610343818460208701610301565b9190910192915050565b602081526000825180602084015261036c816040850160208701610301565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212208ce966e1385eefb01b44b0d1cdba417199b04aa2fe5c746c59969a22757b9b3664736f6c634300080f0033a3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212207b63003df7f905db73bc6dfd429e1f3244bef25c4f88af0412ba6d9c9e0e7f9064736f6c634300080f0033", - "deployedBytecode": "0x60806040523480156200001157600080fd5b5060043610620002e45760003560e01c80637a7da0041162000199578063a36a363011620000e9578063d809aa611162000097578063e30c3978116200007a578063e30c39781462000638578063e975c0c31462000642578063f8dfc2cc146200064c57600080fd5b8063d809aa611462000617578063d8dfeb45146200062e57600080fd5b8063b0e21e8a11620000cc578063b0e21e8a14620005ec578063ba2de9bc14620005f6578063c0c53b8b146200060057600080fd5b8063a36a363014620005cb578063af2757b714620005d557600080fd5b80638da5cb5b11620001475780639fd0506d116200012a5780639fd0506d1462000593578063a123c33e146200059d578063a1eef78e14620005b457600080fd5b80638da5cb5b14620005725780638fbf1803146200057c57600080fd5b80637d254e66116200017c5780637d254e66146200050a5780637d49c1b7146200052d5780637fd29192146200053757600080fd5b80637a7da00414620004dc5780637c01369014620004f357600080fd5b80634c5430a0116200025557806365e821e5116200020357806366c0623911620001e657806366c0623914620004b15780636fc6407c14620004bb57806375907f2814620004c557600080fd5b806365e821e51462000483578063666e1b39146200049a57600080fd5b80635c975abb11620002385780635c975abb14620004075780635f1cc005146200042257806361d027b3146200047957600080fd5b80634c5430a014620003d9578063554bab3c14620003f057600080fd5b80632d809cb611620002b35780633ceda01111620002965780633ceda01114620003925780634256dd7814620003ab578063478739ca14620003c257600080fd5b80632d809cb61462000371578063391d0c9c146200038857600080fd5b806308cdc2a814620002e95780630d57036114620003025780632933d89114620003435780632b800e3b146200035a575b600080fd5b62000300620002fa36600462001df6565b62000663565b005b620003196200031336600462001e1a565b62000734565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b620003006200035436600462001e6c565b62000926565b620003196200036b36600462001e6c565b620009fe565b620003196200038236600462001eac565b62000a42565b6200031962000a79565b6200039c62000aa9565b6040519081526020016200033a565b62000300620003bc36600462001e6c565b62000ad4565b62000300620003d336600462001e6c565b62000bf1565b62000319620003ea36600462001e6c565b62000d0e565b620003006200040136600462001eac565b62000d73565b6200041162000e5a565b60405190151581526020016200033a565b620004396200043336600462001e6c565b62000e85565b60408051825173ffffffffffffffffffffffffffffffffffffffff908116825260208085015182169083015292820151909216908201526060016200033a565b6200031962000f13565b620003006200049436600462001eac565b62000f21565b62000319620004ab36600462001eac565b62001057565b6200039c62001088565b6200031962001094565b62000300620004d636600462001e6c565b620010bf565b62000300620004ed36600462001eac565b620011dc565b620003006200050436600462001eac565b62001312565b6200039c6200051b36600462001eac565b60016020526000908152604090205481565b6200039c62001448565b620004116200054836600462001eac565b73ffffffffffffffffffffffffffffffffffffffff16600090815260016020526040902054151590565b6200031962001473565b620003006200058d36600462001e6c565b62001481565b6200031962001587565b62000319620005ae36600462001e6c565b620015e9565b62000300620005c536600462001e6c565b62001630565b6200039c62001701565b62000300620005e636600462001ecc565b6200172c565b6200039c6200183c565b6200039c62001867565b620003006200061136600462001ef4565b62001892565b620003006200062836600462001e6c565b620019d1565b6200031962001aee565b6200031962001b19565b6200039c62001b27565b620003006200065d36600462001ecc565b62001b52565b6200066d62001587565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614620006d2576040517f84f8637600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620006fc7ff201e8b56b5ea8f1176ce6f2699cbe9659ba7491e9460c9d358ddf61400b5de3829055565b60405181151581527f31311016d7204faff81880133e3db244ae8a8b9ce15e83e2432258226d15f9429060200160405180910390a150565b6000826200074281620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614620007af576040517ff0a882b5000000000000000000000000000000000000000000000000000000008152600481018290526024015b60405180910390fd5b83600003620007ea576040517f7244bc7800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000620007f662000a79565b8460405160240162000809919062002150565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167ff0b4095900000000000000000000000000000000000000000000000000000000179052516200088b9062001de8565b620008989291906200225b565b604051809103906000f080158015620008b5573d6000803e3d6000fd5b5073ffffffffffffffffffffffffffffffffffffffff8116600081815260016020526040908190208890555191925082917f09d535073bc2dc21c8fd680a2141218a65fb0acc46e88b9e5d96f114b734b004906200091590889062002150565b60405180910390a295945050505050565b60006200093381620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146200099c576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b620009c67f2859911faffd405cbcc22bdad2f67b54a86355c092452044dbab4f656aec3dc9839055565b6040518281527fd19fe8ad9152af12b174a60210fb798db0767d63973ebb97298dc44d67a5c82d906020015b60405180910390a15050565b600080828154811062000a155762000a15620022ef565b600091825260209091206003909102015473ffffffffffffffffffffffffffffffffffffffff1692915050565b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604081205462000a739062000d0e565b92915050565b600062000aa47f81565bc82d6e7196d38320713fd94f897c0e1a4c83974a2fbbbf9fbb55a6d8a75490565b905090565b600062000aa47f1f7147efa84c5ef8ccb713891d25247c732a9d5765ebc3bb6cb30d1f17d277f05490565b600062000ae181620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462000b4a576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b62000b5e82670de0b6b3a764000062001c65565b1562000b96576040517f3c5df10400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000bc07f7b1a264a02657d43e78b10f2a591a99a0fdf8a165fb72bbf762d965e9973f64e839055565b6040518281527fd10d75876659a287a59a6ccfa2e3fff42f84d94b542837acd30bc184d562de4090602001620009f2565b600062000bfe81620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462000c67576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b62000c7b82670de0b6b3a764000062001c65565b1562000cb3576040517f0c6b0ec800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000cdd7f6f35922f1b8609c81847a86ce8bb2528f73d722df88772b050ac89d3bc48707d839055565b6040518281527fdf7e6bc55eeb2668bd338e44a5abb721b1f98ad51f7a00baaa1b62f9383862d790602001620009f2565b6000806000838154811062000d275762000d27620022ef565b600091825260209091206002600390920201015473ffffffffffffffffffffffffffffffffffffffff169050801562000d61578062000d6c565b62000d6c83620015e9565b9392505050565b600062000d8081620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462000de9576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b62000e137fc641ae699093d5be5b0b167620fe782b911b5015c8c9f6e14207530ddda0d020839055565b60405173ffffffffffffffffffffffffffffffffffffffff831681527fa4336c0cb1e245b95ad204faed7e940d6dc999684fd8b5e1ff597a0c4efca8ab90602001620009f2565b600062000aa47ff201e8b56b5ea8f1176ce6f2699cbe9659ba7491e9460c9d358ddf61400b5de35490565b60408051606081018252600080825260208201819052918101919091526000828154811062000eb85762000eb8620022ef565b6000918252602091829020604080516060810182526003909302909101805473ffffffffffffffffffffffffffffffffffffffff90811684526001820154811694840194909452600201549092169181019190915292915050565b600062000aa4600062000d0e565b600062000f2e81620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462000f97576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b73ffffffffffffffffffffffffffffffffffffffff82163b62000fe6576040517fe939acbc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620010107fcbd1a41d9e21eb02a3acb8d57f9495422d3837dd84bf5dfbc51964fe540cff41839055565b60405173ffffffffffffffffffffffffffffffffffffffff831681527f18c973e70eca8db74eab2a3e0de3c4bffcc46c45f6f17f600e2d4d4f744e2a2b90602001620009f2565b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604081205462000a7390620015e9565b600062000aa462001c7d565b600062000aa47fcbd1a41d9e21eb02a3acb8d57f9495422d3837dd84bf5dfbc51964fe540cff415490565b6000620010cc81620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462001135576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b6200114982670de0b6b3a764000062001c65565b1562001181576040517fb4c4f79900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620011ab7fdf23e6978beb49efbffd02ffd26ec2f120b1e5be191aa5749bafaa170026fb09839055565b6040518281527f1a35ca75fc5ab34ae3487b3507e7453b6e4c15a69f2392939fbbcf8f64558ad190602001620009f2565b6000620011e981620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462001252576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b73ffffffffffffffffffffffffffffffffffffffff82163b620012a1576040517fe939acbc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620012cb7f9a67237eef0f801c1f3a0e6be772257326890fecbd39f68c5f7bb69ca7c408c3839055565b60405173ffffffffffffffffffffffffffffffffffffffff831681527fa0fe5cb0e8843811ca9f6123983dcdfd45a33b61892b9b8f380ed444078e299a90602001620009f2565b60006200131f81620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462001388576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b73ffffffffffffffffffffffffffffffffffffffff82163b620013d7576040517fe939acbc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620014017f81565bc82d6e7196d38320713fd94f897c0e1a4c83974a2fbbbf9fbb55a6d8a7839055565b60405173ffffffffffffffffffffffffffffffffffffffff831681527f36466d973cc33c9b726f867d2fc1f8cd56d58de206993f62ccba543a3429ea6290602001620009f2565b600062000aa47fd665791d8a3246c9a2360cb3de854da1c9536240e0380f1f5c2dd0e6b8b7c8605490565b600062000aa46000620015e9565b6000808281548110620014985762001498620022ef565b60009182526020909120600390910201805490915073ffffffffffffffffffffffffffffffffffffffff1633811462001501576040517f07f41a5f00000000000000000000000000000000000000000000000000000000815260048101849052602401620007a6565b81547fffffffffffffffffffffffff0000000000000000000000000000000000000000908116835560018301805473ffffffffffffffffffffffffffffffffffffffff841692168217905560405190815283907f87c983c6a4d6d9a68e6d99934d1fb50f760858298c06f8ed6b316f534e06faf4906020015b60405180910390a2505050565b600080620015b37fc641ae699093d5be5b0b167620fe782b911b5015c8c9f6e14207530ddda0d0205490565b905073ffffffffffffffffffffffffffffffffffffffff811615620015d95780620015e3565b620015e362001473565b91505090565b6000808281548110620016005762001600620022ef565b600091825260209091206001600390920201015473ffffffffffffffffffffffffffffffffffffffff1692915050565b60006200163d81620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614620016a6576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b620016d07fd665791d8a3246c9a2360cb3de854da1c9536240e0380f1f5c2dd0e6b8b7c860839055565b6040518281527f7e6452dce5202ad16be30ea14955296f7157b95e4ca48b73fc54d54601185adf90602001620009f2565b600062000aa47fdf23e6978beb49efbffd02ffd26ec2f120b1e5be191aa5749bafaa170026fb095490565b816200173881620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614620017a1576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b8160008481548110620017b857620017b8620022ef565b60009182526020918290206003919091020180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff938416179055604051918416825284917f0bffd4439c17923ee1b2b093be5394c42dcab0d9394e349a8d6a059c239ba60391016200157a565b600062000aa47f7b1a264a02657d43e78b10f2a591a99a0fdf8a165fb72bbf762d965e9973f64e5490565b600062000aa47f2859911faffd405cbcc22bdad2f67b54a86355c092452044dbab4f656aec3dc95490565b600180620018be7f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b5490565b10620018fa576040517f1e7a9d9500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b620019247f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b829055565b60017fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c556200195262001c7d565b506200195e84620011dc565b620019698362000f21565b620019748262001312565b60007fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c556040518181527fbe9b076dc5b65990cca9dd9d7366682482e7817a6f6bc7f4faf4dc32af497f329060200160405180910390a150505050565b6000620019de81620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462001a47576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b62001a5b82670de0b6b3a764000062001c65565b1562001a93576040517f7c3ceda900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62001abd7f1f7147efa84c5ef8ccb713891d25247c732a9d5765ebc3bb6cb30d1f17d277f0839055565b6040518281527f852c049e335a49416ecbcb0128935cc3832c307d450d206f0a2d0bf2b28ba2db90602001620009f2565b600062000aa47f9a67237eef0f801c1f3a0e6be772257326890fecbd39f68c5f7bb69ca7c408c35490565b600062000aa46000620009fe565b600062000aa47f6f35922f1b8609c81847a86ce8bb2528f73d722df88772b050ac89d3bc48707d5490565b8162001b5e81620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462001bc7576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b816000848154811062001bde5762001bde620022ef565b60009182526020918290206003919091020160020180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff938416179055604051918416825284917fffd31ccade46a73a57d8efd7d740bbf6aa67e50a158c98ad82a06ad31556cef491016200157a565b600062001c73838362001daf565b6002149392505050565b600080546040805160608101825283815233602080830182815283850187815260018701885587805293517f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5636003880290810180547fffffffffffffffffffffffff000000000000000000000000000000000000000090811673ffffffffffffffffffffffffffffffffffffffff9485161790915592517f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e56482018054851691841691909117905594517f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5659095018054909216941693909317909255915191825282917f645c9ae30d6a6aa6b2dace770fa0cfac2d8d44b9b036510e0a16aab39e6b5931910160405180910390a2919050565b600082828082111562001dc85760029250505062000a73565b8082101562001ddd5760009250505062000a73565b506001949350505050565b610a93806200231f83390190565b60006020828403121562001e0957600080fd5b8135801515811462000d6c57600080fd5b6000806040838503121562001e2e57600080fd5b82359150602083013567ffffffffffffffff81111562001e4d57600080fd5b83016101e0818603121562001e6157600080fd5b809150509250929050565b60006020828403121562001e7f57600080fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff8116811462001ea957600080fd5b50565b60006020828403121562001ebf57600080fd5b813562000d6c8162001e86565b6000806040838503121562001ee057600080fd5b82359150602083013562001e618162001e86565b60008060006060848603121562001f0a57600080fd5b833562001f178162001e86565b9250602084013562001f298162001e86565b9150604084013562001f3b8162001e86565b809150509250925092565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811262001f7c57600080fd5b830160208101925035905067ffffffffffffffff81111562001f9d57600080fd5b80360382131562001fad57600080fd5b9250929050565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b6002811062001ea957600080fd5b6002811062001ea9577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b8035620020508162001ffd565b6200205b816200200b565b825260208101356200206d8162001ffd565b62002078816200200b565b602083015260408101357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00008116808214620020b257600080fd5b80604085015250505050565b8035620020cb8162001e86565b919050565b8035600f81900b8114620020cb57600080fd5b620020ee81620020d0565b600f0b82526200210160208201620020d0565b600f0b60208301526200211760408201620020d0565b600f0b604083015260608101356fffffffffffffffffffffffffffffffff81168082146200214457600080fd5b80606085015250505050565b60208152600062002162838462001f46565b6101e060208501526200217b6102008501828462001fb4565b9150506200218d602085018562001f46565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0858403016040860152620021c483828462001fb4565b92505050620021da606084016040860162002043565b620021e860a08501620020be565b73ffffffffffffffffffffffffffffffffffffffff811660c08501525060c084013560e084015261010060e085013581850152610120818601358186015261014091508086013582860152506101608186013581860152620022516101808601828801620020e3565b5090949350505050565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b81811015620022a75785810183015185820160600152820162002289565b81811115620022ba576000606083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01692909201606001949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fdfe608060405260405162000a9338038062000a938339810160408190526200002691620004c6565b6200005360017fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d5162000594565b60008051602062000a4c83398151915214620000735762000073620005ba565b620000818282600062000089565b505062000641565b62000094836200015e565b6040516001600160a01b038416907f1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e90600090a2600082511180620000d65750805b15620001595762000157836001600160a01b0316635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200011f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001459190620005d0565b83620002ff60201b620000291760201c565b505b505050565b62000174816200032e60201b620000551760201c565b620001d45760405162461bcd60e51b815260206004820152602560248201527f455243313936373a206e657720626561636f6e206973206e6f74206120636f6e6044820152641d1c9858dd60da1b60648201526084015b60405180910390fd5b6200024e816001600160a01b0316635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000217573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200023d9190620005d0565b6200032e60201b620000551760201c565b620002b55760405162461bcd60e51b815260206004820152603060248201527f455243313936373a20626561636f6e20696d706c656d656e746174696f6e206960448201526f1cc81b9bdd08184818dbdb9d1c9858dd60821b6064820152608401620001cb565b80620002de60008051602062000a4c83398151915260001b6200033d60201b620000711760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b606062000327838360405180606001604052806027815260200162000a6c6027913962000340565b9392505050565b6001600160a01b03163b151590565b90565b60606001600160a01b0384163b620003aa5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401620001cb565b600080856001600160a01b031685604051620003c79190620005ee565b600060405180830381855af49150503d806000811462000404576040519150601f19603f3d011682016040523d82523d6000602084013e62000409565b606091505b5090925090506200041c82828662000426565b9695505050505050565b606083156200043757508162000327565b825115620004485782518084602001fd5b8160405162461bcd60e51b8152600401620001cb91906200060c565b80516001600160a01b03811681146200047c57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b83811015620004b45781810151838201526020016200049a565b83811115620001575750506000910152565b60008060408385031215620004da57600080fd5b620004e58362000464565b60208401519092506001600160401b03808211156200050357600080fd5b818501915085601f8301126200051857600080fd5b8151818111156200052d576200052d62000481565b604051601f8201601f19908116603f0116810190838211818310171562000558576200055862000481565b816040528281528860208487010111156200057257600080fd5b6200058583602083016020880162000497565b80955050505050509250929050565b600082821015620005b557634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b600060208284031215620005e357600080fd5b620003278262000464565b600082516200060281846020870162000497565b9190910192915050565b60208152600082518060208401526200062d81604085016020870162000497565b601f01601f19169190910160400192915050565b6103fb80620006516000396000f3fe60806040523661001357610011610017565b005b6100115b610027610022610074565b610127565b565b606061004e838360405180606001604052806027815260200161039f6027913961014b565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b90565b60006100b47fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d505473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff16635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156100fe573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061012291906102cb565b905090565b3660008037600080366000845af43d6000803e808015610146573d6000f35b3d6000fd5b606073ffffffffffffffffffffffffffffffffffffffff84163b6101f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6000808573ffffffffffffffffffffffffffffffffffffffff168560405161021e9190610331565b600060405180830381855af49150503d8060008114610259576040519150601f19603f3d011682016040523d82523d6000602084013e61025e565b606091505b509150915061026e828286610278565b9695505050505050565b6060831561028757508161004e565b8251156102975782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101ed919061034d565b6000602082840312156102dd57600080fd5b815173ffffffffffffffffffffffffffffffffffffffff8116811461004e57600080fd5b60005b8381101561031c578181015183820152602001610304565b8381111561032b576000848401525b50505050565b60008251610343818460208701610301565b9190910192915050565b602081526000825180602084015261036c816040850160208701610301565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212208ce966e1385eefb01b44b0d1cdba417199b04aa2fe5c746c59969a22757b9b3664736f6c634300080f0033a3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212207b63003df7f905db73bc6dfd429e1f3244bef25c4f88af0412ba6d9c9e0e7f9064736f6c634300080f0033", - "devdoc": { - "kind": "dev", - "methods": { - "acceptCoordinatorOwner(uint256)": { - "details": "Must be called by the coordinator's pending owner", - "params": { - "coordinatorId": "Coordinator to update" - } - }, - "coordinators(uint256)": { - "params": { - "coordinatorId": "Coordinator to return for" - }, - "returns": { - "_0": "Coordinator state" - } - }, - "createCoordinator()": { - "details": "Can only be called by the protocol owner", - "returns": { - "_0": "New coordinator ID" - } - }, - "createProduct(uint256,(string,string,(uint8,uint8,bytes30),address,uint256,uint256,uint256,uint256,uint256,(int128,int128,int128,uint128)))": { - "details": "Can only be called by the coordinator owner", - "params": { - "coordinatorId": "Coordinator that will own the product", - "productInfo": "Product params used to initialize the product" - }, - "returns": { - "_0": "New product contract address" - } - }, - "initialize(address,address,address)": { - "details": "Must be called atomically as part of the upgradeable proxy deployment to avoid front-running", - "params": { - "collateral_": "Collateral contract address", - "incentivizer_": "Incentivizer contract address", - "productBeacon_": "Product implementation beacon address" - } - }, - "isProduct(address)": { - "params": { - "product": "Contract address to check" - }, - "returns": { - "_0": "Whether a contract is a product" - } - }, - "owner()": { - "returns": { - "_0": "Owner of the protocol" - } - }, - "owner(address)": { - "params": { - "product": "Product to return for" - }, - "returns": { - "_0": "Owner of the product" - } - }, - "owner(uint256)": { - "params": { - "coordinatorId": "Coordinator to return for" - }, - "returns": { - "_0": "Owner of the coordinator" - } - }, - "pendingOwner()": { - "returns": { - "_0": "Owner of the protocol" - } - }, - "pendingOwner(uint256)": { - "params": { - "coordinatorId": "Coordinator to return for" - }, - "returns": { - "_0": "Pending owner of the coordinator" - } - }, - "treasury()": { - "details": "Defaults to the `owner` when `treasury` is unset", - "returns": { - "_0": "Treasury of the protocol" - } - }, - "treasury(address)": { - "details": "Defaults to the `owner` when `treasury` is unset", - "params": { - "product": "Product to return for" - }, - "returns": { - "_0": "Treasury of the product" - } - }, - "treasury(uint256)": { - "details": "Defaults to the `owner` when `treasury` is unset", - "params": { - "coordinatorId": "Coordinator to return for" - }, - "returns": { - "_0": "Treasury of the coordinator" - } - }, - "updateCollateral(address)": { - "params": { - "newCollateral": "New Collateral contract address" - } - }, - "updateCoordinatorPendingOwner(uint256,address)": { - "details": "Must be called by the coordinator's current owner", - "params": { - "coordinatorId": "Coordinator to update", - "newPendingOwner": "New pending owner address" - } - }, - "updateCoordinatorTreasury(uint256,address)": { - "details": "Must be called by the coordinator's current owner. Defaults to the coordinator `owner` if set to address(0)", - "params": { - "coordinatorId": "Coordinator to update", - "newTreasury": "New treasury address" - } - }, - "updateIncentivizationFee(uint256)": { - "params": { - "newIncentivizationFee": "New incentivization fee" - } - }, - "updateIncentivizer(address)": { - "params": { - "newIncentivizer": "New Incentivizer contract address" - } - }, - "updateLiquidationFee(uint256)": { - "params": { - "newLiquidationFee": "New liquidation fee" - } - }, - "updateMinCollateral(uint256)": { - "params": { - "newMinCollateral": "New minimum allowed collateral amount" - } - }, - "updateMinFundingFee(uint256)": { - "params": { - "newMinFundingFee": "New minimum allowed funding fee" - } - }, - "updatePaused(bool)": { - "params": { - "newPaused": "New protocol paused state" - } - }, - "updatePauser(address)": { - "params": { - "newPauser": "New protocol pauser address" - } - }, - "updateProductBeacon(address)": { - "params": { - "newProductBeacon": "New Product implementation beacon address" - } - }, - "updateProgramsPerProduct(uint256)": { - "params": { - "newProgramsPerProduct": "New maximum incentivization programs per product allowed" - } - }, - "updateProtocolFee(uint256)": { - "params": { - "newProtocolFee": "New protocol-product fee split" - } - } - }, - "stateVariables": { - "_collateral": { - "details": "Collateral contract address for the protocol" - }, - "_coordinators": { - "details": "List of product coordinators" - }, - "_incentivizationFee": { - "details": "Fee on incentivization programs" - }, - "_incentivizer": { - "details": "Incentivizer contract address for the protocol" - }, - "_liquidationFee": { - "details": "Fee on maintenance for liquidation" - }, - "_minCollateral": { - "details": "Minimum allowable collateral amount per user account" - }, - "_minFundingFee": { - "details": "Minimum allowable funding fee for a product" - }, - "_paused": { - "details": "The paused status of the protocol" - }, - "_pauser": { - "details": "Protocol pauser address. address(0) defaults to owner(0)" - }, - "_productBeacon": { - "details": "Product implementation beacon address for the protocol" - }, - "_programsPerProduct": { - "details": "Maximum incentivization programs per product allowed" - }, - "_protocolFee": { - "details": "Percent of collected fees that go to the protocol treasury vs the product treasury" - }, - "coordinatorFor": { - "details": "Mapping of the coordinator for each product" - } - }, - "title": "Controller", - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": { - "acceptCoordinatorOwner(uint256)": { - "notice": "Accepts ownership over an existing coordinator" - }, - "coordinators(uint256)": { - "notice": "Returns coordinator state for coordinator `coordinatorId`" - }, - "createCoordinator()": { - "notice": "Creates a new coordinator with `msg.sender` as the owner" - }, - "createProduct(uint256,(string,string,(uint8,uint8,bytes30),address,uint256,uint256,uint256,uint256,uint256,(int128,int128,int128,uint128)))": { - "notice": "Creates a new product market with `provider`" - }, - "initialize(address,address,address)": { - "notice": "Initializes the contract state" - }, - "isProduct(address)": { - "notice": "Returns whether a contract is a product" - }, - "owner()": { - "notice": "Returns the owner of the protocol" - }, - "owner(address)": { - "notice": "Returns the owner of the product `product`" - }, - "owner(uint256)": { - "notice": "Returns the owner of the coordinator `coordinatorId`" - }, - "pendingOwner()": { - "notice": "Returns the pending owner of the protocol" - }, - "pendingOwner(uint256)": { - "notice": "Returns the pending owner of the coordinator `coordinatorId`" - }, - "treasury()": { - "notice": "Returns the treasury of the protocol" - }, - "treasury(address)": { - "notice": "Returns the treasury of the product `product`" - }, - "treasury(uint256)": { - "notice": "Returns the treasury of the coordinator `coordinatorId`" - }, - "updateCollateral(address)": { - "notice": "Updates the Collateral contract address" - }, - "updateCoordinatorPendingOwner(uint256,address)": { - "notice": "Updates the pending owner of an existing coordinator" - }, - "updateCoordinatorTreasury(uint256,address)": { - "notice": "Updates the treasury of an existing coordinator" - }, - "updateIncentivizationFee(uint256)": { - "notice": "Updates the incentivization fee" - }, - "updateIncentivizer(address)": { - "notice": "Updates the Incentivizer contract address" - }, - "updateLiquidationFee(uint256)": { - "notice": "Updates the liquidation fee" - }, - "updateMinCollateral(uint256)": { - "notice": "Updates the minimum allowed collateral amount per user account" - }, - "updateMinFundingFee(uint256)": { - "notice": "Updates the minimum allowed funding fee" - }, - "updatePaused(bool)": { - "notice": "Updates the protocol paused state" - }, - "updatePauser(address)": { - "notice": "Updates the protocol pauser address. Zero address defaults to owner(0)" - }, - "updateProductBeacon(address)": { - "notice": "Updates the Product implementation beacon address" - }, - "updateProgramsPerProduct(uint256)": { - "notice": "Updates the maximum incentivization programs per product allowed" - }, - "updateProtocolFee(uint256)": { - "notice": "Updates the protocol-product fee split" - } - }, - "notice": "Manages creating new products and global protocol parameters.", - "version": 1 - }, - "storageLayout": { - "storage": [ - { - "astId": 11565, - "contract": "contracts/controller/Controller.sol:Controller", - "label": "_coordinators", - "offset": 0, - "slot": "0", - "type": "t_array(t_struct(Coordinator)14688_storage)dyn_storage" - }, - { - "astId": 11571, - "contract": "contracts/controller/Controller.sol:Controller", - "label": "coordinatorFor", - "offset": 0, - "slot": "1", - "type": "t_mapping(t_contract(IProduct)16214,t_uint256)" - } - ], - "types": { - "t_address": { - "encoding": "inplace", - "label": "address", - "numberOfBytes": "20" - }, - "t_array(t_struct(Coordinator)14688_storage)dyn_storage": { - "base": "t_struct(Coordinator)14688_storage", - "encoding": "dynamic_array", - "label": "struct IController.Coordinator[]", - "numberOfBytes": "32" - }, - "t_contract(IProduct)16214": { - "encoding": "inplace", - "label": "contract IProduct", - "numberOfBytes": "20" - }, - "t_mapping(t_contract(IProduct)16214,t_uint256)": { - "encoding": "mapping", - "key": "t_contract(IProduct)16214", - "label": "mapping(contract IProduct => uint256)", - "numberOfBytes": "32", - "value": "t_uint256" - }, - "t_struct(Coordinator)14688_storage": { - "encoding": "inplace", - "label": "struct IController.Coordinator", - "members": [ - { - "astId": 14681, - "contract": "contracts/controller/Controller.sol:Controller", - "label": "pendingOwner", - "offset": 0, - "slot": "0", - "type": "t_address" - }, - { - "astId": 14684, - "contract": "contracts/controller/Controller.sol:Controller", - "label": "owner", - "offset": 0, - "slot": "1", - "type": "t_address" - }, - { - "astId": 14687, - "contract": "contracts/controller/Controller.sol:Controller", - "label": "treasury", - "offset": 0, - "slot": "2", - "type": "t_address" - } - ], - "numberOfBytes": "96" - }, - "t_uint256": { - "encoding": "inplace", - "label": "uint256", - "numberOfBytes": "32" - } - } - } -} diff --git a/packages/perennial/deployments/goerli/Controller_Proxy.json b/packages/perennial/deployments/goerli/Controller_Proxy.json deleted file mode 100644 index 13c533259..000000000 --- a/packages/perennial/deployments/goerli/Controller_Proxy.json +++ /dev/null @@ -1,229 +0,0 @@ -{ - "address": "0x7c4ABBF7CB0C0BcB72917734B068Ed4D1AcdF8C5", - "abi": [ - { - "inputs": [ - { - "internalType": "address", - "name": "_logic", - "type": "address" - }, - { - "internalType": "address", - "name": "admin_", - "type": "address" - }, - { - "internalType": "bytes", - "name": "_data", - "type": "bytes" - } - ], - "stateMutability": "payable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "previousAdmin", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "newAdmin", - "type": "address" - } - ], - "name": "AdminChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "beacon", - "type": "address" - } - ], - "name": "BeaconUpgraded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "implementation", - "type": "address" - } - ], - "name": "Upgraded", - "type": "event" - }, - { - "stateMutability": "payable", - "type": "fallback" - }, - { - "inputs": [], - "name": "admin", - "outputs": [ - { - "internalType": "address", - "name": "admin_", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newAdmin", - "type": "address" - } - ], - "name": "changeAdmin", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "implementation", - "outputs": [ - { - "internalType": "address", - "name": "implementation_", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newImplementation", - "type": "address" - } - ], - "name": "upgradeTo", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newImplementation", - "type": "address" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "upgradeToAndCall", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "stateMutability": "payable", - "type": "receive" - } - ], - "transactionHash": "0x0605709147048a7756fdf1de369fae5e046a2a37d09e09a06bf85963dfd15cd5", - "receipt": { - "to": null, - "from": "0x66a7fDB96C583c59597de16d8b2B989231415339", - "contractAddress": "0x7c4ABBF7CB0C0BcB72917734B068Ed4D1AcdF8C5", - "transactionIndex": 10, - "gasUsed": "690597", - "logsBloom": "0x00000000000000000000000000000000400000000000000000000000000000000000000000000000000000000100008000000000000000000000000000000000000000000000000000000002000002000000000000000000000000000000000200000000000000000000000000000000000000800000000000000000000000200000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000020000002000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc7a33079c1cc9e534a6f785ed9c023e329c0093a272fdd872c84c26415d2dd7d", - "transactionHash": "0x0605709147048a7756fdf1de369fae5e046a2a37d09e09a06bf85963dfd15cd5", - "logs": [ - { - "transactionIndex": 10, - "blockNumber": 7681150, - "transactionHash": "0x0605709147048a7756fdf1de369fae5e046a2a37d09e09a06bf85963dfd15cd5", - "address": "0x7c4ABBF7CB0C0BcB72917734B068Ed4D1AcdF8C5", - "topics": [ - "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x0000000000000000000000001c7ee3abc60751dd4069d1b19438a4df92f4eb3a" - ], - "data": "0x", - "logIndex": 16, - "blockHash": "0xc7a33079c1cc9e534a6f785ed9c023e329c0093a272fdd872c84c26415d2dd7d" - }, - { - "transactionIndex": 10, - "blockNumber": 7681150, - "transactionHash": "0x0605709147048a7756fdf1de369fae5e046a2a37d09e09a06bf85963dfd15cd5", - "address": "0x7c4ABBF7CB0C0BcB72917734B068Ed4D1AcdF8C5", - "topics": ["0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f"], - "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000085b75de34c7328625b8c394769d98d64c74febca", - "logIndex": 17, - "blockHash": "0xc7a33079c1cc9e534a6f785ed9c023e329c0093a272fdd872c84c26415d2dd7d" - } - ], - "blockNumber": 7681150, - "cumulativeGasUsed": "5853218", - "status": 1, - "byzantium": true - }, - "args": ["0x1c7ee3aBC60751Dd4069d1b19438a4Df92f4EB3a", "0x85b75DE34c7328625b8c394769D98d64C74fEBCa", "0x"], - "numDeployments": 1, - "solcInputHash": "b6ff42633a62e1bc6c97d8ccad85444b", - "metadata": "{\"compiler\":{\"version\":\"0.8.15+commit.e14f2714\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // 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\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\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 ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\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(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\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 /**\\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 {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x60806040526040516200112838038062001128833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b600080516020620010e1833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b600080516020620010c183398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b6200028c1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e98383604051806060016040528060278152602001620011016027913962000381565b9392505050565b60006200021a600080516020620010c183398151915260001b6200046760201b6200022e1760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd600080516020620010c183398151915260001b6200046760201b6200022e1760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b620002b81760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd600080516020620010e183398151915260001b6200046760201b6200022e1760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610a2980620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b610090366004610895565b610135565b61006b6100a33660046108b0565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b610101366004610895565b610231565b34801561011257600080fd5b506100bd61025e565b6101236102d4565b61013361012e6103ab565b6103b5565b565b61013d6103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481604051806020016040528060008152506000610419565b50565b61017461011b565b6101876103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610419915050565b505050565b6101e661011b565b60006101fd6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103ab565b905090565b61022e61011b565b90565b6102396103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481610444565b60006102686103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103d9565b60606102b183836040518060600160405280602781526020016109cd602791396104a5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6102dc6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102216105cd565b3660008037600080366000845af43d6000803e8080156103d4573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b610422836105f5565b60008251118061042f5750805b156101e65761043e838361028c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61046d6103d9565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161017481610642565b606073ffffffffffffffffffffffffffffffffffffffff84163b61054b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103a2565b6000808573ffffffffffffffffffffffffffffffffffffffff1685604051610573919061095f565b600060405180830381855af49150503d80600081146105ae576040519150601f19603f3d011682016040523d82523d6000602084013e6105b3565b606091505b50915091506105c382828661074e565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103fd565b6105fe816107a1565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff81166106e5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103a2565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060831561075d5750816102b1565b82511561076d5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a2919061097b565b73ffffffffffffffffffffffffffffffffffffffff81163b610845576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103a2565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610708565b803573ffffffffffffffffffffffffffffffffffffffff8116811461089057600080fd5b919050565b6000602082840312156108a757600080fd5b6102b18261086c565b6000806000604084860312156108c557600080fd5b6108ce8461086c565b9250602084013567ffffffffffffffff808211156108eb57600080fd5b818601915086601f8301126108ff57600080fd5b81358181111561090e57600080fd5b87602082850101111561092057600080fd5b6020830194508093505050509250925092565b60005b8381101561094e578181015183820152602001610936565b8381111561043e5750506000910152565b60008251610971818460208701610933565b9190910192915050565b602081526000825180602084015261099a816040850160208701610933565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a4b930408c511c08d53f1ec84bb13fe259938b06e5d586d6adc4fc27200abe6c64736f6c634300080f0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", - "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b610090366004610895565b610135565b61006b6100a33660046108b0565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b610101366004610895565b610231565b34801561011257600080fd5b506100bd61025e565b6101236102d4565b61013361012e6103ab565b6103b5565b565b61013d6103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481604051806020016040528060008152506000610419565b50565b61017461011b565b6101876103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610419915050565b505050565b6101e661011b565b60006101fd6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103ab565b905090565b61022e61011b565b90565b6102396103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481610444565b60006102686103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103d9565b60606102b183836040518060600160405280602781526020016109cd602791396104a5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6102dc6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102216105cd565b3660008037600080366000845af43d6000803e8080156103d4573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b610422836105f5565b60008251118061042f5750805b156101e65761043e838361028c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61046d6103d9565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161017481610642565b606073ffffffffffffffffffffffffffffffffffffffff84163b61054b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103a2565b6000808573ffffffffffffffffffffffffffffffffffffffff1685604051610573919061095f565b600060405180830381855af49150503d80600081146105ae576040519150601f19603f3d011682016040523d82523d6000602084013e6105b3565b606091505b50915091506105c382828661074e565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103fd565b6105fe816107a1565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff81166106e5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103a2565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060831561075d5750816102b1565b82511561076d5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a2919061097b565b73ffffffffffffffffffffffffffffffffffffffff81163b610845576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103a2565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610708565b803573ffffffffffffffffffffffffffffffffffffffff8116811461089057600080fd5b919050565b6000602082840312156108a757600080fd5b6102b18261086c565b6000806000604084860312156108c557600080fd5b6108ce8461086c565b9250602084013567ffffffffffffffff808211156108eb57600080fd5b818601915086601f8301126108ff57600080fd5b81358181111561090e57600080fd5b87602082850101111561092057600080fd5b6020830194508093505050509250925092565b60005b8381101561094e578181015183820152602001610936565b8381111561043e5750506000910152565b60008251610971818460208701610933565b9190910192915050565b602081526000825180602084015261099a816040850160208701610933565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a4b930408c511c08d53f1ec84bb13fe259938b06e5d586d6adc4fc27200abe6c64736f6c634300080f0033", - "devdoc": { - "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", - "kind": "dev", - "methods": { - "admin()": { - "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" - }, - "changeAdmin(address)": { - "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." - }, - "constructor": { - "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." - }, - "implementation()": { - "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" - }, - "upgradeTo(address)": { - "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." - }, - "upgradeToAndCall(address,bytes)": { - "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." - } - }, - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": {}, - "version": 1 - }, - "storageLayout": { - "storage": [], - "types": null - } -} diff --git a/packages/perennial/deployments/goerli/Forwarder.json b/packages/perennial/deployments/goerli/Forwarder.json deleted file mode 100644 index 1bcca7b19..000000000 --- a/packages/perennial/deployments/goerli/Forwarder.json +++ /dev/null @@ -1,239 +0,0 @@ -{ - "address": "0x01Caa6743a96cd8Ed98787579feee12Cbe3DD515", - "abi": [ - { - "inputs": [ - { - "internalType": "Token6", - "name": "usdc_", - "type": "address" - }, - { - "internalType": "Token18", - "name": "dsu_", - "type": "address" - }, - { - "internalType": "contract IBatcher", - "name": "batcher_", - "type": "address" - }, - { - "internalType": "contract ICollateral", - "name": "collateral_", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [], - "name": "ForwarderNotContractAddressError", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "WrapAndDeposit", - "type": "event" - }, - { - "inputs": [], - "name": "DSU", - "outputs": [ - { - "internalType": "Token18", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "USDC", - "outputs": [ - { - "internalType": "Token6", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "batcher", - "outputs": [ - { - "internalType": "contract IBatcher", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "collateral", - "outputs": [ - { - "internalType": "contract ICollateral", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "wrapAndDeposit", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } - ], - "transactionHash": "0x4a26798d46de1305b45fbae9b198e6b634e22d566b4c89a14dbdf7e60628ec29", - "receipt": { - "to": null, - "from": "0x66a7fDB96C583c59597de16d8b2B989231415339", - "contractAddress": "0x01Caa6743a96cd8Ed98787579feee12Cbe3DD515", - "transactionIndex": 58, - "gasUsed": "803249", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000200000200000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000002800000012000000000000000000000000000000000000000000000000000000000000000000000000020000000000001000000000000000000000000000000000000000000000000000000208000000040000020000000000000000000000008000000020000000000010000000000000000000000000000000000000000000000800000000000000", - "blockHash": "0x19921cecd25a100560398b8477ec20dcccea5c6222c330aa674dc4e571340514", - "transactionHash": "0x4a26798d46de1305b45fbae9b198e6b634e22d566b4c89a14dbdf7e60628ec29", - "logs": [ - { - "transactionIndex": 58, - "blockNumber": 7681164, - "transactionHash": "0x4a26798d46de1305b45fbae9b198e6b634e22d566b4c89a14dbdf7e60628ec29", - "address": "0x07865c6E87B9F70255377e024ace6630C1Eaa37F", - "topics": [ - "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", - "0x00000000000000000000000001caa6743a96cd8ed98787579feee12cbe3dd515", - "0x000000000000000000000000736f79f5df3e33718a2ed2270976ed64320808e6" - ], - "data": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "logIndex": 158, - "blockHash": "0x19921cecd25a100560398b8477ec20dcccea5c6222c330aa674dc4e571340514" - }, - { - "transactionIndex": 58, - "blockNumber": 7681164, - "transactionHash": "0x4a26798d46de1305b45fbae9b198e6b634e22d566b4c89a14dbdf7e60628ec29", - "address": "0x237D7a40d3A28aA5dAAb786570d3d8bf8496e497", - "topics": [ - "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", - "0x00000000000000000000000001caa6743a96cd8ed98787579feee12cbe3dd515", - "0x000000000000000000000000741fc06b5de25ac5b31f54b92ee3bf1c97bf8666" - ], - "data": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "logIndex": 159, - "blockHash": "0x19921cecd25a100560398b8477ec20dcccea5c6222c330aa674dc4e571340514" - } - ], - "blockNumber": 7681164, - "cumulativeGasUsed": "12731835", - "status": 1, - "byzantium": true - }, - "args": [ - "0x07865c6E87B9F70255377e024ace6630C1Eaa37F", - "0x237D7a40d3A28aA5dAAb786570d3d8bf8496e497", - "0x736f79F5df3E33718a2ed2270976eD64320808e6", - "0x741FC06B5DE25AC5b31F54B92eE3Bf1C97bf8666" - ], - "numDeployments": 1, - "solcInputHash": "b6ff42633a62e1bc6c97d8ccad85444b", - "metadata": "{\"compiler\":{\"version\":\"0.8.15+commit.e14f2714\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"Token6\",\"name\":\"usdc_\",\"type\":\"address\"},{\"internalType\":\"Token18\",\"name\":\"dsu_\",\"type\":\"address\"},{\"internalType\":\"contract IBatcher\",\"name\":\"batcher_\",\"type\":\"address\"},{\"internalType\":\"contract ICollateral\",\"name\":\"collateral_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"ForwarderNotContractAddressError\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"WrapAndDeposit\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DSU\",\"outputs\":[{\"internalType\":\"Token18\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"USDC\",\"outputs\":[{\"internalType\":\"Token6\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"batcher\",\"outputs\":[{\"internalType\":\"contract IBatcher\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"collateral\",\"outputs\":[{\"internalType\":\"contract ICollateral\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"wrapAndDeposit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"constructor\":{\"params\":{\"batcher_\":\"The USDC-to-DSU batcher contract address\",\"collateral_\":\"The perennial collateral contract address\",\"dsu_\":\"The DSU token contract address\",\"usdc_\":\"The USDC token contract address\"}},\"wrapAndDeposit(address,address,uint256)\":{\"params\":{\"account\":\"Account to deposit the collateral for\",\"amount\":\"18 decimals-normalized stablecoin (USDC, DSU) value of collateral to deposit\",\"product\":\"Product to credit the collateral to\"}}},\"stateVariables\":{\"batcher\":{\"details\":\"Contract that wraps USDC to DSU\"},\"collateral\":{\"details\":\"Contract managing state for collateral accounts in the protocol\"}},\"title\":\"Forwarder\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"constructor\":{\"notice\":\"Initializes the contract state\"},\"wrapAndDeposit(address,address,uint256)\":{\"notice\":\"Pulls `amount` of USDC from `msg.sender`'s balance, wraps it as DSU, and deposits it as collateral to `account`'s `product` account\"}},\"notice\":\"Facilitates collateral deposits to the protocol where the amount is supplied in USDC then wrapped as DSU before being deposited.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/forwarder/Forwarder.sol\":\"Forwarder\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@equilibria/emptyset-batcher/interfaces/IBatcher.sol\":{\"content\":\"//SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\n\\ninterface IBatcher {\\n event Wrap(address indexed to, UFixed18 amount);\\n event Unwrap(address indexed to, UFixed18 amount);\\n event Rebalance(UFixed18 newMinted, UFixed18 newRedeemed);\\n event Close(UFixed18 amount);\\n\\n error BatcherNotImplementedError();\\n error BatcherBalanceMismatchError(UFixed18 oldBalance, UFixed18 newBalance);\\n\\n function totalBalance() external view returns (UFixed18);\\n function wrap(UFixed18 amount, address to) external;\\n function unwrap(UFixed18 amount, address to) external;\\n function rebalance() external;\\n}\\n\",\"keccak256\":\"0x5d49c13991d92df22f77377b4ae98149bdfb588e04a084e00feec70569499c8b\",\"license\":\"Apache-2.0\"},\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\n\\ninterface IOracleProvider {\\n /// @dev A singular oracle version with its corresponding data\\n struct OracleVersion {\\n /// @dev The iterative version\\n uint256 version;\\n\\n /// @dev the timestamp of the oracle update\\n uint256 timestamp;\\n\\n /// @dev The oracle price of the corresponding version\\n Fixed18 price;\\n }\\n\\n function sync() external returns (OracleVersion memory);\\n function currentVersion() external view returns (OracleVersion memory);\\n function atVersion(uint256 oracleVersion) external view returns (OracleVersion memory);\\n}\\n\",\"keccak256\":\"0xde0f20d468ba8b91addfc356e13f2c74a4dc8abe68be323942217c723775d9c1\",\"license\":\"Apache-2.0\"},\"@equilibria/root/curve/CurveMath.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"../number/types/UFixed18.sol\\\";\\nimport \\\"../number/types/Fixed18.sol\\\";\\n\\n/**\\n * @title CurveMath\\n * @notice Library for managing math operations for utilization curves.\\n */\\nlibrary CurveMath {\\n error CurveMathOutOfBoundsError();\\n\\n /**\\n * @notice Computes a linear interpolation between two points\\n * @param startX First point's x-coordinate\\n * @param startY First point's y-coordinate\\n * @param endX Second point's x-coordinate\\n * @param endY Second point's y-coordinate\\n * @param targetX x-coordinate to interpolate\\n * @return y-coordinate for `targetX` along the line from (`startX`, `startY`) -> (`endX`, `endY`)\\n */\\n function linearInterpolation(\\n UFixed18 startX,\\n Fixed18 startY,\\n UFixed18 endX,\\n Fixed18 endY,\\n UFixed18 targetX\\n ) internal pure returns (Fixed18) {\\n if (targetX.lt(startX) || targetX.gt(endX)) revert CurveMathOutOfBoundsError();\\n\\n UFixed18 xRange = endX.sub(startX);\\n Fixed18 yRange = endY.sub(startY);\\n UFixed18 xRatio = targetX.sub(startX).div(xRange);\\n return yRange.mul(Fixed18Lib.from(xRatio)).add(startY);\\n }\\n}\\n\",\"keccak256\":\"0x60d159f9ddf0dbe81124ecad58bba734b4cf82877637ff8d9d7f3e92f2da4ded\",\"license\":\"Apache-2.0\"},\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"../CurveMath.sol\\\";\\nimport \\\"../../number/types/PackedUFixed18.sol\\\";\\nimport \\\"../../number/types/PackedFixed18.sol\\\";\\n\\n/// @dev JumpRateUtilizationCurve type\\nstruct JumpRateUtilizationCurve {\\n PackedFixed18 minRate;\\n PackedFixed18 maxRate;\\n PackedFixed18 targetRate;\\n PackedUFixed18 targetUtilization;\\n}\\nusing JumpRateUtilizationCurveLib for JumpRateUtilizationCurve global;\\ntype JumpRateUtilizationCurveStorage is bytes32;\\nusing JumpRateUtilizationCurveStorageLib for JumpRateUtilizationCurveStorage global;\\n\\n/**\\n * @title JumpRateUtilizationCurveLib\\n * @notice Library for the Jump Rate utilization curve type\\n */\\nlibrary JumpRateUtilizationCurveLib {\\n /**\\n * @notice Computes the corresponding rate for a utilization ratio\\n * @param utilization The utilization ratio\\n * @return The corresponding rate\\n */\\n function compute(JumpRateUtilizationCurve memory self, UFixed18 utilization) internal pure returns (Fixed18) {\\n UFixed18 targetUtilization = self.targetUtilization.unpack();\\n if (utilization.lt(targetUtilization)) {\\n return CurveMath.linearInterpolation(\\n UFixed18Lib.ZERO,\\n self.minRate.unpack(),\\n targetUtilization,\\n self.targetRate.unpack(),\\n utilization\\n );\\n }\\n if (utilization.lt(UFixed18Lib.ONE)) {\\n return CurveMath.linearInterpolation(\\n targetUtilization,\\n self.targetRate.unpack(),\\n UFixed18Lib.ONE,\\n self.maxRate.unpack(),\\n utilization\\n );\\n }\\n return self.maxRate.unpack();\\n }\\n}\\n\\nlibrary JumpRateUtilizationCurveStorageLib {\\n function read(JumpRateUtilizationCurveStorage self) internal view returns (JumpRateUtilizationCurve memory) {\\n return _storagePointer(self);\\n }\\n\\n function store(JumpRateUtilizationCurveStorage self, JumpRateUtilizationCurve memory value) internal {\\n JumpRateUtilizationCurve storage storagePointer = _storagePointer(self);\\n\\n storagePointer.minRate = value.minRate;\\n storagePointer.maxRate = value.maxRate;\\n storagePointer.targetRate = value.targetRate;\\n storagePointer.targetUtilization = value.targetUtilization;\\n }\\n\\n function _storagePointer(JumpRateUtilizationCurveStorage self)\\n private pure returns (JumpRateUtilizationCurve storage pointer) {\\n assembly { pointer.slot := self }\\n }\\n}\",\"keccak256\":\"0xae202813874bc306d51b3dab8194c86f6483bb20bf1f673ddaee16aa8de567ff\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/Fixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SignedMath.sol\\\";\\nimport \\\"./UFixed18.sol\\\";\\nimport \\\"./PackedFixed18.sol\\\";\\n\\n/// @dev Fixed18 type\\ntype Fixed18 is int256;\\nusing Fixed18Lib for Fixed18 global;\\ntype Fixed18Storage is bytes32;\\nusing Fixed18StorageLib for Fixed18Storage global;\\n\\n/**\\n * @title Fixed18Lib\\n * @notice Library for the signed fixed-decimal type.\\n */\\nlibrary Fixed18Lib {\\n error Fixed18OverflowError(uint256 value);\\n error Fixed18PackingOverflowError(int256 value);\\n error Fixed18PackingUnderflowError(int256 value);\\n\\n int256 private constant BASE = 1e18;\\n Fixed18 public constant ZERO = Fixed18.wrap(0);\\n Fixed18 public constant ONE = Fixed18.wrap(BASE);\\n Fixed18 public constant NEG_ONE = Fixed18.wrap(-1 * BASE);\\n Fixed18 public constant MAX = Fixed18.wrap(type(int256).max);\\n Fixed18 public constant MIN = Fixed18.wrap(type(int256).min);\\n\\n /**\\n * @notice Creates a signed fixed-decimal from an unsigned fixed-decimal\\n * @param a Unsigned fixed-decimal\\n * @return New signed fixed-decimal\\n */\\n function from(UFixed18 a) internal pure returns (Fixed18) {\\n uint256 value = UFixed18.unwrap(a);\\n if (value > uint256(type(int256).max)) revert Fixed18OverflowError(value);\\n return Fixed18.wrap(int256(value));\\n }\\n\\n /**\\n * @notice Creates a signed fixed-decimal from a sign and an unsigned fixed-decimal\\n * @param s Sign\\n * @param m Unsigned fixed-decimal magnitude\\n * @return New signed fixed-decimal\\n */\\n function from(int256 s, UFixed18 m) internal pure returns (Fixed18) {\\n if (s > 0) return from(m);\\n if (s < 0) return Fixed18.wrap(-1 * Fixed18.unwrap(from(m)));\\n return ZERO;\\n }\\n\\n /**\\n * @notice Creates a signed fixed-decimal from a signed integer\\n * @param a Signed number\\n * @return New signed fixed-decimal\\n */\\n function from(int256 a) internal pure returns (Fixed18) {\\n return Fixed18.wrap(a * BASE);\\n }\\n\\n /**\\n * @notice Creates a packed signed fixed-decimal from an signed fixed-decimal\\n * @param a signed fixed-decimal\\n * @return New packed signed fixed-decimal\\n */\\n function pack(Fixed18 a) internal pure returns (PackedFixed18) {\\n int256 value = Fixed18.unwrap(a);\\n if (value > type(int128).max) revert Fixed18PackingOverflowError(value);\\n if (value < type(int128).min) revert Fixed18PackingUnderflowError(value);\\n return PackedFixed18.wrap(int128(value));\\n }\\n\\n /**\\n * @notice Returns whether the signed fixed-decimal is equal to zero.\\n * @param a Signed fixed-decimal\\n * @return Whether the signed fixed-decimal is zero.\\n */\\n function isZero(Fixed18 a) internal pure returns (bool) {\\n return Fixed18.unwrap(a) == 0;\\n }\\n\\n /**\\n * @notice Adds two signed fixed-decimals `a` and `b` together\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Resulting summed signed fixed-decimal\\n */\\n function add(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) + Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Subtracts signed fixed-decimal `b` from `a`\\n * @param a Signed fixed-decimal to subtract from\\n * @param b Signed fixed-decimal to subtract\\n * @return Resulting subtracted signed fixed-decimal\\n */\\n function sub(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) - Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Multiplies two signed fixed-decimals `a` and `b` together\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Resulting multiplied signed fixed-decimal\\n */\\n function mul(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / BASE);\\n }\\n\\n /**\\n * @notice Divides signed fixed-decimal `a` by `b`\\n * @param a Signed fixed-decimal to divide\\n * @param b Signed fixed-decimal to divide by\\n * @return Resulting divided signed fixed-decimal\\n */\\n function div(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * BASE / Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0`, `MAX` for `n/0`, and `MIN` for `-n/0`.\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function unsafeDiv(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n if (isZero(b)) {\\n if (gt(a, ZERO)) return MAX;\\n if (lt(a, ZERO)) return MIN;\\n return ONE;\\n } else {\\n return div(a, b);\\n }\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First signed fixed-decimal\\n * @param b Signed number to multiply by\\n * @param c Signed number to divide by\\n * @return Resulting computation\\n */\\n function muldiv(Fixed18 a, int256 b, int256 c) internal pure returns (Fixed18) {\\n return muldiv(a, Fixed18.wrap(b), Fixed18.wrap(c));\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First signed fixed-decimal\\n * @param b Signed fixed-decimal to multiply by\\n * @param c Signed fixed-decimal to divide by\\n * @return Resulting computation\\n */\\n function muldiv(Fixed18 a, Fixed18 b, Fixed18 c) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / Fixed18.unwrap(c));\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is equal to `b`\\n */\\n function eq(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 1;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is greater than `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is greater than `b`\\n */\\n function gt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 2;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is less than `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is less than `b`\\n */\\n function lt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 0;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is greater than or equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is greater than or equal to `b`\\n */\\n function gte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return gt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is less than or equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is less than or equal to `b`\\n */\\n function lte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return lt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Compares the signed fixed-decimals `a` and `b`\\n * @dev Returns: 2 for greater than\\n * 1 for equal to\\n * 0 for less than\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Compare result of `a` and `b`\\n */\\n function compare(Fixed18 a, Fixed18 b) internal pure returns (uint256) {\\n (int256 au, int256 bu) = (Fixed18.unwrap(a), Fixed18.unwrap(b));\\n if (au > bu) return 2;\\n if (au < bu) return 0;\\n return 1;\\n }\\n\\n /**\\n * @notice Returns a signed fixed-decimal representing the ratio of `a` over `b`\\n * @param a First signed number\\n * @param b Second signed number\\n * @return Ratio of `a` over `b`\\n */\\n function ratio(int256 a, int256 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(a * BASE / b);\\n }\\n\\n /**\\n * @notice Returns the minimum of signed fixed-decimals `a` and `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Minimum of `a` and `b`\\n */\\n function min(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(SignedMath.min(Fixed18.unwrap(a), Fixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Returns the maximum of signed fixed-decimals `a` and `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Maximum of `a` and `b`\\n */\\n function max(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(SignedMath.max(Fixed18.unwrap(a), Fixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Converts the signed fixed-decimal into an integer, truncating any decimal portion\\n * @param a Signed fixed-decimal\\n * @return Truncated signed number\\n */\\n function truncate(Fixed18 a) internal pure returns (int256) {\\n return Fixed18.unwrap(a) / BASE;\\n }\\n\\n /**\\n * @notice Returns the sign of the signed fixed-decimal\\n * @dev Returns: -1 for negative\\n * 0 for zero\\n * 1 for positive\\n * @param a Signed fixed-decimal\\n * @return Sign of the signed fixed-decimal\\n */\\n function sign(Fixed18 a) internal pure returns (int256) {\\n if (Fixed18.unwrap(a) > 0) return 1;\\n if (Fixed18.unwrap(a) < 0) return -1;\\n return 0;\\n }\\n\\n /**\\n * @notice Returns the absolute value of the signed fixed-decimal\\n * @param a Signed fixed-decimal\\n * @return Absolute value of the signed fixed-decimal\\n */\\n function abs(Fixed18 a) internal pure returns (UFixed18) {\\n return UFixed18.wrap(SignedMath.abs(Fixed18.unwrap(a)));\\n }\\n}\\n\\nlibrary Fixed18StorageLib {\\n function read(Fixed18Storage self) internal view returns (Fixed18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(Fixed18Storage self, Fixed18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x613587461ef3437ef33229cdda7d34ea746278721baf06e20b2e43977f43174d\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/PackedFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"./Fixed18.sol\\\";\\n\\n/// @dev PackedFixed18 type\\ntype PackedFixed18 is int128;\\nusing PackedFixed18Lib for PackedFixed18 global;\\n\\n/**\\n * @title PackedFixed18Lib\\n * @dev A packed version of the Fixed18 which takes up half the storage space (two PackedFixed18 can be packed\\n * into a single slot). Only valid within the range -1.7014118e+20 <= x <= 1.7014118e+20.\\n * @notice Library for the packed signed fixed-decimal type.\\n */\\nlibrary PackedFixed18Lib {\\n PackedFixed18 public constant MAX = PackedFixed18.wrap(type(int128).max);\\n PackedFixed18 public constant MIN = PackedFixed18.wrap(type(int128).min);\\n\\n /**\\n * @notice Creates an unpacked signed fixed-decimal from a packed signed fixed-decimal\\n * @param self packed signed fixed-decimal\\n * @return New unpacked signed fixed-decimal\\n */\\n function unpack(PackedFixed18 self) internal pure returns (Fixed18) {\\n return Fixed18.wrap(int256(PackedFixed18.unwrap(self)));\\n }\\n}\\n\",\"keccak256\":\"0xb52960cc8e3132e45d342bbbb1c6a96219022cd8557997933bd8250170268b64\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/PackedUFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"./UFixed18.sol\\\";\\n\\n/// @dev PackedUFixed18 type\\ntype PackedUFixed18 is uint128;\\nusing PackedUFixed18Lib for PackedUFixed18 global;\\n\\n/**\\n * @title PackedUFixed18Lib\\n * @dev A packed version of the UFixed18 which takes up half the storage space (two PackedUFixed18 can be packed\\n * into a single slot). Only valid within the range 0 <= x <= 3.4028237e+20.\\n * @notice Library for the packed unsigned fixed-decimal type.\\n */\\nlibrary PackedUFixed18Lib {\\n PackedUFixed18 public constant MAX = PackedUFixed18.wrap(type(uint128).max);\\n\\n /**\\n * @notice Creates an unpacked unsigned fixed-decimal from a packed unsigned fixed-decimal\\n * @param self packed unsigned fixed-decimal\\n * @return New unpacked unsigned fixed-decimal\\n */\\n function unpack(PackedUFixed18 self) internal pure returns (UFixed18) {\\n return UFixed18.wrap(uint256(PackedUFixed18.unwrap(self)));\\n }\\n}\\n\",\"keccak256\":\"0xb5c5cd32d6530b2fe75228b6be32ebcb7762f6d7988b85a6b85a289ce8256d51\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/UFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"./Fixed18.sol\\\";\\nimport \\\"./PackedUFixed18.sol\\\";\\n\\n/// @dev UFixed18 type\\ntype UFixed18 is uint256;\\nusing UFixed18Lib for UFixed18 global;\\ntype UFixed18Storage is bytes32;\\nusing UFixed18StorageLib for UFixed18Storage global;\\n\\n/**\\n * @title UFixed18Lib\\n * @notice Library for the unsigned fixed-decimal type.\\n */\\nlibrary UFixed18Lib {\\n error UFixed18UnderflowError(int256 value);\\n error UFixed18PackingOverflowError(uint256 value);\\n\\n uint256 private constant BASE = 1e18;\\n UFixed18 public constant ZERO = UFixed18.wrap(0);\\n UFixed18 public constant ONE = UFixed18.wrap(BASE);\\n UFixed18 public constant MAX = UFixed18.wrap(type(uint256).max);\\n\\n /**\\n * @notice Creates a unsigned fixed-decimal from a signed fixed-decimal\\n * @param a Signed fixed-decimal\\n * @return New unsigned fixed-decimal\\n */\\n function from(Fixed18 a) internal pure returns (UFixed18) {\\n int256 value = Fixed18.unwrap(a);\\n if (value < 0) revert UFixed18UnderflowError(value);\\n return UFixed18.wrap(uint256(value));\\n }\\n\\n /**\\n * @notice Creates a unsigned fixed-decimal from a unsigned integer\\n * @param a Unsigned number\\n * @return New unsigned fixed-decimal\\n */\\n function from(uint256 a) internal pure returns (UFixed18) {\\n return UFixed18.wrap(a * BASE);\\n }\\n\\n /**\\n * @notice Creates a packed unsigned fixed-decimal from an unsigned fixed-decimal\\n * @param a unsigned fixed-decimal\\n * @return New packed unsigned fixed-decimal\\n */\\n function pack(UFixed18 a) internal pure returns (PackedUFixed18) {\\n uint256 value = UFixed18.unwrap(a);\\n if (value > type(uint128).max) revert UFixed18PackingOverflowError(value);\\n return PackedUFixed18.wrap(uint128(value));\\n }\\n\\n /**\\n * @notice Returns whether the unsigned fixed-decimal is equal to zero.\\n * @param a Unsigned fixed-decimal\\n * @return Whether the unsigned fixed-decimal is zero.\\n */\\n function isZero(UFixed18 a) internal pure returns (bool) {\\n return UFixed18.unwrap(a) == 0;\\n }\\n\\n /**\\n * @notice Adds two unsigned fixed-decimals `a` and `b` together\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Resulting summed unsigned fixed-decimal\\n */\\n function add(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) + UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Subtracts unsigned fixed-decimal `b` from `a`\\n * @param a Unsigned fixed-decimal to subtract from\\n * @param b Unsigned fixed-decimal to subtract\\n * @return Resulting subtracted unsigned fixed-decimal\\n */\\n function sub(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) - UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Multiplies two unsigned fixed-decimals `a` and `b` together\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Resulting multiplied unsigned fixed-decimal\\n */\\n function mul(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / BASE);\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function div(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * BASE / UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0` and `MAX` for `n/0`.\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function unsafeDiv(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n if (isZero(b)) {\\n return isZero(a) ? ONE : MAX;\\n } else {\\n return div(a, b);\\n }\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First unsigned fixed-decimal\\n * @param b Unsigned number to multiply by\\n * @param c Unsigned number to divide by\\n * @return Resulting computation\\n */\\n function muldiv(UFixed18 a, uint256 b, uint256 c) internal pure returns (UFixed18) {\\n return muldiv(a, UFixed18.wrap(b), UFixed18.wrap(c));\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First unsigned fixed-decimal\\n * @param b Unsigned fixed-decimal to multiply by\\n * @param c Unsigned fixed-decimal to divide by\\n * @return Resulting computation\\n */\\n function muldiv(UFixed18 a, UFixed18 b, UFixed18 c) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / UFixed18.unwrap(c));\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is equal to `b`\\n */\\n function eq(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 1;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is greater than `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is greater than `b`\\n */\\n function gt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 2;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is less than `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is less than `b`\\n */\\n function lt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 0;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is greater than or equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is greater than or equal to `b`\\n */\\n function gte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return gt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is less than or equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is less than or equal to `b`\\n */\\n function lte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return lt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Compares the unsigned fixed-decimals `a` and `b`\\n * @dev Returns: 2 for greater than\\n * 1 for equal to\\n * 0 for less than\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Compare result of `a` and `b`\\n */\\n function compare(UFixed18 a, UFixed18 b) internal pure returns (uint256) {\\n (uint256 au, uint256 bu) = (UFixed18.unwrap(a), UFixed18.unwrap(b));\\n if (au > bu) return 2;\\n if (au < bu) return 0;\\n return 1;\\n }\\n\\n /**\\n * @notice Returns a unsigned fixed-decimal representing the ratio of `a` over `b`\\n * @param a First unsigned number\\n * @param b Second unsigned number\\n * @return Ratio of `a` over `b`\\n */\\n function ratio(uint256 a, uint256 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(a * BASE / b);\\n }\\n\\n /**\\n * @notice Returns the minimum of unsigned fixed-decimals `a` and `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Minimum of `a` and `b`\\n */\\n function min(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(Math.min(UFixed18.unwrap(a), UFixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Returns the maximum of unsigned fixed-decimals `a` and `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Maximum of `a` and `b`\\n */\\n function max(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(Math.max(UFixed18.unwrap(a), UFixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Converts the unsigned fixed-decimal into an integer, truncating any decimal portion\\n * @param a Unsigned fixed-decimal\\n * @return Truncated unsigned number\\n */\\n function truncate(UFixed18 a) internal pure returns (uint256) {\\n return UFixed18.unwrap(a) / BASE;\\n }\\n}\\n\\nlibrary UFixed18StorageLib {\\n function read(UFixed18Storage self) internal view returns (UFixed18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(UFixed18Storage self, UFixed18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x8ebef1e6c717f565b9ed545a876b5692b4007e6485c99f39d363f7405e591792\",\"license\":\"Apache-2.0\"},\"@equilibria/root/token/types/Token18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"../../number/types/UFixed18.sol\\\";\\n\\n/// @dev Token18\\ntype Token18 is address;\\nusing Token18Lib for Token18 global;\\ntype Token18Storage is bytes32;\\nusing Token18StorageLib for Token18Storage global;\\n\\n/**\\n * @title Token18Lib\\n * @notice Library to manage 18-decimal ERC20s that is compliant with the fixed-decimal types.\\n * @dev Maintains significant gas savings over other Token implementations since no conversion take place\\n */\\nlibrary Token18Lib {\\n using SafeERC20 for IERC20;\\n\\n Token18 public constant ZERO = Token18.wrap(address(0));\\n\\n /**\\n * @notice Returns whether a token is the zero address\\n * @param self Token to check for\\n * @return Whether the token is the zero address\\n */\\n function isZero(Token18 self) internal pure returns (bool) {\\n return Token18.unwrap(self) == Token18.unwrap(ZERO);\\n }\\n\\n /**\\n * @notice Returns whether the two tokens are equal\\n * @param a First token to compare\\n * @param b Second token to compare\\n * @return Whether the two tokens are equal\\n */\\n function eq(Token18 a, Token18 b) internal pure returns (bool) {\\n return Token18.unwrap(a) == Token18.unwrap(b);\\n }\\n\\n /**\\n * @notice Approves `grantee` to spend infinite tokens from the caller\\n * @param self Token to transfer\\n * @param grantee Address to allow spending\\n */\\n function approve(Token18 self, address grantee) internal {\\n IERC20(Token18.unwrap(self)).safeApprove(grantee, type(uint256).max);\\n }\\n\\n /**\\n * @notice Approves `grantee` to spend `amount` tokens from the caller\\n * @dev There are important race conditions to be aware of when using this function\\n with values other than 0. This will revert if moving from non-zero to non-zero amounts\\n See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/a55b7d13722e7ce850b626da2313f3e66ca1d101/contracts/token/ERC20/IERC20.sol#L57\\n * @param self Token to transfer\\n * @param grantee Address to allow spending\\n * @param amount Amount of tokens to approve to spend\\n */\\n function approve(Token18 self, address grantee, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeApprove(grantee, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers all held tokens from the caller to the `recipient`\\n * @param self Token to transfer\\n * @param recipient Address to receive the tokens\\n */\\n function push(Token18 self, address recipient) internal {\\n push(self, recipient, balanceOf(self, address(this)));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the caller to the `recipient`\\n * @param self Token to transfer\\n * @param recipient Address to transfer tokens to\\n * @param amount Amount of tokens to transfer\\n */\\n function push(Token18 self, address recipient, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransfer(recipient, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the `benefactor` to the caller\\n * @dev Reverts if trying to pull Ether\\n * @param self Token to transfer\\n * @param benefactor Address to transfer tokens from\\n * @param amount Amount of tokens to transfer\\n */\\n function pull(Token18 self, address benefactor, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, address(this), UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the `benefactor` to `recipient`\\n * @dev Reverts if trying to pull Ether\\n * @param self Token to transfer\\n * @param benefactor Address to transfer tokens from\\n * @param recipient Address to transfer tokens to\\n * @param amount Amount of tokens to transfer\\n */\\n function pullTo(Token18 self, address benefactor, address recipient, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, recipient, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Returns the name of the token\\n * @param self Token to check for\\n * @return Token name\\n */\\n function name(Token18 self) internal view returns (string memory) {\\n return IERC20Metadata(Token18.unwrap(self)).name();\\n }\\n\\n /**\\n * @notice Returns the symbol of the token\\n * @param self Token to check for\\n * @return Token symbol\\n */\\n function symbol(Token18 self) internal view returns (string memory) {\\n return IERC20Metadata(Token18.unwrap(self)).symbol();\\n }\\n\\n /**\\n * @notice Returns the `self` token balance of the caller\\n * @param self Token to check for\\n * @return Token balance of the caller\\n */\\n function balanceOf(Token18 self) internal view returns (UFixed18) {\\n return balanceOf(self, address(this));\\n }\\n\\n /**\\n * @notice Returns the `self` token balance of `account`\\n * @param self Token to check for\\n * @param account Account to check\\n * @return Token balance of the account\\n */\\n function balanceOf(Token18 self, address account) internal view returns (UFixed18) {\\n return UFixed18.wrap(IERC20(Token18.unwrap(self)).balanceOf(account));\\n }\\n}\\n\\nlibrary Token18StorageLib {\\n function read(Token18Storage self) internal view returns (Token18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(Token18Storage self, Token18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x6b12afaece814f0ab186200a4729e93eb685a21d3e9b5a3372ff283a7ad5dc23\",\"license\":\"Apache-2.0\"},\"@equilibria/root/token/types/Token6.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"../../number/types/UFixed18.sol\\\";\\n\\n/// @dev Token6\\ntype Token6 is address;\\nusing Token6Lib for Token6 global;\\ntype Token6Storage is bytes32;\\nusing Token6StorageLib for Token6Storage global;\\n\\n/**\\n * @title Token6Lib\\n * @notice Library to manage 6-decimal ERC20s that is compliant with the fixed-decimal types.\\n * @dev Automatically converts from Base-6 token amounts to Base-18 UFixed18 amounts, with optional rounding\\n */\\nlibrary Token6Lib {\\n using SafeERC20 for IERC20;\\n\\n Token6 public constant ZERO = Token6.wrap(address(0));\\n\\n uint256 private constant OFFSET = 1e12;\\n\\n /**\\n * @notice Returns whether a token is the zero address\\n * @param self Token to check for\\n * @return Whether the token is the zero address\\n */\\n function isZero(Token6 self) internal pure returns (bool) {\\n return Token6.unwrap(self) == Token6.unwrap(ZERO);\\n }\\n\\n /**\\n * @notice Returns whether the two tokens are equal\\n * @param a First token to compare\\n * @param b Second token to compare\\n * @return Whether the two tokens are equal\\n */\\n function eq(Token6 a, Token6 b) internal pure returns (bool) {\\n return Token6.unwrap(a) == Token6.unwrap(b);\\n }\\n\\n /**\\n * @notice Approves `grantee` to spend infinite tokens from the caller\\n * @param self Token to transfer\\n * @param grantee Address to allow spending\\n */\\n function approve(Token6 self, address grantee) internal {\\n IERC20(Token6.unwrap(self)).safeApprove(grantee, type(uint256).max);\\n }\\n\\n /**\\n * @notice Approves `grantee` to spend `amount` tokens from the caller\\n * @dev There are important race conditions to be aware of when using this function\\n with values other than 0. This will revert if moving from non-zero to non-zero amounts\\n See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/a55b7d13722e7ce850b626da2313f3e66ca1d101/contracts/token/ERC20/IERC20.sol#L57\\n * @param self Token to transfer\\n * @param grantee Address to allow spending\\n * @param amount Amount of tokens to approve to spend\\n */\\n function approve(Token6 self, address grantee, UFixed18 amount) internal {\\n IERC20(Token6.unwrap(self)).safeApprove(grantee, toTokenAmount(amount, false));\\n }\\n\\n /**\\n * @notice Approves `grantee` to spend `amount` tokens from the caller\\n * @dev There are important race conditions to be aware of when using this function\\n with values other than 0. This will revert if moving from non-zero to non-zero amounts\\n See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/a55b7d13722e7ce850b626da2313f3e66ca1d101/contracts/token/ERC20/IERC20.sol#L57\\n * @param self Token to transfer\\n * @param grantee Address to allow spending\\n * @param amount Amount of tokens to approve to spend\\n * @param roundUp Whether to round decimal token amount up to the next unit\\n */\\n function approve(Token6 self, address grantee, UFixed18 amount, bool roundUp) internal {\\n IERC20(Token6.unwrap(self)).safeApprove(grantee, toTokenAmount(amount, roundUp));\\n }\\n\\n /**\\n * @notice Transfers all held tokens from the caller to the `recipient`\\n * @param self Token to transfer\\n * @param recipient Address to receive the tokens\\n */\\n function push(Token6 self, address recipient) internal {\\n push(self, recipient, balanceOf(self, address(this)));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the caller to the `recipient`\\n * @param self Token to transfer\\n * @param recipient Address to transfer tokens to\\n * @param amount Amount of tokens to transfer\\n */\\n function push(Token6 self, address recipient, UFixed18 amount) internal {\\n IERC20(Token6.unwrap(self)).safeTransfer(recipient, toTokenAmount(amount, false));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the caller to the `recipient`\\n * @param self Token to transfer\\n * @param recipient Address to transfer tokens to\\n * @param amount Amount of tokens to transfer\\n * @param roundUp Whether to round decimal token amount up to the next unit\\n */\\n function push(Token6 self, address recipient, UFixed18 amount, bool roundUp) internal {\\n IERC20(Token6.unwrap(self)).safeTransfer(recipient, toTokenAmount(amount, roundUp));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the `benefactor` to the caller\\n * @dev Reverts if trying to pull Ether\\n * @param self Token to transfer\\n * @param benefactor Address to transfer tokens from\\n * @param amount Amount of tokens to transfer\\n */\\n function pull(Token6 self, address benefactor, UFixed18 amount) internal {\\n IERC20(Token6.unwrap(self)).safeTransferFrom(benefactor, address(this), toTokenAmount(amount, false));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the `benefactor` to the caller\\n * @dev Reverts if trying to pull Ether\\n * @param self Token to transfer\\n * @param benefactor Address to transfer tokens from\\n * @param amount Amount of tokens to transfer\\n * @param roundUp Whether to round decimal token amount up to the next unit\\n */\\n function pull(Token6 self, address benefactor, UFixed18 amount, bool roundUp) internal {\\n IERC20(Token6.unwrap(self)).safeTransferFrom(benefactor, address(this), toTokenAmount(amount, roundUp));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the `benefactor` to `recipient`\\n * @dev Reverts if trying to pull Ether\\n * @param self Token to transfer\\n * @param benefactor Address to transfer tokens from\\n * @param recipient Address to transfer tokens to\\n * @param amount Amount of tokens to transfer\\n */\\n function pullTo(Token6 self, address benefactor, address recipient, UFixed18 amount) internal {\\n IERC20(Token6.unwrap(self)).safeTransferFrom(benefactor, recipient, toTokenAmount(amount, false));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the `benefactor` to `recipient`\\n * @dev Reverts if trying to pull Ether\\n * @param self Token to transfer\\n * @param benefactor Address to transfer tokens from\\n * @param recipient Address to transfer tokens to\\n * @param amount Amount of tokens to transfer\\n * @param roundUp Whether to round decimal token amount up to the next unit\\n */\\n function pullTo(Token6 self, address benefactor, address recipient, UFixed18 amount, bool roundUp) internal {\\n IERC20(Token6.unwrap(self)).safeTransferFrom(benefactor, recipient, toTokenAmount(amount, roundUp));\\n }\\n\\n /**\\n * @notice Returns the name of the token\\n * @param self Token to check for\\n * @return Token name\\n */\\n function name(Token6 self) internal view returns (string memory) {\\n return IERC20Metadata(Token6.unwrap(self)).name();\\n }\\n\\n /**\\n * @notice Returns the symbol of the token\\n * @param self Token to check for\\n * @return Token symbol\\n */\\n function symbol(Token6 self) internal view returns (string memory) {\\n return IERC20Metadata(Token6.unwrap(self)).symbol();\\n }\\n\\n /**\\n * @notice Returns the `self` token balance of the caller\\n * @param self Token to check for\\n * @return Token balance of the caller\\n */\\n function balanceOf(Token6 self) internal view returns (UFixed18) {\\n return balanceOf(self, address(this));\\n }\\n\\n /**\\n * @notice Returns the `self` token balance of `account`\\n * @param self Token to check for\\n * @param account Account to check\\n * @return Token balance of the account\\n */\\n function balanceOf(Token6 self, address account) internal view returns (UFixed18) {\\n return fromTokenAmount(IERC20(Token6.unwrap(self)).balanceOf(account));\\n }\\n\\n /**\\n * @notice Converts the unsigned fixed-decimal amount into the token amount according to\\n * it's defined decimals\\n * @dev Provides the ability to \\\"round up\\\" the token amount which is useful in situations where\\n * are swapping one token for another and don't want to give away \\\"free\\\" units due to rounding\\n * errors in the favor of the user.\\n * @param amount Amount to convert\\n * @param roundUp Whether to round decimal token amount up to the next unit\\n * @return Normalized token amount\\n */\\n function toTokenAmount(UFixed18 amount, bool roundUp) private pure returns (uint256) {\\n return roundUp ? Math.ceilDiv(UFixed18.unwrap(amount), OFFSET) : UFixed18.unwrap(amount) / OFFSET;\\n }\\n\\n /**\\n * @notice Converts the token amount into the unsigned fixed-decimal amount according to\\n * it's defined decimals\\n * @param amount Token amount to convert\\n * @return Normalized unsigned fixed-decimal amount\\n */\\n function fromTokenAmount(uint256 amount) private pure returns (UFixed18) {\\n return UFixed18.wrap(amount * OFFSET);\\n }\\n}\\n\\nlibrary Token6StorageLib {\\n function read(Token6Storage self) internal view returns (Token6 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(Token6Storage self, Token6 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x5ec7bee45a0e13f91ab2399472cf11136496073ad470cd70244855e12a7b6e65\",\"license\":\"Apache-2.0\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\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 amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` 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(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\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\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 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 using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\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 function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc3d946432c0ddbb1f846a0d3985be71299df331b91d06732152117f62f0be2b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // 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\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return 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 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 up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a / b + (a % b == 0 ? 0 : 1);\\n }\\n}\\n\",\"keccak256\":\"0xc995bddbca1ae19788db9f8b61e63385edd3fddf89693b612d5abd1a275974d2\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SignedMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/SignedMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard signed math utilities missing in the Solidity language.\\n */\\nlibrary SignedMath {\\n /**\\n * @dev Returns the largest of two signed numbers.\\n */\\n function max(int256 a, int256 b) internal pure returns (int256) {\\n return 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 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 // must be unchecked in order to support `n = type(int256).min`\\n return uint256(n >= 0 ? n : -n);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb3ebde1c8d27576db912d87c3560dab14adfb9cd001be95890ec4ba035e652e7\",\"license\":\"MIT\"},\"contracts/forwarder/Forwarder.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"../interfaces/IForwarder.sol\\\";\\n\\n/**\\n * @title Forwarder\\n * @notice Facilitates collateral deposits to the protocol where the amount is supplied\\n * in USDC then wrapped as DSU before being deposited.\\n */\\ncontract Forwarder is IForwarder {\\n // @dev USDC stablecoin\\n Token6 public immutable USDC; // solhint-disable-line var-name-mixedcase\\n\\n // @dev DSU stablecoin\\n Token18 public immutable DSU; // solhint-disable-line var-name-mixedcase\\n\\n /// @dev Contract that wraps USDC to DSU\\n IBatcher public immutable batcher;\\n\\n /// @dev Contract managing state for collateral accounts in the protocol\\n ICollateral public immutable collateral;\\n\\n /**\\n * @notice Initializes the contract state\\n * @param usdc_ The USDC token contract address\\n * @param dsu_ The DSU token contract address\\n * @param batcher_ The USDC-to-DSU batcher contract address\\n * @param collateral_ The perennial collateral contract address\\n */\\n constructor(\\n Token6 usdc_,\\n Token18 dsu_,\\n IBatcher batcher_,\\n ICollateral collateral_\\n ) {\\n if (!Address.isContract(Token6.unwrap(usdc_))) revert ForwarderNotContractAddressError();\\n if (!Address.isContract(Token18.unwrap(dsu_))) revert ForwarderNotContractAddressError();\\n if (!Address.isContract(address(batcher_))) revert ForwarderNotContractAddressError();\\n if (!Address.isContract(address(collateral_))) revert ForwarderNotContractAddressError();\\n\\n USDC = usdc_;\\n DSU = dsu_;\\n batcher = batcher_;\\n collateral = collateral_;\\n\\n USDC.approve(address(batcher));\\n DSU.approve(address(collateral));\\n }\\n\\n /**\\n * @notice Pulls `amount` of USDC from `msg.sender`'s balance, wraps it as DSU,\\n and deposits it as collateral to `account`'s `product` account\\n * @param account Account to deposit the collateral for\\n * @param product Product to credit the collateral to\\n * @param amount 18 decimals-normalized stablecoin (USDC, DSU) value of collateral to deposit\\n */\\n function wrapAndDeposit(\\n address account,\\n IProduct product,\\n UFixed18 amount\\n ) external {\\n USDC.pull(msg.sender, amount, true);\\n batcher.wrap(amount, address(this));\\n collateral.depositTo(account, product, amount);\\n emit WrapAndDeposit(account, product, amount);\\n }\\n}\\n\",\"keccak256\":\"0x69355a55b01b5d1c259f0106600873a5c93f34774292c160f86a547bce86b881\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/ICollateral.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"./IController.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\n\\ninterface ICollateral {\\n event Deposit(address indexed user, IProduct indexed product, UFixed18 amount);\\n event Withdrawal(address indexed user, IProduct indexed product, UFixed18 amount);\\n event AccountSettle(IProduct indexed product, address indexed account, Fixed18 amount, UFixed18 newShortfall);\\n event ProductSettle(IProduct indexed product, UFixed18 protocolFee, UFixed18 productFee);\\n event Liquidation(address indexed user, IProduct indexed product, address liquidator, UFixed18 fee);\\n event ShortfallResolution(IProduct indexed product, UFixed18 amount);\\n event FeeClaim(address indexed account, UFixed18 amount);\\n\\n error CollateralCantLiquidate(UFixed18 totalMaintenance, UFixed18 totalCollateral);\\n error CollateralInsufficientCollateralError();\\n error CollateralUnderLimitError();\\n error CollateralZeroAddressError();\\n\\n function token() external view returns (Token18);\\n function fees(address account) external view returns (UFixed18);\\n function initialize(IController controller_) external;\\n function depositTo(address account, IProduct product, UFixed18 amount) external;\\n function withdrawTo(address account, IProduct product, UFixed18 amount) external;\\n function liquidate(address account, IProduct product) external;\\n function settleAccount(address account, Fixed18 amount) external;\\n function settleProduct(UFixed18 amount) external;\\n function collateral(address account, IProduct product) external view returns (UFixed18);\\n function collateral(IProduct product) external view returns (UFixed18);\\n function shortfall(IProduct product) external view returns (UFixed18);\\n function liquidatable(address account, IProduct product) external view returns (bool);\\n function liquidatableNext(address account, IProduct product) external view returns (bool);\\n function resolveShortfall(IProduct product, UFixed18 amount) external;\\n function claimFee() external;\\n}\\n\",\"keccak256\":\"0xa5e7fdda92702f748e6eb8701e522450035a98a05e5fc1cf66d51c52e397d914\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IContractPayoffProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\n\\ninterface IContractPayoffProvider {\\n function payoff(Fixed18 price) external view returns (Fixed18 payoff);\\n}\\n\",\"keccak256\":\"0xd73df106d032e976fd959ee6713240e36f54277ce5f215eaec8d5a2c6720a86b\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IController.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\\\";\\nimport \\\"./ICollateral.sol\\\";\\nimport \\\"./IIncentivizer.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\n\\ninterface IController {\\n /// @dev Coordinator of a one or many products\\n struct Coordinator {\\n /// @dev Pending owner of the product, can accept ownership\\n address pendingOwner;\\n\\n /// @dev Owner of the product, allowed to update select parameters\\n address owner;\\n\\n /// @dev Treasury of the product, collects fees\\n address treasury;\\n }\\n\\n event CollateralUpdated(ICollateral newCollateral);\\n event IncentivizerUpdated(IIncentivizer newIncentivizer);\\n event ProductBeaconUpdated(IBeacon newProductBeacon);\\n event ProtocolFeeUpdated(UFixed18 newProtocolFee);\\n event MinFundingFeeUpdated(UFixed18 newMinFundingFee);\\n event LiquidationFeeUpdated(UFixed18 newLiquidationFee);\\n event IncentivizationFeeUpdated(UFixed18 newIncentivizationFee);\\n event MinCollateralUpdated(UFixed18 newMinCollateral);\\n event ProgramsPerProductUpdated(uint256 newProgramsPerProduct);\\n event PauserUpdated(address newPauser);\\n event PausedUpdated(bool newPaused);\\n event CoordinatorPendingOwnerUpdated(uint256 indexed coordinatorId, address newPendingOwner);\\n event CoordinatorOwnerUpdated(uint256 indexed coordinatorId, address newOwner);\\n event CoordinatorTreasuryUpdated(uint256 indexed coordinatorId, address newTreasury);\\n event CoordinatorCreated(uint256 indexed coordinatorId, address owner);\\n event ProductCreated(IProduct indexed product, IProduct.ProductInfo productInfo);\\n\\n error ControllerNoZeroCoordinatorError();\\n error ControllerNotPauserError();\\n error ControllerNotOwnerError(uint256 controllerId);\\n error ControllerNotPendingOwnerError(uint256 controllerId);\\n error ControllerInvalidProtocolFeeError();\\n error ControllerInvalidMinFundingFeeError();\\n error ControllerInvalidLiquidationFeeError();\\n error ControllerInvalidIncentivizationFeeError();\\n error ControllerNotContractAddressError();\\n\\n function collateral() external view returns (ICollateral);\\n function incentivizer() external view returns (IIncentivizer);\\n function productBeacon() external view returns (IBeacon);\\n function coordinators(uint256 collateralId) external view returns (Coordinator memory);\\n function coordinatorFor(IProduct product) external view returns (uint256);\\n function protocolFee() external view returns (UFixed18);\\n function minFundingFee() external view returns (UFixed18);\\n function liquidationFee() external view returns (UFixed18);\\n function incentivizationFee() external view returns (UFixed18);\\n function minCollateral() external view returns (UFixed18);\\n function programsPerProduct() external view returns (uint256);\\n function pauser() external view returns (address);\\n function paused() external view returns (bool);\\n function initialize(ICollateral collateral_, IIncentivizer incentivizer_, IBeacon productBeacon_) external;\\n function createCoordinator() external returns (uint256);\\n function updateCoordinatorPendingOwner(uint256 coordinatorId, address newPendingOwner) external;\\n function acceptCoordinatorOwner(uint256 coordinatorId) external;\\n function updateCoordinatorTreasury(uint256 coordinatorId, address newTreasury) external;\\n function createProduct(uint256 coordinatorId, IProduct.ProductInfo calldata productInfo) external returns (IProduct);\\n function updateCollateral(ICollateral newCollateral) external;\\n function updateIncentivizer(IIncentivizer newIncentivizer) external;\\n function updateProductBeacon(IBeacon newProductBeacon) external;\\n function updateProtocolFee(UFixed18 newProtocolFee) external;\\n function updateMinFundingFee(UFixed18 newMinFundingFee) external;\\n function updateLiquidationFee(UFixed18 newLiquidationFee) external;\\n function updateIncentivizationFee(UFixed18 newIncentivizationFee) external;\\n function updateMinCollateral(UFixed18 newMinCollateral) external;\\n function updateProgramsPerProduct(uint256 newProductsPerProduct) external;\\n function updatePauser(address newPauser) external;\\n function updatePaused(bool newPaused) external;\\n function isProduct(IProduct product) external view returns (bool);\\n function owner() external view returns (address);\\n function owner(uint256 coordinatorId) external view returns (address);\\n function owner(IProduct product) external view returns (address);\\n function treasury() external view returns (address);\\n function treasury(uint256 coordinatorId) external view returns (address);\\n function treasury(IProduct product) external view returns (address);\\n}\\n\",\"keccak256\":\"0xaabd3740f2265499eea7aad9bd94f9892f53241e5dccce9a50c0e43ed2a6a7cc\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IForwarder.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"@equilibria/root/token/types/Token6.sol\\\";\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/emptyset-batcher/interfaces/IBatcher.sol\\\";\\nimport \\\"./ICollateral.sol\\\";\\n\\ninterface IForwarder {\\n error ForwarderNotContractAddressError();\\n\\n event WrapAndDeposit(address indexed account, IProduct indexed product, UFixed18 amount);\\n\\n function USDC() external view returns (Token6); // solhint-disable-line func-name-mixedcase\\n function DSU() external view returns (Token18); // solhint-disable-line func-name-mixedcase\\n function batcher() external view returns (IBatcher);\\n function collateral() external view returns (ICollateral);\\n function wrapAndDeposit(address account, IProduct product, UFixed18 amount) external;\\n}\\n\",\"keccak256\":\"0x800026180c5f82bba4ecd57d91dc2eb364326de8ca5ed0e56308620d58b6bc61\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IIncentivizer.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./types/ProgramInfo.sol\\\";\\nimport \\\"./IController.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\n\\ninterface IIncentivizer {\\n event ProgramCreated(IProduct indexed product, uint256 indexed programId, ProgramInfo programInfo, UFixed18 programFeeAmount);\\n event ProgramStarted(IProduct indexed product, uint256 indexed programId, uint256 version);\\n event ProgramComplete(IProduct indexed product, uint256 indexed programId, uint256 version);\\n event Claim(IProduct indexed product, address indexed account, uint256 indexed programId, UFixed18 amount);\\n event FeeClaim(Token18 indexed token, UFixed18 amount);\\n\\n error IncentivizerNotAllowedError(IProduct product);\\n error IncentivizerTooManyProgramsError();\\n error IncentivizerNotProgramOwnerError(IProduct product, uint256 programId);\\n error IncentivizerInvalidProgramError(IProduct product, uint256 programId);\\n error IncentivizerBatchClaimArgumentMismatchError();\\n\\n function programInfos(IProduct product, uint256 programId) external view returns (ProgramInfo memory);\\n function fees(Token18 token) external view returns (UFixed18);\\n function initialize(IController controller_) external;\\n function create(IProduct product, ProgramInfo calldata info) external returns (uint256);\\n function complete(IProduct product, uint256 programId) external;\\n function sync(IOracleProvider.OracleVersion memory currentOracleVersion) external;\\n function syncAccount(address account, IOracleProvider.OracleVersion memory currentOracleVersion) external;\\n function claim(IProduct product, uint256[] calldata programIds) external;\\n function claim(IProduct[] calldata products, uint256[][] calldata programIds) external;\\n function claimFee(Token18[] calldata tokens) external;\\n function active(IProduct product) external view returns (uint256);\\n function count(IProduct product) external view returns (uint256);\\n function unclaimed(IProduct product, address account, uint256 programId) external view returns (UFixed18);\\n function available(IProduct product, uint256 programId) external view returns (UFixed18);\\n function versionStarted(IProduct product, uint256 programId) external view returns (uint256);\\n function versionComplete(IProduct product, uint256 programId) external view returns (uint256);\\n function owner(IProduct product, uint256 programId) external view returns (address);\\n function treasury(IProduct product, uint256 programId) external view returns (address);\\n}\\n\",\"keccak256\":\"0x2f95de90dbb3ad35dbfef304f765a622bffff9229868d2898eca8d49c78e8c2c\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IParamProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\\\";\\n\\ninterface IParamProvider {\\n event MaintenanceUpdated(UFixed18 newMaintenance);\\n event FundingFeeUpdated(UFixed18 newFundingFee);\\n event MakerFeeUpdated(UFixed18 newMakerFee);\\n event TakerFeeUpdated(UFixed18 newTakerFee);\\n event MakerLimitUpdated(UFixed18 newMakerLimit);\\n event JumpRateUtilizationCurveUpdated(\\n Fixed18 minRate,\\n Fixed18 maxRate,\\n Fixed18 targetRate,\\n UFixed18 targetUtilization\\n );\\n\\n error ParamProviderInvalidMakerFee();\\n error ParamProviderInvalidTakerFee();\\n error ParamProviderInvalidFundingFee();\\n \\n function maintenance() external view returns (UFixed18);\\n function updateMaintenance(UFixed18 newMaintenance) external;\\n function fundingFee() external view returns (UFixed18);\\n function updateFundingFee(UFixed18 newFundingFee) external;\\n function makerFee() external view returns (UFixed18);\\n function updateMakerFee(UFixed18 newMakerFee) external;\\n function takerFee() external view returns (UFixed18);\\n function updateTakerFee(UFixed18 newTakerFee) external;\\n function makerLimit() external view returns (UFixed18);\\n function updateMakerLimit(UFixed18 newMakerLimit) external;\\n function utilizationCurve() external view returns (JumpRateUtilizationCurve memory);\\n function updateUtilizationCurve(JumpRateUtilizationCurve memory newUtilizationCurve) external;\\n}\\n\",\"keccak256\":\"0x2e2d40d0cf55f167118867e41f740b9b40614d05da50fc9bc33a8cede3eaf03e\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IPayoffProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\n\\ninterface IPayoffProvider {\\n error PayoffProviderInvalidOracle();\\n error PayoffProviderInvalidPayoffDefinitionError();\\n\\n function oracle() external view returns (IOracleProvider);\\n function payoffDefinition() external view returns (PayoffDefinition memory);\\n function currentVersion() external view returns (IOracleProvider.OracleVersion memory);\\n function atVersion(uint256 oracleVersion) external view returns (IOracleProvider.OracleVersion memory);\\n}\\n\",\"keccak256\":\"0xb83d80d624aa9431763f80ecb4bf0214803e25334a7419d954f929e5d0ee7467\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IProduct.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\\\";\\nimport \\\"./IPayoffProvider.sol\\\";\\nimport \\\"./IParamProvider.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\nimport \\\"./types/Position.sol\\\";\\nimport \\\"./types/PrePosition.sol\\\";\\nimport \\\"./types/Accumulator.sol\\\";\\n\\ninterface IProduct is IPayoffProvider, IParamProvider {\\n /// @dev Product Creation parameters\\n struct ProductInfo {\\n /// @dev name of the product\\n string name;\\n\\n /// @dev symbol of the product\\n string symbol;\\n\\n /// @dev product payoff definition\\n PayoffDefinition payoffDefinition;\\n\\n /// @dev oracle address\\n IOracleProvider oracle;\\n\\n /// @dev product maintenance ratio\\n UFixed18 maintenance;\\n\\n /// @dev product funding fee\\n UFixed18 fundingFee;\\n\\n /// @dev product maker fee\\n UFixed18 makerFee;\\n\\n /// @dev product taker fee\\n UFixed18 takerFee;\\n\\n /// @dev product maker limit\\n UFixed18 makerLimit;\\n\\n /// @dev utulization curve definition\\n JumpRateUtilizationCurve utilizationCurve;\\n }\\n\\n event Settle(uint256 preVersion, uint256 toVersion);\\n event AccountSettle(address indexed account, uint256 preVersion, uint256 toVersion);\\n event MakeOpened(address indexed account, uint256 version, UFixed18 amount);\\n event TakeOpened(address indexed account, uint256 version, UFixed18 amount);\\n event MakeClosed(address indexed account, uint256 version, UFixed18 amount);\\n event TakeClosed(address indexed account, uint256 version, UFixed18 amount);\\n event ClosedUpdated(bool indexed newClosed, uint256 version);\\n\\n error ProductInsufficientLiquidityError(UFixed18 socializationFactor);\\n error ProductDoubleSidedError();\\n error ProductOverClosedError();\\n error ProductInsufficientCollateralError();\\n error ProductInLiquidationError();\\n error ProductMakerOverLimitError();\\n error ProductOracleBootstrappingError();\\n error ProductNotOwnerError();\\n error ProductInvalidOracle();\\n error ProductClosedError();\\n\\n function name() external view returns (string memory);\\n function symbol() external view returns (string memory);\\n function initialize(ProductInfo calldata productInfo_) external;\\n function settle() external;\\n function settleAccount(address account) external;\\n function openTake(UFixed18 amount) external;\\n function closeTake(UFixed18 amount) external;\\n function openMake(UFixed18 amount) external;\\n function closeMake(UFixed18 amount) external;\\n function closeAll(address account) external;\\n function maintenance(address account) external view returns (UFixed18);\\n function maintenanceNext(address account) external view returns (UFixed18);\\n function isClosed(address account) external view returns (bool);\\n function isLiquidating(address account) external view returns (bool);\\n function position(address account) external view returns (Position memory);\\n function pre(address account) external view returns (PrePosition memory);\\n function latestVersion() external view returns (uint256);\\n function positionAtVersion(uint256 oracleVersion) external view returns (Position memory);\\n function pre() external view returns (PrePosition memory);\\n function valueAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\\n function shareAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\\n function latestVersion(address account) external view returns (uint256);\\n function rate(Position memory position) external view returns (Fixed18);\\n function closed() external view returns (bool);\\n function updateClosed(bool newClosed) external;\\n}\\n\",\"keccak256\":\"0xe1e80b818eadf4cdb070362e40c7cf3863b50c4f944816af27848e319f587241\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/Accumulator.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"./PackedAccumulator.sol\\\";\\n\\n/// @dev Accumulator type\\nstruct Accumulator {\\n /// @dev maker accumulator per share\\n Fixed18 maker;\\n /// @dev taker accumulator per share\\n Fixed18 taker;\\n}\\nusing AccumulatorLib for Accumulator global;\\n\\n/**\\n * @title AccountAccumulatorLib\\n * @notice Library that surfaces math operations for the Accumulator type.\\n * @dev Accumulators track the cumulative change in position value over time for the maker and taker positions\\n * respectively. Account-level accumulators can then use two of these values `a` and `a'` to compute the\\n * change in position value since last sync. This change in value is then used to compute P&L and fees.\\n */\\nlibrary AccumulatorLib {\\n /**\\n * @notice Creates a packed accumulator from an accumulator\\n * @param self an accumulator\\n * @return New packed accumulator\\n */\\n function pack(Accumulator memory self) internal pure returns (PackedAccumulator memory) {\\n return PackedAccumulator({maker: self.maker.pack(), taker: self.taker.pack()});\\n }\\n\\n /**\\n * @notice Adds two accumulators together\\n * @param a The first accumulator to sum\\n * @param b The second accumulator to sum\\n * @return The resulting summed accumulator\\n */\\n function add(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\\n }\\n\\n /**\\n * @notice Subtracts accumulator `b` from `a`\\n * @param a The accumulator to subtract from\\n * @param b The accumulator to subtract\\n * @return The resulting subtracted accumulator\\n */\\n function sub(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\\n }\\n\\n /**\\n * @notice Multiplies two accumulators together\\n * @param a The first accumulator to multiply\\n * @param b The second accumulator to multiply\\n * @return The resulting multiplied accumulator\\n */\\n function mul(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.mul(b.maker), taker: a.taker.mul(b.taker)});\\n }\\n\\n /**\\n * @notice Sums the maker and taker together from a single accumulator\\n * @param self The struct to operate on\\n * @return The sum of its maker and taker\\n */\\n function sum(Accumulator memory self) internal pure returns (Fixed18) {\\n return self.maker.add(self.taker);\\n }\\n}\\n\",\"keccak256\":\"0x7ccd0a72aa593cefb9f4337cf312799f357b82fcb3f0379de0dc503d1cb7e387\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PackedAccumulator.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/PackedFixed18.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\n\\n/// @dev PackedAccumulator type\\nstruct PackedAccumulator {\\n /// @dev maker accumulator per share\\n PackedFixed18 maker;\\n /// @dev taker accumulator per share\\n PackedFixed18 taker;\\n}\\nusing PackedAccumulatorLib for PackedAccumulator global;\\n\\n/**\\n * @title PackedAccumulatorLib\\n * @dev A packed version of the Accumulator which takes up a single storage slot using `PackedFixed18` values.\\n * @notice Library for the packed Accumulator type.\\n */\\nlibrary PackedAccumulatorLib {\\n /**\\n * @notice Creates an accumulator from a packed accumulator\\n * @param self packed accumulator\\n * @return New accumulator\\n */\\n function unpack(PackedAccumulator memory self) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: self.maker.unpack(), taker: self.taker.unpack()});\\n }\\n}\\n\",\"keccak256\":\"0xd83f2822d4f6c818087a232b54007730992c34ff77377fc307a282f886e7cf65\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PackedPosition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/PackedUFixed18.sol\\\";\\nimport \\\"./Position.sol\\\";\\n\\n/// @dev PackedPosition type\\nstruct PackedPosition {\\n /// @dev Quantity of the maker position\\n PackedUFixed18 maker;\\n /// @dev Quantity of the taker position\\n PackedUFixed18 taker;\\n}\\nusing PackedPositionLib for PackedPosition global;\\n\\n/**\\n * @title PackedPositionLib\\n * @dev A packed version of the Position which takes up a single storage slot using `PackedFixed18` values.\\n * @notice Library for the packed Position type.\\n */\\nlibrary PackedPositionLib {\\n /**\\n * @notice Creates an position from a packed position\\n * @param self packed position\\n * @return New position\\n */\\n function unpack(PackedPosition memory self) internal pure returns (Position memory) {\\n return Position({maker: self.maker.unpack(), taker: self.taker.unpack()});\\n }\\n}\\n\",\"keccak256\":\"0x04968e6794f6244cb3415cea111d640273a81faea957872988d0cb580f45df1e\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PayoffDefinition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"@openzeppelin/contracts/utils/Address.sol\\\";\\nimport \\\"../../interfaces/IContractPayoffProvider.sol\\\";\\n\\n/// @dev PayoffDefinition tyoe\\nstruct PayoffDefinition {\\n PayoffDefinitionLib.PayoffType payoffType;\\n PayoffDefinitionLib.PayoffDirection payoffDirection;\\n bytes30 data;\\n}\\nusing PayoffDefinitionLib for PayoffDefinition global;\\ntype PayoffDefinitionStorage is bytes32;\\nusing PayoffDefinitionStorageLib for PayoffDefinitionStorage global;\\n\\n/**\\n * @title PayoffDefinitionLib\\n * @dev Library that surfaces logic for PayoffDefinition type functionality\\n * @notice Library for the PayoffDefinition type. Performs validity and price transformation\\n based on the payoff definition type.\\n */\\nlibrary PayoffDefinitionLib {\\n using Address for address;\\n\\n error PayoffDefinitionUnsupportedTransform(PayoffType payoffType, PayoffDirection payoffDirection);\\n error PayoffDefinitionNotContract(PayoffType payoffType, bytes30 data);\\n\\n /// @dev Payoff function type enum\\n enum PayoffType { PASSTHROUGH, CONTRACT }\\n enum PayoffDirection { LONG, SHORT }\\n\\n /**\\n * @notice Checks validity of the payoff definition\\n * @param self a payoff definition\\n * @return Whether the payoff definition is valid for it's given type\\n */\\n function valid(PayoffDefinition memory self) internal view returns (bool) {\\n if (self.payoffType == PayoffType.CONTRACT) return address(_providerContract(self)).isContract();\\n\\n // All other payoff types should have no data\\n return uint(bytes32(self.data)) == 0;\\n }\\n\\n /**\\n * @notice Transforms a price based on the payoff definition\\n * @param self a payoff definition\\n * @param price raw oracle price\\n * @return Price transformed by the payoff definition function\\n */\\n function transform(\\n PayoffDefinition memory self,\\n Fixed18 price\\n ) internal view returns (Fixed18) {\\n PayoffType payoffType = self.payoffType;\\n PayoffDirection payoffDirection = self.payoffDirection;\\n Fixed18 transformedPrice;\\n\\n // First get the price depending on the type\\n if (payoffType == PayoffType.PASSTHROUGH) transformedPrice = price;\\n else if (payoffType == PayoffType.CONTRACT) transformedPrice = _payoffFromContract(self, price);\\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\\n\\n // Then transform it depending on the direction flag\\n if (self.payoffDirection == PayoffDirection.LONG) return transformedPrice;\\n else if (self.payoffDirection == PayoffDirection.SHORT) return transformedPrice.mul(Fixed18Lib.NEG_ONE);\\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\\n }\\n\\n /**\\n * @notice Parses the data field into an address\\n * @dev Reverts if payoffType is not CONTRACT\\n * @param self a payoff definition\\n * @return IContractPayoffProvider address\\n */\\n function _providerContract(\\n PayoffDefinition memory self\\n ) private pure returns (IContractPayoffProvider) {\\n if (self.payoffType != PayoffType.CONTRACT) revert PayoffDefinitionNotContract(self.payoffType, self.data);\\n // Shift to pull the last 20 bytes, then cast to an address\\n return IContractPayoffProvider(address(bytes20(self.data << 80)));\\n }\\n\\n /**\\n * @notice Performs a price transformation by calling the underlying payoff contract\\n * @param self a payoff definition\\n * @param price raw oracle price\\n * @return Price transformed by the payoff definition function on the contract\\n */\\n function _payoffFromContract(\\n PayoffDefinition memory self,\\n Fixed18 price\\n ) private view returns (Fixed18) {\\n bytes memory ret = address(_providerContract(self)).functionStaticCall(\\n abi.encodeCall(IContractPayoffProvider.payoff, price)\\n );\\n return Fixed18.wrap(abi.decode(ret, (int256)));\\n }\\n}\\n\\n/**\\n * @title PayoffDefinitionStorageLib\\n * @notice Library that surfaces storage read and writes for the PayoffDefinition type\\n */\\nlibrary PayoffDefinitionStorageLib {\\n function read(PayoffDefinitionStorage self) internal view returns (PayoffDefinition memory) {\\n return _storagePointer(self);\\n }\\n\\n function store(PayoffDefinitionStorage self, PayoffDefinition memory value) internal {\\n PayoffDefinition storage storagePointer = _storagePointer(self);\\n\\n storagePointer.payoffType = value.payoffType;\\n storagePointer.payoffDirection = value.payoffDirection;\\n storagePointer.data = value.data;\\n }\\n\\n function _storagePointer(\\n PayoffDefinitionStorage self\\n ) private pure returns (PayoffDefinition storage pointer) {\\n assembly { pointer.slot := self }\\n }\\n}\\n\",\"keccak256\":\"0x4d3897f408f77381c5ae9990391465c8fd511ddf6ff3b39f6cb69d8c2bd554df\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/Position.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\nimport \\\"./PrePosition.sol\\\";\\nimport \\\"./PackedPosition.sol\\\";\\n\\n/// @dev Position type\\nstruct Position {\\n /// @dev Quantity of the maker position\\n UFixed18 maker;\\n /// @dev Quantity of the taker position\\n UFixed18 taker;\\n}\\nusing PositionLib for Position global;\\n\\n/**\\n * @title PositionLib\\n * @notice Library that surfaces math and settlement computations for the Position type.\\n * @dev Positions track the current quantity of the account's maker and taker positions respectively\\n * denominated as a unit of the product's payoff function.\\n */\\nlibrary PositionLib {\\n /**\\n * @notice Creates a packed position from an position\\n * @param self A position\\n * @return New packed position\\n */\\n function pack(Position memory self) internal pure returns (PackedPosition memory) {\\n return PackedPosition({maker: self.maker.pack(), taker: self.taker.pack()});\\n }\\n\\n /**\\n * @notice Returns whether the position is fully empty\\n * @param self A position\\n * @return Whether the position is empty\\n */\\n function isEmpty(Position memory self) internal pure returns (bool) {\\n return self.maker.isZero() && self.taker.isZero();\\n }\\n\\n /**\\n * @notice Adds position `a` and `b` together, returning the result\\n * @param a The first position to sum\\n * @param b The second position to sum\\n * @return Resulting summed position\\n */\\n function add(Position memory a, Position memory b) internal pure returns (Position memory) {\\n return Position({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\\n }\\n\\n /**\\n * @notice Subtracts position `b` from `a`, returning the result\\n * @param a The position to subtract from\\n * @param b The position to subtract\\n * @return Resulting subtracted position\\n */\\n function sub(Position memory a, Position memory b) internal pure returns (Position memory) {\\n return Position({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\\n }\\n\\n /**\\n * @notice Multiplies position `self` by accumulator `accumulator` and returns the resulting accumulator\\n * @param self The Position to operate on\\n * @param accumulator The accumulator to multiply by\\n * @return Resulting multiplied accumulator\\n */\\n function mul(Position memory self, Accumulator memory accumulator) internal pure returns (Accumulator memory) {\\n return Accumulator({\\n maker: Fixed18Lib.from(self.maker).mul(accumulator.maker),\\n taker: Fixed18Lib.from(self.taker).mul(accumulator.taker)\\n });\\n }\\n\\n /**\\n * @notice Scales position `self` by fixed-decimal `scale` and returns the resulting position\\n * @param self The Position to operate on\\n * @param scale The Fixed-decimal to scale by\\n * @return Resulting scaled position\\n */\\n function mul(Position memory self, UFixed18 scale) internal pure returns (Position memory) {\\n return Position({maker: self.maker.mul(scale), taker: self.taker.mul(scale)});\\n }\\n\\n /**\\n * @notice Divides position `self` by `b` and returns the resulting accumulator\\n * @param self The Position to operate on\\n * @param b The number to divide by\\n * @return Resulting divided accumulator\\n */\\n function div(Position memory self, uint256 b) internal pure returns (Accumulator memory) {\\n return Accumulator({\\n maker: Fixed18Lib.from(self.maker).div(Fixed18Lib.from(UFixed18Lib.from(b))),\\n taker: Fixed18Lib.from(self.taker).div(Fixed18Lib.from(UFixed18Lib.from(b)))\\n });\\n }\\n\\n /**\\n * @notice Returns the maximum of `self`'s maker and taker values\\n * @param self The struct to operate on\\n * @return Resulting maximum value\\n */\\n function max(Position memory self) internal pure returns (UFixed18) {\\n return UFixed18Lib.max(self.maker, self.taker);\\n }\\n\\n /**\\n * @notice Sums the maker and taker together from a single position\\n * @param self The struct to operate on\\n * @return The sum of its maker and taker\\n */\\n function sum(Position memory self) internal pure returns (UFixed18) {\\n return self.maker.add(self.taker);\\n }\\n\\n /**\\n * @notice Computes the next position after the pending-settlement position delta is included\\n * @param self The current Position\\n * @param pre The pending-settlement position delta\\n * @return Next Position\\n */\\n function next(Position memory self, PrePosition memory pre) internal pure returns (Position memory) {\\n return sub(add(self, pre.openPosition), pre.closePosition);\\n }\\n\\n /**\\n * @notice Returns the settled position at oracle version `toOracleVersion`\\n * @dev Checks if a new position is ready to be settled based on the provided `toOracleVersion`\\n * and `pre` and returns accordingly\\n * @param self The current Position\\n * @param pre The pending-settlement position delta\\n * @param toOracleVersion The oracle version to settle to\\n * @return Settled position at oracle version\\n * @return Fee accrued from opening or closing the position\\n * @return Whether a new position was settled\\n */\\n function settled(\\n Position memory self,\\n PrePosition memory pre,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal view returns (Position memory, UFixed18, bool) {\\n return pre.canSettle(toOracleVersion) ? (next(self, pre), pre.computeFee(toOracleVersion), true) : (self, UFixed18Lib.ZERO, false);\\n }\\n\\n /**\\n * @notice Returns the socialization factor for the current position\\n * @dev Socialization account for the case where `taker` > `maker` temporarily due to a liquidation\\n * on the maker side. This dampens the taker's exposure pro-rata to ensure that the maker side\\n * is never exposed over 1 x short.\\n * @param self The Position to operate on\\n * @return Socialization factor\\n */\\n function socializationFactor(Position memory self) internal pure returns (UFixed18) {\\n return self.taker.isZero() ? UFixed18Lib.ONE : UFixed18Lib.min(UFixed18Lib.ONE, self.maker.div(self.taker));\\n }\\n}\\n\",\"keccak256\":\"0x027fe392c4f56bf012ba2ca462fcf23e69f2c3b9d283c14089771813437af991\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PrePosition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./Position.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\n\\n/// @dev PrePosition type\\nstruct PrePosition {\\n /// @dev Oracle version at which the new position delta was recorded\\n uint256 oracleVersion;\\n\\n /// @dev Size of position to open at oracle version\\n Position openPosition;\\n\\n /// @dev Size of position to close at oracle version\\n Position closePosition;\\n}\\nusing PrePositionLib for PrePosition global;\\n\\n/**\\n * @title PrePositionLib\\n * @notice Library that manages a pre-settlement position delta.\\n * @dev PrePositions track the currently awaiting-settlement deltas to a settled Position. These are\\n * Primarily necessary to introduce lag into the settlement system such that oracle lag cannot be\\n * gamed to a user's advantage. When a user opens or closes a new position, it sits as a PrePosition\\n * for one oracle version until it's settle into the Position, making it then effective. PrePositions\\n * are automatically settled at the correct oracle version even if a flywheel call doesn't happen until\\n * several version into the future by using the historical version lookups in the corresponding \\\"Versioned\\\"\\n * global state types.\\n */\\nlibrary PrePositionLib {\\n /**\\n * @notice Returns whether there is no pending-settlement position delta\\n * @dev Can be \\\"empty\\\" even with a non-zero oracleVersion if a position is opened and\\n * closed in the same version netting out to a zero position delta\\n * @param self The struct to operate on\\n * @return Whether the pending-settlement position delta is empty\\n */\\n function isEmpty(PrePosition memory self) internal pure returns (bool) {\\n return self.openPosition.isEmpty() && self.closePosition.isEmpty();\\n }\\n\\n /**\\n * @notice Increments the maker side of the open position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The position amount to open\\n */\\n function openMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.openPosition.maker = self.openPosition.maker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netMake(self);\\n }\\n\\n /**\\n * @notice Increments the maker side of the close position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The maker position amount to close\\n */\\n function closeMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.closePosition.maker = self.closePosition.maker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netMake(self);\\n }\\n\\n /**\\n * @notice Increments the taker side of the open position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The taker position amount to open\\n */\\n function openTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.openPosition.taker = self.openPosition.taker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netTake(self);\\n }\\n\\n /**\\n * @notice Increments the taker side of the close position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The taker position amount to close\\n */\\n function closeTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.closePosition.taker = self.closePosition.taker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netTake(self);\\n }\\n\\n /**\\n * @notice Nets out the open and close on the maker side of the position delta\\n * @param self The struct to operate on\\n */\\n function _netMake(PrePosition storage self) private {\\n if (self.openPosition.maker.gt(self.closePosition.maker)) {\\n self.openPosition.maker = self.openPosition.maker.sub(self.closePosition.maker);\\n self.closePosition.maker = UFixed18Lib.ZERO;\\n } else {\\n self.closePosition.maker = self.closePosition.maker.sub(self.openPosition.maker);\\n self.openPosition.maker = UFixed18Lib.ZERO;\\n }\\n }\\n\\n /**\\n * @notice Nets out the open and close on the taker side of the position delta\\n * @param self The struct to operate on\\n */\\n function _netTake(PrePosition storage self) private {\\n if (self.openPosition.taker.gt(self.closePosition.taker)) {\\n self.openPosition.taker = self.openPosition.taker.sub(self.closePosition.taker);\\n self.closePosition.taker = UFixed18Lib.ZERO;\\n } else {\\n self.closePosition.taker = self.closePosition.taker.sub(self.openPosition.taker);\\n self.openPosition.taker = UFixed18Lib.ZERO;\\n }\\n }\\n\\n /**\\n * @notice Returns whether the the pending position delta can be settled at version `toOracleVersion`\\n * @dev Pending-settlement positions deltas can be settled (1) oracle version after they are recorded\\n * @param self The struct to operate on\\n * @param toOracleVersion The potential oracle version to settle\\n * @return Whether the position delta can be settled\\n */\\n function canSettle(\\n PrePosition memory self,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal pure returns (bool) {\\n return !isEmpty(self) && toOracleVersion.version > self.oracleVersion;\\n }\\n\\n /**\\n * @notice Computes the fee incurred for opening or closing the pending-settlement position\\n * @dev Must be called from a valid product to get the proper fee amounts\\n * @param self The struct to operate on\\n * @param toOracleVersion The oracle version at which settlement takes place\\n * @return positionFee The maker / taker fee incurred\\n */\\n function computeFee(\\n PrePosition memory self,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal view returns (UFixed18) {\\n Position memory positionDelta = self.openPosition.add(self.closePosition);\\n\\n (UFixed18 makerNotional, UFixed18 takerNotional) = (\\n Fixed18Lib.from(positionDelta.maker).mul(toOracleVersion.price).abs(),\\n Fixed18Lib.from(positionDelta.taker).mul(toOracleVersion.price).abs()\\n );\\n\\n IProduct product = IProduct(address(this));\\n return makerNotional.mul(product.makerFee()).add(takerNotional.mul(product.takerFee()));\\n }\\n\\n /**\\n * @notice Computes the next oracle version to settle\\n * @dev - If there is no pending-settlement position delta, returns the current oracle version\\n * - Otherwise returns the oracle version at which the pending-settlement position delta can be first settled\\n *\\n * Corresponds to point (b) in the Position settlement flow\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @return Next oracle version to settle\\n */\\n function settleVersion(PrePosition storage self, uint256 currentVersion) internal view returns (uint256) {\\n uint256 _oracleVersion = self.oracleVersion;\\n return _oracleVersion == 0 ? currentVersion : _oracleVersion + 1;\\n }\\n}\\n\",\"keccak256\":\"0xa6f83f7b5f8139ec874235c406debd086a152977493c08b7f280df6f1737fb96\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/ProgramInfo.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\nimport \\\"./Position.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\n\\n/// @dev ProgramInfo type\\nstruct ProgramInfo {\\n /// @dev Coordinator for this program\\n uint256 coordinatorId;\\n\\n /// @dev Amount of total maker and taker rewards\\n Position amount;\\n\\n /// @dev start timestamp of the program\\n uint256 start;\\n\\n /// @dev duration of the program (in seconds)\\n uint256 duration;\\n\\n /**\\n * @dev Reward ERC20 token contract\\n * @notice Perennial does not support non-standard ERC20s as reward tokens for incentive programs, including,\\n but not limited to: fee on transfer and rebase tokens. Using such a non-standard token will likely\\n result in loss of funds.\\n */\\n Token18 token;\\n}\\nusing ProgramInfoLib for ProgramInfo global;\\n\\n/**\\n * @title ProgramInfoLib\\n * @notice Library that snapshots the static information for a single program.\\n * @dev This information does not change during the operation of a program.\\n */\\nlibrary ProgramInfoLib {\\n uint256 private constant MIN_DURATION = 1 days;\\n uint256 private constant MAX_DURATION = 2 * 365 days;\\n\\n error ProgramInvalidStartError();\\n error ProgramInvalidDurationError();\\n\\n /**\\n * @notice Validates and creates a new Program\\n * @dev Reverts for invalid programInfos\\n * @param programInfo Un-sanitized static program information\\n */\\n function validate(ProgramInfo memory programInfo) internal view {\\n if (isStarted(programInfo, block.timestamp)) revert ProgramInvalidStartError();\\n if (programInfo.duration < MIN_DURATION || programInfo.duration > MAX_DURATION) revert ProgramInvalidDurationError();\\n }\\n\\n /**\\n * @notice Computes a new program info with the fee taken out of the amount\\n * @param programInfo Original program info\\n * @param incentivizationFee The incentivization fee\\n * @return New program info\\n * @return Fee amount\\n */\\n function deductFee(ProgramInfo memory programInfo, UFixed18 incentivizationFee)\\n internal pure returns (ProgramInfo memory, UFixed18) {\\n Position memory newProgramAmount = programInfo.amount.mul(UFixed18Lib.ONE.sub(incentivizationFee));\\n UFixed18 programFeeAmount = programInfo.amount.sub(newProgramAmount).sum();\\n programInfo.amount = newProgramAmount;\\n return (programInfo, programFeeAmount);\\n }\\n\\n /**\\n * @notice Returns the maker and taker amounts per position share\\n * @param self The ProgramInfo to operate on\\n * @return programFee Amounts per share\\n */\\n function amountPerShare(ProgramInfo memory self) internal pure returns (Accumulator memory) {\\n return self.amount.div(self.duration);\\n }\\n\\n /**\\n * @notice Returns whether the program has started by timestamp `timestamp`\\n * @param self The ProgramInfo to operate on\\n * @param timestamp Timestamp to check for\\n * @return Whether the program has started\\n */\\n function isStarted(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\\n return timestamp >= self.start;\\n }\\n\\n /**\\n * @notice Returns whether the program is completed by timestamp `timestamp`\\n * @param self The ProgramInfo to operate on\\n * @param timestamp Timestamp to check for\\n * @return Whether the program is completed\\n */\\n function isComplete(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\\n return timestamp >= (self.start + self.duration);\\n }\\n}\\n\",\"keccak256\":\"0x280fcaf931b49abaec46b95ccbabaaf856a4b8e8d036413c9c3b3af25585d161\",\"license\":\"Apache-2.0\"}},\"version\":1}", - "bytecode": "0x6101006040523480156200001257600080fd5b50604051620012ba380380620012ba83398101604081905262000035916200058a565b6200004b846200017160201b6200034b1760201c565b620000695760405163e5df3e0960e01b815260040160405180910390fd5b6200007f836200017160201b6200034b1760201c565b6200009d5760405163e5df3e0960e01b815260040160405180910390fd5b620000b3826200017160201b6200034b1760201c565b620000d15760405163e5df3e0960e01b815260040160405180910390fd5b620000e7816200017160201b6200034b1760201c565b620001055760405163e5df3e0960e01b815260040160405180910390fd5b6001600160a01b03848116608081905284821660a05283821660c081905291831660e052620001409162000180602090811b6200036717901c565b6200016760e05160a0516001600160a01b03166200018060201b620003671790919060201c565b50505050620006b6565b6001600160a01b03163b151590565b620001a781600019846001600160a01b0316620001ab60201b620003ac179092919060201c565b5050565b801580620002295750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa15801562000201573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620002279190620005f2565b155b620002a15760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e63650000000000000000000060648201526084015b60405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b0390811663095ea7b360e01b17909152620002f9918591620002fe16565b505050565b60006200035a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316620003dc60201b620005b6179092919060201c565b805190915015620002f957808060200190518101906200037b91906200060c565b620002f95760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840162000298565b6060620003ed8484600085620003f7565b90505b9392505050565b6060824710156200045a5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840162000298565b6001600160a01b0385163b620004b35760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640162000298565b600080866001600160a01b03168587604051620004d1919062000663565b60006040518083038185875af1925050503d806000811462000510576040519150601f19603f3d011682016040523d82523d6000602084013e62000515565b606091505b5090925090506200052882828662000533565b979650505050505050565b6060831562000544575081620003f0565b825115620005555782518084602001fd5b8160405162461bcd60e51b815260040162000298919062000681565b6001600160a01b03811681146200058757600080fd5b50565b60008060008060808587031215620005a157600080fd5b8451620005ae8162000571565b6020860151909450620005c18162000571565b6040860151909350620005d48162000571565b6060860151909250620005e78162000571565b939692955090935050565b6000602082840312156200060557600080fd5b5051919050565b6000602082840312156200061f57600080fd5b81518015158114620003f057600080fd5b60005b838110156200064d57818101518382015260200162000633565b838111156200065d576000848401525b50505050565b600082516200067781846020870162000630565b9190910192915050565b6020815260008251806020840152620006a281604085016020870162000630565b601f01601f19169190910160400192915050565b60805160a05160c05160e051610bb862000702600039600081816101240152610281015260008181607101526101be0152600060fd01526000818160d601526101600152610bb86000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c806389a302711161005057806389a30271146100d1578063a2060bcf146100f8578063d8dfeb451461011f57600080fd5b8063025a3a291461006c57806344bc170a146100bc575b600080fd5b6100937f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b6100cf6100ca3660046109d7565b610146565b005b6100937f000000000000000000000000000000000000000000000000000000000000000081565b6100937f000000000000000000000000000000000000000000000000000000000000000081565b6100937f000000000000000000000000000000000000000000000000000000000000000081565b61018973ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016338360016105cf565b6040517f13bac820000000000000000000000000000000000000000000000000000000008152600481018290523060248201527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16906313bac82090604401600060405180830381600087803b15801561021757600080fd5b505af115801561022b573d6000803e3d6000fd5b50506040517ff213159c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff86811660048301528581166024830152604482018590527f000000000000000000000000000000000000000000000000000000000000000016925063f213159c9150606401600060405180830381600087803b1580156102c757600080fd5b505af11580156102db573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8e7ce60e353ab1a4cc59ca4782bdc69e0565713d1824dce27e0de2e362147ed08360405161033e91815260200190565b60405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6103a873ffffffffffffffffffffffffffffffffffffffff8316827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6103ac565b5050565b80158061044c57506040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff838116602483015284169063dd62ed3e90604401602060405180830381865afa158015610426573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061044a9190610a18565b155b6104dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e63650000000000000000000060648201526084015b60405180910390fd5b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526105b19084907f095ea7b300000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152610603565b505050565b60606105c5848460008561070f565b90505b9392505050565b6105fd83306105de85856108a5565b73ffffffffffffffffffffffffffffffffffffffff88169291906108cf565b50505050565b6000610665826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166105b69092919063ffffffff16565b8051909150156105b157808060200190518101906106839190610a31565b6105b1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016104d4565b6060824710156107a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016104d4565b73ffffffffffffffffffffffffffffffffffffffff85163b61081f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016104d4565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516108489190610a7f565b60006040518083038185875af1925050503d8060008114610885576040519150601f19603f3d011682016040523d82523d6000602084013e61088a565b606091505b509150915061089a82828661092d565b979650505050505050565b6000816108c0576108bb64e8d4a5100084610aca565b6105c8565b6105c88364e8d4a51000610980565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526105fd9085907f23b872dd000000000000000000000000000000000000000000000000000000009060840161052f565b6060831561093c5750816105c8565b82511561094c5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104d49190610ade565b600061098c8284610b2f565b1561099857600161099b565b60005b60ff166109a88385610aca565b6105c89190610b43565b73ffffffffffffffffffffffffffffffffffffffff811681146109d457600080fd5b50565b6000806000606084860312156109ec57600080fd5b83356109f7816109b2565b92506020840135610a07816109b2565b929592945050506040919091013590565b600060208284031215610a2a57600080fd5b5051919050565b600060208284031215610a4357600080fd5b815180151581146105c857600080fd5b60005b83811015610a6e578181015183820152602001610a56565b838111156105fd5750506000910152565b60008251610a91818460208701610a53565b9190910192915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600082610ad957610ad9610a9b565b500490565b6020815260008251806020840152610afd816040850160208701610a53565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b600082610b3e57610b3e610a9b565b500690565b60008219821115610b7d577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b50019056fea2646970667358221220ec9c4186939b8bfc3bd6ef92257a35503ebc51f749f10b706ec9c0022f7b049664736f6c634300080f0033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100675760003560e01c806389a302711161005057806389a30271146100d1578063a2060bcf146100f8578063d8dfeb451461011f57600080fd5b8063025a3a291461006c57806344bc170a146100bc575b600080fd5b6100937f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b6100cf6100ca3660046109d7565b610146565b005b6100937f000000000000000000000000000000000000000000000000000000000000000081565b6100937f000000000000000000000000000000000000000000000000000000000000000081565b6100937f000000000000000000000000000000000000000000000000000000000000000081565b61018973ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016338360016105cf565b6040517f13bac820000000000000000000000000000000000000000000000000000000008152600481018290523060248201527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16906313bac82090604401600060405180830381600087803b15801561021757600080fd5b505af115801561022b573d6000803e3d6000fd5b50506040517ff213159c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff86811660048301528581166024830152604482018590527f000000000000000000000000000000000000000000000000000000000000000016925063f213159c9150606401600060405180830381600087803b1580156102c757600080fd5b505af11580156102db573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8e7ce60e353ab1a4cc59ca4782bdc69e0565713d1824dce27e0de2e362147ed08360405161033e91815260200190565b60405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6103a873ffffffffffffffffffffffffffffffffffffffff8316827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6103ac565b5050565b80158061044c57506040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff838116602483015284169063dd62ed3e90604401602060405180830381865afa158015610426573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061044a9190610a18565b155b6104dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e63650000000000000000000060648201526084015b60405180910390fd5b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526105b19084907f095ea7b300000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152610603565b505050565b60606105c5848460008561070f565b90505b9392505050565b6105fd83306105de85856108a5565b73ffffffffffffffffffffffffffffffffffffffff88169291906108cf565b50505050565b6000610665826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166105b69092919063ffffffff16565b8051909150156105b157808060200190518101906106839190610a31565b6105b1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016104d4565b6060824710156107a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016104d4565b73ffffffffffffffffffffffffffffffffffffffff85163b61081f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016104d4565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516108489190610a7f565b60006040518083038185875af1925050503d8060008114610885576040519150601f19603f3d011682016040523d82523d6000602084013e61088a565b606091505b509150915061089a82828661092d565b979650505050505050565b6000816108c0576108bb64e8d4a5100084610aca565b6105c8565b6105c88364e8d4a51000610980565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526105fd9085907f23b872dd000000000000000000000000000000000000000000000000000000009060840161052f565b6060831561093c5750816105c8565b82511561094c5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104d49190610ade565b600061098c8284610b2f565b1561099857600161099b565b60005b60ff166109a88385610aca565b6105c89190610b43565b73ffffffffffffffffffffffffffffffffffffffff811681146109d457600080fd5b50565b6000806000606084860312156109ec57600080fd5b83356109f7816109b2565b92506020840135610a07816109b2565b929592945050506040919091013590565b600060208284031215610a2a57600080fd5b5051919050565b600060208284031215610a4357600080fd5b815180151581146105c857600080fd5b60005b83811015610a6e578181015183820152602001610a56565b838111156105fd5750506000910152565b60008251610a91818460208701610a53565b9190910192915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600082610ad957610ad9610a9b565b500490565b6020815260008251806020840152610afd816040850160208701610a53565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b600082610b3e57610b3e610a9b565b500690565b60008219821115610b7d577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b50019056fea2646970667358221220ec9c4186939b8bfc3bd6ef92257a35503ebc51f749f10b706ec9c0022f7b049664736f6c634300080f0033", - "devdoc": { - "kind": "dev", - "methods": { - "constructor": { - "params": { - "batcher_": "The USDC-to-DSU batcher contract address", - "collateral_": "The perennial collateral contract address", - "dsu_": "The DSU token contract address", - "usdc_": "The USDC token contract address" - } - }, - "wrapAndDeposit(address,address,uint256)": { - "params": { - "account": "Account to deposit the collateral for", - "amount": "18 decimals-normalized stablecoin (USDC, DSU) value of collateral to deposit", - "product": "Product to credit the collateral to" - } - } - }, - "stateVariables": { - "batcher": { - "details": "Contract that wraps USDC to DSU" - }, - "collateral": { - "details": "Contract managing state for collateral accounts in the protocol" - } - }, - "title": "Forwarder", - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": { - "constructor": { - "notice": "Initializes the contract state" - }, - "wrapAndDeposit(address,address,uint256)": { - "notice": "Pulls `amount` of USDC from `msg.sender`'s balance, wraps it as DSU, and deposits it as collateral to `account`'s `product` account" - } - }, - "notice": "Facilitates collateral deposits to the protocol where the amount is supplied in USDC then wrapped as DSU before being deposited.", - "version": 1 - }, - "storageLayout": { - "storage": [], - "types": null - } -} diff --git a/packages/perennial/deployments/goerli/Incentivizer_Impl.json b/packages/perennial/deployments/goerli/Incentivizer_Impl.json deleted file mode 100644 index baba8b6ae..000000000 --- a/packages/perennial/deployments/goerli/Incentivizer_Impl.json +++ /dev/null @@ -1,1361 +0,0 @@ -{ - "address": "0x7869fd0EdCFff8C05600CB71826e59a3ad860938", - "abi": [ - { - "inputs": [ - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Fixed18OverflowError", - "type": "error" - }, - { - "inputs": [], - "name": "IncentivizerBatchClaimArgumentMismatchError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "uint256", - "name": "programId", - "type": "uint256" - } - ], - "name": "IncentivizerInvalidProgramError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "IncentivizerNotAllowedError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "uint256", - "name": "programId", - "type": "uint256" - } - ], - "name": "IncentivizerNotProgramOwnerError", - "type": "error" - }, - { - "inputs": [], - "name": "IncentivizerTooManyProgramsError", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidControllerError", - "type": "error" - }, - { - "inputs": [], - "name": "NotCollateralError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - } - ], - "name": "NotOwnerError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "NotProductError", - "type": "error" - }, - { - "inputs": [], - "name": "PausedError", - "type": "error" - }, - { - "inputs": [], - "name": "ProgramInvalidDurationError", - "type": "error" - }, - { - "inputs": [], - "name": "ProgramInvalidStartError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "int256", - "name": "value", - "type": "int256" - } - ], - "name": "UFixed18UnderflowError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "version", - "type": "uint256" - } - ], - "name": "UInitializableAlreadyInitializedError", - "type": "error" - }, - { - "inputs": [], - "name": "UInitializableNotInitializingError", - "type": "error" - }, - { - "inputs": [], - "name": "UInitializableZeroVersionError", - "type": "error" - }, - { - "inputs": [], - "name": "UReentrancyGuardReentrantCallError", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "programId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "Claim", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "Token18", - "name": "token", - "type": "address" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "FeeClaim", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "version", - "type": "uint256" - } - ], - "name": "Initialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "programId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "version", - "type": "uint256" - } - ], - "name": "ProgramComplete", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "programId", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "amount", - "type": "tuple" - }, - { - "internalType": "uint256", - "name": "start", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "duration", - "type": "uint256" - }, - { - "internalType": "Token18", - "name": "token", - "type": "address" - } - ], - "indexed": false, - "internalType": "struct ProgramInfo", - "name": "programInfo", - "type": "tuple" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "programFeeAmount", - "type": "uint256" - } - ], - "name": "ProgramCreated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "programId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "version", - "type": "uint256" - } - ], - "name": "ProgramStarted", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "active", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "uint256", - "name": "programId", - "type": "uint256" - } - ], - "name": "available", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "uint256[]", - "name": "programIds", - "type": "uint256[]" - } - ], - "name": "claim", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct[]", - "name": "products", - "type": "address[]" - }, - { - "internalType": "uint256[][]", - "name": "programIds", - "type": "uint256[][]" - } - ], - "name": "claim", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "Token18[]", - "name": "tokens", - "type": "address[]" - } - ], - "name": "claimFee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "uint256", - "name": "programId", - "type": "uint256" - } - ], - "name": "complete", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "controller", - "outputs": [ - { - "internalType": "contract IController", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "count", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "components": [ - { - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "amount", - "type": "tuple" - }, - { - "internalType": "uint256", - "name": "start", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "duration", - "type": "uint256" - }, - { - "internalType": "Token18", - "name": "token", - "type": "address" - } - ], - "internalType": "struct ProgramInfo", - "name": "programInfo", - "type": "tuple" - } - ], - "name": "create", - "outputs": [ - { - "internalType": "uint256", - "name": "programId", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "Token18", - "name": "", - "type": "address" - } - ], - "name": "fees", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IController", - "name": "controller_", - "type": "address" - } - ], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "uint256", - "name": "programId", - "type": "uint256" - } - ], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "uint256", - "name": "programId", - "type": "uint256" - } - ], - "name": "programInfos", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "amount", - "type": "tuple" - }, - { - "internalType": "uint256", - "name": "start", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "duration", - "type": "uint256" - }, - { - "internalType": "Token18", - "name": "token", - "type": "address" - } - ], - "internalType": "struct ProgramInfo", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "version", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - }, - { - "internalType": "Fixed18", - "name": "price", - "type": "int256" - } - ], - "internalType": "struct IOracleProvider.OracleVersion", - "name": "currentOracleVersion", - "type": "tuple" - } - ], - "name": "sync", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "components": [ - { - "internalType": "uint256", - "name": "version", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - }, - { - "internalType": "Fixed18", - "name": "price", - "type": "int256" - } - ], - "internalType": "struct IOracleProvider.OracleVersion", - "name": "currentOracleVersion", - "type": "tuple" - } - ], - "name": "syncAccount", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "uint256", - "name": "programId", - "type": "uint256" - } - ], - "name": "treasury", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "uint256", - "name": "programId", - "type": "uint256" - } - ], - "name": "unclaimed", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "uint256", - "name": "programId", - "type": "uint256" - } - ], - "name": "versionComplete", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "uint256", - "name": "programId", - "type": "uint256" - } - ], - "name": "versionStarted", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - } - ], - "transactionHash": "0xbdb5d4287fbb28a2af31e99997983107f98d5f440b93bf68ce1a8d70fd1bac60", - "receipt": { - "to": null, - "from": "0x66a7fDB96C583c59597de16d8b2B989231415339", - "contractAddress": "0x7869fd0EdCFff8C05600CB71826e59a3ad860938", - "transactionIndex": 26, - "gasUsed": "3676487", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x4f3305cfee4983830d6c76daf2511d884548fb4947e94fabdde505bb3b30a6eb", - "transactionHash": "0xbdb5d4287fbb28a2af31e99997983107f98d5f440b93bf68ce1a8d70fd1bac60", - "logs": [], - "blockNumber": 7681108, - "cumulativeGasUsed": "6703813", - "status": 1, - "byzantium": true - }, - "args": [], - "numDeployments": 1, - "solcInputHash": "b6ff42633a62e1bc6c97d8ccad85444b", - "metadata": "{\"compiler\":{\"version\":\"0.8.15+commit.e14f2714\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Fixed18OverflowError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"IncentivizerBatchClaimArgumentMismatchError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"}],\"name\":\"IncentivizerInvalidProgramError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"IncentivizerNotAllowedError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"}],\"name\":\"IncentivizerNotProgramOwnerError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"IncentivizerTooManyProgramsError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidControllerError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotCollateralError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"}],\"name\":\"NotOwnerError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"NotProductError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"PausedError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ProgramInvalidDurationError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ProgramInvalidStartError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"int256\",\"name\":\"value\",\"type\":\"int256\"}],\"name\":\"UFixed18UnderflowError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"UInitializableAlreadyInitializedError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UInitializableNotInitializingError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UInitializableZeroVersionError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UReentrancyGuardReentrantCallError\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Claim\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"Token18\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"FeeClaim\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"ProgramComplete\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"amount\",\"type\":\"tuple\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"duration\",\"type\":\"uint256\"},{\"internalType\":\"Token18\",\"name\":\"token\",\"type\":\"address\"}],\"indexed\":false,\"internalType\":\"struct ProgramInfo\",\"name\":\"programInfo\",\"type\":\"tuple\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"programFeeAmount\",\"type\":\"uint256\"}],\"name\":\"ProgramCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"ProgramStarted\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"active\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"}],\"name\":\"available\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"programIds\",\"type\":\"uint256[]\"}],\"name\":\"claim\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct[]\",\"name\":\"products\",\"type\":\"address[]\"},{\"internalType\":\"uint256[][]\",\"name\":\"programIds\",\"type\":\"uint256[][]\"}],\"name\":\"claim\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"Token18[]\",\"name\":\"tokens\",\"type\":\"address[]\"}],\"name\":\"claimFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"}],\"name\":\"complete\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"controller\",\"outputs\":[{\"internalType\":\"contract IController\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"count\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"amount\",\"type\":\"tuple\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"duration\",\"type\":\"uint256\"},{\"internalType\":\"Token18\",\"name\":\"token\",\"type\":\"address\"}],\"internalType\":\"struct ProgramInfo\",\"name\":\"programInfo\",\"type\":\"tuple\"}],\"name\":\"create\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"Token18\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"fees\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IController\",\"name\":\"controller_\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"}],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"}],\"name\":\"programInfos\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"amount\",\"type\":\"tuple\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"duration\",\"type\":\"uint256\"},{\"internalType\":\"Token18\",\"name\":\"token\",\"type\":\"address\"}],\"internalType\":\"struct ProgramInfo\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"},{\"internalType\":\"Fixed18\",\"name\":\"price\",\"type\":\"int256\"}],\"internalType\":\"struct IOracleProvider.OracleVersion\",\"name\":\"currentOracleVersion\",\"type\":\"tuple\"}],\"name\":\"sync\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"},{\"internalType\":\"Fixed18\",\"name\":\"price\",\"type\":\"int256\"}],\"internalType\":\"struct IOracleProvider.OracleVersion\",\"name\":\"currentOracleVersion\",\"type\":\"tuple\"}],\"name\":\"syncAccount\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"}],\"name\":\"treasury\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"}],\"name\":\"unclaimed\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"}],\"name\":\"versionComplete\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"}],\"name\":\"versionStarted\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"active(address)\":{\"params\":{\"product\":\"Product to check for\"},\"returns\":{\"_0\":\"Number of active programs\"}},\"available(address,uint256)\":{\"params\":{\"product\":\"Product to return for\",\"programId\":\"Program to return for\"},\"returns\":{\"_0\":\"Available rewards for `programId`\"}},\"claim(address,uint256[])\":{\"params\":{\"product\":\"Product to claim rewards for\",\"programIds\":\"Programs to claim rewards for\"}},\"claim(address[],uint256[][])\":{\"params\":{\"products\":\"Products to claim rewards for\",\"programIds\":\"Programs to claim rewards for\"}},\"claimFee(address[])\":{\"params\":{\"tokens\":\"Tokens to claim fees for\"}},\"complete(address,uint256)\":{\"details\":\"Must be called as the program owner\",\"params\":{\"product\":\"Product that the program is running on\",\"programId\":\"Program to complete early\"}},\"count(address)\":{\"params\":{\"product\":\"Product to check for\"},\"returns\":{\"_0\":\"Number of programs (inactive or active)\"}},\"create(address,(uint256,(uint256,uint256),uint256,uint256,address))\":{\"details\":\"Must be called as the product or protocol owner\",\"params\":{\"product\":\"The product to create the new program on\",\"programInfo\":\"Parameters for the new program\"},\"returns\":{\"programId\":\"New program's ID\"}},\"initialize(address)\":{\"details\":\"Must be called atomically as part of the upgradeable proxy deployment to avoid front-running\",\"params\":{\"controller_\":\"Factory contract address\"}},\"owner(address,uint256)\":{\"params\":{\"product\":\"Product to return for\",\"programId\":\"Program to return for\"},\"returns\":{\"_0\":\"The owner of `programId`\"}},\"programInfos(address,uint256)\":{\"params\":{\"product\":\"Product to return for\",\"programId\":\"Program to return for\"},\"returns\":{\"_0\":\"Program info\"}},\"sync((uint256,uint256,int256))\":{\"details\":\"Called every settle() from each product\",\"params\":{\"currentOracleVersion\":\"The preloaded current oracle version\"}},\"syncAccount(address,(uint256,uint256,int256))\":{\"details\":\"Called immediately proceeding a position update in the corresponding product\",\"params\":{\"account\":\"Account to sync\",\"currentOracleVersion\":\"The preloaded current oracle version\"}},\"treasury(address,uint256)\":{\"params\":{\"product\":\"Product to return for\",\"programId\":\"Program to return for\"},\"returns\":{\"_0\":\"The treasury of `programId`\"}},\"unclaimed(address,address,uint256)\":{\"params\":{\"account\":\"Account to return for\",\"product\":\"Product to return for\",\"programId\":\"Program to return for\"},\"returns\":{\"_0\":\"`account`'s total unclaimed rewards for `programId`\"}},\"versionComplete(address,uint256)\":{\"params\":{\"product\":\"Product to return for\",\"programId\":\"Program to return for\"},\"returns\":{\"_0\":\"The version completed for `programId`\"}},\"versionStarted(address,uint256)\":{\"params\":{\"product\":\"Product to return for\",\"programId\":\"Program to return for\"},\"returns\":{\"_0\":\"The version started for `programId`\"}}},\"stateVariables\":{\"_products\":{\"details\":\"Product management state\"},\"fees\":{\"details\":\"Fees that have been collected, but remain unclaimed\"}},\"title\":\"Incentivizer\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"active(address)\":{\"notice\":\"Returns the quantity of active programs for a given product\"},\"available(address,uint256)\":{\"notice\":\"Returns available rewards for a specific program\"},\"claim(address,uint256[])\":{\"notice\":\"Claims all of `msg.sender`'s rewards for `product` programs\"},\"claim(address[],uint256[][])\":{\"notice\":\"Claims all of `msg.sender`'s rewards for a specific program\"},\"claimFee(address[])\":{\"notice\":\"Claims all `tokens` fees to the protocol treasury\"},\"complete(address,uint256)\":{\"notice\":\"Completes an in-progress program early\"},\"count(address)\":{\"notice\":\"Returns the quantity of programs for a given product\"},\"create(address,(uint256,(uint256,uint256),uint256,uint256,address))\":{\"notice\":\"Creates a new incentive program\"},\"initialize(address)\":{\"notice\":\"Initializes the contract state\"},\"owner(address,uint256)\":{\"notice\":\"Returns the owner of a specific program\"},\"programInfos(address,uint256)\":{\"notice\":\"Returns program info for program `programId`\"},\"sync((uint256,uint256,int256))\":{\"notice\":\"Starts and completes programs as they become available\"},\"syncAccount(address,(uint256,uint256,int256))\":{\"notice\":\"Settles unsettled balance for `account`\"},\"treasury(address,uint256)\":{\"notice\":\"Returns the treasury of a specific program\"},\"unclaimed(address,address,uint256)\":{\"notice\":\"Returns `account`'s total unclaimed rewards for a specific program\"},\"versionComplete(address,uint256)\":{\"notice\":\"Returns the version completed for a specific program\"},\"versionStarted(address,uint256)\":{\"notice\":\"Returns the version started for a specific program\"}},\"notice\":\"Manages logic and state for all incentive programs in the protocol.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/incentivizer/Incentivizer.sol\":\"Incentivizer\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\n\\ninterface IOracleProvider {\\n /// @dev A singular oracle version with its corresponding data\\n struct OracleVersion {\\n /// @dev The iterative version\\n uint256 version;\\n\\n /// @dev the timestamp of the oracle update\\n uint256 timestamp;\\n\\n /// @dev The oracle price of the corresponding version\\n Fixed18 price;\\n }\\n\\n function sync() external returns (OracleVersion memory);\\n function currentVersion() external view returns (OracleVersion memory);\\n function atVersion(uint256 oracleVersion) external view returns (OracleVersion memory);\\n}\\n\",\"keccak256\":\"0xde0f20d468ba8b91addfc356e13f2c74a4dc8abe68be323942217c723775d9c1\",\"license\":\"Apache-2.0\"},\"@equilibria/root/control/unstructured/UInitializable.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/Address.sol\\\";\\nimport \\\"../../storage/UStorage.sol\\\";\\n\\n/**\\n * @title UInitializable\\n * @notice Library to manage the initialization lifecycle of upgradeable contracts\\n * @dev `UInitializable` allows the creation of pseudo-constructors for upgradeable contracts. One\\n * `initializer` should be declared per top-level contract. Child contracts can use the `onlyInitializer`\\n * modifier to tag their internal initialization functions to ensure that they can only be called\\n * from a top-level `initializer` or a constructor.\\n */\\nabstract contract UInitializable {\\n error UInitializableZeroVersionError();\\n error UInitializableAlreadyInitializedError(uint256 version);\\n error UInitializableNotInitializingError();\\n\\n event Initialized(uint256 version);\\n\\n /// @dev The initialized flag\\n Uint256Storage private constant _version = Uint256Storage.wrap(keccak256(\\\"equilibria.root.UInitializable.version\\\"));\\n\\n /// @dev The initializing flag\\n BoolStorage private constant _initializing = BoolStorage.wrap(keccak256(\\\"equilibria.root.UInitializable.initializing\\\"));\\n\\n /// @dev Can only be called once per version, `version` is 1-indexed\\n modifier initializer(uint256 version) {\\n if (version == 0) revert UInitializableZeroVersionError();\\n if (_version.read() >= version) revert UInitializableAlreadyInitializedError(version);\\n\\n _version.store(version);\\n _initializing.store(true);\\n\\n _;\\n\\n _initializing.store(false);\\n emit Initialized(version);\\n }\\n\\n /// @dev Can only be called from an initializer or constructor\\n modifier onlyInitializer() {\\n if (!_constructing() && !_initializing.read()) revert UInitializableNotInitializingError();\\n _;\\n }\\n\\n /**\\n * @notice Returns whether the contract is currently being constructed\\n * @dev {Address.isContract} returns false for contracts currently in the process of being constructed\\n * @return Whether the contract is currently being constructed\\n */\\n function _constructing() private view returns (bool) {\\n return !Address.isContract(address(this));\\n }\\n}\\n\",\"keccak256\":\"0xd2743d8fcc220ed2ccdc0bba1db0a3e107741bd5c0cac47ca8c0b5a00ba2fd7f\",\"license\":\"Apache-2.0\"},\"@equilibria/root/control/unstructured/UReentrancyGuard.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"./UInitializable.sol\\\";\\nimport \\\"../../storage/UStorage.sol\\\";\\n\\n/**\\n * @dev Contract module that helps prevent reentrant calls to a function.\\n *\\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\\n * available, which can be applied to functions to make sure there are no nested\\n * (reentrant) calls to them.\\n *\\n * Note that because there is a single `nonReentrant` guard, functions marked as\\n * `nonReentrant` may not call one another. This can be worked around by making\\n * those functions `private`, and then adding `external` `nonReentrant` entry\\n * points to them.\\n *\\n * TIP: If you would like to learn more about reentrancy and alternative ways\\n * to protect against it, check out our blog post\\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\\n *\\n * NOTE: This contract has been extended from the Open Zeppelin library to include an\\n * unstructured storage pattern, so that it can be safely mixed in with upgradeable\\n * contracts without affecting their storage patterns through inheritance.\\n */\\nabstract contract UReentrancyGuard is UInitializable {\\n error UReentrancyGuardReentrantCallError();\\n\\n uint256 private constant _NOT_ENTERED = 1;\\n uint256 private constant _ENTERED = 2;\\n\\n /**\\n * @dev unstructured storage slot for the reentrancy status\\n */\\n Uint256Storage private constant _status = Uint256Storage.wrap(keccak256(\\\"equilibria.root.UReentrancyGuard.status\\\"));\\n\\n /**\\n * @dev Initializes the contract setting the status to _NOT_ENTERED.\\n */\\n function __UReentrancyGuard__initialize() internal onlyInitializer {\\n _status.store(_NOT_ENTERED);\\n }\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n * Calling a `nonReentrant` function from another `nonReentrant`\\n * function is not supported. It is possible to prevent this from happening\\n * by making the `nonReentrant` function external, and make it call a\\n * `private` function that does the actual work.\\n */\\n modifier nonReentrant() {\\n // On the first call to nonReentrant, _notEntered will be true\\n if (_status.read() == _ENTERED) revert UReentrancyGuardReentrantCallError();\\n\\n // Any calls to nonReentrant after this point will fail\\n _status.store(_ENTERED);\\n\\n _;\\n\\n // By storing the original value once again, a refund is triggered (see\\n // https://eips.ethereum.org/EIPS/eip-2200)\\n _status.store(_NOT_ENTERED);\\n }\\n}\\n\",\"keccak256\":\"0x4962245ca8fdda3dc40c0f942a3568d90fb69428a6927b058018b01c90eb9fc9\",\"license\":\"Apache-2.0\"},\"@equilibria/root/curve/CurveMath.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"../number/types/UFixed18.sol\\\";\\nimport \\\"../number/types/Fixed18.sol\\\";\\n\\n/**\\n * @title CurveMath\\n * @notice Library for managing math operations for utilization curves.\\n */\\nlibrary CurveMath {\\n error CurveMathOutOfBoundsError();\\n\\n /**\\n * @notice Computes a linear interpolation between two points\\n * @param startX First point's x-coordinate\\n * @param startY First point's y-coordinate\\n * @param endX Second point's x-coordinate\\n * @param endY Second point's y-coordinate\\n * @param targetX x-coordinate to interpolate\\n * @return y-coordinate for `targetX` along the line from (`startX`, `startY`) -> (`endX`, `endY`)\\n */\\n function linearInterpolation(\\n UFixed18 startX,\\n Fixed18 startY,\\n UFixed18 endX,\\n Fixed18 endY,\\n UFixed18 targetX\\n ) internal pure returns (Fixed18) {\\n if (targetX.lt(startX) || targetX.gt(endX)) revert CurveMathOutOfBoundsError();\\n\\n UFixed18 xRange = endX.sub(startX);\\n Fixed18 yRange = endY.sub(startY);\\n UFixed18 xRatio = targetX.sub(startX).div(xRange);\\n return yRange.mul(Fixed18Lib.from(xRatio)).add(startY);\\n }\\n}\\n\",\"keccak256\":\"0x60d159f9ddf0dbe81124ecad58bba734b4cf82877637ff8d9d7f3e92f2da4ded\",\"license\":\"Apache-2.0\"},\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"../CurveMath.sol\\\";\\nimport \\\"../../number/types/PackedUFixed18.sol\\\";\\nimport \\\"../../number/types/PackedFixed18.sol\\\";\\n\\n/// @dev JumpRateUtilizationCurve type\\nstruct JumpRateUtilizationCurve {\\n PackedFixed18 minRate;\\n PackedFixed18 maxRate;\\n PackedFixed18 targetRate;\\n PackedUFixed18 targetUtilization;\\n}\\nusing JumpRateUtilizationCurveLib for JumpRateUtilizationCurve global;\\ntype JumpRateUtilizationCurveStorage is bytes32;\\nusing JumpRateUtilizationCurveStorageLib for JumpRateUtilizationCurveStorage global;\\n\\n/**\\n * @title JumpRateUtilizationCurveLib\\n * @notice Library for the Jump Rate utilization curve type\\n */\\nlibrary JumpRateUtilizationCurveLib {\\n /**\\n * @notice Computes the corresponding rate for a utilization ratio\\n * @param utilization The utilization ratio\\n * @return The corresponding rate\\n */\\n function compute(JumpRateUtilizationCurve memory self, UFixed18 utilization) internal pure returns (Fixed18) {\\n UFixed18 targetUtilization = self.targetUtilization.unpack();\\n if (utilization.lt(targetUtilization)) {\\n return CurveMath.linearInterpolation(\\n UFixed18Lib.ZERO,\\n self.minRate.unpack(),\\n targetUtilization,\\n self.targetRate.unpack(),\\n utilization\\n );\\n }\\n if (utilization.lt(UFixed18Lib.ONE)) {\\n return CurveMath.linearInterpolation(\\n targetUtilization,\\n self.targetRate.unpack(),\\n UFixed18Lib.ONE,\\n self.maxRate.unpack(),\\n utilization\\n );\\n }\\n return self.maxRate.unpack();\\n }\\n}\\n\\nlibrary JumpRateUtilizationCurveStorageLib {\\n function read(JumpRateUtilizationCurveStorage self) internal view returns (JumpRateUtilizationCurve memory) {\\n return _storagePointer(self);\\n }\\n\\n function store(JumpRateUtilizationCurveStorage self, JumpRateUtilizationCurve memory value) internal {\\n JumpRateUtilizationCurve storage storagePointer = _storagePointer(self);\\n\\n storagePointer.minRate = value.minRate;\\n storagePointer.maxRate = value.maxRate;\\n storagePointer.targetRate = value.targetRate;\\n storagePointer.targetUtilization = value.targetUtilization;\\n }\\n\\n function _storagePointer(JumpRateUtilizationCurveStorage self)\\n private pure returns (JumpRateUtilizationCurve storage pointer) {\\n assembly { pointer.slot := self }\\n }\\n}\",\"keccak256\":\"0xae202813874bc306d51b3dab8194c86f6483bb20bf1f673ddaee16aa8de567ff\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/Fixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SignedMath.sol\\\";\\nimport \\\"./UFixed18.sol\\\";\\nimport \\\"./PackedFixed18.sol\\\";\\n\\n/// @dev Fixed18 type\\ntype Fixed18 is int256;\\nusing Fixed18Lib for Fixed18 global;\\ntype Fixed18Storage is bytes32;\\nusing Fixed18StorageLib for Fixed18Storage global;\\n\\n/**\\n * @title Fixed18Lib\\n * @notice Library for the signed fixed-decimal type.\\n */\\nlibrary Fixed18Lib {\\n error Fixed18OverflowError(uint256 value);\\n error Fixed18PackingOverflowError(int256 value);\\n error Fixed18PackingUnderflowError(int256 value);\\n\\n int256 private constant BASE = 1e18;\\n Fixed18 public constant ZERO = Fixed18.wrap(0);\\n Fixed18 public constant ONE = Fixed18.wrap(BASE);\\n Fixed18 public constant NEG_ONE = Fixed18.wrap(-1 * BASE);\\n Fixed18 public constant MAX = Fixed18.wrap(type(int256).max);\\n Fixed18 public constant MIN = Fixed18.wrap(type(int256).min);\\n\\n /**\\n * @notice Creates a signed fixed-decimal from an unsigned fixed-decimal\\n * @param a Unsigned fixed-decimal\\n * @return New signed fixed-decimal\\n */\\n function from(UFixed18 a) internal pure returns (Fixed18) {\\n uint256 value = UFixed18.unwrap(a);\\n if (value > uint256(type(int256).max)) revert Fixed18OverflowError(value);\\n return Fixed18.wrap(int256(value));\\n }\\n\\n /**\\n * @notice Creates a signed fixed-decimal from a sign and an unsigned fixed-decimal\\n * @param s Sign\\n * @param m Unsigned fixed-decimal magnitude\\n * @return New signed fixed-decimal\\n */\\n function from(int256 s, UFixed18 m) internal pure returns (Fixed18) {\\n if (s > 0) return from(m);\\n if (s < 0) return Fixed18.wrap(-1 * Fixed18.unwrap(from(m)));\\n return ZERO;\\n }\\n\\n /**\\n * @notice Creates a signed fixed-decimal from a signed integer\\n * @param a Signed number\\n * @return New signed fixed-decimal\\n */\\n function from(int256 a) internal pure returns (Fixed18) {\\n return Fixed18.wrap(a * BASE);\\n }\\n\\n /**\\n * @notice Creates a packed signed fixed-decimal from an signed fixed-decimal\\n * @param a signed fixed-decimal\\n * @return New packed signed fixed-decimal\\n */\\n function pack(Fixed18 a) internal pure returns (PackedFixed18) {\\n int256 value = Fixed18.unwrap(a);\\n if (value > type(int128).max) revert Fixed18PackingOverflowError(value);\\n if (value < type(int128).min) revert Fixed18PackingUnderflowError(value);\\n return PackedFixed18.wrap(int128(value));\\n }\\n\\n /**\\n * @notice Returns whether the signed fixed-decimal is equal to zero.\\n * @param a Signed fixed-decimal\\n * @return Whether the signed fixed-decimal is zero.\\n */\\n function isZero(Fixed18 a) internal pure returns (bool) {\\n return Fixed18.unwrap(a) == 0;\\n }\\n\\n /**\\n * @notice Adds two signed fixed-decimals `a` and `b` together\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Resulting summed signed fixed-decimal\\n */\\n function add(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) + Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Subtracts signed fixed-decimal `b` from `a`\\n * @param a Signed fixed-decimal to subtract from\\n * @param b Signed fixed-decimal to subtract\\n * @return Resulting subtracted signed fixed-decimal\\n */\\n function sub(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) - Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Multiplies two signed fixed-decimals `a` and `b` together\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Resulting multiplied signed fixed-decimal\\n */\\n function mul(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / BASE);\\n }\\n\\n /**\\n * @notice Divides signed fixed-decimal `a` by `b`\\n * @param a Signed fixed-decimal to divide\\n * @param b Signed fixed-decimal to divide by\\n * @return Resulting divided signed fixed-decimal\\n */\\n function div(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * BASE / Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0`, `MAX` for `n/0`, and `MIN` for `-n/0`.\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function unsafeDiv(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n if (isZero(b)) {\\n if (gt(a, ZERO)) return MAX;\\n if (lt(a, ZERO)) return MIN;\\n return ONE;\\n } else {\\n return div(a, b);\\n }\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First signed fixed-decimal\\n * @param b Signed number to multiply by\\n * @param c Signed number to divide by\\n * @return Resulting computation\\n */\\n function muldiv(Fixed18 a, int256 b, int256 c) internal pure returns (Fixed18) {\\n return muldiv(a, Fixed18.wrap(b), Fixed18.wrap(c));\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First signed fixed-decimal\\n * @param b Signed fixed-decimal to multiply by\\n * @param c Signed fixed-decimal to divide by\\n * @return Resulting computation\\n */\\n function muldiv(Fixed18 a, Fixed18 b, Fixed18 c) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / Fixed18.unwrap(c));\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is equal to `b`\\n */\\n function eq(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 1;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is greater than `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is greater than `b`\\n */\\n function gt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 2;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is less than `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is less than `b`\\n */\\n function lt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 0;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is greater than or equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is greater than or equal to `b`\\n */\\n function gte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return gt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is less than or equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is less than or equal to `b`\\n */\\n function lte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return lt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Compares the signed fixed-decimals `a` and `b`\\n * @dev Returns: 2 for greater than\\n * 1 for equal to\\n * 0 for less than\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Compare result of `a` and `b`\\n */\\n function compare(Fixed18 a, Fixed18 b) internal pure returns (uint256) {\\n (int256 au, int256 bu) = (Fixed18.unwrap(a), Fixed18.unwrap(b));\\n if (au > bu) return 2;\\n if (au < bu) return 0;\\n return 1;\\n }\\n\\n /**\\n * @notice Returns a signed fixed-decimal representing the ratio of `a` over `b`\\n * @param a First signed number\\n * @param b Second signed number\\n * @return Ratio of `a` over `b`\\n */\\n function ratio(int256 a, int256 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(a * BASE / b);\\n }\\n\\n /**\\n * @notice Returns the minimum of signed fixed-decimals `a` and `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Minimum of `a` and `b`\\n */\\n function min(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(SignedMath.min(Fixed18.unwrap(a), Fixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Returns the maximum of signed fixed-decimals `a` and `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Maximum of `a` and `b`\\n */\\n function max(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(SignedMath.max(Fixed18.unwrap(a), Fixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Converts the signed fixed-decimal into an integer, truncating any decimal portion\\n * @param a Signed fixed-decimal\\n * @return Truncated signed number\\n */\\n function truncate(Fixed18 a) internal pure returns (int256) {\\n return Fixed18.unwrap(a) / BASE;\\n }\\n\\n /**\\n * @notice Returns the sign of the signed fixed-decimal\\n * @dev Returns: -1 for negative\\n * 0 for zero\\n * 1 for positive\\n * @param a Signed fixed-decimal\\n * @return Sign of the signed fixed-decimal\\n */\\n function sign(Fixed18 a) internal pure returns (int256) {\\n if (Fixed18.unwrap(a) > 0) return 1;\\n if (Fixed18.unwrap(a) < 0) return -1;\\n return 0;\\n }\\n\\n /**\\n * @notice Returns the absolute value of the signed fixed-decimal\\n * @param a Signed fixed-decimal\\n * @return Absolute value of the signed fixed-decimal\\n */\\n function abs(Fixed18 a) internal pure returns (UFixed18) {\\n return UFixed18.wrap(SignedMath.abs(Fixed18.unwrap(a)));\\n }\\n}\\n\\nlibrary Fixed18StorageLib {\\n function read(Fixed18Storage self) internal view returns (Fixed18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(Fixed18Storage self, Fixed18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x613587461ef3437ef33229cdda7d34ea746278721baf06e20b2e43977f43174d\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/PackedFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"./Fixed18.sol\\\";\\n\\n/// @dev PackedFixed18 type\\ntype PackedFixed18 is int128;\\nusing PackedFixed18Lib for PackedFixed18 global;\\n\\n/**\\n * @title PackedFixed18Lib\\n * @dev A packed version of the Fixed18 which takes up half the storage space (two PackedFixed18 can be packed\\n * into a single slot). Only valid within the range -1.7014118e+20 <= x <= 1.7014118e+20.\\n * @notice Library for the packed signed fixed-decimal type.\\n */\\nlibrary PackedFixed18Lib {\\n PackedFixed18 public constant MAX = PackedFixed18.wrap(type(int128).max);\\n PackedFixed18 public constant MIN = PackedFixed18.wrap(type(int128).min);\\n\\n /**\\n * @notice Creates an unpacked signed fixed-decimal from a packed signed fixed-decimal\\n * @param self packed signed fixed-decimal\\n * @return New unpacked signed fixed-decimal\\n */\\n function unpack(PackedFixed18 self) internal pure returns (Fixed18) {\\n return Fixed18.wrap(int256(PackedFixed18.unwrap(self)));\\n }\\n}\\n\",\"keccak256\":\"0xb52960cc8e3132e45d342bbbb1c6a96219022cd8557997933bd8250170268b64\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/PackedUFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"./UFixed18.sol\\\";\\n\\n/// @dev PackedUFixed18 type\\ntype PackedUFixed18 is uint128;\\nusing PackedUFixed18Lib for PackedUFixed18 global;\\n\\n/**\\n * @title PackedUFixed18Lib\\n * @dev A packed version of the UFixed18 which takes up half the storage space (two PackedUFixed18 can be packed\\n * into a single slot). Only valid within the range 0 <= x <= 3.4028237e+20.\\n * @notice Library for the packed unsigned fixed-decimal type.\\n */\\nlibrary PackedUFixed18Lib {\\n PackedUFixed18 public constant MAX = PackedUFixed18.wrap(type(uint128).max);\\n\\n /**\\n * @notice Creates an unpacked unsigned fixed-decimal from a packed unsigned fixed-decimal\\n * @param self packed unsigned fixed-decimal\\n * @return New unpacked unsigned fixed-decimal\\n */\\n function unpack(PackedUFixed18 self) internal pure returns (UFixed18) {\\n return UFixed18.wrap(uint256(PackedUFixed18.unwrap(self)));\\n }\\n}\\n\",\"keccak256\":\"0xb5c5cd32d6530b2fe75228b6be32ebcb7762f6d7988b85a6b85a289ce8256d51\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/UFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"./Fixed18.sol\\\";\\nimport \\\"./PackedUFixed18.sol\\\";\\n\\n/// @dev UFixed18 type\\ntype UFixed18 is uint256;\\nusing UFixed18Lib for UFixed18 global;\\ntype UFixed18Storage is bytes32;\\nusing UFixed18StorageLib for UFixed18Storage global;\\n\\n/**\\n * @title UFixed18Lib\\n * @notice Library for the unsigned fixed-decimal type.\\n */\\nlibrary UFixed18Lib {\\n error UFixed18UnderflowError(int256 value);\\n error UFixed18PackingOverflowError(uint256 value);\\n\\n uint256 private constant BASE = 1e18;\\n UFixed18 public constant ZERO = UFixed18.wrap(0);\\n UFixed18 public constant ONE = UFixed18.wrap(BASE);\\n UFixed18 public constant MAX = UFixed18.wrap(type(uint256).max);\\n\\n /**\\n * @notice Creates a unsigned fixed-decimal from a signed fixed-decimal\\n * @param a Signed fixed-decimal\\n * @return New unsigned fixed-decimal\\n */\\n function from(Fixed18 a) internal pure returns (UFixed18) {\\n int256 value = Fixed18.unwrap(a);\\n if (value < 0) revert UFixed18UnderflowError(value);\\n return UFixed18.wrap(uint256(value));\\n }\\n\\n /**\\n * @notice Creates a unsigned fixed-decimal from a unsigned integer\\n * @param a Unsigned number\\n * @return New unsigned fixed-decimal\\n */\\n function from(uint256 a) internal pure returns (UFixed18) {\\n return UFixed18.wrap(a * BASE);\\n }\\n\\n /**\\n * @notice Creates a packed unsigned fixed-decimal from an unsigned fixed-decimal\\n * @param a unsigned fixed-decimal\\n * @return New packed unsigned fixed-decimal\\n */\\n function pack(UFixed18 a) internal pure returns (PackedUFixed18) {\\n uint256 value = UFixed18.unwrap(a);\\n if (value > type(uint128).max) revert UFixed18PackingOverflowError(value);\\n return PackedUFixed18.wrap(uint128(value));\\n }\\n\\n /**\\n * @notice Returns whether the unsigned fixed-decimal is equal to zero.\\n * @param a Unsigned fixed-decimal\\n * @return Whether the unsigned fixed-decimal is zero.\\n */\\n function isZero(UFixed18 a) internal pure returns (bool) {\\n return UFixed18.unwrap(a) == 0;\\n }\\n\\n /**\\n * @notice Adds two unsigned fixed-decimals `a` and `b` together\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Resulting summed unsigned fixed-decimal\\n */\\n function add(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) + UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Subtracts unsigned fixed-decimal `b` from `a`\\n * @param a Unsigned fixed-decimal to subtract from\\n * @param b Unsigned fixed-decimal to subtract\\n * @return Resulting subtracted unsigned fixed-decimal\\n */\\n function sub(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) - UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Multiplies two unsigned fixed-decimals `a` and `b` together\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Resulting multiplied unsigned fixed-decimal\\n */\\n function mul(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / BASE);\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function div(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * BASE / UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0` and `MAX` for `n/0`.\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function unsafeDiv(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n if (isZero(b)) {\\n return isZero(a) ? ONE : MAX;\\n } else {\\n return div(a, b);\\n }\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First unsigned fixed-decimal\\n * @param b Unsigned number to multiply by\\n * @param c Unsigned number to divide by\\n * @return Resulting computation\\n */\\n function muldiv(UFixed18 a, uint256 b, uint256 c) internal pure returns (UFixed18) {\\n return muldiv(a, UFixed18.wrap(b), UFixed18.wrap(c));\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First unsigned fixed-decimal\\n * @param b Unsigned fixed-decimal to multiply by\\n * @param c Unsigned fixed-decimal to divide by\\n * @return Resulting computation\\n */\\n function muldiv(UFixed18 a, UFixed18 b, UFixed18 c) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / UFixed18.unwrap(c));\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is equal to `b`\\n */\\n function eq(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 1;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is greater than `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is greater than `b`\\n */\\n function gt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 2;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is less than `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is less than `b`\\n */\\n function lt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 0;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is greater than or equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is greater than or equal to `b`\\n */\\n function gte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return gt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is less than or equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is less than or equal to `b`\\n */\\n function lte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return lt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Compares the unsigned fixed-decimals `a` and `b`\\n * @dev Returns: 2 for greater than\\n * 1 for equal to\\n * 0 for less than\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Compare result of `a` and `b`\\n */\\n function compare(UFixed18 a, UFixed18 b) internal pure returns (uint256) {\\n (uint256 au, uint256 bu) = (UFixed18.unwrap(a), UFixed18.unwrap(b));\\n if (au > bu) return 2;\\n if (au < bu) return 0;\\n return 1;\\n }\\n\\n /**\\n * @notice Returns a unsigned fixed-decimal representing the ratio of `a` over `b`\\n * @param a First unsigned number\\n * @param b Second unsigned number\\n * @return Ratio of `a` over `b`\\n */\\n function ratio(uint256 a, uint256 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(a * BASE / b);\\n }\\n\\n /**\\n * @notice Returns the minimum of unsigned fixed-decimals `a` and `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Minimum of `a` and `b`\\n */\\n function min(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(Math.min(UFixed18.unwrap(a), UFixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Returns the maximum of unsigned fixed-decimals `a` and `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Maximum of `a` and `b`\\n */\\n function max(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(Math.max(UFixed18.unwrap(a), UFixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Converts the unsigned fixed-decimal into an integer, truncating any decimal portion\\n * @param a Unsigned fixed-decimal\\n * @return Truncated unsigned number\\n */\\n function truncate(UFixed18 a) internal pure returns (uint256) {\\n return UFixed18.unwrap(a) / BASE;\\n }\\n}\\n\\nlibrary UFixed18StorageLib {\\n function read(UFixed18Storage self) internal view returns (UFixed18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(UFixed18Storage self, UFixed18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x8ebef1e6c717f565b9ed545a876b5692b4007e6485c99f39d363f7405e591792\",\"license\":\"Apache-2.0\"},\"@equilibria/root/storage/UStorage.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"../number/types/UFixed18.sol\\\";\\n\\n/// @dev Stored boolean slot\\ntype BoolStorage is bytes32;\\nusing BoolStorageLib for BoolStorage global;\\n\\n/// @dev Stored uint256 slot\\ntype Uint256Storage is bytes32;\\nusing Uint256StorageLib for Uint256Storage global;\\n\\n/// @dev Stored int256 slot\\ntype Int256Storage is bytes32;\\nusing Int256StorageLib for Int256Storage global;\\n\\n/// @dev Stored address slot\\ntype AddressStorage is bytes32;\\nusing AddressStorageLib for AddressStorage global;\\n\\n/// @dev Stored bytes32 slot\\ntype Bytes32Storage is bytes32;\\nusing Bytes32StorageLib for Bytes32Storage global;\\n\\n/**\\n * @title BoolStorageLib\\n * @notice Library to manage storage and retrival of a boolean at a fixed storage slot\\n */\\nlibrary BoolStorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored bool value\\n */\\n function read(BoolStorage self) internal view returns (bool value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value boolean value to store\\n */\\n function store(BoolStorage self, bool value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\\n/**\\n * @title Uint256StorageLib\\n * @notice Library to manage storage and retrival of an uint256 at a fixed storage slot\\n */\\nlibrary Uint256StorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored uint256 value\\n */\\n function read(Uint256Storage self) internal view returns (uint256 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value uint256 value to store\\n */\\n function store(Uint256Storage self, uint256 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\\n/**\\n * @title Int256StorageLib\\n * @notice Library to manage storage and retrival of an int256 at a fixed storage slot\\n */\\nlibrary Int256StorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored int256 value\\n */\\n function read(Int256Storage self) internal view returns (int256 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value int256 value to store\\n */\\n function store(Int256Storage self, int256 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\\n/**\\n * @title AddressStorageLib\\n * @notice Library to manage storage and retrival of an address at a fixed storage slot\\n */\\nlibrary AddressStorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored address value\\n */\\n function read(AddressStorage self) internal view returns (address value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value address value to store\\n */\\n function store(AddressStorage self, address value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\\n/**\\n * @title Bytes32StorageLib\\n * @notice Library to manage storage and retrival of a bytes32 at a fixed storage slot\\n */\\nlibrary Bytes32StorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored bytes32 value\\n */\\n function read(Bytes32Storage self) internal view returns (bytes32 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value bytes32 value to store\\n */\\n function store(Bytes32Storage self, bytes32 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0xe2b8491d1b5aa93f7e059e1a8f156b0ab37fef9ed973be97a64f2eabfc2cc172\",\"license\":\"Apache-2.0\"},\"@equilibria/root/token/types/Token18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"../../number/types/UFixed18.sol\\\";\\n\\n/// @dev Token18\\ntype Token18 is address;\\nusing Token18Lib for Token18 global;\\ntype Token18Storage is bytes32;\\nusing Token18StorageLib for Token18Storage global;\\n\\n/**\\n * @title Token18Lib\\n * @notice Library to manage 18-decimal ERC20s that is compliant with the fixed-decimal types.\\n * @dev Maintains significant gas savings over other Token implementations since no conversion take place\\n */\\nlibrary Token18Lib {\\n using SafeERC20 for IERC20;\\n\\n Token18 public constant ZERO = Token18.wrap(address(0));\\n\\n /**\\n * @notice Returns whether a token is the zero address\\n * @param self Token to check for\\n * @return Whether the token is the zero address\\n */\\n function isZero(Token18 self) internal pure returns (bool) {\\n return Token18.unwrap(self) == Token18.unwrap(ZERO);\\n }\\n\\n /**\\n * @notice Returns whether the two tokens are equal\\n * @param a First token to compare\\n * @param b Second token to compare\\n * @return Whether the two tokens are equal\\n */\\n function eq(Token18 a, Token18 b) internal pure returns (bool) {\\n return Token18.unwrap(a) == Token18.unwrap(b);\\n }\\n\\n /**\\n * @notice Approves `grantee` to spend infinite tokens from the caller\\n * @param self Token to transfer\\n * @param grantee Address to allow spending\\n */\\n function approve(Token18 self, address grantee) internal {\\n IERC20(Token18.unwrap(self)).safeApprove(grantee, type(uint256).max);\\n }\\n\\n /**\\n * @notice Approves `grantee` to spend `amount` tokens from the caller\\n * @dev There are important race conditions to be aware of when using this function\\n with values other than 0. This will revert if moving from non-zero to non-zero amounts\\n See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/a55b7d13722e7ce850b626da2313f3e66ca1d101/contracts/token/ERC20/IERC20.sol#L57\\n * @param self Token to transfer\\n * @param grantee Address to allow spending\\n * @param amount Amount of tokens to approve to spend\\n */\\n function approve(Token18 self, address grantee, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeApprove(grantee, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers all held tokens from the caller to the `recipient`\\n * @param self Token to transfer\\n * @param recipient Address to receive the tokens\\n */\\n function push(Token18 self, address recipient) internal {\\n push(self, recipient, balanceOf(self, address(this)));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the caller to the `recipient`\\n * @param self Token to transfer\\n * @param recipient Address to transfer tokens to\\n * @param amount Amount of tokens to transfer\\n */\\n function push(Token18 self, address recipient, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransfer(recipient, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the `benefactor` to the caller\\n * @dev Reverts if trying to pull Ether\\n * @param self Token to transfer\\n * @param benefactor Address to transfer tokens from\\n * @param amount Amount of tokens to transfer\\n */\\n function pull(Token18 self, address benefactor, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, address(this), UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the `benefactor` to `recipient`\\n * @dev Reverts if trying to pull Ether\\n * @param self Token to transfer\\n * @param benefactor Address to transfer tokens from\\n * @param recipient Address to transfer tokens to\\n * @param amount Amount of tokens to transfer\\n */\\n function pullTo(Token18 self, address benefactor, address recipient, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, recipient, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Returns the name of the token\\n * @param self Token to check for\\n * @return Token name\\n */\\n function name(Token18 self) internal view returns (string memory) {\\n return IERC20Metadata(Token18.unwrap(self)).name();\\n }\\n\\n /**\\n * @notice Returns the symbol of the token\\n * @param self Token to check for\\n * @return Token symbol\\n */\\n function symbol(Token18 self) internal view returns (string memory) {\\n return IERC20Metadata(Token18.unwrap(self)).symbol();\\n }\\n\\n /**\\n * @notice Returns the `self` token balance of the caller\\n * @param self Token to check for\\n * @return Token balance of the caller\\n */\\n function balanceOf(Token18 self) internal view returns (UFixed18) {\\n return balanceOf(self, address(this));\\n }\\n\\n /**\\n * @notice Returns the `self` token balance of `account`\\n * @param self Token to check for\\n * @param account Account to check\\n * @return Token balance of the account\\n */\\n function balanceOf(Token18 self, address account) internal view returns (UFixed18) {\\n return UFixed18.wrap(IERC20(Token18.unwrap(self)).balanceOf(account));\\n }\\n}\\n\\nlibrary Token18StorageLib {\\n function read(Token18Storage self) internal view returns (Token18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(Token18Storage self, Token18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x6b12afaece814f0ab186200a4729e93eb685a21d3e9b5a3372ff283a7ad5dc23\",\"license\":\"Apache-2.0\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\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 amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` 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(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\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\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 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 using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\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 function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc3d946432c0ddbb1f846a0d3985be71299df331b91d06732152117f62f0be2b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // 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\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return 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 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 up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a / b + (a % b == 0 ? 0 : 1);\\n }\\n}\\n\",\"keccak256\":\"0xc995bddbca1ae19788db9f8b61e63385edd3fddf89693b612d5abd1a275974d2\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SignedMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/SignedMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard signed math utilities missing in the Solidity language.\\n */\\nlibrary SignedMath {\\n /**\\n * @dev Returns the largest of two signed numbers.\\n */\\n function max(int256 a, int256 b) internal pure returns (int256) {\\n return 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 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 // must be unchecked in order to support `n = type(int256).min`\\n return uint256(n >= 0 ? n : -n);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb3ebde1c8d27576db912d87c3560dab14adfb9cd001be95890ec4ba035e652e7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/structs/EnumerableSet.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n return _values(set._inner);\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0xacac2065b3ed1facff1163435890d4a6bcdc474e857e8e2c91ae5fb50418f723\",\"license\":\"MIT\"},\"contracts/controller/UControllerProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"@equilibria/root/control/unstructured/UInitializable.sol\\\";\\nimport \\\"@equilibria/root/storage/UStorage.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/Address.sol\\\";\\nimport \\\"../interfaces/IController.sol\\\";\\nimport \\\"../interfaces/IProduct.sol\\\";\\n\\n/**\\n * @title UControllerProvider\\n * @notice Mix-in that manages a controller pointer and associated permissioning modifiers.\\n * @dev Uses unstructured storage so that it is safe to mix-in to upgreadable contracts without modifying\\n * their storage layout.\\n */\\nabstract contract UControllerProvider is UInitializable {\\n error NotOwnerError(uint256 coordinatorId);\\n error NotProductError(IProduct product);\\n error NotCollateralError();\\n error PausedError();\\n error InvalidControllerError();\\n\\n /// @dev The controller contract address\\n AddressStorage private constant _controller = AddressStorage.wrap(keccak256(\\\"equilibria.perennial.UControllerProvider.controller\\\"));\\n function controller() public view returns (IController) { return IController(_controller.read()); }\\n\\n /**\\n * @notice Initializes the contract state\\n * @param controller_ Protocol Controller contract address\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function __UControllerProvider__initialize(IController controller_) internal onlyInitializer {\\n if (!Address.isContract(address(controller_))) revert InvalidControllerError();\\n _controller.store(address(controller_));\\n }\\n\\n /// @dev Only allow a valid product contract to call\\n modifier onlyProduct {\\n if (!controller().isProduct(IProduct(msg.sender))) revert NotProductError(IProduct(msg.sender));\\n\\n _;\\n }\\n\\n /// @dev Verify that `product` is a valid product contract\\n modifier isProduct(IProduct product) {\\n if (!controller().isProduct(product)) revert NotProductError(product);\\n\\n _;\\n }\\n\\n /// @dev Only allow the Collateral contract to call\\n modifier onlyCollateral {\\n if (msg.sender != address(controller().collateral())) revert NotCollateralError();\\n\\n _;\\n }\\n\\n /// @dev Only allow the coordinator owner to call\\n modifier onlyOwner(uint256 coordinatorId) {\\n if (msg.sender != controller().owner(coordinatorId)) revert NotOwnerError(coordinatorId);\\n\\n _;\\n }\\n\\n /// @dev Only allow if the protocol is currently unpaused\\n modifier notPaused() {\\n if (controller().paused()) revert PausedError();\\n\\n _;\\n }\\n}\\n\",\"keccak256\":\"0x10c6f4ae1a3a511aad470e40c61de5b2171f4151e2dea000acd2ffbd26dcbc2a\",\"license\":\"Apache-2.0\"},\"contracts/incentivizer/Incentivizer.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"@equilibria/root/control/unstructured/UInitializable.sol\\\";\\nimport \\\"@equilibria/root/control/unstructured/UReentrancyGuard.sol\\\";\\nimport \\\"../interfaces/IIncentivizer.sol\\\";\\nimport \\\"../interfaces/IController.sol\\\";\\nimport \\\"../controller/UControllerProvider.sol\\\";\\nimport \\\"./types/ProductManager.sol\\\";\\n\\n/**\\n * @title Incentivizer\\n * @notice Manages logic and state for all incentive programs in the protocol.\\n */\\ncontract Incentivizer is IIncentivizer, UInitializable, UControllerProvider, UReentrancyGuard {\\n /// @dev Product management state\\n mapping(IProduct => ProductManager) private _products;\\n\\n /// @dev Fees that have been collected, but remain unclaimed\\n mapping(Token18 => UFixed18) public fees;\\n\\n /**\\n * @notice Initializes the contract state\\n * @dev Must be called atomically as part of the upgradeable proxy deployment to\\n * avoid front-running\\n * @param controller_ Factory contract address\\n */\\n function initialize(IController controller_) external initializer(1) {\\n __UControllerProvider__initialize(controller_);\\n __UReentrancyGuard__initialize();\\n }\\n\\n /**\\n * @notice Creates a new incentive program\\n * @dev Must be called as the product or protocol owner\\n * @param product The product to create the new program on\\n * @param programInfo Parameters for the new program\\n * @return programId New program's ID\\n */\\n function create(IProduct product, ProgramInfo calldata programInfo)\\n external\\n nonReentrant\\n isProduct(product)\\n notPaused\\n onlyOwner(programInfo.coordinatorId)\\n returns (uint256 programId) {\\n IController _controller = controller();\\n\\n // Validate\\n if (programInfo.coordinatorId != 0 && programInfo.coordinatorId != _controller.coordinatorFor(product))\\n revert IncentivizerNotAllowedError(product);\\n if (active(product) >= _controller.programsPerProduct())\\n revert IncentivizerTooManyProgramsError();\\n ProgramInfoLib.validate(programInfo);\\n\\n // Take fee\\n (ProgramInfo memory newProgramInfo, UFixed18 programFeeAmount) = ProgramInfoLib.deductFee(programInfo, _controller.incentivizationFee());\\n fees[newProgramInfo.token] = fees[newProgramInfo.token].add(programFeeAmount);\\n\\n // Register program\\n programId = _products[product].register(newProgramInfo);\\n\\n // Charge creator\\n newProgramInfo.token.pull(msg.sender, programInfo.amount.sum());\\n\\n emit ProgramCreated(\\n product,\\n programId,\\n newProgramInfo,\\n programFeeAmount\\n );\\n }\\n\\n /**\\n * @notice Completes an in-progress program early\\n * @dev Must be called as the program owner\\n * @param product Product that the program is running on\\n * @param programId Program to complete early\\n */\\n function complete(IProduct product, uint256 programId)\\n external\\n nonReentrant\\n isProgram(product, programId)\\n notPaused\\n onlyProgramOwner(product, programId)\\n {\\n ProductManagerLib.SyncResult memory syncResult = _products[product].complete(product, programId);\\n _handleSyncResult(product, syncResult);\\n }\\n\\n /**\\n * @notice Starts and completes programs as they become available\\n * @dev Called every settle() from each product\\n * @param currentOracleVersion The preloaded current oracle version\\n */\\n function sync(IOracleProvider.OracleVersion memory currentOracleVersion) external onlyProduct {\\n IProduct product = IProduct(msg.sender);\\n\\n ProductManagerLib.SyncResult[] memory syncResults = _products[product].sync(product, currentOracleVersion);\\n for (uint256 i = 0; i < syncResults.length; i++) {\\n _handleSyncResult(product, syncResults[i]);\\n }\\n }\\n\\n /**\\n * @notice Handles refunding and event emitting on program start and completion\\n * @param product Product that the program is running on\\n * @param syncResult The data from the sync event to handle\\n */\\n function _handleSyncResult(IProduct product, ProductManagerLib.SyncResult memory syncResult) private {\\n uint256 programId = syncResult.programId;\\n if (!syncResult.refundAmount.isZero())\\n _products[product].token(programId).push(treasury(product, programId), syncResult.refundAmount);\\n if (syncResult.versionStarted != 0)\\n emit ProgramStarted(product, programId, syncResult.versionStarted);\\n if (syncResult.versionComplete != 0)\\n emit ProgramComplete(product, programId, syncResult.versionComplete);\\n }\\n\\n /**\\n * @notice Settles unsettled balance for `account`\\n * @dev Called immediately proceeding a position update in the corresponding product\\n * @param account Account to sync\\n * @param currentOracleVersion The preloaded current oracle version\\n */\\n function syncAccount(\\n address account,\\n IOracleProvider.OracleVersion memory currentOracleVersion\\n ) external onlyProduct {\\n IProduct product = IProduct(msg.sender);\\n _products[product].syncAccount(product, account, currentOracleVersion);\\n }\\n\\n /**\\n * @notice Claims all of `msg.sender`'s rewards for `product` programs\\n * @param product Product to claim rewards for\\n * @param programIds Programs to claim rewards for\\n */\\n function claim(IProduct product, uint256[] calldata programIds)\\n external\\n nonReentrant\\n {\\n _claimProduct(product, programIds);\\n }\\n\\n /**\\n * @notice Claims all of `msg.sender`'s rewards for a specific program\\n * @param products Products to claim rewards for\\n * @param programIds Programs to claim rewards for\\n */\\n function claim(IProduct[] calldata products, uint256[][] calldata programIds)\\n external\\n nonReentrant\\n {\\n if (products.length != programIds.length) revert IncentivizerBatchClaimArgumentMismatchError();\\n for (uint256 i; i < products.length; i++) {\\n _claimProduct(products[i], programIds[i]);\\n }\\n }\\n\\n /**\\n * @notice Claims all of `msg.sender`'s rewards for `product` programs\\n * @dev Internal helper with validation checks\\n * @param product Product to claim rewards for\\n * @param programIds Programs to claim rewards for\\n */\\n function _claimProduct(IProduct product, uint256[] memory programIds)\\n private\\n isProduct(product)\\n notPaused\\n settleForAccount(msg.sender, product)\\n {\\n for (uint256 i; i < programIds.length; i++) {\\n _claimProgram(product, programIds[i]);\\n }\\n }\\n\\n /**\\n * @notice Claims all of `msg.sender`'s rewards for `programId` on `product`\\n * @dev Internal helper with validation checks\\n * @param product Product to claim rewards for\\n * @param programId Program to claim rewards for\\n */\\n function _claimProgram(IProduct product, uint256 programId)\\n private\\n isProgram(product, programId)\\n {\\n ProductManager storage productManager = _products[product];\\n UFixed18 claimAmount = productManager.claim(msg.sender, programId);\\n productManager.token(programId).push(msg.sender, claimAmount);\\n emit Claim(product, msg.sender, programId, claimAmount);\\n }\\n\\n /**\\n * @notice Claims all `tokens` fees to the protocol treasury\\n * @param tokens Tokens to claim fees for\\n */\\n function claimFee(Token18[] calldata tokens) external notPaused {\\n for(uint256 i; i < tokens.length; i++) {\\n Token18 token = tokens[i];\\n UFixed18 amount = fees[token];\\n\\n fees[token] = UFixed18Lib.ZERO;\\n token.push(controller().treasury(), amount);\\n\\n emit FeeClaim(token, amount);\\n }\\n }\\n\\n /**\\n * @notice Returns the quantity of active programs for a given product\\n * @param product Product to check for\\n * @return Number of active programs\\n */\\n function active(IProduct product) public view returns (uint256) {\\n return _products[product].active();\\n }\\n\\n /**\\n * @notice Returns the quantity of programs for a given product\\n * @param product Product to check for\\n * @return Number of programs (inactive or active)\\n */\\n function count(IProduct product) external view returns (uint256) {\\n return _products[product].programInfos.length;\\n }\\n\\n /**\\n * @notice Returns program info for program `programId`\\n * @param product Product to return for\\n * @param programId Program to return for\\n * @return Program info\\n */\\n function programInfos(IProduct product, uint256 programId) external view returns (ProgramInfo memory) {\\n return _products[product].programInfos[programId];\\n }\\n\\n /**\\n * @notice Returns `account`'s total unclaimed rewards for a specific program\\n * @param product Product to return for\\n * @param account Account to return for\\n * @param programId Program to return for\\n * @return `account`'s total unclaimed rewards for `programId`\\n */\\n function unclaimed(IProduct product, address account, uint256 programId) external view returns (UFixed18) {\\n return _products[product].unclaimed(account, programId);\\n }\\n\\n /**\\n * @notice Returns available rewards for a specific program\\n * @param product Product to return for\\n * @param programId Program to return for\\n * @return Available rewards for `programId`\\n */\\n function available(IProduct product, uint256 programId) external view returns (UFixed18) {\\n return _products[product].programs[programId].available;\\n }\\n\\n /**\\n * @notice Returns the version started for a specific program\\n * @param product Product to return for\\n * @param programId Program to return for\\n * @return The version started for `programId`\\n */\\n function versionStarted(IProduct product, uint256 programId) external view returns (uint256) {\\n return _products[product].programs[programId].versionStarted;\\n }\\n\\n /**\\n * @notice Returns the version completed for a specific program\\n * @param product Product to return for\\n * @param programId Program to return for\\n * @return The version completed for `programId`\\n */\\n function versionComplete(IProduct product, uint256 programId) external view returns (uint256) {\\n return _products[product].programs[programId].versionComplete;\\n }\\n\\n /**\\n * @notice Returns the owner of a specific program\\n * @param product Product to return for\\n * @param programId Program to return for\\n * @return The owner of `programId`\\n */\\n function owner(IProduct product, uint256 programId) public view returns (address) {\\n return controller().owner(_products[product].programInfos[programId].coordinatorId);\\n }\\n\\n /**\\n * @notice Returns the treasury of a specific program\\n * @param product Product to return for\\n * @param programId Program to return for\\n * @return The treasury of `programId`\\n */\\n function treasury(IProduct product, uint256 programId) public view returns (address) {\\n return controller().treasury(_products[product].programInfos[programId].coordinatorId);\\n }\\n\\n /// @dev Helper to fully settle an account's state\\n modifier settleForAccount(address account, IProduct product) {\\n product.settleAccount(account);\\n\\n _;\\n }\\n\\n /// @dev Only allow the owner of `programId` to call\\n modifier onlyProgramOwner(IProduct product, uint256 programId) {\\n if (msg.sender != owner(product, programId)) revert IncentivizerNotProgramOwnerError(product, programId);\\n\\n _;\\n }\\n\\n /// @dev Only allow a valid `programId`\\n modifier isProgram(IProduct product, uint256 programId) {\\n if (!_products[product].valid(programId)) revert IncentivizerInvalidProgramError(product, programId);\\n\\n _;\\n }\\n}\\n\",\"keccak256\":\"0x7b22c1099ba0a72ca4ef8d87cfc2fbb66cf0c28e43faa59a6af71369d8a06aa9\",\"license\":\"Apache-2.0\"},\"contracts/incentivizer/types/ProductManager.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\nimport \\\"./Program.sol\\\";\\n\\n/// @dev ProductManager type\\nstruct ProductManager {\\n /// @dev Static program state\\n ProgramInfo[] programInfos;\\n\\n /// @dev Dynamic program state\\n mapping(uint256 => Program) programs;\\n\\n /// @dev Mapping of all active programs for each product\\n EnumerableSet.UintSet activePrograms;\\n\\n /// @dev Mapping of all active programs for each user\\n mapping(address => EnumerableSet.UintSet) activeProgramsFor;\\n\\n /// @dev Mapping of the next program to watch for for each user\\n mapping(address => uint256) nextProgramFor;\\n}\\nusing ProductManagerLib for ProductManager global;\\n\\n/**\\n * @title ProductManagerLib\\n * @notice Library that manages each product's incentivization state and logic.\\n */\\nlibrary ProductManagerLib {\\n using EnumerableSet for EnumerableSet.UintSet;\\n\\n /// @dev Result data for a sync event\\n struct SyncResult {\\n /// @dev The programId that was updated\\n uint256 programId;\\n\\n /// @dev If non-zero, the new versionStart value of the program\\n uint256 versionStarted;\\n\\n /// @dev If non-zero, the new versionComplete value of the program\\n uint256 versionComplete;\\n\\n /// @dev If non-zero, the amount to refund due to completion\\n UFixed18 refundAmount;\\n }\\n\\n /**\\n * @notice Registers a new program on this product\\n * @param self The Product manager to operate on\\n * @param programInfo The static program info\\n * @return programId The new program's ID\\n */\\n function register(\\n ProductManager storage self,\\n ProgramInfo memory programInfo\\n ) internal returns (uint256 programId) {\\n programId = self.programInfos.length;\\n self.programInfos.push(programInfo);\\n self.programs[programId].initialize(programInfo);\\n self.activePrograms.add(programId);\\n }\\n\\n /**\\n * @notice Syncs this product with the latest data\\n * @param self The Program manager to operate on\\n * @param product This Product\\n * @param currentOracleVersion The preloaded current oracle version\\n */\\n function sync(\\n ProductManager storage self,\\n IProduct product,\\n IOracleProvider.OracleVersion memory currentOracleVersion\\n ) internal returns (SyncResult[] memory results) {\\n\\n uint256[] memory activeProgramIds = self.activePrograms.values();\\n results = new SyncResult[](activeProgramIds.length);\\n\\n for (uint256 i; i < activeProgramIds.length; i++) {\\n // Load program\\n uint256 programId = activeProgramIds[i];\\n ProgramInfo memory programInfo = self.programInfos[programId];\\n Program storage program = self.programs[programId];\\n\\n // If timestamp-started, grab current version (first version after start)\\n uint256 versionStarted;\\n if (program.versionStarted == 0 && programInfo.isStarted(currentOracleVersion.timestamp)) {\\n versionStarted = _start(self, programId, currentOracleVersion);\\n }\\n\\n // If timestamp-completed, grab previous version (last version before completion)\\n uint256 versionComplete;\\n UFixed18 refundAmount;\\n if (program.versionComplete == 0 && programInfo.isComplete(currentOracleVersion.timestamp)) {\\n (versionComplete, refundAmount) = _complete(self, product, programId);\\n }\\n\\n // Save result\\n results[i] = SyncResult(programId, versionStarted, versionComplete, refundAmount);\\n }\\n }\\n\\n /**\\n * @notice Syncs an account for this product with the latest data\\n * @dev Assumes that sync() has already been called as part of the transaction flow\\n * @param self The Program manager to operate on\\n * @param product This Product\\n * @param account The account to sync\\n * @param currentOracleVersion The preloaded current oracle version\\n */\\n function syncAccount(\\n ProductManager storage self,\\n IProduct product,\\n address account,\\n IOracleProvider.OracleVersion memory currentOracleVersion\\n ) internal {\\n\\n // Add any unseen programs\\n uint256 fromProgramId = self.nextProgramFor[account];\\n uint256 toProgramId = self.programInfos.length;\\n for (uint256 programId = fromProgramId; programId < toProgramId; programId++) {\\n self.activeProgramsFor[account].add(programId);\\n }\\n self.nextProgramFor[account] = toProgramId;\\n\\n // Settle programs\\n uint256[] memory activeProgramIds = self.activeProgramsFor[account].values();\\n for (uint256 i; i < activeProgramIds.length; i++) {\\n uint256 programId = activeProgramIds[i];\\n Program storage program = self.programs[programId];\\n program.settle(product, self.programInfos[programId], account, currentOracleVersion);\\n if (!self.activePrograms.contains(programId) && currentOracleVersion.version >= program.versionComplete) {\\n self.activeProgramsFor[account].remove(programId);\\n }\\n }\\n }\\n\\n /**\\n * @notice Returns the quantity of active programs for this product\\n * @param self The Program manager to operate on\\n * @return The quantity of active programs\\n */\\n function active(ProductManager storage self) internal view returns (uint256) {\\n return self.activePrograms.length();\\n }\\n\\n /**\\n * @notice Forces the specified program to complete if it hasn't already\\n * @param self The Program manager to operate on\\n * @param product The Product to operate on\\n * @param programId The Program to complete\\n * @return result The sync result data from completion\\n */\\n function complete(\\n ProductManager storage self,\\n IProduct product,\\n uint256 programId\\n ) internal returns (SyncResult memory result) {\\n Program storage program = self.programs[programId];\\n\\n // If not started, start first\\n if (program.versionStarted == 0) {\\n result.versionStarted = _start(self, programId, product.currentVersion());\\n }\\n\\n // If not completed already, complete\\n if (program.versionComplete == 0) {\\n (result.versionComplete, result.refundAmount) = _complete(self, product, programId);\\n }\\n }\\n\\n /**\\n * @notice Starts the program\\n * @dev Rewards do not start accruing until the program has started\\n * Internal helper, does not prevent incorrectly-timed starting\\n * @param self The Program manager to operate on\\n * @param programId The Program to start\\n * @param currentOracleVersion The effective starting oracle version\\n * @return versionStarted The version that the program started\\n */\\n function _start(\\n ProductManager storage self,\\n uint256 programId,\\n IOracleProvider.OracleVersion memory currentOracleVersion\\n ) internal returns (uint256 versionStarted) {\\n versionStarted = currentOracleVersion.version;\\n self.programs[programId].start(currentOracleVersion.version);\\n }\\n\\n /**\\n * @notice Completes the program\\n * @dev Completion stops rewards from accruing\\n * Internal helper, does not prevent incorrectly-timed completion\\n * @param self The Program manager to operate on\\n * @param product The Product to operate on\\n * @param programId The Program to complete\\n * @return versionComplete The version that the program complete\\n * @return refundAmount The refunded token amount\\n */\\n function _complete(\\n ProductManager storage self,\\n IProduct product,\\n uint256 programId\\n ) internal returns (uint256 versionComplete, UFixed18 refundAmount) {\\n (versionComplete, refundAmount) = self.programs[programId].complete(product, self.programInfos[programId]);\\n self.activePrograms.remove(programId);\\n }\\n\\n /**\\n * @notice Claims all of `account`'s rewards for a specific program\\n * @param self The Program manager to operate on\\n * @param account Account to claim rewards for\\n * @param programId Program to claim rewards for\\n * @return Amount claimed\\n */\\n function claim(ProductManager storage self, address account, uint256 programId) internal returns (UFixed18) {\\n return self.programs[programId].claim(account);\\n }\\n\\n /**\\n * @notice Returns the total amount of unclaimed rewards for account `account`\\n * @param self The Program manager to operate on\\n * @param account The account to check for\\n * @param programId The Program to check for\\n * @return Total amount of unclaimed rewards for account\\n */\\n function unclaimed(ProductManager storage self, address account, uint256 programId) internal view returns (UFixed18) {\\n if (!valid(self, programId)) return (UFixed18Lib.ZERO);\\n return self.programs[programId].settled[account];\\n }\\n\\n /**\\n * @notice Returns the token denominatino of the program's rewards\\n * @param self The Program manager to operate on\\n * @param programId The Program to check for\\n * @return The token for the program\\n */\\n function token(ProductManager storage self, uint256 programId) internal view returns (Token18) {\\n return self.programInfos[programId].token;\\n }\\n\\n /**\\n * @notice Returns whether the supplied programId is valid\\n * @param self The Program manager to operate on\\n * @param programId The Program to check for\\n * @return Whether the supplied programId is valid\\n */\\n function valid(ProductManager storage self, uint256 programId) internal view returns (bool) {\\n return programId < self.programInfos.length;\\n }\\n}\\n\",\"keccak256\":\"0x7db9fa9c04ec523c44d0aab52c8cd779a2b752e77bf16e0d90e4e0c159e24275\",\"license\":\"Apache-2.0\"},\"contracts/incentivizer/types/Program.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"../../interfaces/types/ProgramInfo.sol\\\";\\n\\n/// @dev Program type\\nstruct Program {\\n /// @dev Mapping of latest rewards settled for each account\\n mapping(address => UFixed18) settled;\\n\\n /// @dev Total amount of rewards yet to be claimed\\n UFixed18 available;\\n\\n /// @dev Oracle version that the program started, 0 when hasn't started\\n uint256 versionStarted;\\n\\n /// @dev Oracle version that the program completed, 0 is still ongoing\\n uint256 versionComplete;\\n}\\nusing ProgramLib for Program global;\\n\\n/**\\n * @title ProgramLib\\n * @notice Library that manages all of the mutable state for a single incentivization program.\\n */\\nlibrary ProgramLib {\\n /**\\n * @notice Initializes the program state\\n * @param self The Program to operate on\\n * @param programInfo Static program information\\n */\\n function initialize(Program storage self, ProgramInfo memory programInfo) internal {\\n self.available = programInfo.amount.sum();\\n }\\n\\n /**\\n * @notice Starts the program\\n * @dev Rewards do not start accruing until the program has started accruing\\n * Does not stop double-starting\\n * @param self The Program to operate on\\n * @param oracleVersion The effective starting oracle version\\n */\\n function start(Program storage self, uint256 oracleVersion) internal {\\n self.versionStarted = oracleVersion;\\n }\\n\\n /**\\n * @notice Completes the program\\n * @dev Completion stops rewards from accruing\\n * Does not prevent double-completion\\n * @param self The Program to operate on\\n * @param product The Product to operate on\\n * @param programInfo Static program information\\n * @return versionComplete The version that the program completed on\\n * @return refundAmount The refund amount from the program\\n */\\n function complete(\\n Program storage self,\\n IProduct product,\\n ProgramInfo memory programInfo\\n ) internal returns (uint256 versionComplete, UFixed18 refundAmount) {\\n uint256 versionStarted = self.versionStarted;\\n versionComplete = Math.max(versionStarted, product.latestVersion());\\n self.versionComplete = versionComplete;\\n\\n IOracleProvider.OracleVersion memory fromOracleVersion = product.atVersion(versionStarted);\\n IOracleProvider.OracleVersion memory toOracleVersion = product.atVersion(versionComplete);\\n\\n uint256 inactiveDuration = programInfo.duration - (toOracleVersion.timestamp - fromOracleVersion.timestamp);\\n refundAmount = programInfo.amount.sum().muldiv(inactiveDuration, programInfo.duration);\\n self.available = self.available.sub(refundAmount);\\n }\\n\\n /**\\n * @notice Settles unclaimed rewards for account `account`\\n * @param self The Program to operate on\\n * @param product The Product to operate on\\n * @param programInfo Static program information\\n * @param account The account to settle for\\n * @param currentOracleVersion The preloaded current oracle version\\n */\\n function settle(\\n Program storage self,\\n IProduct product,\\n ProgramInfo memory programInfo,\\n address account,\\n IOracleProvider.OracleVersion memory currentOracleVersion\\n ) internal {\\n UFixed18 unsettledAmount = _unsettled(self, product, programInfo, account, currentOracleVersion);\\n self.settled[account] = self.settled[account].add(unsettledAmount);\\n self.available = self.available.sub(unsettledAmount);\\n }\\n\\n /**\\n * @notice Claims settled rewards for account `account`\\n * @param self The Program to operate on\\n * @param account The account to claim for\\n */\\n function claim(Program storage self, address account) internal returns (UFixed18 claimedAmount) {\\n claimedAmount = self.settled[account];\\n self.settled[account] = UFixed18Lib.ZERO;\\n }\\n\\n /**\\n * @notice Returns the unsettled amount of unclaimed rewards for account `account`\\n * @dev Clears when a program is closed\\n * Assumes that position is unchanged since last settlement, must be settled prior to user position update\\n * @param self The Program to operate on\\n * @param product The Product to operate on\\n * @param programInfo Static program information\\n * @param account The account to claim for\\n * @param currentOracleVersion Current oracle version\\n * @return amount Amount of unsettled rewards for account\\n */\\n function _unsettled(\\n Program storage self,\\n IProduct product,\\n ProgramInfo memory programInfo,\\n address account,\\n IOracleProvider.OracleVersion memory currentOracleVersion\\n ) private view returns (UFixed18 amount) {\\n // program stage overview\\n //\\n // V = latest user settle version, V' = current user settle version\\n // S = versionStarted, E = versionEnded\\n //\\n // (1) V V' S E program not yet started\\n // (2) V S V' E use versionStarted -> V' for userShareDelta\\n // (3) S V V' E use V -> V' for userShareDelta\\n // (4) S V E V' use V -> versionComplete for userShareDelta\\n // (5) S E V V' program already completed\\n // (6) V S E V' use versionStarted -> versionComplete for userShareDelta\\n //\\n // NOTE: V == S and V' == E both default to the inner case\\n\\n (uint256 _versionStarted, uint256 _versionComplete) = (\\n self.versionStarted == 0 ? currentOracleVersion.version : self.versionStarted, // start must be no earlier than current version\\n self.versionComplete == 0 ? type(uint256).max : self.versionComplete // we don't know when completion occurs\\n );\\n\\n // accruing must start between self.versionStarted and self.versionComplete\\n uint256 fromVersion = Math.min(_versionComplete, Math.max(_versionStarted, product.latestVersion(account)));\\n // accruing must complete between self.versionStarted and self.versionComplete, we know self.versionStarted must be no earlier than current version\\n uint256 toVersion = Math.min(_versionComplete, currentOracleVersion.version);\\n\\n Accumulator memory globalShareDelta = product.shareAtVersion(toVersion).sub(product.shareAtVersion(fromVersion));\\n Accumulator memory computedUserShareDelta = product.position(account).mul(globalShareDelta);\\n amount = UFixed18Lib.from(programInfo.amountPerShare().mul(computedUserShareDelta).sum());\\n }\\n}\\n\",\"keccak256\":\"0xbc1acfcb2160ba7e08e515ef88bced2ef4acedba57bd55b55117fc05e4747fa5\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/ICollateral.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"./IController.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\n\\ninterface ICollateral {\\n event Deposit(address indexed user, IProduct indexed product, UFixed18 amount);\\n event Withdrawal(address indexed user, IProduct indexed product, UFixed18 amount);\\n event AccountSettle(IProduct indexed product, address indexed account, Fixed18 amount, UFixed18 newShortfall);\\n event ProductSettle(IProduct indexed product, UFixed18 protocolFee, UFixed18 productFee);\\n event Liquidation(address indexed user, IProduct indexed product, address liquidator, UFixed18 fee);\\n event ShortfallResolution(IProduct indexed product, UFixed18 amount);\\n event FeeClaim(address indexed account, UFixed18 amount);\\n\\n error CollateralCantLiquidate(UFixed18 totalMaintenance, UFixed18 totalCollateral);\\n error CollateralInsufficientCollateralError();\\n error CollateralUnderLimitError();\\n error CollateralZeroAddressError();\\n\\n function token() external view returns (Token18);\\n function fees(address account) external view returns (UFixed18);\\n function initialize(IController controller_) external;\\n function depositTo(address account, IProduct product, UFixed18 amount) external;\\n function withdrawTo(address account, IProduct product, UFixed18 amount) external;\\n function liquidate(address account, IProduct product) external;\\n function settleAccount(address account, Fixed18 amount) external;\\n function settleProduct(UFixed18 amount) external;\\n function collateral(address account, IProduct product) external view returns (UFixed18);\\n function collateral(IProduct product) external view returns (UFixed18);\\n function shortfall(IProduct product) external view returns (UFixed18);\\n function liquidatable(address account, IProduct product) external view returns (bool);\\n function liquidatableNext(address account, IProduct product) external view returns (bool);\\n function resolveShortfall(IProduct product, UFixed18 amount) external;\\n function claimFee() external;\\n}\\n\",\"keccak256\":\"0xa5e7fdda92702f748e6eb8701e522450035a98a05e5fc1cf66d51c52e397d914\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IContractPayoffProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\n\\ninterface IContractPayoffProvider {\\n function payoff(Fixed18 price) external view returns (Fixed18 payoff);\\n}\\n\",\"keccak256\":\"0xd73df106d032e976fd959ee6713240e36f54277ce5f215eaec8d5a2c6720a86b\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IController.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\\\";\\nimport \\\"./ICollateral.sol\\\";\\nimport \\\"./IIncentivizer.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\n\\ninterface IController {\\n /// @dev Coordinator of a one or many products\\n struct Coordinator {\\n /// @dev Pending owner of the product, can accept ownership\\n address pendingOwner;\\n\\n /// @dev Owner of the product, allowed to update select parameters\\n address owner;\\n\\n /// @dev Treasury of the product, collects fees\\n address treasury;\\n }\\n\\n event CollateralUpdated(ICollateral newCollateral);\\n event IncentivizerUpdated(IIncentivizer newIncentivizer);\\n event ProductBeaconUpdated(IBeacon newProductBeacon);\\n event ProtocolFeeUpdated(UFixed18 newProtocolFee);\\n event MinFundingFeeUpdated(UFixed18 newMinFundingFee);\\n event LiquidationFeeUpdated(UFixed18 newLiquidationFee);\\n event IncentivizationFeeUpdated(UFixed18 newIncentivizationFee);\\n event MinCollateralUpdated(UFixed18 newMinCollateral);\\n event ProgramsPerProductUpdated(uint256 newProgramsPerProduct);\\n event PauserUpdated(address newPauser);\\n event PausedUpdated(bool newPaused);\\n event CoordinatorPendingOwnerUpdated(uint256 indexed coordinatorId, address newPendingOwner);\\n event CoordinatorOwnerUpdated(uint256 indexed coordinatorId, address newOwner);\\n event CoordinatorTreasuryUpdated(uint256 indexed coordinatorId, address newTreasury);\\n event CoordinatorCreated(uint256 indexed coordinatorId, address owner);\\n event ProductCreated(IProduct indexed product, IProduct.ProductInfo productInfo);\\n\\n error ControllerNoZeroCoordinatorError();\\n error ControllerNotPauserError();\\n error ControllerNotOwnerError(uint256 controllerId);\\n error ControllerNotPendingOwnerError(uint256 controllerId);\\n error ControllerInvalidProtocolFeeError();\\n error ControllerInvalidMinFundingFeeError();\\n error ControllerInvalidLiquidationFeeError();\\n error ControllerInvalidIncentivizationFeeError();\\n error ControllerNotContractAddressError();\\n\\n function collateral() external view returns (ICollateral);\\n function incentivizer() external view returns (IIncentivizer);\\n function productBeacon() external view returns (IBeacon);\\n function coordinators(uint256 collateralId) external view returns (Coordinator memory);\\n function coordinatorFor(IProduct product) external view returns (uint256);\\n function protocolFee() external view returns (UFixed18);\\n function minFundingFee() external view returns (UFixed18);\\n function liquidationFee() external view returns (UFixed18);\\n function incentivizationFee() external view returns (UFixed18);\\n function minCollateral() external view returns (UFixed18);\\n function programsPerProduct() external view returns (uint256);\\n function pauser() external view returns (address);\\n function paused() external view returns (bool);\\n function initialize(ICollateral collateral_, IIncentivizer incentivizer_, IBeacon productBeacon_) external;\\n function createCoordinator() external returns (uint256);\\n function updateCoordinatorPendingOwner(uint256 coordinatorId, address newPendingOwner) external;\\n function acceptCoordinatorOwner(uint256 coordinatorId) external;\\n function updateCoordinatorTreasury(uint256 coordinatorId, address newTreasury) external;\\n function createProduct(uint256 coordinatorId, IProduct.ProductInfo calldata productInfo) external returns (IProduct);\\n function updateCollateral(ICollateral newCollateral) external;\\n function updateIncentivizer(IIncentivizer newIncentivizer) external;\\n function updateProductBeacon(IBeacon newProductBeacon) external;\\n function updateProtocolFee(UFixed18 newProtocolFee) external;\\n function updateMinFundingFee(UFixed18 newMinFundingFee) external;\\n function updateLiquidationFee(UFixed18 newLiquidationFee) external;\\n function updateIncentivizationFee(UFixed18 newIncentivizationFee) external;\\n function updateMinCollateral(UFixed18 newMinCollateral) external;\\n function updateProgramsPerProduct(uint256 newProductsPerProduct) external;\\n function updatePauser(address newPauser) external;\\n function updatePaused(bool newPaused) external;\\n function isProduct(IProduct product) external view returns (bool);\\n function owner() external view returns (address);\\n function owner(uint256 coordinatorId) external view returns (address);\\n function owner(IProduct product) external view returns (address);\\n function treasury() external view returns (address);\\n function treasury(uint256 coordinatorId) external view returns (address);\\n function treasury(IProduct product) external view returns (address);\\n}\\n\",\"keccak256\":\"0xaabd3740f2265499eea7aad9bd94f9892f53241e5dccce9a50c0e43ed2a6a7cc\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IIncentivizer.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./types/ProgramInfo.sol\\\";\\nimport \\\"./IController.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\n\\ninterface IIncentivizer {\\n event ProgramCreated(IProduct indexed product, uint256 indexed programId, ProgramInfo programInfo, UFixed18 programFeeAmount);\\n event ProgramStarted(IProduct indexed product, uint256 indexed programId, uint256 version);\\n event ProgramComplete(IProduct indexed product, uint256 indexed programId, uint256 version);\\n event Claim(IProduct indexed product, address indexed account, uint256 indexed programId, UFixed18 amount);\\n event FeeClaim(Token18 indexed token, UFixed18 amount);\\n\\n error IncentivizerNotAllowedError(IProduct product);\\n error IncentivizerTooManyProgramsError();\\n error IncentivizerNotProgramOwnerError(IProduct product, uint256 programId);\\n error IncentivizerInvalidProgramError(IProduct product, uint256 programId);\\n error IncentivizerBatchClaimArgumentMismatchError();\\n\\n function programInfos(IProduct product, uint256 programId) external view returns (ProgramInfo memory);\\n function fees(Token18 token) external view returns (UFixed18);\\n function initialize(IController controller_) external;\\n function create(IProduct product, ProgramInfo calldata info) external returns (uint256);\\n function complete(IProduct product, uint256 programId) external;\\n function sync(IOracleProvider.OracleVersion memory currentOracleVersion) external;\\n function syncAccount(address account, IOracleProvider.OracleVersion memory currentOracleVersion) external;\\n function claim(IProduct product, uint256[] calldata programIds) external;\\n function claim(IProduct[] calldata products, uint256[][] calldata programIds) external;\\n function claimFee(Token18[] calldata tokens) external;\\n function active(IProduct product) external view returns (uint256);\\n function count(IProduct product) external view returns (uint256);\\n function unclaimed(IProduct product, address account, uint256 programId) external view returns (UFixed18);\\n function available(IProduct product, uint256 programId) external view returns (UFixed18);\\n function versionStarted(IProduct product, uint256 programId) external view returns (uint256);\\n function versionComplete(IProduct product, uint256 programId) external view returns (uint256);\\n function owner(IProduct product, uint256 programId) external view returns (address);\\n function treasury(IProduct product, uint256 programId) external view returns (address);\\n}\\n\",\"keccak256\":\"0x2f95de90dbb3ad35dbfef304f765a622bffff9229868d2898eca8d49c78e8c2c\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IParamProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\\\";\\n\\ninterface IParamProvider {\\n event MaintenanceUpdated(UFixed18 newMaintenance);\\n event FundingFeeUpdated(UFixed18 newFundingFee);\\n event MakerFeeUpdated(UFixed18 newMakerFee);\\n event TakerFeeUpdated(UFixed18 newTakerFee);\\n event MakerLimitUpdated(UFixed18 newMakerLimit);\\n event JumpRateUtilizationCurveUpdated(\\n Fixed18 minRate,\\n Fixed18 maxRate,\\n Fixed18 targetRate,\\n UFixed18 targetUtilization\\n );\\n\\n error ParamProviderInvalidMakerFee();\\n error ParamProviderInvalidTakerFee();\\n error ParamProviderInvalidFundingFee();\\n \\n function maintenance() external view returns (UFixed18);\\n function updateMaintenance(UFixed18 newMaintenance) external;\\n function fundingFee() external view returns (UFixed18);\\n function updateFundingFee(UFixed18 newFundingFee) external;\\n function makerFee() external view returns (UFixed18);\\n function updateMakerFee(UFixed18 newMakerFee) external;\\n function takerFee() external view returns (UFixed18);\\n function updateTakerFee(UFixed18 newTakerFee) external;\\n function makerLimit() external view returns (UFixed18);\\n function updateMakerLimit(UFixed18 newMakerLimit) external;\\n function utilizationCurve() external view returns (JumpRateUtilizationCurve memory);\\n function updateUtilizationCurve(JumpRateUtilizationCurve memory newUtilizationCurve) external;\\n}\\n\",\"keccak256\":\"0x2e2d40d0cf55f167118867e41f740b9b40614d05da50fc9bc33a8cede3eaf03e\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IPayoffProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\n\\ninterface IPayoffProvider {\\n error PayoffProviderInvalidOracle();\\n error PayoffProviderInvalidPayoffDefinitionError();\\n\\n function oracle() external view returns (IOracleProvider);\\n function payoffDefinition() external view returns (PayoffDefinition memory);\\n function currentVersion() external view returns (IOracleProvider.OracleVersion memory);\\n function atVersion(uint256 oracleVersion) external view returns (IOracleProvider.OracleVersion memory);\\n}\\n\",\"keccak256\":\"0xb83d80d624aa9431763f80ecb4bf0214803e25334a7419d954f929e5d0ee7467\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IProduct.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\\\";\\nimport \\\"./IPayoffProvider.sol\\\";\\nimport \\\"./IParamProvider.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\nimport \\\"./types/Position.sol\\\";\\nimport \\\"./types/PrePosition.sol\\\";\\nimport \\\"./types/Accumulator.sol\\\";\\n\\ninterface IProduct is IPayoffProvider, IParamProvider {\\n /// @dev Product Creation parameters\\n struct ProductInfo {\\n /// @dev name of the product\\n string name;\\n\\n /// @dev symbol of the product\\n string symbol;\\n\\n /// @dev product payoff definition\\n PayoffDefinition payoffDefinition;\\n\\n /// @dev oracle address\\n IOracleProvider oracle;\\n\\n /// @dev product maintenance ratio\\n UFixed18 maintenance;\\n\\n /// @dev product funding fee\\n UFixed18 fundingFee;\\n\\n /// @dev product maker fee\\n UFixed18 makerFee;\\n\\n /// @dev product taker fee\\n UFixed18 takerFee;\\n\\n /// @dev product maker limit\\n UFixed18 makerLimit;\\n\\n /// @dev utulization curve definition\\n JumpRateUtilizationCurve utilizationCurve;\\n }\\n\\n event Settle(uint256 preVersion, uint256 toVersion);\\n event AccountSettle(address indexed account, uint256 preVersion, uint256 toVersion);\\n event MakeOpened(address indexed account, uint256 version, UFixed18 amount);\\n event TakeOpened(address indexed account, uint256 version, UFixed18 amount);\\n event MakeClosed(address indexed account, uint256 version, UFixed18 amount);\\n event TakeClosed(address indexed account, uint256 version, UFixed18 amount);\\n event ClosedUpdated(bool indexed newClosed, uint256 version);\\n\\n error ProductInsufficientLiquidityError(UFixed18 socializationFactor);\\n error ProductDoubleSidedError();\\n error ProductOverClosedError();\\n error ProductInsufficientCollateralError();\\n error ProductInLiquidationError();\\n error ProductMakerOverLimitError();\\n error ProductOracleBootstrappingError();\\n error ProductNotOwnerError();\\n error ProductInvalidOracle();\\n error ProductClosedError();\\n\\n function name() external view returns (string memory);\\n function symbol() external view returns (string memory);\\n function initialize(ProductInfo calldata productInfo_) external;\\n function settle() external;\\n function settleAccount(address account) external;\\n function openTake(UFixed18 amount) external;\\n function closeTake(UFixed18 amount) external;\\n function openMake(UFixed18 amount) external;\\n function closeMake(UFixed18 amount) external;\\n function closeAll(address account) external;\\n function maintenance(address account) external view returns (UFixed18);\\n function maintenanceNext(address account) external view returns (UFixed18);\\n function isClosed(address account) external view returns (bool);\\n function isLiquidating(address account) external view returns (bool);\\n function position(address account) external view returns (Position memory);\\n function pre(address account) external view returns (PrePosition memory);\\n function latestVersion() external view returns (uint256);\\n function positionAtVersion(uint256 oracleVersion) external view returns (Position memory);\\n function pre() external view returns (PrePosition memory);\\n function valueAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\\n function shareAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\\n function latestVersion(address account) external view returns (uint256);\\n function rate(Position memory position) external view returns (Fixed18);\\n function closed() external view returns (bool);\\n function updateClosed(bool newClosed) external;\\n}\\n\",\"keccak256\":\"0xe1e80b818eadf4cdb070362e40c7cf3863b50c4f944816af27848e319f587241\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/Accumulator.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"./PackedAccumulator.sol\\\";\\n\\n/// @dev Accumulator type\\nstruct Accumulator {\\n /// @dev maker accumulator per share\\n Fixed18 maker;\\n /// @dev taker accumulator per share\\n Fixed18 taker;\\n}\\nusing AccumulatorLib for Accumulator global;\\n\\n/**\\n * @title AccountAccumulatorLib\\n * @notice Library that surfaces math operations for the Accumulator type.\\n * @dev Accumulators track the cumulative change in position value over time for the maker and taker positions\\n * respectively. Account-level accumulators can then use two of these values `a` and `a'` to compute the\\n * change in position value since last sync. This change in value is then used to compute P&L and fees.\\n */\\nlibrary AccumulatorLib {\\n /**\\n * @notice Creates a packed accumulator from an accumulator\\n * @param self an accumulator\\n * @return New packed accumulator\\n */\\n function pack(Accumulator memory self) internal pure returns (PackedAccumulator memory) {\\n return PackedAccumulator({maker: self.maker.pack(), taker: self.taker.pack()});\\n }\\n\\n /**\\n * @notice Adds two accumulators together\\n * @param a The first accumulator to sum\\n * @param b The second accumulator to sum\\n * @return The resulting summed accumulator\\n */\\n function add(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\\n }\\n\\n /**\\n * @notice Subtracts accumulator `b` from `a`\\n * @param a The accumulator to subtract from\\n * @param b The accumulator to subtract\\n * @return The resulting subtracted accumulator\\n */\\n function sub(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\\n }\\n\\n /**\\n * @notice Multiplies two accumulators together\\n * @param a The first accumulator to multiply\\n * @param b The second accumulator to multiply\\n * @return The resulting multiplied accumulator\\n */\\n function mul(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.mul(b.maker), taker: a.taker.mul(b.taker)});\\n }\\n\\n /**\\n * @notice Sums the maker and taker together from a single accumulator\\n * @param self The struct to operate on\\n * @return The sum of its maker and taker\\n */\\n function sum(Accumulator memory self) internal pure returns (Fixed18) {\\n return self.maker.add(self.taker);\\n }\\n}\\n\",\"keccak256\":\"0x7ccd0a72aa593cefb9f4337cf312799f357b82fcb3f0379de0dc503d1cb7e387\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PackedAccumulator.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/PackedFixed18.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\n\\n/// @dev PackedAccumulator type\\nstruct PackedAccumulator {\\n /// @dev maker accumulator per share\\n PackedFixed18 maker;\\n /// @dev taker accumulator per share\\n PackedFixed18 taker;\\n}\\nusing PackedAccumulatorLib for PackedAccumulator global;\\n\\n/**\\n * @title PackedAccumulatorLib\\n * @dev A packed version of the Accumulator which takes up a single storage slot using `PackedFixed18` values.\\n * @notice Library for the packed Accumulator type.\\n */\\nlibrary PackedAccumulatorLib {\\n /**\\n * @notice Creates an accumulator from a packed accumulator\\n * @param self packed accumulator\\n * @return New accumulator\\n */\\n function unpack(PackedAccumulator memory self) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: self.maker.unpack(), taker: self.taker.unpack()});\\n }\\n}\\n\",\"keccak256\":\"0xd83f2822d4f6c818087a232b54007730992c34ff77377fc307a282f886e7cf65\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PackedPosition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/PackedUFixed18.sol\\\";\\nimport \\\"./Position.sol\\\";\\n\\n/// @dev PackedPosition type\\nstruct PackedPosition {\\n /// @dev Quantity of the maker position\\n PackedUFixed18 maker;\\n /// @dev Quantity of the taker position\\n PackedUFixed18 taker;\\n}\\nusing PackedPositionLib for PackedPosition global;\\n\\n/**\\n * @title PackedPositionLib\\n * @dev A packed version of the Position which takes up a single storage slot using `PackedFixed18` values.\\n * @notice Library for the packed Position type.\\n */\\nlibrary PackedPositionLib {\\n /**\\n * @notice Creates an position from a packed position\\n * @param self packed position\\n * @return New position\\n */\\n function unpack(PackedPosition memory self) internal pure returns (Position memory) {\\n return Position({maker: self.maker.unpack(), taker: self.taker.unpack()});\\n }\\n}\\n\",\"keccak256\":\"0x04968e6794f6244cb3415cea111d640273a81faea957872988d0cb580f45df1e\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PayoffDefinition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"@openzeppelin/contracts/utils/Address.sol\\\";\\nimport \\\"../../interfaces/IContractPayoffProvider.sol\\\";\\n\\n/// @dev PayoffDefinition tyoe\\nstruct PayoffDefinition {\\n PayoffDefinitionLib.PayoffType payoffType;\\n PayoffDefinitionLib.PayoffDirection payoffDirection;\\n bytes30 data;\\n}\\nusing PayoffDefinitionLib for PayoffDefinition global;\\ntype PayoffDefinitionStorage is bytes32;\\nusing PayoffDefinitionStorageLib for PayoffDefinitionStorage global;\\n\\n/**\\n * @title PayoffDefinitionLib\\n * @dev Library that surfaces logic for PayoffDefinition type functionality\\n * @notice Library for the PayoffDefinition type. Performs validity and price transformation\\n based on the payoff definition type.\\n */\\nlibrary PayoffDefinitionLib {\\n using Address for address;\\n\\n error PayoffDefinitionUnsupportedTransform(PayoffType payoffType, PayoffDirection payoffDirection);\\n error PayoffDefinitionNotContract(PayoffType payoffType, bytes30 data);\\n\\n /// @dev Payoff function type enum\\n enum PayoffType { PASSTHROUGH, CONTRACT }\\n enum PayoffDirection { LONG, SHORT }\\n\\n /**\\n * @notice Checks validity of the payoff definition\\n * @param self a payoff definition\\n * @return Whether the payoff definition is valid for it's given type\\n */\\n function valid(PayoffDefinition memory self) internal view returns (bool) {\\n if (self.payoffType == PayoffType.CONTRACT) return address(_providerContract(self)).isContract();\\n\\n // All other payoff types should have no data\\n return uint(bytes32(self.data)) == 0;\\n }\\n\\n /**\\n * @notice Transforms a price based on the payoff definition\\n * @param self a payoff definition\\n * @param price raw oracle price\\n * @return Price transformed by the payoff definition function\\n */\\n function transform(\\n PayoffDefinition memory self,\\n Fixed18 price\\n ) internal view returns (Fixed18) {\\n PayoffType payoffType = self.payoffType;\\n PayoffDirection payoffDirection = self.payoffDirection;\\n Fixed18 transformedPrice;\\n\\n // First get the price depending on the type\\n if (payoffType == PayoffType.PASSTHROUGH) transformedPrice = price;\\n else if (payoffType == PayoffType.CONTRACT) transformedPrice = _payoffFromContract(self, price);\\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\\n\\n // Then transform it depending on the direction flag\\n if (self.payoffDirection == PayoffDirection.LONG) return transformedPrice;\\n else if (self.payoffDirection == PayoffDirection.SHORT) return transformedPrice.mul(Fixed18Lib.NEG_ONE);\\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\\n }\\n\\n /**\\n * @notice Parses the data field into an address\\n * @dev Reverts if payoffType is not CONTRACT\\n * @param self a payoff definition\\n * @return IContractPayoffProvider address\\n */\\n function _providerContract(\\n PayoffDefinition memory self\\n ) private pure returns (IContractPayoffProvider) {\\n if (self.payoffType != PayoffType.CONTRACT) revert PayoffDefinitionNotContract(self.payoffType, self.data);\\n // Shift to pull the last 20 bytes, then cast to an address\\n return IContractPayoffProvider(address(bytes20(self.data << 80)));\\n }\\n\\n /**\\n * @notice Performs a price transformation by calling the underlying payoff contract\\n * @param self a payoff definition\\n * @param price raw oracle price\\n * @return Price transformed by the payoff definition function on the contract\\n */\\n function _payoffFromContract(\\n PayoffDefinition memory self,\\n Fixed18 price\\n ) private view returns (Fixed18) {\\n bytes memory ret = address(_providerContract(self)).functionStaticCall(\\n abi.encodeCall(IContractPayoffProvider.payoff, price)\\n );\\n return Fixed18.wrap(abi.decode(ret, (int256)));\\n }\\n}\\n\\n/**\\n * @title PayoffDefinitionStorageLib\\n * @notice Library that surfaces storage read and writes for the PayoffDefinition type\\n */\\nlibrary PayoffDefinitionStorageLib {\\n function read(PayoffDefinitionStorage self) internal view returns (PayoffDefinition memory) {\\n return _storagePointer(self);\\n }\\n\\n function store(PayoffDefinitionStorage self, PayoffDefinition memory value) internal {\\n PayoffDefinition storage storagePointer = _storagePointer(self);\\n\\n storagePointer.payoffType = value.payoffType;\\n storagePointer.payoffDirection = value.payoffDirection;\\n storagePointer.data = value.data;\\n }\\n\\n function _storagePointer(\\n PayoffDefinitionStorage self\\n ) private pure returns (PayoffDefinition storage pointer) {\\n assembly { pointer.slot := self }\\n }\\n}\\n\",\"keccak256\":\"0x4d3897f408f77381c5ae9990391465c8fd511ddf6ff3b39f6cb69d8c2bd554df\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/Position.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\nimport \\\"./PrePosition.sol\\\";\\nimport \\\"./PackedPosition.sol\\\";\\n\\n/// @dev Position type\\nstruct Position {\\n /// @dev Quantity of the maker position\\n UFixed18 maker;\\n /// @dev Quantity of the taker position\\n UFixed18 taker;\\n}\\nusing PositionLib for Position global;\\n\\n/**\\n * @title PositionLib\\n * @notice Library that surfaces math and settlement computations for the Position type.\\n * @dev Positions track the current quantity of the account's maker and taker positions respectively\\n * denominated as a unit of the product's payoff function.\\n */\\nlibrary PositionLib {\\n /**\\n * @notice Creates a packed position from an position\\n * @param self A position\\n * @return New packed position\\n */\\n function pack(Position memory self) internal pure returns (PackedPosition memory) {\\n return PackedPosition({maker: self.maker.pack(), taker: self.taker.pack()});\\n }\\n\\n /**\\n * @notice Returns whether the position is fully empty\\n * @param self A position\\n * @return Whether the position is empty\\n */\\n function isEmpty(Position memory self) internal pure returns (bool) {\\n return self.maker.isZero() && self.taker.isZero();\\n }\\n\\n /**\\n * @notice Adds position `a` and `b` together, returning the result\\n * @param a The first position to sum\\n * @param b The second position to sum\\n * @return Resulting summed position\\n */\\n function add(Position memory a, Position memory b) internal pure returns (Position memory) {\\n return Position({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\\n }\\n\\n /**\\n * @notice Subtracts position `b` from `a`, returning the result\\n * @param a The position to subtract from\\n * @param b The position to subtract\\n * @return Resulting subtracted position\\n */\\n function sub(Position memory a, Position memory b) internal pure returns (Position memory) {\\n return Position({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\\n }\\n\\n /**\\n * @notice Multiplies position `self` by accumulator `accumulator` and returns the resulting accumulator\\n * @param self The Position to operate on\\n * @param accumulator The accumulator to multiply by\\n * @return Resulting multiplied accumulator\\n */\\n function mul(Position memory self, Accumulator memory accumulator) internal pure returns (Accumulator memory) {\\n return Accumulator({\\n maker: Fixed18Lib.from(self.maker).mul(accumulator.maker),\\n taker: Fixed18Lib.from(self.taker).mul(accumulator.taker)\\n });\\n }\\n\\n /**\\n * @notice Scales position `self` by fixed-decimal `scale` and returns the resulting position\\n * @param self The Position to operate on\\n * @param scale The Fixed-decimal to scale by\\n * @return Resulting scaled position\\n */\\n function mul(Position memory self, UFixed18 scale) internal pure returns (Position memory) {\\n return Position({maker: self.maker.mul(scale), taker: self.taker.mul(scale)});\\n }\\n\\n /**\\n * @notice Divides position `self` by `b` and returns the resulting accumulator\\n * @param self The Position to operate on\\n * @param b The number to divide by\\n * @return Resulting divided accumulator\\n */\\n function div(Position memory self, uint256 b) internal pure returns (Accumulator memory) {\\n return Accumulator({\\n maker: Fixed18Lib.from(self.maker).div(Fixed18Lib.from(UFixed18Lib.from(b))),\\n taker: Fixed18Lib.from(self.taker).div(Fixed18Lib.from(UFixed18Lib.from(b)))\\n });\\n }\\n\\n /**\\n * @notice Returns the maximum of `self`'s maker and taker values\\n * @param self The struct to operate on\\n * @return Resulting maximum value\\n */\\n function max(Position memory self) internal pure returns (UFixed18) {\\n return UFixed18Lib.max(self.maker, self.taker);\\n }\\n\\n /**\\n * @notice Sums the maker and taker together from a single position\\n * @param self The struct to operate on\\n * @return The sum of its maker and taker\\n */\\n function sum(Position memory self) internal pure returns (UFixed18) {\\n return self.maker.add(self.taker);\\n }\\n\\n /**\\n * @notice Computes the next position after the pending-settlement position delta is included\\n * @param self The current Position\\n * @param pre The pending-settlement position delta\\n * @return Next Position\\n */\\n function next(Position memory self, PrePosition memory pre) internal pure returns (Position memory) {\\n return sub(add(self, pre.openPosition), pre.closePosition);\\n }\\n\\n /**\\n * @notice Returns the settled position at oracle version `toOracleVersion`\\n * @dev Checks if a new position is ready to be settled based on the provided `toOracleVersion`\\n * and `pre` and returns accordingly\\n * @param self The current Position\\n * @param pre The pending-settlement position delta\\n * @param toOracleVersion The oracle version to settle to\\n * @return Settled position at oracle version\\n * @return Fee accrued from opening or closing the position\\n * @return Whether a new position was settled\\n */\\n function settled(\\n Position memory self,\\n PrePosition memory pre,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal view returns (Position memory, UFixed18, bool) {\\n return pre.canSettle(toOracleVersion) ? (next(self, pre), pre.computeFee(toOracleVersion), true) : (self, UFixed18Lib.ZERO, false);\\n }\\n\\n /**\\n * @notice Returns the socialization factor for the current position\\n * @dev Socialization account for the case where `taker` > `maker` temporarily due to a liquidation\\n * on the maker side. This dampens the taker's exposure pro-rata to ensure that the maker side\\n * is never exposed over 1 x short.\\n * @param self The Position to operate on\\n * @return Socialization factor\\n */\\n function socializationFactor(Position memory self) internal pure returns (UFixed18) {\\n return self.taker.isZero() ? UFixed18Lib.ONE : UFixed18Lib.min(UFixed18Lib.ONE, self.maker.div(self.taker));\\n }\\n}\\n\",\"keccak256\":\"0x027fe392c4f56bf012ba2ca462fcf23e69f2c3b9d283c14089771813437af991\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PrePosition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./Position.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\n\\n/// @dev PrePosition type\\nstruct PrePosition {\\n /// @dev Oracle version at which the new position delta was recorded\\n uint256 oracleVersion;\\n\\n /// @dev Size of position to open at oracle version\\n Position openPosition;\\n\\n /// @dev Size of position to close at oracle version\\n Position closePosition;\\n}\\nusing PrePositionLib for PrePosition global;\\n\\n/**\\n * @title PrePositionLib\\n * @notice Library that manages a pre-settlement position delta.\\n * @dev PrePositions track the currently awaiting-settlement deltas to a settled Position. These are\\n * Primarily necessary to introduce lag into the settlement system such that oracle lag cannot be\\n * gamed to a user's advantage. When a user opens or closes a new position, it sits as a PrePosition\\n * for one oracle version until it's settle into the Position, making it then effective. PrePositions\\n * are automatically settled at the correct oracle version even if a flywheel call doesn't happen until\\n * several version into the future by using the historical version lookups in the corresponding \\\"Versioned\\\"\\n * global state types.\\n */\\nlibrary PrePositionLib {\\n /**\\n * @notice Returns whether there is no pending-settlement position delta\\n * @dev Can be \\\"empty\\\" even with a non-zero oracleVersion if a position is opened and\\n * closed in the same version netting out to a zero position delta\\n * @param self The struct to operate on\\n * @return Whether the pending-settlement position delta is empty\\n */\\n function isEmpty(PrePosition memory self) internal pure returns (bool) {\\n return self.openPosition.isEmpty() && self.closePosition.isEmpty();\\n }\\n\\n /**\\n * @notice Increments the maker side of the open position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The position amount to open\\n */\\n function openMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.openPosition.maker = self.openPosition.maker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netMake(self);\\n }\\n\\n /**\\n * @notice Increments the maker side of the close position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The maker position amount to close\\n */\\n function closeMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.closePosition.maker = self.closePosition.maker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netMake(self);\\n }\\n\\n /**\\n * @notice Increments the taker side of the open position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The taker position amount to open\\n */\\n function openTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.openPosition.taker = self.openPosition.taker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netTake(self);\\n }\\n\\n /**\\n * @notice Increments the taker side of the close position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The taker position amount to close\\n */\\n function closeTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.closePosition.taker = self.closePosition.taker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netTake(self);\\n }\\n\\n /**\\n * @notice Nets out the open and close on the maker side of the position delta\\n * @param self The struct to operate on\\n */\\n function _netMake(PrePosition storage self) private {\\n if (self.openPosition.maker.gt(self.closePosition.maker)) {\\n self.openPosition.maker = self.openPosition.maker.sub(self.closePosition.maker);\\n self.closePosition.maker = UFixed18Lib.ZERO;\\n } else {\\n self.closePosition.maker = self.closePosition.maker.sub(self.openPosition.maker);\\n self.openPosition.maker = UFixed18Lib.ZERO;\\n }\\n }\\n\\n /**\\n * @notice Nets out the open and close on the taker side of the position delta\\n * @param self The struct to operate on\\n */\\n function _netTake(PrePosition storage self) private {\\n if (self.openPosition.taker.gt(self.closePosition.taker)) {\\n self.openPosition.taker = self.openPosition.taker.sub(self.closePosition.taker);\\n self.closePosition.taker = UFixed18Lib.ZERO;\\n } else {\\n self.closePosition.taker = self.closePosition.taker.sub(self.openPosition.taker);\\n self.openPosition.taker = UFixed18Lib.ZERO;\\n }\\n }\\n\\n /**\\n * @notice Returns whether the the pending position delta can be settled at version `toOracleVersion`\\n * @dev Pending-settlement positions deltas can be settled (1) oracle version after they are recorded\\n * @param self The struct to operate on\\n * @param toOracleVersion The potential oracle version to settle\\n * @return Whether the position delta can be settled\\n */\\n function canSettle(\\n PrePosition memory self,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal pure returns (bool) {\\n return !isEmpty(self) && toOracleVersion.version > self.oracleVersion;\\n }\\n\\n /**\\n * @notice Computes the fee incurred for opening or closing the pending-settlement position\\n * @dev Must be called from a valid product to get the proper fee amounts\\n * @param self The struct to operate on\\n * @param toOracleVersion The oracle version at which settlement takes place\\n * @return positionFee The maker / taker fee incurred\\n */\\n function computeFee(\\n PrePosition memory self,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal view returns (UFixed18) {\\n Position memory positionDelta = self.openPosition.add(self.closePosition);\\n\\n (UFixed18 makerNotional, UFixed18 takerNotional) = (\\n Fixed18Lib.from(positionDelta.maker).mul(toOracleVersion.price).abs(),\\n Fixed18Lib.from(positionDelta.taker).mul(toOracleVersion.price).abs()\\n );\\n\\n IProduct product = IProduct(address(this));\\n return makerNotional.mul(product.makerFee()).add(takerNotional.mul(product.takerFee()));\\n }\\n\\n /**\\n * @notice Computes the next oracle version to settle\\n * @dev - If there is no pending-settlement position delta, returns the current oracle version\\n * - Otherwise returns the oracle version at which the pending-settlement position delta can be first settled\\n *\\n * Corresponds to point (b) in the Position settlement flow\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @return Next oracle version to settle\\n */\\n function settleVersion(PrePosition storage self, uint256 currentVersion) internal view returns (uint256) {\\n uint256 _oracleVersion = self.oracleVersion;\\n return _oracleVersion == 0 ? currentVersion : _oracleVersion + 1;\\n }\\n}\\n\",\"keccak256\":\"0xa6f83f7b5f8139ec874235c406debd086a152977493c08b7f280df6f1737fb96\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/ProgramInfo.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\nimport \\\"./Position.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\n\\n/// @dev ProgramInfo type\\nstruct ProgramInfo {\\n /// @dev Coordinator for this program\\n uint256 coordinatorId;\\n\\n /// @dev Amount of total maker and taker rewards\\n Position amount;\\n\\n /// @dev start timestamp of the program\\n uint256 start;\\n\\n /// @dev duration of the program (in seconds)\\n uint256 duration;\\n\\n /**\\n * @dev Reward ERC20 token contract\\n * @notice Perennial does not support non-standard ERC20s as reward tokens for incentive programs, including,\\n but not limited to: fee on transfer and rebase tokens. Using such a non-standard token will likely\\n result in loss of funds.\\n */\\n Token18 token;\\n}\\nusing ProgramInfoLib for ProgramInfo global;\\n\\n/**\\n * @title ProgramInfoLib\\n * @notice Library that snapshots the static information for a single program.\\n * @dev This information does not change during the operation of a program.\\n */\\nlibrary ProgramInfoLib {\\n uint256 private constant MIN_DURATION = 1 days;\\n uint256 private constant MAX_DURATION = 2 * 365 days;\\n\\n error ProgramInvalidStartError();\\n error ProgramInvalidDurationError();\\n\\n /**\\n * @notice Validates and creates a new Program\\n * @dev Reverts for invalid programInfos\\n * @param programInfo Un-sanitized static program information\\n */\\n function validate(ProgramInfo memory programInfo) internal view {\\n if (isStarted(programInfo, block.timestamp)) revert ProgramInvalidStartError();\\n if (programInfo.duration < MIN_DURATION || programInfo.duration > MAX_DURATION) revert ProgramInvalidDurationError();\\n }\\n\\n /**\\n * @notice Computes a new program info with the fee taken out of the amount\\n * @param programInfo Original program info\\n * @param incentivizationFee The incentivization fee\\n * @return New program info\\n * @return Fee amount\\n */\\n function deductFee(ProgramInfo memory programInfo, UFixed18 incentivizationFee)\\n internal pure returns (ProgramInfo memory, UFixed18) {\\n Position memory newProgramAmount = programInfo.amount.mul(UFixed18Lib.ONE.sub(incentivizationFee));\\n UFixed18 programFeeAmount = programInfo.amount.sub(newProgramAmount).sum();\\n programInfo.amount = newProgramAmount;\\n return (programInfo, programFeeAmount);\\n }\\n\\n /**\\n * @notice Returns the maker and taker amounts per position share\\n * @param self The ProgramInfo to operate on\\n * @return programFee Amounts per share\\n */\\n function amountPerShare(ProgramInfo memory self) internal pure returns (Accumulator memory) {\\n return self.amount.div(self.duration);\\n }\\n\\n /**\\n * @notice Returns whether the program has started by timestamp `timestamp`\\n * @param self The ProgramInfo to operate on\\n * @param timestamp Timestamp to check for\\n * @return Whether the program has started\\n */\\n function isStarted(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\\n return timestamp >= self.start;\\n }\\n\\n /**\\n * @notice Returns whether the program is completed by timestamp `timestamp`\\n * @param self The ProgramInfo to operate on\\n * @param timestamp Timestamp to check for\\n * @return Whether the program is completed\\n */\\n function isComplete(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\\n return timestamp >= (self.start + self.duration);\\n }\\n}\\n\",\"keccak256\":\"0x280fcaf931b49abaec46b95ccbabaaf856a4b8e8d036413c9c3b3af25585d161\",\"license\":\"Apache-2.0\"}},\"version\":1}", - "bytecode": "0x608060405234801561001057600080fd5b506141e7806100206000396000f3fe608060405234801561001057600080fd5b50600436106101515760003560e01c806370f3f08b116100cd578063d758869111610081578063f77c479111610066578063f77c479114610325578063f8724aba1461032d578063faaebd211461037557600080fd5b8063d7588691146102ff578063e1e5a82e1461031257600080fd5b8063a55ff01d116100b2578063a55ff01d146102c6578063b774b601146102d9578063c4d66de8146102ec57600080fd5b806370f3f08b1461026b57806390672ad8146102b357600080fd5b80632c3e50e5116101245780634ea71327116101095780634ea713271461023257806366f8162e146102455780636da0d5401461025857600080fd5b80632c3e50e5146101ff578063457182781461021f57600080fd5b806305d85eda14610156578063095c82411461019f578063144dcdd1146101b25780631830349c146101ea575b600080fd5b61018c6101643660046136a4565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6040519081526020015b60405180910390f35b61018c6101ad3660046136c1565b610395565b6101c56101c03660046136c1565b6103d1565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610196565b6101fd6101f83660046137ef565b6104c0565b005b61021261020d3660046136c1565b6105b5565b6040516101969190613825565b6101fd61022d3660046138c6565b61066f565b61018c6102403660046136a4565b61075a565b61018c61025336600461391b565b610788565b6101c56102663660046136c1565b6107c0565b61018c6102793660046136c1565b73ffffffffffffffffffffffffffffffffffffffff9190911660009081526020818152604080832093835260019093019052206003015490565b6101fd6102c136600461395c565b610837565b6101fd6102d43660046139c8565b6109c3565b6101fd6102e73660046139e4565b610af0565b6101fd6102fa3660046136a4565b610cfa565b61018c61030d366004613a26565b610e18565b6101fd6103203660046136c1565b6114b6565b6101c5611771565b61018c61033b3660046136c1565b73ffffffffffffffffffffffffffffffffffffffff9190911660009081526020818152604080832093835260019384019091529020015490565b61018c6103833660046136a4565b60016020526000908152604090205481565b73ffffffffffffffffffffffffffffffffffffffff82166000908152602081815260408083208484526001019091529020600201545b92915050565b60006103db611771565b73ffffffffffffffffffffffffffffffffffffffff16634c5430a06000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001848154811061044857610448613a85565b9060005260206000209060060201600001546040518263ffffffff1660e01b815260040161047891815260200190565b602060405180830381865afa158015610495573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104b99190613ab4565b9392505050565b6104c8611771565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff9190911690637fd2919290602401602060405180830381865afa158015610534573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105589190613ad1565b610595576040517f4d5325650000000000000000000000000000000000000000000000000000000081523360048201526024015b60405180910390fd5b3360008181526020819052604090206105b0908285856117a0565b505050565b6105bd613622565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090208054839081106105f4576105f4613a85565b60009182526020918290206040805160a0810182526006909302909101805483528151808301835260018201548152600282015481860152938301939093526003830154908201526004820154606082015260059091015473ffffffffffffffffffffffffffffffffffffffff166080820152905092915050565b60026106997f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b036106d0576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755610731838383808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506119ad92505050565b60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755505050565b73ffffffffffffffffffffffffffffffffffffffff811660009081526020819052604081206103cb90611c10565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604081206107b8908484611c1e565b949350505050565b60006107ca611771565b73ffffffffffffffffffffffffffffffffffffffff1663a123c33e6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001848154811061044857610448613a85565b60026108617f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03610898576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7558281146108f5576040517f90fb223000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b838110156109975761098585858381811061091557610915613a85565b905060200201602081019061092a91906136a4565b84848481811061093c5761093c613a85565b905060200281019061094e9190613af3565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506119ad92505050565b8061098f81613b8a565b9150506108f8565b5060017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7555b50505050565b6109cb611771565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff9190911690637fd2919290602401602060405180830381865afa158015610a37573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a5b9190613ad1565b610a93576040517f4d53256500000000000000000000000000000000000000000000000000000000815233600482015260240161058c565b336000818152602081905260408120610aad908385611c71565b905060005b81518110156109bd57610ade83838381518110610ad157610ad1613a85565b6020026020010151611e85565b80610ae881613b8a565b915050610ab2565b610af8611771565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b669190613ad1565b15610b9d576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b818110156105b0576000838383818110610bbc57610bbc613a85565b9050602002016020810190610bd191906136a4565b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604081208054919055909150610c95610c09611771565b73ffffffffffffffffffffffffffffffffffffffff166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c779190613ab4565b73ffffffffffffffffffffffffffffffffffffffff84169083611fb3565b8173ffffffffffffffffffffffffffffffffffffffff167f10df095d1434aed409b2f33d2a6a8456f8b0824633cc12a1b43032085aadc41d82604051610cdd91815260200190565b60405180910390a250508080610cf290613b8a565b915050610ba0565b600180610d257f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b5490565b10610d5f576040517f1e7a9d950000000000000000000000000000000000000000000000000000000081526004810182905260240161058c565b610d887f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b829055565b60017fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c55610db582611fd4565b610dbd6120b4565b60007fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c556040518181527fbe9b076dc5b65990cca9dd9d7366682482e7817a6f6bc7f4faf4dc32af497f329060200160405180910390a15050565b60006002610e447f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03610e7b576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75582610ea8611771565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301529190911690637fd2919290602401602060405180830381865afa158015610f16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f3a9190613ad1565b610f88576040517f4d53256500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8216600482015260240161058c565b610f90611771565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ffe9190613ad1565b15611035576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b823561103f611771565b73ffffffffffffffffffffffffffffffffffffffff1663a123c33e826040518263ffffffff1660e01b815260040161107991815260200190565b602060405180830381865afa158015611096573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ba9190613ab4565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611121576040517f48f62f3c0000000000000000000000000000000000000000000000000000000081526004810182905260240161058c565b600061112b611771565b90508435158015906111cd57506040517f7d254e6600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8781166004830152821690637d254e6690602401602060405180830381865afa1580156111a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111c89190613bc2565b853514155b1561121c576040517fe264a52400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8716600482015260240161058c565b8073ffffffffffffffffffffffffffffffffffffffff16637d49c1b76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611267573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061128b9190613bc2565b6112948761075a565b106112cb576040517f1651519200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6112e26112dd36879003870187613c51565b612140565b60008061136b6112f736899003890189613c51565b8473ffffffffffffffffffffffffffffffffffffffff16633ceda0116040518163ffffffff1660e01b8152600401602060405180830381865afa158015611342573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113669190613bc2565b6121d0565b608082015173ffffffffffffffffffffffffffffffffffffffff1660009081526001602052604090205491935091506113a4908261222f565b608083015173ffffffffffffffffffffffffffffffffffffffff908116600090815260016020908152604080832094909455918b16815290819052206113ea908361223b565b955061142c3361140a611405368b90038b0160208c01613cf4565b6122f5565b608085015173ffffffffffffffffffffffffffffffffffffffff169190612309565b858873ffffffffffffffffffffffffffffffffffffffff167fee8233a38e17998eb73ba822048e13762f2b68729ef94c45133866ee75754dc68484604051611475929190613d10565b60405180910390a350505050506103cb60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d76119a990919063ffffffff16565b60026114e07f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03611517576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75573ffffffffffffffffffffffffffffffffffffffff82166000908152602081905260409020548290829081106115bc576040517fd063582900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff831660048201526024810182905260440161058c565b6115c4611771565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561160e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116329190613ad1565b15611669576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b838361167582826107c0565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146116f8576040517fa17e375200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff831660048201526024810182905260440161058c565b73ffffffffffffffffffffffffffffffffffffffff8616600090815260208190526040812061172890888861232b565b90506117348782611e85565b505050505061176d60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d76119a990919063ffffffff16565b5050565b600061179b7f0e555410d8128dff796eab5d29b97dd593ce9cab44a71b64c08244579ea605335490565b905090565b73ffffffffffffffffffffffffffffffffffffffff821660009081526005850160205260409020548454815b818110156118185773ffffffffffffffffffffffffffffffffffffffff851660009081526004880160205260409020611805908261241b565b508061181081613b8a565b9150506117cc565b5073ffffffffffffffffffffffffffffffffffffffff84166000908152600587016020908152604080832084905560048901909152812061185890612427565b905060005b815181101561199f57600082828151811061187a5761187a613a85565b6020026020010151905060008960010160008381526020019081526020016000209050611933898b60000184815481106118b6576118b6613a85565b60009182526020918290206040805160a0810182526006909302909101805483528151808301835260018201548152600282015481860152938301939093526003830154908201526004820154606082015260059091015473ffffffffffffffffffffffffffffffffffffffff1660808201528391908b8b612434565b61194060028b01836124bb565b15801561195257506003810154875110155b1561198a5773ffffffffffffffffffffffffffffffffffffffff8816600090815260048b016020526040902061198890836124d3565b505b5050808061199790613b8a565b91505061185d565b5050505050505050565b9055565b816119b6611771565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301529190911690637fd2919290602401602060405180830381865afa158015611a24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a489190613ad1565b611a96576040517f4d53256500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8216600482015260240161058c565b611a9e611771565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ae8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b0c9190613ad1565b15611b43576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517ff667f897000000000000000000000000000000000000000000000000000000008152336004820181905290849073ffffffffffffffffffffffffffffffffffffffff82169063f667f89790602401600060405180830381600087803b158015611baf57600080fd5b505af1158015611bc3573d6000803e3d6000fd5b5050505060005b8451811015611c0857611bf686868381518110611be957611be9613a85565b60200260200101516124df565b80611c0081613b8a565b915050611bca565b505050505050565b60006103cb82600201612612565b6000611c2b848390541190565b611c37575060006104b9565b506000818152600184016020908152604080832073ffffffffffffffffffffffffffffffffffffffff861684529091529020549392505050565b60606000611c8185600201612427565b9050805167ffffffffffffffff811115611c9d57611c9d6136ed565b604051908082528060200260200182016040528015611cf957816020015b611ce66040518060800160405280600081526020016000815260200160008152602001600081525090565b815260200190600190039081611cbb5790505b50915060005b8151811015611e7c576000828281518110611d1c57611d1c613a85565b602002602001015190506000876000018281548110611d3d57611d3d613a85565b600091825260208083206040805160a08101825260069094029091018054845281518083018352600180830154825260028084015483870152868601929092526003830154868501526004830154606087015260059092015473ffffffffffffffffffffffffffffffffffffffff166080860152878652908d019092528320908101549193509190158015611dda57506020880151604084015111155b15611ded57611dea8a858a61261c565b90505b60008083600301546000148015611e0f575060208a0151611e0f908690612639565b15611e2557611e1f8c8c88612659565b90925090505b604051806080016040528087815260200184815260200183815260200182815250898881518110611e5857611e58613a85565b60200260200101819052505050505050508080611e7490613b8a565b915050611cff565b50509392505050565b8051606082015115611eef57611eef611e9e84836103d1565b606084015173ffffffffffffffffffffffffffffffffffffffff86166000908152602081905260409020611ed29085612715565b73ffffffffffffffffffffffffffffffffffffffff169190611fb3565b602082015115611f4f57808373ffffffffffffffffffffffffffffffffffffffff167f1239d8c1165187259e281474a9ae5bb87fabb197873589de0a2645ae5e2261da8460200151604051611f4691815260200190565b60405180910390a35b6040820151156105b057808373ffffffffffffffffffffffffffffffffffffffff167fc590246f839a70d2279ef40b9e46b50bb20789c016f823abca87b69963f225848460400151604051611fa691815260200190565b60405180910390a3505050565b6105b073ffffffffffffffffffffffffffffffffffffffff8416838361275d565b303b1515801561200357507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b1561203a576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff81163b612088576040517f14878b6900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6120b17f0e555410d8128dff796eab5d29b97dd593ce9cab44a71b64c08244579ea60533829055565b50565b303b151580156120e357507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b1561211a576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755565b6040810151421061217d576040517f0a5af16500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620151808160600151108061219957506303c267008160600151115b156120b1576040517f72cd3d6300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6121d8613622565b6000806121fb6121f0670de0b6b3a764000086612831565b60208701519061283d565b9050600061221961140583886020015161288e90919063ffffffff16565b60208701929092525084925090505b9250929050565b60006104b98284613d79565b815460018082018455600084815260208082208551600686029091019081558582015180518286015582015160028201556040808701516003830155606087015160048301556080870151600590920180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff909316929092179091558483529286019052206122e190836128dc565b6122ee600284018261241b565b5092915050565b602081015181516000916103cb919061222f565b6105b073ffffffffffffffffffffffffffffffffffffffff84168330846128f5565b6123566040518060800160405280600081526020016000815260200160008152602001600081525090565b6000828152600185016020526040812060028101549091036123f1576123eb85848673ffffffffffffffffffffffffffffffffffffffff16639d888e866040518163ffffffff1660e01b8152600401606060405180830381865afa1580156123c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123e69190613d91565b61261c565b60208301525b806003015460000361241357612408858585612659565b606084015260408301525b509392505050565b60006104b98383612953565b606060006104b9836129a2565b600061244386868686866129fe565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260208890526040902054909150612476908261222f565b73ffffffffffffffffffffffffffffffffffffffff841660009081526020889052604090205560018601546124ab9082612831565b8660010181905550505050505050565b600081815260018301602052604081205415156104b9565b60006104b98383612cff565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260208190526040902054829082908110612560576040517fd063582900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff831660048201526024810182905260440161058c565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260208190526040812090612591823387612df2565b90506125a23382611ed28589612715565b843373ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167f865ca08d59f5cb456e85cd2f7ef63664ea4f73327414e9d8152c4158b0e946458460405161260291815260200190565b60405180910390a4505050505050565b60006103cb825490565b8051600083815260018501602052604090206002018190556104b9565b60008260600151836040015161264f9190613d79565b9091101592915050565b6000806126fa8486600001858154811061267557612675613a85565b600091825260208083206040805160a081018252600690940290910180548452815180830183526001808301548252600283015482860152858501919091526003820154858401526004820154606086015260059091015473ffffffffffffffffffffffffffffffffffffffff1660808501528985528b019091529091209190612e2e565b909250905061270c60028601846124d3565b50935093915050565b600082600001828154811061272c5761272c613a85565b600091825260209091206006909102016005015473ffffffffffffffffffffffffffffffffffffffff169392505050565b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526105b09084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152613026565b60006104b98284613e14565b604080518082019091526000808252602082015260408051808201909152835181906128699085613132565b815260200161288584866020015161313290919063ffffffff16565b90529392505050565b6040805180820190915260008082526020820152604080518082019091528251845182916128bc9190612831565b81526020016128858460200151866020015161283190919063ffffffff16565b6128e981602001516122f5565b82600101819055505050565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526109bd9085907f23b872dd00000000000000000000000000000000000000000000000000000000906084016127af565b600081815260018301602052604081205461299a575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556103cb565b5060006103cb565b6060816000018054806020026020016040519081016040528092919081815260200182805480156129f257602002820191906000526020600020905b8154815260200190600101908083116129de575b50505050509050919050565b60008060008760020154600014612a19578760020154612a1c565b83515b600389015415612a30578860030154612a52565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff5b6040517f8e480b2000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8881166004830152929450909250600091612b01918491612afc9187918d1690638e480b2090602401602060405180830381865afa158015612ad3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612af79190613bc2565b613151565b613168565b90506000612b13838760000151613168565b90506000612c298a73ffffffffffffffffffffffffffffffffffffffff1663476fa96d856040518263ffffffff1660e01b8152600401612b5591815260200190565b6040805180830381865afa158015612b71573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b959190613e2b565b6040517f476fa96d0000000000000000000000000000000000000000000000000000000081526004810185905273ffffffffffffffffffffffffffffffffffffffff8d169063476fa96d906024016040805180830381865afa158015612bff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c239190613e2b565b90613177565b6040517fb7648fb900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8a81166004830152919250600091612cca9184918e169063b7648fb9906024016040805180830381865afa158015612ca0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cc49190613e2b565b906131c5565b9050612cef612cea612ce583612cdf8e613219565b90613240565b61328e565b6132a2565b9c9b505050505050505050505050565b60008181526001830160205260408120548015612de8576000612d23600183613e14565b8554909150600090612d3790600190613e14565b9050818114612d9c576000866000018281548110612d5757612d57613a85565b9060005260206000200154905080876000018481548110612d7a57612d7a613a85565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612dad57612dad613e5d565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506103cb565b60009150506103cb565b6000818152600184016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8616845290915281208054908290556107b8565b600080600085600201549050612e89818673ffffffffffffffffffffffffffffffffffffffff1663c07f47d46040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ad3573d6000803e3d6000fd5b600387018190556040517f7ece075d0000000000000000000000000000000000000000000000000000000081526004810183905290935060009073ffffffffffffffffffffffffffffffffffffffff871690637ece075d90602401606060405180830381865afa158015612f01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f259190613d91565b6040517f7ece075d0000000000000000000000000000000000000000000000000000000081526004810186905290915060009073ffffffffffffffffffffffffffffffffffffffff881690637ece075d90602401606060405180830381865afa158015612f96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fba9190613d91565b9050600082602001518260200151612fd29190613e14565b8760600151612fe19190613e14565b9050613000818860600151612ff98a602001516122f5565b91906132e2565b60018a01549095506130129086612831565b896001018190555050505050935093915050565b6000613088826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166132ef9092919063ffffffff16565b8051909150156105b057808060200190518101906130a69190613ad1565b6105b0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840161058c565b6000670de0b6b3a76400006131478385613e8c565b6104b99190613ef8565b60008183101561316157816104b9565b5090919050565b600081831061316157816104b9565b6040805180820190915260008082526020820152604080518082019091528251845182916131a591906132fe565b8152602001612885846020015186602001516132fe90919063ffffffff16565b604080518082019091526000808252602082015260405180604001604052806131ff84600001516131f9876000015161330a565b90613369565b815260200161288584602001516131f9876020015161330a565b6040805180820190915260008082526020820152606082015160208301516103cb91613388565b60408051808201909152600080825260208201526040805180820190915282518451829161326e9190613369565b81526020016128858460200151866020015161336990919063ffffffff16565b602081015181516000916103cb91906133ed565b600081818112156103cb576040517f501f289e0000000000000000000000000000000000000000000000000000000081526004810182905260240161058c565b60006107b88484846133f9565b60606107b88484600085613410565b60006104b98284613f0c565b6000817f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8111156103cb576040517ea07eb50000000000000000000000000000000000000000000000000000000081526004810182905260240161058c565b6000670de0b6b3a764000061337e8385613f80565b6104b9919061403c565b604080518082019091526000808252602082015260405180604001604052806133cc6133bb6133b6866135a6565b61330a565b86516133c69061330a565b906135ba565b81526020016128856133e06133b6866135a6565b6133c6876020015161330a565b60006104b982846140a4565b6000816134068486613e8c565b6107b89190613ef8565b6060824710156134a2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c0000000000000000000000000000000000000000000000000000606482015260840161058c565b73ffffffffffffffffffffffffffffffffffffffff85163b613520576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161058c565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516135499190614144565b60006040518083038185875af1925050503d8060008114613586576040519150601f19603f3d011682016040523d82523d6000602084013e61358b565b606091505b509150915061359b8282866135cf565b979650505050505050565b60006103cb670de0b6b3a764000083613e8c565b60008161337e670de0b6b3a764000085613f80565b606083156135de5750816104b9565b8251156135ee5782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161058c9190614160565b6040518060a0016040528060008152602001613651604051806040016040528060008152602001600081525090565b81526020016000815260200160008152602001600073ffffffffffffffffffffffffffffffffffffffff1681525090565b73ffffffffffffffffffffffffffffffffffffffff811681146120b157600080fd5b6000602082840312156136b657600080fd5b81356104b981613682565b600080604083850312156136d457600080fd5b82356136df81613682565b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040805190810167ffffffffffffffff81118282101715613766577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405290565b60006060828403121561377e57600080fd5b6040516060810181811067ffffffffffffffff821117156137c8577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b80604052508091508235815260208301356020820152604083013560408201525092915050565b6000806080838503121561380257600080fd5b823561380d81613682565b915061381c846020850161376c565b90509250929050565b60c081016103cb8284805182526020810151805160208401526020810151604084015250604081015160608301526060810151608083015273ffffffffffffffffffffffffffffffffffffffff60808201511660a08301525050565b60008083601f84011261389357600080fd5b50813567ffffffffffffffff8111156138ab57600080fd5b6020830191508360208260051b850101111561222857600080fd5b6000806000604084860312156138db57600080fd5b83356138e681613682565b9250602084013567ffffffffffffffff81111561390257600080fd5b61390e86828701613881565b9497909650939450505050565b60008060006060848603121561393057600080fd5b833561393b81613682565b9250602084013561394b81613682565b929592945050506040919091013590565b6000806000806040858703121561397257600080fd5b843567ffffffffffffffff8082111561398a57600080fd5b61399688838901613881565b909650945060208701359150808211156139af57600080fd5b506139bc87828801613881565b95989497509550505050565b6000606082840312156139da57600080fd5b6104b9838361376c565b600080602083850312156139f757600080fd5b823567ffffffffffffffff811115613a0e57600080fd5b613a1a85828601613881565b90969095509350505050565b60008082840360e0811215613a3a57600080fd5b8335613a4581613682565b925060c07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe082011215613a7757600080fd5b506020830190509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600060208284031215613ac657600080fd5b81516104b981613682565b600060208284031215613ae357600080fd5b815180151581146104b957600080fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112613b2857600080fd5b83018035915067ffffffffffffffff821115613b4357600080fd5b6020019150600581901b360382131561222857600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203613bbb57613bbb613b5b565b5060010190565b600060208284031215613bd457600080fd5b5051919050565b600060408284031215613bed57600080fd5b6040516040810181811067ffffffffffffffff82111715613c37577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604052823581526020928301359281019290925250919050565b600060c08284031215613c6357600080fd5b60405160a0810181811067ffffffffffffffff82111715613cad577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405282358152613cc18460208501613bdb565b6020820152606083013560408201526080830135606082015260a0830135613ce881613682565b60808201529392505050565b600060408284031215613d0657600080fd5b6104b98383613bdb565b60e08101613d6c8285805182526020810151805160208401526020810151604084015250604081015160608301526060810151608083015273ffffffffffffffffffffffffffffffffffffffff60808201511660a08301525050565b8260c08301529392505050565b60008219821115613d8c57613d8c613b5b565b500190565b600060608284031215613da357600080fd5b6040516060810181811067ffffffffffffffff82111715613ded577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b80604052508251815260208301516020820152604083015160408201528091505092915050565b600082821015613e2657613e26613b5b565b500390565b600060408284031215613e3d57600080fd5b613e4561371c565b82518152602083015160208201528091505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613ec457613ec4613b5b565b500290565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600082613f0757613f07613ec9565b500490565b6000808312837f800000000000000000000000000000000000000000000000000000000000000001831281151615613f4657613f46613b5b565b837f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff018313811615613f7a57613f7a613b5b565b50500390565b60007f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600084136000841385830485118282161615613fc157613fc1613b5b565b7f80000000000000000000000000000000000000000000000000000000000000006000871286820588128184161615613ffc57613ffc613b5b565b6000871292508782058712848416161561401857614018613b5b565b8785058712818416161561402e5761402e613b5b565b505050929093029392505050565b60008261404b5761404b613ec9565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83147f80000000000000000000000000000000000000000000000000000000000000008314161561409f5761409f613b5b565b500590565b6000808212827f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038413811516156140de576140de613b5b565b827f800000000000000000000000000000000000000000000000000000000000000003841281161561411257614112613b5b565b50500190565b60005b8381101561413357818101518382015260200161411b565b838111156109bd5750506000910152565b60008251614156818460208701614118565b9190910192915050565b602081526000825180602084015261417f816040850160208701614118565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fea2646970667358221220831c6b889a16c321a2b85f3e8d7e805b9de07b7c96d87d8c2eeb97c9c669aa1264736f6c634300080f0033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101515760003560e01c806370f3f08b116100cd578063d758869111610081578063f77c479111610066578063f77c479114610325578063f8724aba1461032d578063faaebd211461037557600080fd5b8063d7588691146102ff578063e1e5a82e1461031257600080fd5b8063a55ff01d116100b2578063a55ff01d146102c6578063b774b601146102d9578063c4d66de8146102ec57600080fd5b806370f3f08b1461026b57806390672ad8146102b357600080fd5b80632c3e50e5116101245780634ea71327116101095780634ea713271461023257806366f8162e146102455780636da0d5401461025857600080fd5b80632c3e50e5146101ff578063457182781461021f57600080fd5b806305d85eda14610156578063095c82411461019f578063144dcdd1146101b25780631830349c146101ea575b600080fd5b61018c6101643660046136a4565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6040519081526020015b60405180910390f35b61018c6101ad3660046136c1565b610395565b6101c56101c03660046136c1565b6103d1565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610196565b6101fd6101f83660046137ef565b6104c0565b005b61021261020d3660046136c1565b6105b5565b6040516101969190613825565b6101fd61022d3660046138c6565b61066f565b61018c6102403660046136a4565b61075a565b61018c61025336600461391b565b610788565b6101c56102663660046136c1565b6107c0565b61018c6102793660046136c1565b73ffffffffffffffffffffffffffffffffffffffff9190911660009081526020818152604080832093835260019093019052206003015490565b6101fd6102c136600461395c565b610837565b6101fd6102d43660046139c8565b6109c3565b6101fd6102e73660046139e4565b610af0565b6101fd6102fa3660046136a4565b610cfa565b61018c61030d366004613a26565b610e18565b6101fd6103203660046136c1565b6114b6565b6101c5611771565b61018c61033b3660046136c1565b73ffffffffffffffffffffffffffffffffffffffff9190911660009081526020818152604080832093835260019384019091529020015490565b61018c6103833660046136a4565b60016020526000908152604090205481565b73ffffffffffffffffffffffffffffffffffffffff82166000908152602081815260408083208484526001019091529020600201545b92915050565b60006103db611771565b73ffffffffffffffffffffffffffffffffffffffff16634c5430a06000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001848154811061044857610448613a85565b9060005260206000209060060201600001546040518263ffffffff1660e01b815260040161047891815260200190565b602060405180830381865afa158015610495573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104b99190613ab4565b9392505050565b6104c8611771565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff9190911690637fd2919290602401602060405180830381865afa158015610534573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105589190613ad1565b610595576040517f4d5325650000000000000000000000000000000000000000000000000000000081523360048201526024015b60405180910390fd5b3360008181526020819052604090206105b0908285856117a0565b505050565b6105bd613622565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090208054839081106105f4576105f4613a85565b60009182526020918290206040805160a0810182526006909302909101805483528151808301835260018201548152600282015481860152938301939093526003830154908201526004820154606082015260059091015473ffffffffffffffffffffffffffffffffffffffff166080820152905092915050565b60026106997f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b036106d0576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755610731838383808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506119ad92505050565b60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755505050565b73ffffffffffffffffffffffffffffffffffffffff811660009081526020819052604081206103cb90611c10565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604081206107b8908484611c1e565b949350505050565b60006107ca611771565b73ffffffffffffffffffffffffffffffffffffffff1663a123c33e6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001848154811061044857610448613a85565b60026108617f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03610898576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7558281146108f5576040517f90fb223000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b838110156109975761098585858381811061091557610915613a85565b905060200201602081019061092a91906136a4565b84848481811061093c5761093c613a85565b905060200281019061094e9190613af3565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506119ad92505050565b8061098f81613b8a565b9150506108f8565b5060017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7555b50505050565b6109cb611771565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff9190911690637fd2919290602401602060405180830381865afa158015610a37573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a5b9190613ad1565b610a93576040517f4d53256500000000000000000000000000000000000000000000000000000000815233600482015260240161058c565b336000818152602081905260408120610aad908385611c71565b905060005b81518110156109bd57610ade83838381518110610ad157610ad1613a85565b6020026020010151611e85565b80610ae881613b8a565b915050610ab2565b610af8611771565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b669190613ad1565b15610b9d576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b818110156105b0576000838383818110610bbc57610bbc613a85565b9050602002016020810190610bd191906136a4565b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604081208054919055909150610c95610c09611771565b73ffffffffffffffffffffffffffffffffffffffff166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c779190613ab4565b73ffffffffffffffffffffffffffffffffffffffff84169083611fb3565b8173ffffffffffffffffffffffffffffffffffffffff167f10df095d1434aed409b2f33d2a6a8456f8b0824633cc12a1b43032085aadc41d82604051610cdd91815260200190565b60405180910390a250508080610cf290613b8a565b915050610ba0565b600180610d257f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b5490565b10610d5f576040517f1e7a9d950000000000000000000000000000000000000000000000000000000081526004810182905260240161058c565b610d887f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b829055565b60017fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c55610db582611fd4565b610dbd6120b4565b60007fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c556040518181527fbe9b076dc5b65990cca9dd9d7366682482e7817a6f6bc7f4faf4dc32af497f329060200160405180910390a15050565b60006002610e447f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03610e7b576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75582610ea8611771565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301529190911690637fd2919290602401602060405180830381865afa158015610f16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f3a9190613ad1565b610f88576040517f4d53256500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8216600482015260240161058c565b610f90611771565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ffe9190613ad1565b15611035576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b823561103f611771565b73ffffffffffffffffffffffffffffffffffffffff1663a123c33e826040518263ffffffff1660e01b815260040161107991815260200190565b602060405180830381865afa158015611096573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ba9190613ab4565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611121576040517f48f62f3c0000000000000000000000000000000000000000000000000000000081526004810182905260240161058c565b600061112b611771565b90508435158015906111cd57506040517f7d254e6600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8781166004830152821690637d254e6690602401602060405180830381865afa1580156111a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111c89190613bc2565b853514155b1561121c576040517fe264a52400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8716600482015260240161058c565b8073ffffffffffffffffffffffffffffffffffffffff16637d49c1b76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611267573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061128b9190613bc2565b6112948761075a565b106112cb576040517f1651519200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6112e26112dd36879003870187613c51565b612140565b60008061136b6112f736899003890189613c51565b8473ffffffffffffffffffffffffffffffffffffffff16633ceda0116040518163ffffffff1660e01b8152600401602060405180830381865afa158015611342573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113669190613bc2565b6121d0565b608082015173ffffffffffffffffffffffffffffffffffffffff1660009081526001602052604090205491935091506113a4908261222f565b608083015173ffffffffffffffffffffffffffffffffffffffff908116600090815260016020908152604080832094909455918b16815290819052206113ea908361223b565b955061142c3361140a611405368b90038b0160208c01613cf4565b6122f5565b608085015173ffffffffffffffffffffffffffffffffffffffff169190612309565b858873ffffffffffffffffffffffffffffffffffffffff167fee8233a38e17998eb73ba822048e13762f2b68729ef94c45133866ee75754dc68484604051611475929190613d10565b60405180910390a350505050506103cb60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d76119a990919063ffffffff16565b60026114e07f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03611517576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75573ffffffffffffffffffffffffffffffffffffffff82166000908152602081905260409020548290829081106115bc576040517fd063582900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff831660048201526024810182905260440161058c565b6115c4611771565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561160e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116329190613ad1565b15611669576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b838361167582826107c0565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146116f8576040517fa17e375200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff831660048201526024810182905260440161058c565b73ffffffffffffffffffffffffffffffffffffffff8616600090815260208190526040812061172890888861232b565b90506117348782611e85565b505050505061176d60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d76119a990919063ffffffff16565b5050565b600061179b7f0e555410d8128dff796eab5d29b97dd593ce9cab44a71b64c08244579ea605335490565b905090565b73ffffffffffffffffffffffffffffffffffffffff821660009081526005850160205260409020548454815b818110156118185773ffffffffffffffffffffffffffffffffffffffff851660009081526004880160205260409020611805908261241b565b508061181081613b8a565b9150506117cc565b5073ffffffffffffffffffffffffffffffffffffffff84166000908152600587016020908152604080832084905560048901909152812061185890612427565b905060005b815181101561199f57600082828151811061187a5761187a613a85565b6020026020010151905060008960010160008381526020019081526020016000209050611933898b60000184815481106118b6576118b6613a85565b60009182526020918290206040805160a0810182526006909302909101805483528151808301835260018201548152600282015481860152938301939093526003830154908201526004820154606082015260059091015473ffffffffffffffffffffffffffffffffffffffff1660808201528391908b8b612434565b61194060028b01836124bb565b15801561195257506003810154875110155b1561198a5773ffffffffffffffffffffffffffffffffffffffff8816600090815260048b016020526040902061198890836124d3565b505b5050808061199790613b8a565b91505061185d565b5050505050505050565b9055565b816119b6611771565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301529190911690637fd2919290602401602060405180830381865afa158015611a24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a489190613ad1565b611a96576040517f4d53256500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8216600482015260240161058c565b611a9e611771565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ae8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b0c9190613ad1565b15611b43576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517ff667f897000000000000000000000000000000000000000000000000000000008152336004820181905290849073ffffffffffffffffffffffffffffffffffffffff82169063f667f89790602401600060405180830381600087803b158015611baf57600080fd5b505af1158015611bc3573d6000803e3d6000fd5b5050505060005b8451811015611c0857611bf686868381518110611be957611be9613a85565b60200260200101516124df565b80611c0081613b8a565b915050611bca565b505050505050565b60006103cb82600201612612565b6000611c2b848390541190565b611c37575060006104b9565b506000818152600184016020908152604080832073ffffffffffffffffffffffffffffffffffffffff861684529091529020549392505050565b60606000611c8185600201612427565b9050805167ffffffffffffffff811115611c9d57611c9d6136ed565b604051908082528060200260200182016040528015611cf957816020015b611ce66040518060800160405280600081526020016000815260200160008152602001600081525090565b815260200190600190039081611cbb5790505b50915060005b8151811015611e7c576000828281518110611d1c57611d1c613a85565b602002602001015190506000876000018281548110611d3d57611d3d613a85565b600091825260208083206040805160a08101825260069094029091018054845281518083018352600180830154825260028084015483870152868601929092526003830154868501526004830154606087015260059092015473ffffffffffffffffffffffffffffffffffffffff166080860152878652908d019092528320908101549193509190158015611dda57506020880151604084015111155b15611ded57611dea8a858a61261c565b90505b60008083600301546000148015611e0f575060208a0151611e0f908690612639565b15611e2557611e1f8c8c88612659565b90925090505b604051806080016040528087815260200184815260200183815260200182815250898881518110611e5857611e58613a85565b60200260200101819052505050505050508080611e7490613b8a565b915050611cff565b50509392505050565b8051606082015115611eef57611eef611e9e84836103d1565b606084015173ffffffffffffffffffffffffffffffffffffffff86166000908152602081905260409020611ed29085612715565b73ffffffffffffffffffffffffffffffffffffffff169190611fb3565b602082015115611f4f57808373ffffffffffffffffffffffffffffffffffffffff167f1239d8c1165187259e281474a9ae5bb87fabb197873589de0a2645ae5e2261da8460200151604051611f4691815260200190565b60405180910390a35b6040820151156105b057808373ffffffffffffffffffffffffffffffffffffffff167fc590246f839a70d2279ef40b9e46b50bb20789c016f823abca87b69963f225848460400151604051611fa691815260200190565b60405180910390a3505050565b6105b073ffffffffffffffffffffffffffffffffffffffff8416838361275d565b303b1515801561200357507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b1561203a576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff81163b612088576040517f14878b6900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6120b17f0e555410d8128dff796eab5d29b97dd593ce9cab44a71b64c08244579ea60533829055565b50565b303b151580156120e357507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b1561211a576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755565b6040810151421061217d576040517f0a5af16500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620151808160600151108061219957506303c267008160600151115b156120b1576040517f72cd3d6300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6121d8613622565b6000806121fb6121f0670de0b6b3a764000086612831565b60208701519061283d565b9050600061221961140583886020015161288e90919063ffffffff16565b60208701929092525084925090505b9250929050565b60006104b98284613d79565b815460018082018455600084815260208082208551600686029091019081558582015180518286015582015160028201556040808701516003830155606087015160048301556080870151600590920180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff909316929092179091558483529286019052206122e190836128dc565b6122ee600284018261241b565b5092915050565b602081015181516000916103cb919061222f565b6105b073ffffffffffffffffffffffffffffffffffffffff84168330846128f5565b6123566040518060800160405280600081526020016000815260200160008152602001600081525090565b6000828152600185016020526040812060028101549091036123f1576123eb85848673ffffffffffffffffffffffffffffffffffffffff16639d888e866040518163ffffffff1660e01b8152600401606060405180830381865afa1580156123c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123e69190613d91565b61261c565b60208301525b806003015460000361241357612408858585612659565b606084015260408301525b509392505050565b60006104b98383612953565b606060006104b9836129a2565b600061244386868686866129fe565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260208890526040902054909150612476908261222f565b73ffffffffffffffffffffffffffffffffffffffff841660009081526020889052604090205560018601546124ab9082612831565b8660010181905550505050505050565b600081815260018301602052604081205415156104b9565b60006104b98383612cff565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260208190526040902054829082908110612560576040517fd063582900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff831660048201526024810182905260440161058c565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260208190526040812090612591823387612df2565b90506125a23382611ed28589612715565b843373ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167f865ca08d59f5cb456e85cd2f7ef63664ea4f73327414e9d8152c4158b0e946458460405161260291815260200190565b60405180910390a4505050505050565b60006103cb825490565b8051600083815260018501602052604090206002018190556104b9565b60008260600151836040015161264f9190613d79565b9091101592915050565b6000806126fa8486600001858154811061267557612675613a85565b600091825260208083206040805160a081018252600690940290910180548452815180830183526001808301548252600283015482860152858501919091526003820154858401526004820154606086015260059091015473ffffffffffffffffffffffffffffffffffffffff1660808501528985528b019091529091209190612e2e565b909250905061270c60028601846124d3565b50935093915050565b600082600001828154811061272c5761272c613a85565b600091825260209091206006909102016005015473ffffffffffffffffffffffffffffffffffffffff169392505050565b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526105b09084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152613026565b60006104b98284613e14565b604080518082019091526000808252602082015260408051808201909152835181906128699085613132565b815260200161288584866020015161313290919063ffffffff16565b90529392505050565b6040805180820190915260008082526020820152604080518082019091528251845182916128bc9190612831565b81526020016128858460200151866020015161283190919063ffffffff16565b6128e981602001516122f5565b82600101819055505050565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526109bd9085907f23b872dd00000000000000000000000000000000000000000000000000000000906084016127af565b600081815260018301602052604081205461299a575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556103cb565b5060006103cb565b6060816000018054806020026020016040519081016040528092919081815260200182805480156129f257602002820191906000526020600020905b8154815260200190600101908083116129de575b50505050509050919050565b60008060008760020154600014612a19578760020154612a1c565b83515b600389015415612a30578860030154612a52565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff5b6040517f8e480b2000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8881166004830152929450909250600091612b01918491612afc9187918d1690638e480b2090602401602060405180830381865afa158015612ad3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612af79190613bc2565b613151565b613168565b90506000612b13838760000151613168565b90506000612c298a73ffffffffffffffffffffffffffffffffffffffff1663476fa96d856040518263ffffffff1660e01b8152600401612b5591815260200190565b6040805180830381865afa158015612b71573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b959190613e2b565b6040517f476fa96d0000000000000000000000000000000000000000000000000000000081526004810185905273ffffffffffffffffffffffffffffffffffffffff8d169063476fa96d906024016040805180830381865afa158015612bff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c239190613e2b565b90613177565b6040517fb7648fb900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8a81166004830152919250600091612cca9184918e169063b7648fb9906024016040805180830381865afa158015612ca0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cc49190613e2b565b906131c5565b9050612cef612cea612ce583612cdf8e613219565b90613240565b61328e565b6132a2565b9c9b505050505050505050505050565b60008181526001830160205260408120548015612de8576000612d23600183613e14565b8554909150600090612d3790600190613e14565b9050818114612d9c576000866000018281548110612d5757612d57613a85565b9060005260206000200154905080876000018481548110612d7a57612d7a613a85565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612dad57612dad613e5d565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506103cb565b60009150506103cb565b6000818152600184016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8616845290915281208054908290556107b8565b600080600085600201549050612e89818673ffffffffffffffffffffffffffffffffffffffff1663c07f47d46040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ad3573d6000803e3d6000fd5b600387018190556040517f7ece075d0000000000000000000000000000000000000000000000000000000081526004810183905290935060009073ffffffffffffffffffffffffffffffffffffffff871690637ece075d90602401606060405180830381865afa158015612f01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f259190613d91565b6040517f7ece075d0000000000000000000000000000000000000000000000000000000081526004810186905290915060009073ffffffffffffffffffffffffffffffffffffffff881690637ece075d90602401606060405180830381865afa158015612f96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fba9190613d91565b9050600082602001518260200151612fd29190613e14565b8760600151612fe19190613e14565b9050613000818860600151612ff98a602001516122f5565b91906132e2565b60018a01549095506130129086612831565b896001018190555050505050935093915050565b6000613088826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166132ef9092919063ffffffff16565b8051909150156105b057808060200190518101906130a69190613ad1565b6105b0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840161058c565b6000670de0b6b3a76400006131478385613e8c565b6104b99190613ef8565b60008183101561316157816104b9565b5090919050565b600081831061316157816104b9565b6040805180820190915260008082526020820152604080518082019091528251845182916131a591906132fe565b8152602001612885846020015186602001516132fe90919063ffffffff16565b604080518082019091526000808252602082015260405180604001604052806131ff84600001516131f9876000015161330a565b90613369565b815260200161288584602001516131f9876020015161330a565b6040805180820190915260008082526020820152606082015160208301516103cb91613388565b60408051808201909152600080825260208201526040805180820190915282518451829161326e9190613369565b81526020016128858460200151866020015161336990919063ffffffff16565b602081015181516000916103cb91906133ed565b600081818112156103cb576040517f501f289e0000000000000000000000000000000000000000000000000000000081526004810182905260240161058c565b60006107b88484846133f9565b60606107b88484600085613410565b60006104b98284613f0c565b6000817f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8111156103cb576040517ea07eb50000000000000000000000000000000000000000000000000000000081526004810182905260240161058c565b6000670de0b6b3a764000061337e8385613f80565b6104b9919061403c565b604080518082019091526000808252602082015260405180604001604052806133cc6133bb6133b6866135a6565b61330a565b86516133c69061330a565b906135ba565b81526020016128856133e06133b6866135a6565b6133c6876020015161330a565b60006104b982846140a4565b6000816134068486613e8c565b6107b89190613ef8565b6060824710156134a2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c0000000000000000000000000000000000000000000000000000606482015260840161058c565b73ffffffffffffffffffffffffffffffffffffffff85163b613520576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161058c565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516135499190614144565b60006040518083038185875af1925050503d8060008114613586576040519150601f19603f3d011682016040523d82523d6000602084013e61358b565b606091505b509150915061359b8282866135cf565b979650505050505050565b60006103cb670de0b6b3a764000083613e8c565b60008161337e670de0b6b3a764000085613f80565b606083156135de5750816104b9565b8251156135ee5782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161058c9190614160565b6040518060a0016040528060008152602001613651604051806040016040528060008152602001600081525090565b81526020016000815260200160008152602001600073ffffffffffffffffffffffffffffffffffffffff1681525090565b73ffffffffffffffffffffffffffffffffffffffff811681146120b157600080fd5b6000602082840312156136b657600080fd5b81356104b981613682565b600080604083850312156136d457600080fd5b82356136df81613682565b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040805190810167ffffffffffffffff81118282101715613766577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405290565b60006060828403121561377e57600080fd5b6040516060810181811067ffffffffffffffff821117156137c8577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b80604052508091508235815260208301356020820152604083013560408201525092915050565b6000806080838503121561380257600080fd5b823561380d81613682565b915061381c846020850161376c565b90509250929050565b60c081016103cb8284805182526020810151805160208401526020810151604084015250604081015160608301526060810151608083015273ffffffffffffffffffffffffffffffffffffffff60808201511660a08301525050565b60008083601f84011261389357600080fd5b50813567ffffffffffffffff8111156138ab57600080fd5b6020830191508360208260051b850101111561222857600080fd5b6000806000604084860312156138db57600080fd5b83356138e681613682565b9250602084013567ffffffffffffffff81111561390257600080fd5b61390e86828701613881565b9497909650939450505050565b60008060006060848603121561393057600080fd5b833561393b81613682565b9250602084013561394b81613682565b929592945050506040919091013590565b6000806000806040858703121561397257600080fd5b843567ffffffffffffffff8082111561398a57600080fd5b61399688838901613881565b909650945060208701359150808211156139af57600080fd5b506139bc87828801613881565b95989497509550505050565b6000606082840312156139da57600080fd5b6104b9838361376c565b600080602083850312156139f757600080fd5b823567ffffffffffffffff811115613a0e57600080fd5b613a1a85828601613881565b90969095509350505050565b60008082840360e0811215613a3a57600080fd5b8335613a4581613682565b925060c07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe082011215613a7757600080fd5b506020830190509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600060208284031215613ac657600080fd5b81516104b981613682565b600060208284031215613ae357600080fd5b815180151581146104b957600080fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112613b2857600080fd5b83018035915067ffffffffffffffff821115613b4357600080fd5b6020019150600581901b360382131561222857600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203613bbb57613bbb613b5b565b5060010190565b600060208284031215613bd457600080fd5b5051919050565b600060408284031215613bed57600080fd5b6040516040810181811067ffffffffffffffff82111715613c37577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604052823581526020928301359281019290925250919050565b600060c08284031215613c6357600080fd5b60405160a0810181811067ffffffffffffffff82111715613cad577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405282358152613cc18460208501613bdb565b6020820152606083013560408201526080830135606082015260a0830135613ce881613682565b60808201529392505050565b600060408284031215613d0657600080fd5b6104b98383613bdb565b60e08101613d6c8285805182526020810151805160208401526020810151604084015250604081015160608301526060810151608083015273ffffffffffffffffffffffffffffffffffffffff60808201511660a08301525050565b8260c08301529392505050565b60008219821115613d8c57613d8c613b5b565b500190565b600060608284031215613da357600080fd5b6040516060810181811067ffffffffffffffff82111715613ded577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b80604052508251815260208301516020820152604083015160408201528091505092915050565b600082821015613e2657613e26613b5b565b500390565b600060408284031215613e3d57600080fd5b613e4561371c565b82518152602083015160208201528091505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613ec457613ec4613b5b565b500290565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600082613f0757613f07613ec9565b500490565b6000808312837f800000000000000000000000000000000000000000000000000000000000000001831281151615613f4657613f46613b5b565b837f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff018313811615613f7a57613f7a613b5b565b50500390565b60007f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600084136000841385830485118282161615613fc157613fc1613b5b565b7f80000000000000000000000000000000000000000000000000000000000000006000871286820588128184161615613ffc57613ffc613b5b565b6000871292508782058712848416161561401857614018613b5b565b8785058712818416161561402e5761402e613b5b565b505050929093029392505050565b60008261404b5761404b613ec9565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83147f80000000000000000000000000000000000000000000000000000000000000008314161561409f5761409f613b5b565b500590565b6000808212827f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038413811516156140de576140de613b5b565b827f800000000000000000000000000000000000000000000000000000000000000003841281161561411257614112613b5b565b50500190565b60005b8381101561413357818101518382015260200161411b565b838111156109bd5750506000910152565b60008251614156818460208701614118565b9190910192915050565b602081526000825180602084015261417f816040850160208701614118565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fea2646970667358221220831c6b889a16c321a2b85f3e8d7e805b9de07b7c96d87d8c2eeb97c9c669aa1264736f6c634300080f0033", - "devdoc": { - "kind": "dev", - "methods": { - "active(address)": { - "params": { - "product": "Product to check for" - }, - "returns": { - "_0": "Number of active programs" - } - }, - "available(address,uint256)": { - "params": { - "product": "Product to return for", - "programId": "Program to return for" - }, - "returns": { - "_0": "Available rewards for `programId`" - } - }, - "claim(address,uint256[])": { - "params": { - "product": "Product to claim rewards for", - "programIds": "Programs to claim rewards for" - } - }, - "claim(address[],uint256[][])": { - "params": { - "products": "Products to claim rewards for", - "programIds": "Programs to claim rewards for" - } - }, - "claimFee(address[])": { - "params": { - "tokens": "Tokens to claim fees for" - } - }, - "complete(address,uint256)": { - "details": "Must be called as the program owner", - "params": { - "product": "Product that the program is running on", - "programId": "Program to complete early" - } - }, - "count(address)": { - "params": { - "product": "Product to check for" - }, - "returns": { - "_0": "Number of programs (inactive or active)" - } - }, - "create(address,(uint256,(uint256,uint256),uint256,uint256,address))": { - "details": "Must be called as the product or protocol owner", - "params": { - "product": "The product to create the new program on", - "programInfo": "Parameters for the new program" - }, - "returns": { - "programId": "New program's ID" - } - }, - "initialize(address)": { - "details": "Must be called atomically as part of the upgradeable proxy deployment to avoid front-running", - "params": { - "controller_": "Factory contract address" - } - }, - "owner(address,uint256)": { - "params": { - "product": "Product to return for", - "programId": "Program to return for" - }, - "returns": { - "_0": "The owner of `programId`" - } - }, - "programInfos(address,uint256)": { - "params": { - "product": "Product to return for", - "programId": "Program to return for" - }, - "returns": { - "_0": "Program info" - } - }, - "sync((uint256,uint256,int256))": { - "details": "Called every settle() from each product", - "params": { - "currentOracleVersion": "The preloaded current oracle version" - } - }, - "syncAccount(address,(uint256,uint256,int256))": { - "details": "Called immediately proceeding a position update in the corresponding product", - "params": { - "account": "Account to sync", - "currentOracleVersion": "The preloaded current oracle version" - } - }, - "treasury(address,uint256)": { - "params": { - "product": "Product to return for", - "programId": "Program to return for" - }, - "returns": { - "_0": "The treasury of `programId`" - } - }, - "unclaimed(address,address,uint256)": { - "params": { - "account": "Account to return for", - "product": "Product to return for", - "programId": "Program to return for" - }, - "returns": { - "_0": "`account`'s total unclaimed rewards for `programId`" - } - }, - "versionComplete(address,uint256)": { - "params": { - "product": "Product to return for", - "programId": "Program to return for" - }, - "returns": { - "_0": "The version completed for `programId`" - } - }, - "versionStarted(address,uint256)": { - "params": { - "product": "Product to return for", - "programId": "Program to return for" - }, - "returns": { - "_0": "The version started for `programId`" - } - } - }, - "stateVariables": { - "_products": { - "details": "Product management state" - }, - "fees": { - "details": "Fees that have been collected, but remain unclaimed" - } - }, - "title": "Incentivizer", - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": { - "active(address)": { - "notice": "Returns the quantity of active programs for a given product" - }, - "available(address,uint256)": { - "notice": "Returns available rewards for a specific program" - }, - "claim(address,uint256[])": { - "notice": "Claims all of `msg.sender`'s rewards for `product` programs" - }, - "claim(address[],uint256[][])": { - "notice": "Claims all of `msg.sender`'s rewards for a specific program" - }, - "claimFee(address[])": { - "notice": "Claims all `tokens` fees to the protocol treasury" - }, - "complete(address,uint256)": { - "notice": "Completes an in-progress program early" - }, - "count(address)": { - "notice": "Returns the quantity of programs for a given product" - }, - "create(address,(uint256,(uint256,uint256),uint256,uint256,address))": { - "notice": "Creates a new incentive program" - }, - "initialize(address)": { - "notice": "Initializes the contract state" - }, - "owner(address,uint256)": { - "notice": "Returns the owner of a specific program" - }, - "programInfos(address,uint256)": { - "notice": "Returns program info for program `programId`" - }, - "sync((uint256,uint256,int256))": { - "notice": "Starts and completes programs as they become available" - }, - "syncAccount(address,(uint256,uint256,int256))": { - "notice": "Settles unsettled balance for `account`" - }, - "treasury(address,uint256)": { - "notice": "Returns the treasury of a specific program" - }, - "unclaimed(address,address,uint256)": { - "notice": "Returns `account`'s total unclaimed rewards for a specific program" - }, - "versionComplete(address,uint256)": { - "notice": "Returns the version completed for a specific program" - }, - "versionStarted(address,uint256)": { - "notice": "Returns the version started for a specific program" - } - }, - "notice": "Manages logic and state for all incentive programs in the protocol.", - "version": 1 - }, - "storageLayout": { - "storage": [ - { - "astId": 12696, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "_products", - "offset": 0, - "slot": "0", - "type": "t_mapping(t_contract(IProduct)16214,t_struct(ProductManager)13513_storage)" - }, - { - "astId": 12703, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "fees", - "offset": 0, - "slot": "1", - "type": "t_mapping(t_userDefinedValueType(Token18)4011,t_userDefinedValueType(UFixed18)3224)" - } - ], - "types": { - "t_address": { - "encoding": "inplace", - "label": "address", - "numberOfBytes": "20" - }, - "t_array(t_bytes32)dyn_storage": { - "base": "t_bytes32", - "encoding": "dynamic_array", - "label": "bytes32[]", - "numberOfBytes": "32" - }, - "t_array(t_struct(ProgramInfo)17590_storage)dyn_storage": { - "base": "t_struct(ProgramInfo)17590_storage", - "encoding": "dynamic_array", - "label": "struct ProgramInfo[]", - "numberOfBytes": "32" - }, - "t_bytes32": { - "encoding": "inplace", - "label": "bytes32", - "numberOfBytes": "32" - }, - "t_contract(IProduct)16214": { - "encoding": "inplace", - "label": "contract IProduct", - "numberOfBytes": "20" - }, - "t_mapping(t_address,t_struct(UintSet)10257_storage)": { - "encoding": "mapping", - "key": "t_address", - "label": "mapping(address => struct EnumerableSet.UintSet)", - "numberOfBytes": "32", - "value": "t_struct(UintSet)10257_storage" - }, - "t_mapping(t_address,t_uint256)": { - "encoding": "mapping", - "key": "t_address", - "label": "mapping(address => uint256)", - "numberOfBytes": "32", - "value": "t_uint256" - }, - "t_mapping(t_address,t_userDefinedValueType(UFixed18)3224)": { - "encoding": "mapping", - "key": "t_address", - "label": "mapping(address => UFixed18)", - "numberOfBytes": "32", - "value": "t_userDefinedValueType(UFixed18)3224" - }, - "t_mapping(t_bytes32,t_uint256)": { - "encoding": "mapping", - "key": "t_bytes32", - "label": "mapping(bytes32 => uint256)", - "numberOfBytes": "32", - "value": "t_uint256" - }, - "t_mapping(t_contract(IProduct)16214,t_struct(ProductManager)13513_storage)": { - "encoding": "mapping", - "key": "t_contract(IProduct)16214", - "label": "mapping(contract IProduct => struct ProductManager)", - "numberOfBytes": "32", - "value": "t_struct(ProductManager)13513_storage" - }, - "t_mapping(t_uint256,t_struct(Program)14108_storage)": { - "encoding": "mapping", - "key": "t_uint256", - "label": "mapping(uint256 => struct Program)", - "numberOfBytes": "32", - "value": "t_struct(Program)14108_storage" - }, - "t_mapping(t_userDefinedValueType(Token18)4011,t_userDefinedValueType(UFixed18)3224)": { - "encoding": "mapping", - "key": "t_userDefinedValueType(Token18)4011", - "label": "mapping(Token18 => UFixed18)", - "numberOfBytes": "32", - "value": "t_userDefinedValueType(UFixed18)3224" - }, - "t_struct(Position)16769_storage": { - "encoding": "inplace", - "label": "struct Position", - "members": [ - { - "astId": 16764, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "maker", - "offset": 0, - "slot": "0", - "type": "t_userDefinedValueType(UFixed18)3224" - }, - { - "astId": 16768, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "taker", - "offset": 0, - "slot": "1", - "type": "t_userDefinedValueType(UFixed18)3224" - } - ], - "numberOfBytes": "64" - }, - "t_struct(ProductManager)13513_storage": { - "encoding": "inplace", - "label": "struct ProductManager", - "members": [ - { - "astId": 13491, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "programInfos", - "offset": 0, - "slot": "0", - "type": "t_array(t_struct(ProgramInfo)17590_storage)dyn_storage" - }, - { - "astId": 13497, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "programs", - "offset": 0, - "slot": "1", - "type": "t_mapping(t_uint256,t_struct(Program)14108_storage)" - }, - { - "astId": 13501, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "activePrograms", - "offset": 0, - "slot": "2", - "type": "t_struct(UintSet)10257_storage" - }, - { - "astId": 13507, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "activeProgramsFor", - "offset": 0, - "slot": "4", - "type": "t_mapping(t_address,t_struct(UintSet)10257_storage)" - }, - { - "astId": 13512, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "nextProgramFor", - "offset": 0, - "slot": "5", - "type": "t_mapping(t_address,t_uint256)" - } - ], - "numberOfBytes": "192" - }, - "t_struct(Program)14108_storage": { - "encoding": "inplace", - "label": "struct Program", - "members": [ - { - "astId": 14097, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "settled", - "offset": 0, - "slot": "0", - "type": "t_mapping(t_address,t_userDefinedValueType(UFixed18)3224)" - }, - { - "astId": 14101, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "available", - "offset": 0, - "slot": "1", - "type": "t_userDefinedValueType(UFixed18)3224" - }, - { - "astId": 14104, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "versionStarted", - "offset": 0, - "slot": "2", - "type": "t_uint256" - }, - { - "astId": 14107, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "versionComplete", - "offset": 0, - "slot": "3", - "type": "t_uint256" - } - ], - "numberOfBytes": "128" - }, - "t_struct(ProgramInfo)17590_storage": { - "encoding": "inplace", - "label": "struct ProgramInfo", - "members": [ - { - "astId": 17575, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "coordinatorId", - "offset": 0, - "slot": "0", - "type": "t_uint256" - }, - { - "astId": 17579, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "amount", - "offset": 0, - "slot": "1", - "type": "t_struct(Position)16769_storage" - }, - { - "astId": 17582, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "start", - "offset": 0, - "slot": "3", - "type": "t_uint256" - }, - { - "astId": 17585, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "duration", - "offset": 0, - "slot": "4", - "type": "t_uint256" - }, - { - "astId": 17589, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "token", - "offset": 0, - "slot": "5", - "type": "t_userDefinedValueType(Token18)4011" - } - ], - "numberOfBytes": "192" - }, - "t_struct(Set)9799_storage": { - "encoding": "inplace", - "label": "struct EnumerableSet.Set", - "members": [ - { - "astId": 9794, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "_values", - "offset": 0, - "slot": "0", - "type": "t_array(t_bytes32)dyn_storage" - }, - { - "astId": 9798, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "_indexes", - "offset": 0, - "slot": "1", - "type": "t_mapping(t_bytes32,t_uint256)" - } - ], - "numberOfBytes": "64" - }, - "t_struct(UintSet)10257_storage": { - "encoding": "inplace", - "label": "struct EnumerableSet.UintSet", - "members": [ - { - "astId": 10256, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "_inner", - "offset": 0, - "slot": "0", - "type": "t_struct(Set)9799_storage" - } - ], - "numberOfBytes": "64" - }, - "t_uint256": { - "encoding": "inplace", - "label": "uint256", - "numberOfBytes": "32" - }, - "t_userDefinedValueType(Token18)4011": { - "encoding": "inplace", - "label": "Token18", - "numberOfBytes": "20" - }, - "t_userDefinedValueType(UFixed18)3224": { - "encoding": "inplace", - "label": "UFixed18", - "numberOfBytes": "32" - } - } - } -} diff --git a/packages/perennial/deployments/goerli/Incentivizer_Proxy.json b/packages/perennial/deployments/goerli/Incentivizer_Proxy.json deleted file mode 100644 index e09b95b84..000000000 --- a/packages/perennial/deployments/goerli/Incentivizer_Proxy.json +++ /dev/null @@ -1,229 +0,0 @@ -{ - "address": "0x1960628db367281B1a186dD5B80B5dd6978F016F", - "abi": [ - { - "inputs": [ - { - "internalType": "address", - "name": "_logic", - "type": "address" - }, - { - "internalType": "address", - "name": "admin_", - "type": "address" - }, - { - "internalType": "bytes", - "name": "_data", - "type": "bytes" - } - ], - "stateMutability": "payable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "previousAdmin", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "newAdmin", - "type": "address" - } - ], - "name": "AdminChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "beacon", - "type": "address" - } - ], - "name": "BeaconUpgraded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "implementation", - "type": "address" - } - ], - "name": "Upgraded", - "type": "event" - }, - { - "stateMutability": "payable", - "type": "fallback" - }, - { - "inputs": [], - "name": "admin", - "outputs": [ - { - "internalType": "address", - "name": "admin_", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newAdmin", - "type": "address" - } - ], - "name": "changeAdmin", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "implementation", - "outputs": [ - { - "internalType": "address", - "name": "implementation_", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newImplementation", - "type": "address" - } - ], - "name": "upgradeTo", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newImplementation", - "type": "address" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "upgradeToAndCall", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "stateMutability": "payable", - "type": "receive" - } - ], - "transactionHash": "0xe55e0a5434d697f50f45b1b9b5a0367ea0425c493b785ccac06d6b13259ad556", - "receipt": { - "to": null, - "from": "0x66a7fDB96C583c59597de16d8b2B989231415339", - "contractAddress": "0x1960628db367281B1a186dD5B80B5dd6978F016F", - "transactionIndex": 6, - "gasUsed": "690585", - "logsBloom": "0x00000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000002000000000000000000000000000000000000000000000000000000000004000000000000800000000000000000000000000000000000000000000800000000000000000000000000000000000000810000000000000000000000000000000000000000000000000000000000000000200000000020000000000000000000000000000000000400000000000020000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x68bc8890fc3fbb51a894d984a7c9f823f549091d0300d6e2ea1c64a9b2a08329", - "transactionHash": "0xe55e0a5434d697f50f45b1b9b5a0367ea0425c493b785ccac06d6b13259ad556", - "logs": [ - { - "transactionIndex": 6, - "blockNumber": 7681149, - "transactionHash": "0xe55e0a5434d697f50f45b1b9b5a0367ea0425c493b785ccac06d6b13259ad556", - "address": "0x1960628db367281B1a186dD5B80B5dd6978F016F", - "topics": [ - "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x0000000000000000000000007869fd0edcfff8c05600cb71826e59a3ad860938" - ], - "data": "0x", - "logIndex": 4, - "blockHash": "0x68bc8890fc3fbb51a894d984a7c9f823f549091d0300d6e2ea1c64a9b2a08329" - }, - { - "transactionIndex": 6, - "blockNumber": 7681149, - "transactionHash": "0xe55e0a5434d697f50f45b1b9b5a0367ea0425c493b785ccac06d6b13259ad556", - "address": "0x1960628db367281B1a186dD5B80B5dd6978F016F", - "topics": ["0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f"], - "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000085b75de34c7328625b8c394769d98d64c74febca", - "logIndex": 5, - "blockHash": "0x68bc8890fc3fbb51a894d984a7c9f823f549091d0300d6e2ea1c64a9b2a08329" - } - ], - "blockNumber": 7681149, - "cumulativeGasUsed": "9228085", - "status": 1, - "byzantium": true - }, - "args": ["0x7869fd0EdCFff8C05600CB71826e59a3ad860938", "0x85b75DE34c7328625b8c394769D98d64C74fEBCa", "0x"], - "numDeployments": 1, - "solcInputHash": "b6ff42633a62e1bc6c97d8ccad85444b", - "metadata": "{\"compiler\":{\"version\":\"0.8.15+commit.e14f2714\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // 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\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\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 ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\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(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\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 /**\\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 {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x60806040526040516200112838038062001128833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b600080516020620010e1833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b600080516020620010c183398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b6200028c1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e98383604051806060016040528060278152602001620011016027913962000381565b9392505050565b60006200021a600080516020620010c183398151915260001b6200046760201b6200022e1760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd600080516020620010c183398151915260001b6200046760201b6200022e1760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b620002b81760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd600080516020620010e183398151915260001b6200046760201b6200022e1760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610a2980620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b610090366004610895565b610135565b61006b6100a33660046108b0565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b610101366004610895565b610231565b34801561011257600080fd5b506100bd61025e565b6101236102d4565b61013361012e6103ab565b6103b5565b565b61013d6103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481604051806020016040528060008152506000610419565b50565b61017461011b565b6101876103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610419915050565b505050565b6101e661011b565b60006101fd6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103ab565b905090565b61022e61011b565b90565b6102396103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481610444565b60006102686103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103d9565b60606102b183836040518060600160405280602781526020016109cd602791396104a5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6102dc6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102216105cd565b3660008037600080366000845af43d6000803e8080156103d4573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b610422836105f5565b60008251118061042f5750805b156101e65761043e838361028c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61046d6103d9565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161017481610642565b606073ffffffffffffffffffffffffffffffffffffffff84163b61054b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103a2565b6000808573ffffffffffffffffffffffffffffffffffffffff1685604051610573919061095f565b600060405180830381855af49150503d80600081146105ae576040519150601f19603f3d011682016040523d82523d6000602084013e6105b3565b606091505b50915091506105c382828661074e565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103fd565b6105fe816107a1565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff81166106e5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103a2565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060831561075d5750816102b1565b82511561076d5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a2919061097b565b73ffffffffffffffffffffffffffffffffffffffff81163b610845576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103a2565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610708565b803573ffffffffffffffffffffffffffffffffffffffff8116811461089057600080fd5b919050565b6000602082840312156108a757600080fd5b6102b18261086c565b6000806000604084860312156108c557600080fd5b6108ce8461086c565b9250602084013567ffffffffffffffff808211156108eb57600080fd5b818601915086601f8301126108ff57600080fd5b81358181111561090e57600080fd5b87602082850101111561092057600080fd5b6020830194508093505050509250925092565b60005b8381101561094e578181015183820152602001610936565b8381111561043e5750506000910152565b60008251610971818460208701610933565b9190910192915050565b602081526000825180602084015261099a816040850160208701610933565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a4b930408c511c08d53f1ec84bb13fe259938b06e5d586d6adc4fc27200abe6c64736f6c634300080f0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", - "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b610090366004610895565b610135565b61006b6100a33660046108b0565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b610101366004610895565b610231565b34801561011257600080fd5b506100bd61025e565b6101236102d4565b61013361012e6103ab565b6103b5565b565b61013d6103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481604051806020016040528060008152506000610419565b50565b61017461011b565b6101876103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610419915050565b505050565b6101e661011b565b60006101fd6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103ab565b905090565b61022e61011b565b90565b6102396103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481610444565b60006102686103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103d9565b60606102b183836040518060600160405280602781526020016109cd602791396104a5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6102dc6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102216105cd565b3660008037600080366000845af43d6000803e8080156103d4573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b610422836105f5565b60008251118061042f5750805b156101e65761043e838361028c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61046d6103d9565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161017481610642565b606073ffffffffffffffffffffffffffffffffffffffff84163b61054b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103a2565b6000808573ffffffffffffffffffffffffffffffffffffffff1685604051610573919061095f565b600060405180830381855af49150503d80600081146105ae576040519150601f19603f3d011682016040523d82523d6000602084013e6105b3565b606091505b50915091506105c382828661074e565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103fd565b6105fe816107a1565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff81166106e5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103a2565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060831561075d5750816102b1565b82511561076d5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a2919061097b565b73ffffffffffffffffffffffffffffffffffffffff81163b610845576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103a2565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610708565b803573ffffffffffffffffffffffffffffffffffffffff8116811461089057600080fd5b919050565b6000602082840312156108a757600080fd5b6102b18261086c565b6000806000604084860312156108c557600080fd5b6108ce8461086c565b9250602084013567ffffffffffffffff808211156108eb57600080fd5b818601915086601f8301126108ff57600080fd5b81358181111561090e57600080fd5b87602082850101111561092057600080fd5b6020830194508093505050509250925092565b60005b8381101561094e578181015183820152602001610936565b8381111561043e5750506000910152565b60008251610971818460208701610933565b9190910192915050565b602081526000825180602084015261099a816040850160208701610933565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a4b930408c511c08d53f1ec84bb13fe259938b06e5d586d6adc4fc27200abe6c64736f6c634300080f0033", - "devdoc": { - "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", - "kind": "dev", - "methods": { - "admin()": { - "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" - }, - "changeAdmin(address)": { - "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." - }, - "constructor": { - "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." - }, - "implementation()": { - "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" - }, - "upgradeTo(address)": { - "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." - }, - "upgradeToAndCall(address,bytes)": { - "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." - } - }, - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": {}, - "version": 1 - }, - "storageLayout": { - "storage": [], - "types": null - } -} diff --git a/packages/perennial/deployments/goerli/PerennialLens_V01.json b/packages/perennial/deployments/goerli/PerennialLens_V01.json deleted file mode 100644 index 15761e426..000000000 --- a/packages/perennial/deployments/goerli/PerennialLens_V01.json +++ /dev/null @@ -1,2259 +0,0 @@ -{ - "address": "0x0007022265705459637082D672B2DfDa7835D7ac", - "abi": [ - { - "inputs": [ - { - "internalType": "contract IController", - "name": "_controller", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "uint256[]", - "name": "versions", - "type": "uint256[]" - } - ], - "name": "atVersions", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "version", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - }, - { - "internalType": "Fixed18", - "name": "price", - "type": "int256" - } - ], - "internalType": "struct IOracleProvider.OracleVersion[]", - "name": "prices", - "type": "tuple[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "collateral", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "collateral", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "collateral", - "outputs": [ - { - "internalType": "contract ICollateral", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "controller", - "outputs": [ - { - "internalType": "contract IController", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "dailyRate", - "outputs": [ - { - "internalType": "Fixed18", - "name": "", - "type": "int256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "exposure", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "fees", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "fees", - "outputs": [ - { - "internalType": "UFixed18", - "name": "protocolFees", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "productFees", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "globalPosition", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "oracleVersion", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "openPosition", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "closePosition", - "type": "tuple" - } - ], - "internalType": "struct PrePosition", - "name": "", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "info", - "outputs": [ - { - "components": [ - { - "internalType": "string", - "name": "name", - "type": "string" - }, - { - "internalType": "string", - "name": "symbol", - "type": "string" - }, - { - "components": [ - { - "internalType": "enum PayoffDefinitionLib.PayoffType", - "name": "payoffType", - "type": "uint8" - }, - { - "internalType": "enum PayoffDefinitionLib.PayoffDirection", - "name": "payoffDirection", - "type": "uint8" - }, - { - "internalType": "bytes30", - "name": "data", - "type": "bytes30" - } - ], - "internalType": "struct PayoffDefinition", - "name": "payoffDefinition", - "type": "tuple" - }, - { - "internalType": "contract IOracleProvider", - "name": "oracle", - "type": "address" - }, - { - "internalType": "UFixed18", - "name": "maintenance", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "fundingFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "makerFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "takerFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "makerLimit", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "PackedFixed18", - "name": "minRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "maxRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "targetRate", - "type": "int128" - }, - { - "internalType": "PackedUFixed18", - "name": "targetUtilization", - "type": "uint128" - } - ], - "internalType": "struct JumpRateUtilizationCurve", - "name": "utilizationCurve", - "type": "tuple" - } - ], - "internalType": "struct IProduct.ProductInfo", - "name": "_info", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "latestVersion", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "version", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - }, - { - "internalType": "Fixed18", - "name": "price", - "type": "int256" - } - ], - "internalType": "struct IOracleProvider.OracleVersion", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "liquidatable", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "liquidating", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "maintenance", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "UFixed18", - "name": "positionSize", - "type": "uint256" - } - ], - "name": "maintenanceRequired", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "openInterest", - "outputs": [ - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "openInterest", - "outputs": [ - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "position", - "outputs": [ - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "position", - "outputs": [ - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "pre", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "oracleVersion", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "openPosition", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "closePosition", - "type": "tuple" - } - ], - "internalType": "struct PrePosition", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "pre", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "oracleVersion", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "openPosition", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "closePosition", - "type": "tuple" - } - ], - "internalType": "struct PrePosition", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "rate", - "outputs": [ - { - "internalType": "Fixed18", - "name": "", - "type": "int256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "shortfall", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "snapshot", - "outputs": [ - { - "components": [ - { - "internalType": "address", - "name": "productAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "userAddress", - "type": "address" - }, - { - "internalType": "UFixed18", - "name": "collateral", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "maintenance", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "uint256", - "name": "oracleVersion", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "openPosition", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "closePosition", - "type": "tuple" - } - ], - "internalType": "struct PrePosition", - "name": "pre", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "position", - "type": "tuple" - }, - { - "internalType": "bool", - "name": "liquidatable", - "type": "bool" - }, - { - "internalType": "bool", - "name": "liquidating", - "type": "bool" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "openInterest", - "type": "tuple" - }, - { - "internalType": "UFixed18", - "name": "fees", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "exposure", - "type": "uint256" - } - ], - "internalType": "struct IPerennialLens.UserProductSnapshot", - "name": "_snapshot", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "snapshot", - "outputs": [ - { - "components": [ - { - "components": [ - { - "internalType": "string", - "name": "name", - "type": "string" - }, - { - "internalType": "string", - "name": "symbol", - "type": "string" - }, - { - "components": [ - { - "internalType": "enum PayoffDefinitionLib.PayoffType", - "name": "payoffType", - "type": "uint8" - }, - { - "internalType": "enum PayoffDefinitionLib.PayoffDirection", - "name": "payoffDirection", - "type": "uint8" - }, - { - "internalType": "bytes30", - "name": "data", - "type": "bytes30" - } - ], - "internalType": "struct PayoffDefinition", - "name": "payoffDefinition", - "type": "tuple" - }, - { - "internalType": "contract IOracleProvider", - "name": "oracle", - "type": "address" - }, - { - "internalType": "UFixed18", - "name": "maintenance", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "fundingFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "makerFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "takerFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "makerLimit", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "PackedFixed18", - "name": "minRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "maxRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "targetRate", - "type": "int128" - }, - { - "internalType": "PackedUFixed18", - "name": "targetUtilization", - "type": "uint128" - } - ], - "internalType": "struct JumpRateUtilizationCurve", - "name": "utilizationCurve", - "type": "tuple" - } - ], - "internalType": "struct IProduct.ProductInfo", - "name": "productInfo", - "type": "tuple" - }, - { - "internalType": "address", - "name": "productAddress", - "type": "address" - }, - { - "internalType": "Fixed18", - "name": "rate", - "type": "int256" - }, - { - "internalType": "Fixed18", - "name": "dailyRate", - "type": "int256" - }, - { - "components": [ - { - "internalType": "uint256", - "name": "version", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - }, - { - "internalType": "Fixed18", - "name": "price", - "type": "int256" - } - ], - "internalType": "struct IOracleProvider.OracleVersion", - "name": "latestVersion", - "type": "tuple" - }, - { - "internalType": "UFixed18", - "name": "maintenance", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "collateral", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "shortfall", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "uint256", - "name": "oracleVersion", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "openPosition", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "closePosition", - "type": "tuple" - } - ], - "internalType": "struct PrePosition", - "name": "pre", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "position", - "type": "tuple" - }, - { - "internalType": "UFixed18", - "name": "productFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "protocolFee", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "openInterest", - "type": "tuple" - } - ], - "internalType": "struct IPerennialLens.ProductSnapshot", - "name": "_snapshot", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct[]", - "name": "productAddresses", - "type": "address[]" - } - ], - "name": "snapshots", - "outputs": [ - { - "components": [ - { - "internalType": "address", - "name": "productAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "userAddress", - "type": "address" - }, - { - "internalType": "UFixed18", - "name": "collateral", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "maintenance", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "uint256", - "name": "oracleVersion", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "openPosition", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "closePosition", - "type": "tuple" - } - ], - "internalType": "struct PrePosition", - "name": "pre", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "position", - "type": "tuple" - }, - { - "internalType": "bool", - "name": "liquidatable", - "type": "bool" - }, - { - "internalType": "bool", - "name": "liquidating", - "type": "bool" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "openInterest", - "type": "tuple" - }, - { - "internalType": "UFixed18", - "name": "fees", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "exposure", - "type": "uint256" - } - ], - "internalType": "struct IPerennialLens.UserProductSnapshot[]", - "name": "_snapshots", - "type": "tuple[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct[]", - "name": "productAddresses", - "type": "address[]" - } - ], - "name": "snapshots", - "outputs": [ - { - "components": [ - { - "components": [ - { - "internalType": "string", - "name": "name", - "type": "string" - }, - { - "internalType": "string", - "name": "symbol", - "type": "string" - }, - { - "components": [ - { - "internalType": "enum PayoffDefinitionLib.PayoffType", - "name": "payoffType", - "type": "uint8" - }, - { - "internalType": "enum PayoffDefinitionLib.PayoffDirection", - "name": "payoffDirection", - "type": "uint8" - }, - { - "internalType": "bytes30", - "name": "data", - "type": "bytes30" - } - ], - "internalType": "struct PayoffDefinition", - "name": "payoffDefinition", - "type": "tuple" - }, - { - "internalType": "contract IOracleProvider", - "name": "oracle", - "type": "address" - }, - { - "internalType": "UFixed18", - "name": "maintenance", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "fundingFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "makerFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "takerFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "makerLimit", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "PackedFixed18", - "name": "minRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "maxRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "targetRate", - "type": "int128" - }, - { - "internalType": "PackedUFixed18", - "name": "targetUtilization", - "type": "uint128" - } - ], - "internalType": "struct JumpRateUtilizationCurve", - "name": "utilizationCurve", - "type": "tuple" - } - ], - "internalType": "struct IProduct.ProductInfo", - "name": "productInfo", - "type": "tuple" - }, - { - "internalType": "address", - "name": "productAddress", - "type": "address" - }, - { - "internalType": "Fixed18", - "name": "rate", - "type": "int256" - }, - { - "internalType": "Fixed18", - "name": "dailyRate", - "type": "int256" - }, - { - "components": [ - { - "internalType": "uint256", - "name": "version", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - }, - { - "internalType": "Fixed18", - "name": "price", - "type": "int256" - } - ], - "internalType": "struct IOracleProvider.OracleVersion", - "name": "latestVersion", - "type": "tuple" - }, - { - "internalType": "UFixed18", - "name": "maintenance", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "collateral", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "shortfall", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "uint256", - "name": "oracleVersion", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "openPosition", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "closePosition", - "type": "tuple" - } - ], - "internalType": "struct PrePosition", - "name": "pre", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "position", - "type": "tuple" - }, - { - "internalType": "UFixed18", - "name": "productFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "protocolFee", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "openInterest", - "type": "tuple" - } - ], - "internalType": "struct IPerennialLens.ProductSnapshot[]", - "name": "_snapshots", - "type": "tuple[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "unclaimedIncentiveRewards", - "outputs": [ - { - "internalType": "Token18[]", - "name": "tokens", - "type": "address[]" - }, - { - "internalType": "UFixed18[]", - "name": "amounts", - "type": "uint256[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "uint256[]", - "name": "programIds", - "type": "uint256[]" - } - ], - "name": "unclaimedIncentiveRewards", - "outputs": [ - { - "internalType": "Token18[]", - "name": "tokens", - "type": "address[]" - }, - { - "internalType": "UFixed18[]", - "name": "amounts", - "type": "uint256[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "userPosition", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "oracleVersion", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "openPosition", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "closePosition", - "type": "tuple" - } - ], - "internalType": "struct PrePosition", - "name": "", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "function" - } - ], - "transactionHash": "0x9d9adb8f7ad2ad046862a5ffff2f8c640d8993aec22fa109ba62f41a8059c38b", - "receipt": { - "to": null, - "from": "0x66a7fDB96C583c59597de16d8b2B989231415339", - "contractAddress": "0x0007022265705459637082D672B2DfDa7835D7ac", - "transactionIndex": 18, - "gasUsed": "3957334", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xcef53154022e9a5f6b8ec610dc17f38cb4778d4069cc72a156d69c61532621ed", - "transactionHash": "0x9d9adb8f7ad2ad046862a5ffff2f8c640d8993aec22fa109ba62f41a8059c38b", - "logs": [], - "blockNumber": 7681163, - "cumulativeGasUsed": "18766925", - "status": 1, - "byzantium": true - }, - "args": ["0x7c4ABBF7CB0C0BcB72917734B068Ed4D1AcdF8C5"], - "numDeployments": 1, - "solcInputHash": "b6ff42633a62e1bc6c97d8ccad85444b", - "metadata": "{\"compiler\":{\"version\":\"0.8.15+commit.e14f2714\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract IController\",\"name\":\"_controller\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"versions\",\"type\":\"uint256[]\"}],\"name\":\"atVersions\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"},{\"internalType\":\"Fixed18\",\"name\":\"price\",\"type\":\"int256\"}],\"internalType\":\"struct IOracleProvider.OracleVersion[]\",\"name\":\"prices\",\"type\":\"tuple[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"collateral\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"collateral\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"collateral\",\"outputs\":[{\"internalType\":\"contract ICollateral\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"controller\",\"outputs\":[{\"internalType\":\"contract IController\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"dailyRate\",\"outputs\":[{\"internalType\":\"Fixed18\",\"name\":\"\",\"type\":\"int256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"exposure\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"fees\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"fees\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"protocolFees\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"productFees\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"globalPosition\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"oracleVersion\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"openPosition\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"closePosition\",\"type\":\"tuple\"}],\"internalType\":\"struct PrePosition\",\"name\":\"\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"info\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"},{\"components\":[{\"internalType\":\"enum PayoffDefinitionLib.PayoffType\",\"name\":\"payoffType\",\"type\":\"uint8\"},{\"internalType\":\"enum PayoffDefinitionLib.PayoffDirection\",\"name\":\"payoffDirection\",\"type\":\"uint8\"},{\"internalType\":\"bytes30\",\"name\":\"data\",\"type\":\"bytes30\"}],\"internalType\":\"struct PayoffDefinition\",\"name\":\"payoffDefinition\",\"type\":\"tuple\"},{\"internalType\":\"contract IOracleProvider\",\"name\":\"oracle\",\"type\":\"address\"},{\"internalType\":\"UFixed18\",\"name\":\"maintenance\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"fundingFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"makerFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"takerFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"makerLimit\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"PackedFixed18\",\"name\":\"minRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"maxRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"targetRate\",\"type\":\"int128\"},{\"internalType\":\"PackedUFixed18\",\"name\":\"targetUtilization\",\"type\":\"uint128\"}],\"internalType\":\"struct JumpRateUtilizationCurve\",\"name\":\"utilizationCurve\",\"type\":\"tuple\"}],\"internalType\":\"struct IProduct.ProductInfo\",\"name\":\"_info\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"latestVersion\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"},{\"internalType\":\"Fixed18\",\"name\":\"price\",\"type\":\"int256\"}],\"internalType\":\"struct IOracleProvider.OracleVersion\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"liquidatable\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"liquidating\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"maintenance\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"UFixed18\",\"name\":\"positionSize\",\"type\":\"uint256\"}],\"name\":\"maintenanceRequired\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"openInterest\",\"outputs\":[{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"openInterest\",\"outputs\":[{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"position\",\"outputs\":[{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"position\",\"outputs\":[{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"pre\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"oracleVersion\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"openPosition\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"closePosition\",\"type\":\"tuple\"}],\"internalType\":\"struct PrePosition\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"pre\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"oracleVersion\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"openPosition\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"closePosition\",\"type\":\"tuple\"}],\"internalType\":\"struct PrePosition\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"rate\",\"outputs\":[{\"internalType\":\"Fixed18\",\"name\":\"\",\"type\":\"int256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"shortfall\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"snapshot\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"productAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"},{\"internalType\":\"UFixed18\",\"name\":\"collateral\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"maintenance\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"oracleVersion\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"openPosition\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"closePosition\",\"type\":\"tuple\"}],\"internalType\":\"struct PrePosition\",\"name\":\"pre\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"position\",\"type\":\"tuple\"},{\"internalType\":\"bool\",\"name\":\"liquidatable\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"liquidating\",\"type\":\"bool\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"openInterest\",\"type\":\"tuple\"},{\"internalType\":\"UFixed18\",\"name\":\"fees\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"exposure\",\"type\":\"uint256\"}],\"internalType\":\"struct IPerennialLens.UserProductSnapshot\",\"name\":\"_snapshot\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"snapshot\",\"outputs\":[{\"components\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"},{\"components\":[{\"internalType\":\"enum PayoffDefinitionLib.PayoffType\",\"name\":\"payoffType\",\"type\":\"uint8\"},{\"internalType\":\"enum PayoffDefinitionLib.PayoffDirection\",\"name\":\"payoffDirection\",\"type\":\"uint8\"},{\"internalType\":\"bytes30\",\"name\":\"data\",\"type\":\"bytes30\"}],\"internalType\":\"struct PayoffDefinition\",\"name\":\"payoffDefinition\",\"type\":\"tuple\"},{\"internalType\":\"contract IOracleProvider\",\"name\":\"oracle\",\"type\":\"address\"},{\"internalType\":\"UFixed18\",\"name\":\"maintenance\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"fundingFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"makerFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"takerFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"makerLimit\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"PackedFixed18\",\"name\":\"minRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"maxRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"targetRate\",\"type\":\"int128\"},{\"internalType\":\"PackedUFixed18\",\"name\":\"targetUtilization\",\"type\":\"uint128\"}],\"internalType\":\"struct JumpRateUtilizationCurve\",\"name\":\"utilizationCurve\",\"type\":\"tuple\"}],\"internalType\":\"struct IProduct.ProductInfo\",\"name\":\"productInfo\",\"type\":\"tuple\"},{\"internalType\":\"address\",\"name\":\"productAddress\",\"type\":\"address\"},{\"internalType\":\"Fixed18\",\"name\":\"rate\",\"type\":\"int256\"},{\"internalType\":\"Fixed18\",\"name\":\"dailyRate\",\"type\":\"int256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"},{\"internalType\":\"Fixed18\",\"name\":\"price\",\"type\":\"int256\"}],\"internalType\":\"struct IOracleProvider.OracleVersion\",\"name\":\"latestVersion\",\"type\":\"tuple\"},{\"internalType\":\"UFixed18\",\"name\":\"maintenance\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"collateral\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"shortfall\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"oracleVersion\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"openPosition\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"closePosition\",\"type\":\"tuple\"}],\"internalType\":\"struct PrePosition\",\"name\":\"pre\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"position\",\"type\":\"tuple\"},{\"internalType\":\"UFixed18\",\"name\":\"productFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"protocolFee\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"openInterest\",\"type\":\"tuple\"}],\"internalType\":\"struct IPerennialLens.ProductSnapshot\",\"name\":\"_snapshot\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct[]\",\"name\":\"productAddresses\",\"type\":\"address[]\"}],\"name\":\"snapshots\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"productAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"},{\"internalType\":\"UFixed18\",\"name\":\"collateral\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"maintenance\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"oracleVersion\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"openPosition\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"closePosition\",\"type\":\"tuple\"}],\"internalType\":\"struct PrePosition\",\"name\":\"pre\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"position\",\"type\":\"tuple\"},{\"internalType\":\"bool\",\"name\":\"liquidatable\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"liquidating\",\"type\":\"bool\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"openInterest\",\"type\":\"tuple\"},{\"internalType\":\"UFixed18\",\"name\":\"fees\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"exposure\",\"type\":\"uint256\"}],\"internalType\":\"struct IPerennialLens.UserProductSnapshot[]\",\"name\":\"_snapshots\",\"type\":\"tuple[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct[]\",\"name\":\"productAddresses\",\"type\":\"address[]\"}],\"name\":\"snapshots\",\"outputs\":[{\"components\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"},{\"components\":[{\"internalType\":\"enum PayoffDefinitionLib.PayoffType\",\"name\":\"payoffType\",\"type\":\"uint8\"},{\"internalType\":\"enum PayoffDefinitionLib.PayoffDirection\",\"name\":\"payoffDirection\",\"type\":\"uint8\"},{\"internalType\":\"bytes30\",\"name\":\"data\",\"type\":\"bytes30\"}],\"internalType\":\"struct PayoffDefinition\",\"name\":\"payoffDefinition\",\"type\":\"tuple\"},{\"internalType\":\"contract IOracleProvider\",\"name\":\"oracle\",\"type\":\"address\"},{\"internalType\":\"UFixed18\",\"name\":\"maintenance\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"fundingFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"makerFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"takerFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"makerLimit\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"PackedFixed18\",\"name\":\"minRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"maxRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"targetRate\",\"type\":\"int128\"},{\"internalType\":\"PackedUFixed18\",\"name\":\"targetUtilization\",\"type\":\"uint128\"}],\"internalType\":\"struct JumpRateUtilizationCurve\",\"name\":\"utilizationCurve\",\"type\":\"tuple\"}],\"internalType\":\"struct IProduct.ProductInfo\",\"name\":\"productInfo\",\"type\":\"tuple\"},{\"internalType\":\"address\",\"name\":\"productAddress\",\"type\":\"address\"},{\"internalType\":\"Fixed18\",\"name\":\"rate\",\"type\":\"int256\"},{\"internalType\":\"Fixed18\",\"name\":\"dailyRate\",\"type\":\"int256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"},{\"internalType\":\"Fixed18\",\"name\":\"price\",\"type\":\"int256\"}],\"internalType\":\"struct IOracleProvider.OracleVersion\",\"name\":\"latestVersion\",\"type\":\"tuple\"},{\"internalType\":\"UFixed18\",\"name\":\"maintenance\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"collateral\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"shortfall\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"oracleVersion\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"openPosition\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"closePosition\",\"type\":\"tuple\"}],\"internalType\":\"struct PrePosition\",\"name\":\"pre\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"position\",\"type\":\"tuple\"},{\"internalType\":\"UFixed18\",\"name\":\"productFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"protocolFee\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"openInterest\",\"type\":\"tuple\"}],\"internalType\":\"struct IPerennialLens.ProductSnapshot[]\",\"name\":\"_snapshots\",\"type\":\"tuple[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"unclaimedIncentiveRewards\",\"outputs\":[{\"internalType\":\"Token18[]\",\"name\":\"tokens\",\"type\":\"address[]\"},{\"internalType\":\"UFixed18[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"programIds\",\"type\":\"uint256[]\"}],\"name\":\"unclaimedIncentiveRewards\",\"outputs\":[{\"internalType\":\"Token18[]\",\"name\":\"tokens\",\"type\":\"address[]\"},{\"internalType\":\"UFixed18[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"userPosition\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"oracleVersion\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"openPosition\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"closePosition\",\"type\":\"tuple\"}],\"internalType\":\"struct PrePosition\",\"name\":\"\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"atVersions(address,uint256[])\":{\"params\":{\"product\":\"Product address\",\"versions\":\"Oracle versions to query\"},\"returns\":{\"prices\":\"Product prices at specified versions\"}},\"collateral()\":{\"returns\":{\"_0\":\"Protocol collateral address\"}},\"collateral(address)\":{\"params\":{\"product\":\"Product address\"},\"returns\":{\"_0\":\"Total collateral for product\"}},\"collateral(address,address)\":{\"params\":{\"account\":\"Account address\",\"product\":\"Product address\"},\"returns\":{\"_0\":\"User deposited collateral for product\"}},\"constructor\":{\"params\":{\"_controller\":\"Protocol controller address\"}},\"dailyRate(address)\":{\"params\":{\"product\":\"Product address\"},\"returns\":{\"_0\":\"Product current funding extrapolated to a daily rate\"}},\"exposure(address,address)\":{\"params\":{\"account\":\"Account address\",\"product\":\"Product address\"},\"returns\":{\"_0\":\"User's exposure (openInterest * utilization) after settle\"}},\"fees(address)\":{\"params\":{\"product\":\"Product address\"},\"returns\":{\"productFees\":\"fees accrued by the product owner\",\"protocolFees\":\"fees accrued by the protocol\"}},\"fees(address,address)\":{\"params\":{\"account\":\"Account address\",\"product\":\"Product address\"},\"returns\":{\"_0\":\"sum of all fees accrued by the account\"}},\"globalPosition(address)\":{\"params\":{\"product\":\"Product address\"},\"returns\":{\"_0\":\"Product pre-position\",\"_1\":\"Product position\"}},\"info(address)\":{\"params\":{\"product\":\"Product address\"},\"returns\":{\"_info\":\"of the product\"}},\"latestVersion(address)\":{\"params\":{\"product\":\"Product address\"},\"returns\":{\"_0\":\"Product latest price\"}},\"liquidatable(address,address)\":{\"params\":{\"account\":\"Account address\",\"product\":\"Product address\"},\"returns\":{\"_0\":\"Whether or not the user's position eligible to be liquidated\"}},\"liquidating(address,address)\":{\"params\":{\"account\":\"Account address\",\"product\":\"Product address\"},\"returns\":{\"_0\":\"Whether or not the user's position is being liquidated\"}},\"maintenance(address,address)\":{\"params\":{\"account\":\"Account address\",\"product\":\"Product address\"},\"returns\":{\"_0\":\"Maximum of user maintenance, and maintenanceNext\"}},\"maintenanceRequired(address,address,uint256)\":{\"params\":{\"account\":\"Account address\",\"positionSize\":\"size of position for maintenance calculation\",\"product\":\"Product address\"},\"returns\":{\"_0\":\"Maintenance required for position in product\"}},\"name(address)\":{\"params\":{\"product\":\"Product address\"},\"returns\":{\"_0\":\"Name of the product\"}},\"openInterest(address)\":{\"params\":{\"product\":\"Product address\"},\"returns\":{\"_0\":\"Product maker and taker position multiplied by latest price after settle\"}},\"openInterest(address,address)\":{\"params\":{\"account\":\"Account address\",\"product\":\"Product address\"},\"returns\":{\"_0\":\"User's maker or taker position multiplied by latest price after settle\"}},\"position(address)\":{\"params\":{\"product\":\"Product address\"},\"returns\":{\"_0\":\"product position\"}},\"position(address,address)\":{\"params\":{\"account\":\"Account address\",\"product\":\"Product address\"},\"returns\":{\"_0\":\"User position\"}},\"pre(address)\":{\"params\":{\"product\":\"Product address\"},\"returns\":{\"_0\":\"Product pre-position\"}},\"pre(address,address)\":{\"params\":{\"account\":\"Account address\",\"product\":\"Product address\"},\"returns\":{\"_0\":\"User pre-position\"}},\"rate(address)\":{\"params\":{\"product\":\"Product address\"},\"returns\":{\"_0\":\"Product current funding rate\"}},\"shortfall(address)\":{\"params\":{\"product\":\"Product address\"},\"returns\":{\"_0\":\"Total shortfall for product\"}},\"snapshot(address)\":{\"params\":{\"product\":\"Product address\"},\"returns\":{\"_snapshot\":\"for the product after settle\"}},\"snapshot(address,address)\":{\"params\":{\"account\":\"User addresses\",\"product\":\"Product address\"},\"returns\":{\"_snapshot\":\"UserSnapshot for the product after settle\"}},\"snapshots(address,address[])\":{\"params\":{\"account\":\"User addresses\",\"productAddresses\":\"Product addresses\"},\"returns\":{\"_snapshots\":\"UserSnapshot for each product after settle\"}},\"snapshots(address[])\":{\"params\":{\"productAddresses\":\"Product addresses\"},\"returns\":{\"_snapshots\":\"a snapshot for each product after settle\"}},\"symbol(address)\":{\"params\":{\"product\":\"Product address\"},\"returns\":{\"_0\":\"Symbol of the product\"}},\"unclaimedIncentiveRewards(address,address)\":{\"params\":{\"account\":\"Account address\",\"product\":\"Product address\"},\"returns\":{\"amounts\":\"Token amounts of unclaimed incentive rewards for given product\",\"tokens\":\"Token addresses of unclaimed incentive rewards for given product\"}},\"unclaimedIncentiveRewards(address,address,uint256[])\":{\"params\":{\"account\":\"Account address\",\"product\":\"Product address\",\"programIds\":\"Program IDs to query\"},\"returns\":{\"amounts\":\"Token amounts of unclaimed incentive rewards for given program IDs\",\"tokens\":\"Token addresses of unclaimed incentive rewards for given program IDs\"}},\"userPosition(address,address)\":{\"params\":{\"account\":\"Account address\",\"product\":\"Product address\"},\"returns\":{\"_0\":\"User pre-position\",\"_1\":\"User position\"}}},\"stateVariables\":{\"controller\":{\"return\":\"Protocol controller\",\"returns\":{\"_0\":\"Protocol controller\"}}},\"title\":\"Lens contract to conveniently pull protocol data\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"atVersions(address,uint256[])\":{\"notice\":\"Prices of product at specified versions after settle\"},\"collateral()\":{\"notice\":\"Protocol collateral address\"},\"collateral(address)\":{\"notice\":\"Product total collateral amount after settle\"},\"collateral(address,address)\":{\"notice\":\"User collateral amount for product after settle\"},\"controller()\":{\"notice\":\"Protocol controller\"},\"dailyRate(address)\":{\"notice\":\"Product funding extrapolated to a daily rate after settle\"},\"exposure(address,address)\":{\"notice\":\"User's exposure in product after settle\"},\"fees(address)\":{\"notice\":\"Fees accumulated by product and protocol treasuries after settle\"},\"fees(address,address)\":{\"notice\":\"Fees accumulated by account after settle\"},\"globalPosition(address)\":{\"notice\":\"Product pre-position and position after settle\"},\"info(address)\":{\"notice\":\"Returns the info of the provided `product`\"},\"latestVersion(address)\":{\"notice\":\"Current price of product after settle\"},\"liquidatable(address,address)\":{\"notice\":\"User liquidatble status for product after settle\"},\"liquidating(address,address)\":{\"notice\":\"User liquidating status for product after settle\"},\"maintenance(address,address)\":{\"notice\":\"User maintenance amount for product after settle\"},\"maintenanceRequired(address,address,uint256)\":{\"notice\":\"User's maintenance required for position size in product after settle\"},\"name(address)\":{\"notice\":\"Returns the name of the provided `product`\"},\"openInterest(address)\":{\"notice\":\"Product total open interest after settle\"},\"openInterest(address,address)\":{\"notice\":\"User's open interest in product after settle\"},\"position(address)\":{\"notice\":\"Product position after settle\"},\"position(address,address)\":{\"notice\":\"User position for product after settle\"},\"pre(address)\":{\"notice\":\"Product pre position after settle\"},\"pre(address,address)\":{\"notice\":\"User pre position for product after settle\"},\"rate(address)\":{\"notice\":\"Product funding rate after settle\"},\"shortfall(address)\":{\"notice\":\"Product total shortfall amount after settle\"},\"snapshot(address)\":{\"notice\":\"Returns the snapshot of the provided `product`\"},\"snapshot(address,address)\":{\"notice\":\"Returns the user snapshot for the provided `product`\"},\"snapshots(address,address[])\":{\"notice\":\"Returns the user snapshots for the provided `productAddresses`\"},\"snapshots(address[])\":{\"notice\":\"Returns the snapshots of the provided `productAddresses`\"},\"symbol(address)\":{\"notice\":\"Returns the symbol of the provided `product`\"},\"unclaimedIncentiveRewards(address,address)\":{\"notice\":\"User's unclaimed rewards for all programs for product after settle\"},\"unclaimedIncentiveRewards(address,address,uint256[])\":{\"notice\":\"User's unclaimed rewards for provided programs for product after settle\"},\"userPosition(address,address)\":{\"notice\":\"User pre-position and position for product after settle\"}},\"notice\":\"All functions should be called using `callStatic`\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/lens/PerennialLens.sol\":\"PerennialLens\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\n\\ninterface IOracleProvider {\\n /// @dev A singular oracle version with its corresponding data\\n struct OracleVersion {\\n /// @dev The iterative version\\n uint256 version;\\n\\n /// @dev the timestamp of the oracle update\\n uint256 timestamp;\\n\\n /// @dev The oracle price of the corresponding version\\n Fixed18 price;\\n }\\n\\n function sync() external returns (OracleVersion memory);\\n function currentVersion() external view returns (OracleVersion memory);\\n function atVersion(uint256 oracleVersion) external view returns (OracleVersion memory);\\n}\\n\",\"keccak256\":\"0xde0f20d468ba8b91addfc356e13f2c74a4dc8abe68be323942217c723775d9c1\",\"license\":\"Apache-2.0\"},\"@equilibria/root/curve/CurveMath.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"../number/types/UFixed18.sol\\\";\\nimport \\\"../number/types/Fixed18.sol\\\";\\n\\n/**\\n * @title CurveMath\\n * @notice Library for managing math operations for utilization curves.\\n */\\nlibrary CurveMath {\\n error CurveMathOutOfBoundsError();\\n\\n /**\\n * @notice Computes a linear interpolation between two points\\n * @param startX First point's x-coordinate\\n * @param startY First point's y-coordinate\\n * @param endX Second point's x-coordinate\\n * @param endY Second point's y-coordinate\\n * @param targetX x-coordinate to interpolate\\n * @return y-coordinate for `targetX` along the line from (`startX`, `startY`) -> (`endX`, `endY`)\\n */\\n function linearInterpolation(\\n UFixed18 startX,\\n Fixed18 startY,\\n UFixed18 endX,\\n Fixed18 endY,\\n UFixed18 targetX\\n ) internal pure returns (Fixed18) {\\n if (targetX.lt(startX) || targetX.gt(endX)) revert CurveMathOutOfBoundsError();\\n\\n UFixed18 xRange = endX.sub(startX);\\n Fixed18 yRange = endY.sub(startY);\\n UFixed18 xRatio = targetX.sub(startX).div(xRange);\\n return yRange.mul(Fixed18Lib.from(xRatio)).add(startY);\\n }\\n}\\n\",\"keccak256\":\"0x60d159f9ddf0dbe81124ecad58bba734b4cf82877637ff8d9d7f3e92f2da4ded\",\"license\":\"Apache-2.0\"},\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"../CurveMath.sol\\\";\\nimport \\\"../../number/types/PackedUFixed18.sol\\\";\\nimport \\\"../../number/types/PackedFixed18.sol\\\";\\n\\n/// @dev JumpRateUtilizationCurve type\\nstruct JumpRateUtilizationCurve {\\n PackedFixed18 minRate;\\n PackedFixed18 maxRate;\\n PackedFixed18 targetRate;\\n PackedUFixed18 targetUtilization;\\n}\\nusing JumpRateUtilizationCurveLib for JumpRateUtilizationCurve global;\\ntype JumpRateUtilizationCurveStorage is bytes32;\\nusing JumpRateUtilizationCurveStorageLib for JumpRateUtilizationCurveStorage global;\\n\\n/**\\n * @title JumpRateUtilizationCurveLib\\n * @notice Library for the Jump Rate utilization curve type\\n */\\nlibrary JumpRateUtilizationCurveLib {\\n /**\\n * @notice Computes the corresponding rate for a utilization ratio\\n * @param utilization The utilization ratio\\n * @return The corresponding rate\\n */\\n function compute(JumpRateUtilizationCurve memory self, UFixed18 utilization) internal pure returns (Fixed18) {\\n UFixed18 targetUtilization = self.targetUtilization.unpack();\\n if (utilization.lt(targetUtilization)) {\\n return CurveMath.linearInterpolation(\\n UFixed18Lib.ZERO,\\n self.minRate.unpack(),\\n targetUtilization,\\n self.targetRate.unpack(),\\n utilization\\n );\\n }\\n if (utilization.lt(UFixed18Lib.ONE)) {\\n return CurveMath.linearInterpolation(\\n targetUtilization,\\n self.targetRate.unpack(),\\n UFixed18Lib.ONE,\\n self.maxRate.unpack(),\\n utilization\\n );\\n }\\n return self.maxRate.unpack();\\n }\\n}\\n\\nlibrary JumpRateUtilizationCurveStorageLib {\\n function read(JumpRateUtilizationCurveStorage self) internal view returns (JumpRateUtilizationCurve memory) {\\n return _storagePointer(self);\\n }\\n\\n function store(JumpRateUtilizationCurveStorage self, JumpRateUtilizationCurve memory value) internal {\\n JumpRateUtilizationCurve storage storagePointer = _storagePointer(self);\\n\\n storagePointer.minRate = value.minRate;\\n storagePointer.maxRate = value.maxRate;\\n storagePointer.targetRate = value.targetRate;\\n storagePointer.targetUtilization = value.targetUtilization;\\n }\\n\\n function _storagePointer(JumpRateUtilizationCurveStorage self)\\n private pure returns (JumpRateUtilizationCurve storage pointer) {\\n assembly { pointer.slot := self }\\n }\\n}\",\"keccak256\":\"0xae202813874bc306d51b3dab8194c86f6483bb20bf1f673ddaee16aa8de567ff\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/Fixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SignedMath.sol\\\";\\nimport \\\"./UFixed18.sol\\\";\\nimport \\\"./PackedFixed18.sol\\\";\\n\\n/// @dev Fixed18 type\\ntype Fixed18 is int256;\\nusing Fixed18Lib for Fixed18 global;\\ntype Fixed18Storage is bytes32;\\nusing Fixed18StorageLib for Fixed18Storage global;\\n\\n/**\\n * @title Fixed18Lib\\n * @notice Library for the signed fixed-decimal type.\\n */\\nlibrary Fixed18Lib {\\n error Fixed18OverflowError(uint256 value);\\n error Fixed18PackingOverflowError(int256 value);\\n error Fixed18PackingUnderflowError(int256 value);\\n\\n int256 private constant BASE = 1e18;\\n Fixed18 public constant ZERO = Fixed18.wrap(0);\\n Fixed18 public constant ONE = Fixed18.wrap(BASE);\\n Fixed18 public constant NEG_ONE = Fixed18.wrap(-1 * BASE);\\n Fixed18 public constant MAX = Fixed18.wrap(type(int256).max);\\n Fixed18 public constant MIN = Fixed18.wrap(type(int256).min);\\n\\n /**\\n * @notice Creates a signed fixed-decimal from an unsigned fixed-decimal\\n * @param a Unsigned fixed-decimal\\n * @return New signed fixed-decimal\\n */\\n function from(UFixed18 a) internal pure returns (Fixed18) {\\n uint256 value = UFixed18.unwrap(a);\\n if (value > uint256(type(int256).max)) revert Fixed18OverflowError(value);\\n return Fixed18.wrap(int256(value));\\n }\\n\\n /**\\n * @notice Creates a signed fixed-decimal from a sign and an unsigned fixed-decimal\\n * @param s Sign\\n * @param m Unsigned fixed-decimal magnitude\\n * @return New signed fixed-decimal\\n */\\n function from(int256 s, UFixed18 m) internal pure returns (Fixed18) {\\n if (s > 0) return from(m);\\n if (s < 0) return Fixed18.wrap(-1 * Fixed18.unwrap(from(m)));\\n return ZERO;\\n }\\n\\n /**\\n * @notice Creates a signed fixed-decimal from a signed integer\\n * @param a Signed number\\n * @return New signed fixed-decimal\\n */\\n function from(int256 a) internal pure returns (Fixed18) {\\n return Fixed18.wrap(a * BASE);\\n }\\n\\n /**\\n * @notice Creates a packed signed fixed-decimal from an signed fixed-decimal\\n * @param a signed fixed-decimal\\n * @return New packed signed fixed-decimal\\n */\\n function pack(Fixed18 a) internal pure returns (PackedFixed18) {\\n int256 value = Fixed18.unwrap(a);\\n if (value > type(int128).max) revert Fixed18PackingOverflowError(value);\\n if (value < type(int128).min) revert Fixed18PackingUnderflowError(value);\\n return PackedFixed18.wrap(int128(value));\\n }\\n\\n /**\\n * @notice Returns whether the signed fixed-decimal is equal to zero.\\n * @param a Signed fixed-decimal\\n * @return Whether the signed fixed-decimal is zero.\\n */\\n function isZero(Fixed18 a) internal pure returns (bool) {\\n return Fixed18.unwrap(a) == 0;\\n }\\n\\n /**\\n * @notice Adds two signed fixed-decimals `a` and `b` together\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Resulting summed signed fixed-decimal\\n */\\n function add(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) + Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Subtracts signed fixed-decimal `b` from `a`\\n * @param a Signed fixed-decimal to subtract from\\n * @param b Signed fixed-decimal to subtract\\n * @return Resulting subtracted signed fixed-decimal\\n */\\n function sub(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) - Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Multiplies two signed fixed-decimals `a` and `b` together\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Resulting multiplied signed fixed-decimal\\n */\\n function mul(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / BASE);\\n }\\n\\n /**\\n * @notice Divides signed fixed-decimal `a` by `b`\\n * @param a Signed fixed-decimal to divide\\n * @param b Signed fixed-decimal to divide by\\n * @return Resulting divided signed fixed-decimal\\n */\\n function div(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * BASE / Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0`, `MAX` for `n/0`, and `MIN` for `-n/0`.\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function unsafeDiv(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n if (isZero(b)) {\\n if (gt(a, ZERO)) return MAX;\\n if (lt(a, ZERO)) return MIN;\\n return ONE;\\n } else {\\n return div(a, b);\\n }\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First signed fixed-decimal\\n * @param b Signed number to multiply by\\n * @param c Signed number to divide by\\n * @return Resulting computation\\n */\\n function muldiv(Fixed18 a, int256 b, int256 c) internal pure returns (Fixed18) {\\n return muldiv(a, Fixed18.wrap(b), Fixed18.wrap(c));\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First signed fixed-decimal\\n * @param b Signed fixed-decimal to multiply by\\n * @param c Signed fixed-decimal to divide by\\n * @return Resulting computation\\n */\\n function muldiv(Fixed18 a, Fixed18 b, Fixed18 c) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / Fixed18.unwrap(c));\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is equal to `b`\\n */\\n function eq(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 1;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is greater than `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is greater than `b`\\n */\\n function gt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 2;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is less than `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is less than `b`\\n */\\n function lt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 0;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is greater than or equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is greater than or equal to `b`\\n */\\n function gte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return gt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is less than or equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is less than or equal to `b`\\n */\\n function lte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return lt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Compares the signed fixed-decimals `a` and `b`\\n * @dev Returns: 2 for greater than\\n * 1 for equal to\\n * 0 for less than\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Compare result of `a` and `b`\\n */\\n function compare(Fixed18 a, Fixed18 b) internal pure returns (uint256) {\\n (int256 au, int256 bu) = (Fixed18.unwrap(a), Fixed18.unwrap(b));\\n if (au > bu) return 2;\\n if (au < bu) return 0;\\n return 1;\\n }\\n\\n /**\\n * @notice Returns a signed fixed-decimal representing the ratio of `a` over `b`\\n * @param a First signed number\\n * @param b Second signed number\\n * @return Ratio of `a` over `b`\\n */\\n function ratio(int256 a, int256 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(a * BASE / b);\\n }\\n\\n /**\\n * @notice Returns the minimum of signed fixed-decimals `a` and `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Minimum of `a` and `b`\\n */\\n function min(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(SignedMath.min(Fixed18.unwrap(a), Fixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Returns the maximum of signed fixed-decimals `a` and `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Maximum of `a` and `b`\\n */\\n function max(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(SignedMath.max(Fixed18.unwrap(a), Fixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Converts the signed fixed-decimal into an integer, truncating any decimal portion\\n * @param a Signed fixed-decimal\\n * @return Truncated signed number\\n */\\n function truncate(Fixed18 a) internal pure returns (int256) {\\n return Fixed18.unwrap(a) / BASE;\\n }\\n\\n /**\\n * @notice Returns the sign of the signed fixed-decimal\\n * @dev Returns: -1 for negative\\n * 0 for zero\\n * 1 for positive\\n * @param a Signed fixed-decimal\\n * @return Sign of the signed fixed-decimal\\n */\\n function sign(Fixed18 a) internal pure returns (int256) {\\n if (Fixed18.unwrap(a) > 0) return 1;\\n if (Fixed18.unwrap(a) < 0) return -1;\\n return 0;\\n }\\n\\n /**\\n * @notice Returns the absolute value of the signed fixed-decimal\\n * @param a Signed fixed-decimal\\n * @return Absolute value of the signed fixed-decimal\\n */\\n function abs(Fixed18 a) internal pure returns (UFixed18) {\\n return UFixed18.wrap(SignedMath.abs(Fixed18.unwrap(a)));\\n }\\n}\\n\\nlibrary Fixed18StorageLib {\\n function read(Fixed18Storage self) internal view returns (Fixed18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(Fixed18Storage self, Fixed18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x613587461ef3437ef33229cdda7d34ea746278721baf06e20b2e43977f43174d\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/PackedFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"./Fixed18.sol\\\";\\n\\n/// @dev PackedFixed18 type\\ntype PackedFixed18 is int128;\\nusing PackedFixed18Lib for PackedFixed18 global;\\n\\n/**\\n * @title PackedFixed18Lib\\n * @dev A packed version of the Fixed18 which takes up half the storage space (two PackedFixed18 can be packed\\n * into a single slot). Only valid within the range -1.7014118e+20 <= x <= 1.7014118e+20.\\n * @notice Library for the packed signed fixed-decimal type.\\n */\\nlibrary PackedFixed18Lib {\\n PackedFixed18 public constant MAX = PackedFixed18.wrap(type(int128).max);\\n PackedFixed18 public constant MIN = PackedFixed18.wrap(type(int128).min);\\n\\n /**\\n * @notice Creates an unpacked signed fixed-decimal from a packed signed fixed-decimal\\n * @param self packed signed fixed-decimal\\n * @return New unpacked signed fixed-decimal\\n */\\n function unpack(PackedFixed18 self) internal pure returns (Fixed18) {\\n return Fixed18.wrap(int256(PackedFixed18.unwrap(self)));\\n }\\n}\\n\",\"keccak256\":\"0xb52960cc8e3132e45d342bbbb1c6a96219022cd8557997933bd8250170268b64\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/PackedUFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"./UFixed18.sol\\\";\\n\\n/// @dev PackedUFixed18 type\\ntype PackedUFixed18 is uint128;\\nusing PackedUFixed18Lib for PackedUFixed18 global;\\n\\n/**\\n * @title PackedUFixed18Lib\\n * @dev A packed version of the UFixed18 which takes up half the storage space (two PackedUFixed18 can be packed\\n * into a single slot). Only valid within the range 0 <= x <= 3.4028237e+20.\\n * @notice Library for the packed unsigned fixed-decimal type.\\n */\\nlibrary PackedUFixed18Lib {\\n PackedUFixed18 public constant MAX = PackedUFixed18.wrap(type(uint128).max);\\n\\n /**\\n * @notice Creates an unpacked unsigned fixed-decimal from a packed unsigned fixed-decimal\\n * @param self packed unsigned fixed-decimal\\n * @return New unpacked unsigned fixed-decimal\\n */\\n function unpack(PackedUFixed18 self) internal pure returns (UFixed18) {\\n return UFixed18.wrap(uint256(PackedUFixed18.unwrap(self)));\\n }\\n}\\n\",\"keccak256\":\"0xb5c5cd32d6530b2fe75228b6be32ebcb7762f6d7988b85a6b85a289ce8256d51\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/UFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"./Fixed18.sol\\\";\\nimport \\\"./PackedUFixed18.sol\\\";\\n\\n/// @dev UFixed18 type\\ntype UFixed18 is uint256;\\nusing UFixed18Lib for UFixed18 global;\\ntype UFixed18Storage is bytes32;\\nusing UFixed18StorageLib for UFixed18Storage global;\\n\\n/**\\n * @title UFixed18Lib\\n * @notice Library for the unsigned fixed-decimal type.\\n */\\nlibrary UFixed18Lib {\\n error UFixed18UnderflowError(int256 value);\\n error UFixed18PackingOverflowError(uint256 value);\\n\\n uint256 private constant BASE = 1e18;\\n UFixed18 public constant ZERO = UFixed18.wrap(0);\\n UFixed18 public constant ONE = UFixed18.wrap(BASE);\\n UFixed18 public constant MAX = UFixed18.wrap(type(uint256).max);\\n\\n /**\\n * @notice Creates a unsigned fixed-decimal from a signed fixed-decimal\\n * @param a Signed fixed-decimal\\n * @return New unsigned fixed-decimal\\n */\\n function from(Fixed18 a) internal pure returns (UFixed18) {\\n int256 value = Fixed18.unwrap(a);\\n if (value < 0) revert UFixed18UnderflowError(value);\\n return UFixed18.wrap(uint256(value));\\n }\\n\\n /**\\n * @notice Creates a unsigned fixed-decimal from a unsigned integer\\n * @param a Unsigned number\\n * @return New unsigned fixed-decimal\\n */\\n function from(uint256 a) internal pure returns (UFixed18) {\\n return UFixed18.wrap(a * BASE);\\n }\\n\\n /**\\n * @notice Creates a packed unsigned fixed-decimal from an unsigned fixed-decimal\\n * @param a unsigned fixed-decimal\\n * @return New packed unsigned fixed-decimal\\n */\\n function pack(UFixed18 a) internal pure returns (PackedUFixed18) {\\n uint256 value = UFixed18.unwrap(a);\\n if (value > type(uint128).max) revert UFixed18PackingOverflowError(value);\\n return PackedUFixed18.wrap(uint128(value));\\n }\\n\\n /**\\n * @notice Returns whether the unsigned fixed-decimal is equal to zero.\\n * @param a Unsigned fixed-decimal\\n * @return Whether the unsigned fixed-decimal is zero.\\n */\\n function isZero(UFixed18 a) internal pure returns (bool) {\\n return UFixed18.unwrap(a) == 0;\\n }\\n\\n /**\\n * @notice Adds two unsigned fixed-decimals `a` and `b` together\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Resulting summed unsigned fixed-decimal\\n */\\n function add(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) + UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Subtracts unsigned fixed-decimal `b` from `a`\\n * @param a Unsigned fixed-decimal to subtract from\\n * @param b Unsigned fixed-decimal to subtract\\n * @return Resulting subtracted unsigned fixed-decimal\\n */\\n function sub(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) - UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Multiplies two unsigned fixed-decimals `a` and `b` together\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Resulting multiplied unsigned fixed-decimal\\n */\\n function mul(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / BASE);\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function div(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * BASE / UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0` and `MAX` for `n/0`.\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function unsafeDiv(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n if (isZero(b)) {\\n return isZero(a) ? ONE : MAX;\\n } else {\\n return div(a, b);\\n }\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First unsigned fixed-decimal\\n * @param b Unsigned number to multiply by\\n * @param c Unsigned number to divide by\\n * @return Resulting computation\\n */\\n function muldiv(UFixed18 a, uint256 b, uint256 c) internal pure returns (UFixed18) {\\n return muldiv(a, UFixed18.wrap(b), UFixed18.wrap(c));\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First unsigned fixed-decimal\\n * @param b Unsigned fixed-decimal to multiply by\\n * @param c Unsigned fixed-decimal to divide by\\n * @return Resulting computation\\n */\\n function muldiv(UFixed18 a, UFixed18 b, UFixed18 c) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / UFixed18.unwrap(c));\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is equal to `b`\\n */\\n function eq(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 1;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is greater than `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is greater than `b`\\n */\\n function gt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 2;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is less than `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is less than `b`\\n */\\n function lt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 0;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is greater than or equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is greater than or equal to `b`\\n */\\n function gte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return gt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is less than or equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is less than or equal to `b`\\n */\\n function lte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return lt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Compares the unsigned fixed-decimals `a` and `b`\\n * @dev Returns: 2 for greater than\\n * 1 for equal to\\n * 0 for less than\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Compare result of `a` and `b`\\n */\\n function compare(UFixed18 a, UFixed18 b) internal pure returns (uint256) {\\n (uint256 au, uint256 bu) = (UFixed18.unwrap(a), UFixed18.unwrap(b));\\n if (au > bu) return 2;\\n if (au < bu) return 0;\\n return 1;\\n }\\n\\n /**\\n * @notice Returns a unsigned fixed-decimal representing the ratio of `a` over `b`\\n * @param a First unsigned number\\n * @param b Second unsigned number\\n * @return Ratio of `a` over `b`\\n */\\n function ratio(uint256 a, uint256 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(a * BASE / b);\\n }\\n\\n /**\\n * @notice Returns the minimum of unsigned fixed-decimals `a` and `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Minimum of `a` and `b`\\n */\\n function min(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(Math.min(UFixed18.unwrap(a), UFixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Returns the maximum of unsigned fixed-decimals `a` and `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Maximum of `a` and `b`\\n */\\n function max(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(Math.max(UFixed18.unwrap(a), UFixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Converts the unsigned fixed-decimal into an integer, truncating any decimal portion\\n * @param a Unsigned fixed-decimal\\n * @return Truncated unsigned number\\n */\\n function truncate(UFixed18 a) internal pure returns (uint256) {\\n return UFixed18.unwrap(a) / BASE;\\n }\\n}\\n\\nlibrary UFixed18StorageLib {\\n function read(UFixed18Storage self) internal view returns (UFixed18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(UFixed18Storage self, UFixed18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x8ebef1e6c717f565b9ed545a876b5692b4007e6485c99f39d363f7405e591792\",\"license\":\"Apache-2.0\"},\"@equilibria/root/token/types/Token18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"../../number/types/UFixed18.sol\\\";\\n\\n/// @dev Token18\\ntype Token18 is address;\\nusing Token18Lib for Token18 global;\\ntype Token18Storage is bytes32;\\nusing Token18StorageLib for Token18Storage global;\\n\\n/**\\n * @title Token18Lib\\n * @notice Library to manage 18-decimal ERC20s that is compliant with the fixed-decimal types.\\n * @dev Maintains significant gas savings over other Token implementations since no conversion take place\\n */\\nlibrary Token18Lib {\\n using SafeERC20 for IERC20;\\n\\n Token18 public constant ZERO = Token18.wrap(address(0));\\n\\n /**\\n * @notice Returns whether a token is the zero address\\n * @param self Token to check for\\n * @return Whether the token is the zero address\\n */\\n function isZero(Token18 self) internal pure returns (bool) {\\n return Token18.unwrap(self) == Token18.unwrap(ZERO);\\n }\\n\\n /**\\n * @notice Returns whether the two tokens are equal\\n * @param a First token to compare\\n * @param b Second token to compare\\n * @return Whether the two tokens are equal\\n */\\n function eq(Token18 a, Token18 b) internal pure returns (bool) {\\n return Token18.unwrap(a) == Token18.unwrap(b);\\n }\\n\\n /**\\n * @notice Approves `grantee` to spend infinite tokens from the caller\\n * @param self Token to transfer\\n * @param grantee Address to allow spending\\n */\\n function approve(Token18 self, address grantee) internal {\\n IERC20(Token18.unwrap(self)).safeApprove(grantee, type(uint256).max);\\n }\\n\\n /**\\n * @notice Approves `grantee` to spend `amount` tokens from the caller\\n * @dev There are important race conditions to be aware of when using this function\\n with values other than 0. This will revert if moving from non-zero to non-zero amounts\\n See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/a55b7d13722e7ce850b626da2313f3e66ca1d101/contracts/token/ERC20/IERC20.sol#L57\\n * @param self Token to transfer\\n * @param grantee Address to allow spending\\n * @param amount Amount of tokens to approve to spend\\n */\\n function approve(Token18 self, address grantee, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeApprove(grantee, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers all held tokens from the caller to the `recipient`\\n * @param self Token to transfer\\n * @param recipient Address to receive the tokens\\n */\\n function push(Token18 self, address recipient) internal {\\n push(self, recipient, balanceOf(self, address(this)));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the caller to the `recipient`\\n * @param self Token to transfer\\n * @param recipient Address to transfer tokens to\\n * @param amount Amount of tokens to transfer\\n */\\n function push(Token18 self, address recipient, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransfer(recipient, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the `benefactor` to the caller\\n * @dev Reverts if trying to pull Ether\\n * @param self Token to transfer\\n * @param benefactor Address to transfer tokens from\\n * @param amount Amount of tokens to transfer\\n */\\n function pull(Token18 self, address benefactor, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, address(this), UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the `benefactor` to `recipient`\\n * @dev Reverts if trying to pull Ether\\n * @param self Token to transfer\\n * @param benefactor Address to transfer tokens from\\n * @param recipient Address to transfer tokens to\\n * @param amount Amount of tokens to transfer\\n */\\n function pullTo(Token18 self, address benefactor, address recipient, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, recipient, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Returns the name of the token\\n * @param self Token to check for\\n * @return Token name\\n */\\n function name(Token18 self) internal view returns (string memory) {\\n return IERC20Metadata(Token18.unwrap(self)).name();\\n }\\n\\n /**\\n * @notice Returns the symbol of the token\\n * @param self Token to check for\\n * @return Token symbol\\n */\\n function symbol(Token18 self) internal view returns (string memory) {\\n return IERC20Metadata(Token18.unwrap(self)).symbol();\\n }\\n\\n /**\\n * @notice Returns the `self` token balance of the caller\\n * @param self Token to check for\\n * @return Token balance of the caller\\n */\\n function balanceOf(Token18 self) internal view returns (UFixed18) {\\n return balanceOf(self, address(this));\\n }\\n\\n /**\\n * @notice Returns the `self` token balance of `account`\\n * @param self Token to check for\\n * @param account Account to check\\n * @return Token balance of the account\\n */\\n function balanceOf(Token18 self, address account) internal view returns (UFixed18) {\\n return UFixed18.wrap(IERC20(Token18.unwrap(self)).balanceOf(account));\\n }\\n}\\n\\nlibrary Token18StorageLib {\\n function read(Token18Storage self) internal view returns (Token18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(Token18Storage self, Token18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x6b12afaece814f0ab186200a4729e93eb685a21d3e9b5a3372ff283a7ad5dc23\",\"license\":\"Apache-2.0\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\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 amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` 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(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\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\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 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 using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\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 function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc3d946432c0ddbb1f846a0d3985be71299df331b91d06732152117f62f0be2b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // 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\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return 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 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 up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a / b + (a % b == 0 ? 0 : 1);\\n }\\n}\\n\",\"keccak256\":\"0xc995bddbca1ae19788db9f8b61e63385edd3fddf89693b612d5abd1a275974d2\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SignedMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/SignedMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard signed math utilities missing in the Solidity language.\\n */\\nlibrary SignedMath {\\n /**\\n * @dev Returns the largest of two signed numbers.\\n */\\n function max(int256 a, int256 b) internal pure returns (int256) {\\n return 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 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 // must be unchecked in order to support `n = type(int256).min`\\n return uint256(n >= 0 ? n : -n);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb3ebde1c8d27576db912d87c3560dab14adfb9cd001be95890ec4ba035e652e7\",\"license\":\"MIT\"},\"contracts/interfaces/ICollateral.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"./IController.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\n\\ninterface ICollateral {\\n event Deposit(address indexed user, IProduct indexed product, UFixed18 amount);\\n event Withdrawal(address indexed user, IProduct indexed product, UFixed18 amount);\\n event AccountSettle(IProduct indexed product, address indexed account, Fixed18 amount, UFixed18 newShortfall);\\n event ProductSettle(IProduct indexed product, UFixed18 protocolFee, UFixed18 productFee);\\n event Liquidation(address indexed user, IProduct indexed product, address liquidator, UFixed18 fee);\\n event ShortfallResolution(IProduct indexed product, UFixed18 amount);\\n event FeeClaim(address indexed account, UFixed18 amount);\\n\\n error CollateralCantLiquidate(UFixed18 totalMaintenance, UFixed18 totalCollateral);\\n error CollateralInsufficientCollateralError();\\n error CollateralUnderLimitError();\\n error CollateralZeroAddressError();\\n\\n function token() external view returns (Token18);\\n function fees(address account) external view returns (UFixed18);\\n function initialize(IController controller_) external;\\n function depositTo(address account, IProduct product, UFixed18 amount) external;\\n function withdrawTo(address account, IProduct product, UFixed18 amount) external;\\n function liquidate(address account, IProduct product) external;\\n function settleAccount(address account, Fixed18 amount) external;\\n function settleProduct(UFixed18 amount) external;\\n function collateral(address account, IProduct product) external view returns (UFixed18);\\n function collateral(IProduct product) external view returns (UFixed18);\\n function shortfall(IProduct product) external view returns (UFixed18);\\n function liquidatable(address account, IProduct product) external view returns (bool);\\n function liquidatableNext(address account, IProduct product) external view returns (bool);\\n function resolveShortfall(IProduct product, UFixed18 amount) external;\\n function claimFee() external;\\n}\\n\",\"keccak256\":\"0xa5e7fdda92702f748e6eb8701e522450035a98a05e5fc1cf66d51c52e397d914\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IContractPayoffProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\n\\ninterface IContractPayoffProvider {\\n function payoff(Fixed18 price) external view returns (Fixed18 payoff);\\n}\\n\",\"keccak256\":\"0xd73df106d032e976fd959ee6713240e36f54277ce5f215eaec8d5a2c6720a86b\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IController.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\\\";\\nimport \\\"./ICollateral.sol\\\";\\nimport \\\"./IIncentivizer.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\n\\ninterface IController {\\n /// @dev Coordinator of a one or many products\\n struct Coordinator {\\n /// @dev Pending owner of the product, can accept ownership\\n address pendingOwner;\\n\\n /// @dev Owner of the product, allowed to update select parameters\\n address owner;\\n\\n /// @dev Treasury of the product, collects fees\\n address treasury;\\n }\\n\\n event CollateralUpdated(ICollateral newCollateral);\\n event IncentivizerUpdated(IIncentivizer newIncentivizer);\\n event ProductBeaconUpdated(IBeacon newProductBeacon);\\n event ProtocolFeeUpdated(UFixed18 newProtocolFee);\\n event MinFundingFeeUpdated(UFixed18 newMinFundingFee);\\n event LiquidationFeeUpdated(UFixed18 newLiquidationFee);\\n event IncentivizationFeeUpdated(UFixed18 newIncentivizationFee);\\n event MinCollateralUpdated(UFixed18 newMinCollateral);\\n event ProgramsPerProductUpdated(uint256 newProgramsPerProduct);\\n event PauserUpdated(address newPauser);\\n event PausedUpdated(bool newPaused);\\n event CoordinatorPendingOwnerUpdated(uint256 indexed coordinatorId, address newPendingOwner);\\n event CoordinatorOwnerUpdated(uint256 indexed coordinatorId, address newOwner);\\n event CoordinatorTreasuryUpdated(uint256 indexed coordinatorId, address newTreasury);\\n event CoordinatorCreated(uint256 indexed coordinatorId, address owner);\\n event ProductCreated(IProduct indexed product, IProduct.ProductInfo productInfo);\\n\\n error ControllerNoZeroCoordinatorError();\\n error ControllerNotPauserError();\\n error ControllerNotOwnerError(uint256 controllerId);\\n error ControllerNotPendingOwnerError(uint256 controllerId);\\n error ControllerInvalidProtocolFeeError();\\n error ControllerInvalidMinFundingFeeError();\\n error ControllerInvalidLiquidationFeeError();\\n error ControllerInvalidIncentivizationFeeError();\\n error ControllerNotContractAddressError();\\n\\n function collateral() external view returns (ICollateral);\\n function incentivizer() external view returns (IIncentivizer);\\n function productBeacon() external view returns (IBeacon);\\n function coordinators(uint256 collateralId) external view returns (Coordinator memory);\\n function coordinatorFor(IProduct product) external view returns (uint256);\\n function protocolFee() external view returns (UFixed18);\\n function minFundingFee() external view returns (UFixed18);\\n function liquidationFee() external view returns (UFixed18);\\n function incentivizationFee() external view returns (UFixed18);\\n function minCollateral() external view returns (UFixed18);\\n function programsPerProduct() external view returns (uint256);\\n function pauser() external view returns (address);\\n function paused() external view returns (bool);\\n function initialize(ICollateral collateral_, IIncentivizer incentivizer_, IBeacon productBeacon_) external;\\n function createCoordinator() external returns (uint256);\\n function updateCoordinatorPendingOwner(uint256 coordinatorId, address newPendingOwner) external;\\n function acceptCoordinatorOwner(uint256 coordinatorId) external;\\n function updateCoordinatorTreasury(uint256 coordinatorId, address newTreasury) external;\\n function createProduct(uint256 coordinatorId, IProduct.ProductInfo calldata productInfo) external returns (IProduct);\\n function updateCollateral(ICollateral newCollateral) external;\\n function updateIncentivizer(IIncentivizer newIncentivizer) external;\\n function updateProductBeacon(IBeacon newProductBeacon) external;\\n function updateProtocolFee(UFixed18 newProtocolFee) external;\\n function updateMinFundingFee(UFixed18 newMinFundingFee) external;\\n function updateLiquidationFee(UFixed18 newLiquidationFee) external;\\n function updateIncentivizationFee(UFixed18 newIncentivizationFee) external;\\n function updateMinCollateral(UFixed18 newMinCollateral) external;\\n function updateProgramsPerProduct(uint256 newProductsPerProduct) external;\\n function updatePauser(address newPauser) external;\\n function updatePaused(bool newPaused) external;\\n function isProduct(IProduct product) external view returns (bool);\\n function owner() external view returns (address);\\n function owner(uint256 coordinatorId) external view returns (address);\\n function owner(IProduct product) external view returns (address);\\n function treasury() external view returns (address);\\n function treasury(uint256 coordinatorId) external view returns (address);\\n function treasury(IProduct product) external view returns (address);\\n}\\n\",\"keccak256\":\"0xaabd3740f2265499eea7aad9bd94f9892f53241e5dccce9a50c0e43ed2a6a7cc\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IIncentivizer.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./types/ProgramInfo.sol\\\";\\nimport \\\"./IController.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\n\\ninterface IIncentivizer {\\n event ProgramCreated(IProduct indexed product, uint256 indexed programId, ProgramInfo programInfo, UFixed18 programFeeAmount);\\n event ProgramStarted(IProduct indexed product, uint256 indexed programId, uint256 version);\\n event ProgramComplete(IProduct indexed product, uint256 indexed programId, uint256 version);\\n event Claim(IProduct indexed product, address indexed account, uint256 indexed programId, UFixed18 amount);\\n event FeeClaim(Token18 indexed token, UFixed18 amount);\\n\\n error IncentivizerNotAllowedError(IProduct product);\\n error IncentivizerTooManyProgramsError();\\n error IncentivizerNotProgramOwnerError(IProduct product, uint256 programId);\\n error IncentivizerInvalidProgramError(IProduct product, uint256 programId);\\n error IncentivizerBatchClaimArgumentMismatchError();\\n\\n function programInfos(IProduct product, uint256 programId) external view returns (ProgramInfo memory);\\n function fees(Token18 token) external view returns (UFixed18);\\n function initialize(IController controller_) external;\\n function create(IProduct product, ProgramInfo calldata info) external returns (uint256);\\n function complete(IProduct product, uint256 programId) external;\\n function sync(IOracleProvider.OracleVersion memory currentOracleVersion) external;\\n function syncAccount(address account, IOracleProvider.OracleVersion memory currentOracleVersion) external;\\n function claim(IProduct product, uint256[] calldata programIds) external;\\n function claim(IProduct[] calldata products, uint256[][] calldata programIds) external;\\n function claimFee(Token18[] calldata tokens) external;\\n function active(IProduct product) external view returns (uint256);\\n function count(IProduct product) external view returns (uint256);\\n function unclaimed(IProduct product, address account, uint256 programId) external view returns (UFixed18);\\n function available(IProduct product, uint256 programId) external view returns (UFixed18);\\n function versionStarted(IProduct product, uint256 programId) external view returns (uint256);\\n function versionComplete(IProduct product, uint256 programId) external view returns (uint256);\\n function owner(IProduct product, uint256 programId) external view returns (address);\\n function treasury(IProduct product, uint256 programId) external view returns (address);\\n}\\n\",\"keccak256\":\"0x2f95de90dbb3ad35dbfef304f765a622bffff9229868d2898eca8d49c78e8c2c\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IParamProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\\\";\\n\\ninterface IParamProvider {\\n event MaintenanceUpdated(UFixed18 newMaintenance);\\n event FundingFeeUpdated(UFixed18 newFundingFee);\\n event MakerFeeUpdated(UFixed18 newMakerFee);\\n event TakerFeeUpdated(UFixed18 newTakerFee);\\n event MakerLimitUpdated(UFixed18 newMakerLimit);\\n event JumpRateUtilizationCurveUpdated(\\n Fixed18 minRate,\\n Fixed18 maxRate,\\n Fixed18 targetRate,\\n UFixed18 targetUtilization\\n );\\n\\n error ParamProviderInvalidMakerFee();\\n error ParamProviderInvalidTakerFee();\\n error ParamProviderInvalidFundingFee();\\n \\n function maintenance() external view returns (UFixed18);\\n function updateMaintenance(UFixed18 newMaintenance) external;\\n function fundingFee() external view returns (UFixed18);\\n function updateFundingFee(UFixed18 newFundingFee) external;\\n function makerFee() external view returns (UFixed18);\\n function updateMakerFee(UFixed18 newMakerFee) external;\\n function takerFee() external view returns (UFixed18);\\n function updateTakerFee(UFixed18 newTakerFee) external;\\n function makerLimit() external view returns (UFixed18);\\n function updateMakerLimit(UFixed18 newMakerLimit) external;\\n function utilizationCurve() external view returns (JumpRateUtilizationCurve memory);\\n function updateUtilizationCurve(JumpRateUtilizationCurve memory newUtilizationCurve) external;\\n}\\n\",\"keccak256\":\"0x2e2d40d0cf55f167118867e41f740b9b40614d05da50fc9bc33a8cede3eaf03e\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IPayoffProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\n\\ninterface IPayoffProvider {\\n error PayoffProviderInvalidOracle();\\n error PayoffProviderInvalidPayoffDefinitionError();\\n\\n function oracle() external view returns (IOracleProvider);\\n function payoffDefinition() external view returns (PayoffDefinition memory);\\n function currentVersion() external view returns (IOracleProvider.OracleVersion memory);\\n function atVersion(uint256 oracleVersion) external view returns (IOracleProvider.OracleVersion memory);\\n}\\n\",\"keccak256\":\"0xb83d80d624aa9431763f80ecb4bf0214803e25334a7419d954f929e5d0ee7467\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IPerennialLens.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\nimport \\\"./ICollateral.sol\\\";\\nimport \\\"./IController.sol\\\";\\n\\n/**\\n * @title Lens contract to conveniently pull protocol, product, and userproduct data\\n * @notice All functions should be called using `callStatic`\\n */\\ninterface IPerennialLens {\\n /// @dev Snapshot of Product information\\n struct ProductSnapshot {\\n IProduct.ProductInfo productInfo;\\n address productAddress;\\n Fixed18 rate;\\n Fixed18 dailyRate;\\n IOracleProvider.OracleVersion latestVersion;\\n UFixed18 maintenance;\\n UFixed18 collateral;\\n UFixed18 shortfall;\\n PrePosition pre;\\n Position position;\\n UFixed18 productFee;\\n UFixed18 protocolFee;\\n Position openInterest;\\n }\\n\\n /// @dev Snapshot of User state for a Product\\n struct UserProductSnapshot {\\n address productAddress;\\n address userAddress;\\n UFixed18 collateral;\\n UFixed18 maintenance;\\n PrePosition pre;\\n Position position;\\n bool liquidatable;\\n bool liquidating;\\n Position openInterest;\\n UFixed18 fees;\\n UFixed18 exposure;\\n }\\n\\n // Protocol Values\\n function controller() external view returns (IController);\\n function collateral() external view returns (ICollateral);\\n\\n // Snapshot Functions for batch values\\n function snapshots(IProduct[] calldata productAddresses) external returns (ProductSnapshot[] memory);\\n function snapshot(IProduct product) external returns (ProductSnapshot memory);\\n function snapshots(address account, IProduct[] calldata productAddresses) external returns (UserProductSnapshot[] memory);\\n function snapshot(address account, IProduct product) external returns (UserProductSnapshot memory);\\n\\n // Product Values\\n function name(IProduct product) external view returns (string memory);\\n function symbol(IProduct product) external view returns (string memory);\\n function info(IProduct product) external view returns (IProduct.ProductInfo memory _info);\\n function collateral(IProduct product) external returns (UFixed18);\\n function shortfall(IProduct product) external returns (UFixed18);\\n function pre(IProduct product) external returns (PrePosition memory);\\n function fees(IProduct product) external returns (UFixed18 protocolFees, UFixed18 productFees);\\n function position(IProduct product) external returns (Position memory);\\n function globalPosition(IProduct product) external returns (PrePosition memory, Position memory);\\n function latestVersion(IProduct product) external returns (IOracleProvider.OracleVersion memory);\\n function atVersions(IProduct product, uint[] memory versions) external returns (IOracleProvider.OracleVersion[] memory prices);\\n function rate(IProduct product) external returns (Fixed18);\\n function openInterest(IProduct product) external returns (Position memory);\\n function dailyRate(IProduct product) external returns (Fixed18);\\n\\n // UserProduct Values\\n function collateral(address account, IProduct product) external returns (UFixed18);\\n function maintenance(address account, IProduct product) external returns (UFixed18);\\n function liquidatable(address account, IProduct product) external returns (bool);\\n function liquidating(address account, IProduct product) external returns (bool);\\n function pre(address account, IProduct product) external returns (PrePosition memory);\\n function position(address account, IProduct product) external returns (Position memory);\\n function userPosition(address account, IProduct product) external returns (PrePosition memory, Position memory);\\n function fees(address account, IProduct product) external returns (UFixed18);\\n function openInterest(address account, IProduct product) external returns (Position memory);\\n function exposure(address account, IProduct product) external returns (UFixed18);\\n function maintenanceRequired(\\n address account,\\n IProduct product,\\n UFixed18 positionSize\\n ) external returns (UFixed18);\\n function unclaimedIncentiveRewards(address account, IProduct product)\\n external\\n returns (Token18[] memory tokens, UFixed18[] memory amounts);\\n function unclaimedIncentiveRewards(\\n address account,\\n IProduct product,\\n uint256[] calldata programIds\\n ) external returns (Token18[] memory tokens, UFixed18[] memory amounts);\\n}\\n\",\"keccak256\":\"0x620401075cd7f65213980cbb4aee48867ad1e98ab361c0589d15d838e0ed13aa\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IProduct.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\\\";\\nimport \\\"./IPayoffProvider.sol\\\";\\nimport \\\"./IParamProvider.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\nimport \\\"./types/Position.sol\\\";\\nimport \\\"./types/PrePosition.sol\\\";\\nimport \\\"./types/Accumulator.sol\\\";\\n\\ninterface IProduct is IPayoffProvider, IParamProvider {\\n /// @dev Product Creation parameters\\n struct ProductInfo {\\n /// @dev name of the product\\n string name;\\n\\n /// @dev symbol of the product\\n string symbol;\\n\\n /// @dev product payoff definition\\n PayoffDefinition payoffDefinition;\\n\\n /// @dev oracle address\\n IOracleProvider oracle;\\n\\n /// @dev product maintenance ratio\\n UFixed18 maintenance;\\n\\n /// @dev product funding fee\\n UFixed18 fundingFee;\\n\\n /// @dev product maker fee\\n UFixed18 makerFee;\\n\\n /// @dev product taker fee\\n UFixed18 takerFee;\\n\\n /// @dev product maker limit\\n UFixed18 makerLimit;\\n\\n /// @dev utulization curve definition\\n JumpRateUtilizationCurve utilizationCurve;\\n }\\n\\n event Settle(uint256 preVersion, uint256 toVersion);\\n event AccountSettle(address indexed account, uint256 preVersion, uint256 toVersion);\\n event MakeOpened(address indexed account, uint256 version, UFixed18 amount);\\n event TakeOpened(address indexed account, uint256 version, UFixed18 amount);\\n event MakeClosed(address indexed account, uint256 version, UFixed18 amount);\\n event TakeClosed(address indexed account, uint256 version, UFixed18 amount);\\n event ClosedUpdated(bool indexed newClosed, uint256 version);\\n\\n error ProductInsufficientLiquidityError(UFixed18 socializationFactor);\\n error ProductDoubleSidedError();\\n error ProductOverClosedError();\\n error ProductInsufficientCollateralError();\\n error ProductInLiquidationError();\\n error ProductMakerOverLimitError();\\n error ProductOracleBootstrappingError();\\n error ProductNotOwnerError();\\n error ProductInvalidOracle();\\n error ProductClosedError();\\n\\n function name() external view returns (string memory);\\n function symbol() external view returns (string memory);\\n function initialize(ProductInfo calldata productInfo_) external;\\n function settle() external;\\n function settleAccount(address account) external;\\n function openTake(UFixed18 amount) external;\\n function closeTake(UFixed18 amount) external;\\n function openMake(UFixed18 amount) external;\\n function closeMake(UFixed18 amount) external;\\n function closeAll(address account) external;\\n function maintenance(address account) external view returns (UFixed18);\\n function maintenanceNext(address account) external view returns (UFixed18);\\n function isClosed(address account) external view returns (bool);\\n function isLiquidating(address account) external view returns (bool);\\n function position(address account) external view returns (Position memory);\\n function pre(address account) external view returns (PrePosition memory);\\n function latestVersion() external view returns (uint256);\\n function positionAtVersion(uint256 oracleVersion) external view returns (Position memory);\\n function pre() external view returns (PrePosition memory);\\n function valueAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\\n function shareAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\\n function latestVersion(address account) external view returns (uint256);\\n function rate(Position memory position) external view returns (Fixed18);\\n function closed() external view returns (bool);\\n function updateClosed(bool newClosed) external;\\n}\\n\",\"keccak256\":\"0xe1e80b818eadf4cdb070362e40c7cf3863b50c4f944816af27848e319f587241\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/Accumulator.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"./PackedAccumulator.sol\\\";\\n\\n/// @dev Accumulator type\\nstruct Accumulator {\\n /// @dev maker accumulator per share\\n Fixed18 maker;\\n /// @dev taker accumulator per share\\n Fixed18 taker;\\n}\\nusing AccumulatorLib for Accumulator global;\\n\\n/**\\n * @title AccountAccumulatorLib\\n * @notice Library that surfaces math operations for the Accumulator type.\\n * @dev Accumulators track the cumulative change in position value over time for the maker and taker positions\\n * respectively. Account-level accumulators can then use two of these values `a` and `a'` to compute the\\n * change in position value since last sync. This change in value is then used to compute P&L and fees.\\n */\\nlibrary AccumulatorLib {\\n /**\\n * @notice Creates a packed accumulator from an accumulator\\n * @param self an accumulator\\n * @return New packed accumulator\\n */\\n function pack(Accumulator memory self) internal pure returns (PackedAccumulator memory) {\\n return PackedAccumulator({maker: self.maker.pack(), taker: self.taker.pack()});\\n }\\n\\n /**\\n * @notice Adds two accumulators together\\n * @param a The first accumulator to sum\\n * @param b The second accumulator to sum\\n * @return The resulting summed accumulator\\n */\\n function add(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\\n }\\n\\n /**\\n * @notice Subtracts accumulator `b` from `a`\\n * @param a The accumulator to subtract from\\n * @param b The accumulator to subtract\\n * @return The resulting subtracted accumulator\\n */\\n function sub(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\\n }\\n\\n /**\\n * @notice Multiplies two accumulators together\\n * @param a The first accumulator to multiply\\n * @param b The second accumulator to multiply\\n * @return The resulting multiplied accumulator\\n */\\n function mul(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.mul(b.maker), taker: a.taker.mul(b.taker)});\\n }\\n\\n /**\\n * @notice Sums the maker and taker together from a single accumulator\\n * @param self The struct to operate on\\n * @return The sum of its maker and taker\\n */\\n function sum(Accumulator memory self) internal pure returns (Fixed18) {\\n return self.maker.add(self.taker);\\n }\\n}\\n\",\"keccak256\":\"0x7ccd0a72aa593cefb9f4337cf312799f357b82fcb3f0379de0dc503d1cb7e387\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PackedAccumulator.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/PackedFixed18.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\n\\n/// @dev PackedAccumulator type\\nstruct PackedAccumulator {\\n /// @dev maker accumulator per share\\n PackedFixed18 maker;\\n /// @dev taker accumulator per share\\n PackedFixed18 taker;\\n}\\nusing PackedAccumulatorLib for PackedAccumulator global;\\n\\n/**\\n * @title PackedAccumulatorLib\\n * @dev A packed version of the Accumulator which takes up a single storage slot using `PackedFixed18` values.\\n * @notice Library for the packed Accumulator type.\\n */\\nlibrary PackedAccumulatorLib {\\n /**\\n * @notice Creates an accumulator from a packed accumulator\\n * @param self packed accumulator\\n * @return New accumulator\\n */\\n function unpack(PackedAccumulator memory self) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: self.maker.unpack(), taker: self.taker.unpack()});\\n }\\n}\\n\",\"keccak256\":\"0xd83f2822d4f6c818087a232b54007730992c34ff77377fc307a282f886e7cf65\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PackedPosition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/PackedUFixed18.sol\\\";\\nimport \\\"./Position.sol\\\";\\n\\n/// @dev PackedPosition type\\nstruct PackedPosition {\\n /// @dev Quantity of the maker position\\n PackedUFixed18 maker;\\n /// @dev Quantity of the taker position\\n PackedUFixed18 taker;\\n}\\nusing PackedPositionLib for PackedPosition global;\\n\\n/**\\n * @title PackedPositionLib\\n * @dev A packed version of the Position which takes up a single storage slot using `PackedFixed18` values.\\n * @notice Library for the packed Position type.\\n */\\nlibrary PackedPositionLib {\\n /**\\n * @notice Creates an position from a packed position\\n * @param self packed position\\n * @return New position\\n */\\n function unpack(PackedPosition memory self) internal pure returns (Position memory) {\\n return Position({maker: self.maker.unpack(), taker: self.taker.unpack()});\\n }\\n}\\n\",\"keccak256\":\"0x04968e6794f6244cb3415cea111d640273a81faea957872988d0cb580f45df1e\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PayoffDefinition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"@openzeppelin/contracts/utils/Address.sol\\\";\\nimport \\\"../../interfaces/IContractPayoffProvider.sol\\\";\\n\\n/// @dev PayoffDefinition tyoe\\nstruct PayoffDefinition {\\n PayoffDefinitionLib.PayoffType payoffType;\\n PayoffDefinitionLib.PayoffDirection payoffDirection;\\n bytes30 data;\\n}\\nusing PayoffDefinitionLib for PayoffDefinition global;\\ntype PayoffDefinitionStorage is bytes32;\\nusing PayoffDefinitionStorageLib for PayoffDefinitionStorage global;\\n\\n/**\\n * @title PayoffDefinitionLib\\n * @dev Library that surfaces logic for PayoffDefinition type functionality\\n * @notice Library for the PayoffDefinition type. Performs validity and price transformation\\n based on the payoff definition type.\\n */\\nlibrary PayoffDefinitionLib {\\n using Address for address;\\n\\n error PayoffDefinitionUnsupportedTransform(PayoffType payoffType, PayoffDirection payoffDirection);\\n error PayoffDefinitionNotContract(PayoffType payoffType, bytes30 data);\\n\\n /// @dev Payoff function type enum\\n enum PayoffType { PASSTHROUGH, CONTRACT }\\n enum PayoffDirection { LONG, SHORT }\\n\\n /**\\n * @notice Checks validity of the payoff definition\\n * @param self a payoff definition\\n * @return Whether the payoff definition is valid for it's given type\\n */\\n function valid(PayoffDefinition memory self) internal view returns (bool) {\\n if (self.payoffType == PayoffType.CONTRACT) return address(_providerContract(self)).isContract();\\n\\n // All other payoff types should have no data\\n return uint(bytes32(self.data)) == 0;\\n }\\n\\n /**\\n * @notice Transforms a price based on the payoff definition\\n * @param self a payoff definition\\n * @param price raw oracle price\\n * @return Price transformed by the payoff definition function\\n */\\n function transform(\\n PayoffDefinition memory self,\\n Fixed18 price\\n ) internal view returns (Fixed18) {\\n PayoffType payoffType = self.payoffType;\\n PayoffDirection payoffDirection = self.payoffDirection;\\n Fixed18 transformedPrice;\\n\\n // First get the price depending on the type\\n if (payoffType == PayoffType.PASSTHROUGH) transformedPrice = price;\\n else if (payoffType == PayoffType.CONTRACT) transformedPrice = _payoffFromContract(self, price);\\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\\n\\n // Then transform it depending on the direction flag\\n if (self.payoffDirection == PayoffDirection.LONG) return transformedPrice;\\n else if (self.payoffDirection == PayoffDirection.SHORT) return transformedPrice.mul(Fixed18Lib.NEG_ONE);\\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\\n }\\n\\n /**\\n * @notice Parses the data field into an address\\n * @dev Reverts if payoffType is not CONTRACT\\n * @param self a payoff definition\\n * @return IContractPayoffProvider address\\n */\\n function _providerContract(\\n PayoffDefinition memory self\\n ) private pure returns (IContractPayoffProvider) {\\n if (self.payoffType != PayoffType.CONTRACT) revert PayoffDefinitionNotContract(self.payoffType, self.data);\\n // Shift to pull the last 20 bytes, then cast to an address\\n return IContractPayoffProvider(address(bytes20(self.data << 80)));\\n }\\n\\n /**\\n * @notice Performs a price transformation by calling the underlying payoff contract\\n * @param self a payoff definition\\n * @param price raw oracle price\\n * @return Price transformed by the payoff definition function on the contract\\n */\\n function _payoffFromContract(\\n PayoffDefinition memory self,\\n Fixed18 price\\n ) private view returns (Fixed18) {\\n bytes memory ret = address(_providerContract(self)).functionStaticCall(\\n abi.encodeCall(IContractPayoffProvider.payoff, price)\\n );\\n return Fixed18.wrap(abi.decode(ret, (int256)));\\n }\\n}\\n\\n/**\\n * @title PayoffDefinitionStorageLib\\n * @notice Library that surfaces storage read and writes for the PayoffDefinition type\\n */\\nlibrary PayoffDefinitionStorageLib {\\n function read(PayoffDefinitionStorage self) internal view returns (PayoffDefinition memory) {\\n return _storagePointer(self);\\n }\\n\\n function store(PayoffDefinitionStorage self, PayoffDefinition memory value) internal {\\n PayoffDefinition storage storagePointer = _storagePointer(self);\\n\\n storagePointer.payoffType = value.payoffType;\\n storagePointer.payoffDirection = value.payoffDirection;\\n storagePointer.data = value.data;\\n }\\n\\n function _storagePointer(\\n PayoffDefinitionStorage self\\n ) private pure returns (PayoffDefinition storage pointer) {\\n assembly { pointer.slot := self }\\n }\\n}\\n\",\"keccak256\":\"0x4d3897f408f77381c5ae9990391465c8fd511ddf6ff3b39f6cb69d8c2bd554df\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/Position.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\nimport \\\"./PrePosition.sol\\\";\\nimport \\\"./PackedPosition.sol\\\";\\n\\n/// @dev Position type\\nstruct Position {\\n /// @dev Quantity of the maker position\\n UFixed18 maker;\\n /// @dev Quantity of the taker position\\n UFixed18 taker;\\n}\\nusing PositionLib for Position global;\\n\\n/**\\n * @title PositionLib\\n * @notice Library that surfaces math and settlement computations for the Position type.\\n * @dev Positions track the current quantity of the account's maker and taker positions respectively\\n * denominated as a unit of the product's payoff function.\\n */\\nlibrary PositionLib {\\n /**\\n * @notice Creates a packed position from an position\\n * @param self A position\\n * @return New packed position\\n */\\n function pack(Position memory self) internal pure returns (PackedPosition memory) {\\n return PackedPosition({maker: self.maker.pack(), taker: self.taker.pack()});\\n }\\n\\n /**\\n * @notice Returns whether the position is fully empty\\n * @param self A position\\n * @return Whether the position is empty\\n */\\n function isEmpty(Position memory self) internal pure returns (bool) {\\n return self.maker.isZero() && self.taker.isZero();\\n }\\n\\n /**\\n * @notice Adds position `a` and `b` together, returning the result\\n * @param a The first position to sum\\n * @param b The second position to sum\\n * @return Resulting summed position\\n */\\n function add(Position memory a, Position memory b) internal pure returns (Position memory) {\\n return Position({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\\n }\\n\\n /**\\n * @notice Subtracts position `b` from `a`, returning the result\\n * @param a The position to subtract from\\n * @param b The position to subtract\\n * @return Resulting subtracted position\\n */\\n function sub(Position memory a, Position memory b) internal pure returns (Position memory) {\\n return Position({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\\n }\\n\\n /**\\n * @notice Multiplies position `self` by accumulator `accumulator` and returns the resulting accumulator\\n * @param self The Position to operate on\\n * @param accumulator The accumulator to multiply by\\n * @return Resulting multiplied accumulator\\n */\\n function mul(Position memory self, Accumulator memory accumulator) internal pure returns (Accumulator memory) {\\n return Accumulator({\\n maker: Fixed18Lib.from(self.maker).mul(accumulator.maker),\\n taker: Fixed18Lib.from(self.taker).mul(accumulator.taker)\\n });\\n }\\n\\n /**\\n * @notice Scales position `self` by fixed-decimal `scale` and returns the resulting position\\n * @param self The Position to operate on\\n * @param scale The Fixed-decimal to scale by\\n * @return Resulting scaled position\\n */\\n function mul(Position memory self, UFixed18 scale) internal pure returns (Position memory) {\\n return Position({maker: self.maker.mul(scale), taker: self.taker.mul(scale)});\\n }\\n\\n /**\\n * @notice Divides position `self` by `b` and returns the resulting accumulator\\n * @param self The Position to operate on\\n * @param b The number to divide by\\n * @return Resulting divided accumulator\\n */\\n function div(Position memory self, uint256 b) internal pure returns (Accumulator memory) {\\n return Accumulator({\\n maker: Fixed18Lib.from(self.maker).div(Fixed18Lib.from(UFixed18Lib.from(b))),\\n taker: Fixed18Lib.from(self.taker).div(Fixed18Lib.from(UFixed18Lib.from(b)))\\n });\\n }\\n\\n /**\\n * @notice Returns the maximum of `self`'s maker and taker values\\n * @param self The struct to operate on\\n * @return Resulting maximum value\\n */\\n function max(Position memory self) internal pure returns (UFixed18) {\\n return UFixed18Lib.max(self.maker, self.taker);\\n }\\n\\n /**\\n * @notice Sums the maker and taker together from a single position\\n * @param self The struct to operate on\\n * @return The sum of its maker and taker\\n */\\n function sum(Position memory self) internal pure returns (UFixed18) {\\n return self.maker.add(self.taker);\\n }\\n\\n /**\\n * @notice Computes the next position after the pending-settlement position delta is included\\n * @param self The current Position\\n * @param pre The pending-settlement position delta\\n * @return Next Position\\n */\\n function next(Position memory self, PrePosition memory pre) internal pure returns (Position memory) {\\n return sub(add(self, pre.openPosition), pre.closePosition);\\n }\\n\\n /**\\n * @notice Returns the settled position at oracle version `toOracleVersion`\\n * @dev Checks if a new position is ready to be settled based on the provided `toOracleVersion`\\n * and `pre` and returns accordingly\\n * @param self The current Position\\n * @param pre The pending-settlement position delta\\n * @param toOracleVersion The oracle version to settle to\\n * @return Settled position at oracle version\\n * @return Fee accrued from opening or closing the position\\n * @return Whether a new position was settled\\n */\\n function settled(\\n Position memory self,\\n PrePosition memory pre,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal view returns (Position memory, UFixed18, bool) {\\n return pre.canSettle(toOracleVersion) ? (next(self, pre), pre.computeFee(toOracleVersion), true) : (self, UFixed18Lib.ZERO, false);\\n }\\n\\n /**\\n * @notice Returns the socialization factor for the current position\\n * @dev Socialization account for the case where `taker` > `maker` temporarily due to a liquidation\\n * on the maker side. This dampens the taker's exposure pro-rata to ensure that the maker side\\n * is never exposed over 1 x short.\\n * @param self The Position to operate on\\n * @return Socialization factor\\n */\\n function socializationFactor(Position memory self) internal pure returns (UFixed18) {\\n return self.taker.isZero() ? UFixed18Lib.ONE : UFixed18Lib.min(UFixed18Lib.ONE, self.maker.div(self.taker));\\n }\\n}\\n\",\"keccak256\":\"0x027fe392c4f56bf012ba2ca462fcf23e69f2c3b9d283c14089771813437af991\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PrePosition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./Position.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\n\\n/// @dev PrePosition type\\nstruct PrePosition {\\n /// @dev Oracle version at which the new position delta was recorded\\n uint256 oracleVersion;\\n\\n /// @dev Size of position to open at oracle version\\n Position openPosition;\\n\\n /// @dev Size of position to close at oracle version\\n Position closePosition;\\n}\\nusing PrePositionLib for PrePosition global;\\n\\n/**\\n * @title PrePositionLib\\n * @notice Library that manages a pre-settlement position delta.\\n * @dev PrePositions track the currently awaiting-settlement deltas to a settled Position. These are\\n * Primarily necessary to introduce lag into the settlement system such that oracle lag cannot be\\n * gamed to a user's advantage. When a user opens or closes a new position, it sits as a PrePosition\\n * for one oracle version until it's settle into the Position, making it then effective. PrePositions\\n * are automatically settled at the correct oracle version even if a flywheel call doesn't happen until\\n * several version into the future by using the historical version lookups in the corresponding \\\"Versioned\\\"\\n * global state types.\\n */\\nlibrary PrePositionLib {\\n /**\\n * @notice Returns whether there is no pending-settlement position delta\\n * @dev Can be \\\"empty\\\" even with a non-zero oracleVersion if a position is opened and\\n * closed in the same version netting out to a zero position delta\\n * @param self The struct to operate on\\n * @return Whether the pending-settlement position delta is empty\\n */\\n function isEmpty(PrePosition memory self) internal pure returns (bool) {\\n return self.openPosition.isEmpty() && self.closePosition.isEmpty();\\n }\\n\\n /**\\n * @notice Increments the maker side of the open position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The position amount to open\\n */\\n function openMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.openPosition.maker = self.openPosition.maker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netMake(self);\\n }\\n\\n /**\\n * @notice Increments the maker side of the close position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The maker position amount to close\\n */\\n function closeMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.closePosition.maker = self.closePosition.maker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netMake(self);\\n }\\n\\n /**\\n * @notice Increments the taker side of the open position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The taker position amount to open\\n */\\n function openTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.openPosition.taker = self.openPosition.taker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netTake(self);\\n }\\n\\n /**\\n * @notice Increments the taker side of the close position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The taker position amount to close\\n */\\n function closeTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.closePosition.taker = self.closePosition.taker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netTake(self);\\n }\\n\\n /**\\n * @notice Nets out the open and close on the maker side of the position delta\\n * @param self The struct to operate on\\n */\\n function _netMake(PrePosition storage self) private {\\n if (self.openPosition.maker.gt(self.closePosition.maker)) {\\n self.openPosition.maker = self.openPosition.maker.sub(self.closePosition.maker);\\n self.closePosition.maker = UFixed18Lib.ZERO;\\n } else {\\n self.closePosition.maker = self.closePosition.maker.sub(self.openPosition.maker);\\n self.openPosition.maker = UFixed18Lib.ZERO;\\n }\\n }\\n\\n /**\\n * @notice Nets out the open and close on the taker side of the position delta\\n * @param self The struct to operate on\\n */\\n function _netTake(PrePosition storage self) private {\\n if (self.openPosition.taker.gt(self.closePosition.taker)) {\\n self.openPosition.taker = self.openPosition.taker.sub(self.closePosition.taker);\\n self.closePosition.taker = UFixed18Lib.ZERO;\\n } else {\\n self.closePosition.taker = self.closePosition.taker.sub(self.openPosition.taker);\\n self.openPosition.taker = UFixed18Lib.ZERO;\\n }\\n }\\n\\n /**\\n * @notice Returns whether the the pending position delta can be settled at version `toOracleVersion`\\n * @dev Pending-settlement positions deltas can be settled (1) oracle version after they are recorded\\n * @param self The struct to operate on\\n * @param toOracleVersion The potential oracle version to settle\\n * @return Whether the position delta can be settled\\n */\\n function canSettle(\\n PrePosition memory self,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal pure returns (bool) {\\n return !isEmpty(self) && toOracleVersion.version > self.oracleVersion;\\n }\\n\\n /**\\n * @notice Computes the fee incurred for opening or closing the pending-settlement position\\n * @dev Must be called from a valid product to get the proper fee amounts\\n * @param self The struct to operate on\\n * @param toOracleVersion The oracle version at which settlement takes place\\n * @return positionFee The maker / taker fee incurred\\n */\\n function computeFee(\\n PrePosition memory self,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal view returns (UFixed18) {\\n Position memory positionDelta = self.openPosition.add(self.closePosition);\\n\\n (UFixed18 makerNotional, UFixed18 takerNotional) = (\\n Fixed18Lib.from(positionDelta.maker).mul(toOracleVersion.price).abs(),\\n Fixed18Lib.from(positionDelta.taker).mul(toOracleVersion.price).abs()\\n );\\n\\n IProduct product = IProduct(address(this));\\n return makerNotional.mul(product.makerFee()).add(takerNotional.mul(product.takerFee()));\\n }\\n\\n /**\\n * @notice Computes the next oracle version to settle\\n * @dev - If there is no pending-settlement position delta, returns the current oracle version\\n * - Otherwise returns the oracle version at which the pending-settlement position delta can be first settled\\n *\\n * Corresponds to point (b) in the Position settlement flow\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @return Next oracle version to settle\\n */\\n function settleVersion(PrePosition storage self, uint256 currentVersion) internal view returns (uint256) {\\n uint256 _oracleVersion = self.oracleVersion;\\n return _oracleVersion == 0 ? currentVersion : _oracleVersion + 1;\\n }\\n}\\n\",\"keccak256\":\"0xa6f83f7b5f8139ec874235c406debd086a152977493c08b7f280df6f1737fb96\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/ProgramInfo.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\nimport \\\"./Position.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\n\\n/// @dev ProgramInfo type\\nstruct ProgramInfo {\\n /// @dev Coordinator for this program\\n uint256 coordinatorId;\\n\\n /// @dev Amount of total maker and taker rewards\\n Position amount;\\n\\n /// @dev start timestamp of the program\\n uint256 start;\\n\\n /// @dev duration of the program (in seconds)\\n uint256 duration;\\n\\n /**\\n * @dev Reward ERC20 token contract\\n * @notice Perennial does not support non-standard ERC20s as reward tokens for incentive programs, including,\\n but not limited to: fee on transfer and rebase tokens. Using such a non-standard token will likely\\n result in loss of funds.\\n */\\n Token18 token;\\n}\\nusing ProgramInfoLib for ProgramInfo global;\\n\\n/**\\n * @title ProgramInfoLib\\n * @notice Library that snapshots the static information for a single program.\\n * @dev This information does not change during the operation of a program.\\n */\\nlibrary ProgramInfoLib {\\n uint256 private constant MIN_DURATION = 1 days;\\n uint256 private constant MAX_DURATION = 2 * 365 days;\\n\\n error ProgramInvalidStartError();\\n error ProgramInvalidDurationError();\\n\\n /**\\n * @notice Validates and creates a new Program\\n * @dev Reverts for invalid programInfos\\n * @param programInfo Un-sanitized static program information\\n */\\n function validate(ProgramInfo memory programInfo) internal view {\\n if (isStarted(programInfo, block.timestamp)) revert ProgramInvalidStartError();\\n if (programInfo.duration < MIN_DURATION || programInfo.duration > MAX_DURATION) revert ProgramInvalidDurationError();\\n }\\n\\n /**\\n * @notice Computes a new program info with the fee taken out of the amount\\n * @param programInfo Original program info\\n * @param incentivizationFee The incentivization fee\\n * @return New program info\\n * @return Fee amount\\n */\\n function deductFee(ProgramInfo memory programInfo, UFixed18 incentivizationFee)\\n internal pure returns (ProgramInfo memory, UFixed18) {\\n Position memory newProgramAmount = programInfo.amount.mul(UFixed18Lib.ONE.sub(incentivizationFee));\\n UFixed18 programFeeAmount = programInfo.amount.sub(newProgramAmount).sum();\\n programInfo.amount = newProgramAmount;\\n return (programInfo, programFeeAmount);\\n }\\n\\n /**\\n * @notice Returns the maker and taker amounts per position share\\n * @param self The ProgramInfo to operate on\\n * @return programFee Amounts per share\\n */\\n function amountPerShare(ProgramInfo memory self) internal pure returns (Accumulator memory) {\\n return self.amount.div(self.duration);\\n }\\n\\n /**\\n * @notice Returns whether the program has started by timestamp `timestamp`\\n * @param self The ProgramInfo to operate on\\n * @param timestamp Timestamp to check for\\n * @return Whether the program has started\\n */\\n function isStarted(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\\n return timestamp >= self.start;\\n }\\n\\n /**\\n * @notice Returns whether the program is completed by timestamp `timestamp`\\n * @param self The ProgramInfo to operate on\\n * @param timestamp Timestamp to check for\\n * @return Whether the program is completed\\n */\\n function isComplete(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\\n return timestamp >= (self.start + self.duration);\\n }\\n}\\n\",\"keccak256\":\"0x280fcaf931b49abaec46b95ccbabaaf856a4b8e8d036413c9c3b3af25585d161\",\"license\":\"Apache-2.0\"},\"contracts/lens/PerennialLens.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"../interfaces/IPerennialLens.sol\\\";\\n\\n/**\\n * @title Lens contract to conveniently pull protocol data\\n * @notice All functions should be called using `callStatic`\\n */\\ncontract PerennialLens is IPerennialLens {\\n /**\\n * @notice Protocol controller\\n * @return Protocol controller\\n */\\n IController public immutable controller;\\n\\n /// @param _controller Protocol controller address\\n constructor(IController _controller) {\\n controller = _controller;\\n }\\n\\n /**\\n * @notice Protocol collateral address\\n * @return Protocol collateral address\\n */\\n function collateral() public view returns (ICollateral) {\\n return controller.collateral();\\n }\\n\\n /**\\n * Snapshot Functions\\n */\\n\\n /**\\n * @notice Returns the snapshots of the provided `productAddresses`\\n * @param productAddresses Product addresses\\n * @return _snapshots a snapshot for each product after settle\\n */\\n function snapshots(IProduct[] calldata productAddresses) public returns (ProductSnapshot[] memory _snapshots) {\\n _snapshots = new ProductSnapshot[](productAddresses.length);\\n for (uint256 i = 0; i < productAddresses.length; i++) {\\n _snapshots[i] = snapshot(productAddresses[i]);\\n }\\n }\\n\\n /**\\n * @notice Returns the snapshot of the provided `product`\\n * @param product Product address\\n * @return _snapshot for the product after settle\\n */\\n function snapshot(IProduct product) public settle(product) returns (ProductSnapshot memory _snapshot) {\\n _snapshot.productInfo = info(product);\\n _snapshot.productAddress = address(product);\\n _snapshot.rate = rate(product);\\n _snapshot.dailyRate = dailyRate(product);\\n _snapshot.latestVersion = latestVersion(product);\\n _snapshot.maintenance = product.maintenance();\\n _snapshot.collateral = collateral(product);\\n _snapshot.shortfall = shortfall(product);\\n _snapshot.pre = pre(product);\\n _snapshot.position = position(product);\\n (_snapshot.productFee, _snapshot.protocolFee) = fees(product);\\n _snapshot.openInterest = openInterest(product);\\n }\\n\\n /**\\n * @notice Returns the user snapshots for the provided `productAddresses`\\n * @param account User addresses\\n * @param productAddresses Product addresses\\n * @return _snapshots UserSnapshot for each product after settle\\n */\\n function snapshots(address account, IProduct[] memory productAddresses)\\n public returns (UserProductSnapshot[] memory _snapshots)\\n {\\n _snapshots = new UserProductSnapshot[](productAddresses.length);\\n for (uint256 i = 0; i < productAddresses.length; i++) {\\n _snapshots[i] = snapshot(account, productAddresses[i]);\\n }\\n }\\n\\n /**\\n * @notice Returns the user snapshot for the provided `product`\\n * @param account User addresses\\n * @param product Product address\\n * @return _snapshot UserSnapshot for the product after settle\\n */\\n function snapshot(address account, IProduct product)\\n public\\n settleAccount(account, product)\\n returns (UserProductSnapshot memory _snapshot)\\n {\\n _snapshot.productAddress = address(product);\\n _snapshot.userAddress = account;\\n _snapshot.collateral = collateral(account, product);\\n _snapshot.maintenance = maintenance(account, product);\\n _snapshot.pre = pre(account, product);\\n _snapshot.position = position(account, product);\\n _snapshot.liquidatable = liquidatable(account, product);\\n _snapshot.liquidating = liquidating(account, product);\\n _snapshot.openInterest = openInterest(account, product);\\n _snapshot.fees = fees(account, product);\\n _snapshot.exposure = exposure(account, product);\\n }\\n\\n /**\\n * End Snapshot Functions\\n */\\n\\n /**\\n * Product Individual Fields Functions\\n */\\n\\n /**\\n * @notice Returns the name of the provided `product`\\n * @param product Product address\\n * @return Name of the product\\n */\\n function name(IProduct product) public view returns (string memory) {\\n return product.name();\\n }\\n\\n /**\\n * @notice Returns the symbol of the provided `product`\\n * @param product Product address\\n * @return Symbol of the product\\n */\\n function symbol(IProduct product) public view returns (string memory) {\\n return product.symbol();\\n }\\n\\n /**\\n * @notice Returns the info of the provided `product`\\n * @param product Product address\\n * @return _info of the product\\n */\\n function info(IProduct product) public view returns (IProduct.ProductInfo memory _info) {\\n _info.name = name(product);\\n _info.symbol = symbol(product);\\n _info.payoffDefinition = product.payoffDefinition();\\n _info.oracle = product.oracle();\\n _info.maintenance = product.maintenance();\\n _info.fundingFee = product.fundingFee();\\n _info.makerFee = product.makerFee();\\n _info.takerFee = product.takerFee();\\n _info.makerLimit = product.makerLimit();\\n _info.utilizationCurve = product.utilizationCurve();\\n }\\n\\n /**\\n * @notice Product total collateral amount after settle\\n * @param product Product address\\n * @return Total collateral for product\\n */\\n function collateral(IProduct product) public settle(product) returns (UFixed18) {\\n return collateral().collateral(product);\\n }\\n\\n /**\\n * @notice Product total shortfall amount after settle\\n * @param product Product address\\n * @return Total shortfall for product\\n */\\n function shortfall(IProduct product) public settle(product) returns (UFixed18) {\\n return collateral().shortfall(product);\\n }\\n\\n /**\\n * @notice Product pre position after settle\\n * @param product Product address\\n * @return Product pre-position\\n */\\n function pre(IProduct product) public settle(product) returns (PrePosition memory) {\\n return product.pre();\\n }\\n\\n /**\\n * @notice Product position after settle\\n * @param product Product address\\n * @return product position\\n */\\n function position(IProduct product) public settle(product) returns (Position memory) {\\n return _latestPosition(product);\\n }\\n\\n /**\\n * @notice Product pre-position and position after settle\\n * @param product Product address\\n * @return Product pre-position\\n * @return Product position\\n */\\n function globalPosition(IProduct product) public settle(product) returns (PrePosition memory, Position memory) {\\n return (product.pre(), _latestPosition(product));\\n }\\n\\n /**\\n * @notice Current price of product after settle\\n * @param product Product address\\n * @return Product latest price\\n */\\n function latestVersion(IProduct product) public settle(product) returns (IOracleProvider.OracleVersion memory) {\\n return _latestVersion(product);\\n }\\n\\n /**\\n * @notice Prices of product at specified versions after settle\\n * @param product Product address\\n * @param versions Oracle versions to query\\n * @return prices Product prices at specified versions\\n */\\n function atVersions(IProduct product, uint256[] memory versions)\\n public\\n settle(product)\\n returns (IOracleProvider.OracleVersion[] memory prices)\\n {\\n prices = new IOracleProvider.OracleVersion[](versions.length);\\n for (uint256 i = 0; i < versions.length; i++) {\\n prices[i] = product.atVersion(versions[i]);\\n }\\n }\\n\\n /**\\n * @notice Product funding rate after settle\\n * @param product Product address\\n * @return Product current funding rate\\n */\\n function rate(IProduct product) public settle(product) returns (Fixed18) {\\n Position memory position_ = _latestPosition(product);\\n return product.rate(position_);\\n }\\n\\n /**\\n * @notice Product funding extrapolated to a daily rate after settle\\n * @param product Product address\\n * @return Product current funding extrapolated to a daily rate\\n */\\n function dailyRate(IProduct product) public settle(product) returns (Fixed18) {\\n Position memory position_ = _latestPosition(product);\\n return product.rate(position_).mul(Fixed18Lib.from(60 * 60 * 24));\\n }\\n\\n /**\\n * @notice Fees accumulated by product and protocol treasuries after settle\\n * @param product Product address\\n * @return protocolFees fees accrued by the protocol\\n * @return productFees fees accrued by the product owner\\n */\\n function fees(IProduct product) public settle(product) returns (UFixed18 protocolFees, UFixed18 productFees) {\\n address protocolTreasury = controller.treasury();\\n address productTreasury = controller.treasury(product);\\n\\n protocolFees = collateral().fees(protocolTreasury);\\n productFees = collateral().fees(productTreasury);\\n }\\n\\n /**\\n * @notice Product total open interest after settle\\n * @param product Product address\\n * @return Product maker and taker position multiplied by latest price after settle\\n */\\n function openInterest(IProduct product) public settle(product) returns (Position memory) {\\n return _latestPosition(product).mul(_latestVersion(product).price.abs());\\n }\\n\\n /**\\n * End Product Individual Fields Functions\\n */\\n\\n /**\\n * UserProduct Individual Fields Functions\\n */\\n\\n /**\\n * @notice User collateral amount for product after settle\\n * @param account Account address\\n * @param product Product address\\n * @return User deposited collateral for product\\n */\\n function collateral(address account, IProduct product) public settleAccount(account, product) returns (UFixed18) {\\n return collateral().collateral(account, product);\\n }\\n\\n /**\\n * @notice User maintenance amount for product after settle\\n * @param account Account address\\n * @param product Product address\\n * @return Maximum of user maintenance, and maintenanceNext\\n */\\n function maintenance(address account, IProduct product) public settleAccount(account, product) returns (UFixed18) {\\n return UFixed18Lib.max(product.maintenance(account), product.maintenanceNext(account));\\n }\\n\\n /**\\n * @notice User liquidatble status for product after settle\\n * @param account Account address\\n * @param product Product address\\n * @return Whether or not the user's position eligible to be liquidated\\n */\\n function liquidatable(address account, IProduct product) public settleAccount(account, product) returns (bool) {\\n return collateral().liquidatable(account, product);\\n }\\n\\n /**\\n * @notice User liquidating status for product after settle\\n * @param account Account address\\n * @param product Product address\\n * @return Whether or not the user's position is being liquidated\\n */\\n function liquidating(address account, IProduct product) public settleAccount(account, product) returns (bool) {\\n return product.isLiquidating(account);\\n }\\n\\n /**\\n * @notice User pre position for product after settle\\n * @param account Account address\\n * @param product Product address\\n * @return User pre-position\\n */\\n function pre(address account, IProduct product)\\n public\\n settleAccount(account, product)\\n returns (PrePosition memory)\\n {\\n return product.pre(account);\\n }\\n\\n /**\\n * @notice User position for product after settle\\n * @param account Account address\\n * @param product Product address\\n * @return User position\\n */\\n function position(address account, IProduct product)\\n public\\n settleAccount(account, product)\\n returns (Position memory)\\n {\\n return product.position(account);\\n }\\n\\n /**\\n * @notice User pre-position and position for product after settle\\n * @param account Account address\\n * @param product Product address\\n * @return User pre-position\\n * @return User position\\n */\\n function userPosition(address account, IProduct product)\\n public\\n settleAccount(account, product)\\n returns (PrePosition memory, Position memory)\\n {\\n return (product.pre(account), product.position(account));\\n }\\n\\n /**\\n * @notice Fees accumulated by account after settle\\n * @param account Account address\\n * @param product Product address\\n * @return sum of all fees accrued by the account\\n */\\n function fees(address account, IProduct product) public settleAccount(account, product) returns (UFixed18) {\\n return collateral().fees(account);\\n }\\n\\n /**\\n * @notice User's open interest in product after settle\\n * @param account Account address\\n * @param product Product address\\n * @return User's maker or taker position multiplied by latest price after settle\\n */\\n function openInterest(address account, IProduct product)\\n public\\n settleAccount(account, product)\\n returns (Position memory)\\n {\\n return product.position(account).mul(_latestVersion(product).price.abs());\\n }\\n\\n /**\\n * @notice User's exposure in product after settle\\n * @param account Account address\\n * @param product Product address\\n * @return User's exposure (openInterest * utilization) after settle\\n */\\n function exposure(address account, IProduct product) public settleAccount(account, product) returns (UFixed18) {\\n (, Position memory _pos) = globalPosition(product);\\n if (_pos.maker.isZero()) { return UFixed18Lib.ZERO; }\\n\\n Position memory _openInterest = openInterest(account, product);\\n if (!_openInterest.taker.isZero()) {\\n return _openInterest.taker; // Taker exposure is always 100% of openInterest\\n }\\n\\n UFixed18 utilization = _pos.taker.div(_pos.maker);\\n return utilization.mul(_openInterest.maker); // Maker exposure is openInterest * utilization\\n }\\n\\n /**\\n * @notice User's maintenance required for position size in product after settle\\n * @param account Account address\\n * @param product Product address\\n * @param positionSize size of position for maintenance calculation\\n * @return Maintenance required for position in product\\n */\\n function maintenanceRequired(\\n address account,\\n IProduct product,\\n UFixed18 positionSize\\n ) public settleAccount(account, product) returns (UFixed18) {\\n UFixed18 notional = positionSize.mul(_latestVersion(product).price.abs());\\n return notional.mul(product.maintenance());\\n }\\n\\n /**\\n * @notice User's unclaimed rewards for all programs for product after settle\\n * @param account Account address\\n * @param product Product address\\n * @return tokens Token addresses of unclaimed incentive rewards for given product\\n * @return amounts Token amounts of unclaimed incentive rewards for given product\\n */\\n function unclaimedIncentiveRewards(address account, IProduct product)\\n public\\n settleAccount(account, product)\\n returns (Token18[] memory tokens, UFixed18[] memory amounts)\\n {\\n IIncentivizer incentivizer = controller.incentivizer();\\n\\n uint256 programsLength = incentivizer.count(product);\\n tokens = new Token18[](programsLength);\\n amounts = new UFixed18[](programsLength);\\n for (uint256 i = 0; i < programsLength; i++) {\\n ProgramInfo memory programInfo = incentivizer.programInfos(product, i);\\n tokens[i] = programInfo.token;\\n amounts[i] = incentivizer.unclaimed(product, account, i);\\n }\\n }\\n\\n /**\\n * @notice User's unclaimed rewards for provided programs for product after settle\\n * @param account Account address\\n * @param product Product address\\n * @param programIds Program IDs to query\\n * @return tokens Token addresses of unclaimed incentive rewards for given program IDs\\n * @return amounts Token amounts of unclaimed incentive rewards for given program IDs\\n */\\n function unclaimedIncentiveRewards(\\n address account,\\n IProduct product,\\n uint256[] calldata programIds\\n ) public settleAccount(account, product) returns (Token18[] memory tokens, UFixed18[] memory amounts) {\\n IIncentivizer incentivizer = controller.incentivizer();\\n tokens = new Token18[](programIds.length);\\n amounts = new UFixed18[](programIds.length);\\n for (uint256 i = 0; i < programIds.length; i++) {\\n ProgramInfo memory programInfo = incentivizer.programInfos(product, programIds[i]);\\n tokens[i] = programInfo.token;\\n amounts[i] = incentivizer.unclaimed(product, account, programIds[i]);\\n }\\n }\\n\\n /**\\n * End UserProduct Individual Fields Functions\\n */\\n\\n /**\\n * Private Helper Functions\\n */\\n\\n /**\\n * @notice Returns the Product's latest position\\n * @dev Private function, does not call settle itself\\n * @param product Product address\\n * @return Latest position for the product\\n */\\n function _latestPosition(IProduct product) private view returns (Position memory) {\\n return product.positionAtVersion(product.latestVersion());\\n }\\n\\n /**\\n * @notice Returns the Product's latest version\\n * @dev Private function, does not call settle itself\\n * @param product Product address\\n * @return Latest version for the product\\n */\\n function _latestVersion(IProduct product) private view returns (IOracleProvider.OracleVersion memory) {\\n return product.atVersion(product.latestVersion());\\n }\\n\\n /**\\n * End Private Helper Functions\\n */\\n\\n /**\\n * Modifier Functions\\n */\\n\\n /// @dev Settles the product\\n modifier settle(IProduct product) {\\n product.settle();\\n _;\\n }\\n\\n /// @dev Settles the product. product.settleAccount also settles the product\\n modifier settleAccount(address account, IProduct product) {\\n product.settleAccount(account);\\n _;\\n }\\n\\n /**\\n * End Modifier Functions\\n */\\n}\\n\",\"keccak256\":\"0x5478ea94c64a9760090faecaffbe6cba8bf531a00d2baefd8ed08e7f78593389\",\"license\":\"Apache-2.0\"}},\"version\":1}", - "bytecode": "0x60a06040523480156200001157600080fd5b506040516200479938038062004799833981016040819052620000349162000046565b6001600160a01b031660805262000078565b6000602082840312156200005957600080fd5b81516001600160a01b03811681146200007157600080fd5b9392505050565b6080516146e2620000b76000396000818161052e015281816117d60152818161268b01528181612a3b01528181612dca0152612ea201526146e26000f3fe608060405234801561001057600080fd5b506004361061020b5760003560e01c80638f5edc081161012a578063b7a98f97116100bd578063edd8ca7b1161008c578063f77c479111610071578063f77c479114610529578063f8083f5614610550578063faaebd211461056357600080fd5b8063edd8ca7b14610503578063f5c06e1b1461051657600080fd5b8063b7a98f971461049d578063cc218ece146104b0578063d8dfeb45146104c3578063e9c6b4c1146104f057600080fd5b8063a5fdc5de116100f9578063a5fdc5de14610444578063a86e357614610457578063b4d6f7811461046a578063b7648fb91461047d57600080fd5b80638f5edc08146103de5780639b9ac2cb146103fe5780639bc02857146104115780639be2a5671461043157600080fd5b806337e710ac116101a25780637e64cc13116101715780637e64cc131461036757806382df39de146103885780638e076924146103ab5780638e480b20146103be57600080fd5b806337e710ac1461030e578063540027e6146103215780636878353e146103345780636efef0851461034757600080fd5b80631e0c6fb9116101de5780631e0c6fb91461029b578063204e94b0146102bb578063237e5899146102db57806326512160146102ee57600080fd5b80630198489214610210578063036790c0146102395780630aae7a6b1461025a5780630ba9d8ca1461027a575b600080fd5b61022361021e36600461363e565b61058b565b60405161023091906136d5565b60405180910390f35b61024c61024736600461363e565b610624565b6040516102309291906136e8565b61026d61026836600461363e565b610723565b60405161023091906138af565b61028d61028836600461363e565b610b37565b604051908152602001610230565b6102ae6102a936600461363e565b610c43565b60405161023091906138c2565b6102ce6102c93660046138f8565b610d22565b6040516102309190613a2e565b61028d6102e93660046138f8565b610e67565b6103016102fc36600461363e565b610f6f565b6040516102309190613b6e565b61028d61031c3660046138f8565b611104565b61028d61032f36600461363e565b6112bf565b61024c6103423660046138f8565b6113d7565b61035a610355366004613c4c565b6115a2565b6040516102309190613cf7565b61037a6103753660046138f8565b611748565b604051610230929190613d59565b61039b6103963660046138f8565b611b2e565b6040519015158152602001610230565b61028d6103b9366004613dea565b611c5a565b6103d16103cc36600461363e565b611d8a565b6040516102309190613e2b565b6103f16103ec366004613e4c565b611e18565b6040516102309190613eec565b61028d61040c3660046138f8565b611ed6565b61042461041f366004613f7b565b611ffa565b6040516102309190613fbd565b6102ae61043f3660046138f8565b6120b6565b61028d61045236600461363e565b6121d3565b61022361046536600461363e565b6122d1565b61028d61047836600461363e565b61231e565b61049061048b36600461363e565b6123df565b604051610230919061403d565b6104906104ab3660046138f8565b61245d565b61028d6104be3660046138f8565b612598565b6104cb612687565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610230565b6104906104fe3660046138f8565b61271d565b61049061051136600461363e565b612843565b61039b6105243660046138f8565b6128d0565b6104cb7f000000000000000000000000000000000000000000000000000000000000000081565b61037a61055e366004614054565b6129ad565b61057661057136600461363e565b612d62565b60408051928352602083019190915201610230565b60608173ffffffffffffffffffffffffffffffffffffffff166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa1580156105d8573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405261061e91908101906140b9565b92915050565b61062c613357565b6040805180820190915260008082526020820152828073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561068957600080fd5b505af115801561069d573d6000803e3d6000fd5b505050508373ffffffffffffffffffffffffffffffffffffffff166359ea287d6040518163ffffffff1660e01b815260040160a060405180830381865afa1580156106ec573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061071091906141ba565b6107198561304f565b9250925050915091565b61072b6133ad565b6107348261058b565b815261073f826122d1565b81602001819052508173ffffffffffffffffffffffffffffffffffffffff166305d5c1cb6040518163ffffffff1660e01b8152600401606060405180830381865afa158015610792573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107b6919061422e565b81604001819052508173ffffffffffffffffffffffffffffffffffffffff16637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610809573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061082d919061429b565b816060019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508173ffffffffffffffffffffffffffffffffffffffff16636c376cc56040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108d391906142b8565b8160800181815250508173ffffffffffffffffffffffffffffffffffffffff16635d16e1206040518163ffffffff1660e01b8152600401602060405180830381865afa158015610927573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061094b91906142b8565b8160a00181815250508173ffffffffffffffffffffffffffffffffffffffff1663fc741c7c6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561099f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109c391906142b8565b8160c00181815250508173ffffffffffffffffffffffffffffffffffffffff166343f0179b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a3b91906142b8565b8160e00181815250508173ffffffffffffffffffffffffffffffffffffffff1663193775676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a8f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ab391906142b8565b816101000181815250508173ffffffffffffffffffffffffffffffffffffffff1663a12e1b336040518163ffffffff1660e01b8152600401608060405180830381865afa158015610b08573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2c91906142e8565b610120820152919050565b6000818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610b8257600080fd5b505af1158015610b96573d6000803e3d6000fd5b505050506000610ba58461304f565b6040517f60ec91d600000000000000000000000000000000000000000000000000000000815290915073ffffffffffffffffffffffffffffffffffffffff8516906360ec91d690610bfa90849060040161403d565b602060405180830381865afa158015610c17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c3b91906142b8565b949350505050565b610c4b613357565b818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610c9457600080fd5b505af1158015610ca8573d6000803e3d6000fd5b505050508273ffffffffffffffffffffffffffffffffffffffff166359ea287d6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610cf7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d1b91906141ba565b9392505050565b610d2a613477565b6040517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80851660048301528491849182169063f667f89790602401600060405180830381600087803b158015610d9757600080fd5b505af1158015610dab573d6000803e3d6000fd5b50505073ffffffffffffffffffffffffffffffffffffffff80861685528616602085015250610dda8585612598565b6040840152610de98585611104565b6060840152610df885856120b6565b6080840152610e07858561271d565b60a0840152610e168585611b2e565b151560c0840152610e2785856128d0565b151560e0840152610e38858561245d565b610100840152610e488585611ed6565b610120840152610e588585610e67565b61014084015250909392505050565b6040517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8084166004830152600091849184919082169063f667f89790602401600060405180830381600087803b158015610ed857600080fd5b505af1158015610eec573d6000803e3d6000fd5b505050506000610efb85610624565b805190925015905015610f12576000935050610f67565b6000610f1e878761245d565b9050610f2c81602001511590565b610f3d57602001519350610f679050565b81516020830151600091610f51919061314c565b8251909150610f6190829061316b565b95505050505b505092915050565b610f7761353d565b818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610fc057600080fd5b505af1158015610fd4573d6000803e3d6000fd5b50505050610fe183610723565b825273ffffffffffffffffffffffffffffffffffffffff8316602083015261100883610b37565b6040830152611016836112bf565b606083015261102483611d8a565b82608001819052508273ffffffffffffffffffffffffffffffffffffffff16636c376cc56040518163ffffffff1660e01b8152600401602060405180830381865afa158015611077573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061109b91906142b8565b60a08301526110a9836121d3565b60c08301526110b78361231e565b60e08301526110c583610c43565b6101008301526110d4836123df565b6101208301526110e383612d62565b6101608401526101408301526110f883612843565b61018083015250919050565b6040517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8084166004830152600091849184919082169063f667f89790602401600060405180830381600087803b15801561117557600080fd5b505af1158015611189573d6000803e3d6000fd5b50506040517f9168902400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88811660048301526112b6935087169150639168902490602401602060405180830381865afa1580156111fd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061122191906142b8565b6040517fab582f2900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff888116600483015287169063ab582f2990602401602060405180830381865afa15801561128d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112b191906142b8565b613180565b95945050505050565b6000818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561130a57600080fd5b505af115801561131e573d6000803e3d6000fd5b50505050600061132d8461304f565b9050610c3b61133e6201518061318c565b6040517f60ec91d600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8716906360ec91d69061139090869060040161403d565b602060405180830381865afa1580156113ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113d191906142b8565b906131a0565b6113df613357565b6040805180820182526000808252602082015290517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301528591859182169063f667f89790602401600060405180830381600087803b15801561145e57600080fd5b505af1158015611472573d6000803e3d6000fd5b50506040517f1e0c6fb900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff898116600483015288169250631e0c6fb9915060240160a060405180830381865afa1580156114e2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061150691906141ba565b6040517fb7648fb900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff888116600483015287169063b7648fb9906024016040805180830381865afa158015611571573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611595919061437c565b9350935050509250929050565b6060828073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156115ed57600080fd5b505af1158015611601573d6000803e3d6000fd5b50505050825167ffffffffffffffff81111561161f5761161f613b81565b60405190808252806020026020018201604052801561167457816020015b61166160405180606001604052806000815260200160008152602001600081525090565b81526020019060019003908161163d5790505b50915060005b8351811015610f67578473ffffffffffffffffffffffffffffffffffffffff16637ece075d8583815181106116b1576116b1614398565b60200260200101516040518263ffffffff1660e01b81526004016116d791815260200190565b606060405180830381865afa1580156116f4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061171891906143c7565b83828151811061172a5761172a614398565b6020026020010181905250808061174090614432565b91505061167a565b6040517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff808416600483015260609182918591859182169063f667f89790602401600060405180830381600087803b1580156117ba57600080fd5b505af11580156117ce573d6000803e3d6000fd5b5050505060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16636fc6407c6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561183f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611863919061429b565b6040517f05d85eda00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88811660048301529192506000918316906305d85eda90602401602060405180830381865afa1580156118d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118f991906142b8565b90508067ffffffffffffffff81111561191457611914613b81565b60405190808252806020026020018201604052801561193d578160200160208202803683370190505b5095508067ffffffffffffffff81111561195957611959613b81565b604051908082528060200260200182016040528015611982578160200160208202803683370190505b50945060005b81811015611b22576040517f2c3e50e500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff89811660048301526024820183905260009190851690632c3e50e59060440160c060405180830381865afa158015611a07573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a2b919061446a565b90508060800151888381518110611a4457611a44614398565b73ffffffffffffffffffffffffffffffffffffffff92831660209182029290920101526040517f66f8162e0000000000000000000000000000000000000000000000000000000081528a821660048201528b8216602482015260448101849052908516906366f8162e90606401602060405180830381865afa158015611ace573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611af291906142b8565b878381518110611b0457611b04614398565b60209081029190910101525080611b1a81614432565b915050611988565b50505050509250929050565b6040517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8084166004830152600091849184919082169063f667f89790602401600060405180830381600087803b158015611b9f57600080fd5b505af1158015611bb3573d6000803e3d6000fd5b50505050611bbf612687565b6040517f82df39de00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8781166004830152868116602483015291909116906382df39de906044015b602060405180830381865afa158015611c36573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112b691906144e6565b6040517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8085166004830152600091859185919082169063f667f89790602401600060405180830381600087803b158015611ccb57600080fd5b505af1158015611cdf573d6000803e3d6000fd5b505050506000611d04611cfd611cf4886131bf565b604001516132cd565b869061316b565b9050611d7f8673ffffffffffffffffffffffffffffffffffffffff16636c376cc56040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d54573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d7891906142b8565b829061316b565b979650505050505050565b611dae60405180606001604052806000815260200160008152602001600081525090565b818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611df757600080fd5b505af1158015611e0b573d6000803e3d6000fd5b50505050610d1b836131bf565b6060815167ffffffffffffffff811115611e3457611e34613b81565b604051908082528060200260200182016040528015611e6d57816020015b611e5a613477565b815260200190600190039081611e525790505b50905060005b8251811015611ecf57611e9f84848381518110611e9257611e92614398565b6020026020010151610d22565b828281518110611eb157611eb1614398565b60200260200101819052508080611ec790614432565b915050611e73565b5092915050565b6040517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8084166004830152600091849184919082169063f667f89790602401600060405180830381600087803b158015611f4757600080fd5b505af1158015611f5b573d6000803e3d6000fd5b50505050611f67612687565b6040517ffaaebd2100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8781166004830152919091169063faaebd21906024015b602060405180830381865afa158015611fd6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112b691906142b8565b60608167ffffffffffffffff81111561201557612015613b81565b60405190808252806020026020018201604052801561204e57816020015b61203b61353d565b8152602001906001900390816120335790505b50905060005b82811015611ecf5761208684848381811061207157612071614398565b90506020020160208101906102fc919061363e565b82828151811061209857612098614398565b602002602001018190525080806120ae90614432565b915050612054565b6120be613357565b6040517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80851660048301528491849182169063f667f89790602401600060405180830381600087803b15801561212b57600080fd5b505af115801561213f573d6000803e3d6000fd5b50506040517f1e0c6fb900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff888116600483015287169250631e0c6fb9915060240160a060405180830381865afa1580156121af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112b691906141ba565b6000818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561221e57600080fd5b505af1158015612232573d6000803e3d6000fd5b5050505061223e612687565b6040517fa5fdc5de00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8581166004830152919091169063a5fdc5de906024015b602060405180830381865afa1580156122ad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d1b91906142b8565b60608173ffffffffffffffffffffffffffffffffffffffff166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa1580156105d8573d6000803e3d6000fd5b6000818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561236957600080fd5b505af115801561237d573d6000803e3d6000fd5b50505050612389612687565b6040517fb4d6f78100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8581166004830152919091169063b4d6f78190602401612290565b6040805180820190915260008082526020820152818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561243c57600080fd5b505af1158015612450573d6000803e3d6000fd5b50505050610d1b8361304f565b6040805180820182526000808252602082015290517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301528491849182169063f667f89790602401600060405180830381600087803b1580156124dc57600080fd5b505af11580156124f0573d6000803e3d6000fd5b505050506112b6612503611cf4866131bf565b6040517fb7648fb900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff888116600483015287169063b7648fb9906024016040805180830381865afa15801561256e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612592919061437c565b906132d8565b6040517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8084166004830152600091849184919082169063f667f89790602401600060405180830381600087803b15801561260957600080fd5b505af115801561261d573d6000803e3d6000fd5b50505050612629612687565b6040517fcc218ece00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff87811660048301528681166024830152919091169063cc218ece90604401611fb9565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa1580156126f4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612718919061429b565b905090565b6040805180820182526000808252602082015290517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301528491849182169063f667f89790602401600060405180830381600087803b15801561279c57600080fd5b505af11580156127b0573d6000803e3d6000fd5b50506040517fb7648fb900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88811660048301528716925063b7648fb991506024016040805180830381865afa15801561281f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112b6919061437c565b6040805180820190915260008082526020820152818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156128a057600080fd5b505af11580156128b4573d6000803e3d6000fd5b50505050610d1b6128c7611cf4856131bf565b6125928561304f565b6040517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8084166004830152600091849184919082169063f667f89790602401600060405180830381600087803b15801561294157600080fd5b505af1158015612955573d6000803e3d6000fd5b50506040517f58ca6f9800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8881166004830152871692506358ca6f989150602401611c19565b6040517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff808616600483015260609182918791879182169063f667f89790602401600060405180830381600087803b158015612a1f57600080fd5b505af1158015612a33573d6000803e3d6000fd5b5050505060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16636fc6407c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612aa4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ac8919061429b565b90508567ffffffffffffffff811115612ae357612ae3613b81565b604051908082528060200260200182016040528015612b0c578160200160208202803683370190505b5094508567ffffffffffffffff811115612b2857612b28613b81565b604051908082528060200260200182016040528015612b51578160200160208202803683370190505b50935060005b86811015612d555760008273ffffffffffffffffffffffffffffffffffffffff16632c3e50e58b8b8b86818110612b9057612b90614398565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e087901b16815273ffffffffffffffffffffffffffffffffffffffff9094166004850152602002919091013560248301525060440160c060405180830381865afa158015612c07573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c2b919061446a565b90508060800151878381518110612c4457612c44614398565b73ffffffffffffffffffffffffffffffffffffffff928316602091820292909201015283166366f8162e8b8d8c8c87818110612c8257612c82614398565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e088901b16815273ffffffffffffffffffffffffffffffffffffffff958616600482015294909316602485015250602090910201356044820152606401602060405180830381865afa158015612d01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d2591906142b8565b868381518110612d3757612d37614398565b60209081029190910101525080612d4d81614432565b915050612b57565b5050505094509492505050565b600080828073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b158015612dae57600080fd5b505af1158015612dc2573d6000803e3d6000fd5b5050505060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015612e33573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e57919061429b565b6040517f2d809cb600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff87811660048301529192506000917f00000000000000000000000000000000000000000000000000000000000000001690632d809cb690602401602060405180830381865afa158015612ee9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f0d919061429b565b9050612f17612687565b6040517ffaaebd2100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8481166004830152919091169063faaebd2190602401602060405180830381865afa158015612f85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fa991906142b8565b9450612fb3612687565b6040517ffaaebd2100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8381166004830152919091169063faaebd2190602401602060405180830381865afa158015613021573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061304591906142b8565b9350505050915091565b60408051808201909152600080825260208201528173ffffffffffffffffffffffffffffffffffffffff16639a427d038373ffffffffffffffffffffffffffffffffffffffff1663c07f47d46040518163ffffffff1660e01b8152600401602060405180830381865afa1580156130ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130ee91906142b8565b6040518263ffffffff1660e01b815260040161310c91815260200190565b6040805180830381865afa158015613128573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061061e919061437c565b600081613161670de0b6b3a764000085614508565b610d1b9190614574565b6000670de0b6b3a76400006131618385614508565b6000610d1b8383613329565b600061061e670de0b6b3a764000083614588565b6000670de0b6b3a76400006131b58385614588565b610d1b9190614644565b6131e360405180606001604052806000815260200160008152602001600081525090565b8173ffffffffffffffffffffffffffffffffffffffff16637ece075d8373ffffffffffffffffffffffffffffffffffffffff1663c07f47d46040518163ffffffff1660e01b8152600401602060405180830381865afa15801561324a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061326e91906142b8565b6040518263ffffffff1660e01b815260040161328c91815260200190565b606060405180830381865afa1580156132a9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061061e91906143c7565b600061061e82613340565b60408051808201909152600080825260208201526040805180820190915283518190613304908561316b565b815260200161332084866020015161316b90919063ffffffff16565b90529392505050565b6000818310156133395781610d1b565b5090919050565b600080821215613353578160000361061e565b5090565b604051806060016040528060008152602001613386604051806040016040528060008152602001600081525090565b81526020016133a8604051806040016040528060008152602001600081525090565b905290565b60405180610140016040528060608152602001606081526020016133ec6040805160608101909152806000815260200160008152600060209091015290565b8152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001600081526020016000815260200160008152602001600081526020016133a860405180608001604052806000600f0b81526020016000600f0b81526020016000600f0b815260200160006fffffffffffffffffffffffffffffffff1681525090565b604051806101600160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001600081526020016134d3613357565b81526020016134f5604051806040016040528060008152602001600081525090565b8152602001600015158152602001600015158152602001613529604051806040016040528060008152602001600081525090565b815260200160008152602001600081525090565b604051806101a001604052806135516133ad565b8152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001600081526020016135a560405180606001604052806000815260200160008152602001600081525090565b81526020016000815260200160008152602001600081526020016135c7613357565b81526020016135e9604051806040016040528060008152602001600081525090565b815260200160008152602001600081526020016133a8604051806040016040528060008152602001600081525090565b73ffffffffffffffffffffffffffffffffffffffff8116811461363b57600080fd5b50565b60006020828403121561365057600080fd5b8135610d1b81613619565b60005b8381101561367657818101518382015260200161365e565b83811115613685576000848401525b50505050565b600081518084526136a381602086016020860161365b565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000610d1b602083018461368b565b82518152602080840151805182840152810151604080840191909152840151805160608401520151608082015260e08101825160a0830152602083015160c0830152610d1b565b6002811061363b577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b80516137718161372f565b825260208101516137818161372f565b60208301526040908101517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000016910152565b60006101e082518185526137c98286018261368b565b915050602083015184820360208601526137e3828261368b565b91505060408301516137f86040860182613766565b50606083015173ffffffffffffffffffffffffffffffffffffffff811660a086015250608083015160c085015260a083015160e085015260c0830151610100818187015260e0850151915061012082818801528186015161014088015280860151925050506138a76101608601828051600f0b82526020810151600f0b60208301526040810151600f0b60408301526fffffffffffffffffffffffffffffffff60608201511660608301525050565b509392505050565b602081526000610d1b60208301846137b3565b81518152602080830151805182840152810151604080840191909152830151805160608401520151608082015260a0810161061e565b6000806040838503121561390b57600080fd5b823561391681613619565b9150602083013561392681613619565b809150509250929050565b805173ffffffffffffffffffffffffffffffffffffffff1682526020810151613972602084018273ffffffffffffffffffffffffffffffffffffffff169052565b50604081015160408301526060810151606083015260808101516139c560808401828051825260208082015180518285015290810151604084015250604001518051606083015260200151608090910152565b5060a08101516101206139e48185018380518252602090810151910152565b60c0830151151561016085015260e0830151151561018085015261010083015180516101a0860152602001516101c08501528201516101e084015250610140015161020090910152565b610220810161061e8284613931565b60006102a08251818552613a53828601826137b3565b9150506020830151613a7d602086018273ffffffffffffffffffffffffffffffffffffffff169052565b5060408301516040850152606083015160608501526080830151613ab860808601828051825260208082015190830152604090810151910152565b5060a083015160e085015260c0830151610100818187015260e0850151915061012082818801528186015192506101409150613b22828801848051825260208082015180518285015290810151604084015250604001518051606083015260200151608090910152565b85015180516101e08801526020810151610200880152915084015161022086015250610160830151610240850152610180830151805161026086015260208101516102808601526138a7565b602081526000610d1b6020830184613a3d565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516060810167ffffffffffffffff81118282101715613bd357613bd3613b81565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715613c2057613c20613b81565b604052919050565b600067ffffffffffffffff821115613c4257613c42613b81565b5060051b60200190565b60008060408385031215613c5f57600080fd5b8235613c6a81613619565b915060208381013567ffffffffffffffff811115613c8757600080fd5b8401601f81018613613c9857600080fd5b8035613cab613ca682613c28565b613bd9565b81815260059190911b82018301908381019088831115613cca57600080fd5b928401925b82841015613ce857833582529284019290840190613ccf565b80955050505050509250929050565b6020808252825182820181905260009190848201906040850190845b81811015613d4d57613d3a8385518051825260208082015190830152604090810151910152565b9284019260609290920191600101613d13565b50909695505050505050565b604080825283519082018190526000906020906060840190828701845b82811015613da857815173ffffffffffffffffffffffffffffffffffffffff1684529284019290840190600101613d76565b5050508381038285015284518082528583019183019060005b81811015613ddd57835183529284019291840191600101613dc1565b5090979650505050505050565b600080600060608486031215613dff57600080fd5b8335613e0a81613619565b92506020840135613e1a81613619565b929592945050506040919091013590565b8151815260208083015190820152604080830151908201526060810161061e565b60008060408385031215613e5f57600080fd5b8235613e6a81613619565b915060208381013567ffffffffffffffff811115613e8757600080fd5b8401601f81018613613e9857600080fd5b8035613ea6613ca682613c28565b81815260059190911b82018301908381019088831115613ec557600080fd5b928401925b82841015613ce8578335613edd81613619565b82529284019290840190613eca565b6020808252825182820181905260009190848201906040850190845b81811015613d4d57613f1b838551613931565b928401926102209290920191600101613f08565b60008083601f840112613f4157600080fd5b50813567ffffffffffffffff811115613f5957600080fd5b6020830191508360208260051b8501011115613f7457600080fd5b9250929050565b60008060208385031215613f8e57600080fd5b823567ffffffffffffffff811115613fa557600080fd5b613fb185828601613f2f565b90969095509350505050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015614030577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc088860301845261401e858351613a3d565b94509285019290850190600101613fe4565b5092979650505050505050565b81518152602080830151908201526040810161061e565b6000806000806060858703121561406a57600080fd5b843561407581613619565b9350602085013561408581613619565b9250604085013567ffffffffffffffff8111156140a157600080fd5b6140ad87828801613f2f565b95989497509550505050565b6000602082840312156140cb57600080fd5b815167ffffffffffffffff808211156140e357600080fd5b818401915084601f8301126140f757600080fd5b81518181111561410957614109613b81565b61413a60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601613bd9565b915080825285602082850101111561415157600080fd5b61416281602084016020860161365b565b50949350505050565b60006040828403121561417d57600080fd5b6040516040810181811067ffffffffffffffff821117156141a0576141a0613b81565b604052825181526020928301519281019290925250919050565b600060a082840312156141cc57600080fd5b6040516060810181811067ffffffffffffffff821117156141ef576141ef613b81565b60405282518152614203846020850161416b565b6020820152614215846060850161416b565b60408201529392505050565b6002811061363b57600080fd5b60006060828403121561424057600080fd5b614248613bb0565b825161425381614221565b8152602083015161426381614221565b602082015260408301517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00008116811461421557600080fd5b6000602082840312156142ad57600080fd5b8151610d1b81613619565b6000602082840312156142ca57600080fd5b5051919050565b8051600f81900b81146142e357600080fd5b919050565b6000608082840312156142fa57600080fd5b6040516080810181811067ffffffffffffffff8211171561431d5761431d613b81565b604052614329836142d1565b8152614337602084016142d1565b6020820152614348604084016142d1565b604082015260608301516fffffffffffffffffffffffffffffffff8116811461437057600080fd5b60608201529392505050565b60006040828403121561438e57600080fd5b610d1b838361416b565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000606082840312156143d957600080fd5b6143e1613bb0565b8251815260208301516020820152604083015160408201528091505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361446357614463614403565b5060010190565b600060c0828403121561447c57600080fd5b60405160a0810181811067ffffffffffffffff8211171561449f5761449f613b81565b604052825181526144b3846020850161416b565b6020820152606083015160408201526080830151606082015260a08301516144da81613619565b60808201529392505050565b6000602082840312156144f857600080fd5b81518015158114610d1b57600080fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561454057614540614403565b500290565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60008261458357614583614545565b500490565b60007f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000841360008413858304851182821616156145c9576145c9614403565b7f8000000000000000000000000000000000000000000000000000000000000000600087128682058812818416161561460457614604614403565b6000871292508782058712848416161561462057614620614403565b8785058712818416161561463657614636614403565b505050929093029392505050565b60008261465357614653614545565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83147f8000000000000000000000000000000000000000000000000000000000000000831416156146a7576146a7614403565b50059056fea26469706673582212206db77c0d984546687817814f74442aaf51c5a60c503137ad38573cdbc56fa1f664736f6c634300080f0033", - "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061020b5760003560e01c80638f5edc081161012a578063b7a98f97116100bd578063edd8ca7b1161008c578063f77c479111610071578063f77c479114610529578063f8083f5614610550578063faaebd211461056357600080fd5b8063edd8ca7b14610503578063f5c06e1b1461051657600080fd5b8063b7a98f971461049d578063cc218ece146104b0578063d8dfeb45146104c3578063e9c6b4c1146104f057600080fd5b8063a5fdc5de116100f9578063a5fdc5de14610444578063a86e357614610457578063b4d6f7811461046a578063b7648fb91461047d57600080fd5b80638f5edc08146103de5780639b9ac2cb146103fe5780639bc02857146104115780639be2a5671461043157600080fd5b806337e710ac116101a25780637e64cc13116101715780637e64cc131461036757806382df39de146103885780638e076924146103ab5780638e480b20146103be57600080fd5b806337e710ac1461030e578063540027e6146103215780636878353e146103345780636efef0851461034757600080fd5b80631e0c6fb9116101de5780631e0c6fb91461029b578063204e94b0146102bb578063237e5899146102db57806326512160146102ee57600080fd5b80630198489214610210578063036790c0146102395780630aae7a6b1461025a5780630ba9d8ca1461027a575b600080fd5b61022361021e36600461363e565b61058b565b60405161023091906136d5565b60405180910390f35b61024c61024736600461363e565b610624565b6040516102309291906136e8565b61026d61026836600461363e565b610723565b60405161023091906138af565b61028d61028836600461363e565b610b37565b604051908152602001610230565b6102ae6102a936600461363e565b610c43565b60405161023091906138c2565b6102ce6102c93660046138f8565b610d22565b6040516102309190613a2e565b61028d6102e93660046138f8565b610e67565b6103016102fc36600461363e565b610f6f565b6040516102309190613b6e565b61028d61031c3660046138f8565b611104565b61028d61032f36600461363e565b6112bf565b61024c6103423660046138f8565b6113d7565b61035a610355366004613c4c565b6115a2565b6040516102309190613cf7565b61037a6103753660046138f8565b611748565b604051610230929190613d59565b61039b6103963660046138f8565b611b2e565b6040519015158152602001610230565b61028d6103b9366004613dea565b611c5a565b6103d16103cc36600461363e565b611d8a565b6040516102309190613e2b565b6103f16103ec366004613e4c565b611e18565b6040516102309190613eec565b61028d61040c3660046138f8565b611ed6565b61042461041f366004613f7b565b611ffa565b6040516102309190613fbd565b6102ae61043f3660046138f8565b6120b6565b61028d61045236600461363e565b6121d3565b61022361046536600461363e565b6122d1565b61028d61047836600461363e565b61231e565b61049061048b36600461363e565b6123df565b604051610230919061403d565b6104906104ab3660046138f8565b61245d565b61028d6104be3660046138f8565b612598565b6104cb612687565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610230565b6104906104fe3660046138f8565b61271d565b61049061051136600461363e565b612843565b61039b6105243660046138f8565b6128d0565b6104cb7f000000000000000000000000000000000000000000000000000000000000000081565b61037a61055e366004614054565b6129ad565b61057661057136600461363e565b612d62565b60408051928352602083019190915201610230565b60608173ffffffffffffffffffffffffffffffffffffffff166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa1580156105d8573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405261061e91908101906140b9565b92915050565b61062c613357565b6040805180820190915260008082526020820152828073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561068957600080fd5b505af115801561069d573d6000803e3d6000fd5b505050508373ffffffffffffffffffffffffffffffffffffffff166359ea287d6040518163ffffffff1660e01b815260040160a060405180830381865afa1580156106ec573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061071091906141ba565b6107198561304f565b9250925050915091565b61072b6133ad565b6107348261058b565b815261073f826122d1565b81602001819052508173ffffffffffffffffffffffffffffffffffffffff166305d5c1cb6040518163ffffffff1660e01b8152600401606060405180830381865afa158015610792573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107b6919061422e565b81604001819052508173ffffffffffffffffffffffffffffffffffffffff16637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610809573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061082d919061429b565b816060019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508173ffffffffffffffffffffffffffffffffffffffff16636c376cc56040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108d391906142b8565b8160800181815250508173ffffffffffffffffffffffffffffffffffffffff16635d16e1206040518163ffffffff1660e01b8152600401602060405180830381865afa158015610927573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061094b91906142b8565b8160a00181815250508173ffffffffffffffffffffffffffffffffffffffff1663fc741c7c6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561099f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109c391906142b8565b8160c00181815250508173ffffffffffffffffffffffffffffffffffffffff166343f0179b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a3b91906142b8565b8160e00181815250508173ffffffffffffffffffffffffffffffffffffffff1663193775676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a8f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ab391906142b8565b816101000181815250508173ffffffffffffffffffffffffffffffffffffffff1663a12e1b336040518163ffffffff1660e01b8152600401608060405180830381865afa158015610b08573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2c91906142e8565b610120820152919050565b6000818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610b8257600080fd5b505af1158015610b96573d6000803e3d6000fd5b505050506000610ba58461304f565b6040517f60ec91d600000000000000000000000000000000000000000000000000000000815290915073ffffffffffffffffffffffffffffffffffffffff8516906360ec91d690610bfa90849060040161403d565b602060405180830381865afa158015610c17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c3b91906142b8565b949350505050565b610c4b613357565b818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610c9457600080fd5b505af1158015610ca8573d6000803e3d6000fd5b505050508273ffffffffffffffffffffffffffffffffffffffff166359ea287d6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610cf7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d1b91906141ba565b9392505050565b610d2a613477565b6040517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80851660048301528491849182169063f667f89790602401600060405180830381600087803b158015610d9757600080fd5b505af1158015610dab573d6000803e3d6000fd5b50505073ffffffffffffffffffffffffffffffffffffffff80861685528616602085015250610dda8585612598565b6040840152610de98585611104565b6060840152610df885856120b6565b6080840152610e07858561271d565b60a0840152610e168585611b2e565b151560c0840152610e2785856128d0565b151560e0840152610e38858561245d565b610100840152610e488585611ed6565b610120840152610e588585610e67565b61014084015250909392505050565b6040517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8084166004830152600091849184919082169063f667f89790602401600060405180830381600087803b158015610ed857600080fd5b505af1158015610eec573d6000803e3d6000fd5b505050506000610efb85610624565b805190925015905015610f12576000935050610f67565b6000610f1e878761245d565b9050610f2c81602001511590565b610f3d57602001519350610f679050565b81516020830151600091610f51919061314c565b8251909150610f6190829061316b565b95505050505b505092915050565b610f7761353d565b818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610fc057600080fd5b505af1158015610fd4573d6000803e3d6000fd5b50505050610fe183610723565b825273ffffffffffffffffffffffffffffffffffffffff8316602083015261100883610b37565b6040830152611016836112bf565b606083015261102483611d8a565b82608001819052508273ffffffffffffffffffffffffffffffffffffffff16636c376cc56040518163ffffffff1660e01b8152600401602060405180830381865afa158015611077573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061109b91906142b8565b60a08301526110a9836121d3565b60c08301526110b78361231e565b60e08301526110c583610c43565b6101008301526110d4836123df565b6101208301526110e383612d62565b6101608401526101408301526110f883612843565b61018083015250919050565b6040517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8084166004830152600091849184919082169063f667f89790602401600060405180830381600087803b15801561117557600080fd5b505af1158015611189573d6000803e3d6000fd5b50506040517f9168902400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88811660048301526112b6935087169150639168902490602401602060405180830381865afa1580156111fd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061122191906142b8565b6040517fab582f2900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff888116600483015287169063ab582f2990602401602060405180830381865afa15801561128d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112b191906142b8565b613180565b95945050505050565b6000818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561130a57600080fd5b505af115801561131e573d6000803e3d6000fd5b50505050600061132d8461304f565b9050610c3b61133e6201518061318c565b6040517f60ec91d600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8716906360ec91d69061139090869060040161403d565b602060405180830381865afa1580156113ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113d191906142b8565b906131a0565b6113df613357565b6040805180820182526000808252602082015290517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301528591859182169063f667f89790602401600060405180830381600087803b15801561145e57600080fd5b505af1158015611472573d6000803e3d6000fd5b50506040517f1e0c6fb900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff898116600483015288169250631e0c6fb9915060240160a060405180830381865afa1580156114e2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061150691906141ba565b6040517fb7648fb900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff888116600483015287169063b7648fb9906024016040805180830381865afa158015611571573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611595919061437c565b9350935050509250929050565b6060828073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156115ed57600080fd5b505af1158015611601573d6000803e3d6000fd5b50505050825167ffffffffffffffff81111561161f5761161f613b81565b60405190808252806020026020018201604052801561167457816020015b61166160405180606001604052806000815260200160008152602001600081525090565b81526020019060019003908161163d5790505b50915060005b8351811015610f67578473ffffffffffffffffffffffffffffffffffffffff16637ece075d8583815181106116b1576116b1614398565b60200260200101516040518263ffffffff1660e01b81526004016116d791815260200190565b606060405180830381865afa1580156116f4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061171891906143c7565b83828151811061172a5761172a614398565b6020026020010181905250808061174090614432565b91505061167a565b6040517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff808416600483015260609182918591859182169063f667f89790602401600060405180830381600087803b1580156117ba57600080fd5b505af11580156117ce573d6000803e3d6000fd5b5050505060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16636fc6407c6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561183f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611863919061429b565b6040517f05d85eda00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88811660048301529192506000918316906305d85eda90602401602060405180830381865afa1580156118d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118f991906142b8565b90508067ffffffffffffffff81111561191457611914613b81565b60405190808252806020026020018201604052801561193d578160200160208202803683370190505b5095508067ffffffffffffffff81111561195957611959613b81565b604051908082528060200260200182016040528015611982578160200160208202803683370190505b50945060005b81811015611b22576040517f2c3e50e500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff89811660048301526024820183905260009190851690632c3e50e59060440160c060405180830381865afa158015611a07573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a2b919061446a565b90508060800151888381518110611a4457611a44614398565b73ffffffffffffffffffffffffffffffffffffffff92831660209182029290920101526040517f66f8162e0000000000000000000000000000000000000000000000000000000081528a821660048201528b8216602482015260448101849052908516906366f8162e90606401602060405180830381865afa158015611ace573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611af291906142b8565b878381518110611b0457611b04614398565b60209081029190910101525080611b1a81614432565b915050611988565b50505050509250929050565b6040517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8084166004830152600091849184919082169063f667f89790602401600060405180830381600087803b158015611b9f57600080fd5b505af1158015611bb3573d6000803e3d6000fd5b50505050611bbf612687565b6040517f82df39de00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8781166004830152868116602483015291909116906382df39de906044015b602060405180830381865afa158015611c36573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112b691906144e6565b6040517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8085166004830152600091859185919082169063f667f89790602401600060405180830381600087803b158015611ccb57600080fd5b505af1158015611cdf573d6000803e3d6000fd5b505050506000611d04611cfd611cf4886131bf565b604001516132cd565b869061316b565b9050611d7f8673ffffffffffffffffffffffffffffffffffffffff16636c376cc56040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d54573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d7891906142b8565b829061316b565b979650505050505050565b611dae60405180606001604052806000815260200160008152602001600081525090565b818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611df757600080fd5b505af1158015611e0b573d6000803e3d6000fd5b50505050610d1b836131bf565b6060815167ffffffffffffffff811115611e3457611e34613b81565b604051908082528060200260200182016040528015611e6d57816020015b611e5a613477565b815260200190600190039081611e525790505b50905060005b8251811015611ecf57611e9f84848381518110611e9257611e92614398565b6020026020010151610d22565b828281518110611eb157611eb1614398565b60200260200101819052508080611ec790614432565b915050611e73565b5092915050565b6040517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8084166004830152600091849184919082169063f667f89790602401600060405180830381600087803b158015611f4757600080fd5b505af1158015611f5b573d6000803e3d6000fd5b50505050611f67612687565b6040517ffaaebd2100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8781166004830152919091169063faaebd21906024015b602060405180830381865afa158015611fd6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112b691906142b8565b60608167ffffffffffffffff81111561201557612015613b81565b60405190808252806020026020018201604052801561204e57816020015b61203b61353d565b8152602001906001900390816120335790505b50905060005b82811015611ecf5761208684848381811061207157612071614398565b90506020020160208101906102fc919061363e565b82828151811061209857612098614398565b602002602001018190525080806120ae90614432565b915050612054565b6120be613357565b6040517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80851660048301528491849182169063f667f89790602401600060405180830381600087803b15801561212b57600080fd5b505af115801561213f573d6000803e3d6000fd5b50506040517f1e0c6fb900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff888116600483015287169250631e0c6fb9915060240160a060405180830381865afa1580156121af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112b691906141ba565b6000818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561221e57600080fd5b505af1158015612232573d6000803e3d6000fd5b5050505061223e612687565b6040517fa5fdc5de00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8581166004830152919091169063a5fdc5de906024015b602060405180830381865afa1580156122ad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d1b91906142b8565b60608173ffffffffffffffffffffffffffffffffffffffff166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa1580156105d8573d6000803e3d6000fd5b6000818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561236957600080fd5b505af115801561237d573d6000803e3d6000fd5b50505050612389612687565b6040517fb4d6f78100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8581166004830152919091169063b4d6f78190602401612290565b6040805180820190915260008082526020820152818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561243c57600080fd5b505af1158015612450573d6000803e3d6000fd5b50505050610d1b8361304f565b6040805180820182526000808252602082015290517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301528491849182169063f667f89790602401600060405180830381600087803b1580156124dc57600080fd5b505af11580156124f0573d6000803e3d6000fd5b505050506112b6612503611cf4866131bf565b6040517fb7648fb900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff888116600483015287169063b7648fb9906024016040805180830381865afa15801561256e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612592919061437c565b906132d8565b6040517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8084166004830152600091849184919082169063f667f89790602401600060405180830381600087803b15801561260957600080fd5b505af115801561261d573d6000803e3d6000fd5b50505050612629612687565b6040517fcc218ece00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff87811660048301528681166024830152919091169063cc218ece90604401611fb9565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa1580156126f4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612718919061429b565b905090565b6040805180820182526000808252602082015290517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301528491849182169063f667f89790602401600060405180830381600087803b15801561279c57600080fd5b505af11580156127b0573d6000803e3d6000fd5b50506040517fb7648fb900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88811660048301528716925063b7648fb991506024016040805180830381865afa15801561281f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112b6919061437c565b6040805180820190915260008082526020820152818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156128a057600080fd5b505af11580156128b4573d6000803e3d6000fd5b50505050610d1b6128c7611cf4856131bf565b6125928561304f565b6040517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8084166004830152600091849184919082169063f667f89790602401600060405180830381600087803b15801561294157600080fd5b505af1158015612955573d6000803e3d6000fd5b50506040517f58ca6f9800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8881166004830152871692506358ca6f989150602401611c19565b6040517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff808616600483015260609182918791879182169063f667f89790602401600060405180830381600087803b158015612a1f57600080fd5b505af1158015612a33573d6000803e3d6000fd5b5050505060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16636fc6407c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612aa4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ac8919061429b565b90508567ffffffffffffffff811115612ae357612ae3613b81565b604051908082528060200260200182016040528015612b0c578160200160208202803683370190505b5094508567ffffffffffffffff811115612b2857612b28613b81565b604051908082528060200260200182016040528015612b51578160200160208202803683370190505b50935060005b86811015612d555760008273ffffffffffffffffffffffffffffffffffffffff16632c3e50e58b8b8b86818110612b9057612b90614398565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e087901b16815273ffffffffffffffffffffffffffffffffffffffff9094166004850152602002919091013560248301525060440160c060405180830381865afa158015612c07573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c2b919061446a565b90508060800151878381518110612c4457612c44614398565b73ffffffffffffffffffffffffffffffffffffffff928316602091820292909201015283166366f8162e8b8d8c8c87818110612c8257612c82614398565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e088901b16815273ffffffffffffffffffffffffffffffffffffffff958616600482015294909316602485015250602090910201356044820152606401602060405180830381865afa158015612d01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d2591906142b8565b868381518110612d3757612d37614398565b60209081029190910101525080612d4d81614432565b915050612b57565b5050505094509492505050565b600080828073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b158015612dae57600080fd5b505af1158015612dc2573d6000803e3d6000fd5b5050505060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015612e33573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e57919061429b565b6040517f2d809cb600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff87811660048301529192506000917f00000000000000000000000000000000000000000000000000000000000000001690632d809cb690602401602060405180830381865afa158015612ee9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f0d919061429b565b9050612f17612687565b6040517ffaaebd2100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8481166004830152919091169063faaebd2190602401602060405180830381865afa158015612f85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fa991906142b8565b9450612fb3612687565b6040517ffaaebd2100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8381166004830152919091169063faaebd2190602401602060405180830381865afa158015613021573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061304591906142b8565b9350505050915091565b60408051808201909152600080825260208201528173ffffffffffffffffffffffffffffffffffffffff16639a427d038373ffffffffffffffffffffffffffffffffffffffff1663c07f47d46040518163ffffffff1660e01b8152600401602060405180830381865afa1580156130ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130ee91906142b8565b6040518263ffffffff1660e01b815260040161310c91815260200190565b6040805180830381865afa158015613128573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061061e919061437c565b600081613161670de0b6b3a764000085614508565b610d1b9190614574565b6000670de0b6b3a76400006131618385614508565b6000610d1b8383613329565b600061061e670de0b6b3a764000083614588565b6000670de0b6b3a76400006131b58385614588565b610d1b9190614644565b6131e360405180606001604052806000815260200160008152602001600081525090565b8173ffffffffffffffffffffffffffffffffffffffff16637ece075d8373ffffffffffffffffffffffffffffffffffffffff1663c07f47d46040518163ffffffff1660e01b8152600401602060405180830381865afa15801561324a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061326e91906142b8565b6040518263ffffffff1660e01b815260040161328c91815260200190565b606060405180830381865afa1580156132a9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061061e91906143c7565b600061061e82613340565b60408051808201909152600080825260208201526040805180820190915283518190613304908561316b565b815260200161332084866020015161316b90919063ffffffff16565b90529392505050565b6000818310156133395781610d1b565b5090919050565b600080821215613353578160000361061e565b5090565b604051806060016040528060008152602001613386604051806040016040528060008152602001600081525090565b81526020016133a8604051806040016040528060008152602001600081525090565b905290565b60405180610140016040528060608152602001606081526020016133ec6040805160608101909152806000815260200160008152600060209091015290565b8152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001600081526020016000815260200160008152602001600081526020016133a860405180608001604052806000600f0b81526020016000600f0b81526020016000600f0b815260200160006fffffffffffffffffffffffffffffffff1681525090565b604051806101600160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001600081526020016134d3613357565b81526020016134f5604051806040016040528060008152602001600081525090565b8152602001600015158152602001600015158152602001613529604051806040016040528060008152602001600081525090565b815260200160008152602001600081525090565b604051806101a001604052806135516133ad565b8152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001600081526020016135a560405180606001604052806000815260200160008152602001600081525090565b81526020016000815260200160008152602001600081526020016135c7613357565b81526020016135e9604051806040016040528060008152602001600081525090565b815260200160008152602001600081526020016133a8604051806040016040528060008152602001600081525090565b73ffffffffffffffffffffffffffffffffffffffff8116811461363b57600080fd5b50565b60006020828403121561365057600080fd5b8135610d1b81613619565b60005b8381101561367657818101518382015260200161365e565b83811115613685576000848401525b50505050565b600081518084526136a381602086016020860161365b565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000610d1b602083018461368b565b82518152602080840151805182840152810151604080840191909152840151805160608401520151608082015260e08101825160a0830152602083015160c0830152610d1b565b6002811061363b577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b80516137718161372f565b825260208101516137818161372f565b60208301526040908101517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000016910152565b60006101e082518185526137c98286018261368b565b915050602083015184820360208601526137e3828261368b565b91505060408301516137f86040860182613766565b50606083015173ffffffffffffffffffffffffffffffffffffffff811660a086015250608083015160c085015260a083015160e085015260c0830151610100818187015260e0850151915061012082818801528186015161014088015280860151925050506138a76101608601828051600f0b82526020810151600f0b60208301526040810151600f0b60408301526fffffffffffffffffffffffffffffffff60608201511660608301525050565b509392505050565b602081526000610d1b60208301846137b3565b81518152602080830151805182840152810151604080840191909152830151805160608401520151608082015260a0810161061e565b6000806040838503121561390b57600080fd5b823561391681613619565b9150602083013561392681613619565b809150509250929050565b805173ffffffffffffffffffffffffffffffffffffffff1682526020810151613972602084018273ffffffffffffffffffffffffffffffffffffffff169052565b50604081015160408301526060810151606083015260808101516139c560808401828051825260208082015180518285015290810151604084015250604001518051606083015260200151608090910152565b5060a08101516101206139e48185018380518252602090810151910152565b60c0830151151561016085015260e0830151151561018085015261010083015180516101a0860152602001516101c08501528201516101e084015250610140015161020090910152565b610220810161061e8284613931565b60006102a08251818552613a53828601826137b3565b9150506020830151613a7d602086018273ffffffffffffffffffffffffffffffffffffffff169052565b5060408301516040850152606083015160608501526080830151613ab860808601828051825260208082015190830152604090810151910152565b5060a083015160e085015260c0830151610100818187015260e0850151915061012082818801528186015192506101409150613b22828801848051825260208082015180518285015290810151604084015250604001518051606083015260200151608090910152565b85015180516101e08801526020810151610200880152915084015161022086015250610160830151610240850152610180830151805161026086015260208101516102808601526138a7565b602081526000610d1b6020830184613a3d565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516060810167ffffffffffffffff81118282101715613bd357613bd3613b81565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715613c2057613c20613b81565b604052919050565b600067ffffffffffffffff821115613c4257613c42613b81565b5060051b60200190565b60008060408385031215613c5f57600080fd5b8235613c6a81613619565b915060208381013567ffffffffffffffff811115613c8757600080fd5b8401601f81018613613c9857600080fd5b8035613cab613ca682613c28565b613bd9565b81815260059190911b82018301908381019088831115613cca57600080fd5b928401925b82841015613ce857833582529284019290840190613ccf565b80955050505050509250929050565b6020808252825182820181905260009190848201906040850190845b81811015613d4d57613d3a8385518051825260208082015190830152604090810151910152565b9284019260609290920191600101613d13565b50909695505050505050565b604080825283519082018190526000906020906060840190828701845b82811015613da857815173ffffffffffffffffffffffffffffffffffffffff1684529284019290840190600101613d76565b5050508381038285015284518082528583019183019060005b81811015613ddd57835183529284019291840191600101613dc1565b5090979650505050505050565b600080600060608486031215613dff57600080fd5b8335613e0a81613619565b92506020840135613e1a81613619565b929592945050506040919091013590565b8151815260208083015190820152604080830151908201526060810161061e565b60008060408385031215613e5f57600080fd5b8235613e6a81613619565b915060208381013567ffffffffffffffff811115613e8757600080fd5b8401601f81018613613e9857600080fd5b8035613ea6613ca682613c28565b81815260059190911b82018301908381019088831115613ec557600080fd5b928401925b82841015613ce8578335613edd81613619565b82529284019290840190613eca565b6020808252825182820181905260009190848201906040850190845b81811015613d4d57613f1b838551613931565b928401926102209290920191600101613f08565b60008083601f840112613f4157600080fd5b50813567ffffffffffffffff811115613f5957600080fd5b6020830191508360208260051b8501011115613f7457600080fd5b9250929050565b60008060208385031215613f8e57600080fd5b823567ffffffffffffffff811115613fa557600080fd5b613fb185828601613f2f565b90969095509350505050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015614030577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc088860301845261401e858351613a3d565b94509285019290850190600101613fe4565b5092979650505050505050565b81518152602080830151908201526040810161061e565b6000806000806060858703121561406a57600080fd5b843561407581613619565b9350602085013561408581613619565b9250604085013567ffffffffffffffff8111156140a157600080fd5b6140ad87828801613f2f565b95989497509550505050565b6000602082840312156140cb57600080fd5b815167ffffffffffffffff808211156140e357600080fd5b818401915084601f8301126140f757600080fd5b81518181111561410957614109613b81565b61413a60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601613bd9565b915080825285602082850101111561415157600080fd5b61416281602084016020860161365b565b50949350505050565b60006040828403121561417d57600080fd5b6040516040810181811067ffffffffffffffff821117156141a0576141a0613b81565b604052825181526020928301519281019290925250919050565b600060a082840312156141cc57600080fd5b6040516060810181811067ffffffffffffffff821117156141ef576141ef613b81565b60405282518152614203846020850161416b565b6020820152614215846060850161416b565b60408201529392505050565b6002811061363b57600080fd5b60006060828403121561424057600080fd5b614248613bb0565b825161425381614221565b8152602083015161426381614221565b602082015260408301517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00008116811461421557600080fd5b6000602082840312156142ad57600080fd5b8151610d1b81613619565b6000602082840312156142ca57600080fd5b5051919050565b8051600f81900b81146142e357600080fd5b919050565b6000608082840312156142fa57600080fd5b6040516080810181811067ffffffffffffffff8211171561431d5761431d613b81565b604052614329836142d1565b8152614337602084016142d1565b6020820152614348604084016142d1565b604082015260608301516fffffffffffffffffffffffffffffffff8116811461437057600080fd5b60608201529392505050565b60006040828403121561438e57600080fd5b610d1b838361416b565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000606082840312156143d957600080fd5b6143e1613bb0565b8251815260208301516020820152604083015160408201528091505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361446357614463614403565b5060010190565b600060c0828403121561447c57600080fd5b60405160a0810181811067ffffffffffffffff8211171561449f5761449f613b81565b604052825181526144b3846020850161416b565b6020820152606083015160408201526080830151606082015260a08301516144da81613619565b60808201529392505050565b6000602082840312156144f857600080fd5b81518015158114610d1b57600080fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561454057614540614403565b500290565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60008261458357614583614545565b500490565b60007f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000841360008413858304851182821616156145c9576145c9614403565b7f8000000000000000000000000000000000000000000000000000000000000000600087128682058812818416161561460457614604614403565b6000871292508782058712848416161561462057614620614403565b8785058712818416161561463657614636614403565b505050929093029392505050565b60008261465357614653614545565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83147f8000000000000000000000000000000000000000000000000000000000000000831416156146a7576146a7614403565b50059056fea26469706673582212206db77c0d984546687817814f74442aaf51c5a60c503137ad38573cdbc56fa1f664736f6c634300080f0033", - "devdoc": { - "kind": "dev", - "methods": { - "atVersions(address,uint256[])": { - "params": { - "product": "Product address", - "versions": "Oracle versions to query" - }, - "returns": { - "prices": "Product prices at specified versions" - } - }, - "collateral()": { - "returns": { - "_0": "Protocol collateral address" - } - }, - "collateral(address)": { - "params": { - "product": "Product address" - }, - "returns": { - "_0": "Total collateral for product" - } - }, - "collateral(address,address)": { - "params": { - "account": "Account address", - "product": "Product address" - }, - "returns": { - "_0": "User deposited collateral for product" - } - }, - "constructor": { - "params": { - "_controller": "Protocol controller address" - } - }, - "dailyRate(address)": { - "params": { - "product": "Product address" - }, - "returns": { - "_0": "Product current funding extrapolated to a daily rate" - } - }, - "exposure(address,address)": { - "params": { - "account": "Account address", - "product": "Product address" - }, - "returns": { - "_0": "User's exposure (openInterest * utilization) after settle" - } - }, - "fees(address)": { - "params": { - "product": "Product address" - }, - "returns": { - "productFees": "fees accrued by the product owner", - "protocolFees": "fees accrued by the protocol" - } - }, - "fees(address,address)": { - "params": { - "account": "Account address", - "product": "Product address" - }, - "returns": { - "_0": "sum of all fees accrued by the account" - } - }, - "globalPosition(address)": { - "params": { - "product": "Product address" - }, - "returns": { - "_0": "Product pre-position", - "_1": "Product position" - } - }, - "info(address)": { - "params": { - "product": "Product address" - }, - "returns": { - "_info": "of the product" - } - }, - "latestVersion(address)": { - "params": { - "product": "Product address" - }, - "returns": { - "_0": "Product latest price" - } - }, - "liquidatable(address,address)": { - "params": { - "account": "Account address", - "product": "Product address" - }, - "returns": { - "_0": "Whether or not the user's position eligible to be liquidated" - } - }, - "liquidating(address,address)": { - "params": { - "account": "Account address", - "product": "Product address" - }, - "returns": { - "_0": "Whether or not the user's position is being liquidated" - } - }, - "maintenance(address,address)": { - "params": { - "account": "Account address", - "product": "Product address" - }, - "returns": { - "_0": "Maximum of user maintenance, and maintenanceNext" - } - }, - "maintenanceRequired(address,address,uint256)": { - "params": { - "account": "Account address", - "positionSize": "size of position for maintenance calculation", - "product": "Product address" - }, - "returns": { - "_0": "Maintenance required for position in product" - } - }, - "name(address)": { - "params": { - "product": "Product address" - }, - "returns": { - "_0": "Name of the product" - } - }, - "openInterest(address)": { - "params": { - "product": "Product address" - }, - "returns": { - "_0": "Product maker and taker position multiplied by latest price after settle" - } - }, - "openInterest(address,address)": { - "params": { - "account": "Account address", - "product": "Product address" - }, - "returns": { - "_0": "User's maker or taker position multiplied by latest price after settle" - } - }, - "position(address)": { - "params": { - "product": "Product address" - }, - "returns": { - "_0": "product position" - } - }, - "position(address,address)": { - "params": { - "account": "Account address", - "product": "Product address" - }, - "returns": { - "_0": "User position" - } - }, - "pre(address)": { - "params": { - "product": "Product address" - }, - "returns": { - "_0": "Product pre-position" - } - }, - "pre(address,address)": { - "params": { - "account": "Account address", - "product": "Product address" - }, - "returns": { - "_0": "User pre-position" - } - }, - "rate(address)": { - "params": { - "product": "Product address" - }, - "returns": { - "_0": "Product current funding rate" - } - }, - "shortfall(address)": { - "params": { - "product": "Product address" - }, - "returns": { - "_0": "Total shortfall for product" - } - }, - "snapshot(address)": { - "params": { - "product": "Product address" - }, - "returns": { - "_snapshot": "for the product after settle" - } - }, - "snapshot(address,address)": { - "params": { - "account": "User addresses", - "product": "Product address" - }, - "returns": { - "_snapshot": "UserSnapshot for the product after settle" - } - }, - "snapshots(address,address[])": { - "params": { - "account": "User addresses", - "productAddresses": "Product addresses" - }, - "returns": { - "_snapshots": "UserSnapshot for each product after settle" - } - }, - "snapshots(address[])": { - "params": { - "productAddresses": "Product addresses" - }, - "returns": { - "_snapshots": "a snapshot for each product after settle" - } - }, - "symbol(address)": { - "params": { - "product": "Product address" - }, - "returns": { - "_0": "Symbol of the product" - } - }, - "unclaimedIncentiveRewards(address,address)": { - "params": { - "account": "Account address", - "product": "Product address" - }, - "returns": { - "amounts": "Token amounts of unclaimed incentive rewards for given product", - "tokens": "Token addresses of unclaimed incentive rewards for given product" - } - }, - "unclaimedIncentiveRewards(address,address,uint256[])": { - "params": { - "account": "Account address", - "product": "Product address", - "programIds": "Program IDs to query" - }, - "returns": { - "amounts": "Token amounts of unclaimed incentive rewards for given program IDs", - "tokens": "Token addresses of unclaimed incentive rewards for given program IDs" - } - }, - "userPosition(address,address)": { - "params": { - "account": "Account address", - "product": "Product address" - }, - "returns": { - "_0": "User pre-position", - "_1": "User position" - } - } - }, - "stateVariables": { - "controller": { - "return": "Protocol controller", - "returns": { - "_0": "Protocol controller" - } - } - }, - "title": "Lens contract to conveniently pull protocol data", - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": { - "atVersions(address,uint256[])": { - "notice": "Prices of product at specified versions after settle" - }, - "collateral()": { - "notice": "Protocol collateral address" - }, - "collateral(address)": { - "notice": "Product total collateral amount after settle" - }, - "collateral(address,address)": { - "notice": "User collateral amount for product after settle" - }, - "controller()": { - "notice": "Protocol controller" - }, - "dailyRate(address)": { - "notice": "Product funding extrapolated to a daily rate after settle" - }, - "exposure(address,address)": { - "notice": "User's exposure in product after settle" - }, - "fees(address)": { - "notice": "Fees accumulated by product and protocol treasuries after settle" - }, - "fees(address,address)": { - "notice": "Fees accumulated by account after settle" - }, - "globalPosition(address)": { - "notice": "Product pre-position and position after settle" - }, - "info(address)": { - "notice": "Returns the info of the provided `product`" - }, - "latestVersion(address)": { - "notice": "Current price of product after settle" - }, - "liquidatable(address,address)": { - "notice": "User liquidatble status for product after settle" - }, - "liquidating(address,address)": { - "notice": "User liquidating status for product after settle" - }, - "maintenance(address,address)": { - "notice": "User maintenance amount for product after settle" - }, - "maintenanceRequired(address,address,uint256)": { - "notice": "User's maintenance required for position size in product after settle" - }, - "name(address)": { - "notice": "Returns the name of the provided `product`" - }, - "openInterest(address)": { - "notice": "Product total open interest after settle" - }, - "openInterest(address,address)": { - "notice": "User's open interest in product after settle" - }, - "position(address)": { - "notice": "Product position after settle" - }, - "position(address,address)": { - "notice": "User position for product after settle" - }, - "pre(address)": { - "notice": "Product pre position after settle" - }, - "pre(address,address)": { - "notice": "User pre position for product after settle" - }, - "rate(address)": { - "notice": "Product funding rate after settle" - }, - "shortfall(address)": { - "notice": "Product total shortfall amount after settle" - }, - "snapshot(address)": { - "notice": "Returns the snapshot of the provided `product`" - }, - "snapshot(address,address)": { - "notice": "Returns the user snapshot for the provided `product`" - }, - "snapshots(address,address[])": { - "notice": "Returns the user snapshots for the provided `productAddresses`" - }, - "snapshots(address[])": { - "notice": "Returns the snapshots of the provided `productAddresses`" - }, - "symbol(address)": { - "notice": "Returns the symbol of the provided `product`" - }, - "unclaimedIncentiveRewards(address,address)": { - "notice": "User's unclaimed rewards for all programs for product after settle" - }, - "unclaimedIncentiveRewards(address,address,uint256[])": { - "notice": "User's unclaimed rewards for provided programs for product after settle" - }, - "userPosition(address,address)": { - "notice": "User pre-position and position for product after settle" - } - }, - "notice": "All functions should be called using `callStatic`", - "version": 1 - }, - "storageLayout": { - "storage": [], - "types": null - } -} diff --git a/packages/perennial/deployments/goerli/Product_Impl.json b/packages/perennial/deployments/goerli/Product_Impl.json deleted file mode 100644 index 6bd79e806..000000000 --- a/packages/perennial/deployments/goerli/Product_Impl.json +++ /dev/null @@ -1,1464 +0,0 @@ -{ - "address": "0x60eA8B7346B230fB6987783501075A42c2fAeDB4", - "abi": [ - { - "inputs": [], - "name": "CurveMathOutOfBoundsError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Fixed18OverflowError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "int256", - "name": "value", - "type": "int256" - } - ], - "name": "Fixed18PackingOverflowError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "int256", - "name": "value", - "type": "int256" - } - ], - "name": "Fixed18PackingUnderflowError", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidControllerError", - "type": "error" - }, - { - "inputs": [], - "name": "NotCollateralError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - } - ], - "name": "NotOwnerError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "NotProductError", - "type": "error" - }, - { - "inputs": [], - "name": "ParamProviderInvalidFundingFee", - "type": "error" - }, - { - "inputs": [], - "name": "ParamProviderInvalidMakerFee", - "type": "error" - }, - { - "inputs": [], - "name": "ParamProviderInvalidTakerFee", - "type": "error" - }, - { - "inputs": [], - "name": "PausedError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "enum PayoffDefinitionLib.PayoffType", - "name": "payoffType", - "type": "uint8" - }, - { - "internalType": "bytes30", - "name": "data", - "type": "bytes30" - } - ], - "name": "PayoffDefinitionNotContract", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "enum PayoffDefinitionLib.PayoffType", - "name": "payoffType", - "type": "uint8" - }, - { - "internalType": "enum PayoffDefinitionLib.PayoffDirection", - "name": "payoffDirection", - "type": "uint8" - } - ], - "name": "PayoffDefinitionUnsupportedTransform", - "type": "error" - }, - { - "inputs": [], - "name": "PayoffProviderInvalidOracle", - "type": "error" - }, - { - "inputs": [], - "name": "PayoffProviderInvalidPayoffDefinitionError", - "type": "error" - }, - { - "inputs": [], - "name": "ProductClosedError", - "type": "error" - }, - { - "inputs": [], - "name": "ProductDoubleSidedError", - "type": "error" - }, - { - "inputs": [], - "name": "ProductInLiquidationError", - "type": "error" - }, - { - "inputs": [], - "name": "ProductInsufficientCollateralError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "socializationFactor", - "type": "uint256" - } - ], - "name": "ProductInsufficientLiquidityError", - "type": "error" - }, - { - "inputs": [], - "name": "ProductInvalidOracle", - "type": "error" - }, - { - "inputs": [], - "name": "ProductMakerOverLimitError", - "type": "error" - }, - { - "inputs": [], - "name": "ProductNotOwnerError", - "type": "error" - }, - { - "inputs": [], - "name": "ProductOracleBootstrappingError", - "type": "error" - }, - { - "inputs": [], - "name": "ProductOverClosedError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "UFixed18PackingOverflowError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "version", - "type": "uint256" - } - ], - "name": "UInitializableAlreadyInitializedError", - "type": "error" - }, - { - "inputs": [], - "name": "UInitializableNotInitializingError", - "type": "error" - }, - { - "inputs": [], - "name": "UInitializableZeroVersionError", - "type": "error" - }, - { - "inputs": [], - "name": "UReentrancyGuardReentrantCallError", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "preVersion", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "toVersion", - "type": "uint256" - } - ], - "name": "AccountSettle", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bool", - "name": "newClosed", - "type": "bool" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "version", - "type": "uint256" - } - ], - "name": "ClosedUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "UFixed18", - "name": "newFundingFee", - "type": "uint256" - } - ], - "name": "FundingFeeUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "version", - "type": "uint256" - } - ], - "name": "Initialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "Fixed18", - "name": "minRate", - "type": "int256" - }, - { - "indexed": false, - "internalType": "Fixed18", - "name": "maxRate", - "type": "int256" - }, - { - "indexed": false, - "internalType": "Fixed18", - "name": "targetRate", - "type": "int256" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "targetUtilization", - "type": "uint256" - } - ], - "name": "JumpRateUtilizationCurveUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "UFixed18", - "name": "newMaintenance", - "type": "uint256" - } - ], - "name": "MaintenanceUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "version", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "MakeClosed", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "version", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "MakeOpened", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "UFixed18", - "name": "newMakerFee", - "type": "uint256" - } - ], - "name": "MakerFeeUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "UFixed18", - "name": "newMakerLimit", - "type": "uint256" - } - ], - "name": "MakerLimitUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "preVersion", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "toVersion", - "type": "uint256" - } - ], - "name": "Settle", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "version", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "TakeClosed", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "version", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "TakeOpened", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "UFixed18", - "name": "newTakerFee", - "type": "uint256" - } - ], - "name": "TakerFeeUpdated", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "oracleVersion", - "type": "uint256" - } - ], - "name": "atVersion", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "version", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - }, - { - "internalType": "Fixed18", - "name": "price", - "type": "int256" - } - ], - "internalType": "struct IOracleProvider.OracleVersion", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "closeAll", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "closeMake", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "closeTake", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "closed", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "controller", - "outputs": [ - { - "internalType": "contract IController", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "currentVersion", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "version", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - }, - { - "internalType": "Fixed18", - "name": "price", - "type": "int256" - } - ], - "internalType": "struct IOracleProvider.OracleVersion", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "fundingFee", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "string", - "name": "name", - "type": "string" - }, - { - "internalType": "string", - "name": "symbol", - "type": "string" - }, - { - "components": [ - { - "internalType": "enum PayoffDefinitionLib.PayoffType", - "name": "payoffType", - "type": "uint8" - }, - { - "internalType": "enum PayoffDefinitionLib.PayoffDirection", - "name": "payoffDirection", - "type": "uint8" - }, - { - "internalType": "bytes30", - "name": "data", - "type": "bytes30" - } - ], - "internalType": "struct PayoffDefinition", - "name": "payoffDefinition", - "type": "tuple" - }, - { - "internalType": "contract IOracleProvider", - "name": "oracle", - "type": "address" - }, - { - "internalType": "UFixed18", - "name": "maintenance", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "fundingFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "makerFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "takerFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "makerLimit", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "PackedFixed18", - "name": "minRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "maxRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "targetRate", - "type": "int128" - }, - { - "internalType": "PackedUFixed18", - "name": "targetUtilization", - "type": "uint128" - } - ], - "internalType": "struct JumpRateUtilizationCurve", - "name": "utilizationCurve", - "type": "tuple" - } - ], - "internalType": "struct IProduct.ProductInfo", - "name": "productInfo_", - "type": "tuple" - } - ], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "isClosed", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "isLiquidating", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "latestVersion", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "latestVersion", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "maintenance", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "maintenance", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "maintenanceNext", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "makerFee", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "makerLimit", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "openMake", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "openTake", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "oracle", - "outputs": [ - { - "internalType": "contract IOracleProvider", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "payoffDefinition", - "outputs": [ - { - "components": [ - { - "internalType": "enum PayoffDefinitionLib.PayoffType", - "name": "payoffType", - "type": "uint8" - }, - { - "internalType": "enum PayoffDefinitionLib.PayoffDirection", - "name": "payoffDirection", - "type": "uint8" - }, - { - "internalType": "bytes30", - "name": "data", - "type": "bytes30" - } - ], - "internalType": "struct PayoffDefinition", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "position", - "outputs": [ - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "oracleVersion", - "type": "uint256" - } - ], - "name": "positionAtVersion", - "outputs": [ - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "pre", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "oracleVersion", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "openPosition", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "closePosition", - "type": "tuple" - } - ], - "internalType": "struct PrePosition", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "pre", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "oracleVersion", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "openPosition", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "closePosition", - "type": "tuple" - } - ], - "internalType": "struct PrePosition", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "position_", - "type": "tuple" - } - ], - "name": "rate", - "outputs": [ - { - "internalType": "Fixed18", - "name": "", - "type": "int256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "settle", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "settleAccount", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "oracleVersion", - "type": "uint256" - } - ], - "name": "shareAtVersion", - "outputs": [ - { - "components": [ - { - "internalType": "Fixed18", - "name": "maker", - "type": "int256" - }, - { - "internalType": "Fixed18", - "name": "taker", - "type": "int256" - } - ], - "internalType": "struct Accumulator", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "takerFee", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bool", - "name": "newClosed", - "type": "bool" - } - ], - "name": "updateClosed", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "newFundingFee", - "type": "uint256" - } - ], - "name": "updateFundingFee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "newMaintenance", - "type": "uint256" - } - ], - "name": "updateMaintenance", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "newMakerFee", - "type": "uint256" - } - ], - "name": "updateMakerFee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "newMakerLimit", - "type": "uint256" - } - ], - "name": "updateMakerLimit", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "newTakerFee", - "type": "uint256" - } - ], - "name": "updateTakerFee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "PackedFixed18", - "name": "minRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "maxRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "targetRate", - "type": "int128" - }, - { - "internalType": "PackedUFixed18", - "name": "targetUtilization", - "type": "uint128" - } - ], - "internalType": "struct JumpRateUtilizationCurve", - "name": "newUtilizationCurve", - "type": "tuple" - } - ], - "name": "updateUtilizationCurve", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "utilizationCurve", - "outputs": [ - { - "components": [ - { - "internalType": "PackedFixed18", - "name": "minRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "maxRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "targetRate", - "type": "int128" - }, - { - "internalType": "PackedUFixed18", - "name": "targetUtilization", - "type": "uint128" - } - ], - "internalType": "struct JumpRateUtilizationCurve", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "oracleVersion", - "type": "uint256" - } - ], - "name": "valueAtVersion", - "outputs": [ - { - "components": [ - { - "internalType": "Fixed18", - "name": "maker", - "type": "int256" - }, - { - "internalType": "Fixed18", - "name": "taker", - "type": "int256" - } - ], - "internalType": "struct Accumulator", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - } - ], - "transactionHash": "0x03f211fdfac5d50f796fd3ad592c1a0dd9c3a5074e01c9ce3b22e05d41f86ff2", - "receipt": { - "to": null, - "from": "0x66a7fDB96C583c59597de16d8b2B989231415339", - "contractAddress": "0x60eA8B7346B230fB6987783501075A42c2fAeDB4", - "transactionIndex": 20, - "gasUsed": "5279435", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc7e84b365bb3c44e6927b390c59606a3b658ef49d0f2c69aed04bc46b8d3f7af", - "transactionHash": "0x03f211fdfac5d50f796fd3ad592c1a0dd9c3a5074e01c9ce3b22e05d41f86ff2", - "logs": [], - "blockNumber": 7681107, - "cumulativeGasUsed": "11518099", - "status": 1, - "byzantium": true - }, - "args": [], - "numDeployments": 1, - "solcInputHash": "40214df36850e11c061b57b4ce3f83e9", - "metadata": "{\"compiler\":{\"version\":\"0.8.15+commit.e14f2714\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"CurveMathOutOfBoundsError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Fixed18OverflowError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"int256\",\"name\":\"value\",\"type\":\"int256\"}],\"name\":\"Fixed18PackingOverflowError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"int256\",\"name\":\"value\",\"type\":\"int256\"}],\"name\":\"Fixed18PackingUnderflowError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidControllerError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotCollateralError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"}],\"name\":\"NotOwnerError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"NotProductError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ParamProviderInvalidFundingFee\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ParamProviderInvalidMakerFee\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ParamProviderInvalidTakerFee\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"PausedError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"enum PayoffDefinitionLib.PayoffType\",\"name\":\"payoffType\",\"type\":\"uint8\"},{\"internalType\":\"bytes30\",\"name\":\"data\",\"type\":\"bytes30\"}],\"name\":\"PayoffDefinitionNotContract\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"enum PayoffDefinitionLib.PayoffType\",\"name\":\"payoffType\",\"type\":\"uint8\"},{\"internalType\":\"enum PayoffDefinitionLib.PayoffDirection\",\"name\":\"payoffDirection\",\"type\":\"uint8\"}],\"name\":\"PayoffDefinitionUnsupportedTransform\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"PayoffProviderInvalidOracle\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"PayoffProviderInvalidPayoffDefinitionError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ProductClosedError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ProductDoubleSidedError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ProductInLiquidationError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ProductInsufficientCollateralError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"socializationFactor\",\"type\":\"uint256\"}],\"name\":\"ProductInsufficientLiquidityError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ProductInvalidOracle\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ProductMakerOverLimitError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ProductNotOwnerError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ProductOracleBootstrappingError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ProductOverClosedError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"UFixed18PackingOverflowError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"UInitializableAlreadyInitializedError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UInitializableNotInitializingError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UInitializableZeroVersionError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UReentrancyGuardReentrantCallError\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"preVersion\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"toVersion\",\"type\":\"uint256\"}],\"name\":\"AccountSettle\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bool\",\"name\":\"newClosed\",\"type\":\"bool\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"ClosedUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"newFundingFee\",\"type\":\"uint256\"}],\"name\":\"FundingFeeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"Fixed18\",\"name\":\"minRate\",\"type\":\"int256\"},{\"indexed\":false,\"internalType\":\"Fixed18\",\"name\":\"maxRate\",\"type\":\"int256\"},{\"indexed\":false,\"internalType\":\"Fixed18\",\"name\":\"targetRate\",\"type\":\"int256\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"targetUtilization\",\"type\":\"uint256\"}],\"name\":\"JumpRateUtilizationCurveUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"newMaintenance\",\"type\":\"uint256\"}],\"name\":\"MaintenanceUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MakeClosed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MakeOpened\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"newMakerFee\",\"type\":\"uint256\"}],\"name\":\"MakerFeeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"newMakerLimit\",\"type\":\"uint256\"}],\"name\":\"MakerLimitUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"preVersion\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"toVersion\",\"type\":\"uint256\"}],\"name\":\"Settle\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TakeClosed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TakeOpened\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"newTakerFee\",\"type\":\"uint256\"}],\"name\":\"TakerFeeUpdated\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"oracleVersion\",\"type\":\"uint256\"}],\"name\":\"atVersion\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"},{\"internalType\":\"Fixed18\",\"name\":\"price\",\"type\":\"int256\"}],\"internalType\":\"struct IOracleProvider.OracleVersion\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"closeAll\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"closeMake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"closeTake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"closed\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"controller\",\"outputs\":[{\"internalType\":\"contract IController\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"currentVersion\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"},{\"internalType\":\"Fixed18\",\"name\":\"price\",\"type\":\"int256\"}],\"internalType\":\"struct IOracleProvider.OracleVersion\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"fundingFee\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"},{\"components\":[{\"internalType\":\"enum PayoffDefinitionLib.PayoffType\",\"name\":\"payoffType\",\"type\":\"uint8\"},{\"internalType\":\"enum PayoffDefinitionLib.PayoffDirection\",\"name\":\"payoffDirection\",\"type\":\"uint8\"},{\"internalType\":\"bytes30\",\"name\":\"data\",\"type\":\"bytes30\"}],\"internalType\":\"struct PayoffDefinition\",\"name\":\"payoffDefinition\",\"type\":\"tuple\"},{\"internalType\":\"contract IOracleProvider\",\"name\":\"oracle\",\"type\":\"address\"},{\"internalType\":\"UFixed18\",\"name\":\"maintenance\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"fundingFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"makerFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"takerFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"makerLimit\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"PackedFixed18\",\"name\":\"minRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"maxRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"targetRate\",\"type\":\"int128\"},{\"internalType\":\"PackedUFixed18\",\"name\":\"targetUtilization\",\"type\":\"uint128\"}],\"internalType\":\"struct JumpRateUtilizationCurve\",\"name\":\"utilizationCurve\",\"type\":\"tuple\"}],\"internalType\":\"struct IProduct.ProductInfo\",\"name\":\"productInfo_\",\"type\":\"tuple\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"isClosed\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"isLiquidating\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"latestVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"maintenance\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"maintenance\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"maintenanceNext\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"makerFee\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"makerLimit\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"openMake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"openTake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"oracle\",\"outputs\":[{\"internalType\":\"contract IOracleProvider\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"payoffDefinition\",\"outputs\":[{\"components\":[{\"internalType\":\"enum PayoffDefinitionLib.PayoffType\",\"name\":\"payoffType\",\"type\":\"uint8\"},{\"internalType\":\"enum PayoffDefinitionLib.PayoffDirection\",\"name\":\"payoffDirection\",\"type\":\"uint8\"},{\"internalType\":\"bytes30\",\"name\":\"data\",\"type\":\"bytes30\"}],\"internalType\":\"struct PayoffDefinition\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"position\",\"outputs\":[{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"oracleVersion\",\"type\":\"uint256\"}],\"name\":\"positionAtVersion\",\"outputs\":[{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"pre\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"oracleVersion\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"openPosition\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"closePosition\",\"type\":\"tuple\"}],\"internalType\":\"struct PrePosition\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pre\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"oracleVersion\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"openPosition\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"closePosition\",\"type\":\"tuple\"}],\"internalType\":\"struct PrePosition\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"position_\",\"type\":\"tuple\"}],\"name\":\"rate\",\"outputs\":[{\"internalType\":\"Fixed18\",\"name\":\"\",\"type\":\"int256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"settle\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"settleAccount\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"oracleVersion\",\"type\":\"uint256\"}],\"name\":\"shareAtVersion\",\"outputs\":[{\"components\":[{\"internalType\":\"Fixed18\",\"name\":\"maker\",\"type\":\"int256\"},{\"internalType\":\"Fixed18\",\"name\":\"taker\",\"type\":\"int256\"}],\"internalType\":\"struct Accumulator\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"takerFee\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"newClosed\",\"type\":\"bool\"}],\"name\":\"updateClosed\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"newFundingFee\",\"type\":\"uint256\"}],\"name\":\"updateFundingFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"newMaintenance\",\"type\":\"uint256\"}],\"name\":\"updateMaintenance\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"newMakerFee\",\"type\":\"uint256\"}],\"name\":\"updateMakerFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"newMakerLimit\",\"type\":\"uint256\"}],\"name\":\"updateMakerLimit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"newTakerFee\",\"type\":\"uint256\"}],\"name\":\"updateTakerFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"PackedFixed18\",\"name\":\"minRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"maxRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"targetRate\",\"type\":\"int128\"},{\"internalType\":\"PackedUFixed18\",\"name\":\"targetUtilization\",\"type\":\"uint128\"}],\"internalType\":\"struct JumpRateUtilizationCurve\",\"name\":\"newUtilizationCurve\",\"type\":\"tuple\"}],\"name\":\"updateUtilizationCurve\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"utilizationCurve\",\"outputs\":[{\"components\":[{\"internalType\":\"PackedFixed18\",\"name\":\"minRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"maxRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"targetRate\",\"type\":\"int128\"},{\"internalType\":\"PackedUFixed18\",\"name\":\"targetUtilization\",\"type\":\"uint128\"}],\"internalType\":\"struct JumpRateUtilizationCurve\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"oracleVersion\",\"type\":\"uint256\"}],\"name\":\"valueAtVersion\",\"outputs\":[{\"components\":[{\"internalType\":\"Fixed18\",\"name\":\"maker\",\"type\":\"int256\"},{\"internalType\":\"Fixed18\",\"name\":\"taker\",\"type\":\"int256\"}],\"internalType\":\"struct Accumulator\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Cloned by the Controller contract to launch new product markets.\",\"kind\":\"dev\",\"methods\":{\"atVersion(uint256)\":{\"params\":{\"oracleVersion\":\"Oracle version to return for\"},\"returns\":{\"_0\":\"Oracle version at `oracleVersion` with price transformed by payoff function\"}},\"closeAll(address)\":{\"details\":\"Only callable by the Collateral contract as part of the liquidation flow\",\"params\":{\"account\":\"Account to close out\"}},\"closeMake(uint256)\":{\"params\":{\"amount\":\"Amount of the position to close\"}},\"closeTake(uint256)\":{\"params\":{\"amount\":\"Amount of the position to close\"}},\"currentVersion()\":{\"returns\":{\"_0\":\"Current oracle version transformed by the payoff definition\"}},\"initialize((string,string,(uint8,uint8,bytes30),address,uint256,uint256,uint256,uint256,uint256,(int128,int128,int128,uint128)))\":{\"params\":{\"productInfo_\":\"Product initialization params\"}},\"isClosed(address)\":{\"params\":{\"account\":\"Account to return for\"},\"returns\":{\"_0\":\"The the account is closed\"}},\"isLiquidating(address)\":{\"params\":{\"account\":\"Account to return for\"},\"returns\":{\"_0\":\"Whether the account is in liquidation\"}},\"latestVersion()\":{\"returns\":{\"_0\":\"Latest settled oracle version of the product\"}},\"latestVersion(address)\":{\"params\":{\"account\":\"Account to return for\"},\"returns\":{\"_0\":\"Latest settled oracle version of the account\"}},\"maintenance(address)\":{\"params\":{\"account\":\"Account to return for\"},\"returns\":{\"_0\":\"The current maintenance requirement\"}},\"maintenanceNext(address)\":{\"details\":\"Assumes no price change and no funding, used to protect user from over-opening\",\"params\":{\"account\":\"Account to return for\"},\"returns\":{\"_0\":\"The next maintenance requirement\"}},\"openMake(uint256)\":{\"params\":{\"amount\":\"Amount of the position to open\"}},\"openTake(uint256)\":{\"params\":{\"amount\":\"Amount of the position to open\"}},\"position(address)\":{\"params\":{\"account\":\"Account to return for\"},\"returns\":{\"_0\":\"Current position of the account\"}},\"positionAtVersion(uint256)\":{\"details\":\"Only valid for the version at which a global settlement occurred\",\"params\":{\"oracleVersion\":\"Oracle version to return for\"},\"returns\":{\"_0\":\"Global position at oracle version\"}},\"pre()\":{\"returns\":{\"_0\":\"Global pending-settlement position\"}},\"pre(address)\":{\"params\":{\"account\":\"Account to return for\"},\"returns\":{\"_0\":\"Current pre-position of the account\"}},\"rate((uint256,uint256))\":{\"details\":\"Handles 0-maker/taker edge cases\",\"params\":{\"position_\":\"Position to base utilization on\"},\"returns\":{\"_0\":\"The per-second rate\"}},\"settleAccount(address)\":{\"params\":{\"account\":\"Account to settle\"}},\"shareAtVersion(uint256)\":{\"details\":\"Only valid for the version at which a global settlement occurred\",\"params\":{\"oracleVersion\":\"Oracle version to return for\"},\"returns\":{\"_0\":\"Global accumulator share at oracle version\"}},\"updateClosed(bool)\":{\"details\":\"only callable by product owner. Settles the product before flipping the flag\",\"params\":{\"newClosed\":\"new closed value\"}},\"updateFundingFee(uint256)\":{\"details\":\"only callable by product owner\",\"params\":{\"newFundingFee\":\"new funding fee value\"}},\"updateMaintenance(uint256)\":{\"details\":\"only callable by product owner\",\"params\":{\"newMaintenance\":\"new maintenance value\"}},\"updateMakerFee(uint256)\":{\"details\":\"only callable by product owner\",\"params\":{\"newMakerFee\":\"new maker fee value\"}},\"updateMakerLimit(uint256)\":{\"details\":\"only callable by product owner\",\"params\":{\"newMakerLimit\":\"new maker limit value\"}},\"updateTakerFee(uint256)\":{\"details\":\"only callable by product owner\",\"params\":{\"newTakerFee\":\"new taker fee value\"}},\"updateUtilizationCurve((int128,int128,int128,uint128))\":{\"details\":\"only callable by product owner\",\"params\":{\"newUtilizationCurve\":\"new utilization curve value\"}},\"valueAtVersion(uint256)\":{\"details\":\"Only valid for the version at which a global settlement occurred\",\"params\":{\"oracleVersion\":\"Oracle version to return for\"},\"returns\":{\"_0\":\"Global accumulator value at oracle version\"}}},\"stateVariables\":{\"_accumulator\":{\"details\":\"The global accumulator state for the product\"},\"_accumulators\":{\"details\":\"The individual accumulator state for each account\"},\"_closed\":{\"details\":\"Whether or not the product is closed\"},\"_position\":{\"details\":\"The global position state for the product\"},\"_positions\":{\"details\":\"The individual position state for each account\"},\"name\":{\"details\":\"The name of the product\"},\"symbol\":{\"details\":\"The symbol of the product\"}},\"title\":\"Product\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"atVersion(uint256)\":{\"notice\":\"Returns the oracle version at `oracleVersion` transformed by the payoff definition\"},\"closeAll(address)\":{\"notice\":\"Closes all open and pending positions, locking for liquidation\"},\"closeMake(uint256)\":{\"notice\":\"Closes a maker position for `msg.sender`\"},\"closeTake(uint256)\":{\"notice\":\"Closes a taker position for `msg.sender`\"},\"currentVersion()\":{\"notice\":\"Returns the current oracle version transformed by the payoff definition\"},\"initialize((string,string,(uint8,uint8,bytes30),address,uint256,uint256,uint256,uint256,uint256,(int128,int128,int128,uint128)))\":{\"notice\":\"Initializes the contract state\"},\"isClosed(address)\":{\"notice\":\"Returns whether `account` has a completely zero'd position\"},\"isLiquidating(address)\":{\"notice\":\"Returns whether `account` is currently locked for an in-progress liquidation\"},\"latestVersion()\":{\"notice\":\"Returns the global latest settled oracle version\"},\"latestVersion(address)\":{\"notice\":\"Returns `account`'s latest settled oracle version\"},\"maintenance(address)\":{\"notice\":\"Returns the maintenance requirement for `account`\"},\"maintenanceNext(address)\":{\"notice\":\"Returns the maintenance requirement for `account` after next settlement\"},\"openMake(uint256)\":{\"notice\":\"Opens a maker position for `msg.sender`\"},\"openTake(uint256)\":{\"notice\":\"Opens a taker position for `msg.sender`\"},\"position(address)\":{\"notice\":\"Returns `account`'s current position\"},\"positionAtVersion(uint256)\":{\"notice\":\"Returns the global position at oracleVersion `oracleVersion`\"},\"pre()\":{\"notice\":\"Returns the current global pending-settlement position\"},\"pre(address)\":{\"notice\":\"Returns `account`'s current pending-settlement position\"},\"rate((uint256,uint256))\":{\"notice\":\"Returns The per-second rate based on the provided `position`\"},\"settle()\":{\"notice\":\"Surfaces global settlement externally\"},\"settleAccount(address)\":{\"notice\":\"Surfaces account settlement externally\"},\"shareAtVersion(uint256)\":{\"notice\":\"Returns the global accumulator share at oracleVersion `oracleVersion`\"},\"updateClosed(bool)\":{\"notice\":\"Updates product closed state\"},\"updateFundingFee(uint256)\":{\"notice\":\"Updates the funding fee to `newFundingFee`\"},\"updateMaintenance(uint256)\":{\"notice\":\"Updates the maintenance to `newMaintenance`\"},\"updateMakerFee(uint256)\":{\"notice\":\"Updates the maker fee to `newMakerFee`\"},\"updateMakerLimit(uint256)\":{\"notice\":\"Updates the maker limit to `newMakerLimit`\"},\"updateTakerFee(uint256)\":{\"notice\":\"Updates the taker fee to `newTakerFee`\"},\"updateUtilizationCurve((int128,int128,int128,uint128))\":{\"notice\":\"Updates the utilization curve to `newUtilizationCurve`\"},\"valueAtVersion(uint256)\":{\"notice\":\"Returns the global accumulator value at oracleVersion `oracleVersion`\"}},\"notice\":\"Manages logic and state for a single product market.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/product/Product.sol\":\"Product\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":5800},\"remappings\":[]},\"sources\":{\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\":{\"keccak256\":\"0xde0f20d468ba8b91addfc356e13f2c74a4dc8abe68be323942217c723775d9c1\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://a0b0ac97b512059cde8dae4c46391389075ff0fae475dead9ad5245c84c54271\",\"dweb:/ipfs/QmawgiGSqJ6ox8fSM9KVBPdwtjheGEytB7EpLDV1dqqey4\"]},\"@equilibria/root/control/unstructured/UInitializable.sol\":{\"keccak256\":\"0xd2743d8fcc220ed2ccdc0bba1db0a3e107741bd5c0cac47ca8c0b5a00ba2fd7f\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://56aadd6e4d60dde940c2d1dd0f4d39aaca7666850a8af9f288c81cb36ef780d3\",\"dweb:/ipfs/QmSFeJURqupzavfsCTZJHQKDYDnzQnyGAA24oeDCDHpJz4\"]},\"@equilibria/root/control/unstructured/UReentrancyGuard.sol\":{\"keccak256\":\"0x4962245ca8fdda3dc40c0f942a3568d90fb69428a6927b058018b01c90eb9fc9\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://2fc71fcb0176819e0266d3e9ffc9f02548b8513d360d29aeb951577b997caed7\",\"dweb:/ipfs/QmQtdTj4akRn6ZNzQYB1KsxzgdewJGrZNaZp4WYGqbquZA\"]},\"@equilibria/root/curve/CurveMath.sol\":{\"keccak256\":\"0x60d159f9ddf0dbe81124ecad58bba734b4cf82877637ff8d9d7f3e92f2da4ded\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://21ec7d55c7edb5e33a8448f90f8229a69e3ad88ce36f174515008ef6a01aa6d3\",\"dweb:/ipfs/QmNR72iJ8ayUBg8KiwDEdU5bsPf2UU9APPXG4bU1Ehq6zk\"]},\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\":{\"keccak256\":\"0xae202813874bc306d51b3dab8194c86f6483bb20bf1f673ddaee16aa8de567ff\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://078af55f041677c10be7eb87c4c4d7683288b2c04b936bccca9929315b4e7b45\",\"dweb:/ipfs/QmbmQsXNmfVxL95qHFQiaEQpt8PHohnpLdd94T3THYFubF\"]},\"@equilibria/root/number/types/Fixed18.sol\":{\"keccak256\":\"0x613587461ef3437ef33229cdda7d34ea746278721baf06e20b2e43977f43174d\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://630392f0e52d45747543e562ed58962bfa70c867031bdc2f304193072afbd618\",\"dweb:/ipfs/QmT1Zrvart6MYLvf4XqZUjm99L5AfuBcczV27ed3V4AvbW\"]},\"@equilibria/root/number/types/PackedFixed18.sol\":{\"keccak256\":\"0xb52960cc8e3132e45d342bbbb1c6a96219022cd8557997933bd8250170268b64\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://d3dde781dcb4cd5b7aff0d1a2b5d38bd9a321afd371aed6f88e4b4b2bc2a5984\",\"dweb:/ipfs/QmYaAukn1c8tE21HC2N415XZxT1H8zMQeoUoxh3iJTgxyA\"]},\"@equilibria/root/number/types/PackedUFixed18.sol\":{\"keccak256\":\"0xb5c5cd32d6530b2fe75228b6be32ebcb7762f6d7988b85a6b85a289ce8256d51\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://162ccf052216233008e732f0059d7cfde5c0aa70a5d4cf6549b1840f2ea791cc\",\"dweb:/ipfs/QmT95S1UHQbsT2ehAG42tLw4RUwCGijQ4fTkndL126yJmE\"]},\"@equilibria/root/number/types/UFixed18.sol\":{\"keccak256\":\"0x8ebef1e6c717f565b9ed545a876b5692b4007e6485c99f39d363f7405e591792\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://eb72bd190425ef3165df4c255617dfccb494563b3f9953c91aa8c4619cce779f\",\"dweb:/ipfs/QmZdmxTZh8DtGZeE1xzrPxSDNnicRTXpPgG97AsbE3TA3C\"]},\"@equilibria/root/storage/UStorage.sol\":{\"keccak256\":\"0xe2b8491d1b5aa93f7e059e1a8f156b0ab37fef9ed973be97a64f2eabfc2cc172\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://67fd3b83c6e94369d5a75c8fbd15341c4f0c12d6612dc222bc4d82882c1c0f93\",\"dweb:/ipfs/QmNj8i2c5mZysTxoQWg2A21iWyYna6okSHQjHvp6ycQ1Mh\"]},\"@equilibria/root/token/types/Token18.sol\":{\"keccak256\":\"0x6b12afaece814f0ab186200a4729e93eb685a21d3e9b5a3372ff283a7ad5dc23\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://e0118aeb6adc917b2ceadb82cc3a7a56d144ce4c8479296a4b288998c95e23e8\",\"dweb:/ipfs/QmcuREZS6RQU4brXKJ6cYE9dadqMJkrSrRDS7uEVau9eLJ\"]},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://ada1e030c0231db8d143b44ce92b4d1158eedb087880cad6d8cc7bd7ebe7b354\",\"dweb:/ipfs/QmWZ2NHZweRpz1U9GF6R1h65ri76dnX7fNxLBeM2t5N5Ce\"]},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://5a7d5b1ef5d8d5889ad2ed89d8619c09383b80b72ab226e0fe7bde1636481e34\",\"dweb:/ipfs/QmebXWgtEfumQGBdVeM6c71McLixYXQP5Bk6kKXuoY4Bmr\"]},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://5a376d3dda2cb70536c0a45c208b29b34ac560c4cb4f513a42079f96ba47d2dd\",\"dweb:/ipfs/QmZQg6gn1sUpM8wHzwNvSnihumUCAhxD119MpXeKp8B9s8\"]},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"keccak256\":\"0xc3d946432c0ddbb1f846a0d3985be71299df331b91d06732152117f62f0be2b5\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://4632c341a06ba5c079b51ca5a915efab4e6ab57735b37839b3e8365ff806a43e\",\"dweb:/ipfs/QmTHT3xHYed2wajEoA5qu7ii2BxLpPhQZHwAhtLK5Z7ANK\"]},\"@openzeppelin/contracts/utils/Address.sol\":{\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b3a57d0854b2fdce6ebff933a48dca2445643d1eccfc27f00292e937f26c6a58\",\"dweb:/ipfs/QmW45rZooS9TqR4YXUbjRbtf2Bpb5ouSarBvfW1LdGprvV\"]},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"keccak256\":\"0xc995bddbca1ae19788db9f8b61e63385edd3fddf89693b612d5abd1a275974d2\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://ab84f13e6e6e0823854a0cddd49e96df052092d5919f95587607f0ed28a64cb6\",\"dweb:/ipfs/QmbNtqAq23ZDjCzHukQaa7B3y6rcobscm6FZF5PMQXcnVr\"]},\"@openzeppelin/contracts/utils/math/SignedMath.sol\":{\"keccak256\":\"0xb3ebde1c8d27576db912d87c3560dab14adfb9cd001be95890ec4ba035e652e7\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://a709421c4f5d4677db8216055d2d4dac96a613efdb08178a9f7041f0c5cef689\",\"dweb:/ipfs/QmYs2rStvVLDnSJs8HgaMD1ABwoKKWdiVbQyNfLfFWTjTy\"]},\"contracts/controller/UControllerProvider.sol\":{\"keccak256\":\"0x10c6f4ae1a3a511aad470e40c61de5b2171f4151e2dea000acd2ffbd26dcbc2a\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://0f6930c5f0c59189036d86ccf31c7b37016609039ee90cb7605c624c6eed9f8c\",\"dweb:/ipfs/QmcyMMxLKJThDwFP6aAyNDnzNvNUQ6Tx8pq5jeRZdDVwum\"]},\"contracts/interfaces/ICollateral.sol\":{\"keccak256\":\"0xa5e7fdda92702f748e6eb8701e522450035a98a05e5fc1cf66d51c52e397d914\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://76143bc752720d136b0c0ed40c10832ec652f5010bfd988ea623135922eec8a6\",\"dweb:/ipfs/QmSrfhqoNhairnMHdVwdFWLhnAPutLf4k27LbiNuohafek\"]},\"contracts/interfaces/IContractPayoffProvider.sol\":{\"keccak256\":\"0xd73df106d032e976fd959ee6713240e36f54277ce5f215eaec8d5a2c6720a86b\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://b7932019acd64c5310eb266645d9bf9d13ba414ad4cbb8399b5c5fd5702d5d14\",\"dweb:/ipfs/QmVCXi3HXbGxm3kd6MsMULEFjtq8ecWvtREXnkgPgQFNnr\"]},\"contracts/interfaces/IController.sol\":{\"keccak256\":\"0xaabd3740f2265499eea7aad9bd94f9892f53241e5dccce9a50c0e43ed2a6a7cc\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://6164157218ab6f1fb8eb9d292931f83d1406862d0aa985d769efce4906514055\",\"dweb:/ipfs/Qmdq1JVqAX64hE4G7TjLxE5ByH1MT3DhWx9UgsNdcYxt2n\"]},\"contracts/interfaces/IIncentivizer.sol\":{\"keccak256\":\"0x2f95de90dbb3ad35dbfef304f765a622bffff9229868d2898eca8d49c78e8c2c\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://b354084581017fc041d0eab38567493fcb7cddf992550acc2b146a0287a82772\",\"dweb:/ipfs/QmS3eugykAdw5FVUuytnN8d8Rk7vB1LGCL6gCGkj6UaHux\"]},\"contracts/interfaces/IParamProvider.sol\":{\"keccak256\":\"0x2e2d40d0cf55f167118867e41f740b9b40614d05da50fc9bc33a8cede3eaf03e\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://d434bd33927b71335e773b840b7772ea23efd29ac7fb5ab8c21eb2d3f0a8f1cb\",\"dweb:/ipfs/QmSDV6q7SUx74QbZCj5ZScya2kxSB9c2LQFRTRLztpNuJX\"]},\"contracts/interfaces/IPayoffProvider.sol\":{\"keccak256\":\"0xb83d80d624aa9431763f80ecb4bf0214803e25334a7419d954f929e5d0ee7467\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://f16b186a5424f44735d8ee59ddfa188bdee5691b3a4284d0d2c15cb9506accc3\",\"dweb:/ipfs/QmPa26YHbU2kweKyQKqAJfKCe4BfBzHa5AT5CSJQyLJHxx\"]},\"contracts/interfaces/IProduct.sol\":{\"keccak256\":\"0xe1e80b818eadf4cdb070362e40c7cf3863b50c4f944816af27848e319f587241\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://14d6de071435afe4de7681b47dc90857ec43de3d4c5c33f3abf46275cd8b7685\",\"dweb:/ipfs/QmTsrhFR3w5roiZdPsS26vynE3SNMZEhViT1WnDLAy1GKF\"]},\"contracts/interfaces/types/Accumulator.sol\":{\"keccak256\":\"0x7ccd0a72aa593cefb9f4337cf312799f357b82fcb3f0379de0dc503d1cb7e387\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://884ee8101d531f8f596620dbe6f513bdaea06c5d113865fabb26131320286341\",\"dweb:/ipfs/QmRKjXfdTPqErTBz4xFvZMTVX88jxKKw14f1rcfAF7Z2Mr\"]},\"contracts/interfaces/types/PackedAccumulator.sol\":{\"keccak256\":\"0xd83f2822d4f6c818087a232b54007730992c34ff77377fc307a282f886e7cf65\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://0c9c635aa32e6feac02cd3d979f21dd01d70fce677da803958a5f7bf8262177d\",\"dweb:/ipfs/QmQnYbmci8WqyBNzvY7cer56Kwf9PU2Rt3GNn5rdzDQzRa\"]},\"contracts/interfaces/types/PackedPosition.sol\":{\"keccak256\":\"0x04968e6794f6244cb3415cea111d640273a81faea957872988d0cb580f45df1e\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://86c7a1c999d14ef22410bca74c51d3fbdf5ad0160a38eaad89c5e38361b981d0\",\"dweb:/ipfs/QmehdLThnFyoEv79C5xoSPmGFPxjmFvMjcCY94BD2iYmKN\"]},\"contracts/interfaces/types/PayoffDefinition.sol\":{\"keccak256\":\"0x4d3897f408f77381c5ae9990391465c8fd511ddf6ff3b39f6cb69d8c2bd554df\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://9c287e7508600fbf3abd6fd5b5c9294d2d349f59205f2e43e8305d76365058fe\",\"dweb:/ipfs/QmQkcD6bsR2JuhuYfnisE6TaySUKbf6dy939cD4VyT1vQj\"]},\"contracts/interfaces/types/Position.sol\":{\"keccak256\":\"0x027fe392c4f56bf012ba2ca462fcf23e69f2c3b9d283c14089771813437af991\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://d9300f5e81b30795fe38e993fb53fb6aa4ba829088e3e1c151baf5e4207d75cf\",\"dweb:/ipfs/QmSLkhCdGQauQrnBEae8xkXKEhaGZFVHjw29zEWhqCsT85\"]},\"contracts/interfaces/types/PrePosition.sol\":{\"keccak256\":\"0xa6f83f7b5f8139ec874235c406debd086a152977493c08b7f280df6f1737fb96\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://ac7d2a81f5be22873b059396dadcc11b55cabfb4df645066fc62e9f4023886e0\",\"dweb:/ipfs/QmXb33RkGN3pxSmFooZCfp92AJ6cPhgwXCM2DVJkb2W2EP\"]},\"contracts/interfaces/types/ProgramInfo.sol\":{\"keccak256\":\"0x280fcaf931b49abaec46b95ccbabaaf856a4b8e8d036413c9c3b3af25585d161\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://e755bb9bb2fa8c2f2b20226c214cf7306dfa3d84c7cfc275104b7c546d86334b\",\"dweb:/ipfs/QmbFuHfUek97FYpVQF9hP9pUZUVyTaqejvpZAzbikFWVxn\"]},\"contracts/product/Product.sol\":{\"keccak256\":\"0xab85bf0ecb604f5addc50582321f26cdde4f2694390b8ab23aad6f287542d9a2\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://b45829a6be3b45a4b5ea43877936aeff2e3ab48ec4947fe217ec15d79dd77e26\",\"dweb:/ipfs/QmT7WfRrdJDGs8LDLYvviiyJmtxNoMRXftAfPffPxg4f8V\"]},\"contracts/product/UParamProvider.sol\":{\"keccak256\":\"0x504c7d258d932adac2da0cfd17100a7109bd51476f10dcf976d9349003955d31\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://35d53ba11f2ddc4f993c4e52221b0a3e661d3129be26d2db65fa1a5595b74e7f\",\"dweb:/ipfs/QmP6qjtW72N1QSwZd4cPDfFYkqsSuy7oBsPXoLP1ca8PdF\"]},\"contracts/product/UPayoffProvider.sol\":{\"keccak256\":\"0x4faaf5519887fcf551f380b8475a6bc23e07891f35be4582096f296be532d71e\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://9d867e2da89fbf322b387326ecf3f1ddbd81d564d43ec12bed5b7c9fc3517b9c\",\"dweb:/ipfs/QmbnqZimkiCQ3T9FyRtB5Tmh7c1S11xwzSUZcFGJJwv82V\"]},\"contracts/product/types/accumulator/AccountAccumulator.sol\":{\"keccak256\":\"0x93ef06694990ed66672505461ed11a7229d622a8d3c36726884fc9505efb7471\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://d81f01965df38b8677cf9b522f25f1ad43cfa893e481567ecbc31a4a1bde54ff\",\"dweb:/ipfs/QmVFTHo1V2RmQyCDGcL7vNazhwyNxQcSVMHsnY9RjA2Ac6\"]},\"contracts/product/types/accumulator/VersionedAccumulator.sol\":{\"keccak256\":\"0xa51cccef3b5f2075f22793322508e65cedb99cd52104373bdf140c683c256d4a\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://8d961a276280623b502558cb5a914d8ad13dc96e3729347dba5abf0dc1cd6329\",\"dweb:/ipfs/QmRHUEqCWr5g4YohDbjQUFXrfnsLYcuh7FbWuAqeEGu6FU\"]},\"contracts/product/types/position/AccountPosition.sol\":{\"keccak256\":\"0xf1c2e1686ecf354e5a234e4289785453bf3476d07c5331f1460763b31373f5bf\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://215f7c9fc348aef6b640293fc702155021e1143d83589e743ea98d09aa923228\",\"dweb:/ipfs/QmPPijhx4UZ1Q2mBDTHrajNShwYSgN3Ft19gCKBf9knhZA\"]},\"contracts/product/types/position/VersionedPosition.sol\":{\"keccak256\":\"0x64314e810d2549f411f944c72f8b102fed1efb8c35b8fa49fbd70ca86b270870\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://946df2aa4daf2f635edb56550f43c81aad25c685368f9fbba9a169305df58c32\",\"dweb:/ipfs/QmXEE7p2Rp8K61ULcMivdc1rn2JJFu2JpQdBSBCFfPVKr7\"]}},\"version\":1}", - "bytecode": "0x608060405234801561001057600080fd5b50615ef280620000216000396000f3fe608060405234801561001057600080fd5b50600436106102de5760003560e01c806373b88f3b11610186578063a12e1b33116100e3578063e1c3c98d11610097578063f6b3200811610071578063f6b3200814610692578063f77c4791146106a5578063fc741c7c146106ad57600080fd5b8063e1c3c98d14610659578063f0b409591461066c578063f667f8971461067f57600080fd5b8063b7648fb9116100c8578063b7648fb9146105e9578063c07f47d41461063e578063d7d7d6b81461064657600080fd5b8063a12e1b331461057b578063ab582f29146105d657600080fd5b80638e480b201161013a57806395d89b411161011f57806395d89b411461054b5780639a427d03146105535780639d888e861461057357600080fd5b80638e480b201461050f578063916890241461053857600080fd5b80637dc0d1d01161016b5780637dc0d1d0146104bc5780637ece075d146104dc5780638c94b48f146104fc57600080fd5b806373b88f3b1461049657806376f37001146104a957600080fd5b8063476fa96d1161023f57806359ea287d116101f3578063611c71b4116101cd578063611c71b4146104685780636943b0171461047b5780636c376cc51461048e57600080fd5b806359ea287d146104455780635d16e1201461044d57806360ec91d61461045557600080fd5b806358ca6f981161022457806358ca6f98146103eb57806359218fe91461042a578063597e1fb51461043d57600080fd5b8063476fa96d146103c557806356bc1ad4146103d857600080fd5b80631e0c6fb911610296578063212e0ad31161027b578063212e0ad3146103975780633e17b8c7146103aa57806343f0179b146103bd57600080fd5b80631e0c6fb91461034957806320fe9c3c1461036957600080fd5b806311da60b4116102c757806311da60b414610316578063153261e514610320578063193775671461033357600080fd5b806305d5c1cb146102e357806306fdde0314610301575b600080fd5b6102eb6106b5565b6040516102f891906155ad565b60405180910390f35b610309610708565b6040516102f89190615619565b61031e610796565b005b61031e61032e36600461564c565b6108ea565b61033b610a21565b6040519081526020016102f8565b61035c610357366004615679565b610a4b565b6040516102f89190615696565b61037c6103773660046156d0565b610abd565b604080518251815260209283015192810192909252016102f8565b61031e6103a53660046156f7565b610ae2565b61031e6103b83660046156d0565b610c6d565b61033b610d8d565b61037c6103d33660046156d0565b610db7565b61031e6103e63660046156d0565b610dd6565b61041a6103f9366004615679565b6001600160a01b031660009081526002602052604090206007015460ff1690565b60405190151581526020016102f8565b61031e6104383660046156d0565b610ef6565b61041a6111d2565b61035c6111fc565b61033b611253565b61033b610463366004615714565b61127d565b61031e6104763660046156d0565b6112c6565b61041a610489366004615679565b6113e6565b61033b611485565b61031e6104a43660046156d0565b6114af565b61031e6104b73660046156d0565b611863565b6104c4611a45565b6040516001600160a01b0390911681526020016102f8565b6104ef6104ea3660046156d0565b611a6f565b6040516102f89190615726565b61031e61050a3660046156d0565b611b11565b61033b61051d366004615679565b6001600160a01b031660009081526009602052604090205490565b61033b610546366004615679565b611c31565b610309611c52565b6105666105613660046156d0565b611c5f565b6040516102f89190615747565b6104ef611c7e565b610583611cea565b6040516102f8919060006080820190508251600f0b82526020830151600f0b60208301526040830151600f0b60408301526fffffffffffffffffffffffffffffffff606084015116606083015292915050565b61033b6105e4366004615679565b611db7565b6105666105f7366004615679565b6040805180820190915260008082526020820152506001600160a01b0316600090815260026020908152604091829020825180840190935280548352600101549082015290565b600a5461033b565b61031e6106543660046156d0565b611dd8565b61031e6106673660046156d0565b61229c565b61031e61067a36600461575e565b6123bc565b61031e61068d366004615679565b612562565b61031e6106a0366004615679565b6126c5565b6104c4612884565b61033b6128ae565b6106da6040805160608101909152806000815260200160008152600060209091015290565b6107037f630ac9ad193fa8d8f5a7207eefdee35934d664003a3d4c286a591e065a62034e6128d8565b905090565b600080546107159061579a565b80601f01602080910402602001604051908101604052809291908181526020018280546107419061579a565b801561078e5780601f106107635761010080835404028352916020019161078e565b820191906000526020600020905b81548152906001019060200180831161077157829003601f168201915b505050505081565b60026107c07f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b036107f7576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755610823612884565b6001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610860573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061088491906157e7565b156108bb576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6108c3612985565b5060017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755565b60006108f4612884565b604051633e92a73360e11b81523060048201526001600160a01b039190911690637d254e6690602401602060405180830381865afa15801561093a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061095e9190615804565b905033610969612884565b6001600160a01b031663a123c33e836040518263ffffffff1660e01b815260040161099691815260200190565b602060405180830381865afa1580156109b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d7919061581d565b6001600160a01b031614610a065760405163123d8bcf60e21b8152600481018290526024015b60405180910390fd5b610a1d610a18368490038401846158a9565b612c51565b5050565b60006107037f897858f7b7d3c8b4e7a700b401ad192a110353a60c809946583c0d62cda7f0b75490565b610a536154f1565b506001600160a01b031660009081526002602081815260409283902083516060810185529281015483528351808501855260038201548152600482015481840152838301528351808501855260058201548152600690910154918101919091529181019190915290565b6040805180820190915260008082526020820152610adc600a83612d4e565b92915050565b6000610aec612884565b604051633e92a73360e11b81523060048201526001600160a01b039190911690637d254e6690602401602060405180830381865afa158015610b32573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b569190615804565b905033610b61612884565b6001600160a01b031663a123c33e836040518263ffffffff1660e01b8152600401610b8e91815260200190565b602060405180830381865afa158015610bab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bcf919061581d565b6001600160a01b031614610bf95760405163123d8bcf60e21b8152600481018290526024016109fd565b6000610c03612985565b9050610c2e7fbdea2cc426745068386b3804e5b401ae87ffbae9dbf293944b5307f507040c79849055565b8051604051908152831515907f482763b305ee10cd21c16c0cbeed259f2e4fcacdc9767cef16dc1fbe483d3488906020015b60405180910390a2505050565b6000610c77612884565b604051633e92a73360e11b81523060048201526001600160a01b039190911690637d254e6690602401602060405180830381865afa158015610cbd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ce19190615804565b905033610cec612884565b6001600160a01b031663a123c33e836040518263ffffffff1660e01b8152600401610d1991815260200190565b602060405180830381865afa158015610d36573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d5a919061581d565b6001600160a01b031614610d845760405163123d8bcf60e21b8152600481018290526024016109fd565b610a1d82612dad565b60006107037f1d7cfd39841edd73967db6350efae442ebd8c6e1bfca55faa52b046d39b7e4935490565b6040805180820190915260008082526020820152610adc600a83612e4f565b6000610de0612884565b604051633e92a73360e11b81523060048201526001600160a01b039190911690637d254e6690602401602060405180830381865afa158015610e26573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e4a9190615804565b905033610e55612884565b6001600160a01b031663a123c33e836040518263ffffffff1660e01b8152600401610e8291815260200190565b602060405180830381865afa158015610e9f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ec3919061581d565b6001600160a01b031614610eed5760405163123d8bcf60e21b8152600481018290526024016109fd565b610a1d82612ea7565b6002610f207f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03610f57576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755610f83612884565b6001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fc0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fe491906157e7565b1561101b576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336000611026612985565b90506110328282612f00565b3360009081526002602052604090206007015460ff161561107f576040517f6830d4d700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61108933846132fe565b3360009081526002602052604090206110a190613380565b156110d8576040517f3975ab9300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6110e06111d2565b6111a65760408051606081018252600454815281518083018352600554815260065460208281019190915280830191909152825180840184526007548152600854918101919091529181019190915260009061114890611142610561600a5490565b906133ef565b905060006111558261341e565b905061116981670de0b6b3a7640000613467565b156111a3576040517fd8b8b951000000000000000000000000000000000000000000000000000000008152600481018290526024016109fd565b50505b505060017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75550565b50565b60006107037fbdea2cc426745068386b3804e5b401ae87ffbae9dbf293944b5307f507040c795490565b6112046154f1565b5060408051606081018252600454815281518083018352600554815260065460208281019190915280830191909152825180840184526007548152600854918101919091529181019190915290565b60006107037face7e947336f94057b47a9ab5531b0363e85c8d36c05c7d915ec8e525fd159d85490565b60008061128f6020840135843561347b565b905060006112a58261129f611cea565b906134ab565b90506112be6112b76301e13380613542565b8290613556565b949350505050565b60006112d0612884565b604051633e92a73360e11b81523060048201526001600160a01b039190911690637d254e6690602401602060405180830381865afa158015611316573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061133a9190615804565b905033611345612884565b6001600160a01b031663a123c33e836040518263ffffffff1660e01b815260040161137291815260200190565b602060405180830381865afa15801561138f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b3919061581d565b6001600160a01b0316146113dd5760405163123d8bcf60e21b8152600481018290526024016109fd565b610a1d82613575565b6001600160a01b0381166000908152600260208181526040808420815160a0810183528154606080830191825260018401546080840152908252835190810184529482015485528251808401845260038301548152600483015481860152858501528251808401845260058301548152600683015481860152858401529283019390935260079092015460ff16151591810191909152610adc90613617565b60006107037f968cf792ff9a89745e4746179e93a7b9d7f08b0ff8366fd6f6dbd524ef1074645490565b60026114d97f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03611510576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75561153c612884565b6001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611579573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061159d91906157e7565b156115d4576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6115dc6111d2565b15611613576040517fded15dbf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b33600061161e612985565b905061162a8282612f00565b3360009081526002602052604090206007015460ff1615611677576040517f6830d4d700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611682600a5490565b3360009081526002602081905260409091209192506116a391018286613638565b6116af60048286613638565b604080518281526020810186905233917fb9726781b72c53f23217f424d70445b222951f008aeac7eece8139caed71ed2d910160405180910390a2506116f3612884565b6001600160a01b031663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa158015611730573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611754919061581d565b6040517fe41191800000000000000000000000000000000000000000000000000000000081523360048201523060248201526001600160a01b03919091169063e411918090604401602060405180830381865afa1580156117b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117dd91906157e7565b15611814576040517f24a21d2900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b33600090815260026020526040902061182c9061365d565b156110d8576040517f90898fd100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600261188d7f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b036118c4576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7556118f0612884565b6001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561192d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061195191906157e7565b15611988576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336000611993612985565b905061199f8282612f00565b3360009081526002602052604090206007015460ff16156119ec576040517f6830d4d700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6119f633846136bc565b336000908152600260205260409020611a0e90613380565b156111a6576040517f3975ab9300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006107037f6c0d5e3cd81753b1b21f67f61d56a97aae7a3e0179486d114788ad4576f532665490565b611a9360405180606001604052806000815260200160008152602001600081525090565b610adc611a9e611a45565b6001600160a01b0316637ece075d846040518263ffffffff1660e01b8152600401611acb91815260200190565b606060405180830381865afa158015611ae8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b0c919061593d565b61373e565b6000611b1b612884565b604051633e92a73360e11b81523060048201526001600160a01b039190911690637d254e6690602401602060405180830381865afa158015611b61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b859190615804565b905033611b90612884565b6001600160a01b031663a123c33e836040518263ffffffff1660e01b8152600401611bbd91815260200190565b602060405180830381865afa158015611bda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bfe919061581d565b6001600160a01b031614611c285760405163123d8bcf60e21b8152600481018290526024016109fd565b610a1d82613781565b6001600160a01b0381166000908152600260205260408120610adc906137da565b600180546107159061579a565b6040805180820190915260008082526020820152610adc600383613813565b611ca260405180606001604052806000815260200160008152602001600081525090565b610703611cad611a45565b6001600160a01b0316639d888e866040518163ffffffff1660e01b8152600401606060405180830381865afa158015611ae8573d6000803e3d6000fd5b6040805160808101825260008082526020820181905291810182905260608101919091526107037f917d72d9b73e141a5f0eff6b5933a24665154df6903ed198d591afc8ac62f8f660408051608081018252600080825260208201819052918101829052606081019190915281604080516080810182528254600f81810b835270010000000000000000000000000000000091829004810b60208401526001909401549384900b9282019290925291046fffffffffffffffffffffffffffffffff16606082015292915050565b6001600160a01b0381166000908152600260205260408120610adc90613879565b6002611e027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03611e39576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755611e65612884565b6001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ea2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ec691906157e7565b15611efd576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611f056111d2565b15611f3c576040517fded15dbf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336000611f47612985565b9050611f538282612f00565b600a54600003611f8f576040517fc25d67ab00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3360009081526002602052604090206007015460ff1615611fdc576040517f6830d4d700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611fe7600a5490565b336000908152600260208190526040909120919250612008910182866138f3565b612014600482866138f3565b604080518281526020810186905233917ff98b31465ac12e92b5cb136ade913276c267463c4395bb1a3999bc88fb837806910160405180910390a250612058612884565b6001600160a01b031663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa158015612095573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120b9919061581d565b6040517fe41191800000000000000000000000000000000000000000000000000000000081523360048201523060248201526001600160a01b03919091169063e411918090604401602060405180830381865afa15801561211e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061214291906157e7565b15612179576040517f24a21d2900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3360009081526002602052604090206121919061365d565b156121c8576040517f90898fd100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60408051606081018252600454815281518083018352600554815260065460208281019190915280830191909152825180840184526007548152600854918101919091529181019190915260009061222690611142610561600a5490565b905061223b612233610a21565b825190613913565b15612272576040517fcefd0e5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505060017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7555050565b60006122a6612884565b604051633e92a73360e11b81523060048201526001600160a01b039190911690637d254e6690602401602060405180830381865afa1580156122ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123109190615804565b90503361231b612884565b6001600160a01b031663a123c33e836040518263ffffffff1660e01b815260040161234891815260200190565b602060405180830381865afa158015612365573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612389919061581d565b6001600160a01b0316146123b35760405163123d8bcf60e21b8152600481018290526024016109fd565b610a1d82613929565b6001806123e77f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b5490565b10612421576040517f1e7a9d95000000000000000000000000000000000000000000000000000000008152600481018290526024016109fd565b61244a7f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b829055565b60017fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c55612477336139cb565b61249361248a60c0840160a08501615679565b83604001613a9b565b61249b613bf1565b6124d260c083013560e08401356101008501356101208601356101408701356124cd3689900389016101608a016158a9565b613c7d565b6124dc8280615979565b6000916124ea919083615a2b565b506124f86020830183615979565b600191612506919083615a2b565b5060007fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c556040518181527fbe9b076dc5b65990cca9dd9d7366682482e7817a6f6bc7f4faf4dc32af497f329060200160405180910390a15050565b600261258c7f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b036125c3576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7556125ef612884565b6001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561262c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061265091906157e7565b15612687576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000612691612985565b905061269d8282612f00565b5060017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75550565b6126cd612884565b6001600160a01b031663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa15801561270a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061272e919061581d565b6001600160a01b0316336001600160a01b031614612778576040517f40cbe9b100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6127806111d2565b156127b7576040517fded15dbf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060006127c2612985565b90506127ce8282612f00565b6001600160a01b0383166000908152600260208181526040808420815160608101835293810154845281518083018352600382015481526004820154818501528484015281518083018352600582015481526006820154818501528483015281518083019092528054825260018101549282019290925290929161285291906133ef565b90506128628582600001516132fe565b6128708582602001516136bc565b50600701805460ff19166001179055505050565b60006107037f0e555410d8128dff796eab5d29b97dd593ce9cab44a71b64c08244579ea605335490565b60006107037f5a294f9055e9dc7a18078b4e0139086766d723c3cd728bd59cc1f3b589741ed25490565b6128fd6040805160608101909152806000815260200160008152600060209091015290565b604080516060810190915282548390829060ff16600181111561292257612922615547565b600181111561293357612933615547565b81528154602090910190610100900460ff16600181111561295657612956615547565b600181111561296757612967615547565b8152905462010000900460101b61ffff191660209091015292915050565b6129a960405180606001604052806000815260200160008152602001600081525090565b60006129b3612884565b90506129bd613d21565b915060006129ca600a5490565b835190915081036129da57505090565b60006129e582611a6f565b84519091506000906129f990600490613d8f565b9050600085600001518214612a1657612a1182611a6f565b612a18565b855b9050846001600160a01b0316636fc6407c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a58573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a7c919061581d565b6001600160a01b031663a55ff01d876040518263ffffffff1660e01b8152600401612aa79190615726565b600060405180830381600087803b158015612ac157600080fd5b505af1158015612ad5573d6000803e3d6000fd5b505050506000612ae3613db2565b90506000612b00612af9600a8460038988613e2e565b8290613f72565b9050612b11612af960038886613f7e565b8851845191925014612b4357612b2f612af9600a846003878d613e2e565b8351909150612b41906003908a613f7e565b505b866001600160a01b031663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ba5919061581d565b6001600160a01b0316637f3dd53b826040518263ffffffff1660e01b8152600401612bd291815260200190565b600060405180830381600087803b158015612bec57600080fd5b505af1158015612c00573d6000803e3d6000fd5b505084518a516040517f88a84ea6dd274b386afd27dbbe11b6192b25017f5e60bb8c4053dfddb45c294d9450612c3f9350918252602082015260400190565b60405180910390a15050505050505090565b805160208201516fffffffffffffffffffffffffffffffff9182167001000000000000000000000000000000009183168202177f917d72d9b73e141a5f0eff6b5933a24665154df6903ed198d591afc8ac62f8f65560408301516060840151908316921602177f917d72d9b73e141a5f0eff6b5933a24665154df6903ed198d591afc8ac62f8f75580517f0887cb99bfd5017bb9e8282cc29d17176a4f1e542f869a03a5617919fb74620b90600f0b6020830151600f0b6040840151600f0b60608501516fffffffffffffffffffffffffffffffff166040805194855260208501939093529183015260608201526080015b60405180910390a150565b6040805180820182526000808252602080830182905284825260018601815290839020835180850190945254600f81810b8552700100000000000000000000000000000000909104900b9083015290612da69061407c565b9392505050565b612dbf81670de0b6b3a7640000613913565b15612df6576040517fccbac87e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612e1f7f5a294f9055e9dc7a18078b4e0139086766d723c3cd728bd59cc1f3b589741ed2829055565b6040518181527f3ffba897342f8382491dd8984c684cc237d3c045298d4cec8ad0fd7262aa91f190602001612d43565b6040805180820182526000808252602080830182905284825260028601815290839020835180850190945254600f81810b8552700100000000000000000000000000000000909104900b9083015290612da69061407c565b612ed07f968cf792ff9a89745e4746179e93a7b9d7f08b0ff8366fd6f6dbd524ef107464829055565b6040518181527f5339371c8d31c4fb29fd4ad6b3bf89793839a3dfae45035ef23a635916dafc6590602001612d43565b6000612f0a612884565b8251909150612f2e846001600160a01b031660009081526009602052604090205490565b03612f3857505050565b81516001600160a01b038416600090815260026020819052604082209192612f639290910190613d8f565b9050600083600001518214612f8057612f7b82611a6f565b612f82565b835b90506000836001600160a01b0316636fc6407c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612fc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fe8919061581d565b6001600160a01b0316631830349c87846040518363ffffffff1660e01b8152600401613015929190615aec565b600060405180830381600087803b15801561302f57600080fd5b505af1158015613043573d6000803e3d6000fd5b5050506001600160a01b038716600090815260026020908152604080832086516009909352922061308c93506130859261308092600a91906140b8565b614121565b8290614131565b6001600160a01b03871660009081526002602052604090209091506130c5906130be906130b9908561413d565b614201565b8290614260565b85518351919250146131ce57836001600160a01b0316636fc6407c6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561310f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613133919061581d565b6001600160a01b0316631830349c87876040518363ffffffff1660e01b8152600401613160929190615aec565b600060405180830381600087803b15801561317a57600080fd5b505af115801561318e573d6000803e3d6000fd5b5050506001600160a01b03871660009081526002602090815260408083208951600990935292206131cb93506130859261308092600a91906140b8565b90505b836001600160a01b031663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa15801561320c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613230919061581d565b6040517fc9cb48de0000000000000000000000000000000000000000000000000000000081526001600160a01b03888116600483015260248201849052919091169063c9cb48de90604401600060405180830381600087803b15801561329557600080fd5b505af11580156132a9573d6000803e3d6000fd5b5050835187516040805192835260208301919091526001600160a01b038a1693507f9d7055d24918d8c2fd08660a27bf31d4086fa71a51cd07874276470223aa480f92500160405180910390a2505050505050565b6000613309600a5490565b6001600160a01b03841660009081526002602081905260409091209192506133339101828461426c565b61333f6004828461426c565b60408051828152602081018490526001600160a01b038516917f39854479080fac0b5e7c0ecedb0fb02308a72a43cd102c6b9f918653d34003679101610c60565b60408051808201825260038301548152600483015460208083019190915282518084019093528354835260018401549083015260009182916133c2919061428c565b805160058501549192506133d69190613913565b80612da6575060208101516006840154612da691613913565b6040805180820190915260008082526020820152612da661341484846020015161428c565b83604001516142e3565b600061342c82602001511590565b613458576020820151825161345391670de0b6b3a76400009161344e91614331565b614350565b610adc565b670de0b6b3a764000092915050565b6000613473838361435c565b159392505050565b6000816134a15782156134905760001961349a565b670de0b6b3a76400005b9050610adc565b61349a8383614331565b60608201516000906fffffffffffffffffffffffffffffffff166134cf8382613467565b156134f95783516134f190600090600f0b60408701518490600f0b5b87614391565b915050610adc565b61350b83670de0b6b3a7640000613467565b156135355760408401516134f1908290600f0b6020870151670de0b6b3a764000090600f0b6134eb565b50505060200151600f0b90565b6000610adc670de0b6b3a764000083615b4c565b60008161356b670de0b6b3a764000085615b4c565b612da69190615c37565b61358781670de0b6b3a7640000613913565b156135be576040517f4589bde600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6135e77f1d7cfd39841edd73967db6350efae442ebd8c6e1bfca55faa52b046d39b7e493829055565b6040518181527f587b2c669227029fa59d08b2061678cdf5536e8709f7760940e5cf5f24336e4690602001612d43565b60006136268260200151614442565b8015610adc57508151610adc90614461565b60028301546136479082613f72565b600284015581835561365883614479565b505050565b8054600090819015801561367357506003830154155b801561368157506005830154155b600184015490915060009015801561369b57506004840154155b80156136a957506006840154155b9050811580156112be5750159392505050565b60006136c7600a5490565b6001600160a01b03841660009081526002602081905260409091209192506136f1910182846144d5565b6136fd600482846144d5565b60408051828152602081018490526001600160a01b038516917f63625b85818a29587ee919ee6a968ee0b32f3513f2884b3968001062ba49eb6b9101610c60565b61376260405180606001604052806000815260200160008152602001600081525090565b61377882604001516137726106b5565b906144f5565b60408301525090565b6137aa7f897858f7b7d3c8b4e7a700b401ad192a110353a60c809946583c0d62cda7f0b7829055565b6040518181527ff6bebbfbe342f87db90e223fb3dd70b26b082ed4266f1673b509dfeca0a7697a90602001612d43565b600781015460009060ff16156137f257506000919050565b604080518082019091528254815260018301546020820152610adc906145ec565b6040805180820190915260008082526020820152600082815260208481526040918290208251808401909352546fffffffffffffffffffffffffffffffff80821684527001000000000000000000000000000000009091041690820152612da6906146f3565b60408051606081018252600283015481528151808301835260038401548152600484015460208281019190915280830191909152825180840184526005850154815260068501548183015282840152825180840190935283548352600184015490830152600091610adc916138ee91906133ef565b6145ec565b60018301546139029082613f72565b600184015581835561365883614749565b600061391f838361435c565b6002149392505050565b61393b81670de0b6b3a7640000613913565b15613972576040517f82894f6b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61399b7face7e947336f94057b47a9ab5531b0363e85c8d36c05c7d915ec8e525fd159d8829055565b6040518181527ffb8fb3fd721f9e0d7396f8475680125318fb14fffa561a1ab43dfa329f2fd98a90602001612d43565b303b151580156139fa57507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b15613a31576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0381163b613a72576040517f14878b6900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6111cf7f0e555410d8128dff796eab5d29b97dd593ce9cab44a71b64c08244579ea60533829055565b303b15158015613aca57507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b15613b01576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0382163b613b42576040517fd26af10d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b613b6b7f6c0d5e3cd81753b1b21f67f61d56a97aae7a3e0179486d114788ad4576f53266839055565b613b82613b7d36839003830183615c8e565b6147a5565b613bb8576040517f9a51fe8f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610a1d613bca36839003830183615c8e565b7f630ac9ad193fa8d8f5a7207eefdee35934d664003a3d4c286a591e065a62034e906147ea565b303b15158015613c2057507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b15613c57576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755565b303b15158015613cac57507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b15613ce3576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b613cec86612ea7565b613cf585613929565b613cfe84612dad565b613d0783613575565b613d1082613781565b613d1981612c51565b505050505050565b613d4560405180606001604052806000815260200160008152602001600081525090565b610703613d50611a45565b6001600160a01b031663fff6cae96040518163ffffffff1660e01b81526004016060604051808303816000875af1158015611ae8573d6000803e3d6000fd5b81546000908015613daa57613da5816001615cea565b6112be565b509092915050565b6000610703613dbf612884565b6001600160a01b031663e975c0c36040518163ffffffff1660e01b8152600401602060405180830381865afa158015613dfc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e209190615804565b613e28611253565b90614873565b81516000908190613e40908690613813565b9050613e5f604051806040016040528060008152602001600081525090565b613e6b8783878761487f565b93509050613e84613e7d838787614b14565b8290614c7c565b90506000613e93838787614cca565b9050613eb5613eb083613eaa8c8a60000151612d4e565b90614c7c565b614d4f565b8551600090815260018b0160209081526040909120825192909101516fffffffffffffffffffffffffffffffff9081167001000000000000000000000000000000000292169190911790558551613f1790613eb0908390613eaa908d90612e4f565b8551600090815260028b0160209081526040909120825192909101516fffffffffffffffffffffffffffffffff9081167001000000000000000000000000000000000292169190911790555050915190955550929392505050565b6000612da68284615cea565b60408051606081018252600185015481528151808301835260028601548152600386015460208281019190915280830191909152825180840184526004870154815260058701549181019190915291810191909152600090819081908190613ff29086613feb8a8a613813565b9190614d9b565b92509250925061400183614def565b8551600090815260208981526040909120825192909101516fffffffffffffffffffffffffffffffff90811670010000000000000000000000000000000002921691909117905580156140725760006001880181905560028801819055600388018190556004880181905560058801555b5095945050505050565b60408051808201909152600080825260208201526040805180820190915282518190600f0b8152602084810151910190600f0b5b905292915050565b604080518082019091526000808252602082015284546000906140f0906140e0908790612d4e565b6140ea8786612d4e565b90614e59565b6040805180820190915285548152600186015460208201529091506141159082614ea7565b92909555509392505050565b60208101518151600091610adc91905b6000612da68284615d02565b6040805160608101825260028401548152815180830183526003850154815260048501546020828101919091528083019190915282518084018452600586015481526006860154818301528284015282518084019093528454835260018501549083015260009182916141b1919085614d9b565b8251875560209092015160018701559250905080156141fa57600060028501819055600385018190556004850181905560058501819055600685015560078401805460ff191690555b5092915050565b6000817f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811115610adc576040517ea07eb5000000000000000000000000000000000000000000000000000000008152600481018290526024016109fd565b6000612da68284615d76565b600383015461427b9082613f72565b600384015581835561365883614749565b6040805180820190915260008082526020820152604080518082019091528251845182916142ba9190613f72565b81526020016142da84602001518660200151613f7290919063ffffffff16565b90529392505050565b6040805180820190915260008082526020820152604080518082019091528251845182916143119190614ef5565b81526020016142da84602001518660200151614ef590919063ffffffff16565b600081614346670de0b6b3a764000085615dea565b612da69190615e09565b6000612da68383614f01565b600082828082111561437357600292505050610adc565b8082101561438657600092505050610adc565b506001949350505050565b600061439d8287613467565b806143ad57506143ad8285613913565b156143e4576040517f0db0f7cb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006143f08588614ef5565b905060006143fe8588614260565b9050600061441683614410878c614ef5565b90614331565b90506144358861442f61442884614201565b8590614f17565b90614131565b9998505050505050505050565b60006144518260200151614461565b8015610adc5750610adc82604001515b8051600090158015610adc5750602082015115610adc565b6004810154600282015461448c91613913565b156144b357600481015460028201546144a491614ef5565b60028201556000600482015550565b600281015460048201546144c691614ef5565b60048201556000600282015550565b60048301546144e49082613f72565b600484015581835561365883614479565b8151602083015160009190828083600181111561451457614514615547565b03614520575083614580565b600183600181111561453457614534615547565b0361454a576145438686614f2c565b9050614580565b82826040517f7ebf97b40000000000000000000000000000000000000000000000000000000081526004016109fd929190615e1d565b60008660200151600181111561459857614598615547565b036145a7579250610adc915050565b6001866020015160018111156145bf576145bf615547565b0361454a576145e26145db670de0b6b3a7640000600019615b4c565b8290614f17565b9350505050610adc565b6000803090506000816001600160a01b0316639d888e866040518163ffffffff1660e01b8152600401606060405180830381865afa158015614632573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614656919061593d565b604001519050600061467c614677836146716130b989614fcb565b90614f17565b614fdf565b90506146ea836001600160a01b0316636c376cc56040518163ffffffff1660e01b8152600401602060405180830381865afa1580156146bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906146e39190615804565b8290614fea565b95945050505050565b604080518082019091526000808252602082015260408051808201909152825181906fffffffffffffffffffffffffffffffff1681526020848101519101906fffffffffffffffffffffffffffffffff166140b0565b6003810154600182015461475c91613913565b15614783576003810154600182015461477491614ef5565b60018201556000600382015550565b6001810154600382015461479691614ef5565b60038201556000600182015550565b60006001825160018111156147bc576147bc615547565b036147dc57610adc6147cd83614fff565b6001600160a01b03163b151590565b506040015161ffff19161590565b80518254839190829060ff19166001838181111561480a5761480a615547565b02179055506020820151815482907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff1661010083600181111561484f5761484f615547565b0217905550604090910151815460109190911c620100000261ffff90911617905550565b6000612da6838361506a565b60408051808201909152600080825260208201526000306001600160a01b031663597e1fb56040518163ffffffff1660e01b8152600401602060405180830381865afa1580156148d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148f791906157e7565b1561491957505060408051808201909152600080825260208201819052614b0b565b602085015161493f57505060408051808201909152600080825260208201819052614b0b565b845161496257505060408051808201909152600080825260208201819052614b0b565b6000846020015184602001516149789190615e43565b9050600061499461467787604001516146718a60200151614201565b905060006149ab6149a48961341e565b8390614fea565b90506000614a3b6149be6130b98661507a565b6040517f60ec91d600000000000000000000000000000000000000000000000000000000815230906360ec91d6906149fa908e90600401615747565b602060405180830381865afa158015614a17573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906146719190615804565b90506000614a52614a4b84614201565b8390614f17565b9050614a678b614a6183614fdf565b90614fea565b95506000614a8f614a778361508e565b614a8a89614a8486614fdf565b90614ef5565b6150ba565b9050600080614a9d8461508e565b129050614ac3614ab08d60000151614201565b82614abb5783614abd565b845b90613556565b8952614afe614adc670de0b6b3a7640000600019615b4c565b614671614aec8f60200151614201565b84614af75786614abd565b8590613556565b60208a0152505050505050505b94509492505050565b6040805180820190915260008082526020820152306001600160a01b031663597e1fb56040518163ffffffff1660e01b8152600401602060405180830381865afa158015614b66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614b8a91906157e7565b15614ba957506040805180820190915260008082526020820152612da6565b6020840151614bcc57506040805180820190915260008082526020820152612da6565b8351614bec57506040805180820190915260008082526020820152612da6565b6000614c098460400151846040015161426090919063ffffffff16565b90506000614c1d614a4b8760200151614201565b90506000614c30614a4b6130b98961341e565b9050614c59614c49670de0b6b3a7640000600019615b4c565b614671614abb8a60000151614201565b84526020870151614c6d906112b790614201565b60208501525050509392505050565b604080518082019091526000808252602082015260408051808201909152825184518291614caa9190614131565b81526020016142da8460200151866020015161413190919063ffffffff16565b6040805180820190915260008082526020820152600083602001518360200151614cf49190615e43565b855190915015614d1757614d126130b986600001516144108461507a565b614d1a565b60005b8252602085015115614d3f57614d3a6130b986602001516144108461507a565b614d42565b60005b6020830152509392505050565b60408051808201909152600080825260208201526040518060400160405280614d7b84600001516150f4565b600f0b8152602001614d9084602001516150f4565b600f0b905292915050565b6040805180820190915260008082526020820152600080614dbc85856151a1565b614dc95785600080614de0565b614dd386866133ef565b614ddd86866151bd565b60015b92509250925093509350939050565b60408051808201909152600080825260208201526040518060400160405280614e1b8460000151615305565b6fffffffffffffffffffffffffffffffff168152602001614e3f8460200151615305565b6fffffffffffffffffffffffffffffffff16905292915050565b604080518082019091526000808252602082015260408051808201909152825184518291614e879190614260565b81526020016142da8460200151866020015161426090919063ffffffff16565b60408051808201909152600080825260208201526040518060400160405280614edb84600001516146718760000151614201565b81526020016142da84602001516146718760200151614201565b6000612da68284615e43565b6000818310614f105781612da6565b5090919050565b6000670de0b6b3a764000061356b8385615b4c565b600080614fb583604051602401614f4591815260200190565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fd7c7a93500000000000000000000000000000000000000000000000000000000179052614fa686614fff565b6001600160a01b031690615355565b9050808060200190518101906112be9190615804565b6000610adc82600001518360200151614873565b6000610adc8261537a565b6000670de0b6b3a76400006143468385615dea565b600060018251600181111561501657615016615547565b1461505657815160408084015190517f4f5b470e0000000000000000000000000000000000000000000000000000000081526109fd929190600401615e5a565b506040015160101c6001600160a01b031690565b600081831015614f105781612da6565b6000610adc670de0b6b3a764000083615dea565b6000808213156150a057506001919050565b60008212156150b25750600019919050565b506000919050565b6000808313156150cd5761349a82614201565b60008312156150eb576150df82614201565b61349a90600019615b4c565b50600092915050565b6000816f7fffffffffffffffffffffffffffffff811315615144576040517f59aeb746000000000000000000000000000000000000000000000000000000008152600481018290526024016109fd565b7fffffffffffffffffffffffffffffffff80000000000000000000000000000000811215610adc576040517f4e02165d000000000000000000000000000000000000000000000000000000008152600481018290526024016109fd565b60006151ac83614442565b158015612da6575050905190511190565b6000806151db8460400151856020015161428c90919063ffffffff16565b90506000806151f861467786604001516146718660000151614201565b61521061467787604001516146718760200151614201565b9150915060003090506152fa615288826001600160a01b03166343f0179b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561525d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906152819190615804565b8490614fea565b6152f4836001600160a01b031663fc741c7c6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156152c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906152ed9190615804565b8690614fea565b90613f72565b979650505050505050565b6000816fffffffffffffffffffffffffffffffff811115610adc576040517f53851291000000000000000000000000000000000000000000000000000000008152600481018290526024016109fd565b6060612da68383604051806060016040528060258152602001615e9860259139615391565b60008082121561538d5781600003610adc565b5090565b60606001600160a01b0384163b615429576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f416464726573733a207374617469632063616c6c20746f206e6f6e2d636f6e7460448201527f726163740000000000000000000000000000000000000000000000000000000060648201526084016109fd565b600080856001600160a01b0316856040516154449190615e7b565b600060405180830381855afa9150503d806000811461547f576040519150601f19603f3d011682016040523d82523d6000602084013e615484565b606091505b509150915061549482828661549e565b9695505050505050565b606083156154ad575081612da6565b8251156154bd5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109fd9190615619565b604051806060016040528060008152602001615520604051806040016040528060008152602001600081525090565b8152602001615542604051806040016040528060008152602001600081525090565b905290565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b600281106111cf577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b815160608201906155bd81615576565b825260208301516155cd81615576565b8060208401525061ffff19604084015116604083015292915050565b60005b838110156156045781810151838201526020016155ec565b83811115615613576000848401525b50505050565b60208152600082518060208401526156388160408501602087016155e9565b601f01601f19169190910160400192915050565b60006080828403121561565e57600080fd5b50919050565b6001600160a01b03811681146111cf57600080fd5b60006020828403121561568b57600080fd5b8135612da681615664565b8151815260208083015180518284015290810151604083015260a082019050604083015180516060840152602081015160808401526141fa565b6000602082840312156156e257600080fd5b5035919050565b80151581146111cf57600080fd5b60006020828403121561570957600080fd5b8135612da6816156e9565b60006040828403121561565e57600080fd5b81518152602080830151908201526040808301519082015260608101610adc565b815181526020808301519082015260408101610adc565b60006020828403121561577057600080fd5b813567ffffffffffffffff81111561578757600080fd5b82016101e08185031215612da657600080fd5b600181811c908216806157ae57607f821691505b60208210810361565e577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000602082840312156157f957600080fd5b8151612da6816156e9565b60006020828403121561581657600080fd5b5051919050565b60006020828403121561582f57600080fd5b8151612da681615664565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516060810167ffffffffffffffff8111828210171561588c5761588c61583a565b60405290565b8035600f81900b81146158a457600080fd5b919050565b6000608082840312156158bb57600080fd5b6040516080810181811067ffffffffffffffff821117156158de576158de61583a565b6040526158ea83615892565b81526158f860208401615892565b602082015261590960408401615892565b604082015260608301356fffffffffffffffffffffffffffffffff8116811461593157600080fd5b60608201529392505050565b60006060828403121561594f57600080fd5b615957615869565b8251815260208301516020820152604083015160408201528091505092915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126159ae57600080fd5b83018035915067ffffffffffffffff8211156159c957600080fd5b6020019150368190038213156159de57600080fd5b9250929050565b601f82111561365857600081815260208120601f850160051c81016020861015615a0c5750805b601f850160051c820191505b81811015613d1957828155600101615a18565b67ffffffffffffffff831115615a4357615a4361583a565b615a5783615a51835461579a565b836159e5565b6000601f841160018114615a8b5760008515615a735750838201355b600019600387901b1c1916600186901b178355615ae5565b600083815260209020601f19861690835b82811015615abc5786850135825560209485019460019092019101615a9c565b5086821015615ad95760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b6001600160a01b038316815260808101612da660208301848051825260208082015190830152604090810151910152565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600084136000841385830485118282161615615b8d57615b8d615b1d565b7f80000000000000000000000000000000000000000000000000000000000000006000871286820588128184161615615bc857615bc8615b1d565b60008712925087820587128484161615615be457615be4615b1d565b87850587128184161615615bfa57615bfa615b1d565b505050929093029392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600082615c4657615c46615c08565b60001983147f800000000000000000000000000000000000000000000000000000000000000083141615615c7c57615c7c615b1d565b500590565b600281106111cf57600080fd5b600060608284031215615ca057600080fd5b615ca8615869565b8235615cb381615c81565b81526020830135615cc381615c81565b6020820152604083013561ffff1981168114615cde57600080fd5b60408201529392505050565b60008219821115615cfd57615cfd615b1d565b500190565b6000808212827f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03841381151615615d3c57615d3c615b1d565b827f8000000000000000000000000000000000000000000000000000000000000000038412811615615d7057615d70615b1d565b50500190565b6000808312837f800000000000000000000000000000000000000000000000000000000000000001831281151615615db057615db0615b1d565b837f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff018313811615615de457615de4615b1d565b50500390565b6000816000190483118215151615615e0457615e04615b1d565b500290565b600082615e1857615e18615c08565b500490565b60408101615e2a84615576565b838252615e3683615576565b8260208301529392505050565b600082821015615e5557615e55615b1d565b500390565b60408101615e6784615576565b92815261ffff199190911660209091015290565b60008251615e8d8184602087016155e9565b919091019291505056fe416464726573733a206c6f772d6c6576656c207374617469632063616c6c206661696c6564a2646970667358221220c8f28337b68a0a25a9b849842eef3dea5522fe30a7a3178bfe70c89801c2062264736f6c634300080f0033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106102de5760003560e01c806373b88f3b11610186578063a12e1b33116100e3578063e1c3c98d11610097578063f6b3200811610071578063f6b3200814610692578063f77c4791146106a5578063fc741c7c146106ad57600080fd5b8063e1c3c98d14610659578063f0b409591461066c578063f667f8971461067f57600080fd5b8063b7648fb9116100c8578063b7648fb9146105e9578063c07f47d41461063e578063d7d7d6b81461064657600080fd5b8063a12e1b331461057b578063ab582f29146105d657600080fd5b80638e480b201161013a57806395d89b411161011f57806395d89b411461054b5780639a427d03146105535780639d888e861461057357600080fd5b80638e480b201461050f578063916890241461053857600080fd5b80637dc0d1d01161016b5780637dc0d1d0146104bc5780637ece075d146104dc5780638c94b48f146104fc57600080fd5b806373b88f3b1461049657806376f37001146104a957600080fd5b8063476fa96d1161023f57806359ea287d116101f3578063611c71b4116101cd578063611c71b4146104685780636943b0171461047b5780636c376cc51461048e57600080fd5b806359ea287d146104455780635d16e1201461044d57806360ec91d61461045557600080fd5b806358ca6f981161022457806358ca6f98146103eb57806359218fe91461042a578063597e1fb51461043d57600080fd5b8063476fa96d146103c557806356bc1ad4146103d857600080fd5b80631e0c6fb911610296578063212e0ad31161027b578063212e0ad3146103975780633e17b8c7146103aa57806343f0179b146103bd57600080fd5b80631e0c6fb91461034957806320fe9c3c1461036957600080fd5b806311da60b4116102c757806311da60b414610316578063153261e514610320578063193775671461033357600080fd5b806305d5c1cb146102e357806306fdde0314610301575b600080fd5b6102eb6106b5565b6040516102f891906155ad565b60405180910390f35b610309610708565b6040516102f89190615619565b61031e610796565b005b61031e61032e36600461564c565b6108ea565b61033b610a21565b6040519081526020016102f8565b61035c610357366004615679565b610a4b565b6040516102f89190615696565b61037c6103773660046156d0565b610abd565b604080518251815260209283015192810192909252016102f8565b61031e6103a53660046156f7565b610ae2565b61031e6103b83660046156d0565b610c6d565b61033b610d8d565b61037c6103d33660046156d0565b610db7565b61031e6103e63660046156d0565b610dd6565b61041a6103f9366004615679565b6001600160a01b031660009081526002602052604090206007015460ff1690565b60405190151581526020016102f8565b61031e6104383660046156d0565b610ef6565b61041a6111d2565b61035c6111fc565b61033b611253565b61033b610463366004615714565b61127d565b61031e6104763660046156d0565b6112c6565b61041a610489366004615679565b6113e6565b61033b611485565b61031e6104a43660046156d0565b6114af565b61031e6104b73660046156d0565b611863565b6104c4611a45565b6040516001600160a01b0390911681526020016102f8565b6104ef6104ea3660046156d0565b611a6f565b6040516102f89190615726565b61031e61050a3660046156d0565b611b11565b61033b61051d366004615679565b6001600160a01b031660009081526009602052604090205490565b61033b610546366004615679565b611c31565b610309611c52565b6105666105613660046156d0565b611c5f565b6040516102f89190615747565b6104ef611c7e565b610583611cea565b6040516102f8919060006080820190508251600f0b82526020830151600f0b60208301526040830151600f0b60408301526fffffffffffffffffffffffffffffffff606084015116606083015292915050565b61033b6105e4366004615679565b611db7565b6105666105f7366004615679565b6040805180820190915260008082526020820152506001600160a01b0316600090815260026020908152604091829020825180840190935280548352600101549082015290565b600a5461033b565b61031e6106543660046156d0565b611dd8565b61031e6106673660046156d0565b61229c565b61031e61067a36600461575e565b6123bc565b61031e61068d366004615679565b612562565b61031e6106a0366004615679565b6126c5565b6104c4612884565b61033b6128ae565b6106da6040805160608101909152806000815260200160008152600060209091015290565b6107037f630ac9ad193fa8d8f5a7207eefdee35934d664003a3d4c286a591e065a62034e6128d8565b905090565b600080546107159061579a565b80601f01602080910402602001604051908101604052809291908181526020018280546107419061579a565b801561078e5780601f106107635761010080835404028352916020019161078e565b820191906000526020600020905b81548152906001019060200180831161077157829003601f168201915b505050505081565b60026107c07f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b036107f7576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755610823612884565b6001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610860573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061088491906157e7565b156108bb576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6108c3612985565b5060017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755565b60006108f4612884565b604051633e92a73360e11b81523060048201526001600160a01b039190911690637d254e6690602401602060405180830381865afa15801561093a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061095e9190615804565b905033610969612884565b6001600160a01b031663a123c33e836040518263ffffffff1660e01b815260040161099691815260200190565b602060405180830381865afa1580156109b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d7919061581d565b6001600160a01b031614610a065760405163123d8bcf60e21b8152600481018290526024015b60405180910390fd5b610a1d610a18368490038401846158a9565b612c51565b5050565b60006107037f897858f7b7d3c8b4e7a700b401ad192a110353a60c809946583c0d62cda7f0b75490565b610a536154f1565b506001600160a01b031660009081526002602081815260409283902083516060810185529281015483528351808501855260038201548152600482015481840152838301528351808501855260058201548152600690910154918101919091529181019190915290565b6040805180820190915260008082526020820152610adc600a83612d4e565b92915050565b6000610aec612884565b604051633e92a73360e11b81523060048201526001600160a01b039190911690637d254e6690602401602060405180830381865afa158015610b32573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b569190615804565b905033610b61612884565b6001600160a01b031663a123c33e836040518263ffffffff1660e01b8152600401610b8e91815260200190565b602060405180830381865afa158015610bab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bcf919061581d565b6001600160a01b031614610bf95760405163123d8bcf60e21b8152600481018290526024016109fd565b6000610c03612985565b9050610c2e7fbdea2cc426745068386b3804e5b401ae87ffbae9dbf293944b5307f507040c79849055565b8051604051908152831515907f482763b305ee10cd21c16c0cbeed259f2e4fcacdc9767cef16dc1fbe483d3488906020015b60405180910390a2505050565b6000610c77612884565b604051633e92a73360e11b81523060048201526001600160a01b039190911690637d254e6690602401602060405180830381865afa158015610cbd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ce19190615804565b905033610cec612884565b6001600160a01b031663a123c33e836040518263ffffffff1660e01b8152600401610d1991815260200190565b602060405180830381865afa158015610d36573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d5a919061581d565b6001600160a01b031614610d845760405163123d8bcf60e21b8152600481018290526024016109fd565b610a1d82612dad565b60006107037f1d7cfd39841edd73967db6350efae442ebd8c6e1bfca55faa52b046d39b7e4935490565b6040805180820190915260008082526020820152610adc600a83612e4f565b6000610de0612884565b604051633e92a73360e11b81523060048201526001600160a01b039190911690637d254e6690602401602060405180830381865afa158015610e26573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e4a9190615804565b905033610e55612884565b6001600160a01b031663a123c33e836040518263ffffffff1660e01b8152600401610e8291815260200190565b602060405180830381865afa158015610e9f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ec3919061581d565b6001600160a01b031614610eed5760405163123d8bcf60e21b8152600481018290526024016109fd565b610a1d82612ea7565b6002610f207f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03610f57576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755610f83612884565b6001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fc0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fe491906157e7565b1561101b576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336000611026612985565b90506110328282612f00565b3360009081526002602052604090206007015460ff161561107f576040517f6830d4d700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61108933846132fe565b3360009081526002602052604090206110a190613380565b156110d8576040517f3975ab9300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6110e06111d2565b6111a65760408051606081018252600454815281518083018352600554815260065460208281019190915280830191909152825180840184526007548152600854918101919091529181019190915260009061114890611142610561600a5490565b906133ef565b905060006111558261341e565b905061116981670de0b6b3a7640000613467565b156111a3576040517fd8b8b951000000000000000000000000000000000000000000000000000000008152600481018290526024016109fd565b50505b505060017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75550565b50565b60006107037fbdea2cc426745068386b3804e5b401ae87ffbae9dbf293944b5307f507040c795490565b6112046154f1565b5060408051606081018252600454815281518083018352600554815260065460208281019190915280830191909152825180840184526007548152600854918101919091529181019190915290565b60006107037face7e947336f94057b47a9ab5531b0363e85c8d36c05c7d915ec8e525fd159d85490565b60008061128f6020840135843561347b565b905060006112a58261129f611cea565b906134ab565b90506112be6112b76301e13380613542565b8290613556565b949350505050565b60006112d0612884565b604051633e92a73360e11b81523060048201526001600160a01b039190911690637d254e6690602401602060405180830381865afa158015611316573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061133a9190615804565b905033611345612884565b6001600160a01b031663a123c33e836040518263ffffffff1660e01b815260040161137291815260200190565b602060405180830381865afa15801561138f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b3919061581d565b6001600160a01b0316146113dd5760405163123d8bcf60e21b8152600481018290526024016109fd565b610a1d82613575565b6001600160a01b0381166000908152600260208181526040808420815160a0810183528154606080830191825260018401546080840152908252835190810184529482015485528251808401845260038301548152600483015481860152858501528251808401845260058301548152600683015481860152858401529283019390935260079092015460ff16151591810191909152610adc90613617565b60006107037f968cf792ff9a89745e4746179e93a7b9d7f08b0ff8366fd6f6dbd524ef1074645490565b60026114d97f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03611510576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75561153c612884565b6001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611579573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061159d91906157e7565b156115d4576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6115dc6111d2565b15611613576040517fded15dbf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b33600061161e612985565b905061162a8282612f00565b3360009081526002602052604090206007015460ff1615611677576040517f6830d4d700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611682600a5490565b3360009081526002602081905260409091209192506116a391018286613638565b6116af60048286613638565b604080518281526020810186905233917fb9726781b72c53f23217f424d70445b222951f008aeac7eece8139caed71ed2d910160405180910390a2506116f3612884565b6001600160a01b031663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa158015611730573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611754919061581d565b6040517fe41191800000000000000000000000000000000000000000000000000000000081523360048201523060248201526001600160a01b03919091169063e411918090604401602060405180830381865afa1580156117b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117dd91906157e7565b15611814576040517f24a21d2900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b33600090815260026020526040902061182c9061365d565b156110d8576040517f90898fd100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600261188d7f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b036118c4576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7556118f0612884565b6001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561192d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061195191906157e7565b15611988576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336000611993612985565b905061199f8282612f00565b3360009081526002602052604090206007015460ff16156119ec576040517f6830d4d700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6119f633846136bc565b336000908152600260205260409020611a0e90613380565b156111a6576040517f3975ab9300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006107037f6c0d5e3cd81753b1b21f67f61d56a97aae7a3e0179486d114788ad4576f532665490565b611a9360405180606001604052806000815260200160008152602001600081525090565b610adc611a9e611a45565b6001600160a01b0316637ece075d846040518263ffffffff1660e01b8152600401611acb91815260200190565b606060405180830381865afa158015611ae8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b0c919061593d565b61373e565b6000611b1b612884565b604051633e92a73360e11b81523060048201526001600160a01b039190911690637d254e6690602401602060405180830381865afa158015611b61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b859190615804565b905033611b90612884565b6001600160a01b031663a123c33e836040518263ffffffff1660e01b8152600401611bbd91815260200190565b602060405180830381865afa158015611bda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bfe919061581d565b6001600160a01b031614611c285760405163123d8bcf60e21b8152600481018290526024016109fd565b610a1d82613781565b6001600160a01b0381166000908152600260205260408120610adc906137da565b600180546107159061579a565b6040805180820190915260008082526020820152610adc600383613813565b611ca260405180606001604052806000815260200160008152602001600081525090565b610703611cad611a45565b6001600160a01b0316639d888e866040518163ffffffff1660e01b8152600401606060405180830381865afa158015611ae8573d6000803e3d6000fd5b6040805160808101825260008082526020820181905291810182905260608101919091526107037f917d72d9b73e141a5f0eff6b5933a24665154df6903ed198d591afc8ac62f8f660408051608081018252600080825260208201819052918101829052606081019190915281604080516080810182528254600f81810b835270010000000000000000000000000000000091829004810b60208401526001909401549384900b9282019290925291046fffffffffffffffffffffffffffffffff16606082015292915050565b6001600160a01b0381166000908152600260205260408120610adc90613879565b6002611e027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03611e39576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755611e65612884565b6001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ea2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ec691906157e7565b15611efd576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611f056111d2565b15611f3c576040517fded15dbf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336000611f47612985565b9050611f538282612f00565b600a54600003611f8f576040517fc25d67ab00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3360009081526002602052604090206007015460ff1615611fdc576040517f6830d4d700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611fe7600a5490565b336000908152600260208190526040909120919250612008910182866138f3565b612014600482866138f3565b604080518281526020810186905233917ff98b31465ac12e92b5cb136ade913276c267463c4395bb1a3999bc88fb837806910160405180910390a250612058612884565b6001600160a01b031663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa158015612095573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120b9919061581d565b6040517fe41191800000000000000000000000000000000000000000000000000000000081523360048201523060248201526001600160a01b03919091169063e411918090604401602060405180830381865afa15801561211e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061214291906157e7565b15612179576040517f24a21d2900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3360009081526002602052604090206121919061365d565b156121c8576040517f90898fd100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60408051606081018252600454815281518083018352600554815260065460208281019190915280830191909152825180840184526007548152600854918101919091529181019190915260009061222690611142610561600a5490565b905061223b612233610a21565b825190613913565b15612272576040517fcefd0e5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505060017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7555050565b60006122a6612884565b604051633e92a73360e11b81523060048201526001600160a01b039190911690637d254e6690602401602060405180830381865afa1580156122ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123109190615804565b90503361231b612884565b6001600160a01b031663a123c33e836040518263ffffffff1660e01b815260040161234891815260200190565b602060405180830381865afa158015612365573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612389919061581d565b6001600160a01b0316146123b35760405163123d8bcf60e21b8152600481018290526024016109fd565b610a1d82613929565b6001806123e77f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b5490565b10612421576040517f1e7a9d95000000000000000000000000000000000000000000000000000000008152600481018290526024016109fd565b61244a7f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b829055565b60017fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c55612477336139cb565b61249361248a60c0840160a08501615679565b83604001613a9b565b61249b613bf1565b6124d260c083013560e08401356101008501356101208601356101408701356124cd3689900389016101608a016158a9565b613c7d565b6124dc8280615979565b6000916124ea919083615a2b565b506124f86020830183615979565b600191612506919083615a2b565b5060007fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c556040518181527fbe9b076dc5b65990cca9dd9d7366682482e7817a6f6bc7f4faf4dc32af497f329060200160405180910390a15050565b600261258c7f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b036125c3576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7556125ef612884565b6001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561262c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061265091906157e7565b15612687576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000612691612985565b905061269d8282612f00565b5060017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75550565b6126cd612884565b6001600160a01b031663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa15801561270a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061272e919061581d565b6001600160a01b0316336001600160a01b031614612778576040517f40cbe9b100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6127806111d2565b156127b7576040517fded15dbf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060006127c2612985565b90506127ce8282612f00565b6001600160a01b0383166000908152600260208181526040808420815160608101835293810154845281518083018352600382015481526004820154818501528484015281518083018352600582015481526006820154818501528483015281518083019092528054825260018101549282019290925290929161285291906133ef565b90506128628582600001516132fe565b6128708582602001516136bc565b50600701805460ff19166001179055505050565b60006107037f0e555410d8128dff796eab5d29b97dd593ce9cab44a71b64c08244579ea605335490565b60006107037f5a294f9055e9dc7a18078b4e0139086766d723c3cd728bd59cc1f3b589741ed25490565b6128fd6040805160608101909152806000815260200160008152600060209091015290565b604080516060810190915282548390829060ff16600181111561292257612922615547565b600181111561293357612933615547565b81528154602090910190610100900460ff16600181111561295657612956615547565b600181111561296757612967615547565b8152905462010000900460101b61ffff191660209091015292915050565b6129a960405180606001604052806000815260200160008152602001600081525090565b60006129b3612884565b90506129bd613d21565b915060006129ca600a5490565b835190915081036129da57505090565b60006129e582611a6f565b84519091506000906129f990600490613d8f565b9050600085600001518214612a1657612a1182611a6f565b612a18565b855b9050846001600160a01b0316636fc6407c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a58573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a7c919061581d565b6001600160a01b031663a55ff01d876040518263ffffffff1660e01b8152600401612aa79190615726565b600060405180830381600087803b158015612ac157600080fd5b505af1158015612ad5573d6000803e3d6000fd5b505050506000612ae3613db2565b90506000612b00612af9600a8460038988613e2e565b8290613f72565b9050612b11612af960038886613f7e565b8851845191925014612b4357612b2f612af9600a846003878d613e2e565b8351909150612b41906003908a613f7e565b505b866001600160a01b031663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ba5919061581d565b6001600160a01b0316637f3dd53b826040518263ffffffff1660e01b8152600401612bd291815260200190565b600060405180830381600087803b158015612bec57600080fd5b505af1158015612c00573d6000803e3d6000fd5b505084518a516040517f88a84ea6dd274b386afd27dbbe11b6192b25017f5e60bb8c4053dfddb45c294d9450612c3f9350918252602082015260400190565b60405180910390a15050505050505090565b805160208201516fffffffffffffffffffffffffffffffff9182167001000000000000000000000000000000009183168202177f917d72d9b73e141a5f0eff6b5933a24665154df6903ed198d591afc8ac62f8f65560408301516060840151908316921602177f917d72d9b73e141a5f0eff6b5933a24665154df6903ed198d591afc8ac62f8f75580517f0887cb99bfd5017bb9e8282cc29d17176a4f1e542f869a03a5617919fb74620b90600f0b6020830151600f0b6040840151600f0b60608501516fffffffffffffffffffffffffffffffff166040805194855260208501939093529183015260608201526080015b60405180910390a150565b6040805180820182526000808252602080830182905284825260018601815290839020835180850190945254600f81810b8552700100000000000000000000000000000000909104900b9083015290612da69061407c565b9392505050565b612dbf81670de0b6b3a7640000613913565b15612df6576040517fccbac87e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612e1f7f5a294f9055e9dc7a18078b4e0139086766d723c3cd728bd59cc1f3b589741ed2829055565b6040518181527f3ffba897342f8382491dd8984c684cc237d3c045298d4cec8ad0fd7262aa91f190602001612d43565b6040805180820182526000808252602080830182905284825260028601815290839020835180850190945254600f81810b8552700100000000000000000000000000000000909104900b9083015290612da69061407c565b612ed07f968cf792ff9a89745e4746179e93a7b9d7f08b0ff8366fd6f6dbd524ef107464829055565b6040518181527f5339371c8d31c4fb29fd4ad6b3bf89793839a3dfae45035ef23a635916dafc6590602001612d43565b6000612f0a612884565b8251909150612f2e846001600160a01b031660009081526009602052604090205490565b03612f3857505050565b81516001600160a01b038416600090815260026020819052604082209192612f639290910190613d8f565b9050600083600001518214612f8057612f7b82611a6f565b612f82565b835b90506000836001600160a01b0316636fc6407c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612fc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fe8919061581d565b6001600160a01b0316631830349c87846040518363ffffffff1660e01b8152600401613015929190615aec565b600060405180830381600087803b15801561302f57600080fd5b505af1158015613043573d6000803e3d6000fd5b5050506001600160a01b038716600090815260026020908152604080832086516009909352922061308c93506130859261308092600a91906140b8565b614121565b8290614131565b6001600160a01b03871660009081526002602052604090209091506130c5906130be906130b9908561413d565b614201565b8290614260565b85518351919250146131ce57836001600160a01b0316636fc6407c6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561310f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613133919061581d565b6001600160a01b0316631830349c87876040518363ffffffff1660e01b8152600401613160929190615aec565b600060405180830381600087803b15801561317a57600080fd5b505af115801561318e573d6000803e3d6000fd5b5050506001600160a01b03871660009081526002602090815260408083208951600990935292206131cb93506130859261308092600a91906140b8565b90505b836001600160a01b031663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa15801561320c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613230919061581d565b6040517fc9cb48de0000000000000000000000000000000000000000000000000000000081526001600160a01b03888116600483015260248201849052919091169063c9cb48de90604401600060405180830381600087803b15801561329557600080fd5b505af11580156132a9573d6000803e3d6000fd5b5050835187516040805192835260208301919091526001600160a01b038a1693507f9d7055d24918d8c2fd08660a27bf31d4086fa71a51cd07874276470223aa480f92500160405180910390a2505050505050565b6000613309600a5490565b6001600160a01b03841660009081526002602081905260409091209192506133339101828461426c565b61333f6004828461426c565b60408051828152602081018490526001600160a01b038516917f39854479080fac0b5e7c0ecedb0fb02308a72a43cd102c6b9f918653d34003679101610c60565b60408051808201825260038301548152600483015460208083019190915282518084019093528354835260018401549083015260009182916133c2919061428c565b805160058501549192506133d69190613913565b80612da6575060208101516006840154612da691613913565b6040805180820190915260008082526020820152612da661341484846020015161428c565b83604001516142e3565b600061342c82602001511590565b613458576020820151825161345391670de0b6b3a76400009161344e91614331565b614350565b610adc565b670de0b6b3a764000092915050565b6000613473838361435c565b159392505050565b6000816134a15782156134905760001961349a565b670de0b6b3a76400005b9050610adc565b61349a8383614331565b60608201516000906fffffffffffffffffffffffffffffffff166134cf8382613467565b156134f95783516134f190600090600f0b60408701518490600f0b5b87614391565b915050610adc565b61350b83670de0b6b3a7640000613467565b156135355760408401516134f1908290600f0b6020870151670de0b6b3a764000090600f0b6134eb565b50505060200151600f0b90565b6000610adc670de0b6b3a764000083615b4c565b60008161356b670de0b6b3a764000085615b4c565b612da69190615c37565b61358781670de0b6b3a7640000613913565b156135be576040517f4589bde600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6135e77f1d7cfd39841edd73967db6350efae442ebd8c6e1bfca55faa52b046d39b7e493829055565b6040518181527f587b2c669227029fa59d08b2061678cdf5536e8709f7760940e5cf5f24336e4690602001612d43565b60006136268260200151614442565b8015610adc57508151610adc90614461565b60028301546136479082613f72565b600284015581835561365883614479565b505050565b8054600090819015801561367357506003830154155b801561368157506005830154155b600184015490915060009015801561369b57506004840154155b80156136a957506006840154155b9050811580156112be5750159392505050565b60006136c7600a5490565b6001600160a01b03841660009081526002602081905260409091209192506136f1910182846144d5565b6136fd600482846144d5565b60408051828152602081018490526001600160a01b038516917f63625b85818a29587ee919ee6a968ee0b32f3513f2884b3968001062ba49eb6b9101610c60565b61376260405180606001604052806000815260200160008152602001600081525090565b61377882604001516137726106b5565b906144f5565b60408301525090565b6137aa7f897858f7b7d3c8b4e7a700b401ad192a110353a60c809946583c0d62cda7f0b7829055565b6040518181527ff6bebbfbe342f87db90e223fb3dd70b26b082ed4266f1673b509dfeca0a7697a90602001612d43565b600781015460009060ff16156137f257506000919050565b604080518082019091528254815260018301546020820152610adc906145ec565b6040805180820190915260008082526020820152600082815260208481526040918290208251808401909352546fffffffffffffffffffffffffffffffff80821684527001000000000000000000000000000000009091041690820152612da6906146f3565b60408051606081018252600283015481528151808301835260038401548152600484015460208281019190915280830191909152825180840184526005850154815260068501548183015282840152825180840190935283548352600184015490830152600091610adc916138ee91906133ef565b6145ec565b60018301546139029082613f72565b600184015581835561365883614749565b600061391f838361435c565b6002149392505050565b61393b81670de0b6b3a7640000613913565b15613972576040517f82894f6b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61399b7face7e947336f94057b47a9ab5531b0363e85c8d36c05c7d915ec8e525fd159d8829055565b6040518181527ffb8fb3fd721f9e0d7396f8475680125318fb14fffa561a1ab43dfa329f2fd98a90602001612d43565b303b151580156139fa57507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b15613a31576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0381163b613a72576040517f14878b6900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6111cf7f0e555410d8128dff796eab5d29b97dd593ce9cab44a71b64c08244579ea60533829055565b303b15158015613aca57507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b15613b01576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0382163b613b42576040517fd26af10d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b613b6b7f6c0d5e3cd81753b1b21f67f61d56a97aae7a3e0179486d114788ad4576f53266839055565b613b82613b7d36839003830183615c8e565b6147a5565b613bb8576040517f9a51fe8f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610a1d613bca36839003830183615c8e565b7f630ac9ad193fa8d8f5a7207eefdee35934d664003a3d4c286a591e065a62034e906147ea565b303b15158015613c2057507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b15613c57576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755565b303b15158015613cac57507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b15613ce3576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b613cec86612ea7565b613cf585613929565b613cfe84612dad565b613d0783613575565b613d1082613781565b613d1981612c51565b505050505050565b613d4560405180606001604052806000815260200160008152602001600081525090565b610703613d50611a45565b6001600160a01b031663fff6cae96040518163ffffffff1660e01b81526004016060604051808303816000875af1158015611ae8573d6000803e3d6000fd5b81546000908015613daa57613da5816001615cea565b6112be565b509092915050565b6000610703613dbf612884565b6001600160a01b031663e975c0c36040518163ffffffff1660e01b8152600401602060405180830381865afa158015613dfc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e209190615804565b613e28611253565b90614873565b81516000908190613e40908690613813565b9050613e5f604051806040016040528060008152602001600081525090565b613e6b8783878761487f565b93509050613e84613e7d838787614b14565b8290614c7c565b90506000613e93838787614cca565b9050613eb5613eb083613eaa8c8a60000151612d4e565b90614c7c565b614d4f565b8551600090815260018b0160209081526040909120825192909101516fffffffffffffffffffffffffffffffff9081167001000000000000000000000000000000000292169190911790558551613f1790613eb0908390613eaa908d90612e4f565b8551600090815260028b0160209081526040909120825192909101516fffffffffffffffffffffffffffffffff9081167001000000000000000000000000000000000292169190911790555050915190955550929392505050565b6000612da68284615cea565b60408051606081018252600185015481528151808301835260028601548152600386015460208281019190915280830191909152825180840184526004870154815260058701549181019190915291810191909152600090819081908190613ff29086613feb8a8a613813565b9190614d9b565b92509250925061400183614def565b8551600090815260208981526040909120825192909101516fffffffffffffffffffffffffffffffff90811670010000000000000000000000000000000002921691909117905580156140725760006001880181905560028801819055600388018190556004880181905560058801555b5095945050505050565b60408051808201909152600080825260208201526040805180820190915282518190600f0b8152602084810151910190600f0b5b905292915050565b604080518082019091526000808252602082015284546000906140f0906140e0908790612d4e565b6140ea8786612d4e565b90614e59565b6040805180820190915285548152600186015460208201529091506141159082614ea7565b92909555509392505050565b60208101518151600091610adc91905b6000612da68284615d02565b6040805160608101825260028401548152815180830183526003850154815260048501546020828101919091528083019190915282518084018452600586015481526006860154818301528284015282518084019093528454835260018501549083015260009182916141b1919085614d9b565b8251875560209092015160018701559250905080156141fa57600060028501819055600385018190556004850181905560058501819055600685015560078401805460ff191690555b5092915050565b6000817f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811115610adc576040517ea07eb5000000000000000000000000000000000000000000000000000000008152600481018290526024016109fd565b6000612da68284615d76565b600383015461427b9082613f72565b600384015581835561365883614749565b6040805180820190915260008082526020820152604080518082019091528251845182916142ba9190613f72565b81526020016142da84602001518660200151613f7290919063ffffffff16565b90529392505050565b6040805180820190915260008082526020820152604080518082019091528251845182916143119190614ef5565b81526020016142da84602001518660200151614ef590919063ffffffff16565b600081614346670de0b6b3a764000085615dea565b612da69190615e09565b6000612da68383614f01565b600082828082111561437357600292505050610adc565b8082101561438657600092505050610adc565b506001949350505050565b600061439d8287613467565b806143ad57506143ad8285613913565b156143e4576040517f0db0f7cb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006143f08588614ef5565b905060006143fe8588614260565b9050600061441683614410878c614ef5565b90614331565b90506144358861442f61442884614201565b8590614f17565b90614131565b9998505050505050505050565b60006144518260200151614461565b8015610adc5750610adc82604001515b8051600090158015610adc5750602082015115610adc565b6004810154600282015461448c91613913565b156144b357600481015460028201546144a491614ef5565b60028201556000600482015550565b600281015460048201546144c691614ef5565b60048201556000600282015550565b60048301546144e49082613f72565b600484015581835561365883614479565b8151602083015160009190828083600181111561451457614514615547565b03614520575083614580565b600183600181111561453457614534615547565b0361454a576145438686614f2c565b9050614580565b82826040517f7ebf97b40000000000000000000000000000000000000000000000000000000081526004016109fd929190615e1d565b60008660200151600181111561459857614598615547565b036145a7579250610adc915050565b6001866020015160018111156145bf576145bf615547565b0361454a576145e26145db670de0b6b3a7640000600019615b4c565b8290614f17565b9350505050610adc565b6000803090506000816001600160a01b0316639d888e866040518163ffffffff1660e01b8152600401606060405180830381865afa158015614632573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614656919061593d565b604001519050600061467c614677836146716130b989614fcb565b90614f17565b614fdf565b90506146ea836001600160a01b0316636c376cc56040518163ffffffff1660e01b8152600401602060405180830381865afa1580156146bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906146e39190615804565b8290614fea565b95945050505050565b604080518082019091526000808252602082015260408051808201909152825181906fffffffffffffffffffffffffffffffff1681526020848101519101906fffffffffffffffffffffffffffffffff166140b0565b6003810154600182015461475c91613913565b15614783576003810154600182015461477491614ef5565b60018201556000600382015550565b6001810154600382015461479691614ef5565b60038201556000600182015550565b60006001825160018111156147bc576147bc615547565b036147dc57610adc6147cd83614fff565b6001600160a01b03163b151590565b506040015161ffff19161590565b80518254839190829060ff19166001838181111561480a5761480a615547565b02179055506020820151815482907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff1661010083600181111561484f5761484f615547565b0217905550604090910151815460109190911c620100000261ffff90911617905550565b6000612da6838361506a565b60408051808201909152600080825260208201526000306001600160a01b031663597e1fb56040518163ffffffff1660e01b8152600401602060405180830381865afa1580156148d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148f791906157e7565b1561491957505060408051808201909152600080825260208201819052614b0b565b602085015161493f57505060408051808201909152600080825260208201819052614b0b565b845161496257505060408051808201909152600080825260208201819052614b0b565b6000846020015184602001516149789190615e43565b9050600061499461467787604001516146718a60200151614201565b905060006149ab6149a48961341e565b8390614fea565b90506000614a3b6149be6130b98661507a565b6040517f60ec91d600000000000000000000000000000000000000000000000000000000815230906360ec91d6906149fa908e90600401615747565b602060405180830381865afa158015614a17573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906146719190615804565b90506000614a52614a4b84614201565b8390614f17565b9050614a678b614a6183614fdf565b90614fea565b95506000614a8f614a778361508e565b614a8a89614a8486614fdf565b90614ef5565b6150ba565b9050600080614a9d8461508e565b129050614ac3614ab08d60000151614201565b82614abb5783614abd565b845b90613556565b8952614afe614adc670de0b6b3a7640000600019615b4c565b614671614aec8f60200151614201565b84614af75786614abd565b8590613556565b60208a0152505050505050505b94509492505050565b6040805180820190915260008082526020820152306001600160a01b031663597e1fb56040518163ffffffff1660e01b8152600401602060405180830381865afa158015614b66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614b8a91906157e7565b15614ba957506040805180820190915260008082526020820152612da6565b6020840151614bcc57506040805180820190915260008082526020820152612da6565b8351614bec57506040805180820190915260008082526020820152612da6565b6000614c098460400151846040015161426090919063ffffffff16565b90506000614c1d614a4b8760200151614201565b90506000614c30614a4b6130b98961341e565b9050614c59614c49670de0b6b3a7640000600019615b4c565b614671614abb8a60000151614201565b84526020870151614c6d906112b790614201565b60208501525050509392505050565b604080518082019091526000808252602082015260408051808201909152825184518291614caa9190614131565b81526020016142da8460200151866020015161413190919063ffffffff16565b6040805180820190915260008082526020820152600083602001518360200151614cf49190615e43565b855190915015614d1757614d126130b986600001516144108461507a565b614d1a565b60005b8252602085015115614d3f57614d3a6130b986602001516144108461507a565b614d42565b60005b6020830152509392505050565b60408051808201909152600080825260208201526040518060400160405280614d7b84600001516150f4565b600f0b8152602001614d9084602001516150f4565b600f0b905292915050565b6040805180820190915260008082526020820152600080614dbc85856151a1565b614dc95785600080614de0565b614dd386866133ef565b614ddd86866151bd565b60015b92509250925093509350939050565b60408051808201909152600080825260208201526040518060400160405280614e1b8460000151615305565b6fffffffffffffffffffffffffffffffff168152602001614e3f8460200151615305565b6fffffffffffffffffffffffffffffffff16905292915050565b604080518082019091526000808252602082015260408051808201909152825184518291614e879190614260565b81526020016142da8460200151866020015161426090919063ffffffff16565b60408051808201909152600080825260208201526040518060400160405280614edb84600001516146718760000151614201565b81526020016142da84602001516146718760200151614201565b6000612da68284615e43565b6000818310614f105781612da6565b5090919050565b6000670de0b6b3a764000061356b8385615b4c565b600080614fb583604051602401614f4591815260200190565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fd7c7a93500000000000000000000000000000000000000000000000000000000179052614fa686614fff565b6001600160a01b031690615355565b9050808060200190518101906112be9190615804565b6000610adc82600001518360200151614873565b6000610adc8261537a565b6000670de0b6b3a76400006143468385615dea565b600060018251600181111561501657615016615547565b1461505657815160408084015190517f4f5b470e0000000000000000000000000000000000000000000000000000000081526109fd929190600401615e5a565b506040015160101c6001600160a01b031690565b600081831015614f105781612da6565b6000610adc670de0b6b3a764000083615dea565b6000808213156150a057506001919050565b60008212156150b25750600019919050565b506000919050565b6000808313156150cd5761349a82614201565b60008312156150eb576150df82614201565b61349a90600019615b4c565b50600092915050565b6000816f7fffffffffffffffffffffffffffffff811315615144576040517f59aeb746000000000000000000000000000000000000000000000000000000008152600481018290526024016109fd565b7fffffffffffffffffffffffffffffffff80000000000000000000000000000000811215610adc576040517f4e02165d000000000000000000000000000000000000000000000000000000008152600481018290526024016109fd565b60006151ac83614442565b158015612da6575050905190511190565b6000806151db8460400151856020015161428c90919063ffffffff16565b90506000806151f861467786604001516146718660000151614201565b61521061467787604001516146718760200151614201565b9150915060003090506152fa615288826001600160a01b03166343f0179b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561525d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906152819190615804565b8490614fea565b6152f4836001600160a01b031663fc741c7c6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156152c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906152ed9190615804565b8690614fea565b90613f72565b979650505050505050565b6000816fffffffffffffffffffffffffffffffff811115610adc576040517f53851291000000000000000000000000000000000000000000000000000000008152600481018290526024016109fd565b6060612da68383604051806060016040528060258152602001615e9860259139615391565b60008082121561538d5781600003610adc565b5090565b60606001600160a01b0384163b615429576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f416464726573733a207374617469632063616c6c20746f206e6f6e2d636f6e7460448201527f726163740000000000000000000000000000000000000000000000000000000060648201526084016109fd565b600080856001600160a01b0316856040516154449190615e7b565b600060405180830381855afa9150503d806000811461547f576040519150601f19603f3d011682016040523d82523d6000602084013e615484565b606091505b509150915061549482828661549e565b9695505050505050565b606083156154ad575081612da6565b8251156154bd5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109fd9190615619565b604051806060016040528060008152602001615520604051806040016040528060008152602001600081525090565b8152602001615542604051806040016040528060008152602001600081525090565b905290565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b600281106111cf577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b815160608201906155bd81615576565b825260208301516155cd81615576565b8060208401525061ffff19604084015116604083015292915050565b60005b838110156156045781810151838201526020016155ec565b83811115615613576000848401525b50505050565b60208152600082518060208401526156388160408501602087016155e9565b601f01601f19169190910160400192915050565b60006080828403121561565e57600080fd5b50919050565b6001600160a01b03811681146111cf57600080fd5b60006020828403121561568b57600080fd5b8135612da681615664565b8151815260208083015180518284015290810151604083015260a082019050604083015180516060840152602081015160808401526141fa565b6000602082840312156156e257600080fd5b5035919050565b80151581146111cf57600080fd5b60006020828403121561570957600080fd5b8135612da6816156e9565b60006040828403121561565e57600080fd5b81518152602080830151908201526040808301519082015260608101610adc565b815181526020808301519082015260408101610adc565b60006020828403121561577057600080fd5b813567ffffffffffffffff81111561578757600080fd5b82016101e08185031215612da657600080fd5b600181811c908216806157ae57607f821691505b60208210810361565e577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000602082840312156157f957600080fd5b8151612da6816156e9565b60006020828403121561581657600080fd5b5051919050565b60006020828403121561582f57600080fd5b8151612da681615664565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516060810167ffffffffffffffff8111828210171561588c5761588c61583a565b60405290565b8035600f81900b81146158a457600080fd5b919050565b6000608082840312156158bb57600080fd5b6040516080810181811067ffffffffffffffff821117156158de576158de61583a565b6040526158ea83615892565b81526158f860208401615892565b602082015261590960408401615892565b604082015260608301356fffffffffffffffffffffffffffffffff8116811461593157600080fd5b60608201529392505050565b60006060828403121561594f57600080fd5b615957615869565b8251815260208301516020820152604083015160408201528091505092915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126159ae57600080fd5b83018035915067ffffffffffffffff8211156159c957600080fd5b6020019150368190038213156159de57600080fd5b9250929050565b601f82111561365857600081815260208120601f850160051c81016020861015615a0c5750805b601f850160051c820191505b81811015613d1957828155600101615a18565b67ffffffffffffffff831115615a4357615a4361583a565b615a5783615a51835461579a565b836159e5565b6000601f841160018114615a8b5760008515615a735750838201355b600019600387901b1c1916600186901b178355615ae5565b600083815260209020601f19861690835b82811015615abc5786850135825560209485019460019092019101615a9c565b5086821015615ad95760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b6001600160a01b038316815260808101612da660208301848051825260208082015190830152604090810151910152565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600084136000841385830485118282161615615b8d57615b8d615b1d565b7f80000000000000000000000000000000000000000000000000000000000000006000871286820588128184161615615bc857615bc8615b1d565b60008712925087820587128484161615615be457615be4615b1d565b87850587128184161615615bfa57615bfa615b1d565b505050929093029392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600082615c4657615c46615c08565b60001983147f800000000000000000000000000000000000000000000000000000000000000083141615615c7c57615c7c615b1d565b500590565b600281106111cf57600080fd5b600060608284031215615ca057600080fd5b615ca8615869565b8235615cb381615c81565b81526020830135615cc381615c81565b6020820152604083013561ffff1981168114615cde57600080fd5b60408201529392505050565b60008219821115615cfd57615cfd615b1d565b500190565b6000808212827f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03841381151615615d3c57615d3c615b1d565b827f8000000000000000000000000000000000000000000000000000000000000000038412811615615d7057615d70615b1d565b50500190565b6000808312837f800000000000000000000000000000000000000000000000000000000000000001831281151615615db057615db0615b1d565b837f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff018313811615615de457615de4615b1d565b50500390565b6000816000190483118215151615615e0457615e04615b1d565b500290565b600082615e1857615e18615c08565b500490565b60408101615e2a84615576565b838252615e3683615576565b8260208301529392505050565b600082821015615e5557615e55615b1d565b500390565b60408101615e6784615576565b92815261ffff199190911660209091015290565b60008251615e8d8184602087016155e9565b919091019291505056fe416464726573733a206c6f772d6c6576656c207374617469632063616c6c206661696c6564a2646970667358221220c8f28337b68a0a25a9b849842eef3dea5522fe30a7a3178bfe70c89801c2062264736f6c634300080f0033" -} diff --git a/packages/perennial/deployments/goerli/ProxyAdmin.json b/packages/perennial/deployments/goerli/ProxyAdmin.json deleted file mode 100644 index 584b23daa..000000000 --- a/packages/perennial/deployments/goerli/ProxyAdmin.json +++ /dev/null @@ -1,246 +0,0 @@ -{ - "address": "0x85b75DE34c7328625b8c394769D98d64C74fEBCa", - "abi": [ - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "contract TransparentUpgradeableProxy", - "name": "proxy", - "type": "address" - }, - { - "internalType": "address", - "name": "newAdmin", - "type": "address" - } - ], - "name": "changeProxyAdmin", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract TransparentUpgradeableProxy", - "name": "proxy", - "type": "address" - } - ], - "name": "getProxyAdmin", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract TransparentUpgradeableProxy", - "name": "proxy", - "type": "address" - } - ], - "name": "getProxyImplementation", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract TransparentUpgradeableProxy", - "name": "proxy", - "type": "address" - }, - { - "internalType": "address", - "name": "implementation", - "type": "address" - } - ], - "name": "upgrade", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract TransparentUpgradeableProxy", - "name": "proxy", - "type": "address" - }, - { - "internalType": "address", - "name": "implementation", - "type": "address" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "upgradeAndCall", - "outputs": [], - "stateMutability": "payable", - "type": "function" - } - ], - "transactionHash": "0xf4259d6acb24b56c2f4c557d878bfbc51659afb853bd409b9e4503a6f852b5cf", - "receipt": { - "to": null, - "from": "0x66a7fDB96C583c59597de16d8b2B989231415339", - "contractAddress": "0x85b75DE34c7328625b8c394769D98d64C74fEBCa", - "transactionIndex": 28, - "gasUsed": "642227", - "logsBloom": "0x00000000000000000000000000000100000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000400000000000000000000000000000000000000000000000000008000000000000000000010000000020000000000040000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x7614d4e063b8eac6b3a56d88ff780ff6fc1514e2b923122c98bc3fdd956b6679", - "transactionHash": "0xf4259d6acb24b56c2f4c557d878bfbc51659afb853bd409b9e4503a6f852b5cf", - "logs": [ - { - "transactionIndex": 28, - "blockNumber": 7681142, - "transactionHash": "0xf4259d6acb24b56c2f4c557d878bfbc51659afb853bd409b9e4503a6f852b5cf", - "address": "0x85b75DE34c7328625b8c394769D98d64C74fEBCa", - "topics": [ - "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x00000000000000000000000066a7fdb96c583c59597de16d8b2b989231415339" - ], - "data": "0x", - "logIndex": 53, - "blockHash": "0x7614d4e063b8eac6b3a56d88ff780ff6fc1514e2b923122c98bc3fdd956b6679" - } - ], - "blockNumber": 7681142, - "cumulativeGasUsed": "8348549", - "status": 1, - "byzantium": true - }, - "args": [], - "numDeployments": 1, - "solcInputHash": "b6ff42633a62e1bc6c97d8ccad85444b", - "metadata": "{\"compiler\":{\"version\":\"0.8.15+commit.e14f2714\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"contract TransparentUpgradeableProxy\",\"name\":\"proxy\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeProxyAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract TransparentUpgradeableProxy\",\"name\":\"proxy\",\"type\":\"address\"}],\"name\":\"getProxyAdmin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract TransparentUpgradeableProxy\",\"name\":\"proxy\",\"type\":\"address\"}],\"name\":\"getProxyImplementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract TransparentUpgradeableProxy\",\"name\":\"proxy\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"upgrade\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract TransparentUpgradeableProxy\",\"name\":\"proxy\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.\",\"kind\":\"dev\",\"methods\":{\"changeProxyAdmin(address,address)\":{\"details\":\"Changes the admin of `proxy` to `newAdmin`. Requirements: - This contract must be the current admin of `proxy`.\"},\"getProxyAdmin(address)\":{\"details\":\"Returns the current admin of `proxy`. Requirements: - This contract must be the admin of `proxy`.\"},\"getProxyImplementation(address)\":{\"details\":\"Returns the current implementation of `proxy`. Requirements: - This contract must be the admin of `proxy`.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"upgrade(address,address)\":{\"details\":\"Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}. Requirements: - This contract must be the admin of `proxy`.\"},\"upgradeAndCall(address,address,bytes)\":{\"details\":\"Upgrades `proxy` to `implementation` and calls a function on the new implementation. See {TransparentUpgradeableProxy-upgradeToAndCall}. Requirements: - This contract must be the admin of `proxy`.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol\":\"ProxyAdmin\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0x24e0364e503a9bbde94c715d26573a76f14cd2a202d45f96f52134ab806b67b9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/ProxyAdmin.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./TransparentUpgradeableProxy.sol\\\";\\nimport \\\"../../access/Ownable.sol\\\";\\n\\n/**\\n * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an\\n * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.\\n */\\ncontract ProxyAdmin is Ownable {\\n /**\\n * @dev Returns the current implementation of `proxy`.\\n *\\n * Requirements:\\n *\\n * - This contract must be the admin of `proxy`.\\n */\\n function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\\n // We need to manually run the static call since the getter cannot be flagged as view\\n // bytes4(keccak256(\\\"implementation()\\\")) == 0x5c60da1b\\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\\\"5c60da1b\\\");\\n require(success);\\n return abi.decode(returndata, (address));\\n }\\n\\n /**\\n * @dev Returns the current admin of `proxy`.\\n *\\n * Requirements:\\n *\\n * - This contract must be the admin of `proxy`.\\n */\\n function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\\n // We need to manually run the static call since the getter cannot be flagged as view\\n // bytes4(keccak256(\\\"admin()\\\")) == 0xf851a440\\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\\\"f851a440\\\");\\n require(success);\\n return abi.decode(returndata, (address));\\n }\\n\\n /**\\n * @dev Changes the admin of `proxy` to `newAdmin`.\\n *\\n * Requirements:\\n *\\n * - This contract must be the current admin of `proxy`.\\n */\\n function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {\\n proxy.changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.\\n *\\n * Requirements:\\n *\\n * - This contract must be the admin of `proxy`.\\n */\\n function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {\\n proxy.upgradeTo(implementation);\\n }\\n\\n /**\\n * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See\\n * {TransparentUpgradeableProxy-upgradeToAndCall}.\\n *\\n * Requirements:\\n *\\n * - This contract must be the admin of `proxy`.\\n */\\n function upgradeAndCall(\\n TransparentUpgradeableProxy proxy,\\n address implementation,\\n bytes memory data\\n ) public payable virtual onlyOwner {\\n proxy.upgradeToAndCall{value: msg.value}(implementation, data);\\n }\\n}\\n\",\"keccak256\":\"0x33b8603bfbef7f33d9308b79c79aa3db7eb19525fd1addd764285e834ca275d7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // 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\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\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 ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\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(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\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 /**\\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 {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x608060405234801561001057600080fd5b5061001a3361001f565b61006f565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b610a488061007e6000396000f3fe60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461012b57806399a88ec41461013e578063f2fde38b1461015e578063f3b7dead1461017e57600080fd5b8063204e1c7a14610080578063715018a6146100c95780637eff275e146100e05780638da5cb5b14610100575b600080fd5b34801561008c57600080fd5b506100a061009b3660046107e4565b61019e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d557600080fd5b506100de610255565b005b3480156100ec57600080fd5b506100de6100fb366004610808565b6102e7565b34801561010c57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100a0565b6100de610139366004610870565b6103ee565b34801561014a57600080fd5b506100de610159366004610808565b6104fc565b34801561016a57600080fd5b506100de6101793660046107e4565b6105d1565b34801561018a57600080fd5b506100a06101993660046107e4565b610701565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b600060405180830381855afa9150503d8060008114610225576040519150601f19603f3d011682016040523d82523d6000602084013e61022a565b606091505b50915091508161023957600080fd5b8080602001905181019061024d9190610964565b949350505050565b60005473ffffffffffffffffffffffffffffffffffffffff1633146102db576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b6102e5600061074d565b565b60005473ffffffffffffffffffffffffffffffffffffffff163314610368576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b600060405180830381600087803b1580156103d257600080fd5b505af11580156103e6573d6000803e3d6000fd5b505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461046f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef2869034906104c59086908690600401610981565b6000604051808303818588803b1580156104de57600080fd5b505af11580156104f2573d6000803e3d6000fd5b5050505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461057d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016103b8565b60005473ffffffffffffffffffffffffffffffffffffffff163314610652576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b73ffffffffffffffffffffffffffffffffffffffff81166106f5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016102d2565b6106fe8161074d565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff811681146106fe57600080fd5b6000602082840312156107f657600080fd5b8135610801816107c2565b9392505050565b6000806040838503121561081b57600080fd5b8235610826816107c2565b91506020830135610836816107c2565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060006060848603121561088557600080fd5b8335610890816107c2565b925060208401356108a0816107c2565b9150604084013567ffffffffffffffff808211156108bd57600080fd5b818601915086601f8301126108d157600080fd5b8135818111156108e3576108e3610841565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561092957610929610841565b8160405282815289602084870101111561094257600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561097657600080fd5b8151610801816107c2565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b818110156109cb578581018301518582016060015282016109af565b818111156109dd576000606083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160600194935050505056fea2646970667358221220131047e01068f5d9fede9201de856c46786e7562ec5dfad2cd5e344ae34f062064736f6c634300080f0033", - "deployedBytecode": "0x60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461012b57806399a88ec41461013e578063f2fde38b1461015e578063f3b7dead1461017e57600080fd5b8063204e1c7a14610080578063715018a6146100c95780637eff275e146100e05780638da5cb5b14610100575b600080fd5b34801561008c57600080fd5b506100a061009b3660046107e4565b61019e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d557600080fd5b506100de610255565b005b3480156100ec57600080fd5b506100de6100fb366004610808565b6102e7565b34801561010c57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100a0565b6100de610139366004610870565b6103ee565b34801561014a57600080fd5b506100de610159366004610808565b6104fc565b34801561016a57600080fd5b506100de6101793660046107e4565b6105d1565b34801561018a57600080fd5b506100a06101993660046107e4565b610701565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b600060405180830381855afa9150503d8060008114610225576040519150601f19603f3d011682016040523d82523d6000602084013e61022a565b606091505b50915091508161023957600080fd5b8080602001905181019061024d9190610964565b949350505050565b60005473ffffffffffffffffffffffffffffffffffffffff1633146102db576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b6102e5600061074d565b565b60005473ffffffffffffffffffffffffffffffffffffffff163314610368576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b600060405180830381600087803b1580156103d257600080fd5b505af11580156103e6573d6000803e3d6000fd5b505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461046f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef2869034906104c59086908690600401610981565b6000604051808303818588803b1580156104de57600080fd5b505af11580156104f2573d6000803e3d6000fd5b5050505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461057d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016103b8565b60005473ffffffffffffffffffffffffffffffffffffffff163314610652576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b73ffffffffffffffffffffffffffffffffffffffff81166106f5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016102d2565b6106fe8161074d565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff811681146106fe57600080fd5b6000602082840312156107f657600080fd5b8135610801816107c2565b9392505050565b6000806040838503121561081b57600080fd5b8235610826816107c2565b91506020830135610836816107c2565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060006060848603121561088557600080fd5b8335610890816107c2565b925060208401356108a0816107c2565b9150604084013567ffffffffffffffff808211156108bd57600080fd5b818601915086601f8301126108d157600080fd5b8135818111156108e3576108e3610841565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561092957610929610841565b8160405282815289602084870101111561094257600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561097657600080fd5b8151610801816107c2565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b818110156109cb578581018301518582016060015282016109af565b818111156109dd576000606083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160600194935050505056fea2646970667358221220131047e01068f5d9fede9201de856c46786e7562ec5dfad2cd5e344ae34f062064736f6c634300080f0033", - "devdoc": { - "details": "This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.", - "kind": "dev", - "methods": { - "changeProxyAdmin(address,address)": { - "details": "Changes the admin of `proxy` to `newAdmin`. Requirements: - This contract must be the current admin of `proxy`." - }, - "getProxyAdmin(address)": { - "details": "Returns the current admin of `proxy`. Requirements: - This contract must be the admin of `proxy`." - }, - "getProxyImplementation(address)": { - "details": "Returns the current implementation of `proxy`. Requirements: - This contract must be the admin of `proxy`." - }, - "owner()": { - "details": "Returns the address of the current owner." - }, - "renounceOwnership()": { - "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." - }, - "transferOwnership(address)": { - "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." - }, - "upgrade(address,address)": { - "details": "Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}. Requirements: - This contract must be the admin of `proxy`." - }, - "upgradeAndCall(address,address,bytes)": { - "details": "Upgrades `proxy` to `implementation` and calls a function on the new implementation. See {TransparentUpgradeableProxy-upgradeToAndCall}. Requirements: - This contract must be the admin of `proxy`." - } - }, - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": {}, - "version": 1 - }, - "storageLayout": { - "storage": [ - { - "astId": 5416, - "contract": "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol:ProxyAdmin", - "label": "_owner", - "offset": 0, - "slot": "0", - "type": "t_address" - } - ], - "types": { - "t_address": { - "encoding": "inplace", - "label": "address", - "numberOfBytes": "20" - } - } - } -} diff --git a/packages/perennial/deployments/goerli/TimelockController.json b/packages/perennial/deployments/goerli/TimelockController.json deleted file mode 100644 index be2f8b281..000000000 --- a/packages/perennial/deployments/goerli/TimelockController.json +++ /dev/null @@ -1,1230 +0,0 @@ -{ - "address": "0x68F863106ceAD8f615eE023C681aB8eE43e98B9d", - "abi": [ - { - "inputs": [ - { - "internalType": "uint256", - "name": "minDelay", - "type": "uint256" - }, - { - "internalType": "address[]", - "name": "proposers", - "type": "address[]" - }, - { - "internalType": "address[]", - "name": "executors", - "type": "address[]" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "id", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "index", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "CallExecuted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "id", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "index", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "data", - "type": "bytes" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "predecessor", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "delay", - "type": "uint256" - } - ], - "name": "CallScheduled", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "id", - "type": "bytes32" - } - ], - "name": "Cancelled", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "oldDuration", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newDuration", - "type": "uint256" - } - ], - "name": "MinDelayChange", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "previousAdminRole", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "newAdminRole", - "type": "bytes32" - } - ], - "name": "RoleAdminChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "RoleGranted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "RoleRevoked", - "type": "event" - }, - { - "inputs": [], - "name": "CANCELLER_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "DEFAULT_ADMIN_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "EXECUTOR_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "PROPOSER_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "TIMELOCK_ADMIN_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "id", - "type": "bytes32" - } - ], - "name": "cancel", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - }, - { - "internalType": "bytes32", - "name": "predecessor", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - } - ], - "name": "execute", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address[]", - "name": "targets", - "type": "address[]" - }, - { - "internalType": "uint256[]", - "name": "values", - "type": "uint256[]" - }, - { - "internalType": "bytes[]", - "name": "payloads", - "type": "bytes[]" - }, - { - "internalType": "bytes32", - "name": "predecessor", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - } - ], - "name": "executeBatch", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [], - "name": "getMinDelay", - "outputs": [ - { - "internalType": "uint256", - "name": "duration", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - } - ], - "name": "getRoleAdmin", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "id", - "type": "bytes32" - } - ], - "name": "getTimestamp", - "outputs": [ - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "grantRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "hasRole", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - }, - { - "internalType": "bytes32", - "name": "predecessor", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - } - ], - "name": "hashOperation", - "outputs": [ - { - "internalType": "bytes32", - "name": "hash", - "type": "bytes32" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address[]", - "name": "targets", - "type": "address[]" - }, - { - "internalType": "uint256[]", - "name": "values", - "type": "uint256[]" - }, - { - "internalType": "bytes[]", - "name": "payloads", - "type": "bytes[]" - }, - { - "internalType": "bytes32", - "name": "predecessor", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - } - ], - "name": "hashOperationBatch", - "outputs": [ - { - "internalType": "bytes32", - "name": "hash", - "type": "bytes32" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "id", - "type": "bytes32" - } - ], - "name": "isOperation", - "outputs": [ - { - "internalType": "bool", - "name": "pending", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "id", - "type": "bytes32" - } - ], - "name": "isOperationDone", - "outputs": [ - { - "internalType": "bool", - "name": "done", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "id", - "type": "bytes32" - } - ], - "name": "isOperationPending", - "outputs": [ - { - "internalType": "bool", - "name": "pending", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "id", - "type": "bytes32" - } - ], - "name": "isOperationReady", - "outputs": [ - { - "internalType": "bool", - "name": "ready", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "uint256[]", - "name": "", - "type": "uint256[]" - }, - { - "internalType": "uint256[]", - "name": "", - "type": "uint256[]" - }, - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "name": "onERC1155BatchReceived", - "outputs": [ - { - "internalType": "bytes4", - "name": "", - "type": "bytes4" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "name": "onERC1155Received", - "outputs": [ - { - "internalType": "bytes4", - "name": "", - "type": "bytes4" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "name": "onERC721Received", - "outputs": [ - { - "internalType": "bytes4", - "name": "", - "type": "bytes4" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "renounceRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "revokeRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - }, - { - "internalType": "bytes32", - "name": "predecessor", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "delay", - "type": "uint256" - } - ], - "name": "schedule", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address[]", - "name": "targets", - "type": "address[]" - }, - { - "internalType": "uint256[]", - "name": "values", - "type": "uint256[]" - }, - { - "internalType": "bytes[]", - "name": "payloads", - "type": "bytes[]" - }, - { - "internalType": "bytes32", - "name": "predecessor", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "delay", - "type": "uint256" - } - ], - "name": "scheduleBatch", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes4", - "name": "interfaceId", - "type": "bytes4" - } - ], - "name": "supportsInterface", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "newDelay", - "type": "uint256" - } - ], - "name": "updateDelay", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "stateMutability": "payable", - "type": "receive" - } - ], - "transactionHash": "0xad734d78b77618c31e2629f6be54d813381a62be7aa7482b00abe55478827aa9", - "receipt": { - "to": null, - "from": "0x66a7fDB96C583c59597de16d8b2B989231415339", - "contractAddress": "0x68F863106ceAD8f615eE023C681aB8eE43e98B9d", - "transactionIndex": 24, - "gasUsed": "2403523", - "logsBloom": "0x000000040000000008000000000001000a0000000000000000020000000000000000000000000000000000000001000000000000000000000200000010200000000000000000000000000010000000000000000000000000000000000001000000000000020000400000000000000800000000000000000001020000000000000000004000000000400000000000000000000000000000080000000000000400000008000020000000000000000000001000000080000000001000000000000000000000000000004000000000000000020200000000000100000100200020000000000000001000000000000000000000000000000000000000000010000000", - "blockHash": "0x5c9b6400f37e05a6fad877f794e545dcf1ea6c9483bd9b9b17dd9bc01353a4be", - "transactionHash": "0xad734d78b77618c31e2629f6be54d813381a62be7aa7482b00abe55478827aa9", - "logs": [ - { - "transactionIndex": 24, - "blockNumber": 7681141, - "transactionHash": "0xad734d78b77618c31e2629f6be54d813381a62be7aa7482b00abe55478827aa9", - "address": "0x68F863106ceAD8f615eE023C681aB8eE43e98B9d", - "topics": [ - "0xbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff", - "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5" - ], - "data": "0x", - "logIndex": 26, - "blockHash": "0x5c9b6400f37e05a6fad877f794e545dcf1ea6c9483bd9b9b17dd9bc01353a4be" - }, - { - "transactionIndex": 24, - "blockNumber": 7681141, - "transactionHash": "0xad734d78b77618c31e2629f6be54d813381a62be7aa7482b00abe55478827aa9", - "address": "0x68F863106ceAD8f615eE023C681aB8eE43e98B9d", - "topics": [ - "0xbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff", - "0xb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5" - ], - "data": "0x", - "logIndex": 27, - "blockHash": "0x5c9b6400f37e05a6fad877f794e545dcf1ea6c9483bd9b9b17dd9bc01353a4be" - }, - { - "transactionIndex": 24, - "blockNumber": 7681141, - "transactionHash": "0xad734d78b77618c31e2629f6be54d813381a62be7aa7482b00abe55478827aa9", - "address": "0x68F863106ceAD8f615eE023C681aB8eE43e98B9d", - "topics": [ - "0xbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff", - "0xd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e63", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5" - ], - "data": "0x", - "logIndex": 28, - "blockHash": "0x5c9b6400f37e05a6fad877f794e545dcf1ea6c9483bd9b9b17dd9bc01353a4be" - }, - { - "transactionIndex": 24, - "blockNumber": 7681141, - "transactionHash": "0xad734d78b77618c31e2629f6be54d813381a62be7aa7482b00abe55478827aa9", - "address": "0x68F863106ceAD8f615eE023C681aB8eE43e98B9d", - "topics": [ - "0xbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff", - "0xfd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5" - ], - "data": "0x", - "logIndex": 29, - "blockHash": "0x5c9b6400f37e05a6fad877f794e545dcf1ea6c9483bd9b9b17dd9bc01353a4be" - }, - { - "transactionIndex": 24, - "blockNumber": 7681141, - "transactionHash": "0xad734d78b77618c31e2629f6be54d813381a62be7aa7482b00abe55478827aa9", - "address": "0x68F863106ceAD8f615eE023C681aB8eE43e98B9d", - "topics": [ - "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d", - "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", - "0x00000000000000000000000066a7fdb96c583c59597de16d8b2b989231415339", - "0x00000000000000000000000066a7fdb96c583c59597de16d8b2b989231415339" - ], - "data": "0x", - "logIndex": 30, - "blockHash": "0x5c9b6400f37e05a6fad877f794e545dcf1ea6c9483bd9b9b17dd9bc01353a4be" - }, - { - "transactionIndex": 24, - "blockNumber": 7681141, - "transactionHash": "0xad734d78b77618c31e2629f6be54d813381a62be7aa7482b00abe55478827aa9", - "address": "0x68F863106ceAD8f615eE023C681aB8eE43e98B9d", - "topics": [ - "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d", - "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", - "0x00000000000000000000000068f863106cead8f615ee023c681ab8ee43e98b9d", - "0x00000000000000000000000066a7fdb96c583c59597de16d8b2b989231415339" - ], - "data": "0x", - "logIndex": 31, - "blockHash": "0x5c9b6400f37e05a6fad877f794e545dcf1ea6c9483bd9b9b17dd9bc01353a4be" - }, - { - "transactionIndex": 24, - "blockNumber": 7681141, - "transactionHash": "0xad734d78b77618c31e2629f6be54d813381a62be7aa7482b00abe55478827aa9", - "address": "0x68F863106ceAD8f615eE023C681aB8eE43e98B9d", - "topics": [ - "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d", - "0xb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1", - "0x000000000000000000000000f6c02e15187c9b466e81b3ac72ccf32569eb19ed", - "0x00000000000000000000000066a7fdb96c583c59597de16d8b2b989231415339" - ], - "data": "0x", - "logIndex": 32, - "blockHash": "0x5c9b6400f37e05a6fad877f794e545dcf1ea6c9483bd9b9b17dd9bc01353a4be" - }, - { - "transactionIndex": 24, - "blockNumber": 7681141, - "transactionHash": "0xad734d78b77618c31e2629f6be54d813381a62be7aa7482b00abe55478827aa9", - "address": "0x68F863106ceAD8f615eE023C681aB8eE43e98B9d", - "topics": [ - "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d", - "0xfd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783", - "0x000000000000000000000000f6c02e15187c9b466e81b3ac72ccf32569eb19ed", - "0x00000000000000000000000066a7fdb96c583c59597de16d8b2b989231415339" - ], - "data": "0x", - "logIndex": 33, - "blockHash": "0x5c9b6400f37e05a6fad877f794e545dcf1ea6c9483bd9b9b17dd9bc01353a4be" - }, - { - "transactionIndex": 24, - "blockNumber": 7681141, - "transactionHash": "0xad734d78b77618c31e2629f6be54d813381a62be7aa7482b00abe55478827aa9", - "address": "0x68F863106ceAD8f615eE023C681aB8eE43e98B9d", - "topics": [ - "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d", - "0xd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e63", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x00000000000000000000000066a7fdb96c583c59597de16d8b2b989231415339" - ], - "data": "0x", - "logIndex": 34, - "blockHash": "0x5c9b6400f37e05a6fad877f794e545dcf1ea6c9483bd9b9b17dd9bc01353a4be" - }, - { - "transactionIndex": 24, - "blockNumber": 7681141, - "transactionHash": "0xad734d78b77618c31e2629f6be54d813381a62be7aa7482b00abe55478827aa9", - "address": "0x68F863106ceAD8f615eE023C681aB8eE43e98B9d", - "topics": ["0x11c24f4ead16507c69ac467fbd5e4eed5fb5c699626d2cc6d66421df253886d5"], - "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a300", - "logIndex": 35, - "blockHash": "0x5c9b6400f37e05a6fad877f794e545dcf1ea6c9483bd9b9b17dd9bc01353a4be" - } - ], - "blockNumber": 7681141, - "cumulativeGasUsed": "8314583", - "status": 1, - "byzantium": true - }, - "args": [172800, ["0xf6C02E15187c9b466E81B3aC72cCf32569EB19eD"], ["0x0000000000000000000000000000000000000000"]], - "numDeployments": 1, - "solcInputHash": "b6ff42633a62e1bc6c97d8ccad85444b", - "metadata": "{\"compiler\":{\"version\":\"0.8.15+commit.e14f2714\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"minDelay\",\"type\":\"uint256\"},{\"internalType\":\"address[]\",\"name\":\"proposers\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"executors\",\"type\":\"address[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"CallExecuted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"predecessor\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"delay\",\"type\":\"uint256\"}],\"name\":\"CallScheduled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"Cancelled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldDuration\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newDuration\",\"type\":\"uint256\"}],\"name\":\"MinDelayChange\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"CANCELLER_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"EXECUTOR_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"PROPOSER_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"TIMELOCK_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"cancel\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"bytes32\",\"name\":\"predecessor\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"salt\",\"type\":\"bytes32\"}],\"name\":\"execute\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"targets\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"values\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes[]\",\"name\":\"payloads\",\"type\":\"bytes[]\"},{\"internalType\":\"bytes32\",\"name\":\"predecessor\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"salt\",\"type\":\"bytes32\"}],\"name\":\"executeBatch\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMinDelay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"duration\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"getTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"bytes32\",\"name\":\"predecessor\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"salt\",\"type\":\"bytes32\"}],\"name\":\"hashOperation\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"hash\",\"type\":\"bytes32\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"targets\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"values\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes[]\",\"name\":\"payloads\",\"type\":\"bytes[]\"},{\"internalType\":\"bytes32\",\"name\":\"predecessor\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"salt\",\"type\":\"bytes32\"}],\"name\":\"hashOperationBatch\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"hash\",\"type\":\"bytes32\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"isOperation\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"pending\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"isOperationDone\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"done\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"isOperationPending\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"pending\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"isOperationReady\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"ready\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"onERC1155BatchReceived\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"onERC1155Received\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"onERC721Received\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"bytes32\",\"name\":\"predecessor\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"salt\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"delay\",\"type\":\"uint256\"}],\"name\":\"schedule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"targets\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"values\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes[]\",\"name\":\"payloads\",\"type\":\"bytes[]\"},{\"internalType\":\"bytes32\",\"name\":\"predecessor\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"salt\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"delay\",\"type\":\"uint256\"}],\"name\":\"scheduleBatch\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newDelay\",\"type\":\"uint256\"}],\"name\":\"updateDelay\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"Contract module which acts as a timelocked controller. When set as the owner of an `Ownable` smart contract, it enforces a timelock on all `onlyOwner` maintenance operations. This gives time for users of the controlled contract to exit before a potentially dangerous maintenance operation is applied. By default, this contract is self administered, meaning administration tasks have to go through the timelock process. The proposer (resp executor) role is in charge of proposing (resp executing) operations. A common use case is to position this {TimelockController} as the owner of a smart contract, with a multisig or a DAO as the sole proposer. _Available since v3.3._\",\"events\":{\"CallExecuted(bytes32,uint256,address,uint256,bytes)\":{\"details\":\"Emitted when a call is performed as part of operation `id`.\"},\"CallScheduled(bytes32,uint256,address,uint256,bytes,bytes32,uint256)\":{\"details\":\"Emitted when a call is scheduled as part of operation `id`.\"},\"Cancelled(bytes32)\":{\"details\":\"Emitted when operation `id` is cancelled.\"},\"MinDelayChange(uint256,uint256)\":{\"details\":\"Emitted when the minimum delay for future operations is modified.\"}},\"kind\":\"dev\",\"methods\":{\"cancel(bytes32)\":{\"details\":\"Cancel an operation. Requirements: - the caller must have the 'canceller' role.\"},\"constructor\":{\"details\":\"Initializes the contract with a given `minDelay`, and a list of initial proposers and executors. The proposers receive both the proposer and the canceller role (for backward compatibility). The executors receive the executor role. NOTE: At construction, both the deployer and the timelock itself are administrators. This helps further configuration of the timelock by the deployer. After configuration is done, it is recommended that the deployer renounces its admin position and relies on timelocked operations to perform future maintenance.\"},\"execute(address,uint256,bytes,bytes32,bytes32)\":{\"details\":\"Execute an (ready) operation containing a single transaction. Emits a {CallExecuted} event. Requirements: - the caller must have the 'executor' role.\"},\"executeBatch(address[],uint256[],bytes[],bytes32,bytes32)\":{\"details\":\"Execute an (ready) operation containing a batch of transactions. Emits one {CallExecuted} event per transaction in the batch. Requirements: - the caller must have the 'executor' role.\"},\"getMinDelay()\":{\"details\":\"Returns the minimum delay for an operation to become valid. This value can be changed by executing an operation that calls `updateDelay`.\"},\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.\"},\"getTimestamp(bytes32)\":{\"details\":\"Returns the timestamp at with an operation becomes ready (0 for unset operations, 1 for done operations).\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"hashOperation(address,uint256,bytes,bytes32,bytes32)\":{\"details\":\"Returns the identifier of an operation containing a single transaction.\"},\"hashOperationBatch(address[],uint256[],bytes[],bytes32,bytes32)\":{\"details\":\"Returns the identifier of an operation containing a batch of transactions.\"},\"isOperation(bytes32)\":{\"details\":\"Returns whether an id correspond to a registered operation. This includes both Pending, Ready and Done operations.\"},\"isOperationDone(bytes32)\":{\"details\":\"Returns whether an operation is done or not.\"},\"isOperationPending(bytes32)\":{\"details\":\"Returns whether an operation is pending or not.\"},\"isOperationReady(bytes32)\":{\"details\":\"Returns whether an operation is ready or not.\"},\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\":{\"details\":\"See {IERC1155Receiver-onERC1155BatchReceived}.\"},\"onERC1155Received(address,address,uint256,uint256,bytes)\":{\"details\":\"See {IERC1155Receiver-onERC1155Received}.\"},\"onERC721Received(address,address,uint256,bytes)\":{\"details\":\"See {IERC721Receiver-onERC721Received}.\"},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `account`.\"},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role.\"},\"schedule(address,uint256,bytes,bytes32,bytes32,uint256)\":{\"details\":\"Schedule an operation containing a single transaction. Emits a {CallScheduled} event. Requirements: - the caller must have the 'proposer' role.\"},\"scheduleBatch(address[],uint256[],bytes[],bytes32,bytes32,uint256)\":{\"details\":\"Schedule an operation containing a batch of transactions. Emits one {CallScheduled} event per transaction in the batch. Requirements: - the caller must have the 'proposer' role.\"},\"supportsInterface(bytes4)\":{\"details\":\"See {IERC165-supportsInterface}.\"},\"updateDelay(uint256)\":{\"details\":\"Changes the minimum timelock duration for future operations. Emits a {MinDelayChange} event. Requirements: - the caller must be the timelock itself. This can only be achieved by scheduling and later executing an operation where the timelock is the target and the data is the ABI-encoded call to this function.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"@openzeppelin/contracts/governance/TimelockController.sol\":\"TimelockController\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/AccessControl.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (access/AccessControl.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IAccessControl.sol\\\";\\nimport \\\"../utils/Context.sol\\\";\\nimport \\\"../utils/Strings.sol\\\";\\nimport \\\"../utils/introspection/ERC165.sol\\\";\\n\\n/**\\n * @dev Contract module that allows children to implement role-based access\\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\\n * members except through off-chain means by accessing the contract event logs. Some\\n * applications may benefit from on-chain enumerability, for those cases see\\n * {AccessControlEnumerable}.\\n *\\n * Roles are referred to by their `bytes32` identifier. These should be exposed\\n * in the external API and be unique. The best way to achieve this is by\\n * using `public constant` hash digests:\\n *\\n * ```\\n * bytes32 public constant MY_ROLE = keccak256(\\\"MY_ROLE\\\");\\n * ```\\n *\\n * Roles can be used to represent a set of permissions. To restrict access to a\\n * function call, use {hasRole}:\\n *\\n * ```\\n * function foo() public {\\n * require(hasRole(MY_ROLE, msg.sender));\\n * ...\\n * }\\n * ```\\n *\\n * Roles can be granted and revoked dynamically via the {grantRole} and\\n * {revokeRole} functions. Each role has an associated admin role, and only\\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\\n *\\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\\n * that only accounts with this role will be able to grant or revoke other\\n * roles. More complex role relationships can be created by using\\n * {_setRoleAdmin}.\\n *\\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\\n * grant and revoke this role. Extra precautions should be taken to secure\\n * accounts that have been granted it.\\n */\\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\\n struct RoleData {\\n mapping(address => bool) members;\\n bytes32 adminRole;\\n }\\n\\n mapping(bytes32 => RoleData) private _roles;\\n\\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\\n\\n /**\\n * @dev Modifier that checks that an account has a specific role. Reverts\\n * with a standardized message including the required role.\\n *\\n * The format of the revert reason is given by the following regular expression:\\n *\\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\\n *\\n * _Available since v4.1._\\n */\\n modifier onlyRole(bytes32 role) {\\n _checkRole(role);\\n _;\\n }\\n\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\\n }\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\\n return _roles[role].members[account];\\n }\\n\\n /**\\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\\n * Overriding this function changes the behavior of the {onlyRole} modifier.\\n *\\n * Format of the revert message is described in {_checkRole}.\\n *\\n * _Available since v4.6._\\n */\\n function _checkRole(bytes32 role) internal view virtual {\\n _checkRole(role, _msgSender());\\n }\\n\\n /**\\n * @dev Revert with a standard message if `account` is missing `role`.\\n *\\n * The format of the revert reason is given by the following regular expression:\\n *\\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\\n */\\n function _checkRole(bytes32 role, address account) internal view virtual {\\n if (!hasRole(role, account)) {\\n revert(\\n string(\\n abi.encodePacked(\\n \\\"AccessControl: account \\\",\\n Strings.toHexString(uint160(account), 20),\\n \\\" is missing role \\\",\\n Strings.toHexString(uint256(role), 32)\\n )\\n )\\n );\\n }\\n }\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\\n return _roles[role].adminRole;\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n */\\n function renounceRole(bytes32 role, address account) public virtual override {\\n require(account == _msgSender(), \\\"AccessControl: can only renounce roles for self\\\");\\n\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event. Note that unlike {grantRole}, this function doesn't perform any\\n * checks on the calling account.\\n *\\n * [WARNING]\\n * ====\\n * This function should only be called from the constructor when setting\\n * up the initial roles for the system.\\n *\\n * Using this function in any other way is effectively circumventing the admin\\n * system imposed by {AccessControl}.\\n * ====\\n *\\n * NOTE: This function is deprecated in favor of {_grantRole}.\\n */\\n function _setupRole(bytes32 role, address account) internal virtual {\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Sets `adminRole` as ``role``'s admin role.\\n *\\n * Emits a {RoleAdminChanged} event.\\n */\\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\\n bytes32 previousAdminRole = getRoleAdmin(role);\\n _roles[role].adminRole = adminRole;\\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * Internal function without access restriction.\\n */\\n function _grantRole(bytes32 role, address account) internal virtual {\\n if (!hasRole(role, account)) {\\n _roles[role].members[account] = true;\\n emit RoleGranted(role, account, _msgSender());\\n }\\n }\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * Internal function without access restriction.\\n */\\n function _revokeRole(bytes32 role, address account) internal virtual {\\n if (hasRole(role, account)) {\\n _roles[role].members[account] = false;\\n emit RoleRevoked(role, account, _msgSender());\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb4d87ee2ead4bd192b41c128f287d4b7f24b9e0cd740cc9b476881c461286007\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/IAccessControl.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev External interface of AccessControl declared to support ERC165 detection.\\n */\\ninterface IAccessControl {\\n /**\\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\\n *\\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\\n * {RoleAdminChanged} not being emitted signaling this.\\n *\\n * _Available since v3.1._\\n */\\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\\n\\n /**\\n * @dev Emitted when `account` is granted `role`.\\n *\\n * `sender` is the account that originated the contract call, an admin role\\n * bearer except when using {AccessControl-_setupRole}.\\n */\\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Emitted when `account` is revoked `role`.\\n *\\n * `sender` is the account that originated the contract call:\\n * - if using `revokeRole`, it is the admin role bearer\\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\\n */\\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) external view returns (bool);\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function grantRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function revokeRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been granted `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n */\\n function renounceRole(bytes32 role, address account) external;\\n}\\n\",\"keccak256\":\"0x59ce320a585d7e1f163cd70390a0ef2ff9cec832e2aa544293a00692465a7a57\",\"license\":\"MIT\"},\"@openzeppelin/contracts/governance/TimelockController.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (governance/TimelockController.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../access/AccessControl.sol\\\";\\nimport \\\"../token/ERC721/IERC721Receiver.sol\\\";\\nimport \\\"../token/ERC1155/IERC1155Receiver.sol\\\";\\n\\n/**\\n * @dev Contract module which acts as a timelocked controller. When set as the\\n * owner of an `Ownable` smart contract, it enforces a timelock on all\\n * `onlyOwner` maintenance operations. This gives time for users of the\\n * controlled contract to exit before a potentially dangerous maintenance\\n * operation is applied.\\n *\\n * By default, this contract is self administered, meaning administration tasks\\n * have to go through the timelock process. The proposer (resp executor) role\\n * is in charge of proposing (resp executing) operations. A common use case is\\n * to position this {TimelockController} as the owner of a smart contract, with\\n * a multisig or a DAO as the sole proposer.\\n *\\n * _Available since v3.3._\\n */\\ncontract TimelockController is AccessControl, IERC721Receiver, IERC1155Receiver {\\n bytes32 public constant TIMELOCK_ADMIN_ROLE = keccak256(\\\"TIMELOCK_ADMIN_ROLE\\\");\\n bytes32 public constant PROPOSER_ROLE = keccak256(\\\"PROPOSER_ROLE\\\");\\n bytes32 public constant EXECUTOR_ROLE = keccak256(\\\"EXECUTOR_ROLE\\\");\\n bytes32 public constant CANCELLER_ROLE = keccak256(\\\"CANCELLER_ROLE\\\");\\n uint256 internal constant _DONE_TIMESTAMP = uint256(1);\\n\\n mapping(bytes32 => uint256) private _timestamps;\\n uint256 private _minDelay;\\n\\n /**\\n * @dev Emitted when a call is scheduled as part of operation `id`.\\n */\\n event CallScheduled(\\n bytes32 indexed id,\\n uint256 indexed index,\\n address target,\\n uint256 value,\\n bytes data,\\n bytes32 predecessor,\\n uint256 delay\\n );\\n\\n /**\\n * @dev Emitted when a call is performed as part of operation `id`.\\n */\\n event CallExecuted(bytes32 indexed id, uint256 indexed index, address target, uint256 value, bytes data);\\n\\n /**\\n * @dev Emitted when operation `id` is cancelled.\\n */\\n event Cancelled(bytes32 indexed id);\\n\\n /**\\n * @dev Emitted when the minimum delay for future operations is modified.\\n */\\n event MinDelayChange(uint256 oldDuration, uint256 newDuration);\\n\\n /**\\n * @dev Initializes the contract with a given `minDelay`, and a list of\\n * initial proposers and executors. The proposers receive both the\\n * proposer and the canceller role (for backward compatibility). The\\n * executors receive the executor role.\\n *\\n * NOTE: At construction, both the deployer and the timelock itself are\\n * administrators. This helps further configuration of the timelock by the\\n * deployer. After configuration is done, it is recommended that the\\n * deployer renounces its admin position and relies on timelocked\\n * operations to perform future maintenance.\\n */\\n constructor(\\n uint256 minDelay,\\n address[] memory proposers,\\n address[] memory executors\\n ) {\\n _setRoleAdmin(TIMELOCK_ADMIN_ROLE, TIMELOCK_ADMIN_ROLE);\\n _setRoleAdmin(PROPOSER_ROLE, TIMELOCK_ADMIN_ROLE);\\n _setRoleAdmin(EXECUTOR_ROLE, TIMELOCK_ADMIN_ROLE);\\n _setRoleAdmin(CANCELLER_ROLE, TIMELOCK_ADMIN_ROLE);\\n\\n // deployer + self administration\\n _setupRole(TIMELOCK_ADMIN_ROLE, _msgSender());\\n _setupRole(TIMELOCK_ADMIN_ROLE, address(this));\\n\\n // register proposers and cancellers\\n for (uint256 i = 0; i < proposers.length; ++i) {\\n _setupRole(PROPOSER_ROLE, proposers[i]);\\n _setupRole(CANCELLER_ROLE, proposers[i]);\\n }\\n\\n // register executors\\n for (uint256 i = 0; i < executors.length; ++i) {\\n _setupRole(EXECUTOR_ROLE, executors[i]);\\n }\\n\\n _minDelay = minDelay;\\n emit MinDelayChange(0, minDelay);\\n }\\n\\n /**\\n * @dev Modifier to make a function callable only by a certain role. In\\n * addition to checking the sender's role, `address(0)` 's role is also\\n * considered. Granting a role to `address(0)` is equivalent to enabling\\n * this role for everyone.\\n */\\n modifier onlyRoleOrOpenRole(bytes32 role) {\\n if (!hasRole(role, address(0))) {\\n _checkRole(role, _msgSender());\\n }\\n _;\\n }\\n\\n /**\\n * @dev Contract might receive/hold ETH as part of the maintenance process.\\n */\\n receive() external payable {}\\n\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, AccessControl) returns (bool) {\\n return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);\\n }\\n\\n /**\\n * @dev Returns whether an id correspond to a registered operation. This\\n * includes both Pending, Ready and Done operations.\\n */\\n function isOperation(bytes32 id) public view virtual returns (bool pending) {\\n return getTimestamp(id) > 0;\\n }\\n\\n /**\\n * @dev Returns whether an operation is pending or not.\\n */\\n function isOperationPending(bytes32 id) public view virtual returns (bool pending) {\\n return getTimestamp(id) > _DONE_TIMESTAMP;\\n }\\n\\n /**\\n * @dev Returns whether an operation is ready or not.\\n */\\n function isOperationReady(bytes32 id) public view virtual returns (bool ready) {\\n uint256 timestamp = getTimestamp(id);\\n return timestamp > _DONE_TIMESTAMP && timestamp <= block.timestamp;\\n }\\n\\n /**\\n * @dev Returns whether an operation is done or not.\\n */\\n function isOperationDone(bytes32 id) public view virtual returns (bool done) {\\n return getTimestamp(id) == _DONE_TIMESTAMP;\\n }\\n\\n /**\\n * @dev Returns the timestamp at with an operation becomes ready (0 for\\n * unset operations, 1 for done operations).\\n */\\n function getTimestamp(bytes32 id) public view virtual returns (uint256 timestamp) {\\n return _timestamps[id];\\n }\\n\\n /**\\n * @dev Returns the minimum delay for an operation to become valid.\\n *\\n * This value can be changed by executing an operation that calls `updateDelay`.\\n */\\n function getMinDelay() public view virtual returns (uint256 duration) {\\n return _minDelay;\\n }\\n\\n /**\\n * @dev Returns the identifier of an operation containing a single\\n * transaction.\\n */\\n function hashOperation(\\n address target,\\n uint256 value,\\n bytes calldata data,\\n bytes32 predecessor,\\n bytes32 salt\\n ) public pure virtual returns (bytes32 hash) {\\n return keccak256(abi.encode(target, value, data, predecessor, salt));\\n }\\n\\n /**\\n * @dev Returns the identifier of an operation containing a batch of\\n * transactions.\\n */\\n function hashOperationBatch(\\n address[] calldata targets,\\n uint256[] calldata values,\\n bytes[] calldata payloads,\\n bytes32 predecessor,\\n bytes32 salt\\n ) public pure virtual returns (bytes32 hash) {\\n return keccak256(abi.encode(targets, values, payloads, predecessor, salt));\\n }\\n\\n /**\\n * @dev Schedule an operation containing a single transaction.\\n *\\n * Emits a {CallScheduled} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have the 'proposer' role.\\n */\\n function schedule(\\n address target,\\n uint256 value,\\n bytes calldata data,\\n bytes32 predecessor,\\n bytes32 salt,\\n uint256 delay\\n ) public virtual onlyRole(PROPOSER_ROLE) {\\n bytes32 id = hashOperation(target, value, data, predecessor, salt);\\n _schedule(id, delay);\\n emit CallScheduled(id, 0, target, value, data, predecessor, delay);\\n }\\n\\n /**\\n * @dev Schedule an operation containing a batch of transactions.\\n *\\n * Emits one {CallScheduled} event per transaction in the batch.\\n *\\n * Requirements:\\n *\\n * - the caller must have the 'proposer' role.\\n */\\n function scheduleBatch(\\n address[] calldata targets,\\n uint256[] calldata values,\\n bytes[] calldata payloads,\\n bytes32 predecessor,\\n bytes32 salt,\\n uint256 delay\\n ) public virtual onlyRole(PROPOSER_ROLE) {\\n require(targets.length == values.length, \\\"TimelockController: length mismatch\\\");\\n require(targets.length == payloads.length, \\\"TimelockController: length mismatch\\\");\\n\\n bytes32 id = hashOperationBatch(targets, values, payloads, predecessor, salt);\\n _schedule(id, delay);\\n for (uint256 i = 0; i < targets.length; ++i) {\\n emit CallScheduled(id, i, targets[i], values[i], payloads[i], predecessor, delay);\\n }\\n }\\n\\n /**\\n * @dev Schedule an operation that is to becomes valid after a given delay.\\n */\\n function _schedule(bytes32 id, uint256 delay) private {\\n require(!isOperation(id), \\\"TimelockController: operation already scheduled\\\");\\n require(delay >= getMinDelay(), \\\"TimelockController: insufficient delay\\\");\\n _timestamps[id] = block.timestamp + delay;\\n }\\n\\n /**\\n * @dev Cancel an operation.\\n *\\n * Requirements:\\n *\\n * - the caller must have the 'canceller' role.\\n */\\n function cancel(bytes32 id) public virtual onlyRole(CANCELLER_ROLE) {\\n require(isOperationPending(id), \\\"TimelockController: operation cannot be cancelled\\\");\\n delete _timestamps[id];\\n\\n emit Cancelled(id);\\n }\\n\\n /**\\n * @dev Execute an (ready) operation containing a single transaction.\\n *\\n * Emits a {CallExecuted} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have the 'executor' role.\\n */\\n // This function can reenter, but it doesn't pose a risk because _afterCall checks that the proposal is pending,\\n // thus any modifications to the operation during reentrancy should be caught.\\n // slither-disable-next-line reentrancy-eth\\n function execute(\\n address target,\\n uint256 value,\\n bytes calldata data,\\n bytes32 predecessor,\\n bytes32 salt\\n ) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) {\\n bytes32 id = hashOperation(target, value, data, predecessor, salt);\\n _beforeCall(id, predecessor);\\n _call(id, 0, target, value, data);\\n _afterCall(id);\\n }\\n\\n /**\\n * @dev Execute an (ready) operation containing a batch of transactions.\\n *\\n * Emits one {CallExecuted} event per transaction in the batch.\\n *\\n * Requirements:\\n *\\n * - the caller must have the 'executor' role.\\n */\\n function executeBatch(\\n address[] calldata targets,\\n uint256[] calldata values,\\n bytes[] calldata payloads,\\n bytes32 predecessor,\\n bytes32 salt\\n ) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) {\\n require(targets.length == values.length, \\\"TimelockController: length mismatch\\\");\\n require(targets.length == payloads.length, \\\"TimelockController: length mismatch\\\");\\n\\n bytes32 id = hashOperationBatch(targets, values, payloads, predecessor, salt);\\n _beforeCall(id, predecessor);\\n for (uint256 i = 0; i < targets.length; ++i) {\\n _call(id, i, targets[i], values[i], payloads[i]);\\n }\\n _afterCall(id);\\n }\\n\\n /**\\n * @dev Checks before execution of an operation's calls.\\n */\\n function _beforeCall(bytes32 id, bytes32 predecessor) private view {\\n require(isOperationReady(id), \\\"TimelockController: operation is not ready\\\");\\n require(predecessor == bytes32(0) || isOperationDone(predecessor), \\\"TimelockController: missing dependency\\\");\\n }\\n\\n /**\\n * @dev Checks after execution of an operation's calls.\\n */\\n function _afterCall(bytes32 id) private {\\n require(isOperationReady(id), \\\"TimelockController: operation is not ready\\\");\\n _timestamps[id] = _DONE_TIMESTAMP;\\n }\\n\\n /**\\n * @dev Execute an operation's call.\\n *\\n * Emits a {CallExecuted} event.\\n */\\n function _call(\\n bytes32 id,\\n uint256 index,\\n address target,\\n uint256 value,\\n bytes calldata data\\n ) private {\\n (bool success, ) = target.call{value: value}(data);\\n require(success, \\\"TimelockController: underlying transaction reverted\\\");\\n\\n emit CallExecuted(id, index, target, value, data);\\n }\\n\\n /**\\n * @dev Changes the minimum timelock duration for future operations.\\n *\\n * Emits a {MinDelayChange} event.\\n *\\n * Requirements:\\n *\\n * - the caller must be the timelock itself. This can only be achieved by scheduling and later executing\\n * an operation where the timelock is the target and the data is the ABI-encoded call to this function.\\n */\\n function updateDelay(uint256 newDelay) external virtual {\\n require(msg.sender == address(this), \\\"TimelockController: caller must be timelock\\\");\\n emit MinDelayChange(_minDelay, newDelay);\\n _minDelay = newDelay;\\n }\\n\\n /**\\n * @dev See {IERC721Receiver-onERC721Received}.\\n */\\n function onERC721Received(\\n address,\\n address,\\n uint256,\\n bytes memory\\n ) public virtual override returns (bytes4) {\\n return this.onERC721Received.selector;\\n }\\n\\n /**\\n * @dev See {IERC1155Receiver-onERC1155Received}.\\n */\\n function onERC1155Received(\\n address,\\n address,\\n uint256,\\n uint256,\\n bytes memory\\n ) public virtual override returns (bytes4) {\\n return this.onERC1155Received.selector;\\n }\\n\\n /**\\n * @dev See {IERC1155Receiver-onERC1155BatchReceived}.\\n */\\n function onERC1155BatchReceived(\\n address,\\n address,\\n uint256[] memory,\\n uint256[] memory,\\n bytes memory\\n ) public virtual override returns (bytes4) {\\n return this.onERC1155BatchReceived.selector;\\n }\\n}\\n\",\"keccak256\":\"0x7ea1531981766d9a4297f5f2124c7202ec53501f0d692cdcaaf585f6c6cd1977\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165.sol\\\";\\n\\n/**\\n * @dev _Available since v3.1._\\n */\\ninterface IERC1155Receiver is IERC165 {\\n /**\\n * @dev Handles the receipt of a single ERC1155 token type. This function is\\n * called at the end of a `safeTransferFrom` after the balance has been updated.\\n *\\n * NOTE: To accept the transfer, this must return\\n * `bytes4(keccak256(\\\"onERC1155Received(address,address,uint256,uint256,bytes)\\\"))`\\n * (i.e. 0xf23a6e61, or its own function selector).\\n *\\n * @param operator The address which initiated the transfer (i.e. msg.sender)\\n * @param from The address which previously owned the token\\n * @param id The ID of the token being transferred\\n * @param value The amount of tokens being transferred\\n * @param data Additional data with no specified format\\n * @return `bytes4(keccak256(\\\"onERC1155Received(address,address,uint256,uint256,bytes)\\\"))` if transfer is allowed\\n */\\n function onERC1155Received(\\n address operator,\\n address from,\\n uint256 id,\\n uint256 value,\\n bytes calldata data\\n ) external returns (bytes4);\\n\\n /**\\n * @dev Handles the receipt of a multiple ERC1155 token types. This function\\n * is called at the end of a `safeBatchTransferFrom` after the balances have\\n * been updated.\\n *\\n * NOTE: To accept the transfer(s), this must return\\n * `bytes4(keccak256(\\\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\\\"))`\\n * (i.e. 0xbc197c81, or its own function selector).\\n *\\n * @param operator The address which initiated the batch transfer (i.e. msg.sender)\\n * @param from The address which previously owned the token\\n * @param ids An array containing ids of each token being transferred (order and length must match values array)\\n * @param values An array containing amounts of each token being transferred (order and length must match ids array)\\n * @param data Additional data with no specified format\\n * @return `bytes4(keccak256(\\\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\\\"))` if transfer is allowed\\n */\\n function onERC1155BatchReceived(\\n address operator,\\n address from,\\n uint256[] calldata ids,\\n uint256[] calldata values,\\n bytes calldata data\\n ) external returns (bytes4);\\n}\\n\",\"keccak256\":\"0xeb373f1fdc7b755c6a750123a9b9e3a8a02c1470042fd6505d875000a80bde0b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title ERC721 token receiver interface\\n * @dev Interface for any contract that wants to support safeTransfers\\n * from ERC721 asset contracts.\\n */\\ninterface IERC721Receiver {\\n /**\\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\\n * by `operator` from `from`, this function is called.\\n *\\n * It must return its Solidity selector to confirm the token transfer.\\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\\n *\\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\\n */\\n function onERC721Received(\\n address operator,\\n address from,\\n uint256 tokenId,\\n bytes calldata data\\n ) external returns (bytes4);\\n}\\n\",\"keccak256\":\"0xa82b58eca1ee256be466e536706850163d2ec7821945abd6b4778cfb3bee37da\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Strings.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary Strings {\\n bytes16 private constant _HEX_SYMBOLS = \\\"0123456789abcdef\\\";\\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 // Inspired by OraclizeAPI's implementation - MIT licence\\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\\n\\n if (value == 0) {\\n return \\\"0\\\";\\n }\\n uint256 temp = value;\\n uint256 digits;\\n while (temp != 0) {\\n digits++;\\n temp /= 10;\\n }\\n bytes memory buffer = new bytes(digits);\\n while (value != 0) {\\n digits -= 1;\\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\\n value /= 10;\\n }\\n return string(buffer);\\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 if (value == 0) {\\n return \\\"0x00\\\";\\n }\\n uint256 temp = value;\\n uint256 length = 0;\\n while (temp != 0) {\\n length++;\\n temp >>= 8;\\n }\\n return toHexString(value, length);\\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 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_SYMBOLS[value & 0xf];\\n value >>= 4;\\n }\\n require(value == 0, \\\"Strings: hex length insufficient\\\");\\n return string(buffer);\\n }\\n}\\n\",\"keccak256\":\"0x32c202bd28995dd20c4347b7c6467a6d3241c74c8ad3edcbb610cd9205916c45\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/introspection/ERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC165.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC165} interface.\\n *\\n * Contracts that want to implement ERC165 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 *\\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\\n */\\nabstract contract ERC165 is IERC165 {\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n return interfaceId == type(IERC165).interfaceId;\\n }\\n}\\n\",\"keccak256\":\"0xd10975de010d89fd1c78dc5e8a9a7e7f496198085c151648f20cba166b32582b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\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[EIP 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\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x60806040523480156200001157600080fd5b5060405162002b2f38038062002b2f8339810160408190526200003491620003f7565b6200004f60008051602062002aaf833981519152806200021c565b6200007960008051602062002acf83398151915260008051602062002aaf8339815191526200021c565b620000a360008051602062002aef83398151915260008051602062002aaf8339815191526200021c565b620000cd60008051602062002b0f83398151915260008051602062002aaf8339815191526200021c565b620000e860008051602062002aaf8339815191523362000267565b6200010360008051602062002aaf8339815191523062000267565b60005b825181101562000189576200014d60008051602062002acf8339815191528483815181106200013957620001396200046b565b60200260200101516200026760201b60201c565b6200017660008051602062002b0f8339815191528483815181106200013957620001396200046b565b620001818162000481565b905062000106565b5060005b8151811015620001d357620001c060008051602062002aef8339815191528383815181106200013957620001396200046b565b620001cb8162000481565b90506200018d565b5060028390556040805160008152602081018590527f11c24f4ead16507c69ac467fbd5e4eed5fb5c699626d2cc6d66421df253886d5910160405180910390a1505050620004a9565b600082815260208190526040808220600101805490849055905190918391839186917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a4505050565b62000273828262000277565b5050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1662000273576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055620002d33390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b634e487b7160e01b600052604160045260246000fd5b80516001600160a01b03811681146200034557600080fd5b919050565b600082601f8301126200035c57600080fd5b815160206001600160401b03808311156200037b576200037b62000317565b8260051b604051601f19603f83011681018181108482111715620003a357620003a362000317565b604052938452858101830193838101925087851115620003c257600080fd5b83870191505b84821015620003ec57620003dc826200032d565b83529183019190830190620003c8565b979650505050505050565b6000806000606084860312156200040d57600080fd5b835160208501519093506001600160401b03808211156200042d57600080fd5b6200043b878388016200034a565b935060408601519150808211156200045257600080fd5b5062000461868287016200034a565b9150509250925092565b634e487b7160e01b600052603260045260246000fd5b600060018201620004a257634e487b7160e01b600052601160045260246000fd5b5060010190565b6125f680620004b96000396000f3fe6080604052600436106101bb5760003560e01c80638065657f116100ec578063bc197c811161008a578063d547741f11610064578063d547741f146105fd578063e38335e51461061d578063f23a6e6114610630578063f27a0c921461067557600080fd5b8063bc197c811461056b578063c4d252f5146105b0578063d45c4435146105d057600080fd5b806391d14854116100c657806391d14854146104b1578063a217fddf14610502578063b08e51c014610517578063b1c5f4271461054b57600080fd5b80638065657f1461043d5780638f2a0bb01461045d5780638f61f4f51461047d57600080fd5b8063248a9ca31161015957806331d507501161013357806331d50750146103bd57806336568abe146103dd578063584b153e146103fd57806364d623531461041d57600080fd5b8063248a9ca31461033c5780632ab0f5291461036c5780632f2ff15d1461039d57600080fd5b80630d3cf6fc116101955780630d3cf6fc14610260578063134008d31461029457806313bc9f20146102a7578063150b7a02146102c757600080fd5b806301d5062a146101c757806301ffc9a7146101e957806307bd02651461021e57600080fd5b366101c257005b600080fd5b3480156101d357600080fd5b506101e76101e2366004611aae565b61068a565b005b3480156101f557600080fd5b50610209610204366004611b23565b61071f565b60405190151581526020015b60405180910390f35b34801561022a57600080fd5b506102527fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e6381565b604051908152602001610215565b34801561026c57600080fd5b506102527f5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca581565b6101e76102a2366004611b65565b61077b565b3480156102b357600080fd5b506102096102c2366004611bd1565b610836565b3480156102d357600080fd5b5061030b6102e2366004611cf6565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff000000000000000000000000000000000000000000000000000000009091168152602001610215565b34801561034857600080fd5b50610252610357366004611bd1565b60009081526020819052604090206001015490565b34801561037857600080fd5b50610209610387366004611bd1565b6000908152600160208190526040909120541490565b3480156103a957600080fd5b506101e76103b8366004611d5e565b61085c565b3480156103c957600080fd5b506102096103d8366004611bd1565b610886565b3480156103e957600080fd5b506101e76103f8366004611d5e565b61089f565b34801561040957600080fd5b50610209610418366004611bd1565b610957565b34801561042957600080fd5b506101e7610438366004611bd1565b61096d565b34801561044957600080fd5b50610252610458366004611b65565b610a3d565b34801561046957600080fd5b506101e7610478366004611dcf565b610a7c565b34801561048957600080fd5b506102527fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc181565b3480156104bd57600080fd5b506102096104cc366004611d5e565b60009182526020828152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b34801561050e57600080fd5b50610252600081565b34801561052357600080fd5b506102527ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f78381565b34801561055757600080fd5b50610252610566366004611e81565b610cae565b34801561057757600080fd5b5061030b610586366004611faa565b7fbc197c810000000000000000000000000000000000000000000000000000000095945050505050565b3480156105bc57600080fd5b506101e76105cb366004611bd1565b610cf3565b3480156105dc57600080fd5b506102526105eb366004611bd1565b60009081526001602052604090205490565b34801561060957600080fd5b506101e7610618366004611d5e565b610dee565b6101e761062b366004611e81565b610e13565b34801561063c57600080fd5b5061030b61064b366004612054565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b34801561068157600080fd5b50600254610252565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc16106b48161106b565b60006106c4898989898989610a3d565b90506106d08184611078565b6000817f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8b8b8b8b8b8a60405161070c96959493929190612102565b60405180910390a3505050505050505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e00000000000000000000000000000000000000000000000000000000014806107755750610775826111c0565b92915050565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff166107f8576107f88133611257565b6000610808888888888888610a3d565b90506108148185611327565b6108238160008a8a8a8a611464565b61082c816115a9565b5050505050505050565b6000818152600160205260408120546001811180156108555750428111155b9392505050565b6000828152602081905260409020600101546108778161106b565b6108818383611652565b505050565b60008181526001602052604081205481905b1192915050565b73ffffffffffffffffffffffffffffffffffffffff81163314610949576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b6109538282611742565b5050565b6000818152600160208190526040822054610898565b3330146109fc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f54696d656c6f636b436f6e74726f6c6c65723a2063616c6c6572206d7573742060448201527f62652074696d656c6f636b0000000000000000000000000000000000000000006064820152608401610940565b60025460408051918252602082018390527f11c24f4ead16507c69ac467fbd5e4eed5fb5c699626d2cc6d66421df253886d5910160405180910390a1600255565b6000868686868686604051602001610a5a96959493929190612102565b6040516020818303038152906040528051906020012090509695505050505050565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1610aa68161106b565b888714610b35576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f74636800000000000000000000000000000000000000000000000000000000006064820152608401610940565b888514610bc4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f74636800000000000000000000000000000000000000000000000000000000006064820152608401610940565b6000610bd68b8b8b8b8b8b8b8b610cae565b9050610be28184611078565b60005b8a811015610ca05780827f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8e8e85818110610c2257610c2261214d565b9050602002016020810190610c37919061217c565b8d8d86818110610c4957610c4961214d565b905060200201358c8c87818110610c6257610c6261214d565b9050602002810190610c749190612197565b8c8b604051610c8896959493929190612102565b60405180910390a3610c998161222b565b9050610be5565b505050505050505050505050565b60008888888888888888604051602001610ccf989796959493929190612313565b60405160208183030381529060405280519060200120905098975050505050505050565b7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783610d1d8161106b565b610d2682610957565b610db2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20636160448201527f6e6e6f742062652063616e63656c6c65640000000000000000000000000000006064820152608401610940565b6000828152600160205260408082208290555183917fbaa1eb22f2a492ba1a5fea61b8df4d27c6c8b5f3971e63bb58fa14ff72eedb7091a25050565b600082815260208190526040902060010154610e098161106b565b6108818383611742565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff16610e9057610e908133611257565b878614610f1f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f74636800000000000000000000000000000000000000000000000000000000006064820152608401610940565b878414610fae576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f74636800000000000000000000000000000000000000000000000000000000006064820152608401610940565b6000610fc08a8a8a8a8a8a8a8a610cae565b9050610fcc8185611327565b60005b898110156110555761104582828d8d85818110610fee57610fee61214d565b9050602002016020810190611003919061217c565b8c8c868181106110155761101561214d565b905060200201358b8b8781811061102e5761102e61214d565b90506020028101906110409190612197565b611464565b61104e8161222b565b9050610fcf565b5061105f816115a9565b50505050505050505050565b6110758133611257565b50565b61108182610886565b1561110e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20616c60448201527f7265616479207363686564756c656400000000000000000000000000000000006064820152608401610940565b6002548110156111a0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a20696e73756666696369656e7460448201527f2064656c617900000000000000000000000000000000000000000000000000006064820152608401610940565b6111aa81426123e4565b6000928352600160205260409092209190915550565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061077557507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000831614610775565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16610953576112ad8173ffffffffffffffffffffffffffffffffffffffff1660146117f9565b6112b88360206117f9565b6040516020016112c992919061242c565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a0000000000000000000000000000000000000000000000000000000008252610940916004016124ad565b61133082610836565b6113bc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f74207265616479000000000000000000000000000000000000000000006064820152608401610940565b8015806113d85750600081815260016020819052604090912054145b610953576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a206d697373696e67206465706560448201527f6e64656e637900000000000000000000000000000000000000000000000000006064820152608401610940565b60008473ffffffffffffffffffffffffffffffffffffffff1684848460405161148e9291906124fe565b60006040518083038185875af1925050503d80600081146114cb576040519150601f19603f3d011682016040523d82523d6000602084013e6114d0565b606091505b5050905080611561576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603360248201527f54696d656c6f636b436f6e74726f6c6c65723a20756e6465726c79696e67207460448201527f72616e73616374696f6e207265766572746564000000000000000000000000006064820152608401610940565b85877fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b5887878787604051611598949392919061250e565b60405180910390a350505050505050565b6115b281610836565b61163e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f74207265616479000000000000000000000000000000000000000000006064820152608401610940565b600090815260016020819052604090912055565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109535760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556116e43390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16156109535760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6060600061180883600261254e565b6118139060026123e4565b67ffffffffffffffff81111561182b5761182b611bea565b6040519080825280601f01601f191660200182016040528015611855576020820181803683370190505b5090507f30000000000000000000000000000000000000000000000000000000000000008160008151811061188c5761188c61214d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106118ef576118ef61214d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600061192b84600261254e565b6119369060016123e4565b90505b60018111156119d3577f303132333435363738396162636465660000000000000000000000000000000085600f16601081106119775761197761214d565b1a60f81b82828151811061198d5761198d61214d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c936119cc8161258b565b9050611939565b508315610855576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610940565b803573ffffffffffffffffffffffffffffffffffffffff81168114611a6057600080fd5b919050565b60008083601f840112611a7757600080fd5b50813567ffffffffffffffff811115611a8f57600080fd5b602083019150836020828501011115611aa757600080fd5b9250929050565b600080600080600080600060c0888a031215611ac957600080fd5b611ad288611a3c565b965060208801359550604088013567ffffffffffffffff811115611af557600080fd5b611b018a828b01611a65565b989b979a50986060810135976080820135975060a09091013595509350505050565b600060208284031215611b3557600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461085557600080fd5b60008060008060008060a08789031215611b7e57600080fd5b611b8787611a3c565b955060208701359450604087013567ffffffffffffffff811115611baa57600080fd5b611bb689828a01611a65565b979a9699509760608101359660809091013595509350505050565b600060208284031215611be357600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611c6057611c60611bea565b604052919050565b600082601f830112611c7957600080fd5b813567ffffffffffffffff811115611c9357611c93611bea565b611cc460207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611c19565b818152846020838601011115611cd957600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215611d0c57600080fd5b611d1585611a3c565b9350611d2360208601611a3c565b925060408501359150606085013567ffffffffffffffff811115611d4657600080fd5b611d5287828801611c68565b91505092959194509250565b60008060408385031215611d7157600080fd5b82359150611d8160208401611a3c565b90509250929050565b60008083601f840112611d9c57600080fd5b50813567ffffffffffffffff811115611db457600080fd5b6020830191508360208260051b8501011115611aa757600080fd5b600080600080600080600080600060c08a8c031215611ded57600080fd5b893567ffffffffffffffff80821115611e0557600080fd5b611e118d838e01611d8a565b909b50995060208c0135915080821115611e2a57600080fd5b611e368d838e01611d8a565b909950975060408c0135915080821115611e4f57600080fd5b50611e5c8c828d01611d8a565b9a9d999c50979a969997986060880135976080810135975060a0013595509350505050565b60008060008060008060008060a0898b031215611e9d57600080fd5b883567ffffffffffffffff80821115611eb557600080fd5b611ec18c838d01611d8a565b909a50985060208b0135915080821115611eda57600080fd5b611ee68c838d01611d8a565b909850965060408b0135915080821115611eff57600080fd5b50611f0c8b828c01611d8a565b999c989b509699959896976060870135966080013595509350505050565b600082601f830112611f3b57600080fd5b8135602067ffffffffffffffff821115611f5757611f57611bea565b8160051b611f66828201611c19565b9283528481018201928281019087851115611f8057600080fd5b83870192505b84831015611f9f57823582529183019190830190611f86565b979650505050505050565b600080600080600060a08688031215611fc257600080fd5b611fcb86611a3c565b9450611fd960208701611a3c565b9350604086013567ffffffffffffffff80821115611ff657600080fd5b61200289838a01611f2a565b9450606088013591508082111561201857600080fd5b61202489838a01611f2a565b9350608088013591508082111561203a57600080fd5b5061204788828901611c68565b9150509295509295909350565b600080600080600060a0868803121561206c57600080fd5b61207586611a3c565b945061208360208701611a3c565b93506040860135925060608601359150608086013567ffffffffffffffff8111156120ad57600080fd5b61204788828901611c68565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b73ffffffffffffffffffffffffffffffffffffffff8716815285602082015260a06040820152600061213860a0830186886120b9565b60608301949094525060800152949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561218e57600080fd5b61085582611a3c565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126121cc57600080fd5b83018035915067ffffffffffffffff8211156121e757600080fd5b602001915036819003821315611aa757600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361225c5761225c6121fc565b5060010190565b81835260006020808501808196508560051b810191508460005b8781101561230657828403895281357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18836030181126122bc57600080fd5b8701858101903567ffffffffffffffff8111156122d857600080fd5b8036038213156122e757600080fd5b6122f28682846120b9565b9a87019a955050509084019060010161227d565b5091979650505050505050565b60a0808252810188905260008960c08301825b8b8110156123615773ffffffffffffffffffffffffffffffffffffffff61234c84611a3c565b16825260209283019290910190600101612326565b5083810360208501528881527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff89111561239a57600080fd5b8860051b9150818a6020830137818101915050602081016000815260208483030160408501526123cb81888a612263565b6060850196909652505050608001529695505050505050565b600082198211156123f7576123f76121fc565b500190565b60005b838110156124175781810151838201526020016123ff565b83811115612426576000848401525b50505050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516124648160178501602088016123fc565b7f206973206d697373696e6720726f6c652000000000000000000000000000000060179184019182015283516124a18160288401602088016123fc565b01602801949350505050565b60208152600082518060208401526124cc8160408501602087016123fc565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b8183823760009101908152919050565b73ffffffffffffffffffffffffffffffffffffffff851681528360208201526060604082015260006125446060830184866120b9565b9695505050505050565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612586576125866121fc565b500290565b60008161259a5761259a6121fc565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea26469706673582212206c3f14b1a056ea7f0fe0793553971f257bfc9c449371f2593f4b098b3dbe33c964736f6c634300080f00335f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5b09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1d8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e63fd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783", - "deployedBytecode": "0x6080604052600436106101bb5760003560e01c80638065657f116100ec578063bc197c811161008a578063d547741f11610064578063d547741f146105fd578063e38335e51461061d578063f23a6e6114610630578063f27a0c921461067557600080fd5b8063bc197c811461056b578063c4d252f5146105b0578063d45c4435146105d057600080fd5b806391d14854116100c657806391d14854146104b1578063a217fddf14610502578063b08e51c014610517578063b1c5f4271461054b57600080fd5b80638065657f1461043d5780638f2a0bb01461045d5780638f61f4f51461047d57600080fd5b8063248a9ca31161015957806331d507501161013357806331d50750146103bd57806336568abe146103dd578063584b153e146103fd57806364d623531461041d57600080fd5b8063248a9ca31461033c5780632ab0f5291461036c5780632f2ff15d1461039d57600080fd5b80630d3cf6fc116101955780630d3cf6fc14610260578063134008d31461029457806313bc9f20146102a7578063150b7a02146102c757600080fd5b806301d5062a146101c757806301ffc9a7146101e957806307bd02651461021e57600080fd5b366101c257005b600080fd5b3480156101d357600080fd5b506101e76101e2366004611aae565b61068a565b005b3480156101f557600080fd5b50610209610204366004611b23565b61071f565b60405190151581526020015b60405180910390f35b34801561022a57600080fd5b506102527fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e6381565b604051908152602001610215565b34801561026c57600080fd5b506102527f5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca581565b6101e76102a2366004611b65565b61077b565b3480156102b357600080fd5b506102096102c2366004611bd1565b610836565b3480156102d357600080fd5b5061030b6102e2366004611cf6565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff000000000000000000000000000000000000000000000000000000009091168152602001610215565b34801561034857600080fd5b50610252610357366004611bd1565b60009081526020819052604090206001015490565b34801561037857600080fd5b50610209610387366004611bd1565b6000908152600160208190526040909120541490565b3480156103a957600080fd5b506101e76103b8366004611d5e565b61085c565b3480156103c957600080fd5b506102096103d8366004611bd1565b610886565b3480156103e957600080fd5b506101e76103f8366004611d5e565b61089f565b34801561040957600080fd5b50610209610418366004611bd1565b610957565b34801561042957600080fd5b506101e7610438366004611bd1565b61096d565b34801561044957600080fd5b50610252610458366004611b65565b610a3d565b34801561046957600080fd5b506101e7610478366004611dcf565b610a7c565b34801561048957600080fd5b506102527fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc181565b3480156104bd57600080fd5b506102096104cc366004611d5e565b60009182526020828152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b34801561050e57600080fd5b50610252600081565b34801561052357600080fd5b506102527ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f78381565b34801561055757600080fd5b50610252610566366004611e81565b610cae565b34801561057757600080fd5b5061030b610586366004611faa565b7fbc197c810000000000000000000000000000000000000000000000000000000095945050505050565b3480156105bc57600080fd5b506101e76105cb366004611bd1565b610cf3565b3480156105dc57600080fd5b506102526105eb366004611bd1565b60009081526001602052604090205490565b34801561060957600080fd5b506101e7610618366004611d5e565b610dee565b6101e761062b366004611e81565b610e13565b34801561063c57600080fd5b5061030b61064b366004612054565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b34801561068157600080fd5b50600254610252565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc16106b48161106b565b60006106c4898989898989610a3d565b90506106d08184611078565b6000817f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8b8b8b8b8b8a60405161070c96959493929190612102565b60405180910390a3505050505050505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e00000000000000000000000000000000000000000000000000000000014806107755750610775826111c0565b92915050565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff166107f8576107f88133611257565b6000610808888888888888610a3d565b90506108148185611327565b6108238160008a8a8a8a611464565b61082c816115a9565b5050505050505050565b6000818152600160205260408120546001811180156108555750428111155b9392505050565b6000828152602081905260409020600101546108778161106b565b6108818383611652565b505050565b60008181526001602052604081205481905b1192915050565b73ffffffffffffffffffffffffffffffffffffffff81163314610949576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b6109538282611742565b5050565b6000818152600160208190526040822054610898565b3330146109fc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f54696d656c6f636b436f6e74726f6c6c65723a2063616c6c6572206d7573742060448201527f62652074696d656c6f636b0000000000000000000000000000000000000000006064820152608401610940565b60025460408051918252602082018390527f11c24f4ead16507c69ac467fbd5e4eed5fb5c699626d2cc6d66421df253886d5910160405180910390a1600255565b6000868686868686604051602001610a5a96959493929190612102565b6040516020818303038152906040528051906020012090509695505050505050565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1610aa68161106b565b888714610b35576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f74636800000000000000000000000000000000000000000000000000000000006064820152608401610940565b888514610bc4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f74636800000000000000000000000000000000000000000000000000000000006064820152608401610940565b6000610bd68b8b8b8b8b8b8b8b610cae565b9050610be28184611078565b60005b8a811015610ca05780827f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8e8e85818110610c2257610c2261214d565b9050602002016020810190610c37919061217c565b8d8d86818110610c4957610c4961214d565b905060200201358c8c87818110610c6257610c6261214d565b9050602002810190610c749190612197565b8c8b604051610c8896959493929190612102565b60405180910390a3610c998161222b565b9050610be5565b505050505050505050505050565b60008888888888888888604051602001610ccf989796959493929190612313565b60405160208183030381529060405280519060200120905098975050505050505050565b7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783610d1d8161106b565b610d2682610957565b610db2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20636160448201527f6e6e6f742062652063616e63656c6c65640000000000000000000000000000006064820152608401610940565b6000828152600160205260408082208290555183917fbaa1eb22f2a492ba1a5fea61b8df4d27c6c8b5f3971e63bb58fa14ff72eedb7091a25050565b600082815260208190526040902060010154610e098161106b565b6108818383611742565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff16610e9057610e908133611257565b878614610f1f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f74636800000000000000000000000000000000000000000000000000000000006064820152608401610940565b878414610fae576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f74636800000000000000000000000000000000000000000000000000000000006064820152608401610940565b6000610fc08a8a8a8a8a8a8a8a610cae565b9050610fcc8185611327565b60005b898110156110555761104582828d8d85818110610fee57610fee61214d565b9050602002016020810190611003919061217c565b8c8c868181106110155761101561214d565b905060200201358b8b8781811061102e5761102e61214d565b90506020028101906110409190612197565b611464565b61104e8161222b565b9050610fcf565b5061105f816115a9565b50505050505050505050565b6110758133611257565b50565b61108182610886565b1561110e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20616c60448201527f7265616479207363686564756c656400000000000000000000000000000000006064820152608401610940565b6002548110156111a0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a20696e73756666696369656e7460448201527f2064656c617900000000000000000000000000000000000000000000000000006064820152608401610940565b6111aa81426123e4565b6000928352600160205260409092209190915550565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061077557507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000831614610775565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16610953576112ad8173ffffffffffffffffffffffffffffffffffffffff1660146117f9565b6112b88360206117f9565b6040516020016112c992919061242c565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a0000000000000000000000000000000000000000000000000000000008252610940916004016124ad565b61133082610836565b6113bc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f74207265616479000000000000000000000000000000000000000000006064820152608401610940565b8015806113d85750600081815260016020819052604090912054145b610953576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a206d697373696e67206465706560448201527f6e64656e637900000000000000000000000000000000000000000000000000006064820152608401610940565b60008473ffffffffffffffffffffffffffffffffffffffff1684848460405161148e9291906124fe565b60006040518083038185875af1925050503d80600081146114cb576040519150601f19603f3d011682016040523d82523d6000602084013e6114d0565b606091505b5050905080611561576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603360248201527f54696d656c6f636b436f6e74726f6c6c65723a20756e6465726c79696e67207460448201527f72616e73616374696f6e207265766572746564000000000000000000000000006064820152608401610940565b85877fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b5887878787604051611598949392919061250e565b60405180910390a350505050505050565b6115b281610836565b61163e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f74207265616479000000000000000000000000000000000000000000006064820152608401610940565b600090815260016020819052604090912055565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109535760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556116e43390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16156109535760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6060600061180883600261254e565b6118139060026123e4565b67ffffffffffffffff81111561182b5761182b611bea565b6040519080825280601f01601f191660200182016040528015611855576020820181803683370190505b5090507f30000000000000000000000000000000000000000000000000000000000000008160008151811061188c5761188c61214d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106118ef576118ef61214d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600061192b84600261254e565b6119369060016123e4565b90505b60018111156119d3577f303132333435363738396162636465660000000000000000000000000000000085600f16601081106119775761197761214d565b1a60f81b82828151811061198d5761198d61214d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c936119cc8161258b565b9050611939565b508315610855576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610940565b803573ffffffffffffffffffffffffffffffffffffffff81168114611a6057600080fd5b919050565b60008083601f840112611a7757600080fd5b50813567ffffffffffffffff811115611a8f57600080fd5b602083019150836020828501011115611aa757600080fd5b9250929050565b600080600080600080600060c0888a031215611ac957600080fd5b611ad288611a3c565b965060208801359550604088013567ffffffffffffffff811115611af557600080fd5b611b018a828b01611a65565b989b979a50986060810135976080820135975060a09091013595509350505050565b600060208284031215611b3557600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461085557600080fd5b60008060008060008060a08789031215611b7e57600080fd5b611b8787611a3c565b955060208701359450604087013567ffffffffffffffff811115611baa57600080fd5b611bb689828a01611a65565b979a9699509760608101359660809091013595509350505050565b600060208284031215611be357600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611c6057611c60611bea565b604052919050565b600082601f830112611c7957600080fd5b813567ffffffffffffffff811115611c9357611c93611bea565b611cc460207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611c19565b818152846020838601011115611cd957600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215611d0c57600080fd5b611d1585611a3c565b9350611d2360208601611a3c565b925060408501359150606085013567ffffffffffffffff811115611d4657600080fd5b611d5287828801611c68565b91505092959194509250565b60008060408385031215611d7157600080fd5b82359150611d8160208401611a3c565b90509250929050565b60008083601f840112611d9c57600080fd5b50813567ffffffffffffffff811115611db457600080fd5b6020830191508360208260051b8501011115611aa757600080fd5b600080600080600080600080600060c08a8c031215611ded57600080fd5b893567ffffffffffffffff80821115611e0557600080fd5b611e118d838e01611d8a565b909b50995060208c0135915080821115611e2a57600080fd5b611e368d838e01611d8a565b909950975060408c0135915080821115611e4f57600080fd5b50611e5c8c828d01611d8a565b9a9d999c50979a969997986060880135976080810135975060a0013595509350505050565b60008060008060008060008060a0898b031215611e9d57600080fd5b883567ffffffffffffffff80821115611eb557600080fd5b611ec18c838d01611d8a565b909a50985060208b0135915080821115611eda57600080fd5b611ee68c838d01611d8a565b909850965060408b0135915080821115611eff57600080fd5b50611f0c8b828c01611d8a565b999c989b509699959896976060870135966080013595509350505050565b600082601f830112611f3b57600080fd5b8135602067ffffffffffffffff821115611f5757611f57611bea565b8160051b611f66828201611c19565b9283528481018201928281019087851115611f8057600080fd5b83870192505b84831015611f9f57823582529183019190830190611f86565b979650505050505050565b600080600080600060a08688031215611fc257600080fd5b611fcb86611a3c565b9450611fd960208701611a3c565b9350604086013567ffffffffffffffff80821115611ff657600080fd5b61200289838a01611f2a565b9450606088013591508082111561201857600080fd5b61202489838a01611f2a565b9350608088013591508082111561203a57600080fd5b5061204788828901611c68565b9150509295509295909350565b600080600080600060a0868803121561206c57600080fd5b61207586611a3c565b945061208360208701611a3c565b93506040860135925060608601359150608086013567ffffffffffffffff8111156120ad57600080fd5b61204788828901611c68565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b73ffffffffffffffffffffffffffffffffffffffff8716815285602082015260a06040820152600061213860a0830186886120b9565b60608301949094525060800152949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561218e57600080fd5b61085582611a3c565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126121cc57600080fd5b83018035915067ffffffffffffffff8211156121e757600080fd5b602001915036819003821315611aa757600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361225c5761225c6121fc565b5060010190565b81835260006020808501808196508560051b810191508460005b8781101561230657828403895281357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18836030181126122bc57600080fd5b8701858101903567ffffffffffffffff8111156122d857600080fd5b8036038213156122e757600080fd5b6122f28682846120b9565b9a87019a955050509084019060010161227d565b5091979650505050505050565b60a0808252810188905260008960c08301825b8b8110156123615773ffffffffffffffffffffffffffffffffffffffff61234c84611a3c565b16825260209283019290910190600101612326565b5083810360208501528881527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff89111561239a57600080fd5b8860051b9150818a6020830137818101915050602081016000815260208483030160408501526123cb81888a612263565b6060850196909652505050608001529695505050505050565b600082198211156123f7576123f76121fc565b500190565b60005b838110156124175781810151838201526020016123ff565b83811115612426576000848401525b50505050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516124648160178501602088016123fc565b7f206973206d697373696e6720726f6c652000000000000000000000000000000060179184019182015283516124a18160288401602088016123fc565b01602801949350505050565b60208152600082518060208401526124cc8160408501602087016123fc565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b8183823760009101908152919050565b73ffffffffffffffffffffffffffffffffffffffff851681528360208201526060604082015260006125446060830184866120b9565b9695505050505050565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612586576125866121fc565b500290565b60008161259a5761259a6121fc565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea26469706673582212206c3f14b1a056ea7f0fe0793553971f257bfc9c449371f2593f4b098b3dbe33c964736f6c634300080f0033", - "devdoc": { - "details": "Contract module which acts as a timelocked controller. When set as the owner of an `Ownable` smart contract, it enforces a timelock on all `onlyOwner` maintenance operations. This gives time for users of the controlled contract to exit before a potentially dangerous maintenance operation is applied. By default, this contract is self administered, meaning administration tasks have to go through the timelock process. The proposer (resp executor) role is in charge of proposing (resp executing) operations. A common use case is to position this {TimelockController} as the owner of a smart contract, with a multisig or a DAO as the sole proposer. _Available since v3.3._", - "events": { - "CallExecuted(bytes32,uint256,address,uint256,bytes)": { - "details": "Emitted when a call is performed as part of operation `id`." - }, - "CallScheduled(bytes32,uint256,address,uint256,bytes,bytes32,uint256)": { - "details": "Emitted when a call is scheduled as part of operation `id`." - }, - "Cancelled(bytes32)": { - "details": "Emitted when operation `id` is cancelled." - }, - "MinDelayChange(uint256,uint256)": { - "details": "Emitted when the minimum delay for future operations is modified." - } - }, - "kind": "dev", - "methods": { - "cancel(bytes32)": { - "details": "Cancel an operation. Requirements: - the caller must have the 'canceller' role." - }, - "constructor": { - "details": "Initializes the contract with a given `minDelay`, and a list of initial proposers and executors. The proposers receive both the proposer and the canceller role (for backward compatibility). The executors receive the executor role. NOTE: At construction, both the deployer and the timelock itself are administrators. This helps further configuration of the timelock by the deployer. After configuration is done, it is recommended that the deployer renounces its admin position and relies on timelocked operations to perform future maintenance." - }, - "execute(address,uint256,bytes,bytes32,bytes32)": { - "details": "Execute an (ready) operation containing a single transaction. Emits a {CallExecuted} event. Requirements: - the caller must have the 'executor' role." - }, - "executeBatch(address[],uint256[],bytes[],bytes32,bytes32)": { - "details": "Execute an (ready) operation containing a batch of transactions. Emits one {CallExecuted} event per transaction in the batch. Requirements: - the caller must have the 'executor' role." - }, - "getMinDelay()": { - "details": "Returns the minimum delay for an operation to become valid. This value can be changed by executing an operation that calls `updateDelay`." - }, - "getRoleAdmin(bytes32)": { - "details": "Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}." - }, - "getTimestamp(bytes32)": { - "details": "Returns the timestamp at with an operation becomes ready (0 for unset operations, 1 for done operations)." - }, - "grantRole(bytes32,address)": { - "details": "Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role." - }, - "hasRole(bytes32,address)": { - "details": "Returns `true` if `account` has been granted `role`." - }, - "hashOperation(address,uint256,bytes,bytes32,bytes32)": { - "details": "Returns the identifier of an operation containing a single transaction." - }, - "hashOperationBatch(address[],uint256[],bytes[],bytes32,bytes32)": { - "details": "Returns the identifier of an operation containing a batch of transactions." - }, - "isOperation(bytes32)": { - "details": "Returns whether an id correspond to a registered operation. This includes both Pending, Ready and Done operations." - }, - "isOperationDone(bytes32)": { - "details": "Returns whether an operation is done or not." - }, - "isOperationPending(bytes32)": { - "details": "Returns whether an operation is pending or not." - }, - "isOperationReady(bytes32)": { - "details": "Returns whether an operation is ready or not." - }, - "onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)": { - "details": "See {IERC1155Receiver-onERC1155BatchReceived}." - }, - "onERC1155Received(address,address,uint256,uint256,bytes)": { - "details": "See {IERC1155Receiver-onERC1155Received}." - }, - "onERC721Received(address,address,uint256,bytes)": { - "details": "See {IERC721Receiver-onERC721Received}." - }, - "renounceRole(bytes32,address)": { - "details": "Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `account`." - }, - "revokeRole(bytes32,address)": { - "details": "Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role." - }, - "schedule(address,uint256,bytes,bytes32,bytes32,uint256)": { - "details": "Schedule an operation containing a single transaction. Emits a {CallScheduled} event. Requirements: - the caller must have the 'proposer' role." - }, - "scheduleBatch(address[],uint256[],bytes[],bytes32,bytes32,uint256)": { - "details": "Schedule an operation containing a batch of transactions. Emits one {CallScheduled} event per transaction in the batch. Requirements: - the caller must have the 'proposer' role." - }, - "supportsInterface(bytes4)": { - "details": "See {IERC165-supportsInterface}." - }, - "updateDelay(uint256)": { - "details": "Changes the minimum timelock duration for future operations. Emits a {MinDelayChange} event. Requirements: - the caller must be the timelock itself. This can only be achieved by scheduling and later executing an operation where the timelock is the target and the data is the ABI-encoded call to this function." - } - }, - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": {}, - "version": 1 - }, - "storageLayout": { - "storage": [ - { - "astId": 4890, - "contract": "@openzeppelin/contracts/governance/TimelockController.sol:TimelockController", - "label": "_roles", - "offset": 0, - "slot": "0", - "type": "t_mapping(t_bytes32,t_struct(RoleData)4885_storage)" - }, - { - "astId": 5555, - "contract": "@openzeppelin/contracts/governance/TimelockController.sol:TimelockController", - "label": "_timestamps", - "offset": 0, - "slot": "1", - "type": "t_mapping(t_bytes32,t_uint256)" - }, - { - "astId": 5557, - "contract": "@openzeppelin/contracts/governance/TimelockController.sol:TimelockController", - "label": "_minDelay", - "offset": 0, - "slot": "2", - "type": "t_uint256" - } - ], - "types": { - "t_address": { - "encoding": "inplace", - "label": "address", - "numberOfBytes": "20" - }, - "t_bool": { - "encoding": "inplace", - "label": "bool", - "numberOfBytes": "1" - }, - "t_bytes32": { - "encoding": "inplace", - "label": "bytes32", - "numberOfBytes": "32" - }, - "t_mapping(t_address,t_bool)": { - "encoding": "mapping", - "key": "t_address", - "label": "mapping(address => bool)", - "numberOfBytes": "32", - "value": "t_bool" - }, - "t_mapping(t_bytes32,t_struct(RoleData)4885_storage)": { - "encoding": "mapping", - "key": "t_bytes32", - "label": "mapping(bytes32 => struct AccessControl.RoleData)", - "numberOfBytes": "32", - "value": "t_struct(RoleData)4885_storage" - }, - "t_mapping(t_bytes32,t_uint256)": { - "encoding": "mapping", - "key": "t_bytes32", - "label": "mapping(bytes32 => uint256)", - "numberOfBytes": "32", - "value": "t_uint256" - }, - "t_struct(RoleData)4885_storage": { - "encoding": "inplace", - "label": "struct AccessControl.RoleData", - "members": [ - { - "astId": 4882, - "contract": "@openzeppelin/contracts/governance/TimelockController.sol:TimelockController", - "label": "members", - "offset": 0, - "slot": "0", - "type": "t_mapping(t_address,t_bool)" - }, - { - "astId": 4884, - "contract": "@openzeppelin/contracts/governance/TimelockController.sol:TimelockController", - "label": "adminRole", - "offset": 0, - "slot": "1", - "type": "t_bytes32" - } - ], - "numberOfBytes": "64" - }, - "t_uint256": { - "encoding": "inplace", - "label": "uint256", - "numberOfBytes": "32" - } - } - } -} diff --git a/packages/perennial/deployments/goerli/UpgradeableBeacon.json b/packages/perennial/deployments/goerli/UpgradeableBeacon.json deleted file mode 100644 index ef52c057a..000000000 --- a/packages/perennial/deployments/goerli/UpgradeableBeacon.json +++ /dev/null @@ -1,206 +0,0 @@ -{ - "address": "0x431545dA9b7342BCBF4688f25f663b967c10593e", - "abi": [ - { - "inputs": [ - { - "internalType": "address", - "name": "implementation_", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "implementation", - "type": "address" - } - ], - "name": "Upgraded", - "type": "event" - }, - { - "inputs": [], - "name": "implementation", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newImplementation", - "type": "address" - } - ], - "name": "upgradeTo", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } - ], - "transactionHash": "0xa0f0732bec469b99c4aa2bd09d82f4a61abe78b04b46b43ba6c874123c774f1b", - "receipt": { - "to": null, - "from": "0x66a7fDB96C583c59597de16d8b2B989231415339", - "contractAddress": "0x431545dA9b7342BCBF4688f25f663b967c10593e", - "transactionIndex": 30, - "gasUsed": "408807", - "logsBloom": "0x00000000000000000000000000000100000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000008000400000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000080000000000000000000000000000000000000", - "blockHash": "0x97412daafe5447d3b1cb0eb17cc8bb491fcd9e358ccc83b7119551f7ba705a18", - "transactionHash": "0xa0f0732bec469b99c4aa2bd09d82f4a61abe78b04b46b43ba6c874123c774f1b", - "logs": [ - { - "transactionIndex": 30, - "blockNumber": 7681144, - "transactionHash": "0xa0f0732bec469b99c4aa2bd09d82f4a61abe78b04b46b43ba6c874123c774f1b", - "address": "0x431545dA9b7342BCBF4688f25f663b967c10593e", - "topics": [ - "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x00000000000000000000000066a7fdb96c583c59597de16d8b2b989231415339" - ], - "data": "0x", - "logIndex": 65, - "blockHash": "0x97412daafe5447d3b1cb0eb17cc8bb491fcd9e358ccc83b7119551f7ba705a18" - } - ], - "blockNumber": 7681144, - "cumulativeGasUsed": "7347175", - "status": 1, - "byzantium": true - }, - "args": ["0x60eA8B7346B230fB6987783501075A42c2fAeDB4"], - "numDeployments": 1, - "solcInputHash": "b6ff42633a62e1bc6c97d8ccad85444b", - "metadata": "{\"compiler\":{\"version\":\"0.8.15+commit.e14f2714\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their implementation contract, which is where they will delegate all function calls. An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.\",\"events\":{\"Upgraded(address)\":{\"details\":\"Emitted when the implementation returned by the beacon is changed.\"}},\"kind\":\"dev\",\"methods\":{\"constructor\":{\"details\":\"Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the beacon.\"},\"implementation()\":{\"details\":\"Returns the current implementation address.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"upgradeTo(address)\":{\"details\":\"Upgrades the beacon to a new implementation. Emits an {Upgraded} event. Requirements: - msg.sender must be the owner of the contract. - `newImplementation` must be a contract.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol\":\"UpgradeableBeacon\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0x24e0364e503a9bbde94c715d26573a76f14cd2a202d45f96f52134ab806b67b9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/UpgradeableBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IBeacon.sol\\\";\\nimport \\\"../../access/Ownable.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\n\\n/**\\n * @dev This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their\\n * implementation contract, which is where they will delegate all function calls.\\n *\\n * An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.\\n */\\ncontract UpgradeableBeacon is IBeacon, Ownable {\\n address private _implementation;\\n\\n /**\\n * @dev Emitted when the implementation returned by the beacon is changed.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the\\n * beacon.\\n */\\n constructor(address implementation_) {\\n _setImplementation(implementation_);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function implementation() public view virtual override returns (address) {\\n return _implementation;\\n }\\n\\n /**\\n * @dev Upgrades the beacon to a new implementation.\\n *\\n * Emits an {Upgraded} event.\\n *\\n * Requirements:\\n *\\n * - msg.sender must be the owner of the contract.\\n * - `newImplementation` must be a contract.\\n */\\n function upgradeTo(address newImplementation) public virtual onlyOwner {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Sets the implementation contract address for this beacon\\n *\\n * Requirements:\\n *\\n * - `newImplementation` must be a contract.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"UpgradeableBeacon: implementation is not a contract\\\");\\n _implementation = newImplementation;\\n }\\n}\\n\",\"keccak256\":\"0x6ec71aef5659f3f74011169948d2fcda8c6599be5bb38f986380a8737f96cc0f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // 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\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x608060405234801561001057600080fd5b5060405161070c38038061070c83398101604081905261002f91610151565b61003833610047565b61004181610097565b50610181565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6100aa8161014260201b61038d1760201c565b6101205760405162461bcd60e51b815260206004820152603360248201527f5570677261646561626c65426561636f6e3a20696d706c656d656e746174696f60448201527f6e206973206e6f74206120636f6e747261637400000000000000000000000000606482015260840160405180910390fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b03163b151590565b60006020828403121561016357600080fd5b81516001600160a01b038116811461017a57600080fd5b9392505050565b61057c806101906000396000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c8063715018a611610050578063715018a6146100c45780638da5cb5b146100cc578063f2fde38b146100ea57600080fd5b80633659cfe61461006c5780635c60da1b14610081575b600080fd5b61007f61007a366004610509565b6100fd565b005b60015473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61007f6101d0565b60005473ffffffffffffffffffffffffffffffffffffffff1661009b565b61007f6100f8366004610509565b61025d565b60005473ffffffffffffffffffffffffffffffffffffffff163314610183576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b61018c816103a9565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60005473ffffffffffffffffffffffffffffffffffffffff163314610251576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161017a565b61025b6000610494565b565b60005473ffffffffffffffffffffffffffffffffffffffff1633146102de576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161017a565b73ffffffffffffffffffffffffffffffffffffffff8116610381576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161017a565b61038a81610494565b50565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b73ffffffffffffffffffffffffffffffffffffffff81163b61044d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603360248201527f5570677261646561626c65426561636f6e3a20696d706c656d656e746174696f60448201527f6e206973206e6f74206120636f6e747261637400000000000000000000000000606482015260840161017a565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121561051b57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff8116811461053f57600080fd5b939250505056fea2646970667358221220995a0ae0cf04f45364a4a2b63c87f7425d2b95e4f2c42bacf4f6d33339c80e7764736f6c634300080f0033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100675760003560e01c8063715018a611610050578063715018a6146100c45780638da5cb5b146100cc578063f2fde38b146100ea57600080fd5b80633659cfe61461006c5780635c60da1b14610081575b600080fd5b61007f61007a366004610509565b6100fd565b005b60015473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61007f6101d0565b60005473ffffffffffffffffffffffffffffffffffffffff1661009b565b61007f6100f8366004610509565b61025d565b60005473ffffffffffffffffffffffffffffffffffffffff163314610183576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b61018c816103a9565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60005473ffffffffffffffffffffffffffffffffffffffff163314610251576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161017a565b61025b6000610494565b565b60005473ffffffffffffffffffffffffffffffffffffffff1633146102de576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161017a565b73ffffffffffffffffffffffffffffffffffffffff8116610381576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161017a565b61038a81610494565b50565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b73ffffffffffffffffffffffffffffffffffffffff81163b61044d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603360248201527f5570677261646561626c65426561636f6e3a20696d706c656d656e746174696f60448201527f6e206973206e6f74206120636f6e747261637400000000000000000000000000606482015260840161017a565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121561051b57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff8116811461053f57600080fd5b939250505056fea2646970667358221220995a0ae0cf04f45364a4a2b63c87f7425d2b95e4f2c42bacf4f6d33339c80e7764736f6c634300080f0033", - "devdoc": { - "details": "This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their implementation contract, which is where they will delegate all function calls. An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.", - "events": { - "Upgraded(address)": { - "details": "Emitted when the implementation returned by the beacon is changed." - } - }, - "kind": "dev", - "methods": { - "constructor": { - "details": "Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the beacon." - }, - "implementation()": { - "details": "Returns the current implementation address." - }, - "owner()": { - "details": "Returns the address of the current owner." - }, - "renounceOwnership()": { - "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." - }, - "transferOwnership(address)": { - "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." - }, - "upgradeTo(address)": { - "details": "Upgrades the beacon to a new implementation. Emits an {Upgraded} event. Requirements: - msg.sender must be the owner of the contract. - `newImplementation` must be a contract." - } - }, - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": {}, - "version": 1 - }, - "storageLayout": { - "storage": [ - { - "astId": 5416, - "contract": "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol:UpgradeableBeacon", - "label": "_owner", - "offset": 0, - "slot": "0", - "type": "t_address" - }, - { - "astId": 6942, - "contract": "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol:UpgradeableBeacon", - "label": "_implementation", - "offset": 0, - "slot": "1", - "type": "t_address" - } - ], - "types": { - "t_address": { - "encoding": "inplace", - "label": "address", - "numberOfBytes": "20" - } - } - } -} diff --git a/packages/perennial/deployments/goerli/solcInputs/40214df36850e11c061b57b4ce3f83e9.json b/packages/perennial/deployments/goerli/solcInputs/40214df36850e11c061b57b4ce3f83e9.json deleted file mode 100644 index ecbecd14b..000000000 --- a/packages/perennial/deployments/goerli/solcInputs/40214df36850e11c061b57b4ce3f83e9.json +++ /dev/null @@ -1,137 +0,0 @@ -{ - "language": "Solidity", - "sources": { - "contracts/product/Product.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/root/control/unstructured/UInitializable.sol\";\nimport \"@equilibria/root/control/unstructured/UReentrancyGuard.sol\";\nimport \"../controller/UControllerProvider.sol\";\nimport \"./UPayoffProvider.sol\";\nimport \"./UParamProvider.sol\";\nimport \"./types/position/AccountPosition.sol\";\nimport \"./types/accumulator/AccountAccumulator.sol\";\n\n/**\n * @title Product\n * @notice Manages logic and state for a single product market.\n * @dev Cloned by the Controller contract to launch new product markets.\n */\ncontract Product is IProduct, UInitializable, UParamProvider, UPayoffProvider, UReentrancyGuard {\n /// @dev Whether or not the product is closed\n BoolStorage private constant _closed =\n BoolStorage.wrap(keccak256(\"equilibria.perennial.Product.closed\"));\n function closed() public view returns (bool) { return _closed.read(); }\n\n\n /// @dev The name of the product\n string public name;\n\n /// @dev The symbol of the product\n string public symbol;\n\n /// @dev The individual position state for each account\n mapping(address => AccountPosition) private _positions;\n\n /// @dev The global position state for the product\n VersionedPosition private _position;\n\n /// @dev The individual accumulator state for each account\n mapping(address => AccountAccumulator) private _accumulators;\n\n /// @dev The global accumulator state for the product\n VersionedAccumulator private _accumulator;\n\n /**\n * @notice Initializes the contract state\n * @param productInfo_ Product initialization params\n */\n function initialize(ProductInfo calldata productInfo_) external initializer(1) {\n __UControllerProvider__initialize(IController(msg.sender));\n __UPayoffProvider__initialize(productInfo_.oracle, productInfo_.payoffDefinition);\n __UReentrancyGuard__initialize();\n __UParamProvider__initialize(\n productInfo_.maintenance,\n productInfo_.fundingFee,\n productInfo_.makerFee,\n productInfo_.takerFee,\n productInfo_.makerLimit,\n productInfo_.utilizationCurve\n );\n\n name = productInfo_.name;\n symbol = productInfo_.symbol;\n }\n\n /**\n * @notice Surfaces global settlement externally\n */\n function settle() external nonReentrant notPaused {\n _settle();\n }\n\n /**\n * @notice Core global settlement flywheel\n * @dev\n * a) last settle oracle version\n * b) latest pre position oracle version\n * c) current oracle version\n *\n * Settles from a->b then from b->c if either interval is non-zero to account for a change\n * in position quantity at (b).\n *\n * Syncs each to instantaneously after the oracle update.\n */\n function _settle() private returns (IOracleProvider.OracleVersion memory currentOracleVersion) {\n IController _controller = controller();\n\n // Get current oracle version\n currentOracleVersion = _sync();\n\n // Get latest oracle version\n uint256 _latestVersion = latestVersion();\n if (_latestVersion == currentOracleVersion.version) return currentOracleVersion; // short circuit entirely if a == c\n IOracleProvider.OracleVersion memory latestOracleVersion = atVersion(_latestVersion);\n\n // Get settle oracle version\n uint256 _settleVersion = _position.pre.settleVersion(currentOracleVersion.version);\n IOracleProvider.OracleVersion memory settleOracleVersion = _settleVersion == currentOracleVersion.version ?\n currentOracleVersion : // if b == c, don't re-call provider for oracle version\n atVersion(_settleVersion);\n\n // Initiate\n _controller.incentivizer().sync(currentOracleVersion);\n UFixed18 boundedFundingFee = _boundedFundingFee();\n UFixed18 accumulatedFee;\n\n // value a->b\n accumulatedFee = accumulatedFee.add(\n _accumulator.accumulate(boundedFundingFee, _position, latestOracleVersion, settleOracleVersion)\n );\n\n // position a->b\n accumulatedFee = accumulatedFee.add(_position.settle(_latestVersion, settleOracleVersion));\n\n // short-circuit from a->c if b == c\n if (settleOracleVersion.version != currentOracleVersion.version) {\n\n // value b->c\n accumulatedFee = accumulatedFee.add(\n _accumulator.accumulate(boundedFundingFee, _position, settleOracleVersion, currentOracleVersion)\n );\n\n // position b->c (every accumulator version needs a position stamp)\n _position.settle(settleOracleVersion.version, currentOracleVersion);\n }\n\n // settle collateral\n _controller.collateral().settleProduct(accumulatedFee);\n\n emit Settle(settleOracleVersion.version, currentOracleVersion.version);\n }\n\n /**\n * @notice Surfaces account settlement externally\n * @param account Account to settle\n */\n function settleAccount(address account) external nonReentrant notPaused {\n IOracleProvider.OracleVersion memory currentOracleVersion = _settle();\n _settleAccount(account, currentOracleVersion);\n }\n\n /**\n * @notice Core account settlement flywheel\n * @param account Account to settle\n * @dev\n * a) last settle oracle version\n * b) latest pre position oracle version\n * c) current oracle version\n *\n * Settles from a->b then from b->c if either interval is non-zero to account for a change\n * in position quantity at (b).\n *\n * Syncs each to instantaneously after the oracle update.\n */\n function _settleAccount(address account, IOracleProvider.OracleVersion memory currentOracleVersion) private {\n IController _controller = controller();\n\n // Get latest oracle version\n if (latestVersion(account) == currentOracleVersion.version) return; // short circuit entirely if a == c\n\n // Get settle oracle version\n uint256 _settleVersion = _positions[account].pre.settleVersion(currentOracleVersion.version);\n IOracleProvider.OracleVersion memory settleOracleVersion = _settleVersion == currentOracleVersion.version ?\n currentOracleVersion : // if b == c, don't re-call provider for oracle version\n atVersion(_settleVersion);\n\n // initialize\n Fixed18 accumulated;\n\n // sync incentivizer before accumulator\n _controller.incentivizer().syncAccount(account, settleOracleVersion);\n\n // value a->b\n accumulated = accumulated.add(\n _accumulators[account].syncTo(_accumulator, _positions[account], settleOracleVersion.version).sum());\n\n // position a->b\n accumulated = accumulated.sub(Fixed18Lib.from(_positions[account].settle(settleOracleVersion)));\n\n // short-circuit from a->c if b == c\n if (settleOracleVersion.version != currentOracleVersion.version) {\n // sync incentivizer before accumulator\n _controller.incentivizer().syncAccount(account, currentOracleVersion);\n\n // value b->c\n accumulated = accumulated.add(\n _accumulators[account].syncTo(_accumulator, _positions[account], currentOracleVersion.version).sum());\n }\n\n // settle collateral\n _controller.collateral().settleAccount(account, accumulated);\n\n emit AccountSettle(account, settleOracleVersion.version, currentOracleVersion.version);\n }\n\n /**\n * @notice Opens a taker position for `msg.sender`\n * @param amount Amount of the position to open\n */\n function openTake(UFixed18 amount)\n external\n nonReentrant\n notPaused\n notClosed\n settleForAccount(msg.sender)\n takerInvariant\n positionInvariant\n liquidationInvariant\n maintenanceInvariant\n {\n uint256 _latestVersion = latestVersion();\n\n _positions[msg.sender].pre.openTake(_latestVersion, amount);\n _position.pre.openTake(_latestVersion, amount);\n\n emit TakeOpened(msg.sender, _latestVersion, amount);\n }\n\n /**\n * @notice Closes a taker position for `msg.sender`\n * @param amount Amount of the position to close\n */\n function closeTake(UFixed18 amount)\n external\n nonReentrant\n notPaused\n settleForAccount(msg.sender)\n closeInvariant\n liquidationInvariant\n {\n _closeTake(msg.sender, amount);\n }\n\n function _closeTake(address account, UFixed18 amount) private {\n uint256 _latestVersion = latestVersion();\n\n _positions[account].pre.closeTake(_latestVersion, amount);\n _position.pre.closeTake(_latestVersion, amount);\n\n emit TakeClosed(account, _latestVersion, amount);\n }\n\n /**\n * @notice Opens a maker position for `msg.sender`\n * @param amount Amount of the position to open\n */\n function openMake(UFixed18 amount)\n external\n nonReentrant\n notPaused\n notClosed\n settleForAccount(msg.sender)\n nonZeroVersionInvariant\n makerInvariant\n positionInvariant\n liquidationInvariant\n maintenanceInvariant\n {\n uint256 _latestVersion = latestVersion();\n\n _positions[msg.sender].pre.openMake(_latestVersion, amount);\n _position.pre.openMake(_latestVersion, amount);\n\n emit MakeOpened(msg.sender, _latestVersion, amount);\n }\n\n /**\n * @notice Closes a maker position for `msg.sender`\n * @param amount Amount of the position to close\n */\n function closeMake(UFixed18 amount)\n external\n nonReentrant\n notPaused\n settleForAccount(msg.sender)\n takerInvariant\n closeInvariant\n liquidationInvariant\n {\n _closeMake(msg.sender, amount);\n }\n\n function _closeMake(address account, UFixed18 amount) private {\n uint256 _latestVersion = latestVersion();\n\n _positions[account].pre.closeMake(_latestVersion, amount);\n _position.pre.closeMake(_latestVersion, amount);\n\n emit MakeClosed(account, _latestVersion, amount);\n }\n\n /**\n * @notice Closes all open and pending positions, locking for liquidation\n * @dev Only callable by the Collateral contract as part of the liquidation flow\n * @param account Account to close out\n */\n function closeAll(address account) external onlyCollateral notClosed settleForAccount(account) {\n AccountPosition storage accountPosition = _positions[account];\n Position memory p = accountPosition.position.next(_positions[account].pre);\n\n // Close all positions\n _closeMake(account, p.maker);\n _closeTake(account, p.taker);\n\n // Mark liquidation to lock position\n accountPosition.liquidation = true;\n }\n\n /**\n * @notice Returns the maintenance requirement for `account`\n * @param account Account to return for\n * @return The current maintenance requirement\n */\n function maintenance(address account) external view returns (UFixed18) {\n return _positions[account].maintenance();\n }\n\n /**\n * @notice Returns the maintenance requirement for `account` after next settlement\n * @dev Assumes no price change and no funding, used to protect user from over-opening\n * @param account Account to return for\n * @return The next maintenance requirement\n */\n function maintenanceNext(address account) external view returns (UFixed18) {\n return _positions[account].maintenanceNext();\n }\n\n /**\n * @notice Returns whether `account` has a completely zero'd position\n * @param account Account to return for\n * @return The the account is closed\n */\n function isClosed(address account) external view returns (bool) {\n return _positions[account].isClosed();\n }\n\n /**\n * @notice Returns whether `account` is currently locked for an in-progress liquidation\n * @param account Account to return for\n * @return Whether the account is in liquidation\n */\n function isLiquidating(address account) external view returns (bool) {\n return _positions[account].liquidation;\n }\n\n /**\n * @notice Returns `account`'s current position\n * @param account Account to return for\n * @return Current position of the account\n */\n function position(address account) external view returns (Position memory) {\n return _positions[account].position;\n }\n\n /**\n * @notice Returns `account`'s current pending-settlement position\n * @param account Account to return for\n * @return Current pre-position of the account\n */\n function pre(address account) external view returns (PrePosition memory) {\n return _positions[account].pre;\n }\n\n /**\n * @notice Returns the global latest settled oracle version\n * @return Latest settled oracle version of the product\n */\n function latestVersion() public view returns (uint256) {\n return _accumulator.latestVersion;\n }\n\n /**\n * @notice Returns the global position at oracleVersion `oracleVersion`\n * @dev Only valid for the version at which a global settlement occurred\n * @param oracleVersion Oracle version to return for\n * @return Global position at oracle version\n */\n function positionAtVersion(uint256 oracleVersion) public view returns (Position memory) {\n return _position.positionAtVersion(oracleVersion);\n }\n\n /**\n * @notice Returns the current global pending-settlement position\n * @return Global pending-settlement position\n */\n function pre() external view returns (PrePosition memory) {\n return _position.pre;\n }\n\n /**\n * @notice Returns the global accumulator value at oracleVersion `oracleVersion`\n * @dev Only valid for the version at which a global settlement occurred\n * @param oracleVersion Oracle version to return for\n * @return Global accumulator value at oracle version\n */\n function valueAtVersion(uint256 oracleVersion) external view returns (Accumulator memory) {\n return _accumulator.valueAtVersion(oracleVersion);\n }\n\n /**\n * @notice Returns the global accumulator share at oracleVersion `oracleVersion`\n * @dev Only valid for the version at which a global settlement occurred\n * @param oracleVersion Oracle version to return for\n * @return Global accumulator share at oracle version\n */\n function shareAtVersion(uint256 oracleVersion) external view returns (Accumulator memory) {\n return _accumulator.shareAtVersion(oracleVersion);\n }\n\n /**\n * @notice Returns `account`'s latest settled oracle version\n * @param account Account to return for\n * @return Latest settled oracle version of the account\n */\n function latestVersion(address account) public view returns (uint256) {\n return _accumulators[account].latestVersion;\n }\n\n /**\n * @notice Returns The per-second rate based on the provided `position`\n * @dev Handles 0-maker/taker edge cases\n * @param position_ Position to base utilization on\n * @return The per-second rate\n */\n function rate(Position calldata position_) public view returns (Fixed18) {\n UFixed18 utilization = position_.taker.unsafeDiv(position_.maker);\n Fixed18 annualizedRate = utilizationCurve().compute(utilization);\n return annualizedRate.div(Fixed18Lib.from(365 days));\n }\n\n /**\n * @notice Returns the minimum funding fee parameter with a capped range for safety\n * @dev Caps controller.minFundingFee() <= fundingFee() <= 1\n * @return Safe minimum funding fee parameter\n */\n function _boundedFundingFee() private view returns (UFixed18) {\n return fundingFee().max(controller().minFundingFee());\n }\n\n /**\n * @notice Updates product closed state\n * @dev only callable by product owner. Settles the product before flipping the flag\n * @param newClosed new closed value\n */\n function updateClosed(bool newClosed) external onlyProductOwner {\n IOracleProvider.OracleVersion memory oracleVersion = _settle();\n _closed.store(newClosed);\n emit ClosedUpdated(newClosed, oracleVersion.version);\n }\n\n /// @dev Limit total maker for guarded rollouts\n modifier makerInvariant {\n _;\n\n Position memory next = positionAtVersion(latestVersion()).next(_position.pre);\n\n if (next.maker.gt(makerLimit())) revert ProductMakerOverLimitError();\n }\n\n /// @dev Limit maker short exposure to the range 0.0-1.0x of their position. Does not apply when in closeOnly state\n modifier takerInvariant {\n _;\n\n if (closed()) return;\n\n Position memory next = positionAtVersion(latestVersion()).next(_position.pre);\n UFixed18 socializationFactor = next.socializationFactor();\n\n if (socializationFactor.lt(UFixed18Lib.ONE)) revert ProductInsufficientLiquidityError(socializationFactor);\n }\n\n /// @dev Ensure that the user has only taken a maker or taker position, but not both\n modifier positionInvariant {\n _;\n\n if (_positions[msg.sender].isDoubleSided()) revert ProductDoubleSidedError();\n }\n\n /// @dev Ensure that the user hasn't closed more than is open\n modifier closeInvariant {\n _;\n\n if (_positions[msg.sender].isOverClosed()) revert ProductOverClosedError();\n }\n\n /// @dev Ensure that the user will have sufficient margin for maintenance after next settlement\n modifier maintenanceInvariant {\n _;\n\n if (controller().collateral().liquidatableNext(msg.sender, IProduct(this)))\n revert ProductInsufficientCollateralError();\n }\n\n /// @dev Ensure that the user is not currently being liquidated\n modifier liquidationInvariant {\n if (_positions[msg.sender].liquidation) revert ProductInLiquidationError();\n\n _;\n }\n\n /// @dev Helper to fully settle an account's state\n modifier settleForAccount(address account) {\n IOracleProvider.OracleVersion memory _currentVersion = _settle();\n _settleAccount(account, _currentVersion);\n\n _;\n }\n\n /// @dev Ensure we have bootstraped the oracle before creating positions\n modifier nonZeroVersionInvariant {\n if (latestVersion() == 0) revert ProductOracleBootstrappingError();\n\n _;\n }\n\n /// @dev Ensure the product is not closed\n modifier notClosed {\n if (closed()) revert ProductClosedError();\n\n _;\n }\n}\n" - }, - "@equilibria/root/control/unstructured/UInitializable.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"../../storage/UStorage.sol\";\n\n/**\n * @title UInitializable\n * @notice Library to manage the initialization lifecycle of upgradeable contracts\n * @dev `UInitializable` allows the creation of pseudo-constructors for upgradeable contracts. One\n * `initializer` should be declared per top-level contract. Child contracts can use the `onlyInitializer`\n * modifier to tag their internal initialization functions to ensure that they can only be called\n * from a top-level `initializer` or a constructor.\n */\nabstract contract UInitializable {\n error UInitializableZeroVersionError();\n error UInitializableAlreadyInitializedError(uint256 version);\n error UInitializableNotInitializingError();\n\n event Initialized(uint256 version);\n\n /// @dev The initialized flag\n Uint256Storage private constant _version = Uint256Storage.wrap(keccak256(\"equilibria.root.UInitializable.version\"));\n\n /// @dev The initializing flag\n BoolStorage private constant _initializing = BoolStorage.wrap(keccak256(\"equilibria.root.UInitializable.initializing\"));\n\n /// @dev Can only be called once per version, `version` is 1-indexed\n modifier initializer(uint256 version) {\n if (version == 0) revert UInitializableZeroVersionError();\n if (_version.read() >= version) revert UInitializableAlreadyInitializedError(version);\n\n _version.store(version);\n _initializing.store(true);\n\n _;\n\n _initializing.store(false);\n emit Initialized(version);\n }\n\n /// @dev Can only be called from an initializer or constructor\n modifier onlyInitializer() {\n if (!_constructing() && !_initializing.read()) revert UInitializableNotInitializingError();\n _;\n }\n\n /**\n * @notice Returns whether the contract is currently being constructed\n * @dev {Address.isContract} returns false for contracts currently in the process of being constructed\n * @return Whether the contract is currently being constructed\n */\n function _constructing() private view returns (bool) {\n return !Address.isContract(address(this));\n }\n}\n" - }, - "@equilibria/root/control/unstructured/UReentrancyGuard.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"./UInitializable.sol\";\nimport \"../../storage/UStorage.sol\";\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n *\n * NOTE: This contract has been extended from the Open Zeppelin library to include an\n * unstructured storage pattern, so that it can be safely mixed in with upgradeable\n * contracts without affecting their storage patterns through inheritance.\n */\nabstract contract UReentrancyGuard is UInitializable {\n error UReentrancyGuardReentrantCallError();\n\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n /**\n * @dev unstructured storage slot for the reentrancy status\n */\n Uint256Storage private constant _status = Uint256Storage.wrap(keccak256(\"equilibria.root.UReentrancyGuard.status\"));\n\n /**\n * @dev Initializes the contract setting the status to _NOT_ENTERED.\n */\n function __UReentrancyGuard__initialize() internal onlyInitializer {\n _status.store(_NOT_ENTERED);\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and make it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n // On the first call to nonReentrant, _notEntered will be true\n if (_status.read() == _ENTERED) revert UReentrancyGuardReentrantCallError();\n\n // Any calls to nonReentrant after this point will fail\n _status.store(_ENTERED);\n\n _;\n\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status.store(_NOT_ENTERED);\n }\n}\n" - }, - "contracts/controller/UControllerProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/root/control/unstructured/UInitializable.sol\";\nimport \"@equilibria/root/storage/UStorage.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"../interfaces/IController.sol\";\nimport \"../interfaces/IProduct.sol\";\n\n/**\n * @title UControllerProvider\n * @notice Mix-in that manages a controller pointer and associated permissioning modifiers.\n * @dev Uses unstructured storage so that it is safe to mix-in to upgreadable contracts without modifying\n * their storage layout.\n */\nabstract contract UControllerProvider is UInitializable {\n error NotOwnerError(uint256 coordinatorId);\n error NotProductError(IProduct product);\n error NotCollateralError();\n error PausedError();\n error InvalidControllerError();\n\n /// @dev The controller contract address\n AddressStorage private constant _controller = AddressStorage.wrap(keccak256(\"equilibria.perennial.UControllerProvider.controller\"));\n function controller() public view returns (IController) { return IController(_controller.read()); }\n\n /**\n * @notice Initializes the contract state\n * @param controller_ Protocol Controller contract address\n */\n // solhint-disable-next-line func-name-mixedcase\n function __UControllerProvider__initialize(IController controller_) internal onlyInitializer {\n if (!Address.isContract(address(controller_))) revert InvalidControllerError();\n _controller.store(address(controller_));\n }\n\n /// @dev Only allow a valid product contract to call\n modifier onlyProduct {\n if (!controller().isProduct(IProduct(msg.sender))) revert NotProductError(IProduct(msg.sender));\n\n _;\n }\n\n /// @dev Verify that `product` is a valid product contract\n modifier isProduct(IProduct product) {\n if (!controller().isProduct(product)) revert NotProductError(product);\n\n _;\n }\n\n /// @dev Only allow the Collateral contract to call\n modifier onlyCollateral {\n if (msg.sender != address(controller().collateral())) revert NotCollateralError();\n\n _;\n }\n\n /// @dev Only allow the coordinator owner to call\n modifier onlyOwner(uint256 coordinatorId) {\n if (msg.sender != controller().owner(coordinatorId)) revert NotOwnerError(coordinatorId);\n\n _;\n }\n\n /// @dev Only allow if the protocol is currently unpaused\n modifier notPaused() {\n if (controller().paused()) revert PausedError();\n\n _;\n }\n}\n" - }, - "contracts/product/UPayoffProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/control/unstructured/UInitializable.sol\";\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"@equilibria/root/storage/UStorage.sol\";\nimport \"../interfaces/IPayoffProvider.sol\";\nimport \"../interfaces/types/PayoffDefinition.sol\";\n\n/**\n * @title UPayoffProvider\n * @notice Library for manage storing, surfacing, and upgrading a payoff provider.\n * @dev Uses an unstructured storage pattern to store the oracle address and payoff definition which allows this\n provider to be safely used with upgradeable contracts.\n */\nabstract contract UPayoffProvider is IPayoffProvider, UInitializable {\n /// @dev The oracle contract address\n AddressStorage private constant _oracle =\n AddressStorage.wrap(keccak256(\"equilibria.perennial.UPayoffProvider.oracle\"));\n function oracle() public view returns (IOracleProvider) { return IOracleProvider(_oracle.read()); }\n\n /// @dev Payoff definition struct\n PayoffDefinitionStorage private constant _payoffDefinition =\n PayoffDefinitionStorage.wrap(keccak256(\"equilibria.perennial.UPayoffProvider.payoffDefinition\"));\n function payoffDefinition() public view returns (PayoffDefinition memory) { return _payoffDefinition.read(); }\n\n /**\n * @notice Initializes the contract state\n * @param oracle_ Oracle address\n * @param payoffDefinition_ Payoff provider\n */\n // solhint-disable-next-line func-name-mixedcase\n function __UPayoffProvider__initialize(IOracleProvider oracle_, PayoffDefinition calldata payoffDefinition_) internal onlyInitializer {\n if (!Address.isContract(address(oracle_))) revert PayoffProviderInvalidOracle();\n _oracle.store(address(oracle_));\n\n if (!payoffDefinition_.valid()) revert PayoffProviderInvalidPayoffDefinitionError();\n _payoffDefinition.store(payoffDefinition_);\n }\n\n /**\n * @notice Returns the current oracle version transformed by the payoff definition\n * @return Current oracle version transformed by the payoff definition\n */\n function currentVersion() public view returns (IOracleProvider.OracleVersion memory) {\n return _transform(oracle().currentVersion());\n }\n\n /**\n * @notice Returns the oracle version at `oracleVersion` transformed by the payoff definition\n * @param oracleVersion Oracle version to return for\n * @return Oracle version at `oracleVersion` with price transformed by payoff function\n */\n function atVersion(uint256 oracleVersion) public view returns (IOracleProvider.OracleVersion memory) {\n return _transform(oracle().atVersion(oracleVersion));\n }\n\n /**\n * @notice Yook to call sync() on the oracle provider and transform the resulting oracle version\n */\n function _sync() internal returns (IOracleProvider.OracleVersion memory) {\n return _transform(oracle().sync());\n }\n\n /**\n * @notice Returns the transformed oracle version\n * @param oracleVersion Oracle version to transform\n * @return Transformed oracle version\n */\n function _transform(IOracleProvider.OracleVersion memory oracleVersion)\n internal view virtual returns (IOracleProvider.OracleVersion memory) {\n oracleVersion.price = payoffDefinition().transform(oracleVersion.price);\n return oracleVersion;\n }\n}\n" - }, - "contracts/product/UParamProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/control/unstructured/UInitializable.sol\";\nimport \"../controller/UControllerProvider.sol\";\nimport \"../interfaces/IParamProvider.sol\";\nimport \"../interfaces/IProduct.sol\";\n\nabstract contract UParamProvider is IParamProvider, UControllerProvider {\n /**\n * @notice Initializes the contract state\n * @param maintenance_ product maintenance ratio\n * @param fundingFee_ product funding fee\n * @param makerFee_ product maker fee\n * @param takerFee_ product taker fee\n * @param makerLimit_ product maker limit\n * @param utilizationCurve_ utulization curve definition\n */\n // solhint-disable-next-line func-name-mixedcase\n function __UParamProvider__initialize(\n UFixed18 maintenance_,\n UFixed18 fundingFee_,\n UFixed18 makerFee_,\n UFixed18 takerFee_,\n UFixed18 makerLimit_,\n JumpRateUtilizationCurve memory utilizationCurve_\n ) internal onlyInitializer {\n _updateMaintenance(maintenance_);\n _updateFundingFee(fundingFee_);\n _updateMakerFee(makerFee_);\n _updateTakerFee(takerFee_);\n _updateMakerLimit(makerLimit_);\n _updateUtilizationCurve(utilizationCurve_);\n }\n\n /// @dev Only allow the Product's coordinator owner to call\n modifier onlyProductOwner {\n uint256 coordinatorId = controller().coordinatorFor(IProduct(address(this)));\n if (controller().owner(coordinatorId) != msg.sender) revert NotOwnerError(coordinatorId);\n\n _;\n }\n\n /// @dev The maintenance value\n UFixed18Storage private constant _maintenance = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.UParamProvider.maintenance\"));\n function maintenance() public view returns (UFixed18) { return _maintenance.read(); }\n\n /// @dev The funding fee value\n UFixed18Storage private constant _fundingFee = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.UParamProvider.fundingFee\"));\n function fundingFee() public view returns (UFixed18) { return _fundingFee.read(); }\n\n /// @dev The maker fee value\n UFixed18Storage private constant _makerFee = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.UParamProvider.makerFee\"));\n function makerFee() public view returns (UFixed18) { return _makerFee.read(); }\n\n /// @dev The taker fee value\n UFixed18Storage private constant _takerFee = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.UParamProvider.takerFee\"));\n function takerFee() public view returns (UFixed18) { return _takerFee.read(); }\n\n /// @dev The maker limit value\n UFixed18Storage private constant _makerLimit = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.UParamProvider.makerLimit\"));\n function makerLimit() public view returns (UFixed18) { return _makerLimit.read(); }\n\n /// @dev The JumpRateUtilizationCurve params\n JumpRateUtilizationCurveStorage private constant _utilizationCurve =\n JumpRateUtilizationCurveStorage.wrap(keccak256(\"equilibria.perennial.UParamProvider.jumpRateUtilizationCurve\"));\n function utilizationCurve() public view returns (JumpRateUtilizationCurve memory) { return _utilizationCurve.read(); }\n\n /**\n * @notice Updates the maintenance to `newMaintenance`\n * @param newMaintenance new maintenance value\n */\n function _updateMaintenance(UFixed18 newMaintenance) private {\n _maintenance.store(newMaintenance);\n emit MaintenanceUpdated(newMaintenance);\n }\n\n /**\n * @notice Updates the maintenance to `newMaintenance`\n * @dev only callable by product owner\n * @param newMaintenance new maintenance value\n */\n function updateMaintenance(UFixed18 newMaintenance) external onlyProductOwner {\n _updateMaintenance(newMaintenance);\n }\n\n /**\n * @notice Updates the funding fee to `newFundingFee`\n * @param newFundingFee new funding fee value\n */\n function _updateFundingFee(UFixed18 newFundingFee) private {\n if (newFundingFee.gt(UFixed18Lib.ONE)) revert ParamProviderInvalidFundingFee();\n _fundingFee.store(newFundingFee);\n emit FundingFeeUpdated(newFundingFee);\n }\n\n /**\n * @notice Updates the funding fee to `newFundingFee`\n * @dev only callable by product owner\n * @param newFundingFee new funding fee value\n */\n function updateFundingFee(UFixed18 newFundingFee) external onlyProductOwner {\n _updateFundingFee(newFundingFee);\n }\n\n /**\n * @notice Updates the maker fee to `newMakerFee`\n * @param newMakerFee new maker fee value\n */\n function _updateMakerFee(UFixed18 newMakerFee) private {\n if (newMakerFee.gt(UFixed18Lib.ONE)) revert ParamProviderInvalidMakerFee();\n _makerFee.store(newMakerFee);\n emit MakerFeeUpdated(newMakerFee);\n }\n\n /**\n * @notice Updates the maker fee to `newMakerFee`\n * @dev only callable by product owner\n * @param newMakerFee new maker fee value\n */\n function updateMakerFee(UFixed18 newMakerFee) external onlyProductOwner {\n _updateMakerFee(newMakerFee);\n }\n\n /**\n * @notice Updates the taker fee to `newTakerFee`\n * @param newTakerFee new taker fee value\n */\n function _updateTakerFee(UFixed18 newTakerFee) private {\n if (newTakerFee.gt(UFixed18Lib.ONE)) revert ParamProviderInvalidTakerFee();\n _takerFee.store(newTakerFee);\n emit TakerFeeUpdated(newTakerFee);\n }\n\n /**\n * @notice Updates the taker fee to `newTakerFee`\n * @dev only callable by product owner\n * @param newTakerFee new taker fee value\n */\n function updateTakerFee(UFixed18 newTakerFee) external onlyProductOwner {\n _updateTakerFee(newTakerFee);\n }\n\n /**\n * @notice Updates the maker limit to `newMakerLimit`\n * @param newMakerLimit new maker limit value\n */\n function _updateMakerLimit(UFixed18 newMakerLimit) private {\n _makerLimit.store(newMakerLimit);\n emit MakerLimitUpdated(newMakerLimit);\n }\n\n /**\n * @notice Updates the maker limit to `newMakerLimit`\n * @dev only callable by product owner\n * @param newMakerLimit new maker limit value\n */\n function updateMakerLimit(UFixed18 newMakerLimit) external onlyProductOwner {\n _updateMakerLimit(newMakerLimit);\n }\n\n /**\n * @notice Updates the utilization curve to `newUtilizationCurve`\n * @param newUtilizationCurve new utilization curve value\n */\n function _updateUtilizationCurve(JumpRateUtilizationCurve memory newUtilizationCurve) private {\n _utilizationCurve.store(newUtilizationCurve);\n emit JumpRateUtilizationCurveUpdated(\n newUtilizationCurve.minRate.unpack(),\n newUtilizationCurve.maxRate.unpack(),\n newUtilizationCurve.targetRate.unpack(),\n newUtilizationCurve.targetUtilization.unpack()\n );\n }\n\n /**\n * @notice Updates the utilization curve to `newUtilizationCurve`\n * @dev only callable by product owner\n * @param newUtilizationCurve new utilization curve value\n */\n function updateUtilizationCurve(JumpRateUtilizationCurve calldata newUtilizationCurve) external onlyProductOwner {\n _updateUtilizationCurve(newUtilizationCurve);\n }\n}\n" - }, - "contracts/product/types/position/AccountPosition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../../../interfaces/IProduct.sol\";\nimport \"../../../interfaces/types/PrePosition.sol\";\n\n/// @dev AccountPosition type\nstruct AccountPosition {\n /// @dev The current settled position of the account\n Position position;\n\n /// @dev The current position delta pending-settlement\n PrePosition pre;\n\n /// @dev Whether the account is currently locked for liquidation\n bool liquidation;\n}\nusing AccountPositionLib for AccountPosition global;\n\n/**\n * @title AccountPositionLib\n * @notice Library that manages an account-level position.\n */\nlibrary AccountPositionLib {\n /**\n * @notice Settled the account's position to oracle version `toOracleVersion`\n * @param self The struct to operate on\n * @param toOracleVersion The oracle version to accumulate to\n * @return positionFee The fee accrued from opening or closing a new position\n */\n function settle(\n AccountPosition storage self,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal returns (UFixed18 positionFee) {\n bool settled;\n (self.position, positionFee, settled) = self.position.settled(self.pre, toOracleVersion);\n if (settled) {\n delete self.pre;\n self.liquidation = false;\n }\n }\n\n /**\n * @notice Returns the current maintenance requirement for the account\n * @dev Must be called from a valid product to get the proper maintenance value\n * @param self The struct to operate on\n * @return Current maintenance requirement for the account\n */\n function maintenance(AccountPosition storage self) internal view returns (UFixed18) {\n if (self.liquidation) return UFixed18Lib.ZERO;\n return _maintenance(self.position);\n }\n\n /**\n * @notice Returns the maintenance requirement after the next oracle version settlement\n * @dev Includes the current pending-settlement position delta, assumes no price change\n * @param self The struct to operate on\n * @return Next maintenance requirement for the account\n */\n function maintenanceNext(AccountPosition storage self) internal view returns (UFixed18) {\n return _maintenance(self.position.next(self.pre));\n }\n\n /**\n * @notice Returns the maintenance requirement for a given `position`\n * @dev Internal helper\n * @param position The position to compete the maintenance requirement for\n * @return Next maintenance requirement for the account\n */\n function _maintenance(Position memory position) private view returns (UFixed18) {\n IProduct product = IProduct(address(this));\n Fixed18 oraclePrice = product.currentVersion().price;\n UFixed18 notionalMax = Fixed18Lib.from(position.max()).mul(oraclePrice).abs();\n return notionalMax.mul(product.maintenance());\n }\n\n /**\n * @notice Returns whether an account is completely closed, i.e. no position or pre-position\n * @param self The struct to operate on\n * @return Whether the account is closed\n */\n function isClosed(AccountPosition memory self) internal pure returns (bool) {\n return self.pre.isEmpty() && self.position.isEmpty();\n }\n\n /**\n * @notice Returns whether an account has opened position on both sides of the market (maker vs taker)\n * @dev Used to verify the invariant that a single account can only have a position on one side of the\n * market at a time\n * @param self The struct to operate on\n * @return Whether the account is currently doubled sided\n */\n function isDoubleSided(AccountPosition storage self) internal view returns (bool) {\n bool makerEmpty = self.position.maker.isZero() && self.pre.openPosition.maker.isZero() && self.pre.closePosition.maker.isZero();\n bool takerEmpty = self.position.taker.isZero() && self.pre.openPosition.taker.isZero() && self.pre.closePosition.taker.isZero();\n\n return !makerEmpty && !takerEmpty;\n }\n\n /**\n * @notice Returns whether the account's pending-settlement delta closes more position than is open\n * @dev Used to verify the invariant that an account cannot settle into having a negative position\n * @param self The struct to operate on\n * @return Whether the account is currently over closed\n */\n function isOverClosed(AccountPosition storage self) internal view returns (bool) {\n Position memory nextOpen = self.position.add(self.pre.openPosition);\n\n return self.pre.closePosition.maker.gt(nextOpen.maker) || self.pre.closePosition.taker.gt(nextOpen.taker);\n }\n}\n" - }, - "contracts/product/types/accumulator/AccountAccumulator.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../../../interfaces/types/Accumulator.sol\";\nimport \"../position/AccountPosition.sol\";\nimport \"./VersionedAccumulator.sol\";\n\n/// @dev AccountAccumulator type\nstruct AccountAccumulator {\n /// @dev latest version that the account was synced too\n uint256 latestVersion;\n}\nusing AccountAccumulatorLib for AccountAccumulator global;\n\n/**\n * @title AccountAccumulatorLib\n * @notice Library that manages syncing an account-level accumulator.\n */\nlibrary AccountAccumulatorLib {\n /**\n * @notice Syncs the account to oracle version `versionTo`\n * @param self The struct to operate on\n * @param global Pointer to global accumulator\n * @param position Pointer to global position\n * @param versionTo Oracle version to sync account to\n * @return value The value accumulated sync last sync\n */\n function syncTo(\n AccountAccumulator storage self,\n VersionedAccumulator storage global,\n AccountPosition storage position,\n uint256 versionTo\n ) internal returns (Accumulator memory value) {\n Accumulator memory valueAccumulated = global.valueAtVersion(versionTo)\n .sub(global.valueAtVersion(self.latestVersion));\n value = position.position.mul(valueAccumulated);\n self.latestVersion = versionTo;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Address.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // 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\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" - }, - "@equilibria/root/storage/UStorage.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"../number/types/UFixed18.sol\";\n\n/// @dev Stored boolean slot\ntype BoolStorage is bytes32;\nusing BoolStorageLib for BoolStorage global;\n\n/// @dev Stored uint256 slot\ntype Uint256Storage is bytes32;\nusing Uint256StorageLib for Uint256Storage global;\n\n/// @dev Stored int256 slot\ntype Int256Storage is bytes32;\nusing Int256StorageLib for Int256Storage global;\n\n/// @dev Stored address slot\ntype AddressStorage is bytes32;\nusing AddressStorageLib for AddressStorage global;\n\n/// @dev Stored bytes32 slot\ntype Bytes32Storage is bytes32;\nusing Bytes32StorageLib for Bytes32Storage global;\n\n/**\n * @title BoolStorageLib\n * @notice Library to manage storage and retrival of a boolean at a fixed storage slot\n */\nlibrary BoolStorageLib {\n /**\n * @notice Retrieves the stored value\n * @param self Storage slot\n * @return value Stored bool value\n */\n function read(BoolStorage self) internal view returns (bool value) {\n assembly {\n value := sload(self)\n }\n }\n\n /**\n * @notice Stores the value at the specific slot\n * @param self Storage slot\n * @param value boolean value to store\n */\n function store(BoolStorage self, bool value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n\n/**\n * @title Uint256StorageLib\n * @notice Library to manage storage and retrival of an uint256 at a fixed storage slot\n */\nlibrary Uint256StorageLib {\n /**\n * @notice Retrieves the stored value\n * @param self Storage slot\n * @return value Stored uint256 value\n */\n function read(Uint256Storage self) internal view returns (uint256 value) {\n assembly {\n value := sload(self)\n }\n }\n\n /**\n * @notice Stores the value at the specific slot\n * @param self Storage slot\n * @param value uint256 value to store\n */\n function store(Uint256Storage self, uint256 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n\n/**\n * @title Int256StorageLib\n * @notice Library to manage storage and retrival of an int256 at a fixed storage slot\n */\nlibrary Int256StorageLib {\n /**\n * @notice Retrieves the stored value\n * @param self Storage slot\n * @return value Stored int256 value\n */\n function read(Int256Storage self) internal view returns (int256 value) {\n assembly {\n value := sload(self)\n }\n }\n\n /**\n * @notice Stores the value at the specific slot\n * @param self Storage slot\n * @param value int256 value to store\n */\n function store(Int256Storage self, int256 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n\n/**\n * @title AddressStorageLib\n * @notice Library to manage storage and retrival of an address at a fixed storage slot\n */\nlibrary AddressStorageLib {\n /**\n * @notice Retrieves the stored value\n * @param self Storage slot\n * @return value Stored address value\n */\n function read(AddressStorage self) internal view returns (address value) {\n assembly {\n value := sload(self)\n }\n }\n\n /**\n * @notice Stores the value at the specific slot\n * @param self Storage slot\n * @param value address value to store\n */\n function store(AddressStorage self, address value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n\n/**\n * @title Bytes32StorageLib\n * @notice Library to manage storage and retrival of a bytes32 at a fixed storage slot\n */\nlibrary Bytes32StorageLib {\n /**\n * @notice Retrieves the stored value\n * @param self Storage slot\n * @return value Stored bytes32 value\n */\n function read(Bytes32Storage self) internal view returns (bytes32 value) {\n assembly {\n value := sload(self)\n }\n }\n\n /**\n * @notice Stores the value at the specific slot\n * @param self Storage slot\n * @param value bytes32 value to store\n */\n function store(Bytes32Storage self, bytes32 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "@equilibria/root/number/types/UFixed18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"./Fixed18.sol\";\nimport \"./PackedUFixed18.sol\";\n\n/// @dev UFixed18 type\ntype UFixed18 is uint256;\nusing UFixed18Lib for UFixed18 global;\ntype UFixed18Storage is bytes32;\nusing UFixed18StorageLib for UFixed18Storage global;\n\n/**\n * @title UFixed18Lib\n * @notice Library for the unsigned fixed-decimal type.\n */\nlibrary UFixed18Lib {\n error UFixed18UnderflowError(int256 value);\n error UFixed18PackingOverflowError(uint256 value);\n\n uint256 private constant BASE = 1e18;\n UFixed18 public constant ZERO = UFixed18.wrap(0);\n UFixed18 public constant ONE = UFixed18.wrap(BASE);\n UFixed18 public constant MAX = UFixed18.wrap(type(uint256).max);\n\n /**\n * @notice Creates a unsigned fixed-decimal from a signed fixed-decimal\n * @param a Signed fixed-decimal\n * @return New unsigned fixed-decimal\n */\n function from(Fixed18 a) internal pure returns (UFixed18) {\n int256 value = Fixed18.unwrap(a);\n if (value < 0) revert UFixed18UnderflowError(value);\n return UFixed18.wrap(uint256(value));\n }\n\n /**\n * @notice Creates a unsigned fixed-decimal from a unsigned integer\n * @param a Unsigned number\n * @return New unsigned fixed-decimal\n */\n function from(uint256 a) internal pure returns (UFixed18) {\n return UFixed18.wrap(a * BASE);\n }\n\n /**\n * @notice Creates a packed unsigned fixed-decimal from an unsigned fixed-decimal\n * @param a unsigned fixed-decimal\n * @return New packed unsigned fixed-decimal\n */\n function pack(UFixed18 a) internal pure returns (PackedUFixed18) {\n uint256 value = UFixed18.unwrap(a);\n if (value > type(uint128).max) revert UFixed18PackingOverflowError(value);\n return PackedUFixed18.wrap(uint128(value));\n }\n\n /**\n * @notice Returns whether the unsigned fixed-decimal is equal to zero.\n * @param a Unsigned fixed-decimal\n * @return Whether the unsigned fixed-decimal is zero.\n */\n function isZero(UFixed18 a) internal pure returns (bool) {\n return UFixed18.unwrap(a) == 0;\n }\n\n /**\n * @notice Adds two unsigned fixed-decimals `a` and `b` together\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Resulting summed unsigned fixed-decimal\n */\n function add(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) + UFixed18.unwrap(b));\n }\n\n /**\n * @notice Subtracts unsigned fixed-decimal `b` from `a`\n * @param a Unsigned fixed-decimal to subtract from\n * @param b Unsigned fixed-decimal to subtract\n * @return Resulting subtracted unsigned fixed-decimal\n */\n function sub(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) - UFixed18.unwrap(b));\n }\n\n /**\n * @notice Multiplies two unsigned fixed-decimals `a` and `b` together\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Resulting multiplied unsigned fixed-decimal\n */\n function mul(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / BASE);\n }\n\n /**\n * @notice Divides unsigned fixed-decimal `a` by `b`\n * @param a Unsigned fixed-decimal to divide\n * @param b Unsigned fixed-decimal to divide by\n * @return Resulting divided unsigned fixed-decimal\n */\n function div(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) * BASE / UFixed18.unwrap(b));\n }\n\n /**\n * @notice Divides unsigned fixed-decimal `a` by `b`\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0` and `MAX` for `n/0`.\n * @param a Unsigned fixed-decimal to divide\n * @param b Unsigned fixed-decimal to divide by\n * @return Resulting divided unsigned fixed-decimal\n */\n function unsafeDiv(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n if (isZero(b)) {\n return isZero(a) ? ONE : MAX;\n } else {\n return div(a, b);\n }\n }\n\n /**\n * @notice Computes a * b / c without loss of precision due to BASE conversion\n * @param a First unsigned fixed-decimal\n * @param b Unsigned number to multiply by\n * @param c Unsigned number to divide by\n * @return Resulting computation\n */\n function muldiv(UFixed18 a, uint256 b, uint256 c) internal pure returns (UFixed18) {\n return muldiv(a, UFixed18.wrap(b), UFixed18.wrap(c));\n }\n\n /**\n * @notice Computes a * b / c without loss of precision due to BASE conversion\n * @param a First unsigned fixed-decimal\n * @param b Unsigned fixed-decimal to multiply by\n * @param c Unsigned fixed-decimal to divide by\n * @return Resulting computation\n */\n function muldiv(UFixed18 a, UFixed18 b, UFixed18 c) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / UFixed18.unwrap(c));\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is equal to `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is equal to `b`\n */\n function eq(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return compare(a, b) == 1;\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is greater than `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is greater than `b`\n */\n function gt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return compare(a, b) == 2;\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is less than `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is less than `b`\n */\n function lt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return compare(a, b) == 0;\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is greater than or equal to `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is greater than or equal to `b`\n */\n function gte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return gt(a, b) || eq(a, b);\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is less than or equal to `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is less than or equal to `b`\n */\n function lte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return lt(a, b) || eq(a, b);\n }\n\n /**\n * @notice Compares the unsigned fixed-decimals `a` and `b`\n * @dev Returns: 2 for greater than\n * 1 for equal to\n * 0 for less than\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Compare result of `a` and `b`\n */\n function compare(UFixed18 a, UFixed18 b) internal pure returns (uint256) {\n (uint256 au, uint256 bu) = (UFixed18.unwrap(a), UFixed18.unwrap(b));\n if (au > bu) return 2;\n if (au < bu) return 0;\n return 1;\n }\n\n /**\n * @notice Returns a unsigned fixed-decimal representing the ratio of `a` over `b`\n * @param a First unsigned number\n * @param b Second unsigned number\n * @return Ratio of `a` over `b`\n */\n function ratio(uint256 a, uint256 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(a * BASE / b);\n }\n\n /**\n * @notice Returns the minimum of unsigned fixed-decimals `a` and `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Minimum of `a` and `b`\n */\n function min(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(Math.min(UFixed18.unwrap(a), UFixed18.unwrap(b)));\n }\n\n /**\n * @notice Returns the maximum of unsigned fixed-decimals `a` and `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Maximum of `a` and `b`\n */\n function max(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(Math.max(UFixed18.unwrap(a), UFixed18.unwrap(b)));\n }\n\n /**\n * @notice Converts the unsigned fixed-decimal into an integer, truncating any decimal portion\n * @param a Unsigned fixed-decimal\n * @return Truncated unsigned number\n */\n function truncate(UFixed18 a) internal pure returns (uint256) {\n return UFixed18.unwrap(a) / BASE;\n }\n}\n\nlibrary UFixed18StorageLib {\n function read(UFixed18Storage self) internal view returns (UFixed18 value) {\n assembly {\n value := sload(self)\n }\n }\n\n function store(UFixed18Storage self, UFixed18 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return 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 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 up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a / b + (a % b == 0 ? 0 : 1);\n }\n}\n" - }, - "@equilibria/root/number/types/Fixed18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/SignedMath.sol\";\nimport \"./UFixed18.sol\";\nimport \"./PackedFixed18.sol\";\n\n/// @dev Fixed18 type\ntype Fixed18 is int256;\nusing Fixed18Lib for Fixed18 global;\ntype Fixed18Storage is bytes32;\nusing Fixed18StorageLib for Fixed18Storage global;\n\n/**\n * @title Fixed18Lib\n * @notice Library for the signed fixed-decimal type.\n */\nlibrary Fixed18Lib {\n error Fixed18OverflowError(uint256 value);\n error Fixed18PackingOverflowError(int256 value);\n error Fixed18PackingUnderflowError(int256 value);\n\n int256 private constant BASE = 1e18;\n Fixed18 public constant ZERO = Fixed18.wrap(0);\n Fixed18 public constant ONE = Fixed18.wrap(BASE);\n Fixed18 public constant NEG_ONE = Fixed18.wrap(-1 * BASE);\n Fixed18 public constant MAX = Fixed18.wrap(type(int256).max);\n Fixed18 public constant MIN = Fixed18.wrap(type(int256).min);\n\n /**\n * @notice Creates a signed fixed-decimal from an unsigned fixed-decimal\n * @param a Unsigned fixed-decimal\n * @return New signed fixed-decimal\n */\n function from(UFixed18 a) internal pure returns (Fixed18) {\n uint256 value = UFixed18.unwrap(a);\n if (value > uint256(type(int256).max)) revert Fixed18OverflowError(value);\n return Fixed18.wrap(int256(value));\n }\n\n /**\n * @notice Creates a signed fixed-decimal from a sign and an unsigned fixed-decimal\n * @param s Sign\n * @param m Unsigned fixed-decimal magnitude\n * @return New signed fixed-decimal\n */\n function from(int256 s, UFixed18 m) internal pure returns (Fixed18) {\n if (s > 0) return from(m);\n if (s < 0) return Fixed18.wrap(-1 * Fixed18.unwrap(from(m)));\n return ZERO;\n }\n\n /**\n * @notice Creates a signed fixed-decimal from a signed integer\n * @param a Signed number\n * @return New signed fixed-decimal\n */\n function from(int256 a) internal pure returns (Fixed18) {\n return Fixed18.wrap(a * BASE);\n }\n\n /**\n * @notice Creates a packed signed fixed-decimal from an signed fixed-decimal\n * @param a signed fixed-decimal\n * @return New packed signed fixed-decimal\n */\n function pack(Fixed18 a) internal pure returns (PackedFixed18) {\n int256 value = Fixed18.unwrap(a);\n if (value > type(int128).max) revert Fixed18PackingOverflowError(value);\n if (value < type(int128).min) revert Fixed18PackingUnderflowError(value);\n return PackedFixed18.wrap(int128(value));\n }\n\n /**\n * @notice Returns whether the signed fixed-decimal is equal to zero.\n * @param a Signed fixed-decimal\n * @return Whether the signed fixed-decimal is zero.\n */\n function isZero(Fixed18 a) internal pure returns (bool) {\n return Fixed18.unwrap(a) == 0;\n }\n\n /**\n * @notice Adds two signed fixed-decimals `a` and `b` together\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Resulting summed signed fixed-decimal\n */\n function add(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) + Fixed18.unwrap(b));\n }\n\n /**\n * @notice Subtracts signed fixed-decimal `b` from `a`\n * @param a Signed fixed-decimal to subtract from\n * @param b Signed fixed-decimal to subtract\n * @return Resulting subtracted signed fixed-decimal\n */\n function sub(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) - Fixed18.unwrap(b));\n }\n\n /**\n * @notice Multiplies two signed fixed-decimals `a` and `b` together\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Resulting multiplied signed fixed-decimal\n */\n function mul(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / BASE);\n }\n\n /**\n * @notice Divides signed fixed-decimal `a` by `b`\n * @param a Signed fixed-decimal to divide\n * @param b Signed fixed-decimal to divide by\n * @return Resulting divided signed fixed-decimal\n */\n function div(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) * BASE / Fixed18.unwrap(b));\n }\n\n /**\n * @notice Divides unsigned fixed-decimal `a` by `b`\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0`, `MAX` for `n/0`, and `MIN` for `-n/0`.\n * @param a Unsigned fixed-decimal to divide\n * @param b Unsigned fixed-decimal to divide by\n * @return Resulting divided unsigned fixed-decimal\n */\n function unsafeDiv(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n if (isZero(b)) {\n if (gt(a, ZERO)) return MAX;\n if (lt(a, ZERO)) return MIN;\n return ONE;\n } else {\n return div(a, b);\n }\n }\n\n /**\n * @notice Computes a * b / c without loss of precision due to BASE conversion\n * @param a First signed fixed-decimal\n * @param b Signed number to multiply by\n * @param c Signed number to divide by\n * @return Resulting computation\n */\n function muldiv(Fixed18 a, int256 b, int256 c) internal pure returns (Fixed18) {\n return muldiv(a, Fixed18.wrap(b), Fixed18.wrap(c));\n }\n\n /**\n * @notice Computes a * b / c without loss of precision due to BASE conversion\n * @param a First signed fixed-decimal\n * @param b Signed fixed-decimal to multiply by\n * @param c Signed fixed-decimal to divide by\n * @return Resulting computation\n */\n function muldiv(Fixed18 a, Fixed18 b, Fixed18 c) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / Fixed18.unwrap(c));\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is equal to `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is equal to `b`\n */\n function eq(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return compare(a, b) == 1;\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is greater than `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is greater than `b`\n */\n function gt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return compare(a, b) == 2;\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is less than `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is less than `b`\n */\n function lt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return compare(a, b) == 0;\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is greater than or equal to `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is greater than or equal to `b`\n */\n function gte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return gt(a, b) || eq(a, b);\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is less than or equal to `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is less than or equal to `b`\n */\n function lte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return lt(a, b) || eq(a, b);\n }\n\n /**\n * @notice Compares the signed fixed-decimals `a` and `b`\n * @dev Returns: 2 for greater than\n * 1 for equal to\n * 0 for less than\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Compare result of `a` and `b`\n */\n function compare(Fixed18 a, Fixed18 b) internal pure returns (uint256) {\n (int256 au, int256 bu) = (Fixed18.unwrap(a), Fixed18.unwrap(b));\n if (au > bu) return 2;\n if (au < bu) return 0;\n return 1;\n }\n\n /**\n * @notice Returns a signed fixed-decimal representing the ratio of `a` over `b`\n * @param a First signed number\n * @param b Second signed number\n * @return Ratio of `a` over `b`\n */\n function ratio(int256 a, int256 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(a * BASE / b);\n }\n\n /**\n * @notice Returns the minimum of signed fixed-decimals `a` and `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Minimum of `a` and `b`\n */\n function min(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(SignedMath.min(Fixed18.unwrap(a), Fixed18.unwrap(b)));\n }\n\n /**\n * @notice Returns the maximum of signed fixed-decimals `a` and `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Maximum of `a` and `b`\n */\n function max(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(SignedMath.max(Fixed18.unwrap(a), Fixed18.unwrap(b)));\n }\n\n /**\n * @notice Converts the signed fixed-decimal into an integer, truncating any decimal portion\n * @param a Signed fixed-decimal\n * @return Truncated signed number\n */\n function truncate(Fixed18 a) internal pure returns (int256) {\n return Fixed18.unwrap(a) / BASE;\n }\n\n /**\n * @notice Returns the sign of the signed fixed-decimal\n * @dev Returns: -1 for negative\n * 0 for zero\n * 1 for positive\n * @param a Signed fixed-decimal\n * @return Sign of the signed fixed-decimal\n */\n function sign(Fixed18 a) internal pure returns (int256) {\n if (Fixed18.unwrap(a) > 0) return 1;\n if (Fixed18.unwrap(a) < 0) return -1;\n return 0;\n }\n\n /**\n * @notice Returns the absolute value of the signed fixed-decimal\n * @param a Signed fixed-decimal\n * @return Absolute value of the signed fixed-decimal\n */\n function abs(Fixed18 a) internal pure returns (UFixed18) {\n return UFixed18.wrap(SignedMath.abs(Fixed18.unwrap(a)));\n }\n}\n\nlibrary Fixed18StorageLib {\n function read(Fixed18Storage self) internal view returns (Fixed18 value) {\n assembly {\n value := sload(self)\n }\n }\n\n function store(Fixed18Storage self, Fixed18 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "@equilibria/root/number/types/PackedUFixed18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"./UFixed18.sol\";\n\n/// @dev PackedUFixed18 type\ntype PackedUFixed18 is uint128;\nusing PackedUFixed18Lib for PackedUFixed18 global;\n\n/**\n * @title PackedUFixed18Lib\n * @dev A packed version of the UFixed18 which takes up half the storage space (two PackedUFixed18 can be packed\n * into a single slot). Only valid within the range 0 <= x <= 3.4028237e+20.\n * @notice Library for the packed unsigned fixed-decimal type.\n */\nlibrary PackedUFixed18Lib {\n PackedUFixed18 public constant MAX = PackedUFixed18.wrap(type(uint128).max);\n\n /**\n * @notice Creates an unpacked unsigned fixed-decimal from a packed unsigned fixed-decimal\n * @param self packed unsigned fixed-decimal\n * @return New unpacked unsigned fixed-decimal\n */\n function unpack(PackedUFixed18 self) internal pure returns (UFixed18) {\n return UFixed18.wrap(uint256(PackedUFixed18.unwrap(self)));\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/SignedMath.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n /**\n * @dev Returns the largest of two signed numbers.\n */\n function max(int256 a, int256 b) internal pure returns (int256) {\n return 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 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 // must be unchecked in order to support `n = type(int256).min`\n return uint256(n >= 0 ? n : -n);\n }\n }\n}\n" - }, - "@equilibria/root/number/types/PackedFixed18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"./Fixed18.sol\";\n\n/// @dev PackedFixed18 type\ntype PackedFixed18 is int128;\nusing PackedFixed18Lib for PackedFixed18 global;\n\n/**\n * @title PackedFixed18Lib\n * @dev A packed version of the Fixed18 which takes up half the storage space (two PackedFixed18 can be packed\n * into a single slot). Only valid within the range -1.7014118e+20 <= x <= 1.7014118e+20.\n * @notice Library for the packed signed fixed-decimal type.\n */\nlibrary PackedFixed18Lib {\n PackedFixed18 public constant MAX = PackedFixed18.wrap(type(int128).max);\n PackedFixed18 public constant MIN = PackedFixed18.wrap(type(int128).min);\n\n /**\n * @notice Creates an unpacked signed fixed-decimal from a packed signed fixed-decimal\n * @param self packed signed fixed-decimal\n * @return New unpacked signed fixed-decimal\n */\n function unpack(PackedFixed18 self) internal pure returns (Fixed18) {\n return Fixed18.wrap(int256(PackedFixed18.unwrap(self)));\n }\n}\n" - }, - "contracts/interfaces/IController.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\";\nimport \"./ICollateral.sol\";\nimport \"./IIncentivizer.sol\";\nimport \"./IProduct.sol\";\nimport \"./types/PayoffDefinition.sol\";\n\ninterface IController {\n /// @dev Coordinator of a one or many products\n struct Coordinator {\n /// @dev Pending owner of the product, can accept ownership\n address pendingOwner;\n\n /// @dev Owner of the product, allowed to update select parameters\n address owner;\n\n /// @dev Treasury of the product, collects fees\n address treasury;\n }\n\n event CollateralUpdated(ICollateral newCollateral);\n event IncentivizerUpdated(IIncentivizer newIncentivizer);\n event ProductBeaconUpdated(IBeacon newProductBeacon);\n event ProtocolFeeUpdated(UFixed18 newProtocolFee);\n event MinFundingFeeUpdated(UFixed18 newMinFundingFee);\n event LiquidationFeeUpdated(UFixed18 newLiquidationFee);\n event IncentivizationFeeUpdated(UFixed18 newIncentivizationFee);\n event MinCollateralUpdated(UFixed18 newMinCollateral);\n event ProgramsPerProductUpdated(uint256 newProgramsPerProduct);\n event PauserUpdated(address newPauser);\n event PausedUpdated(bool newPaused);\n event CoordinatorPendingOwnerUpdated(uint256 indexed coordinatorId, address newPendingOwner);\n event CoordinatorOwnerUpdated(uint256 indexed coordinatorId, address newOwner);\n event CoordinatorTreasuryUpdated(uint256 indexed coordinatorId, address newTreasury);\n event CoordinatorCreated(uint256 indexed coordinatorId, address owner);\n event ProductCreated(IProduct indexed product, IProduct.ProductInfo productInfo);\n\n error ControllerNoZeroCoordinatorError();\n error ControllerNotPauserError();\n error ControllerNotOwnerError(uint256 controllerId);\n error ControllerNotPendingOwnerError(uint256 controllerId);\n error ControllerInvalidProtocolFeeError();\n error ControllerInvalidMinFundingFeeError();\n error ControllerInvalidLiquidationFeeError();\n error ControllerInvalidIncentivizationFeeError();\n error ControllerNotContractAddressError();\n\n function collateral() external view returns (ICollateral);\n function incentivizer() external view returns (IIncentivizer);\n function productBeacon() external view returns (IBeacon);\n function coordinators(uint256 collateralId) external view returns (Coordinator memory);\n function coordinatorFor(IProduct product) external view returns (uint256);\n function protocolFee() external view returns (UFixed18);\n function minFundingFee() external view returns (UFixed18);\n function liquidationFee() external view returns (UFixed18);\n function incentivizationFee() external view returns (UFixed18);\n function minCollateral() external view returns (UFixed18);\n function programsPerProduct() external view returns (uint256);\n function pauser() external view returns (address);\n function paused() external view returns (bool);\n function initialize(ICollateral collateral_, IIncentivizer incentivizer_, IBeacon productBeacon_) external;\n function createCoordinator() external returns (uint256);\n function updateCoordinatorPendingOwner(uint256 coordinatorId, address newPendingOwner) external;\n function acceptCoordinatorOwner(uint256 coordinatorId) external;\n function updateCoordinatorTreasury(uint256 coordinatorId, address newTreasury) external;\n function createProduct(uint256 coordinatorId, IProduct.ProductInfo calldata productInfo) external returns (IProduct);\n function updateCollateral(ICollateral newCollateral) external;\n function updateIncentivizer(IIncentivizer newIncentivizer) external;\n function updateProductBeacon(IBeacon newProductBeacon) external;\n function updateProtocolFee(UFixed18 newProtocolFee) external;\n function updateMinFundingFee(UFixed18 newMinFundingFee) external;\n function updateLiquidationFee(UFixed18 newLiquidationFee) external;\n function updateIncentivizationFee(UFixed18 newIncentivizationFee) external;\n function updateMinCollateral(UFixed18 newMinCollateral) external;\n function updateProgramsPerProduct(uint256 newProductsPerProduct) external;\n function updatePauser(address newPauser) external;\n function updatePaused(bool newPaused) external;\n function isProduct(IProduct product) external view returns (bool);\n function owner() external view returns (address);\n function owner(uint256 coordinatorId) external view returns (address);\n function owner(IProduct product) external view returns (address);\n function treasury() external view returns (address);\n function treasury(uint256 coordinatorId) external view returns (address);\n function treasury(IProduct product) external view returns (address);\n}\n" - }, - "contracts/interfaces/IProduct.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\";\nimport \"./IPayoffProvider.sol\";\nimport \"./IParamProvider.sol\";\nimport \"./types/PayoffDefinition.sol\";\nimport \"./types/Position.sol\";\nimport \"./types/PrePosition.sol\";\nimport \"./types/Accumulator.sol\";\n\ninterface IProduct is IPayoffProvider, IParamProvider {\n /// @dev Product Creation parameters\n struct ProductInfo {\n /// @dev name of the product\n string name;\n\n /// @dev symbol of the product\n string symbol;\n\n /// @dev product payoff definition\n PayoffDefinition payoffDefinition;\n\n /// @dev oracle address\n IOracleProvider oracle;\n\n /// @dev product maintenance ratio\n UFixed18 maintenance;\n\n /// @dev product funding fee\n UFixed18 fundingFee;\n\n /// @dev product maker fee\n UFixed18 makerFee;\n\n /// @dev product taker fee\n UFixed18 takerFee;\n\n /// @dev product maker limit\n UFixed18 makerLimit;\n\n /// @dev utulization curve definition\n JumpRateUtilizationCurve utilizationCurve;\n }\n\n event Settle(uint256 preVersion, uint256 toVersion);\n event AccountSettle(address indexed account, uint256 preVersion, uint256 toVersion);\n event MakeOpened(address indexed account, uint256 version, UFixed18 amount);\n event TakeOpened(address indexed account, uint256 version, UFixed18 amount);\n event MakeClosed(address indexed account, uint256 version, UFixed18 amount);\n event TakeClosed(address indexed account, uint256 version, UFixed18 amount);\n event ClosedUpdated(bool indexed newClosed, uint256 version);\n\n error ProductInsufficientLiquidityError(UFixed18 socializationFactor);\n error ProductDoubleSidedError();\n error ProductOverClosedError();\n error ProductInsufficientCollateralError();\n error ProductInLiquidationError();\n error ProductMakerOverLimitError();\n error ProductOracleBootstrappingError();\n error ProductNotOwnerError();\n error ProductInvalidOracle();\n error ProductClosedError();\n\n function name() external view returns (string memory);\n function symbol() external view returns (string memory);\n function initialize(ProductInfo calldata productInfo_) external;\n function settle() external;\n function settleAccount(address account) external;\n function openTake(UFixed18 amount) external;\n function closeTake(UFixed18 amount) external;\n function openMake(UFixed18 amount) external;\n function closeMake(UFixed18 amount) external;\n function closeAll(address account) external;\n function maintenance(address account) external view returns (UFixed18);\n function maintenanceNext(address account) external view returns (UFixed18);\n function isClosed(address account) external view returns (bool);\n function isLiquidating(address account) external view returns (bool);\n function position(address account) external view returns (Position memory);\n function pre(address account) external view returns (PrePosition memory);\n function latestVersion() external view returns (uint256);\n function positionAtVersion(uint256 oracleVersion) external view returns (Position memory);\n function pre() external view returns (PrePosition memory);\n function valueAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\n function shareAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\n function latestVersion(address account) external view returns (uint256);\n function rate(Position memory position) external view returns (Fixed18);\n function closed() external view returns (bool);\n function updateClosed(bool newClosed) external;\n}\n" - }, - "@openzeppelin/contracts/proxy/beacon/IBeacon.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n" - }, - "contracts/interfaces/ICollateral.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/root/number/types/Fixed18.sol\";\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"./IController.sol\";\nimport \"./IProduct.sol\";\n\ninterface ICollateral {\n event Deposit(address indexed user, IProduct indexed product, UFixed18 amount);\n event Withdrawal(address indexed user, IProduct indexed product, UFixed18 amount);\n event AccountSettle(IProduct indexed product, address indexed account, Fixed18 amount, UFixed18 newShortfall);\n event ProductSettle(IProduct indexed product, UFixed18 protocolFee, UFixed18 productFee);\n event Liquidation(address indexed user, IProduct indexed product, address liquidator, UFixed18 fee);\n event ShortfallResolution(IProduct indexed product, UFixed18 amount);\n event FeeClaim(address indexed account, UFixed18 amount);\n\n error CollateralCantLiquidate(UFixed18 totalMaintenance, UFixed18 totalCollateral);\n error CollateralInsufficientCollateralError();\n error CollateralUnderLimitError();\n error CollateralZeroAddressError();\n\n function token() external view returns (Token18);\n function fees(address account) external view returns (UFixed18);\n function initialize(IController controller_) external;\n function depositTo(address account, IProduct product, UFixed18 amount) external;\n function withdrawTo(address account, IProduct product, UFixed18 amount) external;\n function liquidate(address account, IProduct product) external;\n function settleAccount(address account, Fixed18 amount) external;\n function settleProduct(UFixed18 amount) external;\n function collateral(address account, IProduct product) external view returns (UFixed18);\n function collateral(IProduct product) external view returns (UFixed18);\n function shortfall(IProduct product) external view returns (UFixed18);\n function liquidatable(address account, IProduct product) external view returns (bool);\n function liquidatableNext(address account, IProduct product) external view returns (bool);\n function resolveShortfall(IProduct product, UFixed18 amount) external;\n function claimFee() external;\n}\n" - }, - "contracts/interfaces/IIncentivizer.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"./types/ProgramInfo.sol\";\nimport \"./IController.sol\";\nimport \"./IProduct.sol\";\n\ninterface IIncentivizer {\n event ProgramCreated(IProduct indexed product, uint256 indexed programId, ProgramInfo programInfo, UFixed18 programFeeAmount);\n event ProgramStarted(IProduct indexed product, uint256 indexed programId, uint256 version);\n event ProgramComplete(IProduct indexed product, uint256 indexed programId, uint256 version);\n event Claim(IProduct indexed product, address indexed account, uint256 indexed programId, UFixed18 amount);\n event FeeClaim(Token18 indexed token, UFixed18 amount);\n\n error IncentivizerNotAllowedError(IProduct product);\n error IncentivizerTooManyProgramsError();\n error IncentivizerNotProgramOwnerError(IProduct product, uint256 programId);\n error IncentivizerInvalidProgramError(IProduct product, uint256 programId);\n error IncentivizerBatchClaimArgumentMismatchError();\n\n function programInfos(IProduct product, uint256 programId) external view returns (ProgramInfo memory);\n function fees(Token18 token) external view returns (UFixed18);\n function initialize(IController controller_) external;\n function create(IProduct product, ProgramInfo calldata info) external returns (uint256);\n function complete(IProduct product, uint256 programId) external;\n function sync(IOracleProvider.OracleVersion memory currentOracleVersion) external;\n function syncAccount(address account, IOracleProvider.OracleVersion memory currentOracleVersion) external;\n function claim(IProduct product, uint256[] calldata programIds) external;\n function claim(IProduct[] calldata products, uint256[][] calldata programIds) external;\n function claimFee(Token18[] calldata tokens) external;\n function active(IProduct product) external view returns (uint256);\n function count(IProduct product) external view returns (uint256);\n function unclaimed(IProduct product, address account, uint256 programId) external view returns (UFixed18);\n function available(IProduct product, uint256 programId) external view returns (UFixed18);\n function versionStarted(IProduct product, uint256 programId) external view returns (uint256);\n function versionComplete(IProduct product, uint256 programId) external view returns (uint256);\n function owner(IProduct product, uint256 programId) external view returns (address);\n function treasury(IProduct product, uint256 programId) external view returns (address);\n}\n" - }, - "contracts/interfaces/types/PayoffDefinition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"../../interfaces/IContractPayoffProvider.sol\";\n\n/// @dev PayoffDefinition tyoe\nstruct PayoffDefinition {\n PayoffDefinitionLib.PayoffType payoffType;\n PayoffDefinitionLib.PayoffDirection payoffDirection;\n bytes30 data;\n}\nusing PayoffDefinitionLib for PayoffDefinition global;\ntype PayoffDefinitionStorage is bytes32;\nusing PayoffDefinitionStorageLib for PayoffDefinitionStorage global;\n\n/**\n * @title PayoffDefinitionLib\n * @dev Library that surfaces logic for PayoffDefinition type functionality\n * @notice Library for the PayoffDefinition type. Performs validity and price transformation\n based on the payoff definition type.\n */\nlibrary PayoffDefinitionLib {\n using Address for address;\n\n error PayoffDefinitionUnsupportedTransform(PayoffType payoffType, PayoffDirection payoffDirection);\n error PayoffDefinitionNotContract(PayoffType payoffType, bytes30 data);\n\n /// @dev Payoff function type enum\n enum PayoffType { PASSTHROUGH, CONTRACT }\n enum PayoffDirection { LONG, SHORT }\n\n /**\n * @notice Checks validity of the payoff definition\n * @param self a payoff definition\n * @return Whether the payoff definition is valid for it's given type\n */\n function valid(PayoffDefinition memory self) internal view returns (bool) {\n if (self.payoffType == PayoffType.CONTRACT) return address(_providerContract(self)).isContract();\n\n // All other payoff types should have no data\n return uint(bytes32(self.data)) == 0;\n }\n\n /**\n * @notice Transforms a price based on the payoff definition\n * @param self a payoff definition\n * @param price raw oracle price\n * @return Price transformed by the payoff definition function\n */\n function transform(\n PayoffDefinition memory self,\n Fixed18 price\n ) internal view returns (Fixed18) {\n PayoffType payoffType = self.payoffType;\n PayoffDirection payoffDirection = self.payoffDirection;\n Fixed18 transformedPrice;\n\n // First get the price depending on the type\n if (payoffType == PayoffType.PASSTHROUGH) transformedPrice = price;\n else if (payoffType == PayoffType.CONTRACT) transformedPrice = _payoffFromContract(self, price);\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\n\n // Then transform it depending on the direction flag\n if (self.payoffDirection == PayoffDirection.LONG) return transformedPrice;\n else if (self.payoffDirection == PayoffDirection.SHORT) return transformedPrice.mul(Fixed18Lib.NEG_ONE);\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\n }\n\n /**\n * @notice Parses the data field into an address\n * @dev Reverts if payoffType is not CONTRACT\n * @param self a payoff definition\n * @return IContractPayoffProvider address\n */\n function _providerContract(\n PayoffDefinition memory self\n ) private pure returns (IContractPayoffProvider) {\n if (self.payoffType != PayoffType.CONTRACT) revert PayoffDefinitionNotContract(self.payoffType, self.data);\n // Shift to pull the last 20 bytes, then cast to an address\n return IContractPayoffProvider(address(bytes20(self.data << 80)));\n }\n\n /**\n * @notice Performs a price transformation by calling the underlying payoff contract\n * @param self a payoff definition\n * @param price raw oracle price\n * @return Price transformed by the payoff definition function on the contract\n */\n function _payoffFromContract(\n PayoffDefinition memory self,\n Fixed18 price\n ) private view returns (Fixed18) {\n bytes memory ret = address(_providerContract(self)).functionStaticCall(\n abi.encodeCall(IContractPayoffProvider.payoff, price)\n );\n return Fixed18.wrap(abi.decode(ret, (int256)));\n }\n}\n\n/**\n * @title PayoffDefinitionStorageLib\n * @notice Library that surfaces storage read and writes for the PayoffDefinition type\n */\nlibrary PayoffDefinitionStorageLib {\n function read(PayoffDefinitionStorage self) internal view returns (PayoffDefinition memory) {\n return _storagePointer(self);\n }\n\n function store(PayoffDefinitionStorage self, PayoffDefinition memory value) internal {\n PayoffDefinition storage storagePointer = _storagePointer(self);\n\n storagePointer.payoffType = value.payoffType;\n storagePointer.payoffDirection = value.payoffDirection;\n storagePointer.data = value.data;\n }\n\n function _storagePointer(\n PayoffDefinitionStorage self\n ) private pure returns (PayoffDefinition storage pointer) {\n assembly { pointer.slot := self }\n }\n}\n" - }, - "@equilibria/root/token/types/Token18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"../../number/types/UFixed18.sol\";\n\n/// @dev Token18\ntype Token18 is address;\nusing Token18Lib for Token18 global;\ntype Token18Storage is bytes32;\nusing Token18StorageLib for Token18Storage global;\n\n/**\n * @title Token18Lib\n * @notice Library to manage 18-decimal ERC20s that is compliant with the fixed-decimal types.\n * @dev Maintains significant gas savings over other Token implementations since no conversion take place\n */\nlibrary Token18Lib {\n using SafeERC20 for IERC20;\n\n Token18 public constant ZERO = Token18.wrap(address(0));\n\n /**\n * @notice Returns whether a token is the zero address\n * @param self Token to check for\n * @return Whether the token is the zero address\n */\n function isZero(Token18 self) internal pure returns (bool) {\n return Token18.unwrap(self) == Token18.unwrap(ZERO);\n }\n\n /**\n * @notice Returns whether the two tokens are equal\n * @param a First token to compare\n * @param b Second token to compare\n * @return Whether the two tokens are equal\n */\n function eq(Token18 a, Token18 b) internal pure returns (bool) {\n return Token18.unwrap(a) == Token18.unwrap(b);\n }\n\n /**\n * @notice Approves `grantee` to spend infinite tokens from the caller\n * @param self Token to transfer\n * @param grantee Address to allow spending\n */\n function approve(Token18 self, address grantee) internal {\n IERC20(Token18.unwrap(self)).safeApprove(grantee, type(uint256).max);\n }\n\n /**\n * @notice Approves `grantee` to spend `amount` tokens from the caller\n * @dev There are important race conditions to be aware of when using this function\n with values other than 0. This will revert if moving from non-zero to non-zero amounts\n See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/a55b7d13722e7ce850b626da2313f3e66ca1d101/contracts/token/ERC20/IERC20.sol#L57\n * @param self Token to transfer\n * @param grantee Address to allow spending\n * @param amount Amount of tokens to approve to spend\n */\n function approve(Token18 self, address grantee, UFixed18 amount) internal {\n IERC20(Token18.unwrap(self)).safeApprove(grantee, UFixed18.unwrap(amount));\n }\n\n /**\n * @notice Transfers all held tokens from the caller to the `recipient`\n * @param self Token to transfer\n * @param recipient Address to receive the tokens\n */\n function push(Token18 self, address recipient) internal {\n push(self, recipient, balanceOf(self, address(this)));\n }\n\n /**\n * @notice Transfers `amount` tokens from the caller to the `recipient`\n * @param self Token to transfer\n * @param recipient Address to transfer tokens to\n * @param amount Amount of tokens to transfer\n */\n function push(Token18 self, address recipient, UFixed18 amount) internal {\n IERC20(Token18.unwrap(self)).safeTransfer(recipient, UFixed18.unwrap(amount));\n }\n\n /**\n * @notice Transfers `amount` tokens from the `benefactor` to the caller\n * @dev Reverts if trying to pull Ether\n * @param self Token to transfer\n * @param benefactor Address to transfer tokens from\n * @param amount Amount of tokens to transfer\n */\n function pull(Token18 self, address benefactor, UFixed18 amount) internal {\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, address(this), UFixed18.unwrap(amount));\n }\n\n /**\n * @notice Transfers `amount` tokens from the `benefactor` to `recipient`\n * @dev Reverts if trying to pull Ether\n * @param self Token to transfer\n * @param benefactor Address to transfer tokens from\n * @param recipient Address to transfer tokens to\n * @param amount Amount of tokens to transfer\n */\n function pullTo(Token18 self, address benefactor, address recipient, UFixed18 amount) internal {\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, recipient, UFixed18.unwrap(amount));\n }\n\n /**\n * @notice Returns the name of the token\n * @param self Token to check for\n * @return Token name\n */\n function name(Token18 self) internal view returns (string memory) {\n return IERC20Metadata(Token18.unwrap(self)).name();\n }\n\n /**\n * @notice Returns the symbol of the token\n * @param self Token to check for\n * @return Token symbol\n */\n function symbol(Token18 self) internal view returns (string memory) {\n return IERC20Metadata(Token18.unwrap(self)).symbol();\n }\n\n /**\n * @notice Returns the `self` token balance of the caller\n * @param self Token to check for\n * @return Token balance of the caller\n */\n function balanceOf(Token18 self) internal view returns (UFixed18) {\n return balanceOf(self, address(this));\n }\n\n /**\n * @notice Returns the `self` token balance of `account`\n * @param self Token to check for\n * @param account Account to check\n * @return Token balance of the account\n */\n function balanceOf(Token18 self, address account) internal view returns (UFixed18) {\n return UFixed18.wrap(IERC20(Token18.unwrap(self)).balanceOf(account));\n }\n}\n\nlibrary Token18StorageLib {\n function read(Token18Storage self) internal view returns (Token18 value) {\n assembly {\n value := sload(self)\n }\n }\n\n function store(Token18Storage self, Token18 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/IERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\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 amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` 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(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\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" - }, - "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 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 using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\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 function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" - }, - "@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/Fixed18.sol\";\n\ninterface IOracleProvider {\n /// @dev A singular oracle version with its corresponding data\n struct OracleVersion {\n /// @dev The iterative version\n uint256 version;\n\n /// @dev the timestamp of the oracle update\n uint256 timestamp;\n\n /// @dev The oracle price of the corresponding version\n Fixed18 price;\n }\n\n function sync() external returns (OracleVersion memory);\n function currentVersion() external view returns (OracleVersion memory);\n function atVersion(uint256 oracleVersion) external view returns (OracleVersion memory);\n}\n" - }, - "contracts/interfaces/types/ProgramInfo.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"../IProduct.sol\";\nimport \"./Position.sol\";\nimport \"./Accumulator.sol\";\n\n/// @dev ProgramInfo type\nstruct ProgramInfo {\n /// @dev Coordinator for this program\n uint256 coordinatorId;\n\n /// @dev Amount of total maker and taker rewards\n Position amount;\n\n /// @dev start timestamp of the program\n uint256 start;\n\n /// @dev duration of the program (in seconds)\n uint256 duration;\n\n /**\n * @dev Reward ERC20 token contract\n * @notice Perennial does not support non-standard ERC20s as reward tokens for incentive programs, including,\n but not limited to: fee on transfer and rebase tokens. Using such a non-standard token will likely\n result in loss of funds.\n */\n Token18 token;\n}\nusing ProgramInfoLib for ProgramInfo global;\n\n/**\n * @title ProgramInfoLib\n * @notice Library that snapshots the static information for a single program.\n * @dev This information does not change during the operation of a program.\n */\nlibrary ProgramInfoLib {\n uint256 private constant MIN_DURATION = 1 days;\n uint256 private constant MAX_DURATION = 2 * 365 days;\n\n error ProgramInvalidStartError();\n error ProgramInvalidDurationError();\n\n /**\n * @notice Validates and creates a new Program\n * @dev Reverts for invalid programInfos\n * @param programInfo Un-sanitized static program information\n */\n function validate(ProgramInfo memory programInfo) internal view {\n if (isStarted(programInfo, block.timestamp)) revert ProgramInvalidStartError();\n if (programInfo.duration < MIN_DURATION || programInfo.duration > MAX_DURATION) revert ProgramInvalidDurationError();\n }\n\n /**\n * @notice Computes a new program info with the fee taken out of the amount\n * @param programInfo Original program info\n * @param incentivizationFee The incentivization fee\n * @return New program info\n * @return Fee amount\n */\n function deductFee(ProgramInfo memory programInfo, UFixed18 incentivizationFee)\n internal pure returns (ProgramInfo memory, UFixed18) {\n Position memory newProgramAmount = programInfo.amount.mul(UFixed18Lib.ONE.sub(incentivizationFee));\n UFixed18 programFeeAmount = programInfo.amount.sub(newProgramAmount).sum();\n programInfo.amount = newProgramAmount;\n return (programInfo, programFeeAmount);\n }\n\n /**\n * @notice Returns the maker and taker amounts per position share\n * @param self The ProgramInfo to operate on\n * @return programFee Amounts per share\n */\n function amountPerShare(ProgramInfo memory self) internal pure returns (Accumulator memory) {\n return self.amount.div(self.duration);\n }\n\n /**\n * @notice Returns whether the program has started by timestamp `timestamp`\n * @param self The ProgramInfo to operate on\n * @param timestamp Timestamp to check for\n * @return Whether the program has started\n */\n function isStarted(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\n return timestamp >= self.start;\n }\n\n /**\n * @notice Returns whether the program is completed by timestamp `timestamp`\n * @param self The ProgramInfo to operate on\n * @param timestamp Timestamp to check for\n * @return Whether the program is completed\n */\n function isComplete(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\n return timestamp >= (self.start + self.duration);\n }\n}\n" - }, - "contracts/interfaces/types/Position.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"../IProduct.sol\";\nimport \"./Accumulator.sol\";\nimport \"./PrePosition.sol\";\nimport \"./PackedPosition.sol\";\n\n/// @dev Position type\nstruct Position {\n /// @dev Quantity of the maker position\n UFixed18 maker;\n /// @dev Quantity of the taker position\n UFixed18 taker;\n}\nusing PositionLib for Position global;\n\n/**\n * @title PositionLib\n * @notice Library that surfaces math and settlement computations for the Position type.\n * @dev Positions track the current quantity of the account's maker and taker positions respectively\n * denominated as a unit of the product's payoff function.\n */\nlibrary PositionLib {\n /**\n * @notice Creates a packed position from an position\n * @param self A position\n * @return New packed position\n */\n function pack(Position memory self) internal pure returns (PackedPosition memory) {\n return PackedPosition({maker: self.maker.pack(), taker: self.taker.pack()});\n }\n\n /**\n * @notice Returns whether the position is fully empty\n * @param self A position\n * @return Whether the position is empty\n */\n function isEmpty(Position memory self) internal pure returns (bool) {\n return self.maker.isZero() && self.taker.isZero();\n }\n\n /**\n * @notice Adds position `a` and `b` together, returning the result\n * @param a The first position to sum\n * @param b The second position to sum\n * @return Resulting summed position\n */\n function add(Position memory a, Position memory b) internal pure returns (Position memory) {\n return Position({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\n }\n\n /**\n * @notice Subtracts position `b` from `a`, returning the result\n * @param a The position to subtract from\n * @param b The position to subtract\n * @return Resulting subtracted position\n */\n function sub(Position memory a, Position memory b) internal pure returns (Position memory) {\n return Position({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\n }\n\n /**\n * @notice Multiplies position `self` by accumulator `accumulator` and returns the resulting accumulator\n * @param self The Position to operate on\n * @param accumulator The accumulator to multiply by\n * @return Resulting multiplied accumulator\n */\n function mul(Position memory self, Accumulator memory accumulator) internal pure returns (Accumulator memory) {\n return Accumulator({\n maker: Fixed18Lib.from(self.maker).mul(accumulator.maker),\n taker: Fixed18Lib.from(self.taker).mul(accumulator.taker)\n });\n }\n\n /**\n * @notice Scales position `self` by fixed-decimal `scale` and returns the resulting position\n * @param self The Position to operate on\n * @param scale The Fixed-decimal to scale by\n * @return Resulting scaled position\n */\n function mul(Position memory self, UFixed18 scale) internal pure returns (Position memory) {\n return Position({maker: self.maker.mul(scale), taker: self.taker.mul(scale)});\n }\n\n /**\n * @notice Divides position `self` by `b` and returns the resulting accumulator\n * @param self The Position to operate on\n * @param b The number to divide by\n * @return Resulting divided accumulator\n */\n function div(Position memory self, uint256 b) internal pure returns (Accumulator memory) {\n return Accumulator({\n maker: Fixed18Lib.from(self.maker).div(Fixed18Lib.from(UFixed18Lib.from(b))),\n taker: Fixed18Lib.from(self.taker).div(Fixed18Lib.from(UFixed18Lib.from(b)))\n });\n }\n\n /**\n * @notice Returns the maximum of `self`'s maker and taker values\n * @param self The struct to operate on\n * @return Resulting maximum value\n */\n function max(Position memory self) internal pure returns (UFixed18) {\n return UFixed18Lib.max(self.maker, self.taker);\n }\n\n /**\n * @notice Sums the maker and taker together from a single position\n * @param self The struct to operate on\n * @return The sum of its maker and taker\n */\n function sum(Position memory self) internal pure returns (UFixed18) {\n return self.maker.add(self.taker);\n }\n\n /**\n * @notice Computes the next position after the pending-settlement position delta is included\n * @param self The current Position\n * @param pre The pending-settlement position delta\n * @return Next Position\n */\n function next(Position memory self, PrePosition memory pre) internal pure returns (Position memory) {\n return sub(add(self, pre.openPosition), pre.closePosition);\n }\n\n /**\n * @notice Returns the settled position at oracle version `toOracleVersion`\n * @dev Checks if a new position is ready to be settled based on the provided `toOracleVersion`\n * and `pre` and returns accordingly\n * @param self The current Position\n * @param pre The pending-settlement position delta\n * @param toOracleVersion The oracle version to settle to\n * @return Settled position at oracle version\n * @return Fee accrued from opening or closing the position\n * @return Whether a new position was settled\n */\n function settled(\n Position memory self,\n PrePosition memory pre,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal view returns (Position memory, UFixed18, bool) {\n return pre.canSettle(toOracleVersion) ? (next(self, pre), pre.computeFee(toOracleVersion), true) : (self, UFixed18Lib.ZERO, false);\n }\n\n /**\n * @notice Returns the socialization factor for the current position\n * @dev Socialization account for the case where `taker` > `maker` temporarily due to a liquidation\n * on the maker side. This dampens the taker's exposure pro-rata to ensure that the maker side\n * is never exposed over 1 x short.\n * @param self The Position to operate on\n * @return Socialization factor\n */\n function socializationFactor(Position memory self) internal pure returns (UFixed18) {\n return self.taker.isZero() ? UFixed18Lib.ONE : UFixed18Lib.min(UFixed18Lib.ONE, self.maker.div(self.taker));\n }\n}\n" - }, - "contracts/interfaces/types/Accumulator.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/Fixed18.sol\";\nimport \"./PackedAccumulator.sol\";\n\n/// @dev Accumulator type\nstruct Accumulator {\n /// @dev maker accumulator per share\n Fixed18 maker;\n /// @dev taker accumulator per share\n Fixed18 taker;\n}\nusing AccumulatorLib for Accumulator global;\n\n/**\n * @title AccountAccumulatorLib\n * @notice Library that surfaces math operations for the Accumulator type.\n * @dev Accumulators track the cumulative change in position value over time for the maker and taker positions\n * respectively. Account-level accumulators can then use two of these values `a` and `a'` to compute the\n * change in position value since last sync. This change in value is then used to compute P&L and fees.\n */\nlibrary AccumulatorLib {\n /**\n * @notice Creates a packed accumulator from an accumulator\n * @param self an accumulator\n * @return New packed accumulator\n */\n function pack(Accumulator memory self) internal pure returns (PackedAccumulator memory) {\n return PackedAccumulator({maker: self.maker.pack(), taker: self.taker.pack()});\n }\n\n /**\n * @notice Adds two accumulators together\n * @param a The first accumulator to sum\n * @param b The second accumulator to sum\n * @return The resulting summed accumulator\n */\n function add(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\n return Accumulator({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\n }\n\n /**\n * @notice Subtracts accumulator `b` from `a`\n * @param a The accumulator to subtract from\n * @param b The accumulator to subtract\n * @return The resulting subtracted accumulator\n */\n function sub(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\n return Accumulator({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\n }\n\n /**\n * @notice Multiplies two accumulators together\n * @param a The first accumulator to multiply\n * @param b The second accumulator to multiply\n * @return The resulting multiplied accumulator\n */\n function mul(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\n return Accumulator({maker: a.maker.mul(b.maker), taker: a.taker.mul(b.taker)});\n }\n\n /**\n * @notice Sums the maker and taker together from a single accumulator\n * @param self The struct to operate on\n * @return The sum of its maker and taker\n */\n function sum(Accumulator memory self) internal pure returns (Fixed18) {\n return self.maker.add(self.taker);\n }\n}\n" - }, - "@equilibria/root/curve/types/JumpRateUtilizationCurve.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"../CurveMath.sol\";\nimport \"../../number/types/PackedUFixed18.sol\";\nimport \"../../number/types/PackedFixed18.sol\";\n\n/// @dev JumpRateUtilizationCurve type\nstruct JumpRateUtilizationCurve {\n PackedFixed18 minRate;\n PackedFixed18 maxRate;\n PackedFixed18 targetRate;\n PackedUFixed18 targetUtilization;\n}\nusing JumpRateUtilizationCurveLib for JumpRateUtilizationCurve global;\ntype JumpRateUtilizationCurveStorage is bytes32;\nusing JumpRateUtilizationCurveStorageLib for JumpRateUtilizationCurveStorage global;\n\n/**\n * @title JumpRateUtilizationCurveLib\n * @notice Library for the Jump Rate utilization curve type\n */\nlibrary JumpRateUtilizationCurveLib {\n /**\n * @notice Computes the corresponding rate for a utilization ratio\n * @param utilization The utilization ratio\n * @return The corresponding rate\n */\n function compute(JumpRateUtilizationCurve memory self, UFixed18 utilization) internal pure returns (Fixed18) {\n UFixed18 targetUtilization = self.targetUtilization.unpack();\n if (utilization.lt(targetUtilization)) {\n return CurveMath.linearInterpolation(\n UFixed18Lib.ZERO,\n self.minRate.unpack(),\n targetUtilization,\n self.targetRate.unpack(),\n utilization\n );\n }\n if (utilization.lt(UFixed18Lib.ONE)) {\n return CurveMath.linearInterpolation(\n targetUtilization,\n self.targetRate.unpack(),\n UFixed18Lib.ONE,\n self.maxRate.unpack(),\n utilization\n );\n }\n return self.maxRate.unpack();\n }\n}\n\nlibrary JumpRateUtilizationCurveStorageLib {\n function read(JumpRateUtilizationCurveStorage self) internal view returns (JumpRateUtilizationCurve memory) {\n return _storagePointer(self);\n }\n\n function store(JumpRateUtilizationCurveStorage self, JumpRateUtilizationCurve memory value) internal {\n JumpRateUtilizationCurve storage storagePointer = _storagePointer(self);\n\n storagePointer.minRate = value.minRate;\n storagePointer.maxRate = value.maxRate;\n storagePointer.targetRate = value.targetRate;\n storagePointer.targetUtilization = value.targetUtilization;\n }\n\n function _storagePointer(JumpRateUtilizationCurveStorage self)\n private pure returns (JumpRateUtilizationCurve storage pointer) {\n assembly { pointer.slot := self }\n }\n}" - }, - "contracts/interfaces/IPayoffProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/Fixed18.sol\";\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"./types/PayoffDefinition.sol\";\n\ninterface IPayoffProvider {\n error PayoffProviderInvalidOracle();\n error PayoffProviderInvalidPayoffDefinitionError();\n\n function oracle() external view returns (IOracleProvider);\n function payoffDefinition() external view returns (PayoffDefinition memory);\n function currentVersion() external view returns (IOracleProvider.OracleVersion memory);\n function atVersion(uint256 oracleVersion) external view returns (IOracleProvider.OracleVersion memory);\n}\n" - }, - "contracts/interfaces/IParamProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\";\n\ninterface IParamProvider {\n event MaintenanceUpdated(UFixed18 newMaintenance);\n event FundingFeeUpdated(UFixed18 newFundingFee);\n event MakerFeeUpdated(UFixed18 newMakerFee);\n event TakerFeeUpdated(UFixed18 newTakerFee);\n event MakerLimitUpdated(UFixed18 newMakerLimit);\n event JumpRateUtilizationCurveUpdated(\n Fixed18 minRate,\n Fixed18 maxRate,\n Fixed18 targetRate,\n UFixed18 targetUtilization\n );\n\n error ParamProviderInvalidMakerFee();\n error ParamProviderInvalidTakerFee();\n error ParamProviderInvalidFundingFee();\n \n function maintenance() external view returns (UFixed18);\n function updateMaintenance(UFixed18 newMaintenance) external;\n function fundingFee() external view returns (UFixed18);\n function updateFundingFee(UFixed18 newFundingFee) external;\n function makerFee() external view returns (UFixed18);\n function updateMakerFee(UFixed18 newMakerFee) external;\n function takerFee() external view returns (UFixed18);\n function updateTakerFee(UFixed18 newTakerFee) external;\n function makerLimit() external view returns (UFixed18);\n function updateMakerLimit(UFixed18 newMakerLimit) external;\n function utilizationCurve() external view returns (JumpRateUtilizationCurve memory);\n function updateUtilizationCurve(JumpRateUtilizationCurve memory newUtilizationCurve) external;\n}\n" - }, - "contracts/interfaces/types/PrePosition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"./Position.sol\";\nimport \"../IProduct.sol\";\n\n/// @dev PrePosition type\nstruct PrePosition {\n /// @dev Oracle version at which the new position delta was recorded\n uint256 oracleVersion;\n\n /// @dev Size of position to open at oracle version\n Position openPosition;\n\n /// @dev Size of position to close at oracle version\n Position closePosition;\n}\nusing PrePositionLib for PrePosition global;\n\n/**\n * @title PrePositionLib\n * @notice Library that manages a pre-settlement position delta.\n * @dev PrePositions track the currently awaiting-settlement deltas to a settled Position. These are\n * Primarily necessary to introduce lag into the settlement system such that oracle lag cannot be\n * gamed to a user's advantage. When a user opens or closes a new position, it sits as a PrePosition\n * for one oracle version until it's settle into the Position, making it then effective. PrePositions\n * are automatically settled at the correct oracle version even if a flywheel call doesn't happen until\n * several version into the future by using the historical version lookups in the corresponding \"Versioned\"\n * global state types.\n */\nlibrary PrePositionLib {\n /**\n * @notice Returns whether there is no pending-settlement position delta\n * @dev Can be \"empty\" even with a non-zero oracleVersion if a position is opened and\n * closed in the same version netting out to a zero position delta\n * @param self The struct to operate on\n * @return Whether the pending-settlement position delta is empty\n */\n function isEmpty(PrePosition memory self) internal pure returns (bool) {\n return self.openPosition.isEmpty() && self.closePosition.isEmpty();\n }\n\n /**\n * @notice Increments the maker side of the open position delta\n * @dev Nets out open and close deltas to minimize the size of each\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @param amount The position amount to open\n */\n function openMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\n self.openPosition.maker = self.openPosition.maker.add(amount);\n self.oracleVersion = currentVersion;\n _netMake(self);\n }\n\n /**\n * @notice Increments the maker side of the close position delta\n * @dev Nets out open and close deltas to minimize the size of each\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @param amount The maker position amount to close\n */\n function closeMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\n self.closePosition.maker = self.closePosition.maker.add(amount);\n self.oracleVersion = currentVersion;\n _netMake(self);\n }\n\n /**\n * @notice Increments the taker side of the open position delta\n * @dev Nets out open and close deltas to minimize the size of each\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @param amount The taker position amount to open\n */\n function openTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\n self.openPosition.taker = self.openPosition.taker.add(amount);\n self.oracleVersion = currentVersion;\n _netTake(self);\n }\n\n /**\n * @notice Increments the taker side of the close position delta\n * @dev Nets out open and close deltas to minimize the size of each\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @param amount The taker position amount to close\n */\n function closeTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\n self.closePosition.taker = self.closePosition.taker.add(amount);\n self.oracleVersion = currentVersion;\n _netTake(self);\n }\n\n /**\n * @notice Nets out the open and close on the maker side of the position delta\n * @param self The struct to operate on\n */\n function _netMake(PrePosition storage self) private {\n if (self.openPosition.maker.gt(self.closePosition.maker)) {\n self.openPosition.maker = self.openPosition.maker.sub(self.closePosition.maker);\n self.closePosition.maker = UFixed18Lib.ZERO;\n } else {\n self.closePosition.maker = self.closePosition.maker.sub(self.openPosition.maker);\n self.openPosition.maker = UFixed18Lib.ZERO;\n }\n }\n\n /**\n * @notice Nets out the open and close on the taker side of the position delta\n * @param self The struct to operate on\n */\n function _netTake(PrePosition storage self) private {\n if (self.openPosition.taker.gt(self.closePosition.taker)) {\n self.openPosition.taker = self.openPosition.taker.sub(self.closePosition.taker);\n self.closePosition.taker = UFixed18Lib.ZERO;\n } else {\n self.closePosition.taker = self.closePosition.taker.sub(self.openPosition.taker);\n self.openPosition.taker = UFixed18Lib.ZERO;\n }\n }\n\n /**\n * @notice Returns whether the the pending position delta can be settled at version `toOracleVersion`\n * @dev Pending-settlement positions deltas can be settled (1) oracle version after they are recorded\n * @param self The struct to operate on\n * @param toOracleVersion The potential oracle version to settle\n * @return Whether the position delta can be settled\n */\n function canSettle(\n PrePosition memory self,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal pure returns (bool) {\n return !isEmpty(self) && toOracleVersion.version > self.oracleVersion;\n }\n\n /**\n * @notice Computes the fee incurred for opening or closing the pending-settlement position\n * @dev Must be called from a valid product to get the proper fee amounts\n * @param self The struct to operate on\n * @param toOracleVersion The oracle version at which settlement takes place\n * @return positionFee The maker / taker fee incurred\n */\n function computeFee(\n PrePosition memory self,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal view returns (UFixed18) {\n Position memory positionDelta = self.openPosition.add(self.closePosition);\n\n (UFixed18 makerNotional, UFixed18 takerNotional) = (\n Fixed18Lib.from(positionDelta.maker).mul(toOracleVersion.price).abs(),\n Fixed18Lib.from(positionDelta.taker).mul(toOracleVersion.price).abs()\n );\n\n IProduct product = IProduct(address(this));\n return makerNotional.mul(product.makerFee()).add(takerNotional.mul(product.takerFee()));\n }\n\n /**\n * @notice Computes the next oracle version to settle\n * @dev - If there is no pending-settlement position delta, returns the current oracle version\n * - Otherwise returns the oracle version at which the pending-settlement position delta can be first settled\n *\n * Corresponds to point (b) in the Position settlement flow\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @return Next oracle version to settle\n */\n function settleVersion(PrePosition storage self, uint256 currentVersion) internal view returns (uint256) {\n uint256 _oracleVersion = self.oracleVersion;\n return _oracleVersion == 0 ? currentVersion : _oracleVersion + 1;\n }\n}\n" - }, - "@equilibria/root/curve/CurveMath.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"../number/types/UFixed18.sol\";\nimport \"../number/types/Fixed18.sol\";\n\n/**\n * @title CurveMath\n * @notice Library for managing math operations for utilization curves.\n */\nlibrary CurveMath {\n error CurveMathOutOfBoundsError();\n\n /**\n * @notice Computes a linear interpolation between two points\n * @param startX First point's x-coordinate\n * @param startY First point's y-coordinate\n * @param endX Second point's x-coordinate\n * @param endY Second point's y-coordinate\n * @param targetX x-coordinate to interpolate\n * @return y-coordinate for `targetX` along the line from (`startX`, `startY`) -> (`endX`, `endY`)\n */\n function linearInterpolation(\n UFixed18 startX,\n Fixed18 startY,\n UFixed18 endX,\n Fixed18 endY,\n UFixed18 targetX\n ) internal pure returns (Fixed18) {\n if (targetX.lt(startX) || targetX.gt(endX)) revert CurveMathOutOfBoundsError();\n\n UFixed18 xRange = endX.sub(startX);\n Fixed18 yRange = endY.sub(startY);\n UFixed18 xRatio = targetX.sub(startX).div(xRange);\n return yRange.mul(Fixed18Lib.from(xRatio)).add(startY);\n }\n}\n" - }, - "contracts/interfaces/IContractPayoffProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/Fixed18.sol\";\n\ninterface IContractPayoffProvider {\n function payoff(Fixed18 price) external view returns (Fixed18 payoff);\n}\n" - }, - "contracts/interfaces/types/PackedPosition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/PackedUFixed18.sol\";\nimport \"./Position.sol\";\n\n/// @dev PackedPosition type\nstruct PackedPosition {\n /// @dev Quantity of the maker position\n PackedUFixed18 maker;\n /// @dev Quantity of the taker position\n PackedUFixed18 taker;\n}\nusing PackedPositionLib for PackedPosition global;\n\n/**\n * @title PackedPositionLib\n * @dev A packed version of the Position which takes up a single storage slot using `PackedFixed18` values.\n * @notice Library for the packed Position type.\n */\nlibrary PackedPositionLib {\n /**\n * @notice Creates an position from a packed position\n * @param self packed position\n * @return New position\n */\n function unpack(PackedPosition memory self) internal pure returns (Position memory) {\n return Position({maker: self.maker.unpack(), taker: self.taker.unpack()});\n }\n}\n" - }, - "contracts/interfaces/types/PackedAccumulator.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/PackedFixed18.sol\";\nimport \"./Accumulator.sol\";\n\n/// @dev PackedAccumulator type\nstruct PackedAccumulator {\n /// @dev maker accumulator per share\n PackedFixed18 maker;\n /// @dev taker accumulator per share\n PackedFixed18 taker;\n}\nusing PackedAccumulatorLib for PackedAccumulator global;\n\n/**\n * @title PackedAccumulatorLib\n * @dev A packed version of the Accumulator which takes up a single storage slot using `PackedFixed18` values.\n * @notice Library for the packed Accumulator type.\n */\nlibrary PackedAccumulatorLib {\n /**\n * @notice Creates an accumulator from a packed accumulator\n * @param self packed accumulator\n * @return New accumulator\n */\n function unpack(PackedAccumulator memory self) internal pure returns (Accumulator memory) {\n return Accumulator({maker: self.maker.unpack(), taker: self.taker.unpack()});\n }\n}\n" - }, - "contracts/product/types/accumulator/VersionedAccumulator.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../../../interfaces/IProduct.sol\";\nimport \"../../../interfaces/types/Accumulator.sol\";\nimport \"../position/VersionedPosition.sol\";\n\n/// @dev VersionedAccumulator type\nstruct VersionedAccumulator {\n /// @dev Latest synced oracle version\n uint256 latestVersion;\n\n /// @dev Mapping of accumulator value at each settled oracle version\n mapping(uint256 => PackedAccumulator) _valueAtVersion;\n\n /// @dev Mapping of accumulator share at each settled oracle version\n mapping(uint256 => PackedAccumulator) _shareAtVersion;\n}\nusing VersionedAccumulatorLib for VersionedAccumulator global;\n\n/**\n * @title VersionedAccumulatorLib\n * @notice Library that manages global versioned accumulator state.\n * @dev Manages two accumulators: value and share. The value accumulator measures the change in position value\n * over time. The share accumulator measures the change in liquidity ownership over time (for tracking\n * incentivization rewards).\n *\n * Both accumulators are stamped for historical lookup anytime there is a global settlement, which services\n * the delayed-position accounting. It is not guaranteed that every version will have a value stamped, but\n * only versions when a settlement occurred are needed for this historical computation.\n */\nlibrary VersionedAccumulatorLib {\n /**\n * @notice Returns the stamped value accumulator at `oracleVersion`\n * @param self The struct to operate on\n * @param oracleVersion The oracle version to retrieve the value at\n * @return The stamped value accumulator at the requested version\n */\n function valueAtVersion(VersionedAccumulator storage self, uint256 oracleVersion) internal view returns (Accumulator memory) {\n return self._valueAtVersion[oracleVersion].unpack();\n }\n\n /**\n * @notice Returns the stamped share accumulator at `oracleVersion`\n * @param self The struct to operate on\n * @param oracleVersion The oracle version to retrieve the share at\n * @return The stamped share accumulator at the requested version\n */\n function shareAtVersion(VersionedAccumulator storage self, uint256 oracleVersion) internal view returns (Accumulator memory) {\n return self._shareAtVersion[oracleVersion].unpack();\n }\n\n /**\n * @notice Globally accumulates all value (position + funding) and share since last oracle update\n * @param self The struct to operate on\n * @param fundingFee The funding fee rate for the product\n * @param position Pointer to global position\n * @param latestOracleVersion The oracle version to accumulate from\n * @param toOracleVersion The oracle version to accumulate to\n * @return accumulatedFee The total fee accrued from accumulation\n */\n function accumulate(\n VersionedAccumulator storage self,\n UFixed18 fundingFee,\n VersionedPosition storage position,\n IOracleProvider.OracleVersion memory latestOracleVersion,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal returns (UFixed18 accumulatedFee) {\n Position memory latestPosition = position.positionAtVersion(latestOracleVersion.version);\n\n // accumulate funding\n Accumulator memory accumulatedPosition;\n (accumulatedPosition, accumulatedFee) =\n _accumulateFunding(fundingFee, latestPosition, latestOracleVersion, toOracleVersion);\n\n // accumulate position\n accumulatedPosition = accumulatedPosition.add(\n _accumulatePosition(latestPosition, latestOracleVersion, toOracleVersion));\n\n // accumulate share\n Accumulator memory accumulatedShare =\n _accumulateShare(latestPosition, latestOracleVersion, toOracleVersion);\n\n // save update\n self._valueAtVersion[toOracleVersion.version] = valueAtVersion(self, latestOracleVersion.version)\n .add(accumulatedPosition)\n .pack();\n self._shareAtVersion[toOracleVersion.version] = shareAtVersion(self, latestOracleVersion.version)\n .add(accumulatedShare)\n .pack();\n self.latestVersion = toOracleVersion.version;\n }\n\n /**\n * @notice Globally accumulates all funding since last oracle update\n * @dev If an oracle version is skipped due to no pre positions, funding will continue to be\n * pegged to the price of the last snapshotted oracleVersion until a new one is accumulated.\n * This is an acceptable approximation.\n * @param fundingFee The funding fee rate for the product\n * @param latestPosition The latest global position\n * @param latestOracleVersion The oracle version to accumulate from\n * @param toOracleVersion The oracle version to accumulate to\n * @return accumulatedFunding The total amount accumulated from funding\n * @return accumulatedFee The total fee accrued from funding accumulation\n */\n function _accumulateFunding(\n UFixed18 fundingFee,\n Position memory latestPosition,\n IOracleProvider.OracleVersion memory latestOracleVersion,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) private view returns (Accumulator memory accumulatedFunding, UFixed18 accumulatedFee) {\n if (_product().closed()) return (Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO), UFixed18Lib.ZERO);\n if (latestPosition.taker.isZero()) return (Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO), UFixed18Lib.ZERO);\n if (latestPosition.maker.isZero()) return (Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO), UFixed18Lib.ZERO);\n\n uint256 elapsed = toOracleVersion.timestamp - latestOracleVersion.timestamp;\n\n UFixed18 takerNotional = Fixed18Lib.from(latestPosition.taker).mul(latestOracleVersion.price).abs();\n UFixed18 socializedNotional = takerNotional.mul(latestPosition.socializationFactor());\n\n Fixed18 rateAccumulated = _product().rate(latestPosition)\n .mul(Fixed18Lib.from(UFixed18Lib.from(elapsed)));\n Fixed18 fundingAccumulated = rateAccumulated.mul(Fixed18Lib.from(socializedNotional));\n accumulatedFee = fundingAccumulated.abs().mul(fundingFee);\n\n Fixed18 fundingAccumulatedWithoutFee = Fixed18Lib.from(\n fundingAccumulated.sign(),\n fundingAccumulated.abs().sub(accumulatedFee)\n );\n\n bool makerPaysFunding = fundingAccumulated.sign() < 0;\n accumulatedFunding.maker = (makerPaysFunding ? fundingAccumulated : fundingAccumulatedWithoutFee)\n .div(Fixed18Lib.from(latestPosition.maker));\n accumulatedFunding.taker = (makerPaysFunding ? fundingAccumulatedWithoutFee : fundingAccumulated)\n .div(Fixed18Lib.from(latestPosition.taker)).mul(Fixed18Lib.NEG_ONE);\n }\n\n /**\n * @notice Globally accumulates position PNL since last oracle update\n * @param latestPosition The latest global position\n * @param latestOracleVersion The oracle version to accumulate from\n * @param toOracleVersion The oracle version to accumulate to\n * @return accumulatedPosition The total amount accumulated from position PNL\n */\n function _accumulatePosition(\n Position memory latestPosition,\n IOracleProvider.OracleVersion memory latestOracleVersion,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) private view returns (Accumulator memory accumulatedPosition) {\n if (_product().closed()) return Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO);\n if (latestPosition.taker.isZero()) return Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO);\n if (latestPosition.maker.isZero()) return Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO);\n\n Fixed18 oracleDelta = toOracleVersion.price.sub(latestOracleVersion.price);\n Fixed18 totalTakerDelta = oracleDelta.mul(Fixed18Lib.from(latestPosition.taker));\n Fixed18 socializedTakerDelta = totalTakerDelta.mul(Fixed18Lib.from(latestPosition.socializationFactor()));\n\n accumulatedPosition.maker = socializedTakerDelta.div(Fixed18Lib.from(latestPosition.maker)).mul(Fixed18Lib.NEG_ONE);\n accumulatedPosition.taker = socializedTakerDelta.div(Fixed18Lib.from(latestPosition.taker));\n }\n\n /**\n * @notice Globally accumulates position's share of the total market since last oracle update\n * @dev This is used to compute incentivization rewards based on market participation\n * @param latestPosition The latest global position\n * @param latestOracleVersion The oracle version to accumulate from\n * @param toOracleVersion The oracle version to accumulate to\n * @return accumulatedShare The total share amount accumulated per position\n */\n function _accumulateShare(\n Position memory latestPosition,\n IOracleProvider.OracleVersion memory latestOracleVersion,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) private pure returns (Accumulator memory accumulatedShare) {\n uint256 elapsed = toOracleVersion.timestamp - latestOracleVersion.timestamp;\n\n accumulatedShare.maker = latestPosition.maker.isZero() ?\n Fixed18Lib.ZERO :\n Fixed18Lib.from(UFixed18Lib.from(elapsed).div(latestPosition.maker));\n accumulatedShare.taker = latestPosition.taker.isZero() ?\n Fixed18Lib.ZERO :\n Fixed18Lib.from(UFixed18Lib.from(elapsed).div(latestPosition.taker));\n }\n\n function _product() private view returns (IProduct) {\n return IProduct(address(this));\n }\n}\n" - }, - "contracts/product/types/position/VersionedPosition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../../../interfaces/types/PrePosition.sol\";\nimport \"../../../interfaces/types/PackedPosition.sol\";\n\n//// @dev VersionedPosition type\nstruct VersionedPosition {\n /// @dev Mapping of global position at each version\n mapping(uint256 => PackedPosition) _positionAtVersion;\n\n /// @dev Current global pending-settlement position delta\n PrePosition pre;\n}\nusing VersionedPositionLib for VersionedPosition global;\n\n/**\n * @title VersionedPositionLib\n * @notice Library that manages global position state.\n * @dev Global position state is used to compute utilization rate and socialization, and to account for and\n * distribute fees globally.\n *\n * Positions are stamped for historical lookup anytime there is a global settlement, which services\n * the delayed-position accounting. It is not guaranteed that every version will have a value stamped, but\n * only versions when a settlement occurred are needed for this historical computation.\n */\nlibrary VersionedPositionLib {\n /**\n * @notice Returns the current global position\n * @return Current global position\n */\n function positionAtVersion(VersionedPosition storage self, uint256 oracleVersion) internal view returns (Position memory) {\n return self._positionAtVersion[oracleVersion].unpack();\n }\n\n /**\n * @notice Settled the global position to oracle version `toOracleVersion`\n * @param self The struct to operate on\n * @param latestVersion The latest settled oracle version\n * @param toOracleVersion The oracle version to settle to\n * @return positionFee The fee accrued from opening or closing a new position\n */\n function settle(\n VersionedPosition storage self,\n uint256 latestVersion,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal returns (UFixed18) {\n (Position memory newPosition, UFixed18 positionFee, bool settled) =\n positionAtVersion(self, latestVersion).settled(self.pre, toOracleVersion);\n\n self._positionAtVersion[toOracleVersion.version] = newPosition.pack();\n if (settled) delete self.pre;\n\n return positionFee;\n }\n}\n" - } - }, - "settings": { - "optimizer": { - "enabled": true, - "runs": 5800 - }, - "outputSelection": { - "*": { - "*": ["abi", "evm.bytecode", "evm.deployedBytecode", "evm.methodIdentifiers", "metadata"], - "": ["ast"] - } - } - } -} diff --git a/packages/perennial/deployments/goerli/solcInputs/b6ff42633a62e1bc6c97d8ccad85444b.json b/packages/perennial/deployments/goerli/solcInputs/b6ff42633a62e1bc6c97d8ccad85444b.json deleted file mode 100644 index 4f280f79d..000000000 --- a/packages/perennial/deployments/goerli/solcInputs/b6ff42633a62e1bc6c97d8ccad85444b.json +++ /dev/null @@ -1,348 +0,0 @@ -{ - "language": "Solidity", - "sources": { - "contracts/collateral/Collateral.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/root/control/unstructured/UInitializable.sol\";\nimport \"@equilibria/root/control/unstructured/UReentrancyGuard.sol\";\nimport \"../interfaces/ICollateral.sol\";\nimport \"./types/OptimisticLedger.sol\";\nimport \"../controller/UControllerProvider.sol\";\n\n/**\n * @title Collateral\n * @notice Manages logic and state for all collateral accounts in the protocol.\n */\ncontract Collateral is ICollateral, UInitializable, UControllerProvider, UReentrancyGuard {\n /// @dev ERC20 stablecoin for collateral\n Token18 public immutable token;\n\n /// @dev Per product collateral state\n mapping(IProduct => OptimisticLedger) private _products;\n\n /// @dev Protocol and product fees collected, but not yet claimed\n mapping(address => UFixed18) public fees;\n\n /**\n * @notice Initializes the immutable contract state\n * @dev Called at implementation instantiate and constant for that implementation.\n * @param token_ Collateral ERC20 stablecoin address\n */\n constructor(Token18 token_) {\n token = token_;\n }\n\n /**\n * @notice Initializes the contract state\n * @dev Must be called atomically as part of the upgradeable proxy deployment to\n * avoid front-running\n * @param controller_ Factory contract address\n */\n function initialize(IController controller_) external initializer(1) {\n __UControllerProvider__initialize(controller_);\n __UReentrancyGuard__initialize();\n }\n\n /**\n * @notice Deposits `amount` collateral from `msg.sender` to `account`'s `product`\n * account\n * @param account Account to deposit the collateral for\n * @param product Product to credit the collateral to\n * @param amount Amount of collateral to deposit\n */\n function depositTo(address account, IProduct product, UFixed18 amount)\n external\n nonReentrant\n notPaused\n notZeroAddress(account)\n isProduct(product)\n collateralInvariant(account, product)\n {\n _products[product].creditAccount(account, amount);\n token.pull(msg.sender, amount);\n\n emit Deposit(account, product, amount);\n }\n\n /**\n * @notice Withdraws `amount` collateral from `msg.sender`'s `product` account\n * and sends it to `account`\n * @param account Account to withdraw the collateral to\n * @param product Product to withdraw the collateral from\n * @param amount Amount of collateral to withdraw\n */\n function withdrawTo(address account, IProduct product, UFixed18 amount)\n external\n nonReentrant\n notPaused\n notZeroAddress(account)\n isProduct(product)\n settleForAccount(msg.sender, product)\n collateralInvariant(msg.sender, product)\n maintenanceInvariant(msg.sender, product)\n {\n amount = amount.eq(UFixed18Lib.MAX) ? collateral(msg.sender, product) : amount;\n _products[product].debitAccount(msg.sender, amount);\n token.push(account, amount);\n\n emit Withdrawal(msg.sender, product, amount);\n }\n\n /**\n * @notice Liquidates `account`'s `product` collateral account\n * @dev Account must be under-collateralized, fee returned immediately to `msg.sender`\n * @param account Account to liquidate\n * @param product Product to liquidate for\n */\n function liquidate(address account, IProduct product)\n external\n nonReentrant\n notPaused\n isProduct(product)\n settleForAccount(account, product)\n {\n UFixed18 totalMaintenance = product.maintenance(account);\n UFixed18 totalCollateral = collateral(account, product);\n\n if (!totalMaintenance.gt(totalCollateral))\n revert CollateralCantLiquidate(totalMaintenance, totalCollateral);\n\n product.closeAll(account);\n\n // claim fee\n UFixed18 liquidationFee = controller().liquidationFee();\n UFixed18 fee = UFixed18Lib.min(totalCollateral, totalMaintenance.mul(liquidationFee));\n\n _products[product].debitAccount(account, fee);\n token.push(msg.sender, fee);\n\n emit Liquidation(account, product, msg.sender, fee);\n }\n\n /**\n * @notice Credits `amount` to `account`'s collateral account\n * @dev Callable only by the corresponding product as part of the settlement flywheel.\n * Moves collateral within a product, any collateral leaving the product due to\n * fees has already been accounted for in the settleProduct flywheel.\n * Debits in excess of the account balance get recorded as shortfall, and can be\n * resolved by the product owner as needed.\n * @param account Account to credit\n * @param amount Amount to credit the account (can be negative)\n */\n function settleAccount(address account, Fixed18 amount) external onlyProduct {\n IProduct product = IProduct(msg.sender);\n\n UFixed18 newShortfall = _products[product].settleAccount(account, amount);\n\n emit AccountSettle(product, account, amount, newShortfall);\n }\n\n /**\n * @notice Debits `amount` from product's total collateral account\n * @dev Callable only by the corresponding product as part of the settlement flywheel\n * Removes collateral from the product as fees.\n * @param amount Amount to debit from the account\n */\n function settleProduct(UFixed18 amount) external onlyProduct {\n (IProduct product, IController controller) = (IProduct(msg.sender), controller());\n\n address protocolTreasury = controller.treasury();\n address productTreasury = controller.treasury(product);\n\n UFixed18 protocolFee = amount.mul(controller.protocolFee());\n UFixed18 productFee = amount.sub(protocolFee);\n\n _products[product].debit(amount);\n fees[protocolTreasury] = fees[protocolTreasury].add(protocolFee);\n fees[productTreasury] = fees[productTreasury].add(productFee);\n\n emit ProductSettle(product, protocolFee, productFee);\n }\n\n /**\n * @notice Returns the balance of `account`'s `product` collateral account\n * @param account Account to return for\n * @param product Product to return for\n * @return The balance of the collateral account\n */\n function collateral(address account, IProduct product) public view returns (UFixed18) {\n return _products[product].balances[account];\n }\n\n /**\n * @notice Returns the total balance of `product`'s collateral\n * @param product Product to return for\n * @return The total balance of collateral in the product\n */\n function collateral(IProduct product) external view returns (UFixed18) {\n return _products[product].total;\n }\n\n /**\n * @notice Returns the current shortfall of `product`'s collateral\n * @param product Product to return for\n * @return The current shortfall of the product\n */\n function shortfall(IProduct product) external view returns (UFixed18) {\n return _products[product].shortfall;\n }\n\n /**\n * @notice Returns whether `account`'s `product` collateral account can be liquidated\n * @param account Account to return for\n * @param product Product to return for\n * @return Whether the account can be liquidated\n */\n function liquidatable(address account, IProduct product) external view returns (bool) {\n return product.maintenance(account).gt(collateral(account, product));\n }\n\n /**\n * @notice Returns whether `account`'s `product` collateral account can be liquidated\n * after the next oracle version settlement\n * @dev Takes into account the current pre-position on the account\n * @param account Account to return for\n * @param product Product to return for\n * @return Whether the account can be liquidated\n */\n function liquidatableNext(address account, IProduct product) external view returns (bool) {\n return product.maintenanceNext(account).gt(collateral(account, product));\n }\n\n /**\n * @notice Injects additional collateral into a product to resolve shortfall\n * @dev Shortfall is a measure of settled insolvency in the market\n * This hook can be used by the product owner or an insurance fund to re-capitalize an insolvent market\n * @param product Product to resolve shortfall for\n * @param amount Amount of shortfall to resolve\n */\n function resolveShortfall(IProduct product, UFixed18 amount) external isProduct(product) notPaused {\n _products[product].resolve(amount);\n token.pull(msg.sender, amount);\n\n emit ShortfallResolution(product, amount);\n }\n\n /**\n * @notice Claims all of `msg.sender`'s fees\n */\n function claimFee() external notPaused {\n UFixed18 amount = fees[msg.sender];\n\n fees[msg.sender] = UFixed18Lib.ZERO;\n token.push(msg.sender, amount);\n\n emit FeeClaim(msg.sender, amount);\n }\n\n /// @dev Ensure that the address is non-zero\n modifier notZeroAddress(address account) {\n if (account == address(0)) revert CollateralZeroAddressError();\n\n _;\n }\n\n /// @dev Ensure that the user has sufficient margin for both current and next maintenance\n modifier maintenanceInvariant(address account, IProduct product) {\n _;\n\n UFixed18 maintenance = product.maintenance(account);\n UFixed18 maintenanceNext = product.maintenanceNext(account);\n\n if (UFixed18Lib.max(maintenance, maintenanceNext).gt(collateral(account, product)))\n revert CollateralInsufficientCollateralError();\n }\n\n /// @dev Ensure that the account is either empty or above the collateral minimum\n modifier collateralInvariant(address account, IProduct product) {\n _;\n\n UFixed18 accountCollateral = collateral(account, product);\n if (!accountCollateral.isZero() && accountCollateral.lt(controller().minCollateral()))\n revert CollateralUnderLimitError();\n }\n\n /// @dev Helper to fully settle an account's state\n modifier settleForAccount(address account, IProduct product) {\n product.settleAccount(account);\n\n _;\n }\n}\n" - }, - "@equilibria/root/control/unstructured/UInitializable.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"../../storage/UStorage.sol\";\n\n/**\n * @title UInitializable\n * @notice Library to manage the initialization lifecycle of upgradeable contracts\n * @dev `UInitializable` allows the creation of pseudo-constructors for upgradeable contracts. One\n * `initializer` should be declared per top-level contract. Child contracts can use the `onlyInitializer`\n * modifier to tag their internal initialization functions to ensure that they can only be called\n * from a top-level `initializer` or a constructor.\n */\nabstract contract UInitializable {\n error UInitializableZeroVersionError();\n error UInitializableAlreadyInitializedError(uint256 version);\n error UInitializableNotInitializingError();\n\n event Initialized(uint256 version);\n\n /// @dev The initialized flag\n Uint256Storage private constant _version = Uint256Storage.wrap(keccak256(\"equilibria.root.UInitializable.version\"));\n\n /// @dev The initializing flag\n BoolStorage private constant _initializing = BoolStorage.wrap(keccak256(\"equilibria.root.UInitializable.initializing\"));\n\n /// @dev Can only be called once per version, `version` is 1-indexed\n modifier initializer(uint256 version) {\n if (version == 0) revert UInitializableZeroVersionError();\n if (_version.read() >= version) revert UInitializableAlreadyInitializedError(version);\n\n _version.store(version);\n _initializing.store(true);\n\n _;\n\n _initializing.store(false);\n emit Initialized(version);\n }\n\n /// @dev Can only be called from an initializer or constructor\n modifier onlyInitializer() {\n if (!_constructing() && !_initializing.read()) revert UInitializableNotInitializingError();\n _;\n }\n\n /**\n * @notice Returns whether the contract is currently being constructed\n * @dev {Address.isContract} returns false for contracts currently in the process of being constructed\n * @return Whether the contract is currently being constructed\n */\n function _constructing() private view returns (bool) {\n return !Address.isContract(address(this));\n }\n}\n" - }, - "@equilibria/root/control/unstructured/UReentrancyGuard.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"./UInitializable.sol\";\nimport \"../../storage/UStorage.sol\";\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n *\n * NOTE: This contract has been extended from the Open Zeppelin library to include an\n * unstructured storage pattern, so that it can be safely mixed in with upgradeable\n * contracts without affecting their storage patterns through inheritance.\n */\nabstract contract UReentrancyGuard is UInitializable {\n error UReentrancyGuardReentrantCallError();\n\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n /**\n * @dev unstructured storage slot for the reentrancy status\n */\n Uint256Storage private constant _status = Uint256Storage.wrap(keccak256(\"equilibria.root.UReentrancyGuard.status\"));\n\n /**\n * @dev Initializes the contract setting the status to _NOT_ENTERED.\n */\n function __UReentrancyGuard__initialize() internal onlyInitializer {\n _status.store(_NOT_ENTERED);\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and make it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n // On the first call to nonReentrant, _notEntered will be true\n if (_status.read() == _ENTERED) revert UReentrancyGuardReentrantCallError();\n\n // Any calls to nonReentrant after this point will fail\n _status.store(_ENTERED);\n\n _;\n\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status.store(_NOT_ENTERED);\n }\n}\n" - }, - "contracts/interfaces/ICollateral.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/root/number/types/Fixed18.sol\";\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"./IController.sol\";\nimport \"./IProduct.sol\";\n\ninterface ICollateral {\n event Deposit(address indexed user, IProduct indexed product, UFixed18 amount);\n event Withdrawal(address indexed user, IProduct indexed product, UFixed18 amount);\n event AccountSettle(IProduct indexed product, address indexed account, Fixed18 amount, UFixed18 newShortfall);\n event ProductSettle(IProduct indexed product, UFixed18 protocolFee, UFixed18 productFee);\n event Liquidation(address indexed user, IProduct indexed product, address liquidator, UFixed18 fee);\n event ShortfallResolution(IProduct indexed product, UFixed18 amount);\n event FeeClaim(address indexed account, UFixed18 amount);\n\n error CollateralCantLiquidate(UFixed18 totalMaintenance, UFixed18 totalCollateral);\n error CollateralInsufficientCollateralError();\n error CollateralUnderLimitError();\n error CollateralZeroAddressError();\n\n function token() external view returns (Token18);\n function fees(address account) external view returns (UFixed18);\n function initialize(IController controller_) external;\n function depositTo(address account, IProduct product, UFixed18 amount) external;\n function withdrawTo(address account, IProduct product, UFixed18 amount) external;\n function liquidate(address account, IProduct product) external;\n function settleAccount(address account, Fixed18 amount) external;\n function settleProduct(UFixed18 amount) external;\n function collateral(address account, IProduct product) external view returns (UFixed18);\n function collateral(IProduct product) external view returns (UFixed18);\n function shortfall(IProduct product) external view returns (UFixed18);\n function liquidatable(address account, IProduct product) external view returns (bool);\n function liquidatableNext(address account, IProduct product) external view returns (bool);\n function resolveShortfall(IProduct product, UFixed18 amount) external;\n function claimFee() external;\n}\n" - }, - "contracts/collateral/types/OptimisticLedger.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\n\n/// @dev OptimisticLedger type\nstruct OptimisticLedger {\n /// @dev Individual account collateral balances\n mapping(address => UFixed18) balances;\n\n /// @dev Total ledger collateral balance\n UFixed18 total;\n\n /// @dev Total ledger collateral shortfall\n UFixed18 shortfall;\n}\nusing OptimisticLedgerLib for OptimisticLedger global;\n\n/**\n * @title OptimisticLedgerLib\n * @notice Library that manages a global vs account ledger where the global ledger is settled separately,\n * and ahead of, the user-level accounts.\n * @dev Ensures that no more collateral leaves the ledger than goes it, while allowing user-level accounts\n * to settle as a follow up step. Overdrafts on the user-level are accounted as \"shortall\". Shortfall\n * in the system is the quantity of insolvency that can be optionally resolved by the ledger owner.\n * Until the shortfall is resolved, collateral may be withdrawn from the ledger on a FCFS basis. However\n * once the ledger total has been depleted, users will not be able to withdraw even if they have non-zero\n * user level balances until the shortfall is resolved, recapitalizing the ledger.\n */\nlibrary OptimisticLedgerLib {\n /**\n * @notice Credits `account` with `amount` collateral\n * @param self The struct to operate on\n * @param account Account to credit collateral to\n * @param amount Amount of collateral to credit\n */\n function creditAccount(OptimisticLedger storage self, address account, UFixed18 amount) internal {\n self.balances[account] = self.balances[account].add(amount);\n self.total = self.total.add(amount);\n }\n\n /**\n * @notice Debits `account` `amount` collateral\n * @param self The struct to operate on\n * @param account Account to debit collateral from\n * @param amount Amount of collateral to debit\n */\n function debitAccount(OptimisticLedger storage self, address account, UFixed18 amount) internal {\n self.balances[account] = self.balances[account].sub(amount);\n self.total = self.total.sub(amount);\n }\n\n /**\n * @notice Credits `account` with `amount` collateral\n * @dev Funds come from inside the product, not totals are updated\n * Shortfall is created if more funds are debited from an account than exist\n * @param self The struct to operate on\n * @param account Account to credit collateral to\n * @param amount Amount of collateral to credit\n * @return newShortfall Any new shortfall incurred during this settlement\n */\n function settleAccount(OptimisticLedger storage self, address account, Fixed18 amount)\n internal returns (UFixed18 newShortfall) {\n Fixed18 newBalance = Fixed18Lib.from(self.balances[account]).add(amount);\n\n if (newBalance.sign() == -1) {\n newShortfall = newBalance.abs();\n newBalance = Fixed18Lib.ZERO;\n }\n\n self.balances[account] = newBalance.abs();\n self.shortfall = self.shortfall.add(newShortfall);\n }\n\n /**\n * @notice Debits ledger globally `amount` collateral\n * @dev Removes balance from total that is accounted for elsewhere (e.g. product-level accumulators)\n * @param self The struct to operate on\n * @param amount Amount of collateral to debit\n */\n function debit(OptimisticLedger storage self, UFixed18 amount) internal {\n self.total = self.total.sub(amount);\n }\n\n /**\n * @notice Reduces the amount of collateral shortfall in the ledger\n * @param self The struct to operate on\n * @param amount Amount of shortfall to resolve\n */\n function resolve(OptimisticLedger storage self, UFixed18 amount) internal {\n self.shortfall = self.shortfall.sub(amount);\n self.total = self.total.add(amount);\n }\n}\n" - }, - "contracts/controller/UControllerProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/root/control/unstructured/UInitializable.sol\";\nimport \"@equilibria/root/storage/UStorage.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"../interfaces/IController.sol\";\nimport \"../interfaces/IProduct.sol\";\n\n/**\n * @title UControllerProvider\n * @notice Mix-in that manages a controller pointer and associated permissioning modifiers.\n * @dev Uses unstructured storage so that it is safe to mix-in to upgreadable contracts without modifying\n * their storage layout.\n */\nabstract contract UControllerProvider is UInitializable {\n error NotOwnerError(uint256 coordinatorId);\n error NotProductError(IProduct product);\n error NotCollateralError();\n error PausedError();\n error InvalidControllerError();\n\n /// @dev The controller contract address\n AddressStorage private constant _controller = AddressStorage.wrap(keccak256(\"equilibria.perennial.UControllerProvider.controller\"));\n function controller() public view returns (IController) { return IController(_controller.read()); }\n\n /**\n * @notice Initializes the contract state\n * @param controller_ Protocol Controller contract address\n */\n // solhint-disable-next-line func-name-mixedcase\n function __UControllerProvider__initialize(IController controller_) internal onlyInitializer {\n if (!Address.isContract(address(controller_))) revert InvalidControllerError();\n _controller.store(address(controller_));\n }\n\n /// @dev Only allow a valid product contract to call\n modifier onlyProduct {\n if (!controller().isProduct(IProduct(msg.sender))) revert NotProductError(IProduct(msg.sender));\n\n _;\n }\n\n /// @dev Verify that `product` is a valid product contract\n modifier isProduct(IProduct product) {\n if (!controller().isProduct(product)) revert NotProductError(product);\n\n _;\n }\n\n /// @dev Only allow the Collateral contract to call\n modifier onlyCollateral {\n if (msg.sender != address(controller().collateral())) revert NotCollateralError();\n\n _;\n }\n\n /// @dev Only allow the coordinator owner to call\n modifier onlyOwner(uint256 coordinatorId) {\n if (msg.sender != controller().owner(coordinatorId)) revert NotOwnerError(coordinatorId);\n\n _;\n }\n\n /// @dev Only allow if the protocol is currently unpaused\n modifier notPaused() {\n if (controller().paused()) revert PausedError();\n\n _;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Address.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // 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\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" - }, - "@equilibria/root/storage/UStorage.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"../number/types/UFixed18.sol\";\n\n/// @dev Stored boolean slot\ntype BoolStorage is bytes32;\nusing BoolStorageLib for BoolStorage global;\n\n/// @dev Stored uint256 slot\ntype Uint256Storage is bytes32;\nusing Uint256StorageLib for Uint256Storage global;\n\n/// @dev Stored int256 slot\ntype Int256Storage is bytes32;\nusing Int256StorageLib for Int256Storage global;\n\n/// @dev Stored address slot\ntype AddressStorage is bytes32;\nusing AddressStorageLib for AddressStorage global;\n\n/// @dev Stored bytes32 slot\ntype Bytes32Storage is bytes32;\nusing Bytes32StorageLib for Bytes32Storage global;\n\n/**\n * @title BoolStorageLib\n * @notice Library to manage storage and retrival of a boolean at a fixed storage slot\n */\nlibrary BoolStorageLib {\n /**\n * @notice Retrieves the stored value\n * @param self Storage slot\n * @return value Stored bool value\n */\n function read(BoolStorage self) internal view returns (bool value) {\n assembly {\n value := sload(self)\n }\n }\n\n /**\n * @notice Stores the value at the specific slot\n * @param self Storage slot\n * @param value boolean value to store\n */\n function store(BoolStorage self, bool value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n\n/**\n * @title Uint256StorageLib\n * @notice Library to manage storage and retrival of an uint256 at a fixed storage slot\n */\nlibrary Uint256StorageLib {\n /**\n * @notice Retrieves the stored value\n * @param self Storage slot\n * @return value Stored uint256 value\n */\n function read(Uint256Storage self) internal view returns (uint256 value) {\n assembly {\n value := sload(self)\n }\n }\n\n /**\n * @notice Stores the value at the specific slot\n * @param self Storage slot\n * @param value uint256 value to store\n */\n function store(Uint256Storage self, uint256 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n\n/**\n * @title Int256StorageLib\n * @notice Library to manage storage and retrival of an int256 at a fixed storage slot\n */\nlibrary Int256StorageLib {\n /**\n * @notice Retrieves the stored value\n * @param self Storage slot\n * @return value Stored int256 value\n */\n function read(Int256Storage self) internal view returns (int256 value) {\n assembly {\n value := sload(self)\n }\n }\n\n /**\n * @notice Stores the value at the specific slot\n * @param self Storage slot\n * @param value int256 value to store\n */\n function store(Int256Storage self, int256 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n\n/**\n * @title AddressStorageLib\n * @notice Library to manage storage and retrival of an address at a fixed storage slot\n */\nlibrary AddressStorageLib {\n /**\n * @notice Retrieves the stored value\n * @param self Storage slot\n * @return value Stored address value\n */\n function read(AddressStorage self) internal view returns (address value) {\n assembly {\n value := sload(self)\n }\n }\n\n /**\n * @notice Stores the value at the specific slot\n * @param self Storage slot\n * @param value address value to store\n */\n function store(AddressStorage self, address value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n\n/**\n * @title Bytes32StorageLib\n * @notice Library to manage storage and retrival of a bytes32 at a fixed storage slot\n */\nlibrary Bytes32StorageLib {\n /**\n * @notice Retrieves the stored value\n * @param self Storage slot\n * @return value Stored bytes32 value\n */\n function read(Bytes32Storage self) internal view returns (bytes32 value) {\n assembly {\n value := sload(self)\n }\n }\n\n /**\n * @notice Stores the value at the specific slot\n * @param self Storage slot\n * @param value bytes32 value to store\n */\n function store(Bytes32Storage self, bytes32 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "@equilibria/root/number/types/UFixed18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"./Fixed18.sol\";\nimport \"./PackedUFixed18.sol\";\n\n/// @dev UFixed18 type\ntype UFixed18 is uint256;\nusing UFixed18Lib for UFixed18 global;\ntype UFixed18Storage is bytes32;\nusing UFixed18StorageLib for UFixed18Storage global;\n\n/**\n * @title UFixed18Lib\n * @notice Library for the unsigned fixed-decimal type.\n */\nlibrary UFixed18Lib {\n error UFixed18UnderflowError(int256 value);\n error UFixed18PackingOverflowError(uint256 value);\n\n uint256 private constant BASE = 1e18;\n UFixed18 public constant ZERO = UFixed18.wrap(0);\n UFixed18 public constant ONE = UFixed18.wrap(BASE);\n UFixed18 public constant MAX = UFixed18.wrap(type(uint256).max);\n\n /**\n * @notice Creates a unsigned fixed-decimal from a signed fixed-decimal\n * @param a Signed fixed-decimal\n * @return New unsigned fixed-decimal\n */\n function from(Fixed18 a) internal pure returns (UFixed18) {\n int256 value = Fixed18.unwrap(a);\n if (value < 0) revert UFixed18UnderflowError(value);\n return UFixed18.wrap(uint256(value));\n }\n\n /**\n * @notice Creates a unsigned fixed-decimal from a unsigned integer\n * @param a Unsigned number\n * @return New unsigned fixed-decimal\n */\n function from(uint256 a) internal pure returns (UFixed18) {\n return UFixed18.wrap(a * BASE);\n }\n\n /**\n * @notice Creates a packed unsigned fixed-decimal from an unsigned fixed-decimal\n * @param a unsigned fixed-decimal\n * @return New packed unsigned fixed-decimal\n */\n function pack(UFixed18 a) internal pure returns (PackedUFixed18) {\n uint256 value = UFixed18.unwrap(a);\n if (value > type(uint128).max) revert UFixed18PackingOverflowError(value);\n return PackedUFixed18.wrap(uint128(value));\n }\n\n /**\n * @notice Returns whether the unsigned fixed-decimal is equal to zero.\n * @param a Unsigned fixed-decimal\n * @return Whether the unsigned fixed-decimal is zero.\n */\n function isZero(UFixed18 a) internal pure returns (bool) {\n return UFixed18.unwrap(a) == 0;\n }\n\n /**\n * @notice Adds two unsigned fixed-decimals `a` and `b` together\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Resulting summed unsigned fixed-decimal\n */\n function add(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) + UFixed18.unwrap(b));\n }\n\n /**\n * @notice Subtracts unsigned fixed-decimal `b` from `a`\n * @param a Unsigned fixed-decimal to subtract from\n * @param b Unsigned fixed-decimal to subtract\n * @return Resulting subtracted unsigned fixed-decimal\n */\n function sub(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) - UFixed18.unwrap(b));\n }\n\n /**\n * @notice Multiplies two unsigned fixed-decimals `a` and `b` together\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Resulting multiplied unsigned fixed-decimal\n */\n function mul(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / BASE);\n }\n\n /**\n * @notice Divides unsigned fixed-decimal `a` by `b`\n * @param a Unsigned fixed-decimal to divide\n * @param b Unsigned fixed-decimal to divide by\n * @return Resulting divided unsigned fixed-decimal\n */\n function div(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) * BASE / UFixed18.unwrap(b));\n }\n\n /**\n * @notice Divides unsigned fixed-decimal `a` by `b`\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0` and `MAX` for `n/0`.\n * @param a Unsigned fixed-decimal to divide\n * @param b Unsigned fixed-decimal to divide by\n * @return Resulting divided unsigned fixed-decimal\n */\n function unsafeDiv(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n if (isZero(b)) {\n return isZero(a) ? ONE : MAX;\n } else {\n return div(a, b);\n }\n }\n\n /**\n * @notice Computes a * b / c without loss of precision due to BASE conversion\n * @param a First unsigned fixed-decimal\n * @param b Unsigned number to multiply by\n * @param c Unsigned number to divide by\n * @return Resulting computation\n */\n function muldiv(UFixed18 a, uint256 b, uint256 c) internal pure returns (UFixed18) {\n return muldiv(a, UFixed18.wrap(b), UFixed18.wrap(c));\n }\n\n /**\n * @notice Computes a * b / c without loss of precision due to BASE conversion\n * @param a First unsigned fixed-decimal\n * @param b Unsigned fixed-decimal to multiply by\n * @param c Unsigned fixed-decimal to divide by\n * @return Resulting computation\n */\n function muldiv(UFixed18 a, UFixed18 b, UFixed18 c) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / UFixed18.unwrap(c));\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is equal to `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is equal to `b`\n */\n function eq(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return compare(a, b) == 1;\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is greater than `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is greater than `b`\n */\n function gt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return compare(a, b) == 2;\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is less than `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is less than `b`\n */\n function lt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return compare(a, b) == 0;\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is greater than or equal to `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is greater than or equal to `b`\n */\n function gte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return gt(a, b) || eq(a, b);\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is less than or equal to `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is less than or equal to `b`\n */\n function lte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return lt(a, b) || eq(a, b);\n }\n\n /**\n * @notice Compares the unsigned fixed-decimals `a` and `b`\n * @dev Returns: 2 for greater than\n * 1 for equal to\n * 0 for less than\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Compare result of `a` and `b`\n */\n function compare(UFixed18 a, UFixed18 b) internal pure returns (uint256) {\n (uint256 au, uint256 bu) = (UFixed18.unwrap(a), UFixed18.unwrap(b));\n if (au > bu) return 2;\n if (au < bu) return 0;\n return 1;\n }\n\n /**\n * @notice Returns a unsigned fixed-decimal representing the ratio of `a` over `b`\n * @param a First unsigned number\n * @param b Second unsigned number\n * @return Ratio of `a` over `b`\n */\n function ratio(uint256 a, uint256 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(a * BASE / b);\n }\n\n /**\n * @notice Returns the minimum of unsigned fixed-decimals `a` and `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Minimum of `a` and `b`\n */\n function min(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(Math.min(UFixed18.unwrap(a), UFixed18.unwrap(b)));\n }\n\n /**\n * @notice Returns the maximum of unsigned fixed-decimals `a` and `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Maximum of `a` and `b`\n */\n function max(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(Math.max(UFixed18.unwrap(a), UFixed18.unwrap(b)));\n }\n\n /**\n * @notice Converts the unsigned fixed-decimal into an integer, truncating any decimal portion\n * @param a Unsigned fixed-decimal\n * @return Truncated unsigned number\n */\n function truncate(UFixed18 a) internal pure returns (uint256) {\n return UFixed18.unwrap(a) / BASE;\n }\n}\n\nlibrary UFixed18StorageLib {\n function read(UFixed18Storage self) internal view returns (UFixed18 value) {\n assembly {\n value := sload(self)\n }\n }\n\n function store(UFixed18Storage self, UFixed18 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return 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 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 up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a / b + (a % b == 0 ? 0 : 1);\n }\n}\n" - }, - "@equilibria/root/number/types/Fixed18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/SignedMath.sol\";\nimport \"./UFixed18.sol\";\nimport \"./PackedFixed18.sol\";\n\n/// @dev Fixed18 type\ntype Fixed18 is int256;\nusing Fixed18Lib for Fixed18 global;\ntype Fixed18Storage is bytes32;\nusing Fixed18StorageLib for Fixed18Storage global;\n\n/**\n * @title Fixed18Lib\n * @notice Library for the signed fixed-decimal type.\n */\nlibrary Fixed18Lib {\n error Fixed18OverflowError(uint256 value);\n error Fixed18PackingOverflowError(int256 value);\n error Fixed18PackingUnderflowError(int256 value);\n\n int256 private constant BASE = 1e18;\n Fixed18 public constant ZERO = Fixed18.wrap(0);\n Fixed18 public constant ONE = Fixed18.wrap(BASE);\n Fixed18 public constant NEG_ONE = Fixed18.wrap(-1 * BASE);\n Fixed18 public constant MAX = Fixed18.wrap(type(int256).max);\n Fixed18 public constant MIN = Fixed18.wrap(type(int256).min);\n\n /**\n * @notice Creates a signed fixed-decimal from an unsigned fixed-decimal\n * @param a Unsigned fixed-decimal\n * @return New signed fixed-decimal\n */\n function from(UFixed18 a) internal pure returns (Fixed18) {\n uint256 value = UFixed18.unwrap(a);\n if (value > uint256(type(int256).max)) revert Fixed18OverflowError(value);\n return Fixed18.wrap(int256(value));\n }\n\n /**\n * @notice Creates a signed fixed-decimal from a sign and an unsigned fixed-decimal\n * @param s Sign\n * @param m Unsigned fixed-decimal magnitude\n * @return New signed fixed-decimal\n */\n function from(int256 s, UFixed18 m) internal pure returns (Fixed18) {\n if (s > 0) return from(m);\n if (s < 0) return Fixed18.wrap(-1 * Fixed18.unwrap(from(m)));\n return ZERO;\n }\n\n /**\n * @notice Creates a signed fixed-decimal from a signed integer\n * @param a Signed number\n * @return New signed fixed-decimal\n */\n function from(int256 a) internal pure returns (Fixed18) {\n return Fixed18.wrap(a * BASE);\n }\n\n /**\n * @notice Creates a packed signed fixed-decimal from an signed fixed-decimal\n * @param a signed fixed-decimal\n * @return New packed signed fixed-decimal\n */\n function pack(Fixed18 a) internal pure returns (PackedFixed18) {\n int256 value = Fixed18.unwrap(a);\n if (value > type(int128).max) revert Fixed18PackingOverflowError(value);\n if (value < type(int128).min) revert Fixed18PackingUnderflowError(value);\n return PackedFixed18.wrap(int128(value));\n }\n\n /**\n * @notice Returns whether the signed fixed-decimal is equal to zero.\n * @param a Signed fixed-decimal\n * @return Whether the signed fixed-decimal is zero.\n */\n function isZero(Fixed18 a) internal pure returns (bool) {\n return Fixed18.unwrap(a) == 0;\n }\n\n /**\n * @notice Adds two signed fixed-decimals `a` and `b` together\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Resulting summed signed fixed-decimal\n */\n function add(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) + Fixed18.unwrap(b));\n }\n\n /**\n * @notice Subtracts signed fixed-decimal `b` from `a`\n * @param a Signed fixed-decimal to subtract from\n * @param b Signed fixed-decimal to subtract\n * @return Resulting subtracted signed fixed-decimal\n */\n function sub(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) - Fixed18.unwrap(b));\n }\n\n /**\n * @notice Multiplies two signed fixed-decimals `a` and `b` together\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Resulting multiplied signed fixed-decimal\n */\n function mul(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / BASE);\n }\n\n /**\n * @notice Divides signed fixed-decimal `a` by `b`\n * @param a Signed fixed-decimal to divide\n * @param b Signed fixed-decimal to divide by\n * @return Resulting divided signed fixed-decimal\n */\n function div(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) * BASE / Fixed18.unwrap(b));\n }\n\n /**\n * @notice Divides unsigned fixed-decimal `a` by `b`\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0`, `MAX` for `n/0`, and `MIN` for `-n/0`.\n * @param a Unsigned fixed-decimal to divide\n * @param b Unsigned fixed-decimal to divide by\n * @return Resulting divided unsigned fixed-decimal\n */\n function unsafeDiv(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n if (isZero(b)) {\n if (gt(a, ZERO)) return MAX;\n if (lt(a, ZERO)) return MIN;\n return ONE;\n } else {\n return div(a, b);\n }\n }\n\n /**\n * @notice Computes a * b / c without loss of precision due to BASE conversion\n * @param a First signed fixed-decimal\n * @param b Signed number to multiply by\n * @param c Signed number to divide by\n * @return Resulting computation\n */\n function muldiv(Fixed18 a, int256 b, int256 c) internal pure returns (Fixed18) {\n return muldiv(a, Fixed18.wrap(b), Fixed18.wrap(c));\n }\n\n /**\n * @notice Computes a * b / c without loss of precision due to BASE conversion\n * @param a First signed fixed-decimal\n * @param b Signed fixed-decimal to multiply by\n * @param c Signed fixed-decimal to divide by\n * @return Resulting computation\n */\n function muldiv(Fixed18 a, Fixed18 b, Fixed18 c) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / Fixed18.unwrap(c));\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is equal to `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is equal to `b`\n */\n function eq(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return compare(a, b) == 1;\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is greater than `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is greater than `b`\n */\n function gt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return compare(a, b) == 2;\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is less than `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is less than `b`\n */\n function lt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return compare(a, b) == 0;\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is greater than or equal to `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is greater than or equal to `b`\n */\n function gte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return gt(a, b) || eq(a, b);\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is less than or equal to `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is less than or equal to `b`\n */\n function lte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return lt(a, b) || eq(a, b);\n }\n\n /**\n * @notice Compares the signed fixed-decimals `a` and `b`\n * @dev Returns: 2 for greater than\n * 1 for equal to\n * 0 for less than\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Compare result of `a` and `b`\n */\n function compare(Fixed18 a, Fixed18 b) internal pure returns (uint256) {\n (int256 au, int256 bu) = (Fixed18.unwrap(a), Fixed18.unwrap(b));\n if (au > bu) return 2;\n if (au < bu) return 0;\n return 1;\n }\n\n /**\n * @notice Returns a signed fixed-decimal representing the ratio of `a` over `b`\n * @param a First signed number\n * @param b Second signed number\n * @return Ratio of `a` over `b`\n */\n function ratio(int256 a, int256 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(a * BASE / b);\n }\n\n /**\n * @notice Returns the minimum of signed fixed-decimals `a` and `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Minimum of `a` and `b`\n */\n function min(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(SignedMath.min(Fixed18.unwrap(a), Fixed18.unwrap(b)));\n }\n\n /**\n * @notice Returns the maximum of signed fixed-decimals `a` and `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Maximum of `a` and `b`\n */\n function max(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(SignedMath.max(Fixed18.unwrap(a), Fixed18.unwrap(b)));\n }\n\n /**\n * @notice Converts the signed fixed-decimal into an integer, truncating any decimal portion\n * @param a Signed fixed-decimal\n * @return Truncated signed number\n */\n function truncate(Fixed18 a) internal pure returns (int256) {\n return Fixed18.unwrap(a) / BASE;\n }\n\n /**\n * @notice Returns the sign of the signed fixed-decimal\n * @dev Returns: -1 for negative\n * 0 for zero\n * 1 for positive\n * @param a Signed fixed-decimal\n * @return Sign of the signed fixed-decimal\n */\n function sign(Fixed18 a) internal pure returns (int256) {\n if (Fixed18.unwrap(a) > 0) return 1;\n if (Fixed18.unwrap(a) < 0) return -1;\n return 0;\n }\n\n /**\n * @notice Returns the absolute value of the signed fixed-decimal\n * @param a Signed fixed-decimal\n * @return Absolute value of the signed fixed-decimal\n */\n function abs(Fixed18 a) internal pure returns (UFixed18) {\n return UFixed18.wrap(SignedMath.abs(Fixed18.unwrap(a)));\n }\n}\n\nlibrary Fixed18StorageLib {\n function read(Fixed18Storage self) internal view returns (Fixed18 value) {\n assembly {\n value := sload(self)\n }\n }\n\n function store(Fixed18Storage self, Fixed18 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "@equilibria/root/number/types/PackedUFixed18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"./UFixed18.sol\";\n\n/// @dev PackedUFixed18 type\ntype PackedUFixed18 is uint128;\nusing PackedUFixed18Lib for PackedUFixed18 global;\n\n/**\n * @title PackedUFixed18Lib\n * @dev A packed version of the UFixed18 which takes up half the storage space (two PackedUFixed18 can be packed\n * into a single slot). Only valid within the range 0 <= x <= 3.4028237e+20.\n * @notice Library for the packed unsigned fixed-decimal type.\n */\nlibrary PackedUFixed18Lib {\n PackedUFixed18 public constant MAX = PackedUFixed18.wrap(type(uint128).max);\n\n /**\n * @notice Creates an unpacked unsigned fixed-decimal from a packed unsigned fixed-decimal\n * @param self packed unsigned fixed-decimal\n * @return New unpacked unsigned fixed-decimal\n */\n function unpack(PackedUFixed18 self) internal pure returns (UFixed18) {\n return UFixed18.wrap(uint256(PackedUFixed18.unwrap(self)));\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/SignedMath.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n /**\n * @dev Returns the largest of two signed numbers.\n */\n function max(int256 a, int256 b) internal pure returns (int256) {\n return 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 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 // must be unchecked in order to support `n = type(int256).min`\n return uint256(n >= 0 ? n : -n);\n }\n }\n}\n" - }, - "@equilibria/root/number/types/PackedFixed18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"./Fixed18.sol\";\n\n/// @dev PackedFixed18 type\ntype PackedFixed18 is int128;\nusing PackedFixed18Lib for PackedFixed18 global;\n\n/**\n * @title PackedFixed18Lib\n * @dev A packed version of the Fixed18 which takes up half the storage space (two PackedFixed18 can be packed\n * into a single slot). Only valid within the range -1.7014118e+20 <= x <= 1.7014118e+20.\n * @notice Library for the packed signed fixed-decimal type.\n */\nlibrary PackedFixed18Lib {\n PackedFixed18 public constant MAX = PackedFixed18.wrap(type(int128).max);\n PackedFixed18 public constant MIN = PackedFixed18.wrap(type(int128).min);\n\n /**\n * @notice Creates an unpacked signed fixed-decimal from a packed signed fixed-decimal\n * @param self packed signed fixed-decimal\n * @return New unpacked signed fixed-decimal\n */\n function unpack(PackedFixed18 self) internal pure returns (Fixed18) {\n return Fixed18.wrap(int256(PackedFixed18.unwrap(self)));\n }\n}\n" - }, - "@equilibria/root/token/types/Token18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"../../number/types/UFixed18.sol\";\n\n/// @dev Token18\ntype Token18 is address;\nusing Token18Lib for Token18 global;\ntype Token18Storage is bytes32;\nusing Token18StorageLib for Token18Storage global;\n\n/**\n * @title Token18Lib\n * @notice Library to manage 18-decimal ERC20s that is compliant with the fixed-decimal types.\n * @dev Maintains significant gas savings over other Token implementations since no conversion take place\n */\nlibrary Token18Lib {\n using SafeERC20 for IERC20;\n\n Token18 public constant ZERO = Token18.wrap(address(0));\n\n /**\n * @notice Returns whether a token is the zero address\n * @param self Token to check for\n * @return Whether the token is the zero address\n */\n function isZero(Token18 self) internal pure returns (bool) {\n return Token18.unwrap(self) == Token18.unwrap(ZERO);\n }\n\n /**\n * @notice Returns whether the two tokens are equal\n * @param a First token to compare\n * @param b Second token to compare\n * @return Whether the two tokens are equal\n */\n function eq(Token18 a, Token18 b) internal pure returns (bool) {\n return Token18.unwrap(a) == Token18.unwrap(b);\n }\n\n /**\n * @notice Approves `grantee` to spend infinite tokens from the caller\n * @param self Token to transfer\n * @param grantee Address to allow spending\n */\n function approve(Token18 self, address grantee) internal {\n IERC20(Token18.unwrap(self)).safeApprove(grantee, type(uint256).max);\n }\n\n /**\n * @notice Approves `grantee` to spend `amount` tokens from the caller\n * @dev There are important race conditions to be aware of when using this function\n with values other than 0. This will revert if moving from non-zero to non-zero amounts\n See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/a55b7d13722e7ce850b626da2313f3e66ca1d101/contracts/token/ERC20/IERC20.sol#L57\n * @param self Token to transfer\n * @param grantee Address to allow spending\n * @param amount Amount of tokens to approve to spend\n */\n function approve(Token18 self, address grantee, UFixed18 amount) internal {\n IERC20(Token18.unwrap(self)).safeApprove(grantee, UFixed18.unwrap(amount));\n }\n\n /**\n * @notice Transfers all held tokens from the caller to the `recipient`\n * @param self Token to transfer\n * @param recipient Address to receive the tokens\n */\n function push(Token18 self, address recipient) internal {\n push(self, recipient, balanceOf(self, address(this)));\n }\n\n /**\n * @notice Transfers `amount` tokens from the caller to the `recipient`\n * @param self Token to transfer\n * @param recipient Address to transfer tokens to\n * @param amount Amount of tokens to transfer\n */\n function push(Token18 self, address recipient, UFixed18 amount) internal {\n IERC20(Token18.unwrap(self)).safeTransfer(recipient, UFixed18.unwrap(amount));\n }\n\n /**\n * @notice Transfers `amount` tokens from the `benefactor` to the caller\n * @dev Reverts if trying to pull Ether\n * @param self Token to transfer\n * @param benefactor Address to transfer tokens from\n * @param amount Amount of tokens to transfer\n */\n function pull(Token18 self, address benefactor, UFixed18 amount) internal {\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, address(this), UFixed18.unwrap(amount));\n }\n\n /**\n * @notice Transfers `amount` tokens from the `benefactor` to `recipient`\n * @dev Reverts if trying to pull Ether\n * @param self Token to transfer\n * @param benefactor Address to transfer tokens from\n * @param recipient Address to transfer tokens to\n * @param amount Amount of tokens to transfer\n */\n function pullTo(Token18 self, address benefactor, address recipient, UFixed18 amount) internal {\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, recipient, UFixed18.unwrap(amount));\n }\n\n /**\n * @notice Returns the name of the token\n * @param self Token to check for\n * @return Token name\n */\n function name(Token18 self) internal view returns (string memory) {\n return IERC20Metadata(Token18.unwrap(self)).name();\n }\n\n /**\n * @notice Returns the symbol of the token\n * @param self Token to check for\n * @return Token symbol\n */\n function symbol(Token18 self) internal view returns (string memory) {\n return IERC20Metadata(Token18.unwrap(self)).symbol();\n }\n\n /**\n * @notice Returns the `self` token balance of the caller\n * @param self Token to check for\n * @return Token balance of the caller\n */\n function balanceOf(Token18 self) internal view returns (UFixed18) {\n return balanceOf(self, address(this));\n }\n\n /**\n * @notice Returns the `self` token balance of `account`\n * @param self Token to check for\n * @param account Account to check\n * @return Token balance of the account\n */\n function balanceOf(Token18 self, address account) internal view returns (UFixed18) {\n return UFixed18.wrap(IERC20(Token18.unwrap(self)).balanceOf(account));\n }\n}\n\nlibrary Token18StorageLib {\n function read(Token18Storage self) internal view returns (Token18 value) {\n assembly {\n value := sload(self)\n }\n }\n\n function store(Token18Storage self, Token18 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "contracts/interfaces/IController.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\";\nimport \"./ICollateral.sol\";\nimport \"./IIncentivizer.sol\";\nimport \"./IProduct.sol\";\nimport \"./types/PayoffDefinition.sol\";\n\ninterface IController {\n /// @dev Coordinator of a one or many products\n struct Coordinator {\n /// @dev Pending owner of the product, can accept ownership\n address pendingOwner;\n\n /// @dev Owner of the product, allowed to update select parameters\n address owner;\n\n /// @dev Treasury of the product, collects fees\n address treasury;\n }\n\n event CollateralUpdated(ICollateral newCollateral);\n event IncentivizerUpdated(IIncentivizer newIncentivizer);\n event ProductBeaconUpdated(IBeacon newProductBeacon);\n event ProtocolFeeUpdated(UFixed18 newProtocolFee);\n event MinFundingFeeUpdated(UFixed18 newMinFundingFee);\n event LiquidationFeeUpdated(UFixed18 newLiquidationFee);\n event IncentivizationFeeUpdated(UFixed18 newIncentivizationFee);\n event MinCollateralUpdated(UFixed18 newMinCollateral);\n event ProgramsPerProductUpdated(uint256 newProgramsPerProduct);\n event PauserUpdated(address newPauser);\n event PausedUpdated(bool newPaused);\n event CoordinatorPendingOwnerUpdated(uint256 indexed coordinatorId, address newPendingOwner);\n event CoordinatorOwnerUpdated(uint256 indexed coordinatorId, address newOwner);\n event CoordinatorTreasuryUpdated(uint256 indexed coordinatorId, address newTreasury);\n event CoordinatorCreated(uint256 indexed coordinatorId, address owner);\n event ProductCreated(IProduct indexed product, IProduct.ProductInfo productInfo);\n\n error ControllerNoZeroCoordinatorError();\n error ControllerNotPauserError();\n error ControllerNotOwnerError(uint256 controllerId);\n error ControllerNotPendingOwnerError(uint256 controllerId);\n error ControllerInvalidProtocolFeeError();\n error ControllerInvalidMinFundingFeeError();\n error ControllerInvalidLiquidationFeeError();\n error ControllerInvalidIncentivizationFeeError();\n error ControllerNotContractAddressError();\n\n function collateral() external view returns (ICollateral);\n function incentivizer() external view returns (IIncentivizer);\n function productBeacon() external view returns (IBeacon);\n function coordinators(uint256 collateralId) external view returns (Coordinator memory);\n function coordinatorFor(IProduct product) external view returns (uint256);\n function protocolFee() external view returns (UFixed18);\n function minFundingFee() external view returns (UFixed18);\n function liquidationFee() external view returns (UFixed18);\n function incentivizationFee() external view returns (UFixed18);\n function minCollateral() external view returns (UFixed18);\n function programsPerProduct() external view returns (uint256);\n function pauser() external view returns (address);\n function paused() external view returns (bool);\n function initialize(ICollateral collateral_, IIncentivizer incentivizer_, IBeacon productBeacon_) external;\n function createCoordinator() external returns (uint256);\n function updateCoordinatorPendingOwner(uint256 coordinatorId, address newPendingOwner) external;\n function acceptCoordinatorOwner(uint256 coordinatorId) external;\n function updateCoordinatorTreasury(uint256 coordinatorId, address newTreasury) external;\n function createProduct(uint256 coordinatorId, IProduct.ProductInfo calldata productInfo) external returns (IProduct);\n function updateCollateral(ICollateral newCollateral) external;\n function updateIncentivizer(IIncentivizer newIncentivizer) external;\n function updateProductBeacon(IBeacon newProductBeacon) external;\n function updateProtocolFee(UFixed18 newProtocolFee) external;\n function updateMinFundingFee(UFixed18 newMinFundingFee) external;\n function updateLiquidationFee(UFixed18 newLiquidationFee) external;\n function updateIncentivizationFee(UFixed18 newIncentivizationFee) external;\n function updateMinCollateral(UFixed18 newMinCollateral) external;\n function updateProgramsPerProduct(uint256 newProductsPerProduct) external;\n function updatePauser(address newPauser) external;\n function updatePaused(bool newPaused) external;\n function isProduct(IProduct product) external view returns (bool);\n function owner() external view returns (address);\n function owner(uint256 coordinatorId) external view returns (address);\n function owner(IProduct product) external view returns (address);\n function treasury() external view returns (address);\n function treasury(uint256 coordinatorId) external view returns (address);\n function treasury(IProduct product) external view returns (address);\n}\n" - }, - "contracts/interfaces/IProduct.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\";\nimport \"./IPayoffProvider.sol\";\nimport \"./IParamProvider.sol\";\nimport \"./types/PayoffDefinition.sol\";\nimport \"./types/Position.sol\";\nimport \"./types/PrePosition.sol\";\nimport \"./types/Accumulator.sol\";\n\ninterface IProduct is IPayoffProvider, IParamProvider {\n /// @dev Product Creation parameters\n struct ProductInfo {\n /// @dev name of the product\n string name;\n\n /// @dev symbol of the product\n string symbol;\n\n /// @dev product payoff definition\n PayoffDefinition payoffDefinition;\n\n /// @dev oracle address\n IOracleProvider oracle;\n\n /// @dev product maintenance ratio\n UFixed18 maintenance;\n\n /// @dev product funding fee\n UFixed18 fundingFee;\n\n /// @dev product maker fee\n UFixed18 makerFee;\n\n /// @dev product taker fee\n UFixed18 takerFee;\n\n /// @dev product maker limit\n UFixed18 makerLimit;\n\n /// @dev utulization curve definition\n JumpRateUtilizationCurve utilizationCurve;\n }\n\n event Settle(uint256 preVersion, uint256 toVersion);\n event AccountSettle(address indexed account, uint256 preVersion, uint256 toVersion);\n event MakeOpened(address indexed account, uint256 version, UFixed18 amount);\n event TakeOpened(address indexed account, uint256 version, UFixed18 amount);\n event MakeClosed(address indexed account, uint256 version, UFixed18 amount);\n event TakeClosed(address indexed account, uint256 version, UFixed18 amount);\n event ClosedUpdated(bool indexed newClosed, uint256 version);\n\n error ProductInsufficientLiquidityError(UFixed18 socializationFactor);\n error ProductDoubleSidedError();\n error ProductOverClosedError();\n error ProductInsufficientCollateralError();\n error ProductInLiquidationError();\n error ProductMakerOverLimitError();\n error ProductOracleBootstrappingError();\n error ProductNotOwnerError();\n error ProductInvalidOracle();\n error ProductClosedError();\n\n function name() external view returns (string memory);\n function symbol() external view returns (string memory);\n function initialize(ProductInfo calldata productInfo_) external;\n function settle() external;\n function settleAccount(address account) external;\n function openTake(UFixed18 amount) external;\n function closeTake(UFixed18 amount) external;\n function openMake(UFixed18 amount) external;\n function closeMake(UFixed18 amount) external;\n function closeAll(address account) external;\n function maintenance(address account) external view returns (UFixed18);\n function maintenanceNext(address account) external view returns (UFixed18);\n function isClosed(address account) external view returns (bool);\n function isLiquidating(address account) external view returns (bool);\n function position(address account) external view returns (Position memory);\n function pre(address account) external view returns (PrePosition memory);\n function latestVersion() external view returns (uint256);\n function positionAtVersion(uint256 oracleVersion) external view returns (Position memory);\n function pre() external view returns (PrePosition memory);\n function valueAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\n function shareAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\n function latestVersion(address account) external view returns (uint256);\n function rate(Position memory position) external view returns (Fixed18);\n function closed() external view returns (bool);\n function updateClosed(bool newClosed) external;\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/IERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\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 amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` 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(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\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" - }, - "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 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 using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\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 function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" - }, - "@openzeppelin/contracts/proxy/beacon/IBeacon.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n" - }, - "contracts/interfaces/IIncentivizer.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"./types/ProgramInfo.sol\";\nimport \"./IController.sol\";\nimport \"./IProduct.sol\";\n\ninterface IIncentivizer {\n event ProgramCreated(IProduct indexed product, uint256 indexed programId, ProgramInfo programInfo, UFixed18 programFeeAmount);\n event ProgramStarted(IProduct indexed product, uint256 indexed programId, uint256 version);\n event ProgramComplete(IProduct indexed product, uint256 indexed programId, uint256 version);\n event Claim(IProduct indexed product, address indexed account, uint256 indexed programId, UFixed18 amount);\n event FeeClaim(Token18 indexed token, UFixed18 amount);\n\n error IncentivizerNotAllowedError(IProduct product);\n error IncentivizerTooManyProgramsError();\n error IncentivizerNotProgramOwnerError(IProduct product, uint256 programId);\n error IncentivizerInvalidProgramError(IProduct product, uint256 programId);\n error IncentivizerBatchClaimArgumentMismatchError();\n\n function programInfos(IProduct product, uint256 programId) external view returns (ProgramInfo memory);\n function fees(Token18 token) external view returns (UFixed18);\n function initialize(IController controller_) external;\n function create(IProduct product, ProgramInfo calldata info) external returns (uint256);\n function complete(IProduct product, uint256 programId) external;\n function sync(IOracleProvider.OracleVersion memory currentOracleVersion) external;\n function syncAccount(address account, IOracleProvider.OracleVersion memory currentOracleVersion) external;\n function claim(IProduct product, uint256[] calldata programIds) external;\n function claim(IProduct[] calldata products, uint256[][] calldata programIds) external;\n function claimFee(Token18[] calldata tokens) external;\n function active(IProduct product) external view returns (uint256);\n function count(IProduct product) external view returns (uint256);\n function unclaimed(IProduct product, address account, uint256 programId) external view returns (UFixed18);\n function available(IProduct product, uint256 programId) external view returns (UFixed18);\n function versionStarted(IProduct product, uint256 programId) external view returns (uint256);\n function versionComplete(IProduct product, uint256 programId) external view returns (uint256);\n function owner(IProduct product, uint256 programId) external view returns (address);\n function treasury(IProduct product, uint256 programId) external view returns (address);\n}\n" - }, - "contracts/interfaces/types/PayoffDefinition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"../../interfaces/IContractPayoffProvider.sol\";\n\n/// @dev PayoffDefinition tyoe\nstruct PayoffDefinition {\n PayoffDefinitionLib.PayoffType payoffType;\n PayoffDefinitionLib.PayoffDirection payoffDirection;\n bytes30 data;\n}\nusing PayoffDefinitionLib for PayoffDefinition global;\ntype PayoffDefinitionStorage is bytes32;\nusing PayoffDefinitionStorageLib for PayoffDefinitionStorage global;\n\n/**\n * @title PayoffDefinitionLib\n * @dev Library that surfaces logic for PayoffDefinition type functionality\n * @notice Library for the PayoffDefinition type. Performs validity and price transformation\n based on the payoff definition type.\n */\nlibrary PayoffDefinitionLib {\n using Address for address;\n\n error PayoffDefinitionUnsupportedTransform(PayoffType payoffType, PayoffDirection payoffDirection);\n error PayoffDefinitionNotContract(PayoffType payoffType, bytes30 data);\n\n /// @dev Payoff function type enum\n enum PayoffType { PASSTHROUGH, CONTRACT }\n enum PayoffDirection { LONG, SHORT }\n\n /**\n * @notice Checks validity of the payoff definition\n * @param self a payoff definition\n * @return Whether the payoff definition is valid for it's given type\n */\n function valid(PayoffDefinition memory self) internal view returns (bool) {\n if (self.payoffType == PayoffType.CONTRACT) return address(_providerContract(self)).isContract();\n\n // All other payoff types should have no data\n return uint(bytes32(self.data)) == 0;\n }\n\n /**\n * @notice Transforms a price based on the payoff definition\n * @param self a payoff definition\n * @param price raw oracle price\n * @return Price transformed by the payoff definition function\n */\n function transform(\n PayoffDefinition memory self,\n Fixed18 price\n ) internal view returns (Fixed18) {\n PayoffType payoffType = self.payoffType;\n PayoffDirection payoffDirection = self.payoffDirection;\n Fixed18 transformedPrice;\n\n // First get the price depending on the type\n if (payoffType == PayoffType.PASSTHROUGH) transformedPrice = price;\n else if (payoffType == PayoffType.CONTRACT) transformedPrice = _payoffFromContract(self, price);\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\n\n // Then transform it depending on the direction flag\n if (self.payoffDirection == PayoffDirection.LONG) return transformedPrice;\n else if (self.payoffDirection == PayoffDirection.SHORT) return transformedPrice.mul(Fixed18Lib.NEG_ONE);\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\n }\n\n /**\n * @notice Parses the data field into an address\n * @dev Reverts if payoffType is not CONTRACT\n * @param self a payoff definition\n * @return IContractPayoffProvider address\n */\n function _providerContract(\n PayoffDefinition memory self\n ) private pure returns (IContractPayoffProvider) {\n if (self.payoffType != PayoffType.CONTRACT) revert PayoffDefinitionNotContract(self.payoffType, self.data);\n // Shift to pull the last 20 bytes, then cast to an address\n return IContractPayoffProvider(address(bytes20(self.data << 80)));\n }\n\n /**\n * @notice Performs a price transformation by calling the underlying payoff contract\n * @param self a payoff definition\n * @param price raw oracle price\n * @return Price transformed by the payoff definition function on the contract\n */\n function _payoffFromContract(\n PayoffDefinition memory self,\n Fixed18 price\n ) private view returns (Fixed18) {\n bytes memory ret = address(_providerContract(self)).functionStaticCall(\n abi.encodeCall(IContractPayoffProvider.payoff, price)\n );\n return Fixed18.wrap(abi.decode(ret, (int256)));\n }\n}\n\n/**\n * @title PayoffDefinitionStorageLib\n * @notice Library that surfaces storage read and writes for the PayoffDefinition type\n */\nlibrary PayoffDefinitionStorageLib {\n function read(PayoffDefinitionStorage self) internal view returns (PayoffDefinition memory) {\n return _storagePointer(self);\n }\n\n function store(PayoffDefinitionStorage self, PayoffDefinition memory value) internal {\n PayoffDefinition storage storagePointer = _storagePointer(self);\n\n storagePointer.payoffType = value.payoffType;\n storagePointer.payoffDirection = value.payoffDirection;\n storagePointer.data = value.data;\n }\n\n function _storagePointer(\n PayoffDefinitionStorage self\n ) private pure returns (PayoffDefinition storage pointer) {\n assembly { pointer.slot := self }\n }\n}\n" - }, - "@equilibria/root/curve/types/JumpRateUtilizationCurve.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"../CurveMath.sol\";\nimport \"../../number/types/PackedUFixed18.sol\";\nimport \"../../number/types/PackedFixed18.sol\";\n\n/// @dev JumpRateUtilizationCurve type\nstruct JumpRateUtilizationCurve {\n PackedFixed18 minRate;\n PackedFixed18 maxRate;\n PackedFixed18 targetRate;\n PackedUFixed18 targetUtilization;\n}\nusing JumpRateUtilizationCurveLib for JumpRateUtilizationCurve global;\ntype JumpRateUtilizationCurveStorage is bytes32;\nusing JumpRateUtilizationCurveStorageLib for JumpRateUtilizationCurveStorage global;\n\n/**\n * @title JumpRateUtilizationCurveLib\n * @notice Library for the Jump Rate utilization curve type\n */\nlibrary JumpRateUtilizationCurveLib {\n /**\n * @notice Computes the corresponding rate for a utilization ratio\n * @param utilization The utilization ratio\n * @return The corresponding rate\n */\n function compute(JumpRateUtilizationCurve memory self, UFixed18 utilization) internal pure returns (Fixed18) {\n UFixed18 targetUtilization = self.targetUtilization.unpack();\n if (utilization.lt(targetUtilization)) {\n return CurveMath.linearInterpolation(\n UFixed18Lib.ZERO,\n self.minRate.unpack(),\n targetUtilization,\n self.targetRate.unpack(),\n utilization\n );\n }\n if (utilization.lt(UFixed18Lib.ONE)) {\n return CurveMath.linearInterpolation(\n targetUtilization,\n self.targetRate.unpack(),\n UFixed18Lib.ONE,\n self.maxRate.unpack(),\n utilization\n );\n }\n return self.maxRate.unpack();\n }\n}\n\nlibrary JumpRateUtilizationCurveStorageLib {\n function read(JumpRateUtilizationCurveStorage self) internal view returns (JumpRateUtilizationCurve memory) {\n return _storagePointer(self);\n }\n\n function store(JumpRateUtilizationCurveStorage self, JumpRateUtilizationCurve memory value) internal {\n JumpRateUtilizationCurve storage storagePointer = _storagePointer(self);\n\n storagePointer.minRate = value.minRate;\n storagePointer.maxRate = value.maxRate;\n storagePointer.targetRate = value.targetRate;\n storagePointer.targetUtilization = value.targetUtilization;\n }\n\n function _storagePointer(JumpRateUtilizationCurveStorage self)\n private pure returns (JumpRateUtilizationCurve storage pointer) {\n assembly { pointer.slot := self }\n }\n}" - }, - "contracts/interfaces/IPayoffProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/Fixed18.sol\";\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"./types/PayoffDefinition.sol\";\n\ninterface IPayoffProvider {\n error PayoffProviderInvalidOracle();\n error PayoffProviderInvalidPayoffDefinitionError();\n\n function oracle() external view returns (IOracleProvider);\n function payoffDefinition() external view returns (PayoffDefinition memory);\n function currentVersion() external view returns (IOracleProvider.OracleVersion memory);\n function atVersion(uint256 oracleVersion) external view returns (IOracleProvider.OracleVersion memory);\n}\n" - }, - "contracts/interfaces/IParamProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\";\n\ninterface IParamProvider {\n event MaintenanceUpdated(UFixed18 newMaintenance);\n event FundingFeeUpdated(UFixed18 newFundingFee);\n event MakerFeeUpdated(UFixed18 newMakerFee);\n event TakerFeeUpdated(UFixed18 newTakerFee);\n event MakerLimitUpdated(UFixed18 newMakerLimit);\n event JumpRateUtilizationCurveUpdated(\n Fixed18 minRate,\n Fixed18 maxRate,\n Fixed18 targetRate,\n UFixed18 targetUtilization\n );\n\n error ParamProviderInvalidMakerFee();\n error ParamProviderInvalidTakerFee();\n error ParamProviderInvalidFundingFee();\n \n function maintenance() external view returns (UFixed18);\n function updateMaintenance(UFixed18 newMaintenance) external;\n function fundingFee() external view returns (UFixed18);\n function updateFundingFee(UFixed18 newFundingFee) external;\n function makerFee() external view returns (UFixed18);\n function updateMakerFee(UFixed18 newMakerFee) external;\n function takerFee() external view returns (UFixed18);\n function updateTakerFee(UFixed18 newTakerFee) external;\n function makerLimit() external view returns (UFixed18);\n function updateMakerLimit(UFixed18 newMakerLimit) external;\n function utilizationCurve() external view returns (JumpRateUtilizationCurve memory);\n function updateUtilizationCurve(JumpRateUtilizationCurve memory newUtilizationCurve) external;\n}\n" - }, - "contracts/interfaces/types/Position.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"../IProduct.sol\";\nimport \"./Accumulator.sol\";\nimport \"./PrePosition.sol\";\nimport \"./PackedPosition.sol\";\n\n/// @dev Position type\nstruct Position {\n /// @dev Quantity of the maker position\n UFixed18 maker;\n /// @dev Quantity of the taker position\n UFixed18 taker;\n}\nusing PositionLib for Position global;\n\n/**\n * @title PositionLib\n * @notice Library that surfaces math and settlement computations for the Position type.\n * @dev Positions track the current quantity of the account's maker and taker positions respectively\n * denominated as a unit of the product's payoff function.\n */\nlibrary PositionLib {\n /**\n * @notice Creates a packed position from an position\n * @param self A position\n * @return New packed position\n */\n function pack(Position memory self) internal pure returns (PackedPosition memory) {\n return PackedPosition({maker: self.maker.pack(), taker: self.taker.pack()});\n }\n\n /**\n * @notice Returns whether the position is fully empty\n * @param self A position\n * @return Whether the position is empty\n */\n function isEmpty(Position memory self) internal pure returns (bool) {\n return self.maker.isZero() && self.taker.isZero();\n }\n\n /**\n * @notice Adds position `a` and `b` together, returning the result\n * @param a The first position to sum\n * @param b The second position to sum\n * @return Resulting summed position\n */\n function add(Position memory a, Position memory b) internal pure returns (Position memory) {\n return Position({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\n }\n\n /**\n * @notice Subtracts position `b` from `a`, returning the result\n * @param a The position to subtract from\n * @param b The position to subtract\n * @return Resulting subtracted position\n */\n function sub(Position memory a, Position memory b) internal pure returns (Position memory) {\n return Position({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\n }\n\n /**\n * @notice Multiplies position `self` by accumulator `accumulator` and returns the resulting accumulator\n * @param self The Position to operate on\n * @param accumulator The accumulator to multiply by\n * @return Resulting multiplied accumulator\n */\n function mul(Position memory self, Accumulator memory accumulator) internal pure returns (Accumulator memory) {\n return Accumulator({\n maker: Fixed18Lib.from(self.maker).mul(accumulator.maker),\n taker: Fixed18Lib.from(self.taker).mul(accumulator.taker)\n });\n }\n\n /**\n * @notice Scales position `self` by fixed-decimal `scale` and returns the resulting position\n * @param self The Position to operate on\n * @param scale The Fixed-decimal to scale by\n * @return Resulting scaled position\n */\n function mul(Position memory self, UFixed18 scale) internal pure returns (Position memory) {\n return Position({maker: self.maker.mul(scale), taker: self.taker.mul(scale)});\n }\n\n /**\n * @notice Divides position `self` by `b` and returns the resulting accumulator\n * @param self The Position to operate on\n * @param b The number to divide by\n * @return Resulting divided accumulator\n */\n function div(Position memory self, uint256 b) internal pure returns (Accumulator memory) {\n return Accumulator({\n maker: Fixed18Lib.from(self.maker).div(Fixed18Lib.from(UFixed18Lib.from(b))),\n taker: Fixed18Lib.from(self.taker).div(Fixed18Lib.from(UFixed18Lib.from(b)))\n });\n }\n\n /**\n * @notice Returns the maximum of `self`'s maker and taker values\n * @param self The struct to operate on\n * @return Resulting maximum value\n */\n function max(Position memory self) internal pure returns (UFixed18) {\n return UFixed18Lib.max(self.maker, self.taker);\n }\n\n /**\n * @notice Sums the maker and taker together from a single position\n * @param self The struct to operate on\n * @return The sum of its maker and taker\n */\n function sum(Position memory self) internal pure returns (UFixed18) {\n return self.maker.add(self.taker);\n }\n\n /**\n * @notice Computes the next position after the pending-settlement position delta is included\n * @param self The current Position\n * @param pre The pending-settlement position delta\n * @return Next Position\n */\n function next(Position memory self, PrePosition memory pre) internal pure returns (Position memory) {\n return sub(add(self, pre.openPosition), pre.closePosition);\n }\n\n /**\n * @notice Returns the settled position at oracle version `toOracleVersion`\n * @dev Checks if a new position is ready to be settled based on the provided `toOracleVersion`\n * and `pre` and returns accordingly\n * @param self The current Position\n * @param pre The pending-settlement position delta\n * @param toOracleVersion The oracle version to settle to\n * @return Settled position at oracle version\n * @return Fee accrued from opening or closing the position\n * @return Whether a new position was settled\n */\n function settled(\n Position memory self,\n PrePosition memory pre,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal view returns (Position memory, UFixed18, bool) {\n return pre.canSettle(toOracleVersion) ? (next(self, pre), pre.computeFee(toOracleVersion), true) : (self, UFixed18Lib.ZERO, false);\n }\n\n /**\n * @notice Returns the socialization factor for the current position\n * @dev Socialization account for the case where `taker` > `maker` temporarily due to a liquidation\n * on the maker side. This dampens the taker's exposure pro-rata to ensure that the maker side\n * is never exposed over 1 x short.\n * @param self The Position to operate on\n * @return Socialization factor\n */\n function socializationFactor(Position memory self) internal pure returns (UFixed18) {\n return self.taker.isZero() ? UFixed18Lib.ONE : UFixed18Lib.min(UFixed18Lib.ONE, self.maker.div(self.taker));\n }\n}\n" - }, - "contracts/interfaces/types/PrePosition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"./Position.sol\";\nimport \"../IProduct.sol\";\n\n/// @dev PrePosition type\nstruct PrePosition {\n /// @dev Oracle version at which the new position delta was recorded\n uint256 oracleVersion;\n\n /// @dev Size of position to open at oracle version\n Position openPosition;\n\n /// @dev Size of position to close at oracle version\n Position closePosition;\n}\nusing PrePositionLib for PrePosition global;\n\n/**\n * @title PrePositionLib\n * @notice Library that manages a pre-settlement position delta.\n * @dev PrePositions track the currently awaiting-settlement deltas to a settled Position. These are\n * Primarily necessary to introduce lag into the settlement system such that oracle lag cannot be\n * gamed to a user's advantage. When a user opens or closes a new position, it sits as a PrePosition\n * for one oracle version until it's settle into the Position, making it then effective. PrePositions\n * are automatically settled at the correct oracle version even if a flywheel call doesn't happen until\n * several version into the future by using the historical version lookups in the corresponding \"Versioned\"\n * global state types.\n */\nlibrary PrePositionLib {\n /**\n * @notice Returns whether there is no pending-settlement position delta\n * @dev Can be \"empty\" even with a non-zero oracleVersion if a position is opened and\n * closed in the same version netting out to a zero position delta\n * @param self The struct to operate on\n * @return Whether the pending-settlement position delta is empty\n */\n function isEmpty(PrePosition memory self) internal pure returns (bool) {\n return self.openPosition.isEmpty() && self.closePosition.isEmpty();\n }\n\n /**\n * @notice Increments the maker side of the open position delta\n * @dev Nets out open and close deltas to minimize the size of each\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @param amount The position amount to open\n */\n function openMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\n self.openPosition.maker = self.openPosition.maker.add(amount);\n self.oracleVersion = currentVersion;\n _netMake(self);\n }\n\n /**\n * @notice Increments the maker side of the close position delta\n * @dev Nets out open and close deltas to minimize the size of each\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @param amount The maker position amount to close\n */\n function closeMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\n self.closePosition.maker = self.closePosition.maker.add(amount);\n self.oracleVersion = currentVersion;\n _netMake(self);\n }\n\n /**\n * @notice Increments the taker side of the open position delta\n * @dev Nets out open and close deltas to minimize the size of each\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @param amount The taker position amount to open\n */\n function openTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\n self.openPosition.taker = self.openPosition.taker.add(amount);\n self.oracleVersion = currentVersion;\n _netTake(self);\n }\n\n /**\n * @notice Increments the taker side of the close position delta\n * @dev Nets out open and close deltas to minimize the size of each\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @param amount The taker position amount to close\n */\n function closeTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\n self.closePosition.taker = self.closePosition.taker.add(amount);\n self.oracleVersion = currentVersion;\n _netTake(self);\n }\n\n /**\n * @notice Nets out the open and close on the maker side of the position delta\n * @param self The struct to operate on\n */\n function _netMake(PrePosition storage self) private {\n if (self.openPosition.maker.gt(self.closePosition.maker)) {\n self.openPosition.maker = self.openPosition.maker.sub(self.closePosition.maker);\n self.closePosition.maker = UFixed18Lib.ZERO;\n } else {\n self.closePosition.maker = self.closePosition.maker.sub(self.openPosition.maker);\n self.openPosition.maker = UFixed18Lib.ZERO;\n }\n }\n\n /**\n * @notice Nets out the open and close on the taker side of the position delta\n * @param self The struct to operate on\n */\n function _netTake(PrePosition storage self) private {\n if (self.openPosition.taker.gt(self.closePosition.taker)) {\n self.openPosition.taker = self.openPosition.taker.sub(self.closePosition.taker);\n self.closePosition.taker = UFixed18Lib.ZERO;\n } else {\n self.closePosition.taker = self.closePosition.taker.sub(self.openPosition.taker);\n self.openPosition.taker = UFixed18Lib.ZERO;\n }\n }\n\n /**\n * @notice Returns whether the the pending position delta can be settled at version `toOracleVersion`\n * @dev Pending-settlement positions deltas can be settled (1) oracle version after they are recorded\n * @param self The struct to operate on\n * @param toOracleVersion The potential oracle version to settle\n * @return Whether the position delta can be settled\n */\n function canSettle(\n PrePosition memory self,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal pure returns (bool) {\n return !isEmpty(self) && toOracleVersion.version > self.oracleVersion;\n }\n\n /**\n * @notice Computes the fee incurred for opening or closing the pending-settlement position\n * @dev Must be called from a valid product to get the proper fee amounts\n * @param self The struct to operate on\n * @param toOracleVersion The oracle version at which settlement takes place\n * @return positionFee The maker / taker fee incurred\n */\n function computeFee(\n PrePosition memory self,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal view returns (UFixed18) {\n Position memory positionDelta = self.openPosition.add(self.closePosition);\n\n (UFixed18 makerNotional, UFixed18 takerNotional) = (\n Fixed18Lib.from(positionDelta.maker).mul(toOracleVersion.price).abs(),\n Fixed18Lib.from(positionDelta.taker).mul(toOracleVersion.price).abs()\n );\n\n IProduct product = IProduct(address(this));\n return makerNotional.mul(product.makerFee()).add(takerNotional.mul(product.takerFee()));\n }\n\n /**\n * @notice Computes the next oracle version to settle\n * @dev - If there is no pending-settlement position delta, returns the current oracle version\n * - Otherwise returns the oracle version at which the pending-settlement position delta can be first settled\n *\n * Corresponds to point (b) in the Position settlement flow\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @return Next oracle version to settle\n */\n function settleVersion(PrePosition storage self, uint256 currentVersion) internal view returns (uint256) {\n uint256 _oracleVersion = self.oracleVersion;\n return _oracleVersion == 0 ? currentVersion : _oracleVersion + 1;\n }\n}\n" - }, - "contracts/interfaces/types/Accumulator.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/Fixed18.sol\";\nimport \"./PackedAccumulator.sol\";\n\n/// @dev Accumulator type\nstruct Accumulator {\n /// @dev maker accumulator per share\n Fixed18 maker;\n /// @dev taker accumulator per share\n Fixed18 taker;\n}\nusing AccumulatorLib for Accumulator global;\n\n/**\n * @title AccountAccumulatorLib\n * @notice Library that surfaces math operations for the Accumulator type.\n * @dev Accumulators track the cumulative change in position value over time for the maker and taker positions\n * respectively. Account-level accumulators can then use two of these values `a` and `a'` to compute the\n * change in position value since last sync. This change in value is then used to compute P&L and fees.\n */\nlibrary AccumulatorLib {\n /**\n * @notice Creates a packed accumulator from an accumulator\n * @param self an accumulator\n * @return New packed accumulator\n */\n function pack(Accumulator memory self) internal pure returns (PackedAccumulator memory) {\n return PackedAccumulator({maker: self.maker.pack(), taker: self.taker.pack()});\n }\n\n /**\n * @notice Adds two accumulators together\n * @param a The first accumulator to sum\n * @param b The second accumulator to sum\n * @return The resulting summed accumulator\n */\n function add(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\n return Accumulator({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\n }\n\n /**\n * @notice Subtracts accumulator `b` from `a`\n * @param a The accumulator to subtract from\n * @param b The accumulator to subtract\n * @return The resulting subtracted accumulator\n */\n function sub(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\n return Accumulator({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\n }\n\n /**\n * @notice Multiplies two accumulators together\n * @param a The first accumulator to multiply\n * @param b The second accumulator to multiply\n * @return The resulting multiplied accumulator\n */\n function mul(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\n return Accumulator({maker: a.maker.mul(b.maker), taker: a.taker.mul(b.taker)});\n }\n\n /**\n * @notice Sums the maker and taker together from a single accumulator\n * @param self The struct to operate on\n * @return The sum of its maker and taker\n */\n function sum(Accumulator memory self) internal pure returns (Fixed18) {\n return self.maker.add(self.taker);\n }\n}\n" - }, - "@equilibria/root/curve/CurveMath.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"../number/types/UFixed18.sol\";\nimport \"../number/types/Fixed18.sol\";\n\n/**\n * @title CurveMath\n * @notice Library for managing math operations for utilization curves.\n */\nlibrary CurveMath {\n error CurveMathOutOfBoundsError();\n\n /**\n * @notice Computes a linear interpolation between two points\n * @param startX First point's x-coordinate\n * @param startY First point's y-coordinate\n * @param endX Second point's x-coordinate\n * @param endY Second point's y-coordinate\n * @param targetX x-coordinate to interpolate\n * @return y-coordinate for `targetX` along the line from (`startX`, `startY`) -> (`endX`, `endY`)\n */\n function linearInterpolation(\n UFixed18 startX,\n Fixed18 startY,\n UFixed18 endX,\n Fixed18 endY,\n UFixed18 targetX\n ) internal pure returns (Fixed18) {\n if (targetX.lt(startX) || targetX.gt(endX)) revert CurveMathOutOfBoundsError();\n\n UFixed18 xRange = endX.sub(startX);\n Fixed18 yRange = endY.sub(startY);\n UFixed18 xRatio = targetX.sub(startX).div(xRange);\n return yRange.mul(Fixed18Lib.from(xRatio)).add(startY);\n }\n}\n" - }, - "@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/Fixed18.sol\";\n\ninterface IOracleProvider {\n /// @dev A singular oracle version with its corresponding data\n struct OracleVersion {\n /// @dev The iterative version\n uint256 version;\n\n /// @dev the timestamp of the oracle update\n uint256 timestamp;\n\n /// @dev The oracle price of the corresponding version\n Fixed18 price;\n }\n\n function sync() external returns (OracleVersion memory);\n function currentVersion() external view returns (OracleVersion memory);\n function atVersion(uint256 oracleVersion) external view returns (OracleVersion memory);\n}\n" - }, - "contracts/interfaces/IContractPayoffProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/Fixed18.sol\";\n\ninterface IContractPayoffProvider {\n function payoff(Fixed18 price) external view returns (Fixed18 payoff);\n}\n" - }, - "contracts/interfaces/types/PackedPosition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/PackedUFixed18.sol\";\nimport \"./Position.sol\";\n\n/// @dev PackedPosition type\nstruct PackedPosition {\n /// @dev Quantity of the maker position\n PackedUFixed18 maker;\n /// @dev Quantity of the taker position\n PackedUFixed18 taker;\n}\nusing PackedPositionLib for PackedPosition global;\n\n/**\n * @title PackedPositionLib\n * @dev A packed version of the Position which takes up a single storage slot using `PackedFixed18` values.\n * @notice Library for the packed Position type.\n */\nlibrary PackedPositionLib {\n /**\n * @notice Creates an position from a packed position\n * @param self packed position\n * @return New position\n */\n function unpack(PackedPosition memory self) internal pure returns (Position memory) {\n return Position({maker: self.maker.unpack(), taker: self.taker.unpack()});\n }\n}\n" - }, - "contracts/interfaces/types/PackedAccumulator.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/PackedFixed18.sol\";\nimport \"./Accumulator.sol\";\n\n/// @dev PackedAccumulator type\nstruct PackedAccumulator {\n /// @dev maker accumulator per share\n PackedFixed18 maker;\n /// @dev taker accumulator per share\n PackedFixed18 taker;\n}\nusing PackedAccumulatorLib for PackedAccumulator global;\n\n/**\n * @title PackedAccumulatorLib\n * @dev A packed version of the Accumulator which takes up a single storage slot using `PackedFixed18` values.\n * @notice Library for the packed Accumulator type.\n */\nlibrary PackedAccumulatorLib {\n /**\n * @notice Creates an accumulator from a packed accumulator\n * @param self packed accumulator\n * @return New accumulator\n */\n function unpack(PackedAccumulator memory self) internal pure returns (Accumulator memory) {\n return Accumulator({maker: self.maker.unpack(), taker: self.taker.unpack()});\n }\n}\n" - }, - "contracts/interfaces/types/ProgramInfo.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"../IProduct.sol\";\nimport \"./Position.sol\";\nimport \"./Accumulator.sol\";\n\n/// @dev ProgramInfo type\nstruct ProgramInfo {\n /// @dev Coordinator for this program\n uint256 coordinatorId;\n\n /// @dev Amount of total maker and taker rewards\n Position amount;\n\n /// @dev start timestamp of the program\n uint256 start;\n\n /// @dev duration of the program (in seconds)\n uint256 duration;\n\n /**\n * @dev Reward ERC20 token contract\n * @notice Perennial does not support non-standard ERC20s as reward tokens for incentive programs, including,\n but not limited to: fee on transfer and rebase tokens. Using such a non-standard token will likely\n result in loss of funds.\n */\n Token18 token;\n}\nusing ProgramInfoLib for ProgramInfo global;\n\n/**\n * @title ProgramInfoLib\n * @notice Library that snapshots the static information for a single program.\n * @dev This information does not change during the operation of a program.\n */\nlibrary ProgramInfoLib {\n uint256 private constant MIN_DURATION = 1 days;\n uint256 private constant MAX_DURATION = 2 * 365 days;\n\n error ProgramInvalidStartError();\n error ProgramInvalidDurationError();\n\n /**\n * @notice Validates and creates a new Program\n * @dev Reverts for invalid programInfos\n * @param programInfo Un-sanitized static program information\n */\n function validate(ProgramInfo memory programInfo) internal view {\n if (isStarted(programInfo, block.timestamp)) revert ProgramInvalidStartError();\n if (programInfo.duration < MIN_DURATION || programInfo.duration > MAX_DURATION) revert ProgramInvalidDurationError();\n }\n\n /**\n * @notice Computes a new program info with the fee taken out of the amount\n * @param programInfo Original program info\n * @param incentivizationFee The incentivization fee\n * @return New program info\n * @return Fee amount\n */\n function deductFee(ProgramInfo memory programInfo, UFixed18 incentivizationFee)\n internal pure returns (ProgramInfo memory, UFixed18) {\n Position memory newProgramAmount = programInfo.amount.mul(UFixed18Lib.ONE.sub(incentivizationFee));\n UFixed18 programFeeAmount = programInfo.amount.sub(newProgramAmount).sum();\n programInfo.amount = newProgramAmount;\n return (programInfo, programFeeAmount);\n }\n\n /**\n * @notice Returns the maker and taker amounts per position share\n * @param self The ProgramInfo to operate on\n * @return programFee Amounts per share\n */\n function amountPerShare(ProgramInfo memory self) internal pure returns (Accumulator memory) {\n return self.amount.div(self.duration);\n }\n\n /**\n * @notice Returns whether the program has started by timestamp `timestamp`\n * @param self The ProgramInfo to operate on\n * @param timestamp Timestamp to check for\n * @return Whether the program has started\n */\n function isStarted(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\n return timestamp >= self.start;\n }\n\n /**\n * @notice Returns whether the program is completed by timestamp `timestamp`\n * @param self The ProgramInfo to operate on\n * @param timestamp Timestamp to check for\n * @return Whether the program is completed\n */\n function isComplete(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\n return timestamp >= (self.start + self.duration);\n }\n}\n" - }, - "contracts/product/UParamProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/control/unstructured/UInitializable.sol\";\nimport \"../controller/UControllerProvider.sol\";\nimport \"../interfaces/IParamProvider.sol\";\nimport \"../interfaces/IProduct.sol\";\n\nabstract contract UParamProvider is IParamProvider, UControllerProvider {\n /**\n * @notice Initializes the contract state\n * @param maintenance_ product maintenance ratio\n * @param fundingFee_ product funding fee\n * @param makerFee_ product maker fee\n * @param takerFee_ product taker fee\n * @param makerLimit_ product maker limit\n * @param utilizationCurve_ utulization curve definition\n */\n // solhint-disable-next-line func-name-mixedcase\n function __UParamProvider__initialize(\n UFixed18 maintenance_,\n UFixed18 fundingFee_,\n UFixed18 makerFee_,\n UFixed18 takerFee_,\n UFixed18 makerLimit_,\n JumpRateUtilizationCurve memory utilizationCurve_\n ) internal onlyInitializer {\n _updateMaintenance(maintenance_);\n _updateFundingFee(fundingFee_);\n _updateMakerFee(makerFee_);\n _updateTakerFee(takerFee_);\n _updateMakerLimit(makerLimit_);\n _updateUtilizationCurve(utilizationCurve_);\n }\n\n /// @dev Only allow the Product's coordinator owner to call\n modifier onlyProductOwner {\n uint256 coordinatorId = controller().coordinatorFor(IProduct(address(this)));\n if (controller().owner(coordinatorId) != msg.sender) revert NotOwnerError(coordinatorId);\n\n _;\n }\n\n /// @dev The maintenance value\n UFixed18Storage private constant _maintenance = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.UParamProvider.maintenance\"));\n function maintenance() public view returns (UFixed18) { return _maintenance.read(); }\n\n /// @dev The funding fee value\n UFixed18Storage private constant _fundingFee = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.UParamProvider.fundingFee\"));\n function fundingFee() public view returns (UFixed18) { return _fundingFee.read(); }\n\n /// @dev The maker fee value\n UFixed18Storage private constant _makerFee = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.UParamProvider.makerFee\"));\n function makerFee() public view returns (UFixed18) { return _makerFee.read(); }\n\n /// @dev The taker fee value\n UFixed18Storage private constant _takerFee = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.UParamProvider.takerFee\"));\n function takerFee() public view returns (UFixed18) { return _takerFee.read(); }\n\n /// @dev The maker limit value\n UFixed18Storage private constant _makerLimit = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.UParamProvider.makerLimit\"));\n function makerLimit() public view returns (UFixed18) { return _makerLimit.read(); }\n\n /// @dev The JumpRateUtilizationCurve params\n JumpRateUtilizationCurveStorage private constant _utilizationCurve =\n JumpRateUtilizationCurveStorage.wrap(keccak256(\"equilibria.perennial.UParamProvider.jumpRateUtilizationCurve\"));\n function utilizationCurve() public view returns (JumpRateUtilizationCurve memory) { return _utilizationCurve.read(); }\n\n /**\n * @notice Updates the maintenance to `newMaintenance`\n * @param newMaintenance new maintenance value\n */\n function _updateMaintenance(UFixed18 newMaintenance) private {\n _maintenance.store(newMaintenance);\n emit MaintenanceUpdated(newMaintenance);\n }\n\n /**\n * @notice Updates the maintenance to `newMaintenance`\n * @dev only callable by product owner\n * @param newMaintenance new maintenance value\n */\n function updateMaintenance(UFixed18 newMaintenance) external onlyProductOwner {\n _updateMaintenance(newMaintenance);\n }\n\n /**\n * @notice Updates the funding fee to `newFundingFee`\n * @param newFundingFee new funding fee value\n */\n function _updateFundingFee(UFixed18 newFundingFee) private {\n if (newFundingFee.gt(UFixed18Lib.ONE)) revert ParamProviderInvalidFundingFee();\n _fundingFee.store(newFundingFee);\n emit FundingFeeUpdated(newFundingFee);\n }\n\n /**\n * @notice Updates the funding fee to `newFundingFee`\n * @dev only callable by product owner\n * @param newFundingFee new funding fee value\n */\n function updateFundingFee(UFixed18 newFundingFee) external onlyProductOwner {\n _updateFundingFee(newFundingFee);\n }\n\n /**\n * @notice Updates the maker fee to `newMakerFee`\n * @param newMakerFee new maker fee value\n */\n function _updateMakerFee(UFixed18 newMakerFee) private {\n if (newMakerFee.gt(UFixed18Lib.ONE)) revert ParamProviderInvalidMakerFee();\n _makerFee.store(newMakerFee);\n emit MakerFeeUpdated(newMakerFee);\n }\n\n /**\n * @notice Updates the maker fee to `newMakerFee`\n * @dev only callable by product owner\n * @param newMakerFee new maker fee value\n */\n function updateMakerFee(UFixed18 newMakerFee) external onlyProductOwner {\n _updateMakerFee(newMakerFee);\n }\n\n /**\n * @notice Updates the taker fee to `newTakerFee`\n * @param newTakerFee new taker fee value\n */\n function _updateTakerFee(UFixed18 newTakerFee) private {\n if (newTakerFee.gt(UFixed18Lib.ONE)) revert ParamProviderInvalidTakerFee();\n _takerFee.store(newTakerFee);\n emit TakerFeeUpdated(newTakerFee);\n }\n\n /**\n * @notice Updates the taker fee to `newTakerFee`\n * @dev only callable by product owner\n * @param newTakerFee new taker fee value\n */\n function updateTakerFee(UFixed18 newTakerFee) external onlyProductOwner {\n _updateTakerFee(newTakerFee);\n }\n\n /**\n * @notice Updates the maker limit to `newMakerLimit`\n * @param newMakerLimit new maker limit value\n */\n function _updateMakerLimit(UFixed18 newMakerLimit) private {\n _makerLimit.store(newMakerLimit);\n emit MakerLimitUpdated(newMakerLimit);\n }\n\n /**\n * @notice Updates the maker limit to `newMakerLimit`\n * @dev only callable by product owner\n * @param newMakerLimit new maker limit value\n */\n function updateMakerLimit(UFixed18 newMakerLimit) external onlyProductOwner {\n _updateMakerLimit(newMakerLimit);\n }\n\n /**\n * @notice Updates the utilization curve to `newUtilizationCurve`\n * @param newUtilizationCurve new utilization curve value\n */\n function _updateUtilizationCurve(JumpRateUtilizationCurve memory newUtilizationCurve) private {\n _utilizationCurve.store(newUtilizationCurve);\n emit JumpRateUtilizationCurveUpdated(\n newUtilizationCurve.minRate.unpack(),\n newUtilizationCurve.maxRate.unpack(),\n newUtilizationCurve.targetRate.unpack(),\n newUtilizationCurve.targetUtilization.unpack()\n );\n }\n\n /**\n * @notice Updates the utilization curve to `newUtilizationCurve`\n * @dev only callable by product owner\n * @param newUtilizationCurve new utilization curve value\n */\n function updateUtilizationCurve(JumpRateUtilizationCurve calldata newUtilizationCurve) external onlyProductOwner {\n _updateUtilizationCurve(newUtilizationCurve);\n }\n}\n" - }, - "contracts/product/types/accumulator/VersionedAccumulator.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../../../interfaces/IProduct.sol\";\nimport \"../../../interfaces/types/Accumulator.sol\";\nimport \"../position/VersionedPosition.sol\";\n\n/// @dev VersionedAccumulator type\nstruct VersionedAccumulator {\n /// @dev Latest synced oracle version\n uint256 latestVersion;\n\n /// @dev Mapping of accumulator value at each settled oracle version\n mapping(uint256 => PackedAccumulator) _valueAtVersion;\n\n /// @dev Mapping of accumulator share at each settled oracle version\n mapping(uint256 => PackedAccumulator) _shareAtVersion;\n}\nusing VersionedAccumulatorLib for VersionedAccumulator global;\n\n/**\n * @title VersionedAccumulatorLib\n * @notice Library that manages global versioned accumulator state.\n * @dev Manages two accumulators: value and share. The value accumulator measures the change in position value\n * over time. The share accumulator measures the change in liquidity ownership over time (for tracking\n * incentivization rewards).\n *\n * Both accumulators are stamped for historical lookup anytime there is a global settlement, which services\n * the delayed-position accounting. It is not guaranteed that every version will have a value stamped, but\n * only versions when a settlement occurred are needed for this historical computation.\n */\nlibrary VersionedAccumulatorLib {\n /**\n * @notice Returns the stamped value accumulator at `oracleVersion`\n * @param self The struct to operate on\n * @param oracleVersion The oracle version to retrieve the value at\n * @return The stamped value accumulator at the requested version\n */\n function valueAtVersion(VersionedAccumulator storage self, uint256 oracleVersion) internal view returns (Accumulator memory) {\n return self._valueAtVersion[oracleVersion].unpack();\n }\n\n /**\n * @notice Returns the stamped share accumulator at `oracleVersion`\n * @param self The struct to operate on\n * @param oracleVersion The oracle version to retrieve the share at\n * @return The stamped share accumulator at the requested version\n */\n function shareAtVersion(VersionedAccumulator storage self, uint256 oracleVersion) internal view returns (Accumulator memory) {\n return self._shareAtVersion[oracleVersion].unpack();\n }\n\n /**\n * @notice Globally accumulates all value (position + funding) and share since last oracle update\n * @param self The struct to operate on\n * @param fundingFee The funding fee rate for the product\n * @param position Pointer to global position\n * @param latestOracleVersion The oracle version to accumulate from\n * @param toOracleVersion The oracle version to accumulate to\n * @return accumulatedFee The total fee accrued from accumulation\n */\n function accumulate(\n VersionedAccumulator storage self,\n UFixed18 fundingFee,\n VersionedPosition storage position,\n IOracleProvider.OracleVersion memory latestOracleVersion,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal returns (UFixed18 accumulatedFee) {\n Position memory latestPosition = position.positionAtVersion(latestOracleVersion.version);\n\n // accumulate funding\n Accumulator memory accumulatedPosition;\n (accumulatedPosition, accumulatedFee) =\n _accumulateFunding(fundingFee, latestPosition, latestOracleVersion, toOracleVersion);\n\n // accumulate position\n accumulatedPosition = accumulatedPosition.add(\n _accumulatePosition(latestPosition, latestOracleVersion, toOracleVersion));\n\n // accumulate share\n Accumulator memory accumulatedShare =\n _accumulateShare(latestPosition, latestOracleVersion, toOracleVersion);\n\n // save update\n self._valueAtVersion[toOracleVersion.version] = valueAtVersion(self, latestOracleVersion.version)\n .add(accumulatedPosition)\n .pack();\n self._shareAtVersion[toOracleVersion.version] = shareAtVersion(self, latestOracleVersion.version)\n .add(accumulatedShare)\n .pack();\n self.latestVersion = toOracleVersion.version;\n }\n\n /**\n * @notice Globally accumulates all funding since last oracle update\n * @dev If an oracle version is skipped due to no pre positions, funding will continue to be\n * pegged to the price of the last snapshotted oracleVersion until a new one is accumulated.\n * This is an acceptable approximation.\n * @param fundingFee The funding fee rate for the product\n * @param latestPosition The latest global position\n * @param latestOracleVersion The oracle version to accumulate from\n * @param toOracleVersion The oracle version to accumulate to\n * @return accumulatedFunding The total amount accumulated from funding\n * @return accumulatedFee The total fee accrued from funding accumulation\n */\n function _accumulateFunding(\n UFixed18 fundingFee,\n Position memory latestPosition,\n IOracleProvider.OracleVersion memory latestOracleVersion,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) private view returns (Accumulator memory accumulatedFunding, UFixed18 accumulatedFee) {\n if (_product().closed()) return (Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO), UFixed18Lib.ZERO);\n if (latestPosition.taker.isZero()) return (Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO), UFixed18Lib.ZERO);\n if (latestPosition.maker.isZero()) return (Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO), UFixed18Lib.ZERO);\n\n uint256 elapsed = toOracleVersion.timestamp - latestOracleVersion.timestamp;\n\n UFixed18 takerNotional = Fixed18Lib.from(latestPosition.taker).mul(latestOracleVersion.price).abs();\n UFixed18 socializedNotional = takerNotional.mul(latestPosition.socializationFactor());\n\n Fixed18 rateAccumulated = _product().rate(latestPosition)\n .mul(Fixed18Lib.from(UFixed18Lib.from(elapsed)));\n Fixed18 fundingAccumulated = rateAccumulated.mul(Fixed18Lib.from(socializedNotional));\n accumulatedFee = fundingAccumulated.abs().mul(fundingFee);\n\n Fixed18 fundingAccumulatedWithoutFee = Fixed18Lib.from(\n fundingAccumulated.sign(),\n fundingAccumulated.abs().sub(accumulatedFee)\n );\n\n bool makerPaysFunding = fundingAccumulated.sign() < 0;\n accumulatedFunding.maker = (makerPaysFunding ? fundingAccumulated : fundingAccumulatedWithoutFee)\n .div(Fixed18Lib.from(latestPosition.maker));\n accumulatedFunding.taker = (makerPaysFunding ? fundingAccumulatedWithoutFee : fundingAccumulated)\n .div(Fixed18Lib.from(latestPosition.taker)).mul(Fixed18Lib.NEG_ONE);\n }\n\n /**\n * @notice Globally accumulates position PNL since last oracle update\n * @param latestPosition The latest global position\n * @param latestOracleVersion The oracle version to accumulate from\n * @param toOracleVersion The oracle version to accumulate to\n * @return accumulatedPosition The total amount accumulated from position PNL\n */\n function _accumulatePosition(\n Position memory latestPosition,\n IOracleProvider.OracleVersion memory latestOracleVersion,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) private view returns (Accumulator memory accumulatedPosition) {\n if (_product().closed()) return Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO);\n if (latestPosition.taker.isZero()) return Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO);\n if (latestPosition.maker.isZero()) return Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO);\n\n Fixed18 oracleDelta = toOracleVersion.price.sub(latestOracleVersion.price);\n Fixed18 totalTakerDelta = oracleDelta.mul(Fixed18Lib.from(latestPosition.taker));\n Fixed18 socializedTakerDelta = totalTakerDelta.mul(Fixed18Lib.from(latestPosition.socializationFactor()));\n\n accumulatedPosition.maker = socializedTakerDelta.div(Fixed18Lib.from(latestPosition.maker)).mul(Fixed18Lib.NEG_ONE);\n accumulatedPosition.taker = socializedTakerDelta.div(Fixed18Lib.from(latestPosition.taker));\n }\n\n /**\n * @notice Globally accumulates position's share of the total market since last oracle update\n * @dev This is used to compute incentivization rewards based on market participation\n * @param latestPosition The latest global position\n * @param latestOracleVersion The oracle version to accumulate from\n * @param toOracleVersion The oracle version to accumulate to\n * @return accumulatedShare The total share amount accumulated per position\n */\n function _accumulateShare(\n Position memory latestPosition,\n IOracleProvider.OracleVersion memory latestOracleVersion,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) private pure returns (Accumulator memory accumulatedShare) {\n uint256 elapsed = toOracleVersion.timestamp - latestOracleVersion.timestamp;\n\n accumulatedShare.maker = latestPosition.maker.isZero() ?\n Fixed18Lib.ZERO :\n Fixed18Lib.from(UFixed18Lib.from(elapsed).div(latestPosition.maker));\n accumulatedShare.taker = latestPosition.taker.isZero() ?\n Fixed18Lib.ZERO :\n Fixed18Lib.from(UFixed18Lib.from(elapsed).div(latestPosition.taker));\n }\n\n function _product() private view returns (IProduct) {\n return IProduct(address(this));\n }\n}\n" - }, - "contracts/product/types/position/VersionedPosition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../../../interfaces/types/PrePosition.sol\";\nimport \"../../../interfaces/types/PackedPosition.sol\";\n\n//// @dev VersionedPosition type\nstruct VersionedPosition {\n /// @dev Mapping of global position at each version\n mapping(uint256 => PackedPosition) _positionAtVersion;\n\n /// @dev Current global pending-settlement position delta\n PrePosition pre;\n}\nusing VersionedPositionLib for VersionedPosition global;\n\n/**\n * @title VersionedPositionLib\n * @notice Library that manages global position state.\n * @dev Global position state is used to compute utilization rate and socialization, and to account for and\n * distribute fees globally.\n *\n * Positions are stamped for historical lookup anytime there is a global settlement, which services\n * the delayed-position accounting. It is not guaranteed that every version will have a value stamped, but\n * only versions when a settlement occurred are needed for this historical computation.\n */\nlibrary VersionedPositionLib {\n /**\n * @notice Returns the current global position\n * @return Current global position\n */\n function positionAtVersion(VersionedPosition storage self, uint256 oracleVersion) internal view returns (Position memory) {\n return self._positionAtVersion[oracleVersion].unpack();\n }\n\n /**\n * @notice Settled the global position to oracle version `toOracleVersion`\n * @param self The struct to operate on\n * @param latestVersion The latest settled oracle version\n * @param toOracleVersion The oracle version to settle to\n * @return positionFee The fee accrued from opening or closing a new position\n */\n function settle(\n VersionedPosition storage self,\n uint256 latestVersion,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal returns (UFixed18) {\n (Position memory newPosition, UFixed18 positionFee, bool settled) =\n positionAtVersion(self, latestVersion).settled(self.pre, toOracleVersion);\n\n self._positionAtVersion[toOracleVersion.version] = newPosition.pack();\n if (settled) delete self.pre;\n\n return positionFee;\n }\n}\n" - }, - "contracts/test/TestnetProductProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\";\nimport \"../interfaces/IContractPayoffProvider.sol\";\n\ncontract TestnetContractPayoffProvider is IContractPayoffProvider {\n function payoff(Fixed18 price) public pure returns (Fixed18) {\n return price.mul(price);\n }\n}\n" - }, - "contracts/product/types/accumulator/AccountAccumulator.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../../../interfaces/types/Accumulator.sol\";\nimport \"../position/AccountPosition.sol\";\nimport \"./VersionedAccumulator.sol\";\n\n/// @dev AccountAccumulator type\nstruct AccountAccumulator {\n /// @dev latest version that the account was synced too\n uint256 latestVersion;\n}\nusing AccountAccumulatorLib for AccountAccumulator global;\n\n/**\n * @title AccountAccumulatorLib\n * @notice Library that manages syncing an account-level accumulator.\n */\nlibrary AccountAccumulatorLib {\n /**\n * @notice Syncs the account to oracle version `versionTo`\n * @param self The struct to operate on\n * @param global Pointer to global accumulator\n * @param position Pointer to global position\n * @param versionTo Oracle version to sync account to\n * @return value The value accumulated sync last sync\n */\n function syncTo(\n AccountAccumulator storage self,\n VersionedAccumulator storage global,\n AccountPosition storage position,\n uint256 versionTo\n ) internal returns (Accumulator memory value) {\n Accumulator memory valueAccumulated = global.valueAtVersion(versionTo)\n .sub(global.valueAtVersion(self.latestVersion));\n value = position.position.mul(valueAccumulated);\n self.latestVersion = versionTo;\n }\n}\n" - }, - "contracts/product/types/position/AccountPosition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../../../interfaces/IProduct.sol\";\nimport \"../../../interfaces/types/PrePosition.sol\";\n\n/// @dev AccountPosition type\nstruct AccountPosition {\n /// @dev The current settled position of the account\n Position position;\n\n /// @dev The current position delta pending-settlement\n PrePosition pre;\n\n /// @dev Whether the account is currently locked for liquidation\n bool liquidation;\n}\nusing AccountPositionLib for AccountPosition global;\n\n/**\n * @title AccountPositionLib\n * @notice Library that manages an account-level position.\n */\nlibrary AccountPositionLib {\n /**\n * @notice Settled the account's position to oracle version `toOracleVersion`\n * @param self The struct to operate on\n * @param toOracleVersion The oracle version to accumulate to\n * @return positionFee The fee accrued from opening or closing a new position\n */\n function settle(\n AccountPosition storage self,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal returns (UFixed18 positionFee) {\n bool settled;\n (self.position, positionFee, settled) = self.position.settled(self.pre, toOracleVersion);\n if (settled) {\n delete self.pre;\n self.liquidation = false;\n }\n }\n\n /**\n * @notice Returns the current maintenance requirement for the account\n * @dev Must be called from a valid product to get the proper maintenance value\n * @param self The struct to operate on\n * @return Current maintenance requirement for the account\n */\n function maintenance(AccountPosition storage self) internal view returns (UFixed18) {\n if (self.liquidation) return UFixed18Lib.ZERO;\n return _maintenance(self.position);\n }\n\n /**\n * @notice Returns the maintenance requirement after the next oracle version settlement\n * @dev Includes the current pending-settlement position delta, assumes no price change\n * @param self The struct to operate on\n * @return Next maintenance requirement for the account\n */\n function maintenanceNext(AccountPosition storage self) internal view returns (UFixed18) {\n return _maintenance(self.position.next(self.pre));\n }\n\n /**\n * @notice Returns the maintenance requirement for a given `position`\n * @dev Internal helper\n * @param position The position to compete the maintenance requirement for\n * @return Next maintenance requirement for the account\n */\n function _maintenance(Position memory position) private view returns (UFixed18) {\n IProduct product = IProduct(address(this));\n Fixed18 oraclePrice = product.currentVersion().price;\n UFixed18 notionalMax = Fixed18Lib.from(position.max()).mul(oraclePrice).abs();\n return notionalMax.mul(product.maintenance());\n }\n\n /**\n * @notice Returns whether an account is completely closed, i.e. no position or pre-position\n * @param self The struct to operate on\n * @return Whether the account is closed\n */\n function isClosed(AccountPosition memory self) internal pure returns (bool) {\n return self.pre.isEmpty() && self.position.isEmpty();\n }\n\n /**\n * @notice Returns whether an account has opened position on both sides of the market (maker vs taker)\n * @dev Used to verify the invariant that a single account can only have a position on one side of the\n * market at a time\n * @param self The struct to operate on\n * @return Whether the account is currently doubled sided\n */\n function isDoubleSided(AccountPosition storage self) internal view returns (bool) {\n bool makerEmpty = self.position.maker.isZero() && self.pre.openPosition.maker.isZero() && self.pre.closePosition.maker.isZero();\n bool takerEmpty = self.position.taker.isZero() && self.pre.openPosition.taker.isZero() && self.pre.closePosition.taker.isZero();\n\n return !makerEmpty && !takerEmpty;\n }\n\n /**\n * @notice Returns whether the account's pending-settlement delta closes more position than is open\n * @dev Used to verify the invariant that an account cannot settle into having a negative position\n * @param self The struct to operate on\n * @return Whether the account is currently over closed\n */\n function isOverClosed(AccountPosition storage self) internal view returns (bool) {\n Position memory nextOpen = self.position.add(self.pre.openPosition);\n\n return self.pre.closePosition.maker.gt(nextOpen.maker) || self.pre.closePosition.taker.gt(nextOpen.taker);\n }\n}\n" - }, - "contracts/product/UPayoffProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/control/unstructured/UInitializable.sol\";\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"@equilibria/root/storage/UStorage.sol\";\nimport \"../interfaces/IPayoffProvider.sol\";\nimport \"../interfaces/types/PayoffDefinition.sol\";\n\n/**\n * @title UPayoffProvider\n * @notice Library for manage storing, surfacing, and upgrading a payoff provider.\n * @dev Uses an unstructured storage pattern to store the oracle address and payoff definition which allows this\n provider to be safely used with upgradeable contracts.\n */\nabstract contract UPayoffProvider is IPayoffProvider, UInitializable {\n /// @dev The oracle contract address\n AddressStorage private constant _oracle =\n AddressStorage.wrap(keccak256(\"equilibria.perennial.UPayoffProvider.oracle\"));\n function oracle() public view returns (IOracleProvider) { return IOracleProvider(_oracle.read()); }\n\n /// @dev Payoff definition struct\n PayoffDefinitionStorage private constant _payoffDefinition =\n PayoffDefinitionStorage.wrap(keccak256(\"equilibria.perennial.UPayoffProvider.payoffDefinition\"));\n function payoffDefinition() public view returns (PayoffDefinition memory) { return _payoffDefinition.read(); }\n\n /**\n * @notice Initializes the contract state\n * @param oracle_ Oracle address\n * @param payoffDefinition_ Payoff provider\n */\n // solhint-disable-next-line func-name-mixedcase\n function __UPayoffProvider__initialize(IOracleProvider oracle_, PayoffDefinition calldata payoffDefinition_) internal onlyInitializer {\n if (!Address.isContract(address(oracle_))) revert PayoffProviderInvalidOracle();\n _oracle.store(address(oracle_));\n\n if (!payoffDefinition_.valid()) revert PayoffProviderInvalidPayoffDefinitionError();\n _payoffDefinition.store(payoffDefinition_);\n }\n\n /**\n * @notice Returns the current oracle version transformed by the payoff definition\n * @return Current oracle version transformed by the payoff definition\n */\n function currentVersion() public view returns (IOracleProvider.OracleVersion memory) {\n return _transform(oracle().currentVersion());\n }\n\n /**\n * @notice Returns the oracle version at `oracleVersion` transformed by the payoff definition\n * @param oracleVersion Oracle version to return for\n * @return Oracle version at `oracleVersion` with price transformed by payoff function\n */\n function atVersion(uint256 oracleVersion) public view returns (IOracleProvider.OracleVersion memory) {\n return _transform(oracle().atVersion(oracleVersion));\n }\n\n /**\n * @notice Yook to call sync() on the oracle provider and transform the resulting oracle version\n */\n function _sync() internal returns (IOracleProvider.OracleVersion memory) {\n return _transform(oracle().sync());\n }\n\n /**\n * @notice Returns the transformed oracle version\n * @param oracleVersion Oracle version to transform\n * @return Transformed oracle version\n */\n function _transform(IOracleProvider.OracleVersion memory oracleVersion)\n internal view virtual returns (IOracleProvider.OracleVersion memory) {\n oracleVersion.price = payoffDefinition().transform(oracleVersion.price);\n return oracleVersion;\n }\n}\n" - }, - "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/UpgradeableBeacon.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IBeacon.sol\";\nimport \"../../access/Ownable.sol\";\nimport \"../../utils/Address.sol\";\n\n/**\n * @dev This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their\n * implementation contract, which is where they will delegate all function calls.\n *\n * An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.\n */\ncontract UpgradeableBeacon is IBeacon, Ownable {\n address private _implementation;\n\n /**\n * @dev Emitted when the implementation returned by the beacon is changed.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the\n * beacon.\n */\n constructor(address implementation_) {\n _setImplementation(implementation_);\n }\n\n /**\n * @dev Returns the current implementation address.\n */\n function implementation() public view virtual override returns (address) {\n return _implementation;\n }\n\n /**\n * @dev Upgrades the beacon to a new implementation.\n *\n * Emits an {Upgraded} event.\n *\n * Requirements:\n *\n * - msg.sender must be the owner of the contract.\n * - `newImplementation` must be a contract.\n */\n function upgradeTo(address newImplementation) public virtual onlyOwner {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Sets the implementation contract address for this beacon\n *\n * Requirements:\n *\n * - `newImplementation` must be a contract.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"UpgradeableBeacon: implementation is not a contract\");\n _implementation = newImplementation;\n }\n}\n" - }, - "@openzeppelin/contracts/access/Ownable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n _;\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Context.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n" - }, - "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/ProxyAdmin.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./TransparentUpgradeableProxy.sol\";\nimport \"../../access/Ownable.sol\";\n\n/**\n * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an\n * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.\n */\ncontract ProxyAdmin is Ownable {\n /**\n * @dev Returns the current implementation of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"implementation()\")) == 0x5c60da1b\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"5c60da1b\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Returns the current admin of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"admin()\")) == 0xf851a440\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"f851a440\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Changes the admin of `proxy` to `newAdmin`.\n *\n * Requirements:\n *\n * - This contract must be the current admin of `proxy`.\n */\n function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {\n proxy.changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {\n proxy.upgradeTo(implementation);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See\n * {TransparentUpgradeableProxy-upgradeToAndCall}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgradeAndCall(\n TransparentUpgradeableProxy proxy,\n address implementation,\n bytes memory data\n ) public payable virtual onlyOwner {\n proxy.upgradeToAndCall{value: msg.value}(implementation, data);\n }\n}\n" - }, - "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC1967/ERC1967Proxy.sol\";\n\n/**\n * @dev This contract implements a proxy that is upgradeable by an admin.\n *\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\n * clashing], which can potentially be used in an attack, this contract uses the\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\n * things that go hand in hand:\n *\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\n * that call matches one of the admin functions exposed by the proxy itself.\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\n * \"admin cannot fallback to proxy target\".\n *\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\n * to sudden errors when trying to call a function from the proxy implementation.\n *\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\n */\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\n /**\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\n */\n constructor(\n address _logic,\n address admin_,\n bytes memory _data\n ) payable ERC1967Proxy(_logic, _data) {\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.admin\")) - 1));\n _changeAdmin(admin_);\n }\n\n /**\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\n */\n modifier ifAdmin() {\n if (msg.sender == _getAdmin()) {\n _;\n } else {\n _fallback();\n }\n }\n\n /**\n * @dev Returns the current admin.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\n */\n function admin() external ifAdmin returns (address admin_) {\n admin_ = _getAdmin();\n }\n\n /**\n * @dev Returns the current implementation.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\n */\n function implementation() external ifAdmin returns (address implementation_) {\n implementation_ = _implementation();\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\n */\n function changeAdmin(address newAdmin) external virtual ifAdmin {\n _changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\n */\n function upgradeTo(address newImplementation) external ifAdmin {\n _upgradeToAndCall(newImplementation, bytes(\"\"), false);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\n * proxied contract.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\n */\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\n _upgradeToAndCall(newImplementation, data, true);\n }\n\n /**\n * @dev Returns the current admin.\n */\n function _admin() internal view virtual returns (address) {\n return _getAdmin();\n }\n\n /**\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\n */\n function _beforeFallback() internal virtual override {\n require(msg.sender != _getAdmin(), \"TransparentUpgradeableProxy: admin cannot fallback to proxy target\");\n super._beforeFallback();\n }\n}\n" - }, - "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Proxy.sol\";\nimport \"./ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\n * implementation address that can be changed. This address is stored in storage in the location specified by\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\n * implementation behind the proxy.\n */\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\n /**\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\n *\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\n */\n constructor(address _logic, bytes memory _data) payable {\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.implementation\")) - 1));\n _upgradeToAndCall(_logic, _data, false);\n }\n\n /**\n * @dev Returns the current implementation address.\n */\n function _implementation() internal view virtual override returns (address impl) {\n return ERC1967Upgrade._getImplementation();\n }\n}\n" - }, - "@openzeppelin/contracts/proxy/Proxy.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n /**\n * @dev Delegates the current call to `implementation`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _delegate(address implementation) internal virtual {\n assembly {\n // Copy msg.data. We take full control of memory in this inline assembly\n // block because it will not return to Solidity code. We overwrite the\n // Solidity scratch pad at memory position 0.\n calldatacopy(0, 0, calldatasize())\n\n // Call the implementation.\n // out and outsize are 0 because we don't know the size yet.\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n // Copy the returned data.\n returndatacopy(0, 0, returndatasize())\n\n switch result\n // delegatecall returns 0 on error.\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n /**\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\n * and {_fallback} should delegate.\n */\n function _implementation() internal view virtual returns (address);\n\n /**\n * @dev Delegates the current call to the address returned by `_implementation()`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _fallback() internal virtual {\n _beforeFallback();\n _delegate(_implementation());\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n * function in the contract matches the call data.\n */\n fallback() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\n * is empty.\n */\n receive() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\n * call, or as part of the Solidity `fallback` or `receive` functions.\n *\n * If overridden should call `super._beforeFallback()`.\n */\n function _beforeFallback() internal virtual {}\n}\n" - }, - "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeacon.sol\";\nimport \"../../interfaces/draft-IERC1822.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/StorageSlot.sol\";\n\n/**\n * @dev This abstract contract provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\n *\n * _Available since v4.1._\n *\n * @custom:oz-upgrades-unsafe-allow delegatecall\n */\nabstract contract ERC1967Upgrade {\n // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\n\n /**\n * @dev Storage slot with the address of the current implementation.\n * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @dev Emitted when the implementation is upgraded.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Returns the current implementation address.\n */\n function _getImplementation() internal view returns (address) {\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 implementation slot.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n }\n\n /**\n * @dev Perform implementation upgrade\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeTo(address newImplementation) internal {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Perform implementation upgrade with additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCall(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n _upgradeTo(newImplementation);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(newImplementation, data);\n }\n }\n\n /**\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCallUUPS(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n // Upgrades from old implementations will perform a rollback test. This test requires the new\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\n // this special case will break upgrade paths from old UUPS implementation to new ones.\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\n _setImplementation(newImplementation);\n } else {\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n require(slot == _IMPLEMENTATION_SLOT, \"ERC1967Upgrade: unsupported proxiableUUID\");\n } catch {\n revert(\"ERC1967Upgrade: new implementation is not UUPS\");\n }\n _upgradeToAndCall(newImplementation, data, forceCall);\n }\n }\n\n /**\n * @dev Storage slot with the admin of the contract.\n * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n /**\n * @dev Emitted when the admin account has changed.\n */\n event AdminChanged(address previousAdmin, address newAdmin);\n\n /**\n * @dev Returns the current admin.\n */\n function _getAdmin() internal view returns (address) {\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 admin slot.\n */\n function _setAdmin(address newAdmin) private {\n require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n */\n function _changeAdmin(address newAdmin) internal {\n emit AdminChanged(_getAdmin(), newAdmin);\n _setAdmin(newAdmin);\n }\n\n /**\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n */\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n /**\n * @dev Emitted when the beacon is upgraded.\n */\n event BeaconUpgraded(address indexed beacon);\n\n /**\n * @dev Returns the current beacon.\n */\n function _getBeacon() internal view returns (address) {\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\n }\n\n /**\n * @dev Stores a new beacon in the EIP1967 beacon slot.\n */\n function _setBeacon(address newBeacon) private {\n require(Address.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n require(\n Address.isContract(IBeacon(newBeacon).implementation()),\n \"ERC1967: beacon implementation is not a contract\"\n );\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n }\n\n /**\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n *\n * Emits a {BeaconUpgraded} event.\n */\n function _upgradeBeaconToAndCall(\n address newBeacon,\n bytes memory data,\n bool forceCall\n ) internal {\n _setBeacon(newBeacon);\n emit BeaconUpgraded(newBeacon);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/interfaces/draft-IERC1822.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822Proxiable {\n /**\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n * address.\n *\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n * function revert if invoked through a proxy.\n */\n function proxiableUUID() external view returns (bytes32);\n}\n" - }, - "@openzeppelin/contracts/utils/StorageSlot.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\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 ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\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(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\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 /**\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 {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n assembly {\n r.slot := slot\n }\n }\n}\n" - }, - "contracts/hardhat-dependency-compiler/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol';\n" - }, - "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/BeaconProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IBeacon.sol\";\nimport \"../Proxy.sol\";\nimport \"../ERC1967/ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements a proxy that gets the implementation address for each call from a {UpgradeableBeacon}.\n *\n * The beacon address is stored in storage slot `uint256(keccak256('eip1967.proxy.beacon')) - 1`, so that it doesn't\n * conflict with the storage layout of the implementation behind the proxy.\n *\n * _Available since v3.4._\n */\ncontract BeaconProxy is Proxy, ERC1967Upgrade {\n /**\n * @dev Initializes the proxy with `beacon`.\n *\n * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This\n * will typically be an encoded function call, and allows initializating the storage of the proxy like a Solidity\n * constructor.\n *\n * Requirements:\n *\n * - `beacon` must be a contract with the interface {IBeacon}.\n */\n constructor(address beacon, bytes memory data) payable {\n assert(_BEACON_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.beacon\")) - 1));\n _upgradeBeaconToAndCall(beacon, data, false);\n }\n\n /**\n * @dev Returns the current beacon address.\n */\n function _beacon() internal view virtual returns (address) {\n return _getBeacon();\n }\n\n /**\n * @dev Returns the current implementation address of the associated beacon.\n */\n function _implementation() internal view virtual override returns (address) {\n return IBeacon(_getBeacon()).implementation();\n }\n\n /**\n * @dev Changes the proxy to use a new beacon. Deprecated: see {_upgradeBeaconToAndCall}.\n *\n * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon.\n *\n * Requirements:\n *\n * - `beacon` must be a contract.\n * - The implementation returned by `beacon` must be a contract.\n */\n function _setBeacon(address beacon, bytes memory data) internal virtual {\n _upgradeBeaconToAndCall(beacon, data, false);\n }\n}\n" - }, - "contracts/controller/Controller.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/root/control/unstructured/UInitializable.sol\";\nimport \"@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol\";\nimport \"../interfaces/IController.sol\";\nimport \"../interfaces/ICollateral.sol\";\nimport \"../interfaces/IIncentivizer.sol\";\nimport \"../interfaces/IProduct.sol\";\n\n/**\n * @title Controller\n * @notice Manages creating new products and global protocol parameters.\n */\ncontract Controller is IController, UInitializable {\n /// @dev Collateral contract address for the protocol\n AddressStorage private constant _collateral = AddressStorage.wrap(keccak256(\"equilibria.perennial.Controller.collateral\"));\n function collateral() public view returns (ICollateral) { return ICollateral(_collateral.read()); }\n\n /// @dev Incentivizer contract address for the protocol\n AddressStorage private constant _incentivizer = AddressStorage.wrap(keccak256(\"equilibria.perennial.Controller.incentivizer\"));\n function incentivizer() public view returns (IIncentivizer) { return IIncentivizer(_incentivizer.read()); }\n\n /// @dev Product implementation beacon address for the protocol\n AddressStorage private constant _productBeacon = AddressStorage.wrap(keccak256(\"equilibria.perennial.Controller.productBeacon\"));\n function productBeacon() public view returns (IBeacon) { return IBeacon(_productBeacon.read()); }\n\n /// @dev Percent of collected fees that go to the protocol treasury vs the product treasury\n UFixed18Storage private constant _protocolFee = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.Controller.protocolFee\"));\n function protocolFee() public view returns (UFixed18) { return _protocolFee.read(); }\n\n /// @dev Minimum allowable funding fee for a product\n UFixed18Storage private constant _minFundingFee = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.Controller.minFundingFee\"));\n function minFundingFee() public view returns (UFixed18) { return _minFundingFee.read(); }\n\n /// @dev Fee on maintenance for liquidation\n UFixed18Storage private constant _liquidationFee = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.Controller.liquidationFee\"));\n function liquidationFee() public view returns (UFixed18) { return _liquidationFee.read(); }\n\n /// @dev Fee on incentivization programs\n UFixed18Storage private constant _incentivizationFee = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.Controller.incentivizationFee\"));\n function incentivizationFee() public view returns (UFixed18) { return _incentivizationFee.read(); }\n\n /// @dev Minimum allowable collateral amount per user account\n UFixed18Storage private constant _minCollateral = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.Controller.minCollateral\"));\n function minCollateral() public view returns (UFixed18) { return _minCollateral.read(); }\n\n /// @dev Maximum incentivization programs per product allowed\n Uint256Storage private constant _programsPerProduct = Uint256Storage.wrap(keccak256(\"equilibria.perennial.Controller.programsPerProduct\"));\n function programsPerProduct() public view returns (uint256) { return _programsPerProduct.read(); }\n\n /// @dev Protocol pauser address. address(0) defaults to owner(0)\n AddressStorage private constant _pauser = AddressStorage.wrap(keccak256(\"equilibria.perennial.Controller.pauser\"));\n function pauser() public view returns (address) {\n address pauser_ = _pauser.read();\n return pauser_ == address(0) ? owner() : pauser_;\n }\n\n /// @dev The paused status of the protocol\n BoolStorage private constant _paused = BoolStorage.wrap(keccak256(\"equilibria.perennial.Controller.paused\"));\n function paused() public view returns (bool) { return _paused.read(); }\n\n /// @dev List of product coordinators\n Coordinator[] private _coordinators;\n\n /// @dev Mapping of the coordinator for each product\n mapping(IProduct => uint256) public coordinatorFor;\n\n /**\n * @notice Initializes the contract state\n * @dev Must be called atomically as part of the upgradeable proxy deployment to\n * avoid front-running\n * @param collateral_ Collateral contract address\n * @param incentivizer_ Incentivizer contract address\n * @param productBeacon_ Product implementation beacon address\n */\n function initialize(\n ICollateral collateral_,\n IIncentivizer incentivizer_,\n IBeacon productBeacon_\n ) external initializer(1) {\n _createCoordinator();\n\n updateCollateral(collateral_);\n updateIncentivizer(incentivizer_);\n updateProductBeacon(productBeacon_);\n }\n\n /**\n * @notice Creates a new coordinator with `msg.sender` as the owner\n * @dev Can only be called by the protocol owner\n * @return New coordinator ID\n */\n function createCoordinator() external returns (uint256) {\n return _createCoordinator();\n }\n\n /**\n * @notice Creates a new coordinator with `msg.sender` as the owner\n * @dev `treasury` and `pauser` initialize as the 0-address, defaulting to the `owner`\n * @return New coordinator ID\n */\n function _createCoordinator() private returns (uint256) {\n uint256 coordinatorId = _coordinators.length;\n\n _coordinators.push(Coordinator({\n pendingOwner: address(0),\n owner: msg.sender,\n treasury: address(0)\n }));\n\n emit CoordinatorCreated(coordinatorId, msg.sender);\n\n return coordinatorId;\n }\n\n /**\n * @notice Updates the pending owner of an existing coordinator\n * @dev Must be called by the coordinator's current owner\n * @param coordinatorId Coordinator to update\n * @param newPendingOwner New pending owner address\n */\n function updateCoordinatorPendingOwner(uint256 coordinatorId, address newPendingOwner) external onlyOwner(coordinatorId) {\n _coordinators[coordinatorId].pendingOwner = newPendingOwner;\n emit CoordinatorPendingOwnerUpdated(coordinatorId, newPendingOwner);\n }\n\n /**\n * @notice Accepts ownership over an existing coordinator\n * @dev Must be called by the coordinator's pending owner\n * @param coordinatorId Coordinator to update\n */\n function acceptCoordinatorOwner(uint256 coordinatorId) external {\n Coordinator storage coordinator = _coordinators[coordinatorId];\n address newPendingOwner = coordinator.pendingOwner;\n\n if (msg.sender != newPendingOwner) revert ControllerNotPendingOwnerError(coordinatorId);\n\n coordinator.pendingOwner = address(0);\n coordinator.owner = newPendingOwner;\n emit CoordinatorOwnerUpdated(coordinatorId, newPendingOwner);\n }\n\n /**\n * @notice Updates the treasury of an existing coordinator\n * @dev Must be called by the coordinator's current owner. Defaults to the coordinator `owner` if set to address(0)\n * @param coordinatorId Coordinator to update\n * @param newTreasury New treasury address\n */\n function updateCoordinatorTreasury(uint256 coordinatorId, address newTreasury) external onlyOwner(coordinatorId) {\n _coordinators[coordinatorId].treasury = newTreasury;\n emit CoordinatorTreasuryUpdated(coordinatorId, newTreasury);\n }\n\n /**\n * @notice Creates a new product market with `provider`\n * @dev Can only be called by the coordinator owner\n * @param coordinatorId Coordinator that will own the product\n * @param productInfo Product params used to initialize the product\n * @return New product contract address\n */\n function createProduct(uint256 coordinatorId, IProduct.ProductInfo calldata productInfo)\n external onlyOwner(coordinatorId) returns (IProduct) {\n if (coordinatorId == 0) revert ControllerNoZeroCoordinatorError();\n\n BeaconProxy newProductProxy = new BeaconProxy(address(productBeacon()), abi.encodeCall(IProduct.initialize, productInfo));\n IProduct newProduct = IProduct(address(newProductProxy));\n coordinatorFor[newProduct] = coordinatorId;\n emit ProductCreated(newProduct, productInfo);\n\n return newProduct;\n }\n\n /**\n * @notice Updates the Collateral contract address\n * @param newCollateral New Collateral contract address\n */\n function updateCollateral(ICollateral newCollateral) public onlyOwner(0) {\n if (!Address.isContract(address(newCollateral))) revert ControllerNotContractAddressError();\n _collateral.store(address(newCollateral));\n emit CollateralUpdated(newCollateral);\n }\n\n /**\n * @notice Updates the Incentivizer contract address\n * @param newIncentivizer New Incentivizer contract address\n */\n function updateIncentivizer(IIncentivizer newIncentivizer) public onlyOwner(0) {\n if (!Address.isContract(address(newIncentivizer))) revert ControllerNotContractAddressError();\n _incentivizer.store(address(newIncentivizer));\n emit IncentivizerUpdated(newIncentivizer);\n }\n\n /**\n * @notice Updates the Product implementation beacon address\n * @param newProductBeacon New Product implementation beacon address\n */\n function updateProductBeacon(IBeacon newProductBeacon) public onlyOwner(0) {\n if (!Address.isContract(address(newProductBeacon))) revert ControllerNotContractAddressError();\n _productBeacon.store(address(newProductBeacon));\n emit ProductBeaconUpdated(newProductBeacon);\n }\n\n /**\n * @notice Updates the protocol-product fee split\n * @param newProtocolFee New protocol-product fee split\n */\n function updateProtocolFee(UFixed18 newProtocolFee) public onlyOwner(0) {\n if (newProtocolFee.gt(UFixed18Lib.ONE)) revert ControllerInvalidProtocolFeeError();\n\n _protocolFee.store(newProtocolFee);\n emit ProtocolFeeUpdated(newProtocolFee);\n }\n\n /**\n * @notice Updates the minimum allowed funding fee\n * @param newMinFundingFee New minimum allowed funding fee\n */\n function updateMinFundingFee(UFixed18 newMinFundingFee) public onlyOwner(0) {\n if (newMinFundingFee.gt(UFixed18Lib.ONE)) revert ControllerInvalidMinFundingFeeError();\n\n _minFundingFee.store(newMinFundingFee);\n emit MinFundingFeeUpdated(newMinFundingFee);\n }\n\n /**\n * @notice Updates the liquidation fee\n * @param newLiquidationFee New liquidation fee\n */\n function updateLiquidationFee(UFixed18 newLiquidationFee) public onlyOwner(0) {\n if (newLiquidationFee.gt(UFixed18Lib.ONE)) revert ControllerInvalidLiquidationFeeError();\n\n _liquidationFee.store(newLiquidationFee);\n emit LiquidationFeeUpdated(newLiquidationFee);\n }\n\n /**\n * @notice Updates the incentivization fee\n * @param newIncentivizationFee New incentivization fee\n */\n function updateIncentivizationFee(UFixed18 newIncentivizationFee) public onlyOwner(0) {\n if (newIncentivizationFee.gt(UFixed18Lib.ONE)) revert ControllerInvalidIncentivizationFeeError();\n\n _incentivizationFee.store(newIncentivizationFee);\n emit IncentivizationFeeUpdated(newIncentivizationFee);\n }\n\n /**\n * @notice Updates the minimum allowed collateral amount per user account\n * @param newMinCollateral New minimum allowed collateral amount\n */\n function updateMinCollateral(UFixed18 newMinCollateral) public onlyOwner(0) {\n _minCollateral.store(newMinCollateral);\n emit MinCollateralUpdated(newMinCollateral);\n }\n\n /**\n * @notice Updates the maximum incentivization programs per product allowed\n * @param newProgramsPerProduct New maximum incentivization programs per product allowed\n */\n function updateProgramsPerProduct(uint256 newProgramsPerProduct) public onlyOwner(0) {\n _programsPerProduct.store(newProgramsPerProduct);\n emit ProgramsPerProductUpdated(newProgramsPerProduct);\n }\n\n /**\n * @notice Updates the protocol pauser address. Zero address defaults to owner(0)\n * @param newPauser New protocol pauser address\n */\n function updatePauser(address newPauser) public onlyOwner(0) {\n _pauser.store(newPauser);\n emit PauserUpdated(newPauser);\n }\n\n /**\n * @notice Updates the protocol paused state\n * @param newPaused New protocol paused state\n */\n function updatePaused(bool newPaused) public onlyPauser {\n _paused.store(newPaused);\n emit PausedUpdated(newPaused);\n }\n\n /**\n * @notice Returns whether a contract is a product\n * @param product Contract address to check\n * @return Whether a contract is a product\n */\n function isProduct(IProduct product) external view returns (bool) {\n return coordinatorFor[product] != 0;\n }\n\n /**\n * @notice Returns coordinator state for coordinator `coordinatorId`\n * @param coordinatorId Coordinator to return for\n * @return Coordinator state\n */\n function coordinators(uint256 coordinatorId) external view returns (Coordinator memory) {\n return _coordinators[coordinatorId];\n }\n\n /**\n * @notice Returns the pending owner of the protocol\n * @return Owner of the protocol\n */\n function pendingOwner() public view returns (address) {\n return pendingOwner(0);\n }\n\n /**\n * @notice Returns the pending owner of the coordinator `coordinatorId`\n * @param coordinatorId Coordinator to return for\n * @return Pending owner of the coordinator\n */\n function pendingOwner(uint256 coordinatorId) public view returns (address) {\n return _coordinators[coordinatorId].pendingOwner;\n }\n\n /**\n * @notice Returns the owner of the protocol\n * @return Owner of the protocol\n */\n function owner() public view returns (address) {\n return owner(0);\n }\n\n /**\n * @notice Returns the owner of the coordinator `coordinatorId`\n * @param coordinatorId Coordinator to return for\n * @return Owner of the coordinator\n */\n function owner(uint256 coordinatorId) public view returns (address) {\n return _coordinators[coordinatorId].owner;\n }\n\n /**\n * @notice Returns the owner of the product `product`\n * @param product Product to return for\n * @return Owner of the product\n */\n function owner(IProduct product) external view returns (address) {\n return owner(coordinatorFor[product]);\n }\n\n /**\n * @notice Returns the treasury of the protocol\n * @dev Defaults to the `owner` when `treasury` is unset\n * @return Treasury of the protocol\n */\n function treasury() external view returns (address) {\n return treasury(0);\n }\n\n /**\n * @notice Returns the treasury of the coordinator `coordinatorId`\n * @dev Defaults to the `owner` when `treasury` is unset\n * @param coordinatorId Coordinator to return for\n * @return Treasury of the coordinator\n */\n function treasury(uint256 coordinatorId) public view returns (address) {\n address _treasury = _coordinators[coordinatorId].treasury;\n return _treasury == address(0) ? owner(coordinatorId) : _treasury;\n }\n\n /**\n * @notice Returns the treasury of the product `product`\n * @dev Defaults to the `owner` when `treasury` is unset\n * @param product Product to return for\n * @return Treasury of the product\n */\n function treasury(IProduct product) external view returns (address) {\n return treasury(coordinatorFor[product]);\n }\n\n /// @dev Only allow owner of `coordinatorId` to call\n modifier onlyOwner(uint256 coordinatorId) {\n if (msg.sender != owner(coordinatorId)) revert ControllerNotOwnerError(coordinatorId);\n\n _;\n }\n\n /// @dev Only allow the pauser to call\n modifier onlyPauser {\n if (msg.sender != pauser()) revert ControllerNotPauserError();\n\n _;\n }\n}\n" - }, - "contracts/incentivizer/Incentivizer.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/root/control/unstructured/UInitializable.sol\";\nimport \"@equilibria/root/control/unstructured/UReentrancyGuard.sol\";\nimport \"../interfaces/IIncentivizer.sol\";\nimport \"../interfaces/IController.sol\";\nimport \"../controller/UControllerProvider.sol\";\nimport \"./types/ProductManager.sol\";\n\n/**\n * @title Incentivizer\n * @notice Manages logic and state for all incentive programs in the protocol.\n */\ncontract Incentivizer is IIncentivizer, UInitializable, UControllerProvider, UReentrancyGuard {\n /// @dev Product management state\n mapping(IProduct => ProductManager) private _products;\n\n /// @dev Fees that have been collected, but remain unclaimed\n mapping(Token18 => UFixed18) public fees;\n\n /**\n * @notice Initializes the contract state\n * @dev Must be called atomically as part of the upgradeable proxy deployment to\n * avoid front-running\n * @param controller_ Factory contract address\n */\n function initialize(IController controller_) external initializer(1) {\n __UControllerProvider__initialize(controller_);\n __UReentrancyGuard__initialize();\n }\n\n /**\n * @notice Creates a new incentive program\n * @dev Must be called as the product or protocol owner\n * @param product The product to create the new program on\n * @param programInfo Parameters for the new program\n * @return programId New program's ID\n */\n function create(IProduct product, ProgramInfo calldata programInfo)\n external\n nonReentrant\n isProduct(product)\n notPaused\n onlyOwner(programInfo.coordinatorId)\n returns (uint256 programId) {\n IController _controller = controller();\n\n // Validate\n if (programInfo.coordinatorId != 0 && programInfo.coordinatorId != _controller.coordinatorFor(product))\n revert IncentivizerNotAllowedError(product);\n if (active(product) >= _controller.programsPerProduct())\n revert IncentivizerTooManyProgramsError();\n ProgramInfoLib.validate(programInfo);\n\n // Take fee\n (ProgramInfo memory newProgramInfo, UFixed18 programFeeAmount) = ProgramInfoLib.deductFee(programInfo, _controller.incentivizationFee());\n fees[newProgramInfo.token] = fees[newProgramInfo.token].add(programFeeAmount);\n\n // Register program\n programId = _products[product].register(newProgramInfo);\n\n // Charge creator\n newProgramInfo.token.pull(msg.sender, programInfo.amount.sum());\n\n emit ProgramCreated(\n product,\n programId,\n newProgramInfo,\n programFeeAmount\n );\n }\n\n /**\n * @notice Completes an in-progress program early\n * @dev Must be called as the program owner\n * @param product Product that the program is running on\n * @param programId Program to complete early\n */\n function complete(IProduct product, uint256 programId)\n external\n nonReentrant\n isProgram(product, programId)\n notPaused\n onlyProgramOwner(product, programId)\n {\n ProductManagerLib.SyncResult memory syncResult = _products[product].complete(product, programId);\n _handleSyncResult(product, syncResult);\n }\n\n /**\n * @notice Starts and completes programs as they become available\n * @dev Called every settle() from each product\n * @param currentOracleVersion The preloaded current oracle version\n */\n function sync(IOracleProvider.OracleVersion memory currentOracleVersion) external onlyProduct {\n IProduct product = IProduct(msg.sender);\n\n ProductManagerLib.SyncResult[] memory syncResults = _products[product].sync(product, currentOracleVersion);\n for (uint256 i = 0; i < syncResults.length; i++) {\n _handleSyncResult(product, syncResults[i]);\n }\n }\n\n /**\n * @notice Handles refunding and event emitting on program start and completion\n * @param product Product that the program is running on\n * @param syncResult The data from the sync event to handle\n */\n function _handleSyncResult(IProduct product, ProductManagerLib.SyncResult memory syncResult) private {\n uint256 programId = syncResult.programId;\n if (!syncResult.refundAmount.isZero())\n _products[product].token(programId).push(treasury(product, programId), syncResult.refundAmount);\n if (syncResult.versionStarted != 0)\n emit ProgramStarted(product, programId, syncResult.versionStarted);\n if (syncResult.versionComplete != 0)\n emit ProgramComplete(product, programId, syncResult.versionComplete);\n }\n\n /**\n * @notice Settles unsettled balance for `account`\n * @dev Called immediately proceeding a position update in the corresponding product\n * @param account Account to sync\n * @param currentOracleVersion The preloaded current oracle version\n */\n function syncAccount(\n address account,\n IOracleProvider.OracleVersion memory currentOracleVersion\n ) external onlyProduct {\n IProduct product = IProduct(msg.sender);\n _products[product].syncAccount(product, account, currentOracleVersion);\n }\n\n /**\n * @notice Claims all of `msg.sender`'s rewards for `product` programs\n * @param product Product to claim rewards for\n * @param programIds Programs to claim rewards for\n */\n function claim(IProduct product, uint256[] calldata programIds)\n external\n nonReentrant\n {\n _claimProduct(product, programIds);\n }\n\n /**\n * @notice Claims all of `msg.sender`'s rewards for a specific program\n * @param products Products to claim rewards for\n * @param programIds Programs to claim rewards for\n */\n function claim(IProduct[] calldata products, uint256[][] calldata programIds)\n external\n nonReentrant\n {\n if (products.length != programIds.length) revert IncentivizerBatchClaimArgumentMismatchError();\n for (uint256 i; i < products.length; i++) {\n _claimProduct(products[i], programIds[i]);\n }\n }\n\n /**\n * @notice Claims all of `msg.sender`'s rewards for `product` programs\n * @dev Internal helper with validation checks\n * @param product Product to claim rewards for\n * @param programIds Programs to claim rewards for\n */\n function _claimProduct(IProduct product, uint256[] memory programIds)\n private\n isProduct(product)\n notPaused\n settleForAccount(msg.sender, product)\n {\n for (uint256 i; i < programIds.length; i++) {\n _claimProgram(product, programIds[i]);\n }\n }\n\n /**\n * @notice Claims all of `msg.sender`'s rewards for `programId` on `product`\n * @dev Internal helper with validation checks\n * @param product Product to claim rewards for\n * @param programId Program to claim rewards for\n */\n function _claimProgram(IProduct product, uint256 programId)\n private\n isProgram(product, programId)\n {\n ProductManager storage productManager = _products[product];\n UFixed18 claimAmount = productManager.claim(msg.sender, programId);\n productManager.token(programId).push(msg.sender, claimAmount);\n emit Claim(product, msg.sender, programId, claimAmount);\n }\n\n /**\n * @notice Claims all `tokens` fees to the protocol treasury\n * @param tokens Tokens to claim fees for\n */\n function claimFee(Token18[] calldata tokens) external notPaused {\n for(uint256 i; i < tokens.length; i++) {\n Token18 token = tokens[i];\n UFixed18 amount = fees[token];\n\n fees[token] = UFixed18Lib.ZERO;\n token.push(controller().treasury(), amount);\n\n emit FeeClaim(token, amount);\n }\n }\n\n /**\n * @notice Returns the quantity of active programs for a given product\n * @param product Product to check for\n * @return Number of active programs\n */\n function active(IProduct product) public view returns (uint256) {\n return _products[product].active();\n }\n\n /**\n * @notice Returns the quantity of programs for a given product\n * @param product Product to check for\n * @return Number of programs (inactive or active)\n */\n function count(IProduct product) external view returns (uint256) {\n return _products[product].programInfos.length;\n }\n\n /**\n * @notice Returns program info for program `programId`\n * @param product Product to return for\n * @param programId Program to return for\n * @return Program info\n */\n function programInfos(IProduct product, uint256 programId) external view returns (ProgramInfo memory) {\n return _products[product].programInfos[programId];\n }\n\n /**\n * @notice Returns `account`'s total unclaimed rewards for a specific program\n * @param product Product to return for\n * @param account Account to return for\n * @param programId Program to return for\n * @return `account`'s total unclaimed rewards for `programId`\n */\n function unclaimed(IProduct product, address account, uint256 programId) external view returns (UFixed18) {\n return _products[product].unclaimed(account, programId);\n }\n\n /**\n * @notice Returns available rewards for a specific program\n * @param product Product to return for\n * @param programId Program to return for\n * @return Available rewards for `programId`\n */\n function available(IProduct product, uint256 programId) external view returns (UFixed18) {\n return _products[product].programs[programId].available;\n }\n\n /**\n * @notice Returns the version started for a specific program\n * @param product Product to return for\n * @param programId Program to return for\n * @return The version started for `programId`\n */\n function versionStarted(IProduct product, uint256 programId) external view returns (uint256) {\n return _products[product].programs[programId].versionStarted;\n }\n\n /**\n * @notice Returns the version completed for a specific program\n * @param product Product to return for\n * @param programId Program to return for\n * @return The version completed for `programId`\n */\n function versionComplete(IProduct product, uint256 programId) external view returns (uint256) {\n return _products[product].programs[programId].versionComplete;\n }\n\n /**\n * @notice Returns the owner of a specific program\n * @param product Product to return for\n * @param programId Program to return for\n * @return The owner of `programId`\n */\n function owner(IProduct product, uint256 programId) public view returns (address) {\n return controller().owner(_products[product].programInfos[programId].coordinatorId);\n }\n\n /**\n * @notice Returns the treasury of a specific program\n * @param product Product to return for\n * @param programId Program to return for\n * @return The treasury of `programId`\n */\n function treasury(IProduct product, uint256 programId) public view returns (address) {\n return controller().treasury(_products[product].programInfos[programId].coordinatorId);\n }\n\n /// @dev Helper to fully settle an account's state\n modifier settleForAccount(address account, IProduct product) {\n product.settleAccount(account);\n\n _;\n }\n\n /// @dev Only allow the owner of `programId` to call\n modifier onlyProgramOwner(IProduct product, uint256 programId) {\n if (msg.sender != owner(product, programId)) revert IncentivizerNotProgramOwnerError(product, programId);\n\n _;\n }\n\n /// @dev Only allow a valid `programId`\n modifier isProgram(IProduct product, uint256 programId) {\n if (!_products[product].valid(programId)) revert IncentivizerInvalidProgramError(product, programId);\n\n _;\n }\n}\n" - }, - "contracts/incentivizer/types/ProductManager.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport \"./Program.sol\";\n\n/// @dev ProductManager type\nstruct ProductManager {\n /// @dev Static program state\n ProgramInfo[] programInfos;\n\n /// @dev Dynamic program state\n mapping(uint256 => Program) programs;\n\n /// @dev Mapping of all active programs for each product\n EnumerableSet.UintSet activePrograms;\n\n /// @dev Mapping of all active programs for each user\n mapping(address => EnumerableSet.UintSet) activeProgramsFor;\n\n /// @dev Mapping of the next program to watch for for each user\n mapping(address => uint256) nextProgramFor;\n}\nusing ProductManagerLib for ProductManager global;\n\n/**\n * @title ProductManagerLib\n * @notice Library that manages each product's incentivization state and logic.\n */\nlibrary ProductManagerLib {\n using EnumerableSet for EnumerableSet.UintSet;\n\n /// @dev Result data for a sync event\n struct SyncResult {\n /// @dev The programId that was updated\n uint256 programId;\n\n /// @dev If non-zero, the new versionStart value of the program\n uint256 versionStarted;\n\n /// @dev If non-zero, the new versionComplete value of the program\n uint256 versionComplete;\n\n /// @dev If non-zero, the amount to refund due to completion\n UFixed18 refundAmount;\n }\n\n /**\n * @notice Registers a new program on this product\n * @param self The Product manager to operate on\n * @param programInfo The static program info\n * @return programId The new program's ID\n */\n function register(\n ProductManager storage self,\n ProgramInfo memory programInfo\n ) internal returns (uint256 programId) {\n programId = self.programInfos.length;\n self.programInfos.push(programInfo);\n self.programs[programId].initialize(programInfo);\n self.activePrograms.add(programId);\n }\n\n /**\n * @notice Syncs this product with the latest data\n * @param self The Program manager to operate on\n * @param product This Product\n * @param currentOracleVersion The preloaded current oracle version\n */\n function sync(\n ProductManager storage self,\n IProduct product,\n IOracleProvider.OracleVersion memory currentOracleVersion\n ) internal returns (SyncResult[] memory results) {\n\n uint256[] memory activeProgramIds = self.activePrograms.values();\n results = new SyncResult[](activeProgramIds.length);\n\n for (uint256 i; i < activeProgramIds.length; i++) {\n // Load program\n uint256 programId = activeProgramIds[i];\n ProgramInfo memory programInfo = self.programInfos[programId];\n Program storage program = self.programs[programId];\n\n // If timestamp-started, grab current version (first version after start)\n uint256 versionStarted;\n if (program.versionStarted == 0 && programInfo.isStarted(currentOracleVersion.timestamp)) {\n versionStarted = _start(self, programId, currentOracleVersion);\n }\n\n // If timestamp-completed, grab previous version (last version before completion)\n uint256 versionComplete;\n UFixed18 refundAmount;\n if (program.versionComplete == 0 && programInfo.isComplete(currentOracleVersion.timestamp)) {\n (versionComplete, refundAmount) = _complete(self, product, programId);\n }\n\n // Save result\n results[i] = SyncResult(programId, versionStarted, versionComplete, refundAmount);\n }\n }\n\n /**\n * @notice Syncs an account for this product with the latest data\n * @dev Assumes that sync() has already been called as part of the transaction flow\n * @param self The Program manager to operate on\n * @param product This Product\n * @param account The account to sync\n * @param currentOracleVersion The preloaded current oracle version\n */\n function syncAccount(\n ProductManager storage self,\n IProduct product,\n address account,\n IOracleProvider.OracleVersion memory currentOracleVersion\n ) internal {\n\n // Add any unseen programs\n uint256 fromProgramId = self.nextProgramFor[account];\n uint256 toProgramId = self.programInfos.length;\n for (uint256 programId = fromProgramId; programId < toProgramId; programId++) {\n self.activeProgramsFor[account].add(programId);\n }\n self.nextProgramFor[account] = toProgramId;\n\n // Settle programs\n uint256[] memory activeProgramIds = self.activeProgramsFor[account].values();\n for (uint256 i; i < activeProgramIds.length; i++) {\n uint256 programId = activeProgramIds[i];\n Program storage program = self.programs[programId];\n program.settle(product, self.programInfos[programId], account, currentOracleVersion);\n if (!self.activePrograms.contains(programId) && currentOracleVersion.version >= program.versionComplete) {\n self.activeProgramsFor[account].remove(programId);\n }\n }\n }\n\n /**\n * @notice Returns the quantity of active programs for this product\n * @param self The Program manager to operate on\n * @return The quantity of active programs\n */\n function active(ProductManager storage self) internal view returns (uint256) {\n return self.activePrograms.length();\n }\n\n /**\n * @notice Forces the specified program to complete if it hasn't already\n * @param self The Program manager to operate on\n * @param product The Product to operate on\n * @param programId The Program to complete\n * @return result The sync result data from completion\n */\n function complete(\n ProductManager storage self,\n IProduct product,\n uint256 programId\n ) internal returns (SyncResult memory result) {\n Program storage program = self.programs[programId];\n\n // If not started, start first\n if (program.versionStarted == 0) {\n result.versionStarted = _start(self, programId, product.currentVersion());\n }\n\n // If not completed already, complete\n if (program.versionComplete == 0) {\n (result.versionComplete, result.refundAmount) = _complete(self, product, programId);\n }\n }\n\n /**\n * @notice Starts the program\n * @dev Rewards do not start accruing until the program has started\n * Internal helper, does not prevent incorrectly-timed starting\n * @param self The Program manager to operate on\n * @param programId The Program to start\n * @param currentOracleVersion The effective starting oracle version\n * @return versionStarted The version that the program started\n */\n function _start(\n ProductManager storage self,\n uint256 programId,\n IOracleProvider.OracleVersion memory currentOracleVersion\n ) internal returns (uint256 versionStarted) {\n versionStarted = currentOracleVersion.version;\n self.programs[programId].start(currentOracleVersion.version);\n }\n\n /**\n * @notice Completes the program\n * @dev Completion stops rewards from accruing\n * Internal helper, does not prevent incorrectly-timed completion\n * @param self The Program manager to operate on\n * @param product The Product to operate on\n * @param programId The Program to complete\n * @return versionComplete The version that the program complete\n * @return refundAmount The refunded token amount\n */\n function _complete(\n ProductManager storage self,\n IProduct product,\n uint256 programId\n ) internal returns (uint256 versionComplete, UFixed18 refundAmount) {\n (versionComplete, refundAmount) = self.programs[programId].complete(product, self.programInfos[programId]);\n self.activePrograms.remove(programId);\n }\n\n /**\n * @notice Claims all of `account`'s rewards for a specific program\n * @param self The Program manager to operate on\n * @param account Account to claim rewards for\n * @param programId Program to claim rewards for\n * @return Amount claimed\n */\n function claim(ProductManager storage self, address account, uint256 programId) internal returns (UFixed18) {\n return self.programs[programId].claim(account);\n }\n\n /**\n * @notice Returns the total amount of unclaimed rewards for account `account`\n * @param self The Program manager to operate on\n * @param account The account to check for\n * @param programId The Program to check for\n * @return Total amount of unclaimed rewards for account\n */\n function unclaimed(ProductManager storage self, address account, uint256 programId) internal view returns (UFixed18) {\n if (!valid(self, programId)) return (UFixed18Lib.ZERO);\n return self.programs[programId].settled[account];\n }\n\n /**\n * @notice Returns the token denominatino of the program's rewards\n * @param self The Program manager to operate on\n * @param programId The Program to check for\n * @return The token for the program\n */\n function token(ProductManager storage self, uint256 programId) internal view returns (Token18) {\n return self.programInfos[programId].token;\n }\n\n /**\n * @notice Returns whether the supplied programId is valid\n * @param self The Program manager to operate on\n * @param programId The Program to check for\n * @return Whether the supplied programId is valid\n */\n function valid(ProductManager storage self, uint256 programId) internal view returns (bool) {\n return programId < self.programInfos.length;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/structs/EnumerableSet.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/structs/EnumerableSet.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping(bytes32 => uint256) _indexes;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (lastIndex != toDeleteIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._values[toDeleteIndex] = lastValue;\n // Update the index for the moved value\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the index for the deleted slot\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._indexes[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n return _values(set._inner);\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n assembly {\n result := store\n }\n\n return result;\n }\n}\n" - }, - "contracts/incentivizer/types/Program.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../../interfaces/types/ProgramInfo.sol\";\n\n/// @dev Program type\nstruct Program {\n /// @dev Mapping of latest rewards settled for each account\n mapping(address => UFixed18) settled;\n\n /// @dev Total amount of rewards yet to be claimed\n UFixed18 available;\n\n /// @dev Oracle version that the program started, 0 when hasn't started\n uint256 versionStarted;\n\n /// @dev Oracle version that the program completed, 0 is still ongoing\n uint256 versionComplete;\n}\nusing ProgramLib for Program global;\n\n/**\n * @title ProgramLib\n * @notice Library that manages all of the mutable state for a single incentivization program.\n */\nlibrary ProgramLib {\n /**\n * @notice Initializes the program state\n * @param self The Program to operate on\n * @param programInfo Static program information\n */\n function initialize(Program storage self, ProgramInfo memory programInfo) internal {\n self.available = programInfo.amount.sum();\n }\n\n /**\n * @notice Starts the program\n * @dev Rewards do not start accruing until the program has started accruing\n * Does not stop double-starting\n * @param self The Program to operate on\n * @param oracleVersion The effective starting oracle version\n */\n function start(Program storage self, uint256 oracleVersion) internal {\n self.versionStarted = oracleVersion;\n }\n\n /**\n * @notice Completes the program\n * @dev Completion stops rewards from accruing\n * Does not prevent double-completion\n * @param self The Program to operate on\n * @param product The Product to operate on\n * @param programInfo Static program information\n * @return versionComplete The version that the program completed on\n * @return refundAmount The refund amount from the program\n */\n function complete(\n Program storage self,\n IProduct product,\n ProgramInfo memory programInfo\n ) internal returns (uint256 versionComplete, UFixed18 refundAmount) {\n uint256 versionStarted = self.versionStarted;\n versionComplete = Math.max(versionStarted, product.latestVersion());\n self.versionComplete = versionComplete;\n\n IOracleProvider.OracleVersion memory fromOracleVersion = product.atVersion(versionStarted);\n IOracleProvider.OracleVersion memory toOracleVersion = product.atVersion(versionComplete);\n\n uint256 inactiveDuration = programInfo.duration - (toOracleVersion.timestamp - fromOracleVersion.timestamp);\n refundAmount = programInfo.amount.sum().muldiv(inactiveDuration, programInfo.duration);\n self.available = self.available.sub(refundAmount);\n }\n\n /**\n * @notice Settles unclaimed rewards for account `account`\n * @param self The Program to operate on\n * @param product The Product to operate on\n * @param programInfo Static program information\n * @param account The account to settle for\n * @param currentOracleVersion The preloaded current oracle version\n */\n function settle(\n Program storage self,\n IProduct product,\n ProgramInfo memory programInfo,\n address account,\n IOracleProvider.OracleVersion memory currentOracleVersion\n ) internal {\n UFixed18 unsettledAmount = _unsettled(self, product, programInfo, account, currentOracleVersion);\n self.settled[account] = self.settled[account].add(unsettledAmount);\n self.available = self.available.sub(unsettledAmount);\n }\n\n /**\n * @notice Claims settled rewards for account `account`\n * @param self The Program to operate on\n * @param account The account to claim for\n */\n function claim(Program storage self, address account) internal returns (UFixed18 claimedAmount) {\n claimedAmount = self.settled[account];\n self.settled[account] = UFixed18Lib.ZERO;\n }\n\n /**\n * @notice Returns the unsettled amount of unclaimed rewards for account `account`\n * @dev Clears when a program is closed\n * Assumes that position is unchanged since last settlement, must be settled prior to user position update\n * @param self The Program to operate on\n * @param product The Product to operate on\n * @param programInfo Static program information\n * @param account The account to claim for\n * @param currentOracleVersion Current oracle version\n * @return amount Amount of unsettled rewards for account\n */\n function _unsettled(\n Program storage self,\n IProduct product,\n ProgramInfo memory programInfo,\n address account,\n IOracleProvider.OracleVersion memory currentOracleVersion\n ) private view returns (UFixed18 amount) {\n // program stage overview\n //\n // V = latest user settle version, V' = current user settle version\n // S = versionStarted, E = versionEnded\n //\n // (1) V V' S E program not yet started\n // (2) V S V' E use versionStarted -> V' for userShareDelta\n // (3) S V V' E use V -> V' for userShareDelta\n // (4) S V E V' use V -> versionComplete for userShareDelta\n // (5) S E V V' program already completed\n // (6) V S E V' use versionStarted -> versionComplete for userShareDelta\n //\n // NOTE: V == S and V' == E both default to the inner case\n\n (uint256 _versionStarted, uint256 _versionComplete) = (\n self.versionStarted == 0 ? currentOracleVersion.version : self.versionStarted, // start must be no earlier than current version\n self.versionComplete == 0 ? type(uint256).max : self.versionComplete // we don't know when completion occurs\n );\n\n // accruing must start between self.versionStarted and self.versionComplete\n uint256 fromVersion = Math.min(_versionComplete, Math.max(_versionStarted, product.latestVersion(account)));\n // accruing must complete between self.versionStarted and self.versionComplete, we know self.versionStarted must be no earlier than current version\n uint256 toVersion = Math.min(_versionComplete, currentOracleVersion.version);\n\n Accumulator memory globalShareDelta = product.shareAtVersion(toVersion).sub(product.shareAtVersion(fromVersion));\n Accumulator memory computedUserShareDelta = product.position(account).mul(globalShareDelta);\n amount = UFixed18Lib.from(programInfo.amountPerShare().mul(computedUserShareDelta).sum());\n }\n}\n" - }, - "@equilibria/emptyset-batcher/batcher/Batcher.sol": { - "content": "//SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"@equilibria/root/token/types/Token6.sol\";\nimport \"@equilibria/root/control/unstructured/UOwnable.sol\";\nimport \"../interfaces/IBatcher.sol\";\n\nabstract contract Batcher is IBatcher, UOwnable {\n using UFixed18Lib for UFixed18;\n using Token18Lib for Token18;\n using Token6Lib for Token6;\n\n IEmptySetReserve public immutable RESERVE;\n Token18 public immutable DSU;\n Token6 public immutable USDC;\n\n constructor(IEmptySetReserve reserve, Token18 dsu, Token6 usdc) {\n RESERVE = reserve;\n DSU = dsu;\n USDC = usdc;\n\n DSU.approve(address(RESERVE));\n USDC.approve(address(RESERVE));\n\n __UOwnable__initialize();\n }\n\n function totalBalance() public view returns (UFixed18) {\n return DSU.balanceOf().add(USDC.balanceOf());\n }\n\n function wrap(UFixed18 amount, address to) external {\n _wrap(amount, to);\n emit Wrap(to, amount);\n }\n\n function _wrap(UFixed18 amount, address to) virtual internal {\n USDC.pull(msg.sender, amount, true);\n DSU.push(to, amount);\n }\n\n function unwrap(UFixed18 amount, address to) external {\n _unwrap(amount, to);\n emit Unwrap(to, amount);\n }\n\n function _unwrap(UFixed18 amount, address to) virtual internal {\n DSU.pull(msg.sender, amount);\n USDC.push(to, amount);\n }\n\n function rebalance() external {\n (UFixed18 usdcBalance, UFixed18 dsuBalance) = (USDC.balanceOf(), DSU.balanceOf());\n\n _rebalance(USDC.balanceOf(), DSU.balanceOf());\n\n (UFixed18 oldBalance, UFixed18 newBalance) = (usdcBalance.add(dsuBalance), totalBalance());\n if (!oldBalance.eq(newBalance)) revert BatcherBalanceMismatchError(oldBalance, newBalance);\n\n emit Rebalance(usdcBalance, UFixed18Lib.ZERO);\n }\n\n function _rebalance(UFixed18 usdcBalance, UFixed18 dsuBalance) virtual internal;\n\n function close() external onlyOwner {\n UFixed18 usdcBalance = USDC.balanceOf();\n if (!usdcBalance.isZero()) RESERVE.mint(usdcBalance);\n\n UFixed18 dsuBalance = DSU.balanceOf();\n UFixed18 repayAmount = UFixed18Lib.min(RESERVE.debt(address(this)), dsuBalance);\n UFixed18 returnAmount = dsuBalance.sub(repayAmount);\n\n RESERVE.repay(address(this), repayAmount);\n if (!returnAmount.isZero()) DSU.push(address(RESERVE), dsuBalance.sub(repayAmount));\n\n emit Close(dsuBalance);\n }\n}\n\ninterface IEmptySetReserve {\n function debt(address borrower) external view returns (UFixed18);\n function repay(address borrower, UFixed18 amount) external;\n function mint(UFixed18 amount) external;\n function redeem(UFixed18 amount) external;\n}\n" - }, - "@equilibria/root/token/types/Token6.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"../../number/types/UFixed18.sol\";\n\n/// @dev Token6\ntype Token6 is address;\nusing Token6Lib for Token6 global;\ntype Token6Storage is bytes32;\nusing Token6StorageLib for Token6Storage global;\n\n/**\n * @title Token6Lib\n * @notice Library to manage 6-decimal ERC20s that is compliant with the fixed-decimal types.\n * @dev Automatically converts from Base-6 token amounts to Base-18 UFixed18 amounts, with optional rounding\n */\nlibrary Token6Lib {\n using SafeERC20 for IERC20;\n\n Token6 public constant ZERO = Token6.wrap(address(0));\n\n uint256 private constant OFFSET = 1e12;\n\n /**\n * @notice Returns whether a token is the zero address\n * @param self Token to check for\n * @return Whether the token is the zero address\n */\n function isZero(Token6 self) internal pure returns (bool) {\n return Token6.unwrap(self) == Token6.unwrap(ZERO);\n }\n\n /**\n * @notice Returns whether the two tokens are equal\n * @param a First token to compare\n * @param b Second token to compare\n * @return Whether the two tokens are equal\n */\n function eq(Token6 a, Token6 b) internal pure returns (bool) {\n return Token6.unwrap(a) == Token6.unwrap(b);\n }\n\n /**\n * @notice Approves `grantee` to spend infinite tokens from the caller\n * @param self Token to transfer\n * @param grantee Address to allow spending\n */\n function approve(Token6 self, address grantee) internal {\n IERC20(Token6.unwrap(self)).safeApprove(grantee, type(uint256).max);\n }\n\n /**\n * @notice Approves `grantee` to spend `amount` tokens from the caller\n * @dev There are important race conditions to be aware of when using this function\n with values other than 0. This will revert if moving from non-zero to non-zero amounts\n See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/a55b7d13722e7ce850b626da2313f3e66ca1d101/contracts/token/ERC20/IERC20.sol#L57\n * @param self Token to transfer\n * @param grantee Address to allow spending\n * @param amount Amount of tokens to approve to spend\n */\n function approve(Token6 self, address grantee, UFixed18 amount) internal {\n IERC20(Token6.unwrap(self)).safeApprove(grantee, toTokenAmount(amount, false));\n }\n\n /**\n * @notice Approves `grantee` to spend `amount` tokens from the caller\n * @dev There are important race conditions to be aware of when using this function\n with values other than 0. This will revert if moving from non-zero to non-zero amounts\n See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/a55b7d13722e7ce850b626da2313f3e66ca1d101/contracts/token/ERC20/IERC20.sol#L57\n * @param self Token to transfer\n * @param grantee Address to allow spending\n * @param amount Amount of tokens to approve to spend\n * @param roundUp Whether to round decimal token amount up to the next unit\n */\n function approve(Token6 self, address grantee, UFixed18 amount, bool roundUp) internal {\n IERC20(Token6.unwrap(self)).safeApprove(grantee, toTokenAmount(amount, roundUp));\n }\n\n /**\n * @notice Transfers all held tokens from the caller to the `recipient`\n * @param self Token to transfer\n * @param recipient Address to receive the tokens\n */\n function push(Token6 self, address recipient) internal {\n push(self, recipient, balanceOf(self, address(this)));\n }\n\n /**\n * @notice Transfers `amount` tokens from the caller to the `recipient`\n * @param self Token to transfer\n * @param recipient Address to transfer tokens to\n * @param amount Amount of tokens to transfer\n */\n function push(Token6 self, address recipient, UFixed18 amount) internal {\n IERC20(Token6.unwrap(self)).safeTransfer(recipient, toTokenAmount(amount, false));\n }\n\n /**\n * @notice Transfers `amount` tokens from the caller to the `recipient`\n * @param self Token to transfer\n * @param recipient Address to transfer tokens to\n * @param amount Amount of tokens to transfer\n * @param roundUp Whether to round decimal token amount up to the next unit\n */\n function push(Token6 self, address recipient, UFixed18 amount, bool roundUp) internal {\n IERC20(Token6.unwrap(self)).safeTransfer(recipient, toTokenAmount(amount, roundUp));\n }\n\n /**\n * @notice Transfers `amount` tokens from the `benefactor` to the caller\n * @dev Reverts if trying to pull Ether\n * @param self Token to transfer\n * @param benefactor Address to transfer tokens from\n * @param amount Amount of tokens to transfer\n */\n function pull(Token6 self, address benefactor, UFixed18 amount) internal {\n IERC20(Token6.unwrap(self)).safeTransferFrom(benefactor, address(this), toTokenAmount(amount, false));\n }\n\n /**\n * @notice Transfers `amount` tokens from the `benefactor` to the caller\n * @dev Reverts if trying to pull Ether\n * @param self Token to transfer\n * @param benefactor Address to transfer tokens from\n * @param amount Amount of tokens to transfer\n * @param roundUp Whether to round decimal token amount up to the next unit\n */\n function pull(Token6 self, address benefactor, UFixed18 amount, bool roundUp) internal {\n IERC20(Token6.unwrap(self)).safeTransferFrom(benefactor, address(this), toTokenAmount(amount, roundUp));\n }\n\n /**\n * @notice Transfers `amount` tokens from the `benefactor` to `recipient`\n * @dev Reverts if trying to pull Ether\n * @param self Token to transfer\n * @param benefactor Address to transfer tokens from\n * @param recipient Address to transfer tokens to\n * @param amount Amount of tokens to transfer\n */\n function pullTo(Token6 self, address benefactor, address recipient, UFixed18 amount) internal {\n IERC20(Token6.unwrap(self)).safeTransferFrom(benefactor, recipient, toTokenAmount(amount, false));\n }\n\n /**\n * @notice Transfers `amount` tokens from the `benefactor` to `recipient`\n * @dev Reverts if trying to pull Ether\n * @param self Token to transfer\n * @param benefactor Address to transfer tokens from\n * @param recipient Address to transfer tokens to\n * @param amount Amount of tokens to transfer\n * @param roundUp Whether to round decimal token amount up to the next unit\n */\n function pullTo(Token6 self, address benefactor, address recipient, UFixed18 amount, bool roundUp) internal {\n IERC20(Token6.unwrap(self)).safeTransferFrom(benefactor, recipient, toTokenAmount(amount, roundUp));\n }\n\n /**\n * @notice Returns the name of the token\n * @param self Token to check for\n * @return Token name\n */\n function name(Token6 self) internal view returns (string memory) {\n return IERC20Metadata(Token6.unwrap(self)).name();\n }\n\n /**\n * @notice Returns the symbol of the token\n * @param self Token to check for\n * @return Token symbol\n */\n function symbol(Token6 self) internal view returns (string memory) {\n return IERC20Metadata(Token6.unwrap(self)).symbol();\n }\n\n /**\n * @notice Returns the `self` token balance of the caller\n * @param self Token to check for\n * @return Token balance of the caller\n */\n function balanceOf(Token6 self) internal view returns (UFixed18) {\n return balanceOf(self, address(this));\n }\n\n /**\n * @notice Returns the `self` token balance of `account`\n * @param self Token to check for\n * @param account Account to check\n * @return Token balance of the account\n */\n function balanceOf(Token6 self, address account) internal view returns (UFixed18) {\n return fromTokenAmount(IERC20(Token6.unwrap(self)).balanceOf(account));\n }\n\n /**\n * @notice Converts the unsigned fixed-decimal amount into the token amount according to\n * it's defined decimals\n * @dev Provides the ability to \"round up\" the token amount which is useful in situations where\n * are swapping one token for another and don't want to give away \"free\" units due to rounding\n * errors in the favor of the user.\n * @param amount Amount to convert\n * @param roundUp Whether to round decimal token amount up to the next unit\n * @return Normalized token amount\n */\n function toTokenAmount(UFixed18 amount, bool roundUp) private pure returns (uint256) {\n return roundUp ? Math.ceilDiv(UFixed18.unwrap(amount), OFFSET) : UFixed18.unwrap(amount) / OFFSET;\n }\n\n /**\n * @notice Converts the token amount into the unsigned fixed-decimal amount according to\n * it's defined decimals\n * @param amount Token amount to convert\n * @return Normalized unsigned fixed-decimal amount\n */\n function fromTokenAmount(uint256 amount) private pure returns (UFixed18) {\n return UFixed18.wrap(amount * OFFSET);\n }\n}\n\nlibrary Token6StorageLib {\n function read(Token6Storage self) internal view returns (Token6 value) {\n assembly {\n value := sload(self)\n }\n }\n\n function store(Token6Storage self, Token6 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "@equilibria/root/control/unstructured/UOwnable.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"./UInitializable.sol\";\nimport \"../../storage/UStorage.sol\";\n\n/**\n * @title UOwnable\n * @notice Library to manage the ownership lifecycle of upgradeable contracts.\n * @dev This contract has been extended from the Open Zeppelin library to include an\n * unstructured storage pattern so that it can be safely mixed in with upgradeable\n * contracts without affecting their storage patterns through inheritance.\n */\nabstract contract UOwnable is UInitializable {\n event OwnerUpdated(address indexed newOwner);\n event PendingOwnerUpdated(address indexed newPendingOwner);\n\n error UOwnableNotOwnerError(address sender);\n error UOwnableNotPendingOwnerError(address sender);\n\n /// @dev The owner address\n AddressStorage private constant _owner = AddressStorage.wrap(keccak256(\"equilibria.root.UOwnable.owner\"));\n function owner() public view returns (address) { return _owner.read(); }\n\n /// @dev The pending owner address\n AddressStorage private constant _pendingOwner = AddressStorage.wrap(keccak256(\"equilibria.root.UOwnable.pendingOwner\"));\n function pendingOwner() public view returns (address) { return _pendingOwner.read(); }\n\n /**\n * @notice Initializes the contract setting `msg.sender` as the initial owner\n */\n function __UOwnable__initialize() internal onlyInitializer {\n _updateOwner(msg.sender);\n }\n\n /**\n * @notice Updates the new pending owner\n * @dev Can only be called by the current owner\n * New owner does not take affect until that address calls `acceptOwner()`\n * @param newPendingOwner New pending owner address\n */\n function updatePendingOwner(address newPendingOwner) public onlyOwner {\n _pendingOwner.store(newPendingOwner);\n emit PendingOwnerUpdated(newPendingOwner);\n }\n\n /**\n * @notice Accepts and transfers the ownership of the contract to the pending owner\n * @dev Can only be called by the pending owner to ensure correctness\n */\n function acceptOwner() external {\n if (msg.sender != pendingOwner()) revert UOwnableNotPendingOwnerError(msg.sender);\n\n _updateOwner(pendingOwner());\n updatePendingOwner(address(0));\n }\n\n /**\n * @notice Updates the owner address\n * @param newOwner New owner address\n */\n function _updateOwner(address newOwner) private {\n _owner.store(newOwner);\n emit OwnerUpdated(newOwner);\n }\n\n /// @dev Throws if called by any account other than the owner\n modifier onlyOwner() {\n if (owner() != msg.sender) revert UOwnableNotOwnerError(msg.sender);\n _;\n }\n}\n" - }, - "@equilibria/emptyset-batcher/interfaces/IBatcher.sol": { - "content": "//SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\n\ninterface IBatcher {\n event Wrap(address indexed to, UFixed18 amount);\n event Unwrap(address indexed to, UFixed18 amount);\n event Rebalance(UFixed18 newMinted, UFixed18 newRedeemed);\n event Close(UFixed18 amount);\n\n error BatcherNotImplementedError();\n error BatcherBalanceMismatchError(UFixed18 oldBalance, UFixed18 newBalance);\n\n function totalBalance() external view returns (UFixed18);\n function wrap(UFixed18 amount, address to) external;\n function unwrap(UFixed18 amount, address to) external;\n function rebalance() external;\n}\n" - }, - "contracts/test/TestnetReserve.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol\";\nimport \"@equilibria/emptyset-batcher/interfaces/IBatcher.sol\";\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"@equilibria/root/token/types/Token6.sol\";\n\ncontract TestnetReserve {\n event Mint(address indexed to, UFixed18 amount);\n event Redeem(address indexed to, UFixed18 amount);\n\n Token18 public immutable DSU; // solhint-disable-line var-name-mixedcase\n Token6 public immutable USDC; // solhint-disable-line var-name-mixedcase\n\n constructor(Token18 dsu_, Token6 usdc_) {\n DSU = dsu_;\n USDC = usdc_;\n }\n\n function mint(UFixed18 amount, address to) external {\n USDC.pull(msg.sender, amount, true);\n ERC20PresetMinterPauser(Token18.unwrap(DSU)).mint(to, UFixed18.unwrap(amount));\n\n emit Mint(to, amount);\n }\n\n function redeem(UFixed18 amount, address to) external {\n DSU.pull(msg.sender, amount);\n ERC20Burnable(Token18.unwrap(DSU)).burn(UFixed18.unwrap(amount));\n USDC.push(to, amount, true);\n\n emit Redeem(to, amount);\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/presets/ERC20PresetMinterPauser.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20.sol\";\nimport \"../extensions/ERC20Burnable.sol\";\nimport \"../extensions/ERC20Pausable.sol\";\nimport \"../../../access/AccessControlEnumerable.sol\";\nimport \"../../../utils/Context.sol\";\n\n/**\n * @dev {ERC20} token, including:\n *\n * - ability for holders to burn (destroy) their tokens\n * - a minter role that allows for token minting (creation)\n * - a pauser role that allows to stop all token transfers\n *\n * This contract uses {AccessControl} to lock permissioned functions using the\n * different roles - head to its documentation for details.\n *\n * The account that deploys the contract will be granted the minter and pauser\n * roles, as well as the default admin role, which will let it grant both minter\n * and pauser roles to other accounts.\n *\n * _Deprecated in favor of https://wizard.openzeppelin.com/[Contracts Wizard]._\n */\ncontract ERC20PresetMinterPauser is Context, AccessControlEnumerable, ERC20Burnable, ERC20Pausable {\n bytes32 public constant MINTER_ROLE = keccak256(\"MINTER_ROLE\");\n bytes32 public constant PAUSER_ROLE = keccak256(\"PAUSER_ROLE\");\n\n /**\n * @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE` and `PAUSER_ROLE` to the\n * account that deploys the contract.\n *\n * See {ERC20-constructor}.\n */\n constructor(string memory name, string memory symbol) ERC20(name, symbol) {\n _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());\n\n _setupRole(MINTER_ROLE, _msgSender());\n _setupRole(PAUSER_ROLE, _msgSender());\n }\n\n /**\n * @dev Creates `amount` new tokens for `to`.\n *\n * See {ERC20-_mint}.\n *\n * Requirements:\n *\n * - the caller must have the `MINTER_ROLE`.\n */\n function mint(address to, uint256 amount) public virtual {\n require(hasRole(MINTER_ROLE, _msgSender()), \"ERC20PresetMinterPauser: must have minter role to mint\");\n _mint(to, amount);\n }\n\n /**\n * @dev Pauses all token transfers.\n *\n * See {ERC20Pausable} and {Pausable-_pause}.\n *\n * Requirements:\n *\n * - the caller must have the `PAUSER_ROLE`.\n */\n function pause() public virtual {\n require(hasRole(PAUSER_ROLE, _msgSender()), \"ERC20PresetMinterPauser: must have pauser role to pause\");\n _pause();\n }\n\n /**\n * @dev Unpauses all token transfers.\n *\n * See {ERC20Pausable} and {Pausable-_unpause}.\n *\n * Requirements:\n *\n * - the caller must have the `PAUSER_ROLE`.\n */\n function unpause() public virtual {\n require(hasRole(PAUSER_ROLE, _msgSender()), \"ERC20PresetMinterPauser: must have pauser role to unpause\");\n _unpause();\n }\n\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual override(ERC20, ERC20Pausable) {\n super._beforeTokenTransfer(from, to, amount);\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Burnable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20.sol\";\nimport \"../../../utils/Context.sol\";\n\n/**\n * @dev Extension of {ERC20} that allows token holders to destroy both their own\n * tokens and those that they have an allowance for, in a way that can be\n * recognized off-chain (via event analysis).\n */\nabstract contract ERC20Burnable is Context, ERC20 {\n /**\n * @dev Destroys `amount` tokens from the caller.\n *\n * See {ERC20-_burn}.\n */\n function burn(uint256 amount) public virtual {\n _burn(_msgSender(), amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, deducting from the caller's\n * allowance.\n *\n * See {ERC20-_burn} and {ERC20-allowance}.\n *\n * Requirements:\n *\n * - the caller must have allowance for ``accounts``'s tokens of at least\n * `amount`.\n */\n function burnFrom(address account, uint256 amount) public virtual {\n _spendAllowance(account, _msgSender(), amount);\n _burn(account, amount);\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/ERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.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 * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\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 ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => 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 * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\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 override 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 override 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 value {ERC20} uses, unless this function is\n * 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 override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override 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 `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` 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 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\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 `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `sender` to `recipient`.\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 * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n }\n _balances[to] += amount;\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` 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 function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/ERC20Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20.sol\";\nimport \"../../../security/Pausable.sol\";\n\n/**\n * @dev ERC20 token with pausable token transfers, minting and burning.\n *\n * Useful for scenarios such as preventing trades until the end of an evaluation\n * period, or having an emergency switch for freezing all token transfers in the\n * event of a large bug.\n */\nabstract contract ERC20Pausable is ERC20, Pausable {\n /**\n * @dev See {ERC20-_beforeTokenTransfer}.\n *\n * Requirements:\n *\n * - the contract must not be paused.\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual override {\n super._beforeTokenTransfer(from, to, amount);\n\n require(!paused(), \"ERC20Pausable: token transfer while paused\");\n }\n}\n" - }, - "@openzeppelin/contracts/access/AccessControlEnumerable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControlEnumerable.sol\";\nimport \"./AccessControl.sol\";\nimport \"../utils/structs/EnumerableSet.sol\";\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override {\n super._grantRole(role, account);\n _roleMembers[role].add(account);\n }\n\n /**\n * @dev Overload {_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override {\n super._revokeRole(role, account);\n _roleMembers[role].remove(account);\n }\n}\n" - }, - "@openzeppelin/contracts/security/Pausable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract Pausable is Context {\n /**\n * @dev Emitted when the pause is triggered by `account`.\n */\n event Paused(address account);\n\n /**\n * @dev Emitted when the pause is lifted by `account`.\n */\n event Unpaused(address account);\n\n bool private _paused;\n\n /**\n * @dev Initializes the contract in unpaused state.\n */\n constructor() {\n _paused = false;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n require(!paused(), \"Pausable: paused\");\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n require(paused(), \"Pausable: not paused\");\n _;\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n}\n" - }, - "@openzeppelin/contracts/access/IAccessControlEnumerable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n" - }, - "@openzeppelin/contracts/access/AccessControl.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\nimport \"../utils/Context.sol\";\nimport \"../utils/Strings.sol\";\nimport \"../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address => bool) members;\n bytes32 adminRole;\n }\n\n mapping(bytes32 => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with a standardized message including the required role.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n *\n * _Available since v4.1._\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n return _roles[role].members[account];\n }\n\n /**\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\n * Overriding this function changes the behavior of the {onlyRole} modifier.\n *\n * Format of the revert message is described in {_checkRole}.\n *\n * _Available since v4.6._\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Revert with a standard message if `account` is missing `role`.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert(\n string(\n abi.encodePacked(\n \"AccessControl: account \",\n Strings.toHexString(uint160(account), 20),\n \" is missing role \",\n Strings.toHexString(uint256(role), 32)\n )\n )\n );\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) public virtual override {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn't perform any\n * checks on the calling account.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n *\n * NOTE: This function is deprecated in favor of {_grantRole}.\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(role, account);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * Internal function without access restriction.\n */\n function _grantRole(bytes32 role, address account) internal virtual {\n if (!hasRole(role, account)) {\n _roles[role].members[account] = true;\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * Internal function without access restriction.\n */\n function _revokeRole(bytes32 role, address account) internal virtual {\n if (hasRole(role, account)) {\n _roles[role].members[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n" - }, - "@openzeppelin/contracts/access/IAccessControl.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n" - }, - "@openzeppelin/contracts/utils/Strings.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\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 // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\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 if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\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 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_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/introspection/ERC165.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 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 *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/introspection/IERC165.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\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[EIP 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" - }, - "contracts/test/TestnetBatcher.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol\";\nimport \"@equilibria/emptyset-batcher/interfaces/IBatcher.sol\";\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"@equilibria/root/token/types/Token6.sol\";\nimport \"./TestnetReserve.sol\";\n\ncontract TestnetBatcher is IBatcher {\n TestnetReserve public reserve;\n\n constructor(TestnetReserve reserve_) {\n reserve = reserve_;\n\n reserve.USDC().approve(address(reserve));\n reserve.DSU().approve(address(reserve));\n }\n\n function totalBalance() external pure returns (UFixed18) {\n return UFixed18Lib.MAX;\n }\n\n // Passthrough to Reserve\n function wrap(UFixed18 amount, address to) external {\n reserve.USDC().pull(msg.sender, amount, true);\n reserve.mint(amount, to);\n\n emit Wrap(to, amount);\n }\n\n function unwrap(UFixed18, address) external pure {\n revert BatcherNotImplementedError();\n }\n\n // No-op\n function rebalance() external pure {\n return;\n }\n}\n" - }, - "contracts/interfaces/IForwarder.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"@equilibria/root/token/types/Token6.sol\";\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/emptyset-batcher/interfaces/IBatcher.sol\";\nimport \"./ICollateral.sol\";\n\ninterface IForwarder {\n error ForwarderNotContractAddressError();\n\n event WrapAndDeposit(address indexed account, IProduct indexed product, UFixed18 amount);\n\n function USDC() external view returns (Token6); // solhint-disable-line func-name-mixedcase\n function DSU() external view returns (Token18); // solhint-disable-line func-name-mixedcase\n function batcher() external view returns (IBatcher);\n function collateral() external view returns (ICollateral);\n function wrapAndDeposit(address account, IProduct product, UFixed18 amount) external;\n}\n" - }, - "contracts/interfaces/IPerennialLens.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"./IProduct.sol\";\nimport \"./ICollateral.sol\";\nimport \"./IController.sol\";\n\n/**\n * @title Lens contract to conveniently pull protocol, product, and userproduct data\n * @notice All functions should be called using `callStatic`\n */\ninterface IPerennialLens {\n /// @dev Snapshot of Product information\n struct ProductSnapshot {\n IProduct.ProductInfo productInfo;\n address productAddress;\n Fixed18 rate;\n Fixed18 dailyRate;\n IOracleProvider.OracleVersion latestVersion;\n UFixed18 maintenance;\n UFixed18 collateral;\n UFixed18 shortfall;\n PrePosition pre;\n Position position;\n UFixed18 productFee;\n UFixed18 protocolFee;\n Position openInterest;\n }\n\n /// @dev Snapshot of User state for a Product\n struct UserProductSnapshot {\n address productAddress;\n address userAddress;\n UFixed18 collateral;\n UFixed18 maintenance;\n PrePosition pre;\n Position position;\n bool liquidatable;\n bool liquidating;\n Position openInterest;\n UFixed18 fees;\n UFixed18 exposure;\n }\n\n // Protocol Values\n function controller() external view returns (IController);\n function collateral() external view returns (ICollateral);\n\n // Snapshot Functions for batch values\n function snapshots(IProduct[] calldata productAddresses) external returns (ProductSnapshot[] memory);\n function snapshot(IProduct product) external returns (ProductSnapshot memory);\n function snapshots(address account, IProduct[] calldata productAddresses) external returns (UserProductSnapshot[] memory);\n function snapshot(address account, IProduct product) external returns (UserProductSnapshot memory);\n\n // Product Values\n function name(IProduct product) external view returns (string memory);\n function symbol(IProduct product) external view returns (string memory);\n function info(IProduct product) external view returns (IProduct.ProductInfo memory _info);\n function collateral(IProduct product) external returns (UFixed18);\n function shortfall(IProduct product) external returns (UFixed18);\n function pre(IProduct product) external returns (PrePosition memory);\n function fees(IProduct product) external returns (UFixed18 protocolFees, UFixed18 productFees);\n function position(IProduct product) external returns (Position memory);\n function globalPosition(IProduct product) external returns (PrePosition memory, Position memory);\n function latestVersion(IProduct product) external returns (IOracleProvider.OracleVersion memory);\n function atVersions(IProduct product, uint[] memory versions) external returns (IOracleProvider.OracleVersion[] memory prices);\n function rate(IProduct product) external returns (Fixed18);\n function openInterest(IProduct product) external returns (Position memory);\n function dailyRate(IProduct product) external returns (Fixed18);\n\n // UserProduct Values\n function collateral(address account, IProduct product) external returns (UFixed18);\n function maintenance(address account, IProduct product) external returns (UFixed18);\n function liquidatable(address account, IProduct product) external returns (bool);\n function liquidating(address account, IProduct product) external returns (bool);\n function pre(address account, IProduct product) external returns (PrePosition memory);\n function position(address account, IProduct product) external returns (Position memory);\n function userPosition(address account, IProduct product) external returns (PrePosition memory, Position memory);\n function fees(address account, IProduct product) external returns (UFixed18);\n function openInterest(address account, IProduct product) external returns (Position memory);\n function exposure(address account, IProduct product) external returns (UFixed18);\n function maintenanceRequired(\n address account,\n IProduct product,\n UFixed18 positionSize\n ) external returns (UFixed18);\n function unclaimedIncentiveRewards(address account, IProduct product)\n external\n returns (Token18[] memory tokens, UFixed18[] memory amounts);\n function unclaimedIncentiveRewards(\n address account,\n IProduct product,\n uint256[] calldata programIds\n ) external returns (Token18[] memory tokens, UFixed18[] memory amounts);\n}\n" - }, - "contracts/lens/PerennialLens.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../interfaces/IPerennialLens.sol\";\n\n/**\n * @title Lens contract to conveniently pull protocol data\n * @notice All functions should be called using `callStatic`\n */\ncontract PerennialLens is IPerennialLens {\n /**\n * @notice Protocol controller\n * @return Protocol controller\n */\n IController public immutable controller;\n\n /// @param _controller Protocol controller address\n constructor(IController _controller) {\n controller = _controller;\n }\n\n /**\n * @notice Protocol collateral address\n * @return Protocol collateral address\n */\n function collateral() public view returns (ICollateral) {\n return controller.collateral();\n }\n\n /**\n * Snapshot Functions\n */\n\n /**\n * @notice Returns the snapshots of the provided `productAddresses`\n * @param productAddresses Product addresses\n * @return _snapshots a snapshot for each product after settle\n */\n function snapshots(IProduct[] calldata productAddresses) public returns (ProductSnapshot[] memory _snapshots) {\n _snapshots = new ProductSnapshot[](productAddresses.length);\n for (uint256 i = 0; i < productAddresses.length; i++) {\n _snapshots[i] = snapshot(productAddresses[i]);\n }\n }\n\n /**\n * @notice Returns the snapshot of the provided `product`\n * @param product Product address\n * @return _snapshot for the product after settle\n */\n function snapshot(IProduct product) public settle(product) returns (ProductSnapshot memory _snapshot) {\n _snapshot.productInfo = info(product);\n _snapshot.productAddress = address(product);\n _snapshot.rate = rate(product);\n _snapshot.dailyRate = dailyRate(product);\n _snapshot.latestVersion = latestVersion(product);\n _snapshot.maintenance = product.maintenance();\n _snapshot.collateral = collateral(product);\n _snapshot.shortfall = shortfall(product);\n _snapshot.pre = pre(product);\n _snapshot.position = position(product);\n (_snapshot.productFee, _snapshot.protocolFee) = fees(product);\n _snapshot.openInterest = openInterest(product);\n }\n\n /**\n * @notice Returns the user snapshots for the provided `productAddresses`\n * @param account User addresses\n * @param productAddresses Product addresses\n * @return _snapshots UserSnapshot for each product after settle\n */\n function snapshots(address account, IProduct[] memory productAddresses)\n public returns (UserProductSnapshot[] memory _snapshots)\n {\n _snapshots = new UserProductSnapshot[](productAddresses.length);\n for (uint256 i = 0; i < productAddresses.length; i++) {\n _snapshots[i] = snapshot(account, productAddresses[i]);\n }\n }\n\n /**\n * @notice Returns the user snapshot for the provided `product`\n * @param account User addresses\n * @param product Product address\n * @return _snapshot UserSnapshot for the product after settle\n */\n function snapshot(address account, IProduct product)\n public\n settleAccount(account, product)\n returns (UserProductSnapshot memory _snapshot)\n {\n _snapshot.productAddress = address(product);\n _snapshot.userAddress = account;\n _snapshot.collateral = collateral(account, product);\n _snapshot.maintenance = maintenance(account, product);\n _snapshot.pre = pre(account, product);\n _snapshot.position = position(account, product);\n _snapshot.liquidatable = liquidatable(account, product);\n _snapshot.liquidating = liquidating(account, product);\n _snapshot.openInterest = openInterest(account, product);\n _snapshot.fees = fees(account, product);\n _snapshot.exposure = exposure(account, product);\n }\n\n /**\n * End Snapshot Functions\n */\n\n /**\n * Product Individual Fields Functions\n */\n\n /**\n * @notice Returns the name of the provided `product`\n * @param product Product address\n * @return Name of the product\n */\n function name(IProduct product) public view returns (string memory) {\n return product.name();\n }\n\n /**\n * @notice Returns the symbol of the provided `product`\n * @param product Product address\n * @return Symbol of the product\n */\n function symbol(IProduct product) public view returns (string memory) {\n return product.symbol();\n }\n\n /**\n * @notice Returns the info of the provided `product`\n * @param product Product address\n * @return _info of the product\n */\n function info(IProduct product) public view returns (IProduct.ProductInfo memory _info) {\n _info.name = name(product);\n _info.symbol = symbol(product);\n _info.payoffDefinition = product.payoffDefinition();\n _info.oracle = product.oracle();\n _info.maintenance = product.maintenance();\n _info.fundingFee = product.fundingFee();\n _info.makerFee = product.makerFee();\n _info.takerFee = product.takerFee();\n _info.makerLimit = product.makerLimit();\n _info.utilizationCurve = product.utilizationCurve();\n }\n\n /**\n * @notice Product total collateral amount after settle\n * @param product Product address\n * @return Total collateral for product\n */\n function collateral(IProduct product) public settle(product) returns (UFixed18) {\n return collateral().collateral(product);\n }\n\n /**\n * @notice Product total shortfall amount after settle\n * @param product Product address\n * @return Total shortfall for product\n */\n function shortfall(IProduct product) public settle(product) returns (UFixed18) {\n return collateral().shortfall(product);\n }\n\n /**\n * @notice Product pre position after settle\n * @param product Product address\n * @return Product pre-position\n */\n function pre(IProduct product) public settle(product) returns (PrePosition memory) {\n return product.pre();\n }\n\n /**\n * @notice Product position after settle\n * @param product Product address\n * @return product position\n */\n function position(IProduct product) public settle(product) returns (Position memory) {\n return _latestPosition(product);\n }\n\n /**\n * @notice Product pre-position and position after settle\n * @param product Product address\n * @return Product pre-position\n * @return Product position\n */\n function globalPosition(IProduct product) public settle(product) returns (PrePosition memory, Position memory) {\n return (product.pre(), _latestPosition(product));\n }\n\n /**\n * @notice Current price of product after settle\n * @param product Product address\n * @return Product latest price\n */\n function latestVersion(IProduct product) public settle(product) returns (IOracleProvider.OracleVersion memory) {\n return _latestVersion(product);\n }\n\n /**\n * @notice Prices of product at specified versions after settle\n * @param product Product address\n * @param versions Oracle versions to query\n * @return prices Product prices at specified versions\n */\n function atVersions(IProduct product, uint256[] memory versions)\n public\n settle(product)\n returns (IOracleProvider.OracleVersion[] memory prices)\n {\n prices = new IOracleProvider.OracleVersion[](versions.length);\n for (uint256 i = 0; i < versions.length; i++) {\n prices[i] = product.atVersion(versions[i]);\n }\n }\n\n /**\n * @notice Product funding rate after settle\n * @param product Product address\n * @return Product current funding rate\n */\n function rate(IProduct product) public settle(product) returns (Fixed18) {\n Position memory position_ = _latestPosition(product);\n return product.rate(position_);\n }\n\n /**\n * @notice Product funding extrapolated to a daily rate after settle\n * @param product Product address\n * @return Product current funding extrapolated to a daily rate\n */\n function dailyRate(IProduct product) public settle(product) returns (Fixed18) {\n Position memory position_ = _latestPosition(product);\n return product.rate(position_).mul(Fixed18Lib.from(60 * 60 * 24));\n }\n\n /**\n * @notice Fees accumulated by product and protocol treasuries after settle\n * @param product Product address\n * @return protocolFees fees accrued by the protocol\n * @return productFees fees accrued by the product owner\n */\n function fees(IProduct product) public settle(product) returns (UFixed18 protocolFees, UFixed18 productFees) {\n address protocolTreasury = controller.treasury();\n address productTreasury = controller.treasury(product);\n\n protocolFees = collateral().fees(protocolTreasury);\n productFees = collateral().fees(productTreasury);\n }\n\n /**\n * @notice Product total open interest after settle\n * @param product Product address\n * @return Product maker and taker position multiplied by latest price after settle\n */\n function openInterest(IProduct product) public settle(product) returns (Position memory) {\n return _latestPosition(product).mul(_latestVersion(product).price.abs());\n }\n\n /**\n * End Product Individual Fields Functions\n */\n\n /**\n * UserProduct Individual Fields Functions\n */\n\n /**\n * @notice User collateral amount for product after settle\n * @param account Account address\n * @param product Product address\n * @return User deposited collateral for product\n */\n function collateral(address account, IProduct product) public settleAccount(account, product) returns (UFixed18) {\n return collateral().collateral(account, product);\n }\n\n /**\n * @notice User maintenance amount for product after settle\n * @param account Account address\n * @param product Product address\n * @return Maximum of user maintenance, and maintenanceNext\n */\n function maintenance(address account, IProduct product) public settleAccount(account, product) returns (UFixed18) {\n return UFixed18Lib.max(product.maintenance(account), product.maintenanceNext(account));\n }\n\n /**\n * @notice User liquidatble status for product after settle\n * @param account Account address\n * @param product Product address\n * @return Whether or not the user's position eligible to be liquidated\n */\n function liquidatable(address account, IProduct product) public settleAccount(account, product) returns (bool) {\n return collateral().liquidatable(account, product);\n }\n\n /**\n * @notice User liquidating status for product after settle\n * @param account Account address\n * @param product Product address\n * @return Whether or not the user's position is being liquidated\n */\n function liquidating(address account, IProduct product) public settleAccount(account, product) returns (bool) {\n return product.isLiquidating(account);\n }\n\n /**\n * @notice User pre position for product after settle\n * @param account Account address\n * @param product Product address\n * @return User pre-position\n */\n function pre(address account, IProduct product)\n public\n settleAccount(account, product)\n returns (PrePosition memory)\n {\n return product.pre(account);\n }\n\n /**\n * @notice User position for product after settle\n * @param account Account address\n * @param product Product address\n * @return User position\n */\n function position(address account, IProduct product)\n public\n settleAccount(account, product)\n returns (Position memory)\n {\n return product.position(account);\n }\n\n /**\n * @notice User pre-position and position for product after settle\n * @param account Account address\n * @param product Product address\n * @return User pre-position\n * @return User position\n */\n function userPosition(address account, IProduct product)\n public\n settleAccount(account, product)\n returns (PrePosition memory, Position memory)\n {\n return (product.pre(account), product.position(account));\n }\n\n /**\n * @notice Fees accumulated by account after settle\n * @param account Account address\n * @param product Product address\n * @return sum of all fees accrued by the account\n */\n function fees(address account, IProduct product) public settleAccount(account, product) returns (UFixed18) {\n return collateral().fees(account);\n }\n\n /**\n * @notice User's open interest in product after settle\n * @param account Account address\n * @param product Product address\n * @return User's maker or taker position multiplied by latest price after settle\n */\n function openInterest(address account, IProduct product)\n public\n settleAccount(account, product)\n returns (Position memory)\n {\n return product.position(account).mul(_latestVersion(product).price.abs());\n }\n\n /**\n * @notice User's exposure in product after settle\n * @param account Account address\n * @param product Product address\n * @return User's exposure (openInterest * utilization) after settle\n */\n function exposure(address account, IProduct product) public settleAccount(account, product) returns (UFixed18) {\n (, Position memory _pos) = globalPosition(product);\n if (_pos.maker.isZero()) { return UFixed18Lib.ZERO; }\n\n Position memory _openInterest = openInterest(account, product);\n if (!_openInterest.taker.isZero()) {\n return _openInterest.taker; // Taker exposure is always 100% of openInterest\n }\n\n UFixed18 utilization = _pos.taker.div(_pos.maker);\n return utilization.mul(_openInterest.maker); // Maker exposure is openInterest * utilization\n }\n\n /**\n * @notice User's maintenance required for position size in product after settle\n * @param account Account address\n * @param product Product address\n * @param positionSize size of position for maintenance calculation\n * @return Maintenance required for position in product\n */\n function maintenanceRequired(\n address account,\n IProduct product,\n UFixed18 positionSize\n ) public settleAccount(account, product) returns (UFixed18) {\n UFixed18 notional = positionSize.mul(_latestVersion(product).price.abs());\n return notional.mul(product.maintenance());\n }\n\n /**\n * @notice User's unclaimed rewards for all programs for product after settle\n * @param account Account address\n * @param product Product address\n * @return tokens Token addresses of unclaimed incentive rewards for given product\n * @return amounts Token amounts of unclaimed incentive rewards for given product\n */\n function unclaimedIncentiveRewards(address account, IProduct product)\n public\n settleAccount(account, product)\n returns (Token18[] memory tokens, UFixed18[] memory amounts)\n {\n IIncentivizer incentivizer = controller.incentivizer();\n\n uint256 programsLength = incentivizer.count(product);\n tokens = new Token18[](programsLength);\n amounts = new UFixed18[](programsLength);\n for (uint256 i = 0; i < programsLength; i++) {\n ProgramInfo memory programInfo = incentivizer.programInfos(product, i);\n tokens[i] = programInfo.token;\n amounts[i] = incentivizer.unclaimed(product, account, i);\n }\n }\n\n /**\n * @notice User's unclaimed rewards for provided programs for product after settle\n * @param account Account address\n * @param product Product address\n * @param programIds Program IDs to query\n * @return tokens Token addresses of unclaimed incentive rewards for given program IDs\n * @return amounts Token amounts of unclaimed incentive rewards for given program IDs\n */\n function unclaimedIncentiveRewards(\n address account,\n IProduct product,\n uint256[] calldata programIds\n ) public settleAccount(account, product) returns (Token18[] memory tokens, UFixed18[] memory amounts) {\n IIncentivizer incentivizer = controller.incentivizer();\n tokens = new Token18[](programIds.length);\n amounts = new UFixed18[](programIds.length);\n for (uint256 i = 0; i < programIds.length; i++) {\n ProgramInfo memory programInfo = incentivizer.programInfos(product, programIds[i]);\n tokens[i] = programInfo.token;\n amounts[i] = incentivizer.unclaimed(product, account, programIds[i]);\n }\n }\n\n /**\n * End UserProduct Individual Fields Functions\n */\n\n /**\n * Private Helper Functions\n */\n\n /**\n * @notice Returns the Product's latest position\n * @dev Private function, does not call settle itself\n * @param product Product address\n * @return Latest position for the product\n */\n function _latestPosition(IProduct product) private view returns (Position memory) {\n return product.positionAtVersion(product.latestVersion());\n }\n\n /**\n * @notice Returns the Product's latest version\n * @dev Private function, does not call settle itself\n * @param product Product address\n * @return Latest version for the product\n */\n function _latestVersion(IProduct product) private view returns (IOracleProvider.OracleVersion memory) {\n return product.atVersion(product.latestVersion());\n }\n\n /**\n * End Private Helper Functions\n */\n\n /**\n * Modifier Functions\n */\n\n /// @dev Settles the product\n modifier settle(IProduct product) {\n product.settle();\n _;\n }\n\n /// @dev Settles the product. product.settleAccount also settles the product\n modifier settleAccount(address account, IProduct product) {\n product.settleAccount(account);\n _;\n }\n\n /**\n * End Modifier Functions\n */\n}\n" - }, - "contracts/forwarder/Forwarder.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../interfaces/IForwarder.sol\";\n\n/**\n * @title Forwarder\n * @notice Facilitates collateral deposits to the protocol where the amount is supplied\n * in USDC then wrapped as DSU before being deposited.\n */\ncontract Forwarder is IForwarder {\n // @dev USDC stablecoin\n Token6 public immutable USDC; // solhint-disable-line var-name-mixedcase\n\n // @dev DSU stablecoin\n Token18 public immutable DSU; // solhint-disable-line var-name-mixedcase\n\n /// @dev Contract that wraps USDC to DSU\n IBatcher public immutable batcher;\n\n /// @dev Contract managing state for collateral accounts in the protocol\n ICollateral public immutable collateral;\n\n /**\n * @notice Initializes the contract state\n * @param usdc_ The USDC token contract address\n * @param dsu_ The DSU token contract address\n * @param batcher_ The USDC-to-DSU batcher contract address\n * @param collateral_ The perennial collateral contract address\n */\n constructor(\n Token6 usdc_,\n Token18 dsu_,\n IBatcher batcher_,\n ICollateral collateral_\n ) {\n if (!Address.isContract(Token6.unwrap(usdc_))) revert ForwarderNotContractAddressError();\n if (!Address.isContract(Token18.unwrap(dsu_))) revert ForwarderNotContractAddressError();\n if (!Address.isContract(address(batcher_))) revert ForwarderNotContractAddressError();\n if (!Address.isContract(address(collateral_))) revert ForwarderNotContractAddressError();\n\n USDC = usdc_;\n DSU = dsu_;\n batcher = batcher_;\n collateral = collateral_;\n\n USDC.approve(address(batcher));\n DSU.approve(address(collateral));\n }\n\n /**\n * @notice Pulls `amount` of USDC from `msg.sender`'s balance, wraps it as DSU,\n and deposits it as collateral to `account`'s `product` account\n * @param account Account to deposit the collateral for\n * @param product Product to credit the collateral to\n * @param amount 18 decimals-normalized stablecoin (USDC, DSU) value of collateral to deposit\n */\n function wrapAndDeposit(\n address account,\n IProduct product,\n UFixed18 amount\n ) external {\n USDC.pull(msg.sender, amount, true);\n batcher.wrap(amount, address(this));\n collateral.depositTo(account, product, amount);\n emit WrapAndDeposit(account, product, amount);\n }\n}\n" - }, - "contracts/test/TestnetUSDC.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol\";\n\ncontract TestnetUSDC is ERC20, ERC20Burnable {\n // solhint-disable-next-line no-empty-blocks\n constructor() ERC20(\"USD Coin\", \"USDC\") { }\n\n function decimals() override public pure returns (uint8) {\n return 6;\n }\n\n function mint(address account, uint256 amount) external {\n _mint(account, amount);\n }\n}\n" - }, - "contracts/test/TestnetDSU.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol\";\n\ncontract TestnetDSU is ERC20, ERC20Burnable {\n uint256 private constant LIMIT = 1_000_000e18;\n\n address public minter;\n\n error TestnetDSUNotMinterError();\n error TestnetDSUOverLimitError();\n\n event TestnetDSUMinterUpdated(address indexed newMinter);\n\n constructor(address _minter) ERC20(\"Digital Standard Unit\", \"DSU\") {\n minter = _minter;\n }\n\n function mint(address account, uint256 amount) external onlyMinter {\n if (amount > LIMIT) revert TestnetDSUOverLimitError();\n\n _mint(account, amount);\n }\n\n function updateMinter(address newMinter) external onlyMinter {\n minter = newMinter;\n\n emit TestnetDSUMinterUpdated(newMinter);\n }\n\n modifier onlyMinter() {\n if (msg.sender != minter) revert TestnetDSUNotMinterError();\n _;\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev _Available since v3.1._\n */\ninterface IERC1155Receiver is IERC165 {\n /**\n * @dev Handles the receipt of a single ERC1155 token type. This function is\n * called at the end of a `safeTransferFrom` after the balance has been updated.\n *\n * NOTE: To accept the transfer, this must return\n * `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))`\n * (i.e. 0xf23a6e61, or its own function selector).\n *\n * @param operator The address which initiated the transfer (i.e. msg.sender)\n * @param from The address which previously owned the token\n * @param id The ID of the token being transferred\n * @param value The amount of tokens being transferred\n * @param data Additional data with no specified format\n * @return `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))` if transfer is allowed\n */\n function onERC1155Received(\n address operator,\n address from,\n uint256 id,\n uint256 value,\n bytes calldata data\n ) external returns (bytes4);\n\n /**\n * @dev Handles the receipt of a multiple ERC1155 token types. This function\n * is called at the end of a `safeBatchTransferFrom` after the balances have\n * been updated.\n *\n * NOTE: To accept the transfer(s), this must return\n * `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))`\n * (i.e. 0xbc197c81, or its own function selector).\n *\n * @param operator The address which initiated the batch transfer (i.e. msg.sender)\n * @param from The address which previously owned the token\n * @param ids An array containing ids of each token being transferred (order and length must match values array)\n * @param values An array containing amounts of each token being transferred (order and length must match ids array)\n * @param data Additional data with no specified format\n * @return `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))` if transfer is allowed\n */\n function onERC1155BatchReceived(\n address operator,\n address from,\n uint256[] calldata ids,\n uint256[] calldata values,\n bytes calldata data\n ) external returns (bytes4);\n}\n" - }, - "@openzeppelin/contracts/governance/TimelockController.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (governance/TimelockController.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../access/AccessControl.sol\";\nimport \"../token/ERC721/IERC721Receiver.sol\";\nimport \"../token/ERC1155/IERC1155Receiver.sol\";\n\n/**\n * @dev Contract module which acts as a timelocked controller. When set as the\n * owner of an `Ownable` smart contract, it enforces a timelock on all\n * `onlyOwner` maintenance operations. This gives time for users of the\n * controlled contract to exit before a potentially dangerous maintenance\n * operation is applied.\n *\n * By default, this contract is self administered, meaning administration tasks\n * have to go through the timelock process. The proposer (resp executor) role\n * is in charge of proposing (resp executing) operations. A common use case is\n * to position this {TimelockController} as the owner of a smart contract, with\n * a multisig or a DAO as the sole proposer.\n *\n * _Available since v3.3._\n */\ncontract TimelockController is AccessControl, IERC721Receiver, IERC1155Receiver {\n bytes32 public constant TIMELOCK_ADMIN_ROLE = keccak256(\"TIMELOCK_ADMIN_ROLE\");\n bytes32 public constant PROPOSER_ROLE = keccak256(\"PROPOSER_ROLE\");\n bytes32 public constant EXECUTOR_ROLE = keccak256(\"EXECUTOR_ROLE\");\n bytes32 public constant CANCELLER_ROLE = keccak256(\"CANCELLER_ROLE\");\n uint256 internal constant _DONE_TIMESTAMP = uint256(1);\n\n mapping(bytes32 => uint256) private _timestamps;\n uint256 private _minDelay;\n\n /**\n * @dev Emitted when a call is scheduled as part of operation `id`.\n */\n event CallScheduled(\n bytes32 indexed id,\n uint256 indexed index,\n address target,\n uint256 value,\n bytes data,\n bytes32 predecessor,\n uint256 delay\n );\n\n /**\n * @dev Emitted when a call is performed as part of operation `id`.\n */\n event CallExecuted(bytes32 indexed id, uint256 indexed index, address target, uint256 value, bytes data);\n\n /**\n * @dev Emitted when operation `id` is cancelled.\n */\n event Cancelled(bytes32 indexed id);\n\n /**\n * @dev Emitted when the minimum delay for future operations is modified.\n */\n event MinDelayChange(uint256 oldDuration, uint256 newDuration);\n\n /**\n * @dev Initializes the contract with a given `minDelay`, and a list of\n * initial proposers and executors. The proposers receive both the\n * proposer and the canceller role (for backward compatibility). The\n * executors receive the executor role.\n *\n * NOTE: At construction, both the deployer and the timelock itself are\n * administrators. This helps further configuration of the timelock by the\n * deployer. After configuration is done, it is recommended that the\n * deployer renounces its admin position and relies on timelocked\n * operations to perform future maintenance.\n */\n constructor(\n uint256 minDelay,\n address[] memory proposers,\n address[] memory executors\n ) {\n _setRoleAdmin(TIMELOCK_ADMIN_ROLE, TIMELOCK_ADMIN_ROLE);\n _setRoleAdmin(PROPOSER_ROLE, TIMELOCK_ADMIN_ROLE);\n _setRoleAdmin(EXECUTOR_ROLE, TIMELOCK_ADMIN_ROLE);\n _setRoleAdmin(CANCELLER_ROLE, TIMELOCK_ADMIN_ROLE);\n\n // deployer + self administration\n _setupRole(TIMELOCK_ADMIN_ROLE, _msgSender());\n _setupRole(TIMELOCK_ADMIN_ROLE, address(this));\n\n // register proposers and cancellers\n for (uint256 i = 0; i < proposers.length; ++i) {\n _setupRole(PROPOSER_ROLE, proposers[i]);\n _setupRole(CANCELLER_ROLE, proposers[i]);\n }\n\n // register executors\n for (uint256 i = 0; i < executors.length; ++i) {\n _setupRole(EXECUTOR_ROLE, executors[i]);\n }\n\n _minDelay = minDelay;\n emit MinDelayChange(0, minDelay);\n }\n\n /**\n * @dev Modifier to make a function callable only by a certain role. In\n * addition to checking the sender's role, `address(0)` 's role is also\n * considered. Granting a role to `address(0)` is equivalent to enabling\n * this role for everyone.\n */\n modifier onlyRoleOrOpenRole(bytes32 role) {\n if (!hasRole(role, address(0))) {\n _checkRole(role, _msgSender());\n }\n _;\n }\n\n /**\n * @dev Contract might receive/hold ETH as part of the maintenance process.\n */\n receive() external payable {}\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, AccessControl) returns (bool) {\n return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns whether an id correspond to a registered operation. This\n * includes both Pending, Ready and Done operations.\n */\n function isOperation(bytes32 id) public view virtual returns (bool pending) {\n return getTimestamp(id) > 0;\n }\n\n /**\n * @dev Returns whether an operation is pending or not.\n */\n function isOperationPending(bytes32 id) public view virtual returns (bool pending) {\n return getTimestamp(id) > _DONE_TIMESTAMP;\n }\n\n /**\n * @dev Returns whether an operation is ready or not.\n */\n function isOperationReady(bytes32 id) public view virtual returns (bool ready) {\n uint256 timestamp = getTimestamp(id);\n return timestamp > _DONE_TIMESTAMP && timestamp <= block.timestamp;\n }\n\n /**\n * @dev Returns whether an operation is done or not.\n */\n function isOperationDone(bytes32 id) public view virtual returns (bool done) {\n return getTimestamp(id) == _DONE_TIMESTAMP;\n }\n\n /**\n * @dev Returns the timestamp at with an operation becomes ready (0 for\n * unset operations, 1 for done operations).\n */\n function getTimestamp(bytes32 id) public view virtual returns (uint256 timestamp) {\n return _timestamps[id];\n }\n\n /**\n * @dev Returns the minimum delay for an operation to become valid.\n *\n * This value can be changed by executing an operation that calls `updateDelay`.\n */\n function getMinDelay() public view virtual returns (uint256 duration) {\n return _minDelay;\n }\n\n /**\n * @dev Returns the identifier of an operation containing a single\n * transaction.\n */\n function hashOperation(\n address target,\n uint256 value,\n bytes calldata data,\n bytes32 predecessor,\n bytes32 salt\n ) public pure virtual returns (bytes32 hash) {\n return keccak256(abi.encode(target, value, data, predecessor, salt));\n }\n\n /**\n * @dev Returns the identifier of an operation containing a batch of\n * transactions.\n */\n function hashOperationBatch(\n address[] calldata targets,\n uint256[] calldata values,\n bytes[] calldata payloads,\n bytes32 predecessor,\n bytes32 salt\n ) public pure virtual returns (bytes32 hash) {\n return keccak256(abi.encode(targets, values, payloads, predecessor, salt));\n }\n\n /**\n * @dev Schedule an operation containing a single transaction.\n *\n * Emits a {CallScheduled} event.\n *\n * Requirements:\n *\n * - the caller must have the 'proposer' role.\n */\n function schedule(\n address target,\n uint256 value,\n bytes calldata data,\n bytes32 predecessor,\n bytes32 salt,\n uint256 delay\n ) public virtual onlyRole(PROPOSER_ROLE) {\n bytes32 id = hashOperation(target, value, data, predecessor, salt);\n _schedule(id, delay);\n emit CallScheduled(id, 0, target, value, data, predecessor, delay);\n }\n\n /**\n * @dev Schedule an operation containing a batch of transactions.\n *\n * Emits one {CallScheduled} event per transaction in the batch.\n *\n * Requirements:\n *\n * - the caller must have the 'proposer' role.\n */\n function scheduleBatch(\n address[] calldata targets,\n uint256[] calldata values,\n bytes[] calldata payloads,\n bytes32 predecessor,\n bytes32 salt,\n uint256 delay\n ) public virtual onlyRole(PROPOSER_ROLE) {\n require(targets.length == values.length, \"TimelockController: length mismatch\");\n require(targets.length == payloads.length, \"TimelockController: length mismatch\");\n\n bytes32 id = hashOperationBatch(targets, values, payloads, predecessor, salt);\n _schedule(id, delay);\n for (uint256 i = 0; i < targets.length; ++i) {\n emit CallScheduled(id, i, targets[i], values[i], payloads[i], predecessor, delay);\n }\n }\n\n /**\n * @dev Schedule an operation that is to becomes valid after a given delay.\n */\n function _schedule(bytes32 id, uint256 delay) private {\n require(!isOperation(id), \"TimelockController: operation already scheduled\");\n require(delay >= getMinDelay(), \"TimelockController: insufficient delay\");\n _timestamps[id] = block.timestamp + delay;\n }\n\n /**\n * @dev Cancel an operation.\n *\n * Requirements:\n *\n * - the caller must have the 'canceller' role.\n */\n function cancel(bytes32 id) public virtual onlyRole(CANCELLER_ROLE) {\n require(isOperationPending(id), \"TimelockController: operation cannot be cancelled\");\n delete _timestamps[id];\n\n emit Cancelled(id);\n }\n\n /**\n * @dev Execute an (ready) operation containing a single transaction.\n *\n * Emits a {CallExecuted} event.\n *\n * Requirements:\n *\n * - the caller must have the 'executor' role.\n */\n // This function can reenter, but it doesn't pose a risk because _afterCall checks that the proposal is pending,\n // thus any modifications to the operation during reentrancy should be caught.\n // slither-disable-next-line reentrancy-eth\n function execute(\n address target,\n uint256 value,\n bytes calldata data,\n bytes32 predecessor,\n bytes32 salt\n ) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) {\n bytes32 id = hashOperation(target, value, data, predecessor, salt);\n _beforeCall(id, predecessor);\n _call(id, 0, target, value, data);\n _afterCall(id);\n }\n\n /**\n * @dev Execute an (ready) operation containing a batch of transactions.\n *\n * Emits one {CallExecuted} event per transaction in the batch.\n *\n * Requirements:\n *\n * - the caller must have the 'executor' role.\n */\n function executeBatch(\n address[] calldata targets,\n uint256[] calldata values,\n bytes[] calldata payloads,\n bytes32 predecessor,\n bytes32 salt\n ) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) {\n require(targets.length == values.length, \"TimelockController: length mismatch\");\n require(targets.length == payloads.length, \"TimelockController: length mismatch\");\n\n bytes32 id = hashOperationBatch(targets, values, payloads, predecessor, salt);\n _beforeCall(id, predecessor);\n for (uint256 i = 0; i < targets.length; ++i) {\n _call(id, i, targets[i], values[i], payloads[i]);\n }\n _afterCall(id);\n }\n\n /**\n * @dev Checks before execution of an operation's calls.\n */\n function _beforeCall(bytes32 id, bytes32 predecessor) private view {\n require(isOperationReady(id), \"TimelockController: operation is not ready\");\n require(predecessor == bytes32(0) || isOperationDone(predecessor), \"TimelockController: missing dependency\");\n }\n\n /**\n * @dev Checks after execution of an operation's calls.\n */\n function _afterCall(bytes32 id) private {\n require(isOperationReady(id), \"TimelockController: operation is not ready\");\n _timestamps[id] = _DONE_TIMESTAMP;\n }\n\n /**\n * @dev Execute an operation's call.\n *\n * Emits a {CallExecuted} event.\n */\n function _call(\n bytes32 id,\n uint256 index,\n address target,\n uint256 value,\n bytes calldata data\n ) private {\n (bool success, ) = target.call{value: value}(data);\n require(success, \"TimelockController: underlying transaction reverted\");\n\n emit CallExecuted(id, index, target, value, data);\n }\n\n /**\n * @dev Changes the minimum timelock duration for future operations.\n *\n * Emits a {MinDelayChange} event.\n *\n * Requirements:\n *\n * - the caller must be the timelock itself. This can only be achieved by scheduling and later executing\n * an operation where the timelock is the target and the data is the ABI-encoded call to this function.\n */\n function updateDelay(uint256 newDelay) external virtual {\n require(msg.sender == address(this), \"TimelockController: caller must be timelock\");\n emit MinDelayChange(_minDelay, newDelay);\n _minDelay = newDelay;\n }\n\n /**\n * @dev See {IERC721Receiver-onERC721Received}.\n */\n function onERC721Received(\n address,\n address,\n uint256,\n bytes memory\n ) public virtual override returns (bytes4) {\n return this.onERC721Received.selector;\n }\n\n /**\n * @dev See {IERC1155Receiver-onERC1155Received}.\n */\n function onERC1155Received(\n address,\n address,\n uint256,\n uint256,\n bytes memory\n ) public virtual override returns (bytes4) {\n return this.onERC1155Received.selector;\n }\n\n /**\n * @dev See {IERC1155Receiver-onERC1155BatchReceived}.\n */\n function onERC1155BatchReceived(\n address,\n address,\n uint256[] memory,\n uint256[] memory,\n bytes memory\n ) public virtual override returns (bytes4) {\n return this.onERC1155BatchReceived.selector;\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" - }, - "contracts/hardhat-dependency-compiler/@openzeppelin/contracts/governance/TimelockController.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@openzeppelin/contracts/governance/TimelockController.sol';\n" - }, - "contracts/hardhat-dependency-compiler/@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol';\n" - }, - "contracts/hardhat-dependency-compiler/@equilibria/emptyset-batcher/batcher/Batcher.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@equilibria/emptyset-batcher/batcher/Batcher.sol';\n" - }, - "contracts/hardhat-dependency-compiler/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol';\n" - }, - "contracts/hardhat-dependency-compiler/@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol';\n" - }, - "@equilibria/perennial-oracle/contracts/ReservoirFeedOracle.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol\";\nimport \"./interfaces/IOracleProvider.sol\";\n\n/**\n * @title ReservoirFeedOracle\n * @notice Reservoir implementation of the IOracle interface, using Reservoir's AggregatorV3Interface adaptors\n * @dev This is a naive implementation which pushes all validation to the underlying. No staleness checks are possible\n This oracle should not be used for regular Chainlink Data Feeds\n */\ncontract ReservoirFeedOracle is IOracleProvider {\n error InvalidOracleVersion();\n\n /// @dev Chainlink price feed to read from\n AggregatorV3Interface public immutable feed;\n\n /// @dev Decimal offset used to normalize chainlink price to 18 decimals\n int256 private immutable _decimalOffset;\n\n /// @dev Which underlying round to consider version 0: version = roundId - _versionOffset\n uint80 private immutable _versionOffset;\n\n /**\n * @notice Initializes the contract state\n * @param feed_ Reservoir price feed\n * @param versionOffset_ Version offset from source round ID\n */\n constructor(AggregatorV3Interface feed_, uint80 versionOffset_) {\n feed = feed_;\n _versionOffset = versionOffset_;\n _decimalOffset = SafeCast.toInt256(10 ** feed_.decimals());\n }\n\n /**\n * @notice Checks for a new price. Does not perform staleness validation as the underlying oracle does not\n support this.\n * @return The current oracle version after sync\n */\n function sync() external view returns (OracleVersion memory) {\n (uint80 roundId, int256 feedPrice, , uint256 timestamp,) = feed.latestRoundData();\n\n return _buildOracleVersion(roundId, feedPrice, timestamp);\n }\n\n /**\n * @notice Returns the current oracle version\n * @return oracleVersion Current oracle version\n */\n function currentVersion() public view returns (OracleVersion memory oracleVersion) {\n (uint80 roundId, int256 feedPrice, , uint256 timestamp,) = feed.latestRoundData();\n\n return _buildOracleVersion(roundId, feedPrice, timestamp);\n }\n\n /**\n * @notice Returns the oracle version specified\n * @dev Converts the passed in version to a roundID by adding _versionOffset\n * @param version The version of which to lookup\n * @return oracleVersion Oracle version at version `version`\n */\n function atVersion(uint256 version) public view returns (OracleVersion memory oracleVersion) {\n // To convert from version to roundId, we add the versionOffset\n uint256 feedRoundID = version + _versionOffset;\n if (feedRoundID > type(uint80).max) revert InvalidOracleVersion();\n (uint80 roundId, int256 feedPrice, , uint256 timestamp,) = feed.getRoundData(uint80(feedRoundID));\n\n return _buildOracleVersion(roundId, feedPrice, timestamp);\n }\n\n /**\n * @notice Builds an oracle version object from a Chainlink round object\n * @dev Converts the passed in roundID to a version by subtracting _versionOffset\n * @param roundId ReservoirRoundId round to build from\n * @param feedPrice price returns by the oracle\n * @param timestamp round timestamps\n * @return Built oracle version\n */\n function _buildOracleVersion(uint80 roundId, int256 feedPrice, uint256 timestamp)\n private view returns (OracleVersion memory) {\n Fixed18 price = Fixed18Lib.ratio(feedPrice, _decimalOffset);\n\n // To convert from roundId to version, we subtract the versionOffset\n return OracleVersion({ version: roundId - _versionOffset, timestamp: timestamp, price: price });\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/SafeCast.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/math/SafeCast.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCast {\n /**\n * @dev Returns the downcasted 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 require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\n return uint224(value);\n }\n\n /**\n * @dev Returns the downcasted 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 require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return uint128(value);\n }\n\n /**\n * @dev Returns the downcasted 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 require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\n return uint96(value);\n }\n\n /**\n * @dev Returns the downcasted 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 require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return uint64(value);\n }\n\n /**\n * @dev Returns the downcasted 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 require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return uint32(value);\n }\n\n /**\n * @dev Returns the downcasted 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 require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return uint16(value);\n }\n\n /**\n * @dev Returns the downcasted uint8 from uint256, reverting on\n * overflow (when the input is greater than largest uint8).\n *\n * Counterpart to Solidity's `uint8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits.\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return uint8(value);\n }\n\n /**\n * @dev Converts a signed int256 into an unsigned uint256.\n *\n * Requirements:\n *\n * - input must be greater than or equal to 0.\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n require(value >= 0, \"SafeCast: value must be positive\");\n return uint256(value);\n }\n\n /**\n * @dev Returns the downcasted int128 from int256, reverting on\n * overflow (when the input is less than smallest int128 or\n * greater than largest int128).\n *\n * Counterpart to Solidity's `int128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v3.1._\n */\n function toInt128(int256 value) internal pure returns (int128) {\n require(value >= type(int128).min && value <= type(int128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return int128(value);\n }\n\n /**\n * @dev Returns the downcasted int64 from int256, reverting on\n * overflow (when the input is less than smallest int64 or\n * greater than largest int64).\n *\n * Counterpart to Solidity's `int64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v3.1._\n */\n function toInt64(int256 value) internal pure returns (int64) {\n require(value >= type(int64).min && value <= type(int64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return int64(value);\n }\n\n /**\n * @dev Returns the downcasted int32 from int256, reverting on\n * overflow (when the input is less than smallest int32 or\n * greater than largest int32).\n *\n * Counterpart to Solidity's `int32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v3.1._\n */\n function toInt32(int256 value) internal pure returns (int32) {\n require(value >= type(int32).min && value <= type(int32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return int32(value);\n }\n\n /**\n * @dev Returns the downcasted int16 from int256, reverting on\n * overflow (when the input is less than smallest int16 or\n * greater than largest int16).\n *\n * Counterpart to Solidity's `int16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v3.1._\n */\n function toInt16(int256 value) internal pure returns (int16) {\n require(value >= type(int16).min && value <= type(int16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return int16(value);\n }\n\n /**\n * @dev Returns the downcasted int8 from int256, reverting on\n * overflow (when the input is less than smallest int8 or\n * greater than largest int8).\n *\n * Counterpart to Solidity's `int8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits.\n *\n * _Available since v3.1._\n */\n function toInt8(int256 value) internal pure returns (int8) {\n require(value >= type(int8).min && value <= type(int8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return int8(value);\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 require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n" - }, - "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface AggregatorV3Interface {\n function decimals() external view returns (uint8);\n\n function description() external view returns (string memory);\n\n function version() external view returns (uint256);\n\n // getRoundData and latestRoundData should both raise \"No data present\"\n // if they do not have data to report, instead of returning unset values\n // which could be misinterpreted as actual reported values.\n function getRoundData(uint80 _roundId)\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n function latestRoundData()\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n}\n" - }, - "@equilibria/perennial-oracle/contracts/test/PassthroughDataFeed.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol\";\n\ncontract PassthroughDataFeed {\n AggregatorV3Interface private _underlying;\n\n constructor(AggregatorV3Interface underlying_) {\n _underlying = underlying_;\n }\n\n function decimals() external view returns (uint8) {\n return _underlying.decimals();\n }\n\n function getRoundData(uint80 roundId) external view returns (uint80, int256, uint256, uint256, uint80) {\n return _underlying.getRoundData(roundId);\n }\n\n function latestRoundData() external view returns (uint80, int256, uint256, uint256, uint80) {\n return _underlying.latestRoundData();\n }\n}\n" - }, - "contracts/hardhat-dependency-compiler/@equilibria/perennial-oracle/contracts/test/PassthroughDataFeed.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@equilibria/perennial-oracle/contracts/test/PassthroughDataFeed.sol';\n" - }, - "@equilibria/perennial-oracle/contracts/types/ChainlinkRound.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol\";\n\n/// @dev ChainlinkRound type\nstruct ChainlinkRound {\n uint256 timestamp;\n int256 answer;\n uint80 roundId;\n}\nusing ChainlinkRoundLib for ChainlinkRound global;\n\n/**\n * @title ChainlinkRoundLib\n * @notice Library that manages Chainlink round parsing.\n */\nlibrary ChainlinkRoundLib {\n /// @dev Phase ID offset location in the round ID\n uint256 constant private PHASE_OFFSET = 64;\n\n /**\n * @notice Computes the chainlink phase ID from a round\n * @param self Round to compute from\n * @return Chainlink phase ID\n */\n function phaseId(ChainlinkRound memory self) internal pure returns (uint16) {\n return uint16(self.roundId >> PHASE_OFFSET);\n }\n}\n" - }, - "@equilibria/perennial-oracle/contracts/types/ChainlinkRegistry.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@chainlink/contracts/src/v0.8/interfaces/FeedRegistryInterface.sol\";\nimport \"./ChainlinkRound.sol\";\n\n/// @dev ChainlinkRegistry type\ntype ChainlinkRegistry is address;\nusing ChainlinkRegistryLib for ChainlinkRegistry global;\n\n/**\n * @title ChainlinkRegistryLib\n * @notice Library that manages interfacing with the Chainlink Feed Registry.\n */\nlibrary ChainlinkRegistryLib {\n /**\n * @notice Returns the decimal amount for a specific feed\n * @param self Chainlink Feed Registry to operate on\n * @param base Base currency token address\n * @param quote Quote currency token address\n * @return Decimal amount\n */\n function decimals(ChainlinkRegistry self, address base, address quote) internal view returns (uint8) {\n return FeedRegistryInterface(ChainlinkRegistry.unwrap(self)).decimals(base, quote);\n }\n\n /**\n * @notice Returns the latest round data for a specific feed\n * @param self Chainlink Feed Registry to operate on\n * @param base Base currency token address\n * @param quote Quote currency token address\n * @return Latest round data\n */\n function getLatestRound(ChainlinkRegistry self, address base, address quote) internal view returns (ChainlinkRound memory) {\n (uint80 roundId, int256 answer, , uint256 updatedAt, ) =\n FeedRegistryInterface(ChainlinkRegistry.unwrap(self)).latestRoundData(base, quote);\n return ChainlinkRound({roundId: roundId, timestamp: updatedAt, answer: answer});\n }\n\n /**\n * @notice Returns a specific round's data for a specific feed\n * @param self Chainlink Feed Registry to operate on\n * @param base Base currency token address\n * @param quote Quote currency token address\n * @param roundId The specific round to fetch data for\n * @return Specific round's data\n */\n function getRound(ChainlinkRegistry self, address base, address quote, uint80 roundId) internal view returns (ChainlinkRound memory) {\n (, int256 answer, , uint256 updatedAt, ) =\n FeedRegistryInterface(ChainlinkRegistry.unwrap(self)).getRoundData(base, quote, roundId);\n return ChainlinkRound({roundId: roundId, timestamp: updatedAt, answer: answer});\n }\n\n\n /**\n * @notice Returns the first round ID for a specific phase ID\n * @param self Chainlink Feed Registry to operate on\n * @param base Base currency token address\n * @param quote Quote currency token address\n * @param phaseId The specific phase to fetch data for\n * @return startingRoundId The starting round ID for the phase\n */\n function getStartingRoundId(ChainlinkRegistry self, address base, address quote, uint16 phaseId)\n internal view returns (uint80 startingRoundId) {\n (startingRoundId, ) =\n FeedRegistryInterface(ChainlinkRegistry.unwrap(self)).getPhaseRange(base, quote, phaseId);\n }\n\n /**\n * @notice Returns the quantity of rounds for a specific phase ID\n * @param self Chainlink Feed Registry to operate on\n * @param base Base currency token address\n * @param quote Quote currency token address\n * @param phaseId The specific phase to fetch data for\n * @return The quantity of rounds for the phase\n */\n function getRoundCount(ChainlinkRegistry self, address base, address quote, uint16 phaseId)\n internal view returns (uint80) {\n (uint80 startingRoundId, uint80 endingRoundId) =\n FeedRegistryInterface(ChainlinkRegistry.unwrap(self)).getPhaseRange(base, quote, phaseId);\n return endingRoundId - startingRoundId + 1;\n }\n}\n" - }, - "@chainlink/contracts/src/v0.8/interfaces/FeedRegistryInterface.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\npragma abicoder v2;\n\nimport \"./AggregatorV2V3Interface.sol\";\n\ninterface FeedRegistryInterface {\n struct Phase {\n uint16 phaseId;\n uint80 startingAggregatorRoundId;\n uint80 endingAggregatorRoundId;\n }\n\n event FeedProposed(\n address indexed asset,\n address indexed denomination,\n address indexed proposedAggregator,\n address currentAggregator,\n address sender\n );\n event FeedConfirmed(\n address indexed asset,\n address indexed denomination,\n address indexed latestAggregator,\n address previousAggregator,\n uint16 nextPhaseId,\n address sender\n );\n\n // V3 AggregatorV3Interface\n\n function decimals(address base, address quote) external view returns (uint8);\n\n function description(address base, address quote) external view returns (string memory);\n\n function version(address base, address quote) external view returns (uint256);\n\n function latestRoundData(address base, address quote)\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n function getRoundData(\n address base,\n address quote,\n uint80 _roundId\n )\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n // V2 AggregatorInterface\n\n function latestAnswer(address base, address quote) external view returns (int256 answer);\n\n function latestTimestamp(address base, address quote) external view returns (uint256 timestamp);\n\n function latestRound(address base, address quote) external view returns (uint256 roundId);\n\n function getAnswer(\n address base,\n address quote,\n uint256 roundId\n ) external view returns (int256 answer);\n\n function getTimestamp(\n address base,\n address quote,\n uint256 roundId\n ) external view returns (uint256 timestamp);\n\n // Registry getters\n\n function getFeed(address base, address quote) external view returns (AggregatorV2V3Interface aggregator);\n\n function getPhaseFeed(\n address base,\n address quote,\n uint16 phaseId\n ) external view returns (AggregatorV2V3Interface aggregator);\n\n function isFeedEnabled(address aggregator) external view returns (bool);\n\n function getPhase(\n address base,\n address quote,\n uint16 phaseId\n ) external view returns (Phase memory phase);\n\n // Round helpers\n\n function getRoundFeed(\n address base,\n address quote,\n uint80 roundId\n ) external view returns (AggregatorV2V3Interface aggregator);\n\n function getPhaseRange(\n address base,\n address quote,\n uint16 phaseId\n ) external view returns (uint80 startingRoundId, uint80 endingRoundId);\n\n function getPreviousRoundId(\n address base,\n address quote,\n uint80 roundId\n ) external view returns (uint80 previousRoundId);\n\n function getNextRoundId(\n address base,\n address quote,\n uint80 roundId\n ) external view returns (uint80 nextRoundId);\n\n // Feed management\n\n function proposeFeed(\n address base,\n address quote,\n address aggregator\n ) external;\n\n function confirmFeed(\n address base,\n address quote,\n address aggregator\n ) external;\n\n // Proposed aggregator\n\n function getProposedFeed(address base, address quote)\n external\n view\n returns (AggregatorV2V3Interface proposedAggregator);\n\n function proposedGetRoundData(\n address base,\n address quote,\n uint80 roundId\n )\n external\n view\n returns (\n uint80 id,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n function proposedLatestRoundData(address base, address quote)\n external\n view\n returns (\n uint80 id,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n // Phases\n function getCurrentPhaseId(address base, address quote) external view returns (uint16 currentPhaseId);\n}\n" - }, - "@chainlink/contracts/src/v0.8/interfaces/AggregatorV2V3Interface.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"./AggregatorInterface.sol\";\nimport \"./AggregatorV3Interface.sol\";\n\ninterface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface {}\n" - }, - "@chainlink/contracts/src/v0.8/interfaces/AggregatorInterface.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface AggregatorInterface {\n function latestAnswer() external view returns (int256);\n\n function latestTimestamp() external view returns (uint256);\n\n function latestRound() external view returns (uint256);\n\n function getAnswer(uint256 roundId) external view returns (int256);\n\n function getTimestamp(uint256 roundId) external view returns (uint256);\n\n event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 updatedAt);\n\n event NewRound(uint256 indexed roundId, address indexed startedBy, uint256 startedAt);\n}\n" - }, - "@equilibria/perennial-oracle/contracts/test/PassthroughChainlinkFeed.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@chainlink/contracts/src/v0.8/interfaces/FeedRegistryInterface.sol\";\n\ncontract PassthroughChainlinkFeed {\n FeedRegistryInterface private _underlying;\n\n constructor(FeedRegistryInterface underlying_) {\n _underlying = underlying_;\n }\n\n function decimals(address base, address quote) external view returns (uint8) {\n return _underlying.decimals(base, quote);\n }\n\n function getRoundData(address base, address quote, uint80 roundId) external view returns (uint80, int256, uint256, uint256, uint80) {\n return _underlying.getRoundData(base, quote, roundId);\n }\n\n function getPhaseRange(address base, address quote, uint16 phaseId) external view returns (uint80, uint80) {\n return _underlying.getPhaseRange(base, quote, phaseId);\n }\n\n function latestRoundData(address base, address quote) external view returns (uint80, int256, uint256, uint256, uint80) {\n return _underlying.latestRoundData(base, quote);\n }\n}\n" - }, - "contracts/hardhat-dependency-compiler/@equilibria/perennial-oracle/contracts/test/PassthroughChainlinkFeed.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@equilibria/perennial-oracle/contracts/test/PassthroughChainlinkFeed.sol';\n" - }, - "@equilibria/perennial-oracle/contracts/ChainlinkOracle.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@chainlink/contracts/src/v0.8/interfaces/FeedRegistryInterface.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"./interfaces/IOracleProvider.sol\";\nimport \"./types/ChainlinkRegistry.sol\";\n\n/**\n * @title ChainlinkOracle\n * @notice Chainlink implementation of the IOracle interface.\n * @dev One instance per Chainlink price feed should be deployed. Multiple products may use the same\n * ChainlinkOracle instance if their payoff functions are based on the same underlying oracle.\n * This implementation only support non-negative prices.\n */\ncontract ChainlinkOracle is IOracleProvider {\n /// @dev Chainlink registry feed address\n ChainlinkRegistry public immutable registry;\n\n /// @dev Base token address for the Chainlink oracle\n address public immutable base;\n\n /// @dev Quote token address for the Chainlink oracle\n address public immutable quote;\n\n /// @dev Decimal offset used to normalize chainlink price to 18 decimals\n int256 private immutable _decimalOffset;\n\n /// @dev Mapping of the first oracle version for each underlying phase ID\n uint256[] private _startingVersionForPhaseId;\n\n /**\n * @notice Initializes the contract state\n * @param registry_ Chainlink price feed registry\n * @param base_ base currency for feed\n * @param quote_ quote currency for feed\n */\n constructor(ChainlinkRegistry registry_, address base_, address quote_) {\n registry = registry_;\n base = base_;\n quote = quote_;\n\n _startingVersionForPhaseId.push(0); // phaseId is 1-indexed, skip index 0\n _startingVersionForPhaseId.push(0); // phaseId is 1-indexed, first phase starts as version 0\n _decimalOffset = SafeCast.toInt256(10 ** registry_.decimals(base, quote));\n }\n\n /**\n * @notice Checks for a new price and updates the internal phase annotation state accordingly\n * @return The current oracle version after sync\n */\n function sync() external returns (OracleVersion memory) {\n // Fetch latest round\n ChainlinkRound memory round = registry.getLatestRound(base, quote);\n\n // Update phase annotation when new phase detected\n while (round.phaseId() > _latestPhaseId()) {\n uint256 roundCount = registry.getRoundCount(base, quote, _latestPhaseId());\n _startingVersionForPhaseId.push(roundCount);\n }\n\n // Return packaged oracle version\n return _buildOracleVersion(round);\n }\n\n /**\n * @notice Returns the current oracle version\n * @return oracleVersion Current oracle version\n */\n function currentVersion() public view returns (OracleVersion memory oracleVersion) {\n return _buildOracleVersion(registry.getLatestRound(base, quote));\n }\n\n /**\n * @notice Returns the current oracle version\n * @param version The version of which to lookup\n * @return oracleVersion Oracle version at version `version`\n */\n function atVersion(uint256 version) public view returns (OracleVersion memory oracleVersion) {\n return _buildOracleVersion(registry.getRound(base, quote, _versionToRoundId(version)), version);\n }\n\n /**\n * @notice Builds an oracle version object from a Chainlink round object\n * @dev Computes the version for the round\n * @param round Chainlink round to build from\n * @return Built oracle version\n */\n function _buildOracleVersion(ChainlinkRound memory round) private view returns (OracleVersion memory) {\n uint256 version = _startingVersionForPhaseId[round.phaseId()] +\n uint256(round.roundId - registry.getStartingRoundId(base, quote, round.phaseId()));\n return _buildOracleVersion(round, version);\n }\n\n /**\n * @notice Builds an oracle version object from a Chainlink round object\n * @param round Chainlink round to build from\n * @param version Determined version for the round\n * @return Built oracle version\n */\n function _buildOracleVersion(ChainlinkRound memory round, uint256 version)\n private view returns (OracleVersion memory) {\n Fixed18 price = Fixed18Lib.ratio(round.answer, _decimalOffset);\n return OracleVersion({ version: version, timestamp: round.timestamp, price: price });\n }\n\n /**\n * @notice Computes the chainlink round ID from a version\n * @notice version Version to compute from\n * @return Chainlink round ID\n */\n function _versionToRoundId(uint256 version) private view returns (uint80) {\n uint16 phaseId = _versionToPhaseId(version);\n return registry.getStartingRoundId(base, quote, phaseId) +\n uint80(version - _startingVersionForPhaseId[phaseId]);\n }\n\n /**\n * @notice Computes the chainlink phase ID from a version\n * @param version Version to compute from\n * @return phaseId Chainlink phase ID\n */\n function _versionToPhaseId(uint256 version) private view returns (uint16 phaseId) {\n phaseId = _latestPhaseId();\n while (_startingVersionForPhaseId[phaseId] > version) {\n phaseId--;\n }\n }\n\n /**\n * @notice Returns the latest phase ID that this contract has seen via `sync()`\n * @return Latest seen phase ID\n */\n function _latestPhaseId() private view returns (uint16) {\n return uint16(_startingVersionForPhaseId.length - 1);\n }\n}\n" - }, - "contracts/hardhat-dependency-compiler/@equilibria/perennial-oracle/contracts/ChainlinkOracle.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@equilibria/perennial-oracle/contracts/ChainlinkOracle.sol';\n" - }, - "contracts/hardhat-dependency-compiler/@equilibria/perennial-oracle/contracts/ReservoirFeedOracle.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@equilibria/perennial-oracle/contracts/ReservoirFeedOracle.sol';\n" - } - }, - "settings": { - "optimizer": { - "enabled": true, - "runs": 1000000 - }, - "outputSelection": { - "*": { - "*": [ - "abi", - "evm.bytecode", - "evm.deployedBytecode", - "evm.methodIdentifiers", - "metadata", - "devdoc", - "userdoc", - "storageLayout", - "evm.gasEstimates" - ], - "": ["ast"] - } - }, - "metadata": { - "useLiteralContent": true - } - } -} diff --git a/packages/perennial/deployments/kovan/.chainId b/packages/perennial/deployments/kovan/.chainId deleted file mode 100644 index f70d7bba4..000000000 --- a/packages/perennial/deployments/kovan/.chainId +++ /dev/null @@ -1 +0,0 @@ -42 \ No newline at end of file diff --git a/packages/perennial/deployments/kovan/Collateral_Impl.json b/packages/perennial/deployments/kovan/Collateral_Impl.json deleted file mode 100644 index 3510e1bf2..000000000 --- a/packages/perennial/deployments/kovan/Collateral_Impl.json +++ /dev/null @@ -1,865 +0,0 @@ -{ - "address": "0x17aBb7df4cdCddA78039D51Abacfd2B75f82434f", - "abi": [ - { - "inputs": [ - { - "internalType": "Token18", - "name": "token_", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "totalMaintenance", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "totalCollateral", - "type": "uint256" - } - ], - "name": "CollateralCantLiquidate", - "type": "error" - }, - { - "inputs": [], - "name": "CollateralInsufficientCollateralError", - "type": "error" - }, - { - "inputs": [], - "name": "CollateralUnderLimitError", - "type": "error" - }, - { - "inputs": [], - "name": "CollateralZeroAddressError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Fixed18OverflowError", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidControllerError", - "type": "error" - }, - { - "inputs": [], - "name": "NotCollateralError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - } - ], - "name": "NotOwnerError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "NotProductError", - "type": "error" - }, - { - "inputs": [], - "name": "PausedError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "version", - "type": "uint256" - } - ], - "name": "UInitializableAlreadyInitializedError", - "type": "error" - }, - { - "inputs": [], - "name": "UInitializableNotInitializingError", - "type": "error" - }, - { - "inputs": [], - "name": "UInitializableZeroVersionError", - "type": "error" - }, - { - "inputs": [], - "name": "UReentrancyGuardReentrantCallError", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": false, - "internalType": "Fixed18", - "name": "amount", - "type": "int256" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "newShortfall", - "type": "uint256" - } - ], - "name": "AccountSettle", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "user", - "type": "address" - }, - { - "indexed": true, - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "Deposit", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "FeeClaim", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "version", - "type": "uint256" - } - ], - "name": "Initialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "user", - "type": "address" - }, - { - "indexed": true, - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "liquidator", - "type": "address" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "fee", - "type": "uint256" - } - ], - "name": "Liquidation", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "protocolFee", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "productFee", - "type": "uint256" - } - ], - "name": "ProductSettle", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "ShortfallResolution", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "user", - "type": "address" - }, - { - "indexed": true, - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "Withdrawal", - "type": "event" - }, - { - "inputs": [], - "name": "claimFee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "collateral", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "collateral", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "controller", - "outputs": [ - { - "internalType": "contract IController", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "depositTo", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "fees", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IController", - "name": "controller_", - "type": "address" - } - ], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "liquidatable", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "liquidatableNext", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "liquidate", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "resolveShortfall", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "Fixed18", - "name": "amount", - "type": "int256" - } - ], - "name": "settleAccount", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "settleProduct", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "shortfall", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "token", - "outputs": [ - { - "internalType": "Token18", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "withdrawTo", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } - ], - "transactionHash": "0xd3630008713e017b2b5a7be399203cb595a075554183890fb01f3ef19e09e12b", - "receipt": { - "to": null, - "from": "0x66a7fDB96C583c59597de16d8b2B989231415339", - "contractAddress": "0x17aBb7df4cdCddA78039D51Abacfd2B75f82434f", - "transactionIndex": 0, - "gasUsed": "2462146", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x224ef7867148870d0246e3016214b4868da365ac47ea4dfb581da2a9633f14bc", - "transactionHash": "0xd3630008713e017b2b5a7be399203cb595a075554183890fb01f3ef19e09e12b", - "logs": [], - "blockNumber": 33203728, - "cumulativeGasUsed": "2462146", - "status": 1, - "byzantium": true - }, - "args": ["0x1e7d42D73291A9580F1f9b6483928319CE1c3d75"], - "numDeployments": 1, - "solcInputHash": "dd52f03d8fef7833844e4ba864fd9fba", - "metadata": "{\"compiler\":{\"version\":\"0.8.15+commit.e14f2714\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"Token18\",\"name\":\"token_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"totalMaintenance\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"totalCollateral\",\"type\":\"uint256\"}],\"name\":\"CollateralCantLiquidate\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CollateralInsufficientCollateralError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CollateralUnderLimitError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CollateralZeroAddressError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Fixed18OverflowError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidControllerError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotCollateralError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"}],\"name\":\"NotOwnerError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"NotProductError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"PausedError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"UInitializableAlreadyInitializedError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UInitializableNotInitializingError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UInitializableZeroVersionError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UReentrancyGuardReentrantCallError\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"Fixed18\",\"name\":\"amount\",\"type\":\"int256\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"newShortfall\",\"type\":\"uint256\"}],\"name\":\"AccountSettle\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Deposit\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"FeeClaim\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"liquidator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"fee\",\"type\":\"uint256\"}],\"name\":\"Liquidation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"protocolFee\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"productFee\",\"type\":\"uint256\"}],\"name\":\"ProductSettle\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"ShortfallResolution\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Withdrawal\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"claimFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"collateral\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"collateral\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"controller\",\"outputs\":[{\"internalType\":\"contract IController\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"depositTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"fees\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IController\",\"name\":\"controller_\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"liquidatable\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"liquidatableNext\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"liquidate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"resolveShortfall\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"Fixed18\",\"name\":\"amount\",\"type\":\"int256\"}],\"name\":\"settleAccount\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"settleProduct\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"shortfall\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"token\",\"outputs\":[{\"internalType\":\"Token18\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"withdrawTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"collateral(address)\":{\"params\":{\"product\":\"Product to return for\"},\"returns\":{\"_0\":\"The total balance of collateral in the product\"}},\"collateral(address,address)\":{\"params\":{\"account\":\"Account to return for\",\"product\":\"Product to return for\"},\"returns\":{\"_0\":\"The balance of the collateral account\"}},\"constructor\":{\"details\":\"Called at implementation instantiate and constant for that implementation.\",\"params\":{\"token_\":\"Collateral ERC20 stablecoin address\"}},\"depositTo(address,address,uint256)\":{\"params\":{\"account\":\"Account to deposit the collateral for\",\"amount\":\"Amount of collateral to deposit\",\"product\":\"Product to credit the collateral to\"}},\"initialize(address)\":{\"details\":\"Must be called atomically as part of the upgradeable proxy deployment to avoid front-running\",\"params\":{\"controller_\":\"Factory contract address\"}},\"liquidatable(address,address)\":{\"params\":{\"account\":\"Account to return for\",\"product\":\"Product to return for\"},\"returns\":{\"_0\":\"Whether the account can be liquidated\"}},\"liquidatableNext(address,address)\":{\"details\":\"Takes into account the current pre-position on the account\",\"params\":{\"account\":\"Account to return for\",\"product\":\"Product to return for\"},\"returns\":{\"_0\":\"Whether the account can be liquidated\"}},\"liquidate(address,address)\":{\"details\":\"Account must be under-collateralized, fee returned immediately to `msg.sender`\",\"params\":{\"account\":\"Account to liquidate\",\"product\":\"Product to liquidate for\"}},\"resolveShortfall(address,uint256)\":{\"details\":\"Shortfall is a measure of settled insolvency in the market This hook can be used by the product owner or an insurance fund to re-capitalize an insolvent market\",\"params\":{\"amount\":\"Amount of shortfall to resolve\",\"product\":\"Product to resolve shortfall for\"}},\"settleAccount(address,int256)\":{\"details\":\"Callable only by the corresponding product as part of the settlement flywheel. Moves collateral within a product, any collateral leaving the product due to fees has already been accounted for in the settleProduct flywheel. Debits in excess of the account balance get recorded as shortfall, and can be resolved by the product owner as needed.\",\"params\":{\"account\":\"Account to credit\",\"amount\":\"Amount to credit the account (can be negative)\"}},\"settleProduct(uint256)\":{\"details\":\"Callable only by the corresponding product as part of the settlement flywheel Removes collateral from the product as fees.\",\"params\":{\"amount\":\"Amount to debit from the account\"}},\"shortfall(address)\":{\"params\":{\"product\":\"Product to return for\"},\"returns\":{\"_0\":\"The current shortfall of the product\"}},\"withdrawTo(address,address,uint256)\":{\"params\":{\"account\":\"Account to withdraw the collateral to\",\"amount\":\"Amount of collateral to withdraw\",\"product\":\"Product to withdraw the collateral from\"}}},\"stateVariables\":{\"_products\":{\"details\":\"Per product collateral state\"},\"fees\":{\"details\":\"Protocol and product fees collected, but not yet claimed\"},\"token\":{\"details\":\"ERC20 stablecoin for collateral\"}},\"title\":\"Collateral\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"claimFee()\":{\"notice\":\"Claims all of `msg.sender`'s fees\"},\"collateral(address)\":{\"notice\":\"Returns the total balance of `product`'s collateral\"},\"collateral(address,address)\":{\"notice\":\"Returns the balance of `account`'s `product` collateral account\"},\"constructor\":{\"notice\":\"Initializes the immutable contract state\"},\"depositTo(address,address,uint256)\":{\"notice\":\"Deposits `amount` collateral from `msg.sender` to `account`'s `product` account\"},\"initialize(address)\":{\"notice\":\"Initializes the contract state\"},\"liquidatable(address,address)\":{\"notice\":\"Returns whether `account`'s `product` collateral account can be liquidated\"},\"liquidatableNext(address,address)\":{\"notice\":\"Returns whether `account`'s `product` collateral account can be liquidated after the next oracle version settlement\"},\"liquidate(address,address)\":{\"notice\":\"Liquidates `account`'s `product` collateral account\"},\"resolveShortfall(address,uint256)\":{\"notice\":\"Injects additional collateral into a product to resolve shortfall\"},\"settleAccount(address,int256)\":{\"notice\":\"Credits `amount` to `account`'s collateral account\"},\"settleProduct(uint256)\":{\"notice\":\"Debits `amount` from product's total collateral account\"},\"shortfall(address)\":{\"notice\":\"Returns the current shortfall of `product`'s collateral\"},\"withdrawTo(address,address,uint256)\":{\"notice\":\"Withdraws `amount` collateral from `msg.sender`'s `product` account and sends it to `account`\"}},\"notice\":\"Manages logic and state for all collateral accounts in the protocol.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/collateral/Collateral.sol\":\"Collateral\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\n\\ninterface IOracleProvider {\\n /// @dev A singular oracle version with its corresponding data\\n struct OracleVersion {\\n /// @dev The iterative version\\n uint256 version;\\n\\n /// @dev the timestamp of the oracle update\\n uint256 timestamp;\\n\\n /// @dev The oracle price of the corresponding version\\n Fixed18 price;\\n }\\n\\n function sync() external returns (OracleVersion memory);\\n function currentVersion() external view returns (OracleVersion memory);\\n function atVersion(uint256 oracleVersion) external view returns (OracleVersion memory);\\n}\\n\",\"keccak256\":\"0xde0f20d468ba8b91addfc356e13f2c74a4dc8abe68be323942217c723775d9c1\",\"license\":\"Apache-2.0\"},\"@equilibria/root/control/unstructured/UInitializable.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/Address.sol\\\";\\nimport \\\"../../storage/UStorage.sol\\\";\\n\\n/**\\n * @title UInitializable\\n * @notice Library to manage the initialization lifecycle of upgradeable contracts\\n * @dev `UInitializable` allows the creation of pseudo-constructors for upgradeable contracts. One\\n * `initializer` should be declared per top-level contract. Child contracts can use the `onlyInitializer`\\n * modifier to tag their internal initialization functions to ensure that they can only be called\\n * from a top-level `initializer` or a constructor.\\n */\\nabstract contract UInitializable {\\n error UInitializableZeroVersionError();\\n error UInitializableAlreadyInitializedError(uint256 version);\\n error UInitializableNotInitializingError();\\n\\n event Initialized(uint256 version);\\n\\n /// @dev The initialized flag\\n Uint256Storage private constant _version = Uint256Storage.wrap(keccak256(\\\"equilibria.root.UInitializable.version\\\"));\\n\\n /// @dev The initializing flag\\n BoolStorage private constant _initializing = BoolStorage.wrap(keccak256(\\\"equilibria.root.UInitializable.initializing\\\"));\\n\\n /// @dev Can only be called once per version, `version` is 1-indexed\\n modifier initializer(uint256 version) {\\n if (version == 0) revert UInitializableZeroVersionError();\\n if (_version.read() >= version) revert UInitializableAlreadyInitializedError(version);\\n\\n _version.store(version);\\n _initializing.store(true);\\n\\n _;\\n\\n _initializing.store(false);\\n emit Initialized(version);\\n }\\n\\n /// @dev Can only be called from an initializer or constructor\\n modifier onlyInitializer() {\\n if (!_constructing() && !_initializing.read()) revert UInitializableNotInitializingError();\\n _;\\n }\\n\\n /**\\n * @notice Returns whether the contract is currently being constructed\\n * @dev {Address.isContract} returns false for contracts currently in the process of being constructed\\n * @return Whether the contract is currently being constructed\\n */\\n function _constructing() private view returns (bool) {\\n return !Address.isContract(address(this));\\n }\\n}\\n\",\"keccak256\":\"0xd2743d8fcc220ed2ccdc0bba1db0a3e107741bd5c0cac47ca8c0b5a00ba2fd7f\",\"license\":\"Apache-2.0\"},\"@equilibria/root/control/unstructured/UReentrancyGuard.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"./UInitializable.sol\\\";\\nimport \\\"../../storage/UStorage.sol\\\";\\n\\n/**\\n * @dev Contract module that helps prevent reentrant calls to a function.\\n *\\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\\n * available, which can be applied to functions to make sure there are no nested\\n * (reentrant) calls to them.\\n *\\n * Note that because there is a single `nonReentrant` guard, functions marked as\\n * `nonReentrant` may not call one another. This can be worked around by making\\n * those functions `private`, and then adding `external` `nonReentrant` entry\\n * points to them.\\n *\\n * TIP: If you would like to learn more about reentrancy and alternative ways\\n * to protect against it, check out our blog post\\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\\n *\\n * NOTE: This contract has been extended from the Open Zeppelin library to include an\\n * unstructured storage pattern, so that it can be safely mixed in with upgradeable\\n * contracts without affecting their storage patterns through inheritance.\\n */\\nabstract contract UReentrancyGuard is UInitializable {\\n error UReentrancyGuardReentrantCallError();\\n\\n uint256 private constant _NOT_ENTERED = 1;\\n uint256 private constant _ENTERED = 2;\\n\\n /**\\n * @dev unstructured storage slot for the reentrancy status\\n */\\n Uint256Storage private constant _status = Uint256Storage.wrap(keccak256(\\\"equilibria.root.UReentrancyGuard.status\\\"));\\n\\n /**\\n * @dev Initializes the contract setting the status to _NOT_ENTERED.\\n */\\n function __UReentrancyGuard__initialize() internal onlyInitializer {\\n _status.store(_NOT_ENTERED);\\n }\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n * Calling a `nonReentrant` function from another `nonReentrant`\\n * function is not supported. It is possible to prevent this from happening\\n * by making the `nonReentrant` function external, and make it call a\\n * `private` function that does the actual work.\\n */\\n modifier nonReentrant() {\\n // On the first call to nonReentrant, _notEntered will be true\\n if (_status.read() == _ENTERED) revert UReentrancyGuardReentrantCallError();\\n\\n // Any calls to nonReentrant after this point will fail\\n _status.store(_ENTERED);\\n\\n _;\\n\\n // By storing the original value once again, a refund is triggered (see\\n // https://eips.ethereum.org/EIPS/eip-2200)\\n _status.store(_NOT_ENTERED);\\n }\\n}\\n\",\"keccak256\":\"0x4962245ca8fdda3dc40c0f942a3568d90fb69428a6927b058018b01c90eb9fc9\",\"license\":\"Apache-2.0\"},\"@equilibria/root/curve/CurveMath.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"../number/types/UFixed18.sol\\\";\\nimport \\\"../number/types/Fixed18.sol\\\";\\n\\n/**\\n * @title CurveMath\\n * @notice Library for managing math operations for utilization curves.\\n */\\nlibrary CurveMath {\\n error CurveMathOutOfBoundsError();\\n\\n /**\\n * @notice Computes a linear interpolation between two points\\n * @param startX First point's x-coordinate\\n * @param startY First point's y-coordinate\\n * @param endX Second point's x-coordinate\\n * @param endY Second point's y-coordinate\\n * @param targetX x-coordinate to interpolate\\n * @return y-coordinate for `targetX` along the line from (`startX`, `startY`) -> (`endX`, `endY`)\\n */\\n function linearInterpolation(\\n UFixed18 startX,\\n Fixed18 startY,\\n UFixed18 endX,\\n Fixed18 endY,\\n UFixed18 targetX\\n ) internal pure returns (Fixed18) {\\n if (targetX.lt(startX) || targetX.gt(endX)) revert CurveMathOutOfBoundsError();\\n\\n UFixed18 xRange = endX.sub(startX);\\n Fixed18 yRange = endY.sub(startY);\\n UFixed18 xRatio = targetX.sub(startX).div(xRange);\\n return yRange.mul(Fixed18Lib.from(xRatio)).add(startY);\\n }\\n}\\n\",\"keccak256\":\"0x60d159f9ddf0dbe81124ecad58bba734b4cf82877637ff8d9d7f3e92f2da4ded\",\"license\":\"Apache-2.0\"},\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"../CurveMath.sol\\\";\\nimport \\\"../../number/types/PackedUFixed18.sol\\\";\\nimport \\\"../../number/types/PackedFixed18.sol\\\";\\n\\n/// @dev JumpRateUtilizationCurve type\\nstruct JumpRateUtilizationCurve {\\n PackedFixed18 minRate;\\n PackedFixed18 maxRate;\\n PackedFixed18 targetRate;\\n PackedUFixed18 targetUtilization;\\n}\\nusing JumpRateUtilizationCurveLib for JumpRateUtilizationCurve global;\\ntype JumpRateUtilizationCurveStorage is bytes32;\\nusing JumpRateUtilizationCurveStorageLib for JumpRateUtilizationCurveStorage global;\\n\\n/**\\n * @title JumpRateUtilizationCurveLib\\n * @notice Library for the Jump Rate utilization curve type\\n */\\nlibrary JumpRateUtilizationCurveLib {\\n /**\\n * @notice Computes the corresponding rate for a utilization ratio\\n * @param utilization The utilization ratio\\n * @return The corresponding rate\\n */\\n function compute(JumpRateUtilizationCurve memory self, UFixed18 utilization) internal pure returns (Fixed18) {\\n UFixed18 targetUtilization = self.targetUtilization.unpack();\\n if (utilization.lt(targetUtilization)) {\\n return CurveMath.linearInterpolation(\\n UFixed18Lib.ZERO,\\n self.minRate.unpack(),\\n targetUtilization,\\n self.targetRate.unpack(),\\n utilization\\n );\\n }\\n if (utilization.lt(UFixed18Lib.ONE)) {\\n return CurveMath.linearInterpolation(\\n targetUtilization,\\n self.targetRate.unpack(),\\n UFixed18Lib.ONE,\\n self.maxRate.unpack(),\\n utilization\\n );\\n }\\n return self.maxRate.unpack();\\n }\\n}\\n\\nlibrary JumpRateUtilizationCurveStorageLib {\\n function read(JumpRateUtilizationCurveStorage self) internal view returns (JumpRateUtilizationCurve memory) {\\n return _storagePointer(self);\\n }\\n\\n function store(JumpRateUtilizationCurveStorage self, JumpRateUtilizationCurve memory value) internal {\\n JumpRateUtilizationCurve storage storagePointer = _storagePointer(self);\\n\\n storagePointer.minRate = value.minRate;\\n storagePointer.maxRate = value.maxRate;\\n storagePointer.targetRate = value.targetRate;\\n storagePointer.targetUtilization = value.targetUtilization;\\n }\\n\\n function _storagePointer(JumpRateUtilizationCurveStorage self)\\n private pure returns (JumpRateUtilizationCurve storage pointer) {\\n assembly { pointer.slot := self }\\n }\\n}\",\"keccak256\":\"0xae202813874bc306d51b3dab8194c86f6483bb20bf1f673ddaee16aa8de567ff\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/Fixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SignedMath.sol\\\";\\nimport \\\"./UFixed18.sol\\\";\\nimport \\\"./PackedFixed18.sol\\\";\\n\\n/// @dev Fixed18 type\\ntype Fixed18 is int256;\\nusing Fixed18Lib for Fixed18 global;\\ntype Fixed18Storage is bytes32;\\nusing Fixed18StorageLib for Fixed18Storage global;\\n\\n/**\\n * @title Fixed18Lib\\n * @notice Library for the signed fixed-decimal type.\\n */\\nlibrary Fixed18Lib {\\n error Fixed18OverflowError(uint256 value);\\n error Fixed18PackingOverflowError(int256 value);\\n error Fixed18PackingUnderflowError(int256 value);\\n\\n int256 private constant BASE = 1e18;\\n Fixed18 public constant ZERO = Fixed18.wrap(0);\\n Fixed18 public constant ONE = Fixed18.wrap(BASE);\\n Fixed18 public constant NEG_ONE = Fixed18.wrap(-1 * BASE);\\n Fixed18 public constant MAX = Fixed18.wrap(type(int256).max);\\n Fixed18 public constant MIN = Fixed18.wrap(type(int256).min);\\n\\n /**\\n * @notice Creates a signed fixed-decimal from an unsigned fixed-decimal\\n * @param a Unsigned fixed-decimal\\n * @return New signed fixed-decimal\\n */\\n function from(UFixed18 a) internal pure returns (Fixed18) {\\n uint256 value = UFixed18.unwrap(a);\\n if (value > uint256(type(int256).max)) revert Fixed18OverflowError(value);\\n return Fixed18.wrap(int256(value));\\n }\\n\\n /**\\n * @notice Creates a signed fixed-decimal from a sign and an unsigned fixed-decimal\\n * @param s Sign\\n * @param m Unsigned fixed-decimal magnitude\\n * @return New signed fixed-decimal\\n */\\n function from(int256 s, UFixed18 m) internal pure returns (Fixed18) {\\n if (s > 0) return from(m);\\n if (s < 0) return Fixed18.wrap(-1 * Fixed18.unwrap(from(m)));\\n return ZERO;\\n }\\n\\n /**\\n * @notice Creates a signed fixed-decimal from a signed integer\\n * @param a Signed number\\n * @return New signed fixed-decimal\\n */\\n function from(int256 a) internal pure returns (Fixed18) {\\n return Fixed18.wrap(a * BASE);\\n }\\n\\n /**\\n * @notice Creates a packed signed fixed-decimal from an signed fixed-decimal\\n * @param a signed fixed-decimal\\n * @return New packed signed fixed-decimal\\n */\\n function pack(Fixed18 a) internal pure returns (PackedFixed18) {\\n int256 value = Fixed18.unwrap(a);\\n if (value > type(int128).max) revert Fixed18PackingOverflowError(value);\\n if (value < type(int128).min) revert Fixed18PackingUnderflowError(value);\\n return PackedFixed18.wrap(int128(value));\\n }\\n\\n /**\\n * @notice Returns whether the signed fixed-decimal is equal to zero.\\n * @param a Signed fixed-decimal\\n * @return Whether the signed fixed-decimal is zero.\\n */\\n function isZero(Fixed18 a) internal pure returns (bool) {\\n return Fixed18.unwrap(a) == 0;\\n }\\n\\n /**\\n * @notice Adds two signed fixed-decimals `a` and `b` together\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Resulting summed signed fixed-decimal\\n */\\n function add(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) + Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Subtracts signed fixed-decimal `b` from `a`\\n * @param a Signed fixed-decimal to subtract from\\n * @param b Signed fixed-decimal to subtract\\n * @return Resulting subtracted signed fixed-decimal\\n */\\n function sub(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) - Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Multiplies two signed fixed-decimals `a` and `b` together\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Resulting multiplied signed fixed-decimal\\n */\\n function mul(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / BASE);\\n }\\n\\n /**\\n * @notice Divides signed fixed-decimal `a` by `b`\\n * @param a Signed fixed-decimal to divide\\n * @param b Signed fixed-decimal to divide by\\n * @return Resulting divided signed fixed-decimal\\n */\\n function div(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * BASE / Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0`, `MAX` for `n/0`, and `MIN` for `-n/0`.\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function unsafeDiv(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n if (isZero(b)) {\\n if (gt(a, ZERO)) return MAX;\\n if (lt(a, ZERO)) return MIN;\\n return ONE;\\n } else {\\n return div(a, b);\\n }\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First signed fixed-decimal\\n * @param b Signed number to multiply by\\n * @param c Signed number to divide by\\n * @return Resulting computation\\n */\\n function muldiv(Fixed18 a, int256 b, int256 c) internal pure returns (Fixed18) {\\n return muldiv(a, Fixed18.wrap(b), Fixed18.wrap(c));\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First signed fixed-decimal\\n * @param b Signed fixed-decimal to multiply by\\n * @param c Signed fixed-decimal to divide by\\n * @return Resulting computation\\n */\\n function muldiv(Fixed18 a, Fixed18 b, Fixed18 c) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / Fixed18.unwrap(c));\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is equal to `b`\\n */\\n function eq(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 1;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is greater than `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is greater than `b`\\n */\\n function gt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 2;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is less than `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is less than `b`\\n */\\n function lt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 0;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is greater than or equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is greater than or equal to `b`\\n */\\n function gte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return gt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is less than or equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is less than or equal to `b`\\n */\\n function lte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return lt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Compares the signed fixed-decimals `a` and `b`\\n * @dev Returns: 2 for greater than\\n * 1 for equal to\\n * 0 for less than\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Compare result of `a` and `b`\\n */\\n function compare(Fixed18 a, Fixed18 b) internal pure returns (uint256) {\\n (int256 au, int256 bu) = (Fixed18.unwrap(a), Fixed18.unwrap(b));\\n if (au > bu) return 2;\\n if (au < bu) return 0;\\n return 1;\\n }\\n\\n /**\\n * @notice Returns a signed fixed-decimal representing the ratio of `a` over `b`\\n * @param a First signed number\\n * @param b Second signed number\\n * @return Ratio of `a` over `b`\\n */\\n function ratio(int256 a, int256 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(a * BASE / b);\\n }\\n\\n /**\\n * @notice Returns the minimum of signed fixed-decimals `a` and `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Minimum of `a` and `b`\\n */\\n function min(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(SignedMath.min(Fixed18.unwrap(a), Fixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Returns the maximum of signed fixed-decimals `a` and `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Maximum of `a` and `b`\\n */\\n function max(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(SignedMath.max(Fixed18.unwrap(a), Fixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Converts the signed fixed-decimal into an integer, truncating any decimal portion\\n * @param a Signed fixed-decimal\\n * @return Truncated signed number\\n */\\n function truncate(Fixed18 a) internal pure returns (int256) {\\n return Fixed18.unwrap(a) / BASE;\\n }\\n\\n /**\\n * @notice Returns the sign of the signed fixed-decimal\\n * @dev Returns: -1 for negative\\n * 0 for zero\\n * 1 for positive\\n * @param a Signed fixed-decimal\\n * @return Sign of the signed fixed-decimal\\n */\\n function sign(Fixed18 a) internal pure returns (int256) {\\n if (Fixed18.unwrap(a) > 0) return 1;\\n if (Fixed18.unwrap(a) < 0) return -1;\\n return 0;\\n }\\n\\n /**\\n * @notice Returns the absolute value of the signed fixed-decimal\\n * @param a Signed fixed-decimal\\n * @return Absolute value of the signed fixed-decimal\\n */\\n function abs(Fixed18 a) internal pure returns (UFixed18) {\\n return UFixed18.wrap(SignedMath.abs(Fixed18.unwrap(a)));\\n }\\n}\\n\\nlibrary Fixed18StorageLib {\\n function read(Fixed18Storage self) internal view returns (Fixed18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(Fixed18Storage self, Fixed18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x613587461ef3437ef33229cdda7d34ea746278721baf06e20b2e43977f43174d\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/PackedFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"./Fixed18.sol\\\";\\n\\n/// @dev PackedFixed18 type\\ntype PackedFixed18 is int128;\\nusing PackedFixed18Lib for PackedFixed18 global;\\n\\n/**\\n * @title PackedFixed18Lib\\n * @dev A packed version of the Fixed18 which takes up half the storage space (two PackedFixed18 can be packed\\n * into a single slot). Only valid within the range -1.7014118e+20 <= x <= 1.7014118e+20.\\n * @notice Library for the packed signed fixed-decimal type.\\n */\\nlibrary PackedFixed18Lib {\\n PackedFixed18 public constant MAX = PackedFixed18.wrap(type(int128).max);\\n PackedFixed18 public constant MIN = PackedFixed18.wrap(type(int128).min);\\n\\n /**\\n * @notice Creates an unpacked signed fixed-decimal from a packed signed fixed-decimal\\n * @param self packed signed fixed-decimal\\n * @return New unpacked signed fixed-decimal\\n */\\n function unpack(PackedFixed18 self) internal pure returns (Fixed18) {\\n return Fixed18.wrap(int256(PackedFixed18.unwrap(self)));\\n }\\n}\\n\",\"keccak256\":\"0xb52960cc8e3132e45d342bbbb1c6a96219022cd8557997933bd8250170268b64\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/PackedUFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"./UFixed18.sol\\\";\\n\\n/// @dev PackedUFixed18 type\\ntype PackedUFixed18 is uint128;\\nusing PackedUFixed18Lib for PackedUFixed18 global;\\n\\n/**\\n * @title PackedUFixed18Lib\\n * @dev A packed version of the UFixed18 which takes up half the storage space (two PackedUFixed18 can be packed\\n * into a single slot). Only valid within the range 0 <= x <= 3.4028237e+20.\\n * @notice Library for the packed unsigned fixed-decimal type.\\n */\\nlibrary PackedUFixed18Lib {\\n PackedUFixed18 public constant MAX = PackedUFixed18.wrap(type(uint128).max);\\n\\n /**\\n * @notice Creates an unpacked unsigned fixed-decimal from a packed unsigned fixed-decimal\\n * @param self packed unsigned fixed-decimal\\n * @return New unpacked unsigned fixed-decimal\\n */\\n function unpack(PackedUFixed18 self) internal pure returns (UFixed18) {\\n return UFixed18.wrap(uint256(PackedUFixed18.unwrap(self)));\\n }\\n}\\n\",\"keccak256\":\"0xb5c5cd32d6530b2fe75228b6be32ebcb7762f6d7988b85a6b85a289ce8256d51\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/UFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"./Fixed18.sol\\\";\\nimport \\\"./PackedUFixed18.sol\\\";\\n\\n/// @dev UFixed18 type\\ntype UFixed18 is uint256;\\nusing UFixed18Lib for UFixed18 global;\\ntype UFixed18Storage is bytes32;\\nusing UFixed18StorageLib for UFixed18Storage global;\\n\\n/**\\n * @title UFixed18Lib\\n * @notice Library for the unsigned fixed-decimal type.\\n */\\nlibrary UFixed18Lib {\\n error UFixed18UnderflowError(int256 value);\\n error UFixed18PackingOverflowError(uint256 value);\\n\\n uint256 private constant BASE = 1e18;\\n UFixed18 public constant ZERO = UFixed18.wrap(0);\\n UFixed18 public constant ONE = UFixed18.wrap(BASE);\\n UFixed18 public constant MAX = UFixed18.wrap(type(uint256).max);\\n\\n /**\\n * @notice Creates a unsigned fixed-decimal from a signed fixed-decimal\\n * @param a Signed fixed-decimal\\n * @return New unsigned fixed-decimal\\n */\\n function from(Fixed18 a) internal pure returns (UFixed18) {\\n int256 value = Fixed18.unwrap(a);\\n if (value < 0) revert UFixed18UnderflowError(value);\\n return UFixed18.wrap(uint256(value));\\n }\\n\\n /**\\n * @notice Creates a unsigned fixed-decimal from a unsigned integer\\n * @param a Unsigned number\\n * @return New unsigned fixed-decimal\\n */\\n function from(uint256 a) internal pure returns (UFixed18) {\\n return UFixed18.wrap(a * BASE);\\n }\\n\\n /**\\n * @notice Creates a packed unsigned fixed-decimal from an unsigned fixed-decimal\\n * @param a unsigned fixed-decimal\\n * @return New packed unsigned fixed-decimal\\n */\\n function pack(UFixed18 a) internal pure returns (PackedUFixed18) {\\n uint256 value = UFixed18.unwrap(a);\\n if (value > type(uint128).max) revert UFixed18PackingOverflowError(value);\\n return PackedUFixed18.wrap(uint128(value));\\n }\\n\\n /**\\n * @notice Returns whether the unsigned fixed-decimal is equal to zero.\\n * @param a Unsigned fixed-decimal\\n * @return Whether the unsigned fixed-decimal is zero.\\n */\\n function isZero(UFixed18 a) internal pure returns (bool) {\\n return UFixed18.unwrap(a) == 0;\\n }\\n\\n /**\\n * @notice Adds two unsigned fixed-decimals `a` and `b` together\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Resulting summed unsigned fixed-decimal\\n */\\n function add(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) + UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Subtracts unsigned fixed-decimal `b` from `a`\\n * @param a Unsigned fixed-decimal to subtract from\\n * @param b Unsigned fixed-decimal to subtract\\n * @return Resulting subtracted unsigned fixed-decimal\\n */\\n function sub(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) - UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Multiplies two unsigned fixed-decimals `a` and `b` together\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Resulting multiplied unsigned fixed-decimal\\n */\\n function mul(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / BASE);\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function div(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * BASE / UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0` and `MAX` for `n/0`.\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function unsafeDiv(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n if (isZero(b)) {\\n return isZero(a) ? ONE : MAX;\\n } else {\\n return div(a, b);\\n }\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First unsigned fixed-decimal\\n * @param b Unsigned number to multiply by\\n * @param c Unsigned number to divide by\\n * @return Resulting computation\\n */\\n function muldiv(UFixed18 a, uint256 b, uint256 c) internal pure returns (UFixed18) {\\n return muldiv(a, UFixed18.wrap(b), UFixed18.wrap(c));\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First unsigned fixed-decimal\\n * @param b Unsigned fixed-decimal to multiply by\\n * @param c Unsigned fixed-decimal to divide by\\n * @return Resulting computation\\n */\\n function muldiv(UFixed18 a, UFixed18 b, UFixed18 c) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / UFixed18.unwrap(c));\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is equal to `b`\\n */\\n function eq(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 1;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is greater than `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is greater than `b`\\n */\\n function gt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 2;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is less than `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is less than `b`\\n */\\n function lt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 0;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is greater than or equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is greater than or equal to `b`\\n */\\n function gte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return gt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is less than or equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is less than or equal to `b`\\n */\\n function lte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return lt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Compares the unsigned fixed-decimals `a` and `b`\\n * @dev Returns: 2 for greater than\\n * 1 for equal to\\n * 0 for less than\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Compare result of `a` and `b`\\n */\\n function compare(UFixed18 a, UFixed18 b) internal pure returns (uint256) {\\n (uint256 au, uint256 bu) = (UFixed18.unwrap(a), UFixed18.unwrap(b));\\n if (au > bu) return 2;\\n if (au < bu) return 0;\\n return 1;\\n }\\n\\n /**\\n * @notice Returns a unsigned fixed-decimal representing the ratio of `a` over `b`\\n * @param a First unsigned number\\n * @param b Second unsigned number\\n * @return Ratio of `a` over `b`\\n */\\n function ratio(uint256 a, uint256 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(a * BASE / b);\\n }\\n\\n /**\\n * @notice Returns the minimum of unsigned fixed-decimals `a` and `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Minimum of `a` and `b`\\n */\\n function min(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(Math.min(UFixed18.unwrap(a), UFixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Returns the maximum of unsigned fixed-decimals `a` and `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Maximum of `a` and `b`\\n */\\n function max(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(Math.max(UFixed18.unwrap(a), UFixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Converts the unsigned fixed-decimal into an integer, truncating any decimal portion\\n * @param a Unsigned fixed-decimal\\n * @return Truncated unsigned number\\n */\\n function truncate(UFixed18 a) internal pure returns (uint256) {\\n return UFixed18.unwrap(a) / BASE;\\n }\\n}\\n\\nlibrary UFixed18StorageLib {\\n function read(UFixed18Storage self) internal view returns (UFixed18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(UFixed18Storage self, UFixed18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x8ebef1e6c717f565b9ed545a876b5692b4007e6485c99f39d363f7405e591792\",\"license\":\"Apache-2.0\"},\"@equilibria/root/storage/UStorage.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"../number/types/UFixed18.sol\\\";\\n\\n/// @dev Stored boolean slot\\ntype BoolStorage is bytes32;\\nusing BoolStorageLib for BoolStorage global;\\n\\n/// @dev Stored uint256 slot\\ntype Uint256Storage is bytes32;\\nusing Uint256StorageLib for Uint256Storage global;\\n\\n/// @dev Stored int256 slot\\ntype Int256Storage is bytes32;\\nusing Int256StorageLib for Int256Storage global;\\n\\n/// @dev Stored address slot\\ntype AddressStorage is bytes32;\\nusing AddressStorageLib for AddressStorage global;\\n\\n/// @dev Stored bytes32 slot\\ntype Bytes32Storage is bytes32;\\nusing Bytes32StorageLib for Bytes32Storage global;\\n\\n/**\\n * @title BoolStorageLib\\n * @notice Library to manage storage and retrival of a boolean at a fixed storage slot\\n */\\nlibrary BoolStorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored bool value\\n */\\n function read(BoolStorage self) internal view returns (bool value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value boolean value to store\\n */\\n function store(BoolStorage self, bool value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\\n/**\\n * @title Uint256StorageLib\\n * @notice Library to manage storage and retrival of an uint256 at a fixed storage slot\\n */\\nlibrary Uint256StorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored uint256 value\\n */\\n function read(Uint256Storage self) internal view returns (uint256 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value uint256 value to store\\n */\\n function store(Uint256Storage self, uint256 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\\n/**\\n * @title Int256StorageLib\\n * @notice Library to manage storage and retrival of an int256 at a fixed storage slot\\n */\\nlibrary Int256StorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored int256 value\\n */\\n function read(Int256Storage self) internal view returns (int256 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value int256 value to store\\n */\\n function store(Int256Storage self, int256 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\\n/**\\n * @title AddressStorageLib\\n * @notice Library to manage storage and retrival of an address at a fixed storage slot\\n */\\nlibrary AddressStorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored address value\\n */\\n function read(AddressStorage self) internal view returns (address value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value address value to store\\n */\\n function store(AddressStorage self, address value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\\n/**\\n * @title Bytes32StorageLib\\n * @notice Library to manage storage and retrival of a bytes32 at a fixed storage slot\\n */\\nlibrary Bytes32StorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored bytes32 value\\n */\\n function read(Bytes32Storage self) internal view returns (bytes32 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value bytes32 value to store\\n */\\n function store(Bytes32Storage self, bytes32 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0xe2b8491d1b5aa93f7e059e1a8f156b0ab37fef9ed973be97a64f2eabfc2cc172\",\"license\":\"Apache-2.0\"},\"@equilibria/root/token/types/Token18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"../../number/types/UFixed18.sol\\\";\\n\\n/// @dev Token18\\ntype Token18 is address;\\nusing Token18Lib for Token18 global;\\ntype Token18Storage is bytes32;\\nusing Token18StorageLib for Token18Storage global;\\n\\n/**\\n * @title Token18Lib\\n * @notice Library to manage 18-decimal ERC20s that is compliant with the fixed-decimal types.\\n * @dev Maintains significant gas savings over other Token implementations since no conversion take place\\n */\\nlibrary Token18Lib {\\n using SafeERC20 for IERC20;\\n\\n Token18 public constant ZERO = Token18.wrap(address(0));\\n\\n /**\\n * @notice Returns whether a token is the zero address\\n * @param self Token to check for\\n * @return Whether the token is the zero address\\n */\\n function isZero(Token18 self) internal pure returns (bool) {\\n return Token18.unwrap(self) == Token18.unwrap(ZERO);\\n }\\n\\n /**\\n * @notice Returns whether the two tokens are equal\\n * @param a First token to compare\\n * @param b Second token to compare\\n * @return Whether the two tokens are equal\\n */\\n function eq(Token18 a, Token18 b) internal pure returns (bool) {\\n return Token18.unwrap(a) == Token18.unwrap(b);\\n }\\n\\n /**\\n * @notice Approves `grantee` to spend infinite tokens from the caller\\n * @param self Token to transfer\\n * @param grantee Address to allow spending\\n */\\n function approve(Token18 self, address grantee) internal {\\n IERC20(Token18.unwrap(self)).safeApprove(grantee, type(uint256).max);\\n }\\n\\n /**\\n * @notice Approves `grantee` to spend `amount` tokens from the caller\\n * @dev There are important race conditions to be aware of when using this function\\n with values other than 0. This will revert if moving from non-zero to non-zero amounts\\n See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/a55b7d13722e7ce850b626da2313f3e66ca1d101/contracts/token/ERC20/IERC20.sol#L57\\n * @param self Token to transfer\\n * @param grantee Address to allow spending\\n * @param amount Amount of tokens to approve to spend\\n */\\n function approve(Token18 self, address grantee, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeApprove(grantee, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers all held tokens from the caller to the `recipient`\\n * @param self Token to transfer\\n * @param recipient Address to receive the tokens\\n */\\n function push(Token18 self, address recipient) internal {\\n push(self, recipient, balanceOf(self, address(this)));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the caller to the `recipient`\\n * @param self Token to transfer\\n * @param recipient Address to transfer tokens to\\n * @param amount Amount of tokens to transfer\\n */\\n function push(Token18 self, address recipient, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransfer(recipient, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the `benefactor` to the caller\\n * @dev Reverts if trying to pull Ether\\n * @param self Token to transfer\\n * @param benefactor Address to transfer tokens from\\n * @param amount Amount of tokens to transfer\\n */\\n function pull(Token18 self, address benefactor, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, address(this), UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the `benefactor` to `recipient`\\n * @dev Reverts if trying to pull Ether\\n * @param self Token to transfer\\n * @param benefactor Address to transfer tokens from\\n * @param recipient Address to transfer tokens to\\n * @param amount Amount of tokens to transfer\\n */\\n function pullTo(Token18 self, address benefactor, address recipient, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, recipient, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Returns the name of the token\\n * @param self Token to check for\\n * @return Token name\\n */\\n function name(Token18 self) internal view returns (string memory) {\\n return IERC20Metadata(Token18.unwrap(self)).name();\\n }\\n\\n /**\\n * @notice Returns the symbol of the token\\n * @param self Token to check for\\n * @return Token symbol\\n */\\n function symbol(Token18 self) internal view returns (string memory) {\\n return IERC20Metadata(Token18.unwrap(self)).symbol();\\n }\\n\\n /**\\n * @notice Returns the `self` token balance of the caller\\n * @param self Token to check for\\n * @return Token balance of the caller\\n */\\n function balanceOf(Token18 self) internal view returns (UFixed18) {\\n return balanceOf(self, address(this));\\n }\\n\\n /**\\n * @notice Returns the `self` token balance of `account`\\n * @param self Token to check for\\n * @param account Account to check\\n * @return Token balance of the account\\n */\\n function balanceOf(Token18 self, address account) internal view returns (UFixed18) {\\n return UFixed18.wrap(IERC20(Token18.unwrap(self)).balanceOf(account));\\n }\\n}\\n\\nlibrary Token18StorageLib {\\n function read(Token18Storage self) internal view returns (Token18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(Token18Storage self, Token18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x6b12afaece814f0ab186200a4729e93eb685a21d3e9b5a3372ff283a7ad5dc23\",\"license\":\"Apache-2.0\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\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 amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` 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(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\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\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 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 using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\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 function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc3d946432c0ddbb1f846a0d3985be71299df331b91d06732152117f62f0be2b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // 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\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return 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 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 up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a / b + (a % b == 0 ? 0 : 1);\\n }\\n}\\n\",\"keccak256\":\"0xc995bddbca1ae19788db9f8b61e63385edd3fddf89693b612d5abd1a275974d2\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SignedMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/SignedMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard signed math utilities missing in the Solidity language.\\n */\\nlibrary SignedMath {\\n /**\\n * @dev Returns the largest of two signed numbers.\\n */\\n function max(int256 a, int256 b) internal pure returns (int256) {\\n return 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 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 // must be unchecked in order to support `n = type(int256).min`\\n return uint256(n >= 0 ? n : -n);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb3ebde1c8d27576db912d87c3560dab14adfb9cd001be95890ec4ba035e652e7\",\"license\":\"MIT\"},\"contracts/collateral/Collateral.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"@equilibria/root/control/unstructured/UInitializable.sol\\\";\\nimport \\\"@equilibria/root/control/unstructured/UReentrancyGuard.sol\\\";\\nimport \\\"../interfaces/ICollateral.sol\\\";\\nimport \\\"./types/OptimisticLedger.sol\\\";\\nimport \\\"../controller/UControllerProvider.sol\\\";\\n\\n/**\\n * @title Collateral\\n * @notice Manages logic and state for all collateral accounts in the protocol.\\n */\\ncontract Collateral is ICollateral, UInitializable, UControllerProvider, UReentrancyGuard {\\n /// @dev ERC20 stablecoin for collateral\\n Token18 public immutable token;\\n\\n /// @dev Per product collateral state\\n mapping(IProduct => OptimisticLedger) private _products;\\n\\n /// @dev Protocol and product fees collected, but not yet claimed\\n mapping(address => UFixed18) public fees;\\n\\n /**\\n * @notice Initializes the immutable contract state\\n * @dev Called at implementation instantiate and constant for that implementation.\\n * @param token_ Collateral ERC20 stablecoin address\\n */\\n constructor(Token18 token_) {\\n token = token_;\\n }\\n\\n /**\\n * @notice Initializes the contract state\\n * @dev Must be called atomically as part of the upgradeable proxy deployment to\\n * avoid front-running\\n * @param controller_ Factory contract address\\n */\\n function initialize(IController controller_) external initializer(1) {\\n __UControllerProvider__initialize(controller_);\\n __UReentrancyGuard__initialize();\\n }\\n\\n /**\\n * @notice Deposits `amount` collateral from `msg.sender` to `account`'s `product`\\n * account\\n * @param account Account to deposit the collateral for\\n * @param product Product to credit the collateral to\\n * @param amount Amount of collateral to deposit\\n */\\n function depositTo(address account, IProduct product, UFixed18 amount)\\n external\\n nonReentrant\\n notPaused\\n notZeroAddress(account)\\n isProduct(product)\\n collateralInvariant(account, product)\\n {\\n _products[product].creditAccount(account, amount);\\n token.pull(msg.sender, amount);\\n\\n emit Deposit(account, product, amount);\\n }\\n\\n /**\\n * @notice Withdraws `amount` collateral from `msg.sender`'s `product` account\\n * and sends it to `account`\\n * @param account Account to withdraw the collateral to\\n * @param product Product to withdraw the collateral from\\n * @param amount Amount of collateral to withdraw\\n */\\n function withdrawTo(address account, IProduct product, UFixed18 amount)\\n external\\n nonReentrant\\n notPaused\\n notZeroAddress(account)\\n isProduct(product)\\n settleForAccount(msg.sender, product)\\n collateralInvariant(msg.sender, product)\\n maintenanceInvariant(msg.sender, product)\\n {\\n amount = amount.eq(UFixed18Lib.MAX) ? collateral(msg.sender, product) : amount;\\n _products[product].debitAccount(msg.sender, amount);\\n token.push(account, amount);\\n\\n emit Withdrawal(msg.sender, product, amount);\\n }\\n\\n /**\\n * @notice Liquidates `account`'s `product` collateral account\\n * @dev Account must be under-collateralized, fee returned immediately to `msg.sender`\\n * @param account Account to liquidate\\n * @param product Product to liquidate for\\n */\\n function liquidate(address account, IProduct product)\\n external\\n nonReentrant\\n notPaused\\n isProduct(product)\\n settleForAccount(account, product)\\n {\\n UFixed18 totalMaintenance = product.maintenance(account);\\n UFixed18 totalCollateral = collateral(account, product);\\n\\n if (!totalMaintenance.gt(totalCollateral))\\n revert CollateralCantLiquidate(totalMaintenance, totalCollateral);\\n\\n product.closeAll(account);\\n\\n // claim fee\\n UFixed18 liquidationFee = controller().liquidationFee();\\n UFixed18 fee = UFixed18Lib.min(totalCollateral, totalMaintenance.mul(liquidationFee));\\n\\n _products[product].debitAccount(account, fee);\\n token.push(msg.sender, fee);\\n\\n emit Liquidation(account, product, msg.sender, fee);\\n }\\n\\n /**\\n * @notice Credits `amount` to `account`'s collateral account\\n * @dev Callable only by the corresponding product as part of the settlement flywheel.\\n * Moves collateral within a product, any collateral leaving the product due to\\n * fees has already been accounted for in the settleProduct flywheel.\\n * Debits in excess of the account balance get recorded as shortfall, and can be\\n * resolved by the product owner as needed.\\n * @param account Account to credit\\n * @param amount Amount to credit the account (can be negative)\\n */\\n function settleAccount(address account, Fixed18 amount) external onlyProduct {\\n IProduct product = IProduct(msg.sender);\\n\\n UFixed18 newShortfall = _products[product].settleAccount(account, amount);\\n\\n emit AccountSettle(product, account, amount, newShortfall);\\n }\\n\\n /**\\n * @notice Debits `amount` from product's total collateral account\\n * @dev Callable only by the corresponding product as part of the settlement flywheel\\n * Removes collateral from the product as fees.\\n * @param amount Amount to debit from the account\\n */\\n function settleProduct(UFixed18 amount) external onlyProduct {\\n (IProduct product, IController controller) = (IProduct(msg.sender), controller());\\n\\n address protocolTreasury = controller.treasury();\\n address productTreasury = controller.treasury(product);\\n\\n UFixed18 protocolFee = amount.mul(controller.protocolFee());\\n UFixed18 productFee = amount.sub(protocolFee);\\n\\n _products[product].debit(amount);\\n fees[protocolTreasury] = fees[protocolTreasury].add(protocolFee);\\n fees[productTreasury] = fees[productTreasury].add(productFee);\\n\\n emit ProductSettle(product, protocolFee, productFee);\\n }\\n\\n /**\\n * @notice Returns the balance of `account`'s `product` collateral account\\n * @param account Account to return for\\n * @param product Product to return for\\n * @return The balance of the collateral account\\n */\\n function collateral(address account, IProduct product) public view returns (UFixed18) {\\n return _products[product].balances[account];\\n }\\n\\n /**\\n * @notice Returns the total balance of `product`'s collateral\\n * @param product Product to return for\\n * @return The total balance of collateral in the product\\n */\\n function collateral(IProduct product) external view returns (UFixed18) {\\n return _products[product].total;\\n }\\n\\n /**\\n * @notice Returns the current shortfall of `product`'s collateral\\n * @param product Product to return for\\n * @return The current shortfall of the product\\n */\\n function shortfall(IProduct product) external view returns (UFixed18) {\\n return _products[product].shortfall;\\n }\\n\\n /**\\n * @notice Returns whether `account`'s `product` collateral account can be liquidated\\n * @param account Account to return for\\n * @param product Product to return for\\n * @return Whether the account can be liquidated\\n */\\n function liquidatable(address account, IProduct product) external view returns (bool) {\\n return product.maintenance(account).gt(collateral(account, product));\\n }\\n\\n /**\\n * @notice Returns whether `account`'s `product` collateral account can be liquidated\\n * after the next oracle version settlement\\n * @dev Takes into account the current pre-position on the account\\n * @param account Account to return for\\n * @param product Product to return for\\n * @return Whether the account can be liquidated\\n */\\n function liquidatableNext(address account, IProduct product) external view returns (bool) {\\n return product.maintenanceNext(account).gt(collateral(account, product));\\n }\\n\\n /**\\n * @notice Injects additional collateral into a product to resolve shortfall\\n * @dev Shortfall is a measure of settled insolvency in the market\\n * This hook can be used by the product owner or an insurance fund to re-capitalize an insolvent market\\n * @param product Product to resolve shortfall for\\n * @param amount Amount of shortfall to resolve\\n */\\n function resolveShortfall(IProduct product, UFixed18 amount) external isProduct(product) notPaused {\\n _products[product].resolve(amount);\\n token.pull(msg.sender, amount);\\n\\n emit ShortfallResolution(product, amount);\\n }\\n\\n /**\\n * @notice Claims all of `msg.sender`'s fees\\n */\\n function claimFee() external notPaused {\\n UFixed18 amount = fees[msg.sender];\\n\\n fees[msg.sender] = UFixed18Lib.ZERO;\\n token.push(msg.sender, amount);\\n\\n emit FeeClaim(msg.sender, amount);\\n }\\n\\n /// @dev Ensure that the address is non-zero\\n modifier notZeroAddress(address account) {\\n if (account == address(0)) revert CollateralZeroAddressError();\\n\\n _;\\n }\\n\\n /// @dev Ensure that the user has sufficient margin for both current and next maintenance\\n modifier maintenanceInvariant(address account, IProduct product) {\\n _;\\n\\n UFixed18 maintenance = product.maintenance(account);\\n UFixed18 maintenanceNext = product.maintenanceNext(account);\\n\\n if (UFixed18Lib.max(maintenance, maintenanceNext).gt(collateral(account, product)))\\n revert CollateralInsufficientCollateralError();\\n }\\n\\n /// @dev Ensure that the account is either empty or above the collateral minimum\\n modifier collateralInvariant(address account, IProduct product) {\\n _;\\n\\n UFixed18 accountCollateral = collateral(account, product);\\n if (!accountCollateral.isZero() && accountCollateral.lt(controller().minCollateral()))\\n revert CollateralUnderLimitError();\\n }\\n\\n /// @dev Helper to fully settle an account's state\\n modifier settleForAccount(address account, IProduct product) {\\n product.settleAccount(account);\\n\\n _;\\n }\\n}\\n\",\"keccak256\":\"0x0edef6aaba1aad7829da49892c5549d0ff91d2f085ca7b438f0488ebab00bf83\",\"license\":\"Apache-2.0\"},\"contracts/collateral/types/OptimisticLedger.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\n\\n/// @dev OptimisticLedger type\\nstruct OptimisticLedger {\\n /// @dev Individual account collateral balances\\n mapping(address => UFixed18) balances;\\n\\n /// @dev Total ledger collateral balance\\n UFixed18 total;\\n\\n /// @dev Total ledger collateral shortfall\\n UFixed18 shortfall;\\n}\\nusing OptimisticLedgerLib for OptimisticLedger global;\\n\\n/**\\n * @title OptimisticLedgerLib\\n * @notice Library that manages a global vs account ledger where the global ledger is settled separately,\\n * and ahead of, the user-level accounts.\\n * @dev Ensures that no more collateral leaves the ledger than goes it, while allowing user-level accounts\\n * to settle as a follow up step. Overdrafts on the user-level are accounted as \\\"shortall\\\". Shortfall\\n * in the system is the quantity of insolvency that can be optionally resolved by the ledger owner.\\n * Until the shortfall is resolved, collateral may be withdrawn from the ledger on a FCFS basis. However\\n * once the ledger total has been depleted, users will not be able to withdraw even if they have non-zero\\n * user level balances until the shortfall is resolved, recapitalizing the ledger.\\n */\\nlibrary OptimisticLedgerLib {\\n /**\\n * @notice Credits `account` with `amount` collateral\\n * @param self The struct to operate on\\n * @param account Account to credit collateral to\\n * @param amount Amount of collateral to credit\\n */\\n function creditAccount(OptimisticLedger storage self, address account, UFixed18 amount) internal {\\n self.balances[account] = self.balances[account].add(amount);\\n self.total = self.total.add(amount);\\n }\\n\\n /**\\n * @notice Debits `account` `amount` collateral\\n * @param self The struct to operate on\\n * @param account Account to debit collateral from\\n * @param amount Amount of collateral to debit\\n */\\n function debitAccount(OptimisticLedger storage self, address account, UFixed18 amount) internal {\\n self.balances[account] = self.balances[account].sub(amount);\\n self.total = self.total.sub(amount);\\n }\\n\\n /**\\n * @notice Credits `account` with `amount` collateral\\n * @dev Funds come from inside the product, not totals are updated\\n * Shortfall is created if more funds are debited from an account than exist\\n * @param self The struct to operate on\\n * @param account Account to credit collateral to\\n * @param amount Amount of collateral to credit\\n * @return newShortfall Any new shortfall incurred during this settlement\\n */\\n function settleAccount(OptimisticLedger storage self, address account, Fixed18 amount)\\n internal returns (UFixed18 newShortfall) {\\n Fixed18 newBalance = Fixed18Lib.from(self.balances[account]).add(amount);\\n\\n if (newBalance.sign() == -1) {\\n newShortfall = newBalance.abs();\\n newBalance = Fixed18Lib.ZERO;\\n }\\n\\n self.balances[account] = newBalance.abs();\\n self.shortfall = self.shortfall.add(newShortfall);\\n }\\n\\n /**\\n * @notice Debits ledger globally `amount` collateral\\n * @dev Removes balance from total that is accounted for elsewhere (e.g. product-level accumulators)\\n * @param self The struct to operate on\\n * @param amount Amount of collateral to debit\\n */\\n function debit(OptimisticLedger storage self, UFixed18 amount) internal {\\n self.total = self.total.sub(amount);\\n }\\n\\n /**\\n * @notice Reduces the amount of collateral shortfall in the ledger\\n * @param self The struct to operate on\\n * @param amount Amount of shortfall to resolve\\n */\\n function resolve(OptimisticLedger storage self, UFixed18 amount) internal {\\n self.shortfall = self.shortfall.sub(amount);\\n self.total = self.total.add(amount);\\n }\\n}\\n\",\"keccak256\":\"0xb0cd6ded1435a956c2f3f8d9f9dd7fa21da1f3e300d4111f8575c51eba41d03d\",\"license\":\"Apache-2.0\"},\"contracts/controller/UControllerProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"@equilibria/root/control/unstructured/UInitializable.sol\\\";\\nimport \\\"@equilibria/root/storage/UStorage.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/Address.sol\\\";\\nimport \\\"../interfaces/IController.sol\\\";\\nimport \\\"../interfaces/IProduct.sol\\\";\\n\\n/**\\n * @title UControllerProvider\\n * @notice Mix-in that manages a controller pointer and associated permissioning modifiers.\\n * @dev Uses unstructured storage so that it is safe to mix-in to upgreadable contracts without modifying\\n * their storage layout.\\n */\\nabstract contract UControllerProvider is UInitializable {\\n error NotOwnerError(uint256 coordinatorId);\\n error NotProductError(IProduct product);\\n error NotCollateralError();\\n error PausedError();\\n error InvalidControllerError();\\n\\n /// @dev The controller contract address\\n AddressStorage private constant _controller = AddressStorage.wrap(keccak256(\\\"equilibria.perennial.UControllerProvider.controller\\\"));\\n function controller() public view returns (IController) { return IController(_controller.read()); }\\n\\n /**\\n * @notice Initializes the contract state\\n * @param controller_ Protocol Controller contract address\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function __UControllerProvider__initialize(IController controller_) internal onlyInitializer {\\n if (!Address.isContract(address(controller_))) revert InvalidControllerError();\\n _controller.store(address(controller_));\\n }\\n\\n /// @dev Only allow a valid product contract to call\\n modifier onlyProduct {\\n if (!controller().isProduct(IProduct(msg.sender))) revert NotProductError(IProduct(msg.sender));\\n\\n _;\\n }\\n\\n /// @dev Verify that `product` is a valid product contract\\n modifier isProduct(IProduct product) {\\n if (!controller().isProduct(product)) revert NotProductError(product);\\n\\n _;\\n }\\n\\n /// @dev Only allow the Collateral contract to call\\n modifier onlyCollateral {\\n if (msg.sender != address(controller().collateral())) revert NotCollateralError();\\n\\n _;\\n }\\n\\n /// @dev Only allow the coordinator owner to call\\n modifier onlyOwner(uint256 coordinatorId) {\\n if (msg.sender != controller().owner(coordinatorId)) revert NotOwnerError(coordinatorId);\\n\\n _;\\n }\\n\\n /// @dev Only allow if the protocol is currently unpaused\\n modifier notPaused() {\\n if (controller().paused()) revert PausedError();\\n\\n _;\\n }\\n}\\n\",\"keccak256\":\"0x10c6f4ae1a3a511aad470e40c61de5b2171f4151e2dea000acd2ffbd26dcbc2a\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/ICollateral.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"./IController.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\n\\ninterface ICollateral {\\n event Deposit(address indexed user, IProduct indexed product, UFixed18 amount);\\n event Withdrawal(address indexed user, IProduct indexed product, UFixed18 amount);\\n event AccountSettle(IProduct indexed product, address indexed account, Fixed18 amount, UFixed18 newShortfall);\\n event ProductSettle(IProduct indexed product, UFixed18 protocolFee, UFixed18 productFee);\\n event Liquidation(address indexed user, IProduct indexed product, address liquidator, UFixed18 fee);\\n event ShortfallResolution(IProduct indexed product, UFixed18 amount);\\n event FeeClaim(address indexed account, UFixed18 amount);\\n\\n error CollateralCantLiquidate(UFixed18 totalMaintenance, UFixed18 totalCollateral);\\n error CollateralInsufficientCollateralError();\\n error CollateralUnderLimitError();\\n error CollateralZeroAddressError();\\n\\n function token() external view returns (Token18);\\n function fees(address account) external view returns (UFixed18);\\n function initialize(IController controller_) external;\\n function depositTo(address account, IProduct product, UFixed18 amount) external;\\n function withdrawTo(address account, IProduct product, UFixed18 amount) external;\\n function liquidate(address account, IProduct product) external;\\n function settleAccount(address account, Fixed18 amount) external;\\n function settleProduct(UFixed18 amount) external;\\n function collateral(address account, IProduct product) external view returns (UFixed18);\\n function collateral(IProduct product) external view returns (UFixed18);\\n function shortfall(IProduct product) external view returns (UFixed18);\\n function liquidatable(address account, IProduct product) external view returns (bool);\\n function liquidatableNext(address account, IProduct product) external view returns (bool);\\n function resolveShortfall(IProduct product, UFixed18 amount) external;\\n function claimFee() external;\\n}\\n\",\"keccak256\":\"0xa5e7fdda92702f748e6eb8701e522450035a98a05e5fc1cf66d51c52e397d914\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IContractPayoffProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\n\\ninterface IContractPayoffProvider {\\n function payoff(Fixed18 price) external view returns (Fixed18 payoff);\\n}\\n\",\"keccak256\":\"0xd73df106d032e976fd959ee6713240e36f54277ce5f215eaec8d5a2c6720a86b\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IController.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\\\";\\nimport \\\"./ICollateral.sol\\\";\\nimport \\\"./IIncentivizer.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\n\\ninterface IController {\\n /// @dev Coordinator of a one or many products\\n struct Coordinator {\\n /// @dev Pending owner of the product, can accept ownership\\n address pendingOwner;\\n\\n /// @dev Owner of the product, allowed to update select parameters\\n address owner;\\n\\n /// @dev Treasury of the product, collects fees\\n address treasury;\\n }\\n\\n event CollateralUpdated(ICollateral newCollateral);\\n event IncentivizerUpdated(IIncentivizer newIncentivizer);\\n event ProductBeaconUpdated(IBeacon newProductBeacon);\\n event ProtocolFeeUpdated(UFixed18 newProtocolFee);\\n event MinFundingFeeUpdated(UFixed18 newMinFundingFee);\\n event LiquidationFeeUpdated(UFixed18 newLiquidationFee);\\n event IncentivizationFeeUpdated(UFixed18 newIncentivizationFee);\\n event MinCollateralUpdated(UFixed18 newMinCollateral);\\n event ProgramsPerProductUpdated(uint256 newProgramsPerProduct);\\n event PauserUpdated(address newPauser);\\n event PausedUpdated(bool newPaused);\\n event CoordinatorPendingOwnerUpdated(uint256 indexed coordinatorId, address newPendingOwner);\\n event CoordinatorOwnerUpdated(uint256 indexed coordinatorId, address newOwner);\\n event CoordinatorTreasuryUpdated(uint256 indexed coordinatorId, address newTreasury);\\n event CoordinatorCreated(uint256 indexed coordinatorId, address owner);\\n event ProductCreated(IProduct indexed product, IProduct.ProductInfo productInfo);\\n\\n error ControllerNoZeroCoordinatorError();\\n error ControllerNotPauserError();\\n error ControllerNotOwnerError(uint256 controllerId);\\n error ControllerNotPendingOwnerError(uint256 controllerId);\\n error ControllerInvalidProtocolFeeError();\\n error ControllerInvalidMinFundingFeeError();\\n error ControllerInvalidLiquidationFeeError();\\n error ControllerInvalidIncentivizationFeeError();\\n error ControllerNotContractAddressError();\\n\\n function collateral() external view returns (ICollateral);\\n function incentivizer() external view returns (IIncentivizer);\\n function productBeacon() external view returns (IBeacon);\\n function coordinators(uint256 collateralId) external view returns (Coordinator memory);\\n function coordinatorFor(IProduct product) external view returns (uint256);\\n function protocolFee() external view returns (UFixed18);\\n function minFundingFee() external view returns (UFixed18);\\n function liquidationFee() external view returns (UFixed18);\\n function incentivizationFee() external view returns (UFixed18);\\n function minCollateral() external view returns (UFixed18);\\n function programsPerProduct() external view returns (uint256);\\n function pauser() external view returns (address);\\n function paused() external view returns (bool);\\n function initialize(ICollateral collateral_, IIncentivizer incentivizer_, IBeacon productBeacon_) external;\\n function createCoordinator() external returns (uint256);\\n function updateCoordinatorPendingOwner(uint256 coordinatorId, address newPendingOwner) external;\\n function acceptCoordinatorOwner(uint256 coordinatorId) external;\\n function updateCoordinatorTreasury(uint256 coordinatorId, address newTreasury) external;\\n function createProduct(uint256 coordinatorId, IProduct.ProductInfo calldata productInfo) external returns (IProduct);\\n function updateCollateral(ICollateral newCollateral) external;\\n function updateIncentivizer(IIncentivizer newIncentivizer) external;\\n function updateProductBeacon(IBeacon newProductBeacon) external;\\n function updateProtocolFee(UFixed18 newProtocolFee) external;\\n function updateMinFundingFee(UFixed18 newMinFundingFee) external;\\n function updateLiquidationFee(UFixed18 newLiquidationFee) external;\\n function updateIncentivizationFee(UFixed18 newIncentivizationFee) external;\\n function updateMinCollateral(UFixed18 newMinCollateral) external;\\n function updateProgramsPerProduct(uint256 newProductsPerProduct) external;\\n function updatePauser(address newPauser) external;\\n function updatePaused(bool newPaused) external;\\n function isProduct(IProduct product) external view returns (bool);\\n function owner() external view returns (address);\\n function owner(uint256 coordinatorId) external view returns (address);\\n function owner(IProduct product) external view returns (address);\\n function treasury() external view returns (address);\\n function treasury(uint256 coordinatorId) external view returns (address);\\n function treasury(IProduct product) external view returns (address);\\n}\\n\",\"keccak256\":\"0xaabd3740f2265499eea7aad9bd94f9892f53241e5dccce9a50c0e43ed2a6a7cc\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IIncentivizer.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./types/ProgramInfo.sol\\\";\\nimport \\\"./IController.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\n\\ninterface IIncentivizer {\\n event ProgramCreated(IProduct indexed product, uint256 indexed programId, ProgramInfo programInfo, UFixed18 programFeeAmount);\\n event ProgramStarted(IProduct indexed product, uint256 indexed programId, uint256 version);\\n event ProgramComplete(IProduct indexed product, uint256 indexed programId, uint256 version);\\n event Claim(IProduct indexed product, address indexed account, uint256 indexed programId, UFixed18 amount);\\n event FeeClaim(Token18 indexed token, UFixed18 amount);\\n\\n error IncentivizerNotAllowedError(IProduct product);\\n error IncentivizerTooManyProgramsError();\\n error IncentivizerNotProgramOwnerError(IProduct product, uint256 programId);\\n error IncentivizerInvalidProgramError(IProduct product, uint256 programId);\\n error IncentivizerBatchClaimArgumentMismatchError();\\n\\n function programInfos(IProduct product, uint256 programId) external view returns (ProgramInfo memory);\\n function fees(Token18 token) external view returns (UFixed18);\\n function initialize(IController controller_) external;\\n function create(IProduct product, ProgramInfo calldata info) external returns (uint256);\\n function complete(IProduct product, uint256 programId) external;\\n function sync(IOracleProvider.OracleVersion memory currentOracleVersion) external;\\n function syncAccount(address account, IOracleProvider.OracleVersion memory currentOracleVersion) external;\\n function claim(IProduct product, uint256[] calldata programIds) external;\\n function claim(IProduct[] calldata products, uint256[][] calldata programIds) external;\\n function claimFee(Token18[] calldata tokens) external;\\n function active(IProduct product) external view returns (uint256);\\n function count(IProduct product) external view returns (uint256);\\n function unclaimed(IProduct product, address account, uint256 programId) external view returns (UFixed18);\\n function available(IProduct product, uint256 programId) external view returns (UFixed18);\\n function versionStarted(IProduct product, uint256 programId) external view returns (uint256);\\n function versionComplete(IProduct product, uint256 programId) external view returns (uint256);\\n function owner(IProduct product, uint256 programId) external view returns (address);\\n function treasury(IProduct product, uint256 programId) external view returns (address);\\n}\\n\",\"keccak256\":\"0x2f95de90dbb3ad35dbfef304f765a622bffff9229868d2898eca8d49c78e8c2c\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IParamProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\\\";\\n\\ninterface IParamProvider {\\n event MaintenanceUpdated(UFixed18 newMaintenance);\\n event FundingFeeUpdated(UFixed18 newFundingFee);\\n event MakerFeeUpdated(UFixed18 newMakerFee);\\n event TakerFeeUpdated(UFixed18 newTakerFee);\\n event MakerLimitUpdated(UFixed18 newMakerLimit);\\n event JumpRateUtilizationCurveUpdated(\\n Fixed18 minRate,\\n Fixed18 maxRate,\\n Fixed18 targetRate,\\n UFixed18 targetUtilization\\n );\\n\\n error ParamProviderInvalidMakerFee();\\n error ParamProviderInvalidTakerFee();\\n error ParamProviderInvalidFundingFee();\\n \\n function maintenance() external view returns (UFixed18);\\n function updateMaintenance(UFixed18 newMaintenance) external;\\n function fundingFee() external view returns (UFixed18);\\n function updateFundingFee(UFixed18 newFundingFee) external;\\n function makerFee() external view returns (UFixed18);\\n function updateMakerFee(UFixed18 newMakerFee) external;\\n function takerFee() external view returns (UFixed18);\\n function updateTakerFee(UFixed18 newTakerFee) external;\\n function makerLimit() external view returns (UFixed18);\\n function updateMakerLimit(UFixed18 newMakerLimit) external;\\n function utilizationCurve() external view returns (JumpRateUtilizationCurve memory);\\n function updateUtilizationCurve(JumpRateUtilizationCurve memory newUtilizationCurve) external;\\n}\\n\",\"keccak256\":\"0x2e2d40d0cf55f167118867e41f740b9b40614d05da50fc9bc33a8cede3eaf03e\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IPayoffProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\n\\ninterface IPayoffProvider {\\n error PayoffProviderInvalidOracle();\\n error PayoffProviderInvalidPayoffDefinitionError();\\n\\n function oracle() external view returns (IOracleProvider);\\n function payoffDefinition() external view returns (PayoffDefinition memory);\\n function currentVersion() external view returns (IOracleProvider.OracleVersion memory);\\n function atVersion(uint256 oracleVersion) external view returns (IOracleProvider.OracleVersion memory);\\n}\\n\",\"keccak256\":\"0xb83d80d624aa9431763f80ecb4bf0214803e25334a7419d954f929e5d0ee7467\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IProduct.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\\\";\\nimport \\\"./IPayoffProvider.sol\\\";\\nimport \\\"./IParamProvider.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\nimport \\\"./types/Position.sol\\\";\\nimport \\\"./types/PrePosition.sol\\\";\\nimport \\\"./types/Accumulator.sol\\\";\\n\\ninterface IProduct is IPayoffProvider, IParamProvider {\\n /// @dev Product Creation parameters\\n struct ProductInfo {\\n /// @dev name of the product\\n string name;\\n\\n /// @dev symbol of the product\\n string symbol;\\n\\n /// @dev product payoff definition\\n PayoffDefinition payoffDefinition;\\n\\n /// @dev oracle address\\n IOracleProvider oracle;\\n\\n /// @dev product maintenance ratio\\n UFixed18 maintenance;\\n\\n /// @dev product funding fee\\n UFixed18 fundingFee;\\n\\n /// @dev product maker fee\\n UFixed18 makerFee;\\n\\n /// @dev product taker fee\\n UFixed18 takerFee;\\n\\n /// @dev product maker limit\\n UFixed18 makerLimit;\\n\\n /// @dev utulization curve definition\\n JumpRateUtilizationCurve utilizationCurve;\\n }\\n\\n event Settle(uint256 preVersion, uint256 toVersion);\\n event AccountSettle(address indexed account, uint256 preVersion, uint256 toVersion);\\n event MakeOpened(address indexed account, uint256 version, UFixed18 amount);\\n event TakeOpened(address indexed account, uint256 version, UFixed18 amount);\\n event MakeClosed(address indexed account, uint256 version, UFixed18 amount);\\n event TakeClosed(address indexed account, uint256 version, UFixed18 amount);\\n event ClosedUpdated(bool indexed newClosed, uint256 version);\\n\\n error ProductInsufficientLiquidityError(UFixed18 socializationFactor);\\n error ProductDoubleSidedError();\\n error ProductOverClosedError();\\n error ProductInsufficientCollateralError();\\n error ProductInLiquidationError();\\n error ProductMakerOverLimitError();\\n error ProductOracleBootstrappingError();\\n error ProductNotOwnerError();\\n error ProductInvalidOracle();\\n error ProductClosedError();\\n\\n function name() external view returns (string memory);\\n function symbol() external view returns (string memory);\\n function initialize(ProductInfo calldata productInfo_) external;\\n function settle() external;\\n function settleAccount(address account) external;\\n function openTake(UFixed18 amount) external;\\n function closeTake(UFixed18 amount) external;\\n function openMake(UFixed18 amount) external;\\n function closeMake(UFixed18 amount) external;\\n function closeAll(address account) external;\\n function maintenance(address account) external view returns (UFixed18);\\n function maintenanceNext(address account) external view returns (UFixed18);\\n function isClosed(address account) external view returns (bool);\\n function isLiquidating(address account) external view returns (bool);\\n function position(address account) external view returns (Position memory);\\n function pre(address account) external view returns (PrePosition memory);\\n function latestVersion() external view returns (uint256);\\n function positionAtVersion(uint256 oracleVersion) external view returns (Position memory);\\n function pre() external view returns (PrePosition memory);\\n function valueAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\\n function shareAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\\n function latestVersion(address account) external view returns (uint256);\\n function rate(Position memory position) external view returns (Fixed18);\\n function closed() external view returns (bool);\\n function updateClosed(bool newClosed) external;\\n}\\n\",\"keccak256\":\"0xe1e80b818eadf4cdb070362e40c7cf3863b50c4f944816af27848e319f587241\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/Accumulator.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"./PackedAccumulator.sol\\\";\\n\\n/// @dev Accumulator type\\nstruct Accumulator {\\n /// @dev maker accumulator per share\\n Fixed18 maker;\\n /// @dev taker accumulator per share\\n Fixed18 taker;\\n}\\nusing AccumulatorLib for Accumulator global;\\n\\n/**\\n * @title AccountAccumulatorLib\\n * @notice Library that surfaces math operations for the Accumulator type.\\n * @dev Accumulators track the cumulative change in position value over time for the maker and taker positions\\n * respectively. Account-level accumulators can then use two of these values `a` and `a'` to compute the\\n * change in position value since last sync. This change in value is then used to compute P&L and fees.\\n */\\nlibrary AccumulatorLib {\\n /**\\n * @notice Creates a packed accumulator from an accumulator\\n * @param self an accumulator\\n * @return New packed accumulator\\n */\\n function pack(Accumulator memory self) internal pure returns (PackedAccumulator memory) {\\n return PackedAccumulator({maker: self.maker.pack(), taker: self.taker.pack()});\\n }\\n\\n /**\\n * @notice Adds two accumulators together\\n * @param a The first accumulator to sum\\n * @param b The second accumulator to sum\\n * @return The resulting summed accumulator\\n */\\n function add(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\\n }\\n\\n /**\\n * @notice Subtracts accumulator `b` from `a`\\n * @param a The accumulator to subtract from\\n * @param b The accumulator to subtract\\n * @return The resulting subtracted accumulator\\n */\\n function sub(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\\n }\\n\\n /**\\n * @notice Multiplies two accumulators together\\n * @param a The first accumulator to multiply\\n * @param b The second accumulator to multiply\\n * @return The resulting multiplied accumulator\\n */\\n function mul(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.mul(b.maker), taker: a.taker.mul(b.taker)});\\n }\\n\\n /**\\n * @notice Sums the maker and taker together from a single accumulator\\n * @param self The struct to operate on\\n * @return The sum of its maker and taker\\n */\\n function sum(Accumulator memory self) internal pure returns (Fixed18) {\\n return self.maker.add(self.taker);\\n }\\n}\\n\",\"keccak256\":\"0x7ccd0a72aa593cefb9f4337cf312799f357b82fcb3f0379de0dc503d1cb7e387\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PackedAccumulator.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/PackedFixed18.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\n\\n/// @dev PackedAccumulator type\\nstruct PackedAccumulator {\\n /// @dev maker accumulator per share\\n PackedFixed18 maker;\\n /// @dev taker accumulator per share\\n PackedFixed18 taker;\\n}\\nusing PackedAccumulatorLib for PackedAccumulator global;\\n\\n/**\\n * @title PackedAccumulatorLib\\n * @dev A packed version of the Accumulator which takes up a single storage slot using `PackedFixed18` values.\\n * @notice Library for the packed Accumulator type.\\n */\\nlibrary PackedAccumulatorLib {\\n /**\\n * @notice Creates an accumulator from a packed accumulator\\n * @param self packed accumulator\\n * @return New accumulator\\n */\\n function unpack(PackedAccumulator memory self) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: self.maker.unpack(), taker: self.taker.unpack()});\\n }\\n}\\n\",\"keccak256\":\"0xd83f2822d4f6c818087a232b54007730992c34ff77377fc307a282f886e7cf65\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PackedPosition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/PackedUFixed18.sol\\\";\\nimport \\\"./Position.sol\\\";\\n\\n/// @dev PackedPosition type\\nstruct PackedPosition {\\n /// @dev Quantity of the maker position\\n PackedUFixed18 maker;\\n /// @dev Quantity of the taker position\\n PackedUFixed18 taker;\\n}\\nusing PackedPositionLib for PackedPosition global;\\n\\n/**\\n * @title PackedPositionLib\\n * @dev A packed version of the Position which takes up a single storage slot using `PackedFixed18` values.\\n * @notice Library for the packed Position type.\\n */\\nlibrary PackedPositionLib {\\n /**\\n * @notice Creates an position from a packed position\\n * @param self packed position\\n * @return New position\\n */\\n function unpack(PackedPosition memory self) internal pure returns (Position memory) {\\n return Position({maker: self.maker.unpack(), taker: self.taker.unpack()});\\n }\\n}\\n\",\"keccak256\":\"0x04968e6794f6244cb3415cea111d640273a81faea957872988d0cb580f45df1e\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PayoffDefinition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"@openzeppelin/contracts/utils/Address.sol\\\";\\nimport \\\"../../interfaces/IContractPayoffProvider.sol\\\";\\n\\n/// @dev PayoffDefinition tyoe\\nstruct PayoffDefinition {\\n PayoffDefinitionLib.PayoffType payoffType;\\n PayoffDefinitionLib.PayoffDirection payoffDirection;\\n bytes30 data;\\n}\\nusing PayoffDefinitionLib for PayoffDefinition global;\\ntype PayoffDefinitionStorage is bytes32;\\nusing PayoffDefinitionStorageLib for PayoffDefinitionStorage global;\\n\\n/**\\n * @title PayoffDefinitionLib\\n * @dev Library that surfaces logic for PayoffDefinition type functionality\\n * @notice Library for the PayoffDefinition type. Performs validity and price transformation\\n based on the payoff definition type.\\n */\\nlibrary PayoffDefinitionLib {\\n using Address for address;\\n\\n error PayoffDefinitionUnsupportedTransform(PayoffType payoffType, PayoffDirection payoffDirection);\\n error PayoffDefinitionNotContract(PayoffType payoffType, bytes30 data);\\n\\n /// @dev Payoff function type enum\\n enum PayoffType { PASSTHROUGH, CONTRACT }\\n enum PayoffDirection { LONG, SHORT }\\n\\n /**\\n * @notice Checks validity of the payoff definition\\n * @param self a payoff definition\\n * @return Whether the payoff definition is valid for it's given type\\n */\\n function valid(PayoffDefinition memory self) internal view returns (bool) {\\n if (self.payoffType == PayoffType.CONTRACT) return address(_providerContract(self)).isContract();\\n\\n // All other payoff types should have no data\\n return uint(bytes32(self.data)) == 0;\\n }\\n\\n /**\\n * @notice Transforms a price based on the payoff definition\\n * @param self a payoff definition\\n * @param price raw oracle price\\n * @return Price transformed by the payoff definition function\\n */\\n function transform(\\n PayoffDefinition memory self,\\n Fixed18 price\\n ) internal view returns (Fixed18) {\\n PayoffType payoffType = self.payoffType;\\n PayoffDirection payoffDirection = self.payoffDirection;\\n Fixed18 transformedPrice;\\n\\n // First get the price depending on the type\\n if (payoffType == PayoffType.PASSTHROUGH) transformedPrice = price;\\n else if (payoffType == PayoffType.CONTRACT) transformedPrice = _payoffFromContract(self, price);\\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\\n\\n // Then transform it depending on the direction flag\\n if (self.payoffDirection == PayoffDirection.LONG) return transformedPrice;\\n else if (self.payoffDirection == PayoffDirection.SHORT) return transformedPrice.mul(Fixed18Lib.NEG_ONE);\\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\\n }\\n\\n /**\\n * @notice Parses the data field into an address\\n * @dev Reverts if payoffType is not CONTRACT\\n * @param self a payoff definition\\n * @return IContractPayoffProvider address\\n */\\n function _providerContract(\\n PayoffDefinition memory self\\n ) private pure returns (IContractPayoffProvider) {\\n if (self.payoffType != PayoffType.CONTRACT) revert PayoffDefinitionNotContract(self.payoffType, self.data);\\n // Shift to pull the last 20 bytes, then cast to an address\\n return IContractPayoffProvider(address(bytes20(self.data << 80)));\\n }\\n\\n /**\\n * @notice Performs a price transformation by calling the underlying payoff contract\\n * @param self a payoff definition\\n * @param price raw oracle price\\n * @return Price transformed by the payoff definition function on the contract\\n */\\n function _payoffFromContract(\\n PayoffDefinition memory self,\\n Fixed18 price\\n ) private view returns (Fixed18) {\\n bytes memory ret = address(_providerContract(self)).functionStaticCall(\\n abi.encodeCall(IContractPayoffProvider.payoff, price)\\n );\\n return Fixed18.wrap(abi.decode(ret, (int256)));\\n }\\n}\\n\\n/**\\n * @title PayoffDefinitionStorageLib\\n * @notice Library that surfaces storage read and writes for the PayoffDefinition type\\n */\\nlibrary PayoffDefinitionStorageLib {\\n function read(PayoffDefinitionStorage self) internal view returns (PayoffDefinition memory) {\\n return _storagePointer(self);\\n }\\n\\n function store(PayoffDefinitionStorage self, PayoffDefinition memory value) internal {\\n PayoffDefinition storage storagePointer = _storagePointer(self);\\n\\n storagePointer.payoffType = value.payoffType;\\n storagePointer.payoffDirection = value.payoffDirection;\\n storagePointer.data = value.data;\\n }\\n\\n function _storagePointer(\\n PayoffDefinitionStorage self\\n ) private pure returns (PayoffDefinition storage pointer) {\\n assembly { pointer.slot := self }\\n }\\n}\\n\",\"keccak256\":\"0x4d3897f408f77381c5ae9990391465c8fd511ddf6ff3b39f6cb69d8c2bd554df\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/Position.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\nimport \\\"./PrePosition.sol\\\";\\nimport \\\"./PackedPosition.sol\\\";\\n\\n/// @dev Position type\\nstruct Position {\\n /// @dev Quantity of the maker position\\n UFixed18 maker;\\n /// @dev Quantity of the taker position\\n UFixed18 taker;\\n}\\nusing PositionLib for Position global;\\n\\n/**\\n * @title PositionLib\\n * @notice Library that surfaces math and settlement computations for the Position type.\\n * @dev Positions track the current quantity of the account's maker and taker positions respectively\\n * denominated as a unit of the product's payoff function.\\n */\\nlibrary PositionLib {\\n /**\\n * @notice Creates a packed position from an position\\n * @param self A position\\n * @return New packed position\\n */\\n function pack(Position memory self) internal pure returns (PackedPosition memory) {\\n return PackedPosition({maker: self.maker.pack(), taker: self.taker.pack()});\\n }\\n\\n /**\\n * @notice Returns whether the position is fully empty\\n * @param self A position\\n * @return Whether the position is empty\\n */\\n function isEmpty(Position memory self) internal pure returns (bool) {\\n return self.maker.isZero() && self.taker.isZero();\\n }\\n\\n /**\\n * @notice Adds position `a` and `b` together, returning the result\\n * @param a The first position to sum\\n * @param b The second position to sum\\n * @return Resulting summed position\\n */\\n function add(Position memory a, Position memory b) internal pure returns (Position memory) {\\n return Position({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\\n }\\n\\n /**\\n * @notice Subtracts position `b` from `a`, returning the result\\n * @param a The position to subtract from\\n * @param b The position to subtract\\n * @return Resulting subtracted position\\n */\\n function sub(Position memory a, Position memory b) internal pure returns (Position memory) {\\n return Position({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\\n }\\n\\n /**\\n * @notice Multiplies position `self` by accumulator `accumulator` and returns the resulting accumulator\\n * @param self The Position to operate on\\n * @param accumulator The accumulator to multiply by\\n * @return Resulting multiplied accumulator\\n */\\n function mul(Position memory self, Accumulator memory accumulator) internal pure returns (Accumulator memory) {\\n return Accumulator({\\n maker: Fixed18Lib.from(self.maker).mul(accumulator.maker),\\n taker: Fixed18Lib.from(self.taker).mul(accumulator.taker)\\n });\\n }\\n\\n /**\\n * @notice Scales position `self` by fixed-decimal `scale` and returns the resulting position\\n * @param self The Position to operate on\\n * @param scale The Fixed-decimal to scale by\\n * @return Resulting scaled position\\n */\\n function mul(Position memory self, UFixed18 scale) internal pure returns (Position memory) {\\n return Position({maker: self.maker.mul(scale), taker: self.taker.mul(scale)});\\n }\\n\\n /**\\n * @notice Divides position `self` by `b` and returns the resulting accumulator\\n * @param self The Position to operate on\\n * @param b The number to divide by\\n * @return Resulting divided accumulator\\n */\\n function div(Position memory self, uint256 b) internal pure returns (Accumulator memory) {\\n return Accumulator({\\n maker: Fixed18Lib.from(self.maker).div(Fixed18Lib.from(UFixed18Lib.from(b))),\\n taker: Fixed18Lib.from(self.taker).div(Fixed18Lib.from(UFixed18Lib.from(b)))\\n });\\n }\\n\\n /**\\n * @notice Returns the maximum of `self`'s maker and taker values\\n * @param self The struct to operate on\\n * @return Resulting maximum value\\n */\\n function max(Position memory self) internal pure returns (UFixed18) {\\n return UFixed18Lib.max(self.maker, self.taker);\\n }\\n\\n /**\\n * @notice Sums the maker and taker together from a single position\\n * @param self The struct to operate on\\n * @return The sum of its maker and taker\\n */\\n function sum(Position memory self) internal pure returns (UFixed18) {\\n return self.maker.add(self.taker);\\n }\\n\\n /**\\n * @notice Computes the next position after the pending-settlement position delta is included\\n * @param self The current Position\\n * @param pre The pending-settlement position delta\\n * @return Next Position\\n */\\n function next(Position memory self, PrePosition memory pre) internal pure returns (Position memory) {\\n return sub(add(self, pre.openPosition), pre.closePosition);\\n }\\n\\n /**\\n * @notice Returns the settled position at oracle version `toOracleVersion`\\n * @dev Checks if a new position is ready to be settled based on the provided `toOracleVersion`\\n * and `pre` and returns accordingly\\n * @param self The current Position\\n * @param pre The pending-settlement position delta\\n * @param toOracleVersion The oracle version to settle to\\n * @return Settled position at oracle version\\n * @return Fee accrued from opening or closing the position\\n * @return Whether a new position was settled\\n */\\n function settled(\\n Position memory self,\\n PrePosition memory pre,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal view returns (Position memory, UFixed18, bool) {\\n return pre.canSettle(toOracleVersion) ? (next(self, pre), pre.computeFee(toOracleVersion), true) : (self, UFixed18Lib.ZERO, false);\\n }\\n\\n /**\\n * @notice Returns the socialization factor for the current position\\n * @dev Socialization account for the case where `taker` > `maker` temporarily due to a liquidation\\n * on the maker side. This dampens the taker's exposure pro-rata to ensure that the maker side\\n * is never exposed over 1 x short.\\n * @param self The Position to operate on\\n * @return Socialization factor\\n */\\n function socializationFactor(Position memory self) internal pure returns (UFixed18) {\\n return self.taker.isZero() ? UFixed18Lib.ONE : UFixed18Lib.min(UFixed18Lib.ONE, self.maker.div(self.taker));\\n }\\n}\\n\",\"keccak256\":\"0x027fe392c4f56bf012ba2ca462fcf23e69f2c3b9d283c14089771813437af991\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PrePosition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./Position.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\n\\n/// @dev PrePosition type\\nstruct PrePosition {\\n /// @dev Oracle version at which the new position delta was recorded\\n uint256 oracleVersion;\\n\\n /// @dev Size of position to open at oracle version\\n Position openPosition;\\n\\n /// @dev Size of position to close at oracle version\\n Position closePosition;\\n}\\nusing PrePositionLib for PrePosition global;\\n\\n/**\\n * @title PrePositionLib\\n * @notice Library that manages a pre-settlement position delta.\\n * @dev PrePositions track the currently awaiting-settlement deltas to a settled Position. These are\\n * Primarily necessary to introduce lag into the settlement system such that oracle lag cannot be\\n * gamed to a user's advantage. When a user opens or closes a new position, it sits as a PrePosition\\n * for one oracle version until it's settle into the Position, making it then effective. PrePositions\\n * are automatically settled at the correct oracle version even if a flywheel call doesn't happen until\\n * several version into the future by using the historical version lookups in the corresponding \\\"Versioned\\\"\\n * global state types.\\n */\\nlibrary PrePositionLib {\\n /**\\n * @notice Returns whether there is no pending-settlement position delta\\n * @dev Can be \\\"empty\\\" even with a non-zero oracleVersion if a position is opened and\\n * closed in the same version netting out to a zero position delta\\n * @param self The struct to operate on\\n * @return Whether the pending-settlement position delta is empty\\n */\\n function isEmpty(PrePosition memory self) internal pure returns (bool) {\\n return self.openPosition.isEmpty() && self.closePosition.isEmpty();\\n }\\n\\n /**\\n * @notice Increments the maker side of the open position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The position amount to open\\n */\\n function openMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.openPosition.maker = self.openPosition.maker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netMake(self);\\n }\\n\\n /**\\n * @notice Increments the maker side of the close position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The maker position amount to close\\n */\\n function closeMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.closePosition.maker = self.closePosition.maker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netMake(self);\\n }\\n\\n /**\\n * @notice Increments the taker side of the open position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The taker position amount to open\\n */\\n function openTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.openPosition.taker = self.openPosition.taker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netTake(self);\\n }\\n\\n /**\\n * @notice Increments the taker side of the close position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The taker position amount to close\\n */\\n function closeTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.closePosition.taker = self.closePosition.taker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netTake(self);\\n }\\n\\n /**\\n * @notice Nets out the open and close on the maker side of the position delta\\n * @param self The struct to operate on\\n */\\n function _netMake(PrePosition storage self) private {\\n if (self.openPosition.maker.gt(self.closePosition.maker)) {\\n self.openPosition.maker = self.openPosition.maker.sub(self.closePosition.maker);\\n self.closePosition.maker = UFixed18Lib.ZERO;\\n } else {\\n self.closePosition.maker = self.closePosition.maker.sub(self.openPosition.maker);\\n self.openPosition.maker = UFixed18Lib.ZERO;\\n }\\n }\\n\\n /**\\n * @notice Nets out the open and close on the taker side of the position delta\\n * @param self The struct to operate on\\n */\\n function _netTake(PrePosition storage self) private {\\n if (self.openPosition.taker.gt(self.closePosition.taker)) {\\n self.openPosition.taker = self.openPosition.taker.sub(self.closePosition.taker);\\n self.closePosition.taker = UFixed18Lib.ZERO;\\n } else {\\n self.closePosition.taker = self.closePosition.taker.sub(self.openPosition.taker);\\n self.openPosition.taker = UFixed18Lib.ZERO;\\n }\\n }\\n\\n /**\\n * @notice Returns whether the the pending position delta can be settled at version `toOracleVersion`\\n * @dev Pending-settlement positions deltas can be settled (1) oracle version after they are recorded\\n * @param self The struct to operate on\\n * @param toOracleVersion The potential oracle version to settle\\n * @return Whether the position delta can be settled\\n */\\n function canSettle(\\n PrePosition memory self,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal pure returns (bool) {\\n return !isEmpty(self) && toOracleVersion.version > self.oracleVersion;\\n }\\n\\n /**\\n * @notice Computes the fee incurred for opening or closing the pending-settlement position\\n * @dev Must be called from a valid product to get the proper fee amounts\\n * @param self The struct to operate on\\n * @param toOracleVersion The oracle version at which settlement takes place\\n * @return positionFee The maker / taker fee incurred\\n */\\n function computeFee(\\n PrePosition memory self,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal view returns (UFixed18) {\\n Position memory positionDelta = self.openPosition.add(self.closePosition);\\n\\n (UFixed18 makerNotional, UFixed18 takerNotional) = (\\n Fixed18Lib.from(positionDelta.maker).mul(toOracleVersion.price).abs(),\\n Fixed18Lib.from(positionDelta.taker).mul(toOracleVersion.price).abs()\\n );\\n\\n IProduct product = IProduct(address(this));\\n return makerNotional.mul(product.makerFee()).add(takerNotional.mul(product.takerFee()));\\n }\\n\\n /**\\n * @notice Computes the next oracle version to settle\\n * @dev - If there is no pending-settlement position delta, returns the current oracle version\\n * - Otherwise returns the oracle version at which the pending-settlement position delta can be first settled\\n *\\n * Corresponds to point (b) in the Position settlement flow\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @return Next oracle version to settle\\n */\\n function settleVersion(PrePosition storage self, uint256 currentVersion) internal view returns (uint256) {\\n uint256 _oracleVersion = self.oracleVersion;\\n return _oracleVersion == 0 ? currentVersion : _oracleVersion + 1;\\n }\\n}\\n\",\"keccak256\":\"0xa6f83f7b5f8139ec874235c406debd086a152977493c08b7f280df6f1737fb96\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/ProgramInfo.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\nimport \\\"./Position.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\n\\n/// @dev ProgramInfo type\\nstruct ProgramInfo {\\n /// @dev Coordinator for this program\\n uint256 coordinatorId;\\n\\n /// @dev Amount of total maker and taker rewards\\n Position amount;\\n\\n /// @dev start timestamp of the program\\n uint256 start;\\n\\n /// @dev duration of the program (in seconds)\\n uint256 duration;\\n\\n /**\\n * @dev Reward ERC20 token contract\\n * @notice Perennial does not support non-standard ERC20s as reward tokens for incentive programs, including,\\n but not limited to: fee on transfer and rebase tokens. Using such a non-standard token will likely\\n result in loss of funds.\\n */\\n Token18 token;\\n}\\nusing ProgramInfoLib for ProgramInfo global;\\n\\n/**\\n * @title ProgramInfoLib\\n * @notice Library that snapshots the static information for a single program.\\n * @dev This information does not change during the operation of a program.\\n */\\nlibrary ProgramInfoLib {\\n uint256 private constant MIN_DURATION = 1 days;\\n uint256 private constant MAX_DURATION = 2 * 365 days;\\n\\n error ProgramInvalidStartError();\\n error ProgramInvalidDurationError();\\n\\n /**\\n * @notice Validates and creates a new Program\\n * @dev Reverts for invalid programInfos\\n * @param programInfo Un-sanitized static program information\\n */\\n function validate(ProgramInfo memory programInfo) internal view {\\n if (isStarted(programInfo, block.timestamp)) revert ProgramInvalidStartError();\\n if (programInfo.duration < MIN_DURATION || programInfo.duration > MAX_DURATION) revert ProgramInvalidDurationError();\\n }\\n\\n /**\\n * @notice Computes a new program info with the fee taken out of the amount\\n * @param programInfo Original program info\\n * @param incentivizationFee The incentivization fee\\n * @return New program info\\n * @return Fee amount\\n */\\n function deductFee(ProgramInfo memory programInfo, UFixed18 incentivizationFee)\\n internal pure returns (ProgramInfo memory, UFixed18) {\\n Position memory newProgramAmount = programInfo.amount.mul(UFixed18Lib.ONE.sub(incentivizationFee));\\n UFixed18 programFeeAmount = programInfo.amount.sub(newProgramAmount).sum();\\n programInfo.amount = newProgramAmount;\\n return (programInfo, programFeeAmount);\\n }\\n\\n /**\\n * @notice Returns the maker and taker amounts per position share\\n * @param self The ProgramInfo to operate on\\n * @return programFee Amounts per share\\n */\\n function amountPerShare(ProgramInfo memory self) internal pure returns (Accumulator memory) {\\n return self.amount.div(self.duration);\\n }\\n\\n /**\\n * @notice Returns whether the program has started by timestamp `timestamp`\\n * @param self The ProgramInfo to operate on\\n * @param timestamp Timestamp to check for\\n * @return Whether the program has started\\n */\\n function isStarted(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\\n return timestamp >= self.start;\\n }\\n\\n /**\\n * @notice Returns whether the program is completed by timestamp `timestamp`\\n * @param self The ProgramInfo to operate on\\n * @param timestamp Timestamp to check for\\n * @return Whether the program is completed\\n */\\n function isComplete(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\\n return timestamp >= (self.start + self.duration);\\n }\\n}\\n\",\"keccak256\":\"0x280fcaf931b49abaec46b95ccbabaaf856a4b8e8d036413c9c3b3af25585d161\",\"license\":\"Apache-2.0\"}},\"version\":1}", - "bytecode": "0x60a06040523480156200001157600080fd5b5060405162002c9338038062002c93833981016040819052620000349162000046565b6001600160a01b031660805262000078565b6000602082840312156200005957600080fd5b81516001600160a01b03811681146200007157600080fd5b9392505050565b608051612bdc620000b7600039600081816102e601528181610c7301528181610df701528181611216015281816119c20152611d800152612bdc6000f3fe608060405234801561001057600080fd5b50600436106101005760003560e01c8063c9cb48de11610097578063f213159c11610066578063f213159c14610281578063f77c479114610294578063faaebd21146102c1578063fc0c546a146102e157600080fd5b8063c9cb48de14610203578063ca70d30014610216578063cc218ece14610229578063e41191801461026e57600080fd5b8063a5fdc5de116100d3578063a5fdc5de1461015d578063b4d6f781146101a4578063c3b35a7e146101dd578063c4d66de8146101f057600080fd5b80637f3dd53b1461010557806382df39de1461011a57806386b9d81f1461014257806399d32fc414610155575b600080fd5b61011861011336600461286d565b610308565b005b61012d6101283660046128a8565b61068e565b60405190151581526020015b60405180910390f35b6101186101503660046128a8565b610765565b610118610d2f565b61019661016b3660046128e1565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090206001015490565b604051908152602001610139565b6101966101b23660046128e1565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090206002015490565b6101186101eb3660046128fe565b610e6b565b6101186101fe3660046128e1565b611563565b61011861021136600461293f565b611681565b61011861022436600461293f565b6117e3565b6101966102373660046128a8565b73ffffffffffffffffffffffffffffffffffffffff8082166000908152602081815260408083209386168352929052205492915050565b61012d61027c3660046128a8565b611a3e565b61011861028f3660046128fe565b611ac9565b61029c611ec4565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610139565b6101966102cf3660046128e1565b60016020526000908152604090205481565b61029c7f000000000000000000000000000000000000000000000000000000000000000081565b610310611ec4565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff9190911690637fd2919290602401602060405180830381865afa15801561037c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103a0919061296b565b6103dd576040517f4d5325650000000000000000000000000000000000000000000000000000000081523360048201526024015b60405180910390fd5b600080336103e9611ec4565b9150915060008173ffffffffffffffffffffffffffffffffffffffff166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561043a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061045e919061298d565b6040517f2d809cb600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8581166004830152919250600091841690632d809cb690602401602060405180830381865afa1580156104d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104f4919061298d565b905060006105718473ffffffffffffffffffffffffffffffffffffffff1663b0e21e8a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610546573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061056a91906129aa565b8790611ef3565b9050600061057f8783611f12565b73ffffffffffffffffffffffffffffffffffffffff871660009081526020819052604090209091506105b19088611f1e565b73ffffffffffffffffffffffffffffffffffffffff84166000908152600160205260409020546105e19083611f39565b73ffffffffffffffffffffffffffffffffffffffff808616600090815260016020526040808220939093559085168152205461061d9082611f39565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260016020908152604091829020939093558051858152928301849052908816917fbb1fb7280f9f082e1804d5dc09e8cd7c89debd6b303542f604bcdf7696d9579d910160405180910390a250505050505050565b73ffffffffffffffffffffffffffffffffffffffff80821660009081526020818152604080832093861683529290529081205461075c906040517f9168902400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff86811660048301528516906391689024906024015b602060405180830381865afa158015610732573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061075691906129aa565b90611f45565b90505b92915050565b600261078f7f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b036107c6576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7556107f2611ec4565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561083c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610860919061296b565b15610897576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806108a0611ec4565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301529190911690637fd2919290602401602060405180830381865afa15801561090e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610932919061296b565b610980576040517f4d53256500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016103d4565b6040517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80851660048301528491849182169063f667f89790602401600060405180830381600087803b1580156109ed57600080fd5b505af1158015610a01573d6000803e3d6000fd5b50506040517f9168902400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88811660048301526000935087169150639168902490602401602060405180830381865afa158015610a74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9891906129aa565b73ffffffffffffffffffffffffffffffffffffffff868116600090815260208181526040808320938b1683529290522054909150610ad68282611f45565b610b16576040517f8b9b0bf800000000000000000000000000000000000000000000000000000000815260048101839052602481018290526044016103d4565b6040517ff6b3200800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff888116600483015287169063f6b3200890602401600060405180830381600087803b158015610b7f57600080fd5b505af1158015610b93573d6000803e3d6000fd5b505050506000610ba1611ec4565b73ffffffffffffffffffffffffffffffffffffffff1663a36a36306040518163ffffffff1660e01b8152600401602060405180830381865afa158015610beb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c0f91906129aa565b90506000610c2683610c218685611ef3565b611f5f565b73ffffffffffffffffffffffffffffffffffffffff89166000908152602081905260409020909150610c59908a83611f6b565b610c9a73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000163383611fdd565b604080513381526020810183905273ffffffffffffffffffffffffffffffffffffffff808b1692908c16917f76f1c54646947e8e8df3eab8141bb3d115d07da2520f8e41b208a17d138a8959910160405180910390a350505050505050610d2b60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7611f5b90919063ffffffff16565b5050565b610d37611ec4565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da5919061296b565b15610ddc576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336000818152600160205260408120805491905590610e33907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169083611fdd565b60405181815233907f10df095d1434aed409b2f33d2a6a8456f8b0824633cc12a1b43032085aadc41d9060200160405180910390a250565b6002610e957f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03610ecc576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755610ef8611ec4565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f66919061296b565b15610f9d576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff8116610feb576040517f94c3555f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82610ff4611ec4565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301529190911690637fd2919290602401602060405180830381865afa158015611062573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611086919061296b565b6110d4576040517f4d53256500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016103d4565b6040517ff667f897000000000000000000000000000000000000000000000000000000008152336004820181905290859073ffffffffffffffffffffffffffffffffffffffff82169063f667f89790602401600060405180830381600087803b15801561114057600080fd5b505af1158015611154573d6000803e3d6000fd5b505050503386338861118f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8a611ffe90919063ffffffff16565b61119957886111c9565b73ffffffffffffffffffffffffffffffffffffffff8a166000908152602081815260408083203384529091529020545b73ffffffffffffffffffffffffffffffffffffffff8b1660009081526020819052604090209099506111fc90338b611f6b565b61123d73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168c8b611fdd565b60405189815273ffffffffffffffffffffffffffffffffffffffff8b169033907f2717ead6b9200dd235aad468c9809ea400fe33ac69b5bfaa6d3e90fc922b63989060200160405180910390a36040517f9168902400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff838116600483015260009190831690639168902490602401602060405180830381865afa1580156112fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061131e91906129aa565b6040517fab582f2900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff858116600483015291925060009184169063ab582f2990602401602060405180830381865afa158015611390573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b491906129aa565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260208181526040808320938916835292905220549091506113f6906107568484612014565b1561142d576040517f40e2812c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505073ffffffffffffffffffffffffffffffffffffffff8181166000908152602081815260408083209386168352929052205480158015906114ec57506114ec611477611ec4565b73ffffffffffffffffffffffffffffffffffffffff1663ba2de9bc6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114e591906129aa565b8290612020565b15611523576040517f410d976900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505050505061155e60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7611f5b90919063ffffffff16565b505050565b60018061158e7f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b5490565b106115c8576040517f1e7a9d95000000000000000000000000000000000000000000000000000000008152600481018290526024016103d4565b6115f17f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b829055565b60017fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c5561161e82612034565b611626612114565b60007fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c556040518181527fbe9b076dc5b65990cca9dd9d7366682482e7817a6f6bc7f4faf4dc32af497f329060200160405180910390a15050565b611689611ec4565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff9190911690637fd2919290602401602060405180830381865afa1580156116f5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611719919061296b565b611751576040517f4d5325650000000000000000000000000000000000000000000000000000000081523360048201526024016103d4565b33600081815260208190526040812061176b9085856121a0565b90508373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f40957a7f26dd9f9d628b1aba01d4a3db4c38008974c79a62f6cf0f273a78b3a885846040516117d5929190918252602082015260400190565b60405180910390a350505050565b816117ec611ec4565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301529190911690637fd2919290602401602060405180830381865afa15801561185a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061187e919061296b565b6118cc576040517f4d53256500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016103d4565b6118d4611ec4565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561191e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611942919061296b565b15611979576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090206119a8908361224b565b6119e973ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016338461226e565b8273ffffffffffffffffffffffffffffffffffffffff167f8ae4dab3d718e6b7019e16378795bb41b3046b9117483430a39f7af4ab9bb89383604051611a3191815260200190565b60405180910390a2505050565b73ffffffffffffffffffffffffffffffffffffffff80821660009081526020818152604080832093861683529290529081205461075c906040517fab582f2900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff868116600483015285169063ab582f2990602401610715565b6002611af37f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03611b2a576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755611b56611ec4565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ba0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bc4919061296b565b15611bfb576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff8116611c49576040517f94c3555f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82611c52611ec4565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301529190911690637fd2919290602401602060405180830381865afa158015611cc0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ce4919061296b565b611d32576040517f4d53256500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016103d4565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260208190526040902085908590611d66908387612290565b611da773ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016338761226e565b8573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167f5548c837ab068cf56a2c2479df0882a4922fd203edb7517321831d95078c5f6287604051611e0691815260200190565b60405180910390a373ffffffffffffffffffffffffffffffffffffffff818116600090815260208181526040808320938616835292905220548015801590611e545750611e54611477611ec4565b15611e8b576040517f410d976900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050505061155e60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7611f5b90919063ffffffff16565b6000611eee7f0e555410d8128dff796eab5d29b97dd593ce9cab44a71b64c08244579ea605335490565b905090565b6000670de0b6b3a7640000611f0883856129f2565b61075c9190612a2f565b600061075c8284612a6a565b6001820154611f2d9082611f12565b82600101819055505050565b600061075c8284612a81565b6000611f5183836122f5565b6002149392505050565b9055565b600061075c838361232a565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260208490526040902054611f9b9082611f12565b73ffffffffffffffffffffffffffffffffffffffff83166000908152602085905260409020556001830154611fd09082611f12565b8360010181905550505050565b61155e73ffffffffffffffffffffffffffffffffffffffff84168383612340565b600061200a83836122f5565b6001149392505050565b600061075c8383612414565b600061202c83836122f5565b159392505050565b303b1515801561206357507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b1561209a576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff81163b6120e8576040517f14878b6900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6121117f0e555410d8128dff796eab5d29b97dd593ce9cab44a71b64c08244579ea60533829055565b50565b303b1515801561214357507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b1561217a576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020849052604081205481906121dd9084906121d790612424565b90612483565b90506121e88161248f565b196121fd576121f6816124d9565b9150600090505b612206816124d9565b73ffffffffffffffffffffffffffffffffffffffff8516600090815260208790526040902055600285015461223b9083611f39565b8560020181905550509392505050565b600282015461225a9082611f12565b60028301556001820154611f2d9082611f39565b61155e73ffffffffffffffffffffffffffffffffffffffff84168330846124e4565b73ffffffffffffffffffffffffffffffffffffffff82166000908152602084905260409020546122c09082611f39565b73ffffffffffffffffffffffffffffffffffffffff83166000908152602085905260409020556001830154611fd09082611f39565b600082828082111561230c5760029250505061075f565b8082101561231f5760009250505061075f565b506001949350505050565b6000818310612339578161075c565b5090919050565b60405173ffffffffffffffffffffffffffffffffffffffff831660248201526044810182905261155e9084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152612548565b600081831015612339578161075c565b6000817f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81111561075f576040517ea07eb5000000000000000000000000000000000000000000000000000000008152600481018290526024016103d4565b600061075c8284612a99565b6000808213156124a157506001919050565b60008212156124d157507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff919050565b506000919050565b600061075f82612654565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526125429085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401612392565b50505050565b60006125aa826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661266b9092919063ffffffff16565b80519091501561155e57808060200190518101906125c8919061296b565b61155e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016103d4565b600080821215612667578160000361075f565b5090565b606061267a8484600085612684565b90505b9392505050565b606082471015612716576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016103d4565b73ffffffffffffffffffffffffffffffffffffffff85163b612794576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103d4565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516127bd9190612b39565b60006040518083038185875af1925050503d80600081146127fa576040519150601f19603f3d011682016040523d82523d6000602084013e6127ff565b606091505b509150915061280f82828661281a565b979650505050505050565b6060831561282957508161267d565b8251156128395782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103d49190612b55565b60006020828403121561287f57600080fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff8116811461211157600080fd5b600080604083850312156128bb57600080fd5b82356128c681612886565b915060208301356128d681612886565b809150509250929050565b6000602082840312156128f357600080fd5b813561267d81612886565b60008060006060848603121561291357600080fd5b833561291e81612886565b9250602084013561292e81612886565b929592945050506040919091013590565b6000806040838503121561295257600080fd5b823561295d81612886565b946020939093013593505050565b60006020828403121561297d57600080fd5b8151801515811461267d57600080fd5b60006020828403121561299f57600080fd5b815161267d81612886565b6000602082840312156129bc57600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612a2a57612a2a6129c3565b500290565b600082612a65577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600082821015612a7c57612a7c6129c3565b500390565b60008219821115612a9457612a946129c3565b500190565b6000808212827f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03841381151615612ad357612ad36129c3565b827f8000000000000000000000000000000000000000000000000000000000000000038412811615612b0757612b076129c3565b50500190565b60005b83811015612b28578181015183820152602001612b10565b838111156125425750506000910152565b60008251612b4b818460208701612b0d565b9190910192915050565b6020815260008251806020840152612b74816040850160208701612b0d565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fea264697066735822122038850e053e69a9af35622637417e9deb9b9695fcb64537d3ef55d2ea84396cbd64736f6c634300080f0033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101005760003560e01c8063c9cb48de11610097578063f213159c11610066578063f213159c14610281578063f77c479114610294578063faaebd21146102c1578063fc0c546a146102e157600080fd5b8063c9cb48de14610203578063ca70d30014610216578063cc218ece14610229578063e41191801461026e57600080fd5b8063a5fdc5de116100d3578063a5fdc5de1461015d578063b4d6f781146101a4578063c3b35a7e146101dd578063c4d66de8146101f057600080fd5b80637f3dd53b1461010557806382df39de1461011a57806386b9d81f1461014257806399d32fc414610155575b600080fd5b61011861011336600461286d565b610308565b005b61012d6101283660046128a8565b61068e565b60405190151581526020015b60405180910390f35b6101186101503660046128a8565b610765565b610118610d2f565b61019661016b3660046128e1565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090206001015490565b604051908152602001610139565b6101966101b23660046128e1565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090206002015490565b6101186101eb3660046128fe565b610e6b565b6101186101fe3660046128e1565b611563565b61011861021136600461293f565b611681565b61011861022436600461293f565b6117e3565b6101966102373660046128a8565b73ffffffffffffffffffffffffffffffffffffffff8082166000908152602081815260408083209386168352929052205492915050565b61012d61027c3660046128a8565b611a3e565b61011861028f3660046128fe565b611ac9565b61029c611ec4565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610139565b6101966102cf3660046128e1565b60016020526000908152604090205481565b61029c7f000000000000000000000000000000000000000000000000000000000000000081565b610310611ec4565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff9190911690637fd2919290602401602060405180830381865afa15801561037c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103a0919061296b565b6103dd576040517f4d5325650000000000000000000000000000000000000000000000000000000081523360048201526024015b60405180910390fd5b600080336103e9611ec4565b9150915060008173ffffffffffffffffffffffffffffffffffffffff166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561043a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061045e919061298d565b6040517f2d809cb600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8581166004830152919250600091841690632d809cb690602401602060405180830381865afa1580156104d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104f4919061298d565b905060006105718473ffffffffffffffffffffffffffffffffffffffff1663b0e21e8a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610546573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061056a91906129aa565b8790611ef3565b9050600061057f8783611f12565b73ffffffffffffffffffffffffffffffffffffffff871660009081526020819052604090209091506105b19088611f1e565b73ffffffffffffffffffffffffffffffffffffffff84166000908152600160205260409020546105e19083611f39565b73ffffffffffffffffffffffffffffffffffffffff808616600090815260016020526040808220939093559085168152205461061d9082611f39565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260016020908152604091829020939093558051858152928301849052908816917fbb1fb7280f9f082e1804d5dc09e8cd7c89debd6b303542f604bcdf7696d9579d910160405180910390a250505050505050565b73ffffffffffffffffffffffffffffffffffffffff80821660009081526020818152604080832093861683529290529081205461075c906040517f9168902400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff86811660048301528516906391689024906024015b602060405180830381865afa158015610732573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061075691906129aa565b90611f45565b90505b92915050565b600261078f7f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b036107c6576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7556107f2611ec4565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561083c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610860919061296b565b15610897576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806108a0611ec4565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301529190911690637fd2919290602401602060405180830381865afa15801561090e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610932919061296b565b610980576040517f4d53256500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016103d4565b6040517ff667f89700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80851660048301528491849182169063f667f89790602401600060405180830381600087803b1580156109ed57600080fd5b505af1158015610a01573d6000803e3d6000fd5b50506040517f9168902400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88811660048301526000935087169150639168902490602401602060405180830381865afa158015610a74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9891906129aa565b73ffffffffffffffffffffffffffffffffffffffff868116600090815260208181526040808320938b1683529290522054909150610ad68282611f45565b610b16576040517f8b9b0bf800000000000000000000000000000000000000000000000000000000815260048101839052602481018290526044016103d4565b6040517ff6b3200800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff888116600483015287169063f6b3200890602401600060405180830381600087803b158015610b7f57600080fd5b505af1158015610b93573d6000803e3d6000fd5b505050506000610ba1611ec4565b73ffffffffffffffffffffffffffffffffffffffff1663a36a36306040518163ffffffff1660e01b8152600401602060405180830381865afa158015610beb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c0f91906129aa565b90506000610c2683610c218685611ef3565b611f5f565b73ffffffffffffffffffffffffffffffffffffffff89166000908152602081905260409020909150610c59908a83611f6b565b610c9a73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000163383611fdd565b604080513381526020810183905273ffffffffffffffffffffffffffffffffffffffff808b1692908c16917f76f1c54646947e8e8df3eab8141bb3d115d07da2520f8e41b208a17d138a8959910160405180910390a350505050505050610d2b60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7611f5b90919063ffffffff16565b5050565b610d37611ec4565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da5919061296b565b15610ddc576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336000818152600160205260408120805491905590610e33907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169083611fdd565b60405181815233907f10df095d1434aed409b2f33d2a6a8456f8b0824633cc12a1b43032085aadc41d9060200160405180910390a250565b6002610e957f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03610ecc576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755610ef8611ec4565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f66919061296b565b15610f9d576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff8116610feb576040517f94c3555f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82610ff4611ec4565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301529190911690637fd2919290602401602060405180830381865afa158015611062573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611086919061296b565b6110d4576040517f4d53256500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016103d4565b6040517ff667f897000000000000000000000000000000000000000000000000000000008152336004820181905290859073ffffffffffffffffffffffffffffffffffffffff82169063f667f89790602401600060405180830381600087803b15801561114057600080fd5b505af1158015611154573d6000803e3d6000fd5b505050503386338861118f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8a611ffe90919063ffffffff16565b61119957886111c9565b73ffffffffffffffffffffffffffffffffffffffff8a166000908152602081815260408083203384529091529020545b73ffffffffffffffffffffffffffffffffffffffff8b1660009081526020819052604090209099506111fc90338b611f6b565b61123d73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168c8b611fdd565b60405189815273ffffffffffffffffffffffffffffffffffffffff8b169033907f2717ead6b9200dd235aad468c9809ea400fe33ac69b5bfaa6d3e90fc922b63989060200160405180910390a36040517f9168902400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff838116600483015260009190831690639168902490602401602060405180830381865afa1580156112fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061131e91906129aa565b6040517fab582f2900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff858116600483015291925060009184169063ab582f2990602401602060405180830381865afa158015611390573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b491906129aa565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260208181526040808320938916835292905220549091506113f6906107568484612014565b1561142d576040517f40e2812c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505073ffffffffffffffffffffffffffffffffffffffff8181166000908152602081815260408083209386168352929052205480158015906114ec57506114ec611477611ec4565b73ffffffffffffffffffffffffffffffffffffffff1663ba2de9bc6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114e591906129aa565b8290612020565b15611523576040517f410d976900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505050505061155e60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7611f5b90919063ffffffff16565b505050565b60018061158e7f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b5490565b106115c8576040517f1e7a9d95000000000000000000000000000000000000000000000000000000008152600481018290526024016103d4565b6115f17f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b829055565b60017fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c5561161e82612034565b611626612114565b60007fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c556040518181527fbe9b076dc5b65990cca9dd9d7366682482e7817a6f6bc7f4faf4dc32af497f329060200160405180910390a15050565b611689611ec4565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff9190911690637fd2919290602401602060405180830381865afa1580156116f5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611719919061296b565b611751576040517f4d5325650000000000000000000000000000000000000000000000000000000081523360048201526024016103d4565b33600081815260208190526040812061176b9085856121a0565b90508373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f40957a7f26dd9f9d628b1aba01d4a3db4c38008974c79a62f6cf0f273a78b3a885846040516117d5929190918252602082015260400190565b60405180910390a350505050565b816117ec611ec4565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301529190911690637fd2919290602401602060405180830381865afa15801561185a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061187e919061296b565b6118cc576040517f4d53256500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016103d4565b6118d4611ec4565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561191e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611942919061296b565b15611979576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090206119a8908361224b565b6119e973ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016338461226e565b8273ffffffffffffffffffffffffffffffffffffffff167f8ae4dab3d718e6b7019e16378795bb41b3046b9117483430a39f7af4ab9bb89383604051611a3191815260200190565b60405180910390a2505050565b73ffffffffffffffffffffffffffffffffffffffff80821660009081526020818152604080832093861683529290529081205461075c906040517fab582f2900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff868116600483015285169063ab582f2990602401610715565b6002611af37f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03611b2a576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755611b56611ec4565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ba0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bc4919061296b565b15611bfb576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff8116611c49576040517f94c3555f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82611c52611ec4565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301529190911690637fd2919290602401602060405180830381865afa158015611cc0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ce4919061296b565b611d32576040517f4d53256500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016103d4565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260208190526040902085908590611d66908387612290565b611da773ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016338761226e565b8573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167f5548c837ab068cf56a2c2479df0882a4922fd203edb7517321831d95078c5f6287604051611e0691815260200190565b60405180910390a373ffffffffffffffffffffffffffffffffffffffff818116600090815260208181526040808320938616835292905220548015801590611e545750611e54611477611ec4565b15611e8b576040517f410d976900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050505061155e60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7611f5b90919063ffffffff16565b6000611eee7f0e555410d8128dff796eab5d29b97dd593ce9cab44a71b64c08244579ea605335490565b905090565b6000670de0b6b3a7640000611f0883856129f2565b61075c9190612a2f565b600061075c8284612a6a565b6001820154611f2d9082611f12565b82600101819055505050565b600061075c8284612a81565b6000611f5183836122f5565b6002149392505050565b9055565b600061075c838361232a565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260208490526040902054611f9b9082611f12565b73ffffffffffffffffffffffffffffffffffffffff83166000908152602085905260409020556001830154611fd09082611f12565b8360010181905550505050565b61155e73ffffffffffffffffffffffffffffffffffffffff84168383612340565b600061200a83836122f5565b6001149392505050565b600061075c8383612414565b600061202c83836122f5565b159392505050565b303b1515801561206357507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b1561209a576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff81163b6120e8576040517f14878b6900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6121117f0e555410d8128dff796eab5d29b97dd593ce9cab44a71b64c08244579ea60533829055565b50565b303b1515801561214357507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b1561217a576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020849052604081205481906121dd9084906121d790612424565b90612483565b90506121e88161248f565b196121fd576121f6816124d9565b9150600090505b612206816124d9565b73ffffffffffffffffffffffffffffffffffffffff8516600090815260208790526040902055600285015461223b9083611f39565b8560020181905550509392505050565b600282015461225a9082611f12565b60028301556001820154611f2d9082611f39565b61155e73ffffffffffffffffffffffffffffffffffffffff84168330846124e4565b73ffffffffffffffffffffffffffffffffffffffff82166000908152602084905260409020546122c09082611f39565b73ffffffffffffffffffffffffffffffffffffffff83166000908152602085905260409020556001830154611fd09082611f39565b600082828082111561230c5760029250505061075f565b8082101561231f5760009250505061075f565b506001949350505050565b6000818310612339578161075c565b5090919050565b60405173ffffffffffffffffffffffffffffffffffffffff831660248201526044810182905261155e9084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152612548565b600081831015612339578161075c565b6000817f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81111561075f576040517ea07eb5000000000000000000000000000000000000000000000000000000008152600481018290526024016103d4565b600061075c8284612a99565b6000808213156124a157506001919050565b60008212156124d157507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff919050565b506000919050565b600061075f82612654565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526125429085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401612392565b50505050565b60006125aa826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661266b9092919063ffffffff16565b80519091501561155e57808060200190518101906125c8919061296b565b61155e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016103d4565b600080821215612667578160000361075f565b5090565b606061267a8484600085612684565b90505b9392505050565b606082471015612716576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016103d4565b73ffffffffffffffffffffffffffffffffffffffff85163b612794576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103d4565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516127bd9190612b39565b60006040518083038185875af1925050503d80600081146127fa576040519150601f19603f3d011682016040523d82523d6000602084013e6127ff565b606091505b509150915061280f82828661281a565b979650505050505050565b6060831561282957508161267d565b8251156128395782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103d49190612b55565b60006020828403121561287f57600080fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff8116811461211157600080fd5b600080604083850312156128bb57600080fd5b82356128c681612886565b915060208301356128d681612886565b809150509250929050565b6000602082840312156128f357600080fd5b813561267d81612886565b60008060006060848603121561291357600080fd5b833561291e81612886565b9250602084013561292e81612886565b929592945050506040919091013590565b6000806040838503121561295257600080fd5b823561295d81612886565b946020939093013593505050565b60006020828403121561297d57600080fd5b8151801515811461267d57600080fd5b60006020828403121561299f57600080fd5b815161267d81612886565b6000602082840312156129bc57600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612a2a57612a2a6129c3565b500290565b600082612a65577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600082821015612a7c57612a7c6129c3565b500390565b60008219821115612a9457612a946129c3565b500190565b6000808212827f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03841381151615612ad357612ad36129c3565b827f8000000000000000000000000000000000000000000000000000000000000000038412811615612b0757612b076129c3565b50500190565b60005b83811015612b28578181015183820152602001612b10565b838111156125425750506000910152565b60008251612b4b818460208701612b0d565b9190910192915050565b6020815260008251806020840152612b74816040850160208701612b0d565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fea264697066735822122038850e053e69a9af35622637417e9deb9b9695fcb64537d3ef55d2ea84396cbd64736f6c634300080f0033", - "devdoc": { - "kind": "dev", - "methods": { - "collateral(address)": { - "params": { - "product": "Product to return for" - }, - "returns": { - "_0": "The total balance of collateral in the product" - } - }, - "collateral(address,address)": { - "params": { - "account": "Account to return for", - "product": "Product to return for" - }, - "returns": { - "_0": "The balance of the collateral account" - } - }, - "constructor": { - "details": "Called at implementation instantiate and constant for that implementation.", - "params": { - "token_": "Collateral ERC20 stablecoin address" - } - }, - "depositTo(address,address,uint256)": { - "params": { - "account": "Account to deposit the collateral for", - "amount": "Amount of collateral to deposit", - "product": "Product to credit the collateral to" - } - }, - "initialize(address)": { - "details": "Must be called atomically as part of the upgradeable proxy deployment to avoid front-running", - "params": { - "controller_": "Factory contract address" - } - }, - "liquidatable(address,address)": { - "params": { - "account": "Account to return for", - "product": "Product to return for" - }, - "returns": { - "_0": "Whether the account can be liquidated" - } - }, - "liquidatableNext(address,address)": { - "details": "Takes into account the current pre-position on the account", - "params": { - "account": "Account to return for", - "product": "Product to return for" - }, - "returns": { - "_0": "Whether the account can be liquidated" - } - }, - "liquidate(address,address)": { - "details": "Account must be under-collateralized, fee returned immediately to `msg.sender`", - "params": { - "account": "Account to liquidate", - "product": "Product to liquidate for" - } - }, - "resolveShortfall(address,uint256)": { - "details": "Shortfall is a measure of settled insolvency in the market This hook can be used by the product owner or an insurance fund to re-capitalize an insolvent market", - "params": { - "amount": "Amount of shortfall to resolve", - "product": "Product to resolve shortfall for" - } - }, - "settleAccount(address,int256)": { - "details": "Callable only by the corresponding product as part of the settlement flywheel. Moves collateral within a product, any collateral leaving the product due to fees has already been accounted for in the settleProduct flywheel. Debits in excess of the account balance get recorded as shortfall, and can be resolved by the product owner as needed.", - "params": { - "account": "Account to credit", - "amount": "Amount to credit the account (can be negative)" - } - }, - "settleProduct(uint256)": { - "details": "Callable only by the corresponding product as part of the settlement flywheel Removes collateral from the product as fees.", - "params": { - "amount": "Amount to debit from the account" - } - }, - "shortfall(address)": { - "params": { - "product": "Product to return for" - }, - "returns": { - "_0": "The current shortfall of the product" - } - }, - "withdrawTo(address,address,uint256)": { - "params": { - "account": "Account to withdraw the collateral to", - "amount": "Amount of collateral to withdraw", - "product": "Product to withdraw the collateral from" - } - } - }, - "stateVariables": { - "_products": { - "details": "Per product collateral state" - }, - "fees": { - "details": "Protocol and product fees collected, but not yet claimed" - }, - "token": { - "details": "ERC20 stablecoin for collateral" - } - }, - "title": "Collateral", - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": { - "claimFee()": { - "notice": "Claims all of `msg.sender`'s fees" - }, - "collateral(address)": { - "notice": "Returns the total balance of `product`'s collateral" - }, - "collateral(address,address)": { - "notice": "Returns the balance of `account`'s `product` collateral account" - }, - "constructor": { - "notice": "Initializes the immutable contract state" - }, - "depositTo(address,address,uint256)": { - "notice": "Deposits `amount` collateral from `msg.sender` to `account`'s `product` account" - }, - "initialize(address)": { - "notice": "Initializes the contract state" - }, - "liquidatable(address,address)": { - "notice": "Returns whether `account`'s `product` collateral account can be liquidated" - }, - "liquidatableNext(address,address)": { - "notice": "Returns whether `account`'s `product` collateral account can be liquidated after the next oracle version settlement" - }, - "liquidate(address,address)": { - "notice": "Liquidates `account`'s `product` collateral account" - }, - "resolveShortfall(address,uint256)": { - "notice": "Injects additional collateral into a product to resolve shortfall" - }, - "settleAccount(address,int256)": { - "notice": "Credits `amount` to `account`'s collateral account" - }, - "settleProduct(uint256)": { - "notice": "Debits `amount` from product's total collateral account" - }, - "shortfall(address)": { - "notice": "Returns the current shortfall of `product`'s collateral" - }, - "withdrawTo(address,address,uint256)": { - "notice": "Withdraws `amount` collateral from `msg.sender`'s `product` account and sends it to `account`" - } - }, - "notice": "Manages logic and state for all collateral accounts in the protocol.", - "version": 1 - }, - "storageLayout": { - "storage": [ - { - "astId": 10414, - "contract": "contracts/collateral/Collateral.sol:Collateral", - "label": "_products", - "offset": 0, - "slot": "0", - "type": "t_mapping(t_contract(IProduct)16058,t_struct(OptimisticLedger)11099_storage)" - }, - { - "astId": 10420, - "contract": "contracts/collateral/Collateral.sol:Collateral", - "label": "fees", - "offset": 0, - "slot": "1", - "type": "t_mapping(t_address,t_userDefinedValueType(UFixed18)3224)" - } - ], - "types": { - "t_address": { - "encoding": "inplace", - "label": "address", - "numberOfBytes": "20" - }, - "t_contract(IProduct)16058": { - "encoding": "inplace", - "label": "contract IProduct", - "numberOfBytes": "20" - }, - "t_mapping(t_address,t_userDefinedValueType(UFixed18)3224)": { - "encoding": "mapping", - "key": "t_address", - "label": "mapping(address => UFixed18)", - "numberOfBytes": "32", - "value": "t_userDefinedValueType(UFixed18)3224" - }, - "t_mapping(t_contract(IProduct)16058,t_struct(OptimisticLedger)11099_storage)": { - "encoding": "mapping", - "key": "t_contract(IProduct)16058", - "label": "mapping(contract IProduct => struct OptimisticLedger)", - "numberOfBytes": "32", - "value": "t_struct(OptimisticLedger)11099_storage" - }, - "t_struct(OptimisticLedger)11099_storage": { - "encoding": "inplace", - "label": "struct OptimisticLedger", - "members": [ - { - "astId": 11090, - "contract": "contracts/collateral/Collateral.sol:Collateral", - "label": "balances", - "offset": 0, - "slot": "0", - "type": "t_mapping(t_address,t_userDefinedValueType(UFixed18)3224)" - }, - { - "astId": 11094, - "contract": "contracts/collateral/Collateral.sol:Collateral", - "label": "total", - "offset": 0, - "slot": "1", - "type": "t_userDefinedValueType(UFixed18)3224" - }, - { - "astId": 11098, - "contract": "contracts/collateral/Collateral.sol:Collateral", - "label": "shortfall", - "offset": 0, - "slot": "2", - "type": "t_userDefinedValueType(UFixed18)3224" - } - ], - "numberOfBytes": "96" - }, - "t_userDefinedValueType(UFixed18)3224": { - "encoding": "inplace", - "label": "UFixed18", - "numberOfBytes": "32" - } - } - } -} diff --git a/packages/perennial/deployments/kovan/Collateral_Proxy.json b/packages/perennial/deployments/kovan/Collateral_Proxy.json deleted file mode 100644 index 6112f5052..000000000 --- a/packages/perennial/deployments/kovan/Collateral_Proxy.json +++ /dev/null @@ -1,229 +0,0 @@ -{ - "address": "0x877682C7a8840D59A63a6227ED2Aeb20C3ae7FeB", - "abi": [ - { - "inputs": [ - { - "internalType": "address", - "name": "_logic", - "type": "address" - }, - { - "internalType": "address", - "name": "admin_", - "type": "address" - }, - { - "internalType": "bytes", - "name": "_data", - "type": "bytes" - } - ], - "stateMutability": "payable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "previousAdmin", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "newAdmin", - "type": "address" - } - ], - "name": "AdminChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "beacon", - "type": "address" - } - ], - "name": "BeaconUpgraded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "implementation", - "type": "address" - } - ], - "name": "Upgraded", - "type": "event" - }, - { - "stateMutability": "payable", - "type": "fallback" - }, - { - "inputs": [], - "name": "admin", - "outputs": [ - { - "internalType": "address", - "name": "admin_", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newAdmin", - "type": "address" - } - ], - "name": "changeAdmin", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "implementation", - "outputs": [ - { - "internalType": "address", - "name": "implementation_", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newImplementation", - "type": "address" - } - ], - "name": "upgradeTo", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newImplementation", - "type": "address" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "upgradeToAndCall", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "stateMutability": "payable", - "type": "receive" - } - ], - "transactionHash": "0x5a7f6e495154c9be3bc7fdddf174938bf709462d5ed8872dec9b744658eb452b", - "receipt": { - "to": null, - "from": "0x66a7fDB96C583c59597de16d8b2B989231415339", - "contractAddress": "0x877682C7a8840D59A63a6227ED2Aeb20C3ae7FeB", - "transactionIndex": 0, - "gasUsed": "690597", - "logsBloom": "0x00000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000020000000000000000000000000000000000000040000000000000000000800000000000000020000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000004020000000000000000000000008000000000400000000000000000000000000000000000000000000000000000000000000000002000000000000000000", - "blockHash": "0xf712f2c138768edb422480b973ae665d6f3b6949955c896e5a2d3219d1949c0b", - "transactionHash": "0x5a7f6e495154c9be3bc7fdddf174938bf709462d5ed8872dec9b744658eb452b", - "logs": [ - { - "transactionIndex": 0, - "blockNumber": 33203740, - "transactionHash": "0x5a7f6e495154c9be3bc7fdddf174938bf709462d5ed8872dec9b744658eb452b", - "address": "0x877682C7a8840D59A63a6227ED2Aeb20C3ae7FeB", - "topics": [ - "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x00000000000000000000000017abb7df4cdcdda78039d51abacfd2b75f82434f" - ], - "data": "0x", - "logIndex": 0, - "blockHash": "0xf712f2c138768edb422480b973ae665d6f3b6949955c896e5a2d3219d1949c0b" - }, - { - "transactionIndex": 0, - "blockNumber": 33203740, - "transactionHash": "0x5a7f6e495154c9be3bc7fdddf174938bf709462d5ed8872dec9b744658eb452b", - "address": "0x877682C7a8840D59A63a6227ED2Aeb20C3ae7FeB", - "topics": ["0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f"], - "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffe829f928cb8c07961bfff04512ac0749d65d27", - "logIndex": 1, - "blockHash": "0xf712f2c138768edb422480b973ae665d6f3b6949955c896e5a2d3219d1949c0b" - } - ], - "blockNumber": 33203740, - "cumulativeGasUsed": "690597", - "status": 1, - "byzantium": true - }, - "args": ["0x17aBb7df4cdCddA78039D51Abacfd2B75f82434f", "0xfFE829F928Cb8C07961bfFF04512ac0749d65d27", "0x"], - "numDeployments": 1, - "solcInputHash": "dd52f03d8fef7833844e4ba864fd9fba", - "metadata": "{\"compiler\":{\"version\":\"0.8.15+commit.e14f2714\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // 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\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\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 ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\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(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\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 /**\\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 {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x60806040526040516200112838038062001128833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b600080516020620010e1833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b600080516020620010c183398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b6200028c1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e98383604051806060016040528060278152602001620011016027913962000381565b9392505050565b60006200021a600080516020620010c183398151915260001b6200046760201b6200022e1760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd600080516020620010c183398151915260001b6200046760201b6200022e1760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b620002b81760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd600080516020620010e183398151915260001b6200046760201b6200022e1760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610a2980620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b610090366004610895565b610135565b61006b6100a33660046108b0565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b610101366004610895565b610231565b34801561011257600080fd5b506100bd61025e565b6101236102d4565b61013361012e6103ab565b6103b5565b565b61013d6103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481604051806020016040528060008152506000610419565b50565b61017461011b565b6101876103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610419915050565b505050565b6101e661011b565b60006101fd6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103ab565b905090565b61022e61011b565b90565b6102396103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481610444565b60006102686103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103d9565b60606102b183836040518060600160405280602781526020016109cd602791396104a5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6102dc6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102216105cd565b3660008037600080366000845af43d6000803e8080156103d4573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b610422836105f5565b60008251118061042f5750805b156101e65761043e838361028c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61046d6103d9565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161017481610642565b606073ffffffffffffffffffffffffffffffffffffffff84163b61054b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103a2565b6000808573ffffffffffffffffffffffffffffffffffffffff1685604051610573919061095f565b600060405180830381855af49150503d80600081146105ae576040519150601f19603f3d011682016040523d82523d6000602084013e6105b3565b606091505b50915091506105c382828661074e565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103fd565b6105fe816107a1565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff81166106e5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103a2565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060831561075d5750816102b1565b82511561076d5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a2919061097b565b73ffffffffffffffffffffffffffffffffffffffff81163b610845576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103a2565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610708565b803573ffffffffffffffffffffffffffffffffffffffff8116811461089057600080fd5b919050565b6000602082840312156108a757600080fd5b6102b18261086c565b6000806000604084860312156108c557600080fd5b6108ce8461086c565b9250602084013567ffffffffffffffff808211156108eb57600080fd5b818601915086601f8301126108ff57600080fd5b81358181111561090e57600080fd5b87602082850101111561092057600080fd5b6020830194508093505050509250925092565b60005b8381101561094e578181015183820152602001610936565b8381111561043e5750506000910152565b60008251610971818460208701610933565b9190910192915050565b602081526000825180602084015261099a816040850160208701610933565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a4b930408c511c08d53f1ec84bb13fe259938b06e5d586d6adc4fc27200abe6c64736f6c634300080f0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", - "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b610090366004610895565b610135565b61006b6100a33660046108b0565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b610101366004610895565b610231565b34801561011257600080fd5b506100bd61025e565b6101236102d4565b61013361012e6103ab565b6103b5565b565b61013d6103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481604051806020016040528060008152506000610419565b50565b61017461011b565b6101876103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610419915050565b505050565b6101e661011b565b60006101fd6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103ab565b905090565b61022e61011b565b90565b6102396103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481610444565b60006102686103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103d9565b60606102b183836040518060600160405280602781526020016109cd602791396104a5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6102dc6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102216105cd565b3660008037600080366000845af43d6000803e8080156103d4573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b610422836105f5565b60008251118061042f5750805b156101e65761043e838361028c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61046d6103d9565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161017481610642565b606073ffffffffffffffffffffffffffffffffffffffff84163b61054b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103a2565b6000808573ffffffffffffffffffffffffffffffffffffffff1685604051610573919061095f565b600060405180830381855af49150503d80600081146105ae576040519150601f19603f3d011682016040523d82523d6000602084013e6105b3565b606091505b50915091506105c382828661074e565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103fd565b6105fe816107a1565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff81166106e5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103a2565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060831561075d5750816102b1565b82511561076d5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a2919061097b565b73ffffffffffffffffffffffffffffffffffffffff81163b610845576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103a2565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610708565b803573ffffffffffffffffffffffffffffffffffffffff8116811461089057600080fd5b919050565b6000602082840312156108a757600080fd5b6102b18261086c565b6000806000604084860312156108c557600080fd5b6108ce8461086c565b9250602084013567ffffffffffffffff808211156108eb57600080fd5b818601915086601f8301126108ff57600080fd5b81358181111561090e57600080fd5b87602082850101111561092057600080fd5b6020830194508093505050509250925092565b60005b8381101561094e578181015183820152602001610936565b8381111561043e5750506000910152565b60008251610971818460208701610933565b9190910192915050565b602081526000825180602084015261099a816040850160208701610933565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a4b930408c511c08d53f1ec84bb13fe259938b06e5d586d6adc4fc27200abe6c64736f6c634300080f0033", - "devdoc": { - "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", - "kind": "dev", - "methods": { - "admin()": { - "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" - }, - "changeAdmin(address)": { - "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." - }, - "constructor": { - "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." - }, - "implementation()": { - "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" - }, - "upgradeTo(address)": { - "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." - }, - "upgradeToAndCall(address,bytes)": { - "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." - } - }, - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": {}, - "version": 1 - }, - "storageLayout": { - "storage": [], - "types": null - } -} diff --git a/packages/perennial/deployments/kovan/Controller_Impl.json b/packages/perennial/deployments/kovan/Controller_Impl.json deleted file mode 100644 index 91a469688..000000000 --- a/packages/perennial/deployments/kovan/Controller_Impl.json +++ /dev/null @@ -1,1531 +0,0 @@ -{ - "address": "0x0818E46C726810c2f7a1C513D0637a862bc0df6F", - "abi": [ - { - "inputs": [], - "name": "ControllerInvalidIncentivizationFeeError", - "type": "error" - }, - { - "inputs": [], - "name": "ControllerInvalidLiquidationFeeError", - "type": "error" - }, - { - "inputs": [], - "name": "ControllerInvalidMinFundingFeeError", - "type": "error" - }, - { - "inputs": [], - "name": "ControllerInvalidProtocolFeeError", - "type": "error" - }, - { - "inputs": [], - "name": "ControllerNoZeroCoordinatorError", - "type": "error" - }, - { - "inputs": [], - "name": "ControllerNotContractAddressError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "controllerId", - "type": "uint256" - } - ], - "name": "ControllerNotOwnerError", - "type": "error" - }, - { - "inputs": [], - "name": "ControllerNotPauserError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "controllerId", - "type": "uint256" - } - ], - "name": "ControllerNotPendingOwnerError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "version", - "type": "uint256" - } - ], - "name": "UInitializableAlreadyInitializedError", - "type": "error" - }, - { - "inputs": [], - "name": "UInitializableNotInitializingError", - "type": "error" - }, - { - "inputs": [], - "name": "UInitializableZeroVersionError", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "contract ICollateral", - "name": "newCollateral", - "type": "address" - } - ], - "name": "CollateralUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "name": "CoordinatorCreated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "CoordinatorOwnerUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "newPendingOwner", - "type": "address" - } - ], - "name": "CoordinatorPendingOwnerUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "newTreasury", - "type": "address" - } - ], - "name": "CoordinatorTreasuryUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "UFixed18", - "name": "newIncentivizationFee", - "type": "uint256" - } - ], - "name": "IncentivizationFeeUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "contract IIncentivizer", - "name": "newIncentivizer", - "type": "address" - } - ], - "name": "IncentivizerUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "version", - "type": "uint256" - } - ], - "name": "Initialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "UFixed18", - "name": "newLiquidationFee", - "type": "uint256" - } - ], - "name": "LiquidationFeeUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "UFixed18", - "name": "newMinCollateral", - "type": "uint256" - } - ], - "name": "MinCollateralUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "UFixed18", - "name": "newMinFundingFee", - "type": "uint256" - } - ], - "name": "MinFundingFeeUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bool", - "name": "newPaused", - "type": "bool" - } - ], - "name": "PausedUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "newPauser", - "type": "address" - } - ], - "name": "PauserUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "contract IBeacon", - "name": "newProductBeacon", - "type": "address" - } - ], - "name": "ProductBeaconUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "components": [ - { - "internalType": "string", - "name": "name", - "type": "string" - }, - { - "internalType": "string", - "name": "symbol", - "type": "string" - }, - { - "components": [ - { - "internalType": "enum PayoffDefinitionLib.PayoffType", - "name": "payoffType", - "type": "uint8" - }, - { - "internalType": "enum PayoffDefinitionLib.PayoffDirection", - "name": "payoffDirection", - "type": "uint8" - }, - { - "internalType": "bytes30", - "name": "data", - "type": "bytes30" - } - ], - "internalType": "struct PayoffDefinition", - "name": "payoffDefinition", - "type": "tuple" - }, - { - "internalType": "contract IOracleProvider", - "name": "oracle", - "type": "address" - }, - { - "internalType": "UFixed18", - "name": "maintenance", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "fundingFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "makerFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "takerFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "makerLimit", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "PackedFixed18", - "name": "minRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "maxRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "targetRate", - "type": "int128" - }, - { - "internalType": "PackedUFixed18", - "name": "targetUtilization", - "type": "uint128" - } - ], - "internalType": "struct JumpRateUtilizationCurve", - "name": "utilizationCurve", - "type": "tuple" - } - ], - "indexed": false, - "internalType": "struct IProduct.ProductInfo", - "name": "productInfo", - "type": "tuple" - } - ], - "name": "ProductCreated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "newProgramsPerProduct", - "type": "uint256" - } - ], - "name": "ProgramsPerProductUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "UFixed18", - "name": "newProtocolFee", - "type": "uint256" - } - ], - "name": "ProtocolFeeUpdated", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - } - ], - "name": "acceptCoordinatorOwner", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "collateral", - "outputs": [ - { - "internalType": "contract ICollateral", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "", - "type": "address" - } - ], - "name": "coordinatorFor", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - } - ], - "name": "coordinators", - "outputs": [ - { - "components": [ - { - "internalType": "address", - "name": "pendingOwner", - "type": "address" - }, - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "address", - "name": "treasury", - "type": "address" - } - ], - "internalType": "struct IController.Coordinator", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "createCoordinator", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "string", - "name": "name", - "type": "string" - }, - { - "internalType": "string", - "name": "symbol", - "type": "string" - }, - { - "components": [ - { - "internalType": "enum PayoffDefinitionLib.PayoffType", - "name": "payoffType", - "type": "uint8" - }, - { - "internalType": "enum PayoffDefinitionLib.PayoffDirection", - "name": "payoffDirection", - "type": "uint8" - }, - { - "internalType": "bytes30", - "name": "data", - "type": "bytes30" - } - ], - "internalType": "struct PayoffDefinition", - "name": "payoffDefinition", - "type": "tuple" - }, - { - "internalType": "contract IOracleProvider", - "name": "oracle", - "type": "address" - }, - { - "internalType": "UFixed18", - "name": "maintenance", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "fundingFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "makerFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "takerFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "makerLimit", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "PackedFixed18", - "name": "minRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "maxRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "targetRate", - "type": "int128" - }, - { - "internalType": "PackedUFixed18", - "name": "targetUtilization", - "type": "uint128" - } - ], - "internalType": "struct JumpRateUtilizationCurve", - "name": "utilizationCurve", - "type": "tuple" - } - ], - "internalType": "struct IProduct.ProductInfo", - "name": "productInfo", - "type": "tuple" - } - ], - "name": "createProduct", - "outputs": [ - { - "internalType": "contract IProduct", - "name": "", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "incentivizationFee", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "incentivizer", - "outputs": [ - { - "internalType": "contract IIncentivizer", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract ICollateral", - "name": "collateral_", - "type": "address" - }, - { - "internalType": "contract IIncentivizer", - "name": "incentivizer_", - "type": "address" - }, - { - "internalType": "contract IBeacon", - "name": "productBeacon_", - "type": "address" - } - ], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "isProduct", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "liquidationFee", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "minCollateral", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "minFundingFee", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - } - ], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "paused", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "pauser", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - } - ], - "name": "pendingOwner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "pendingOwner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "productBeacon", - "outputs": [ - { - "internalType": "contract IBeacon", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "programsPerProduct", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "protocolFee", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "treasury", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - } - ], - "name": "treasury", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "treasury", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract ICollateral", - "name": "newCollateral", - "type": "address" - } - ], - "name": "updateCollateral", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - }, - { - "internalType": "address", - "name": "newPendingOwner", - "type": "address" - } - ], - "name": "updateCoordinatorPendingOwner", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - }, - { - "internalType": "address", - "name": "newTreasury", - "type": "address" - } - ], - "name": "updateCoordinatorTreasury", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "newIncentivizationFee", - "type": "uint256" - } - ], - "name": "updateIncentivizationFee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IIncentivizer", - "name": "newIncentivizer", - "type": "address" - } - ], - "name": "updateIncentivizer", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "newLiquidationFee", - "type": "uint256" - } - ], - "name": "updateLiquidationFee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "newMinCollateral", - "type": "uint256" - } - ], - "name": "updateMinCollateral", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "newMinFundingFee", - "type": "uint256" - } - ], - "name": "updateMinFundingFee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bool", - "name": "newPaused", - "type": "bool" - } - ], - "name": "updatePaused", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newPauser", - "type": "address" - } - ], - "name": "updatePauser", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IBeacon", - "name": "newProductBeacon", - "type": "address" - } - ], - "name": "updateProductBeacon", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "newProgramsPerProduct", - "type": "uint256" - } - ], - "name": "updateProgramsPerProduct", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "newProtocolFee", - "type": "uint256" - } - ], - "name": "updateProtocolFee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } - ], - "transactionHash": "0xdff42b3125b73e7b0c9ca4039db1980766755dc5c46d18b26d446b0ab3c0c09e", - "receipt": { - "to": null, - "from": "0x66a7fDB96C583c59597de16d8b2B989231415339", - "contractAddress": "0x0818E46C726810c2f7a1C513D0637a862bc0df6F", - "transactionIndex": 0, - "gasUsed": "2574331", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x3cae7601da04adf827992a094d939f2335cb34d67e9721988a37d48c898490b5", - "transactionHash": "0xdff42b3125b73e7b0c9ca4039db1980766755dc5c46d18b26d446b0ab3c0c09e", - "logs": [], - "blockNumber": 33203732, - "cumulativeGasUsed": "2574331", - "status": 1, - "byzantium": true - }, - "args": [], - "numDeployments": 1, - "solcInputHash": "dd52f03d8fef7833844e4ba864fd9fba", - "metadata": "{\"compiler\":{\"version\":\"0.8.15+commit.e14f2714\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"ControllerInvalidIncentivizationFeeError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ControllerInvalidLiquidationFeeError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ControllerInvalidMinFundingFeeError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ControllerInvalidProtocolFeeError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ControllerNoZeroCoordinatorError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ControllerNotContractAddressError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"controllerId\",\"type\":\"uint256\"}],\"name\":\"ControllerNotOwnerError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ControllerNotPauserError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"controllerId\",\"type\":\"uint256\"}],\"name\":\"ControllerNotPendingOwnerError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"UInitializableAlreadyInitializedError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UInitializableNotInitializingError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UInitializableZeroVersionError\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract ICollateral\",\"name\":\"newCollateral\",\"type\":\"address\"}],\"name\":\"CollateralUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"CoordinatorCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"CoordinatorOwnerUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newPendingOwner\",\"type\":\"address\"}],\"name\":\"CoordinatorPendingOwnerUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newTreasury\",\"type\":\"address\"}],\"name\":\"CoordinatorTreasuryUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"newIncentivizationFee\",\"type\":\"uint256\"}],\"name\":\"IncentivizationFeeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IIncentivizer\",\"name\":\"newIncentivizer\",\"type\":\"address\"}],\"name\":\"IncentivizerUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"newLiquidationFee\",\"type\":\"uint256\"}],\"name\":\"LiquidationFeeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"newMinCollateral\",\"type\":\"uint256\"}],\"name\":\"MinCollateralUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"newMinFundingFee\",\"type\":\"uint256\"}],\"name\":\"MinFundingFeeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"newPaused\",\"type\":\"bool\"}],\"name\":\"PausedUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newPauser\",\"type\":\"address\"}],\"name\":\"PauserUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IBeacon\",\"name\":\"newProductBeacon\",\"type\":\"address\"}],\"name\":\"ProductBeaconUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"},{\"components\":[{\"internalType\":\"enum PayoffDefinitionLib.PayoffType\",\"name\":\"payoffType\",\"type\":\"uint8\"},{\"internalType\":\"enum PayoffDefinitionLib.PayoffDirection\",\"name\":\"payoffDirection\",\"type\":\"uint8\"},{\"internalType\":\"bytes30\",\"name\":\"data\",\"type\":\"bytes30\"}],\"internalType\":\"struct PayoffDefinition\",\"name\":\"payoffDefinition\",\"type\":\"tuple\"},{\"internalType\":\"contract IOracleProvider\",\"name\":\"oracle\",\"type\":\"address\"},{\"internalType\":\"UFixed18\",\"name\":\"maintenance\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"fundingFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"makerFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"takerFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"makerLimit\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"PackedFixed18\",\"name\":\"minRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"maxRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"targetRate\",\"type\":\"int128\"},{\"internalType\":\"PackedUFixed18\",\"name\":\"targetUtilization\",\"type\":\"uint128\"}],\"internalType\":\"struct JumpRateUtilizationCurve\",\"name\":\"utilizationCurve\",\"type\":\"tuple\"}],\"indexed\":false,\"internalType\":\"struct IProduct.ProductInfo\",\"name\":\"productInfo\",\"type\":\"tuple\"}],\"name\":\"ProductCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newProgramsPerProduct\",\"type\":\"uint256\"}],\"name\":\"ProgramsPerProductUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"newProtocolFee\",\"type\":\"uint256\"}],\"name\":\"ProtocolFeeUpdated\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"}],\"name\":\"acceptCoordinatorOwner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"collateral\",\"outputs\":[{\"internalType\":\"contract ICollateral\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"coordinatorFor\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"}],\"name\":\"coordinators\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"pendingOwner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"treasury\",\"type\":\"address\"}],\"internalType\":\"struct IController.Coordinator\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"createCoordinator\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"},{\"components\":[{\"internalType\":\"enum PayoffDefinitionLib.PayoffType\",\"name\":\"payoffType\",\"type\":\"uint8\"},{\"internalType\":\"enum PayoffDefinitionLib.PayoffDirection\",\"name\":\"payoffDirection\",\"type\":\"uint8\"},{\"internalType\":\"bytes30\",\"name\":\"data\",\"type\":\"bytes30\"}],\"internalType\":\"struct PayoffDefinition\",\"name\":\"payoffDefinition\",\"type\":\"tuple\"},{\"internalType\":\"contract IOracleProvider\",\"name\":\"oracle\",\"type\":\"address\"},{\"internalType\":\"UFixed18\",\"name\":\"maintenance\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"fundingFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"makerFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"takerFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"makerLimit\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"PackedFixed18\",\"name\":\"minRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"maxRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"targetRate\",\"type\":\"int128\"},{\"internalType\":\"PackedUFixed18\",\"name\":\"targetUtilization\",\"type\":\"uint128\"}],\"internalType\":\"struct JumpRateUtilizationCurve\",\"name\":\"utilizationCurve\",\"type\":\"tuple\"}],\"internalType\":\"struct IProduct.ProductInfo\",\"name\":\"productInfo\",\"type\":\"tuple\"}],\"name\":\"createProduct\",\"outputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"incentivizationFee\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"incentivizer\",\"outputs\":[{\"internalType\":\"contract IIncentivizer\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ICollateral\",\"name\":\"collateral_\",\"type\":\"address\"},{\"internalType\":\"contract IIncentivizer\",\"name\":\"incentivizer_\",\"type\":\"address\"},{\"internalType\":\"contract IBeacon\",\"name\":\"productBeacon_\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"isProduct\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"liquidationFee\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minCollateral\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minFundingFee\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"}],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"paused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pauser\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"}],\"name\":\"pendingOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"productBeacon\",\"outputs\":[{\"internalType\":\"contract IBeacon\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"programsPerProduct\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"protocolFee\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"treasury\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"}],\"name\":\"treasury\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"treasury\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ICollateral\",\"name\":\"newCollateral\",\"type\":\"address\"}],\"name\":\"updateCollateral\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"newPendingOwner\",\"type\":\"address\"}],\"name\":\"updateCoordinatorPendingOwner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"newTreasury\",\"type\":\"address\"}],\"name\":\"updateCoordinatorTreasury\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"newIncentivizationFee\",\"type\":\"uint256\"}],\"name\":\"updateIncentivizationFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IIncentivizer\",\"name\":\"newIncentivizer\",\"type\":\"address\"}],\"name\":\"updateIncentivizer\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"newLiquidationFee\",\"type\":\"uint256\"}],\"name\":\"updateLiquidationFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"newMinCollateral\",\"type\":\"uint256\"}],\"name\":\"updateMinCollateral\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"newMinFundingFee\",\"type\":\"uint256\"}],\"name\":\"updateMinFundingFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"newPaused\",\"type\":\"bool\"}],\"name\":\"updatePaused\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newPauser\",\"type\":\"address\"}],\"name\":\"updatePauser\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IBeacon\",\"name\":\"newProductBeacon\",\"type\":\"address\"}],\"name\":\"updateProductBeacon\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newProgramsPerProduct\",\"type\":\"uint256\"}],\"name\":\"updateProgramsPerProduct\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"newProtocolFee\",\"type\":\"uint256\"}],\"name\":\"updateProtocolFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"acceptCoordinatorOwner(uint256)\":{\"details\":\"Must be called by the coordinator's pending owner\",\"params\":{\"coordinatorId\":\"Coordinator to update\"}},\"coordinators(uint256)\":{\"params\":{\"coordinatorId\":\"Coordinator to return for\"},\"returns\":{\"_0\":\"Coordinator state\"}},\"createCoordinator()\":{\"details\":\"Can only be called by the protocol owner\",\"returns\":{\"_0\":\"New coordinator ID\"}},\"createProduct(uint256,(string,string,(uint8,uint8,bytes30),address,uint256,uint256,uint256,uint256,uint256,(int128,int128,int128,uint128)))\":{\"details\":\"Can only be called by the coordinator owner\",\"params\":{\"coordinatorId\":\"Coordinator that will own the product\",\"productInfo\":\"Product params used to initialize the product\"},\"returns\":{\"_0\":\"New product contract address\"}},\"initialize(address,address,address)\":{\"details\":\"Must be called atomically as part of the upgradeable proxy deployment to avoid front-running\",\"params\":{\"collateral_\":\"Collateral contract address\",\"incentivizer_\":\"Incentivizer contract address\",\"productBeacon_\":\"Product implementation beacon address\"}},\"isProduct(address)\":{\"params\":{\"product\":\"Contract address to check\"},\"returns\":{\"_0\":\"Whether a contract is a product\"}},\"owner()\":{\"returns\":{\"_0\":\"Owner of the protocol\"}},\"owner(address)\":{\"params\":{\"product\":\"Product to return for\"},\"returns\":{\"_0\":\"Owner of the product\"}},\"owner(uint256)\":{\"params\":{\"coordinatorId\":\"Coordinator to return for\"},\"returns\":{\"_0\":\"Owner of the coordinator\"}},\"pendingOwner()\":{\"returns\":{\"_0\":\"Owner of the protocol\"}},\"pendingOwner(uint256)\":{\"params\":{\"coordinatorId\":\"Coordinator to return for\"},\"returns\":{\"_0\":\"Pending owner of the coordinator\"}},\"treasury()\":{\"details\":\"Defaults to the `owner` when `treasury` is unset\",\"returns\":{\"_0\":\"Treasury of the protocol\"}},\"treasury(address)\":{\"details\":\"Defaults to the `owner` when `treasury` is unset\",\"params\":{\"product\":\"Product to return for\"},\"returns\":{\"_0\":\"Treasury of the product\"}},\"treasury(uint256)\":{\"details\":\"Defaults to the `owner` when `treasury` is unset\",\"params\":{\"coordinatorId\":\"Coordinator to return for\"},\"returns\":{\"_0\":\"Treasury of the coordinator\"}},\"updateCollateral(address)\":{\"params\":{\"newCollateral\":\"New Collateral contract address\"}},\"updateCoordinatorPendingOwner(uint256,address)\":{\"details\":\"Must be called by the coordinator's current owner\",\"params\":{\"coordinatorId\":\"Coordinator to update\",\"newPendingOwner\":\"New pending owner address\"}},\"updateCoordinatorTreasury(uint256,address)\":{\"details\":\"Must be called by the coordinator's current owner. Defaults to the coordinator `owner` if set to address(0)\",\"params\":{\"coordinatorId\":\"Coordinator to update\",\"newTreasury\":\"New treasury address\"}},\"updateIncentivizationFee(uint256)\":{\"params\":{\"newIncentivizationFee\":\"New incentivization fee\"}},\"updateIncentivizer(address)\":{\"params\":{\"newIncentivizer\":\"New Incentivizer contract address\"}},\"updateLiquidationFee(uint256)\":{\"params\":{\"newLiquidationFee\":\"New liquidation fee\"}},\"updateMinCollateral(uint256)\":{\"params\":{\"newMinCollateral\":\"New minimum allowed collateral amount\"}},\"updateMinFundingFee(uint256)\":{\"params\":{\"newMinFundingFee\":\"New minimum allowed funding fee\"}},\"updatePaused(bool)\":{\"params\":{\"newPaused\":\"New protocol paused state\"}},\"updatePauser(address)\":{\"params\":{\"newPauser\":\"New protocol pauser address\"}},\"updateProductBeacon(address)\":{\"params\":{\"newProductBeacon\":\"New Product implementation beacon address\"}},\"updateProgramsPerProduct(uint256)\":{\"params\":{\"newProgramsPerProduct\":\"New maximum incentivization programs per product allowed\"}},\"updateProtocolFee(uint256)\":{\"params\":{\"newProtocolFee\":\"New protocol-product fee split\"}}},\"stateVariables\":{\"_collateral\":{\"details\":\"Collateral contract address for the protocol\"},\"_coordinators\":{\"details\":\"List of product coordinators\"},\"_incentivizationFee\":{\"details\":\"Fee on incentivization programs\"},\"_incentivizer\":{\"details\":\"Incentivizer contract address for the protocol\"},\"_liquidationFee\":{\"details\":\"Fee on maintenance for liquidation\"},\"_minCollateral\":{\"details\":\"Minimum allowable collateral amount per user account\"},\"_minFundingFee\":{\"details\":\"Minimum allowable funding fee for a product\"},\"_paused\":{\"details\":\"The paused status of the protocol\"},\"_pauser\":{\"details\":\"Protocol pauser address. address(0) defaults to owner(0)\"},\"_productBeacon\":{\"details\":\"Product implementation beacon address for the protocol\"},\"_programsPerProduct\":{\"details\":\"Maximum incentivization programs per product allowed\"},\"_protocolFee\":{\"details\":\"Percent of collected fees that go to the protocol treasury vs the product treasury\"},\"coordinatorFor\":{\"details\":\"Mapping of the coordinator for each product\"}},\"title\":\"Controller\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"acceptCoordinatorOwner(uint256)\":{\"notice\":\"Accepts ownership over an existing coordinator\"},\"coordinators(uint256)\":{\"notice\":\"Returns coordinator state for coordinator `coordinatorId`\"},\"createCoordinator()\":{\"notice\":\"Creates a new coordinator with `msg.sender` as the owner\"},\"createProduct(uint256,(string,string,(uint8,uint8,bytes30),address,uint256,uint256,uint256,uint256,uint256,(int128,int128,int128,uint128)))\":{\"notice\":\"Creates a new product market with `provider`\"},\"initialize(address,address,address)\":{\"notice\":\"Initializes the contract state\"},\"isProduct(address)\":{\"notice\":\"Returns whether a contract is a product\"},\"owner()\":{\"notice\":\"Returns the owner of the protocol\"},\"owner(address)\":{\"notice\":\"Returns the owner of the product `product`\"},\"owner(uint256)\":{\"notice\":\"Returns the owner of the coordinator `coordinatorId`\"},\"pendingOwner()\":{\"notice\":\"Returns the pending owner of the protocol\"},\"pendingOwner(uint256)\":{\"notice\":\"Returns the pending owner of the coordinator `coordinatorId`\"},\"treasury()\":{\"notice\":\"Returns the treasury of the protocol\"},\"treasury(address)\":{\"notice\":\"Returns the treasury of the product `product`\"},\"treasury(uint256)\":{\"notice\":\"Returns the treasury of the coordinator `coordinatorId`\"},\"updateCollateral(address)\":{\"notice\":\"Updates the Collateral contract address\"},\"updateCoordinatorPendingOwner(uint256,address)\":{\"notice\":\"Updates the pending owner of an existing coordinator\"},\"updateCoordinatorTreasury(uint256,address)\":{\"notice\":\"Updates the treasury of an existing coordinator\"},\"updateIncentivizationFee(uint256)\":{\"notice\":\"Updates the incentivization fee\"},\"updateIncentivizer(address)\":{\"notice\":\"Updates the Incentivizer contract address\"},\"updateLiquidationFee(uint256)\":{\"notice\":\"Updates the liquidation fee\"},\"updateMinCollateral(uint256)\":{\"notice\":\"Updates the minimum allowed collateral amount per user account\"},\"updateMinFundingFee(uint256)\":{\"notice\":\"Updates the minimum allowed funding fee\"},\"updatePaused(bool)\":{\"notice\":\"Updates the protocol paused state\"},\"updatePauser(address)\":{\"notice\":\"Updates the protocol pauser address. Zero address defaults to owner(0)\"},\"updateProductBeacon(address)\":{\"notice\":\"Updates the Product implementation beacon address\"},\"updateProgramsPerProduct(uint256)\":{\"notice\":\"Updates the maximum incentivization programs per product allowed\"},\"updateProtocolFee(uint256)\":{\"notice\":\"Updates the protocol-product fee split\"}},\"notice\":\"Manages creating new products and global protocol parameters.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/controller/Controller.sol\":\"Controller\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\n\\ninterface IOracleProvider {\\n /// @dev A singular oracle version with its corresponding data\\n struct OracleVersion {\\n /// @dev The iterative version\\n uint256 version;\\n\\n /// @dev the timestamp of the oracle update\\n uint256 timestamp;\\n\\n /// @dev The oracle price of the corresponding version\\n Fixed18 price;\\n }\\n\\n function sync() external returns (OracleVersion memory);\\n function currentVersion() external view returns (OracleVersion memory);\\n function atVersion(uint256 oracleVersion) external view returns (OracleVersion memory);\\n}\\n\",\"keccak256\":\"0xde0f20d468ba8b91addfc356e13f2c74a4dc8abe68be323942217c723775d9c1\",\"license\":\"Apache-2.0\"},\"@equilibria/root/control/unstructured/UInitializable.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/Address.sol\\\";\\nimport \\\"../../storage/UStorage.sol\\\";\\n\\n/**\\n * @title UInitializable\\n * @notice Library to manage the initialization lifecycle of upgradeable contracts\\n * @dev `UInitializable` allows the creation of pseudo-constructors for upgradeable contracts. One\\n * `initializer` should be declared per top-level contract. Child contracts can use the `onlyInitializer`\\n * modifier to tag their internal initialization functions to ensure that they can only be called\\n * from a top-level `initializer` or a constructor.\\n */\\nabstract contract UInitializable {\\n error UInitializableZeroVersionError();\\n error UInitializableAlreadyInitializedError(uint256 version);\\n error UInitializableNotInitializingError();\\n\\n event Initialized(uint256 version);\\n\\n /// @dev The initialized flag\\n Uint256Storage private constant _version = Uint256Storage.wrap(keccak256(\\\"equilibria.root.UInitializable.version\\\"));\\n\\n /// @dev The initializing flag\\n BoolStorage private constant _initializing = BoolStorage.wrap(keccak256(\\\"equilibria.root.UInitializable.initializing\\\"));\\n\\n /// @dev Can only be called once per version, `version` is 1-indexed\\n modifier initializer(uint256 version) {\\n if (version == 0) revert UInitializableZeroVersionError();\\n if (_version.read() >= version) revert UInitializableAlreadyInitializedError(version);\\n\\n _version.store(version);\\n _initializing.store(true);\\n\\n _;\\n\\n _initializing.store(false);\\n emit Initialized(version);\\n }\\n\\n /// @dev Can only be called from an initializer or constructor\\n modifier onlyInitializer() {\\n if (!_constructing() && !_initializing.read()) revert UInitializableNotInitializingError();\\n _;\\n }\\n\\n /**\\n * @notice Returns whether the contract is currently being constructed\\n * @dev {Address.isContract} returns false for contracts currently in the process of being constructed\\n * @return Whether the contract is currently being constructed\\n */\\n function _constructing() private view returns (bool) {\\n return !Address.isContract(address(this));\\n }\\n}\\n\",\"keccak256\":\"0xd2743d8fcc220ed2ccdc0bba1db0a3e107741bd5c0cac47ca8c0b5a00ba2fd7f\",\"license\":\"Apache-2.0\"},\"@equilibria/root/curve/CurveMath.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"../number/types/UFixed18.sol\\\";\\nimport \\\"../number/types/Fixed18.sol\\\";\\n\\n/**\\n * @title CurveMath\\n * @notice Library for managing math operations for utilization curves.\\n */\\nlibrary CurveMath {\\n error CurveMathOutOfBoundsError();\\n\\n /**\\n * @notice Computes a linear interpolation between two points\\n * @param startX First point's x-coordinate\\n * @param startY First point's y-coordinate\\n * @param endX Second point's x-coordinate\\n * @param endY Second point's y-coordinate\\n * @param targetX x-coordinate to interpolate\\n * @return y-coordinate for `targetX` along the line from (`startX`, `startY`) -> (`endX`, `endY`)\\n */\\n function linearInterpolation(\\n UFixed18 startX,\\n Fixed18 startY,\\n UFixed18 endX,\\n Fixed18 endY,\\n UFixed18 targetX\\n ) internal pure returns (Fixed18) {\\n if (targetX.lt(startX) || targetX.gt(endX)) revert CurveMathOutOfBoundsError();\\n\\n UFixed18 xRange = endX.sub(startX);\\n Fixed18 yRange = endY.sub(startY);\\n UFixed18 xRatio = targetX.sub(startX).div(xRange);\\n return yRange.mul(Fixed18Lib.from(xRatio)).add(startY);\\n }\\n}\\n\",\"keccak256\":\"0x60d159f9ddf0dbe81124ecad58bba734b4cf82877637ff8d9d7f3e92f2da4ded\",\"license\":\"Apache-2.0\"},\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"../CurveMath.sol\\\";\\nimport \\\"../../number/types/PackedUFixed18.sol\\\";\\nimport \\\"../../number/types/PackedFixed18.sol\\\";\\n\\n/// @dev JumpRateUtilizationCurve type\\nstruct JumpRateUtilizationCurve {\\n PackedFixed18 minRate;\\n PackedFixed18 maxRate;\\n PackedFixed18 targetRate;\\n PackedUFixed18 targetUtilization;\\n}\\nusing JumpRateUtilizationCurveLib for JumpRateUtilizationCurve global;\\ntype JumpRateUtilizationCurveStorage is bytes32;\\nusing JumpRateUtilizationCurveStorageLib for JumpRateUtilizationCurveStorage global;\\n\\n/**\\n * @title JumpRateUtilizationCurveLib\\n * @notice Library for the Jump Rate utilization curve type\\n */\\nlibrary JumpRateUtilizationCurveLib {\\n /**\\n * @notice Computes the corresponding rate for a utilization ratio\\n * @param utilization The utilization ratio\\n * @return The corresponding rate\\n */\\n function compute(JumpRateUtilizationCurve memory self, UFixed18 utilization) internal pure returns (Fixed18) {\\n UFixed18 targetUtilization = self.targetUtilization.unpack();\\n if (utilization.lt(targetUtilization)) {\\n return CurveMath.linearInterpolation(\\n UFixed18Lib.ZERO,\\n self.minRate.unpack(),\\n targetUtilization,\\n self.targetRate.unpack(),\\n utilization\\n );\\n }\\n if (utilization.lt(UFixed18Lib.ONE)) {\\n return CurveMath.linearInterpolation(\\n targetUtilization,\\n self.targetRate.unpack(),\\n UFixed18Lib.ONE,\\n self.maxRate.unpack(),\\n utilization\\n );\\n }\\n return self.maxRate.unpack();\\n }\\n}\\n\\nlibrary JumpRateUtilizationCurveStorageLib {\\n function read(JumpRateUtilizationCurveStorage self) internal view returns (JumpRateUtilizationCurve memory) {\\n return _storagePointer(self);\\n }\\n\\n function store(JumpRateUtilizationCurveStorage self, JumpRateUtilizationCurve memory value) internal {\\n JumpRateUtilizationCurve storage storagePointer = _storagePointer(self);\\n\\n storagePointer.minRate = value.minRate;\\n storagePointer.maxRate = value.maxRate;\\n storagePointer.targetRate = value.targetRate;\\n storagePointer.targetUtilization = value.targetUtilization;\\n }\\n\\n function _storagePointer(JumpRateUtilizationCurveStorage self)\\n private pure returns (JumpRateUtilizationCurve storage pointer) {\\n assembly { pointer.slot := self }\\n }\\n}\",\"keccak256\":\"0xae202813874bc306d51b3dab8194c86f6483bb20bf1f673ddaee16aa8de567ff\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/Fixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SignedMath.sol\\\";\\nimport \\\"./UFixed18.sol\\\";\\nimport \\\"./PackedFixed18.sol\\\";\\n\\n/// @dev Fixed18 type\\ntype Fixed18 is int256;\\nusing Fixed18Lib for Fixed18 global;\\ntype Fixed18Storage is bytes32;\\nusing Fixed18StorageLib for Fixed18Storage global;\\n\\n/**\\n * @title Fixed18Lib\\n * @notice Library for the signed fixed-decimal type.\\n */\\nlibrary Fixed18Lib {\\n error Fixed18OverflowError(uint256 value);\\n error Fixed18PackingOverflowError(int256 value);\\n error Fixed18PackingUnderflowError(int256 value);\\n\\n int256 private constant BASE = 1e18;\\n Fixed18 public constant ZERO = Fixed18.wrap(0);\\n Fixed18 public constant ONE = Fixed18.wrap(BASE);\\n Fixed18 public constant NEG_ONE = Fixed18.wrap(-1 * BASE);\\n Fixed18 public constant MAX = Fixed18.wrap(type(int256).max);\\n Fixed18 public constant MIN = Fixed18.wrap(type(int256).min);\\n\\n /**\\n * @notice Creates a signed fixed-decimal from an unsigned fixed-decimal\\n * @param a Unsigned fixed-decimal\\n * @return New signed fixed-decimal\\n */\\n function from(UFixed18 a) internal pure returns (Fixed18) {\\n uint256 value = UFixed18.unwrap(a);\\n if (value > uint256(type(int256).max)) revert Fixed18OverflowError(value);\\n return Fixed18.wrap(int256(value));\\n }\\n\\n /**\\n * @notice Creates a signed fixed-decimal from a sign and an unsigned fixed-decimal\\n * @param s Sign\\n * @param m Unsigned fixed-decimal magnitude\\n * @return New signed fixed-decimal\\n */\\n function from(int256 s, UFixed18 m) internal pure returns (Fixed18) {\\n if (s > 0) return from(m);\\n if (s < 0) return Fixed18.wrap(-1 * Fixed18.unwrap(from(m)));\\n return ZERO;\\n }\\n\\n /**\\n * @notice Creates a signed fixed-decimal from a signed integer\\n * @param a Signed number\\n * @return New signed fixed-decimal\\n */\\n function from(int256 a) internal pure returns (Fixed18) {\\n return Fixed18.wrap(a * BASE);\\n }\\n\\n /**\\n * @notice Creates a packed signed fixed-decimal from an signed fixed-decimal\\n * @param a signed fixed-decimal\\n * @return New packed signed fixed-decimal\\n */\\n function pack(Fixed18 a) internal pure returns (PackedFixed18) {\\n int256 value = Fixed18.unwrap(a);\\n if (value > type(int128).max) revert Fixed18PackingOverflowError(value);\\n if (value < type(int128).min) revert Fixed18PackingUnderflowError(value);\\n return PackedFixed18.wrap(int128(value));\\n }\\n\\n /**\\n * @notice Returns whether the signed fixed-decimal is equal to zero.\\n * @param a Signed fixed-decimal\\n * @return Whether the signed fixed-decimal is zero.\\n */\\n function isZero(Fixed18 a) internal pure returns (bool) {\\n return Fixed18.unwrap(a) == 0;\\n }\\n\\n /**\\n * @notice Adds two signed fixed-decimals `a` and `b` together\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Resulting summed signed fixed-decimal\\n */\\n function add(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) + Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Subtracts signed fixed-decimal `b` from `a`\\n * @param a Signed fixed-decimal to subtract from\\n * @param b Signed fixed-decimal to subtract\\n * @return Resulting subtracted signed fixed-decimal\\n */\\n function sub(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) - Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Multiplies two signed fixed-decimals `a` and `b` together\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Resulting multiplied signed fixed-decimal\\n */\\n function mul(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / BASE);\\n }\\n\\n /**\\n * @notice Divides signed fixed-decimal `a` by `b`\\n * @param a Signed fixed-decimal to divide\\n * @param b Signed fixed-decimal to divide by\\n * @return Resulting divided signed fixed-decimal\\n */\\n function div(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * BASE / Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0`, `MAX` for `n/0`, and `MIN` for `-n/0`.\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function unsafeDiv(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n if (isZero(b)) {\\n if (gt(a, ZERO)) return MAX;\\n if (lt(a, ZERO)) return MIN;\\n return ONE;\\n } else {\\n return div(a, b);\\n }\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First signed fixed-decimal\\n * @param b Signed number to multiply by\\n * @param c Signed number to divide by\\n * @return Resulting computation\\n */\\n function muldiv(Fixed18 a, int256 b, int256 c) internal pure returns (Fixed18) {\\n return muldiv(a, Fixed18.wrap(b), Fixed18.wrap(c));\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First signed fixed-decimal\\n * @param b Signed fixed-decimal to multiply by\\n * @param c Signed fixed-decimal to divide by\\n * @return Resulting computation\\n */\\n function muldiv(Fixed18 a, Fixed18 b, Fixed18 c) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / Fixed18.unwrap(c));\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is equal to `b`\\n */\\n function eq(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 1;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is greater than `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is greater than `b`\\n */\\n function gt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 2;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is less than `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is less than `b`\\n */\\n function lt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 0;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is greater than or equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is greater than or equal to `b`\\n */\\n function gte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return gt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is less than or equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is less than or equal to `b`\\n */\\n function lte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return lt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Compares the signed fixed-decimals `a` and `b`\\n * @dev Returns: 2 for greater than\\n * 1 for equal to\\n * 0 for less than\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Compare result of `a` and `b`\\n */\\n function compare(Fixed18 a, Fixed18 b) internal pure returns (uint256) {\\n (int256 au, int256 bu) = (Fixed18.unwrap(a), Fixed18.unwrap(b));\\n if (au > bu) return 2;\\n if (au < bu) return 0;\\n return 1;\\n }\\n\\n /**\\n * @notice Returns a signed fixed-decimal representing the ratio of `a` over `b`\\n * @param a First signed number\\n * @param b Second signed number\\n * @return Ratio of `a` over `b`\\n */\\n function ratio(int256 a, int256 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(a * BASE / b);\\n }\\n\\n /**\\n * @notice Returns the minimum of signed fixed-decimals `a` and `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Minimum of `a` and `b`\\n */\\n function min(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(SignedMath.min(Fixed18.unwrap(a), Fixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Returns the maximum of signed fixed-decimals `a` and `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Maximum of `a` and `b`\\n */\\n function max(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(SignedMath.max(Fixed18.unwrap(a), Fixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Converts the signed fixed-decimal into an integer, truncating any decimal portion\\n * @param a Signed fixed-decimal\\n * @return Truncated signed number\\n */\\n function truncate(Fixed18 a) internal pure returns (int256) {\\n return Fixed18.unwrap(a) / BASE;\\n }\\n\\n /**\\n * @notice Returns the sign of the signed fixed-decimal\\n * @dev Returns: -1 for negative\\n * 0 for zero\\n * 1 for positive\\n * @param a Signed fixed-decimal\\n * @return Sign of the signed fixed-decimal\\n */\\n function sign(Fixed18 a) internal pure returns (int256) {\\n if (Fixed18.unwrap(a) > 0) return 1;\\n if (Fixed18.unwrap(a) < 0) return -1;\\n return 0;\\n }\\n\\n /**\\n * @notice Returns the absolute value of the signed fixed-decimal\\n * @param a Signed fixed-decimal\\n * @return Absolute value of the signed fixed-decimal\\n */\\n function abs(Fixed18 a) internal pure returns (UFixed18) {\\n return UFixed18.wrap(SignedMath.abs(Fixed18.unwrap(a)));\\n }\\n}\\n\\nlibrary Fixed18StorageLib {\\n function read(Fixed18Storage self) internal view returns (Fixed18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(Fixed18Storage self, Fixed18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x613587461ef3437ef33229cdda7d34ea746278721baf06e20b2e43977f43174d\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/PackedFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"./Fixed18.sol\\\";\\n\\n/// @dev PackedFixed18 type\\ntype PackedFixed18 is int128;\\nusing PackedFixed18Lib for PackedFixed18 global;\\n\\n/**\\n * @title PackedFixed18Lib\\n * @dev A packed version of the Fixed18 which takes up half the storage space (two PackedFixed18 can be packed\\n * into a single slot). Only valid within the range -1.7014118e+20 <= x <= 1.7014118e+20.\\n * @notice Library for the packed signed fixed-decimal type.\\n */\\nlibrary PackedFixed18Lib {\\n PackedFixed18 public constant MAX = PackedFixed18.wrap(type(int128).max);\\n PackedFixed18 public constant MIN = PackedFixed18.wrap(type(int128).min);\\n\\n /**\\n * @notice Creates an unpacked signed fixed-decimal from a packed signed fixed-decimal\\n * @param self packed signed fixed-decimal\\n * @return New unpacked signed fixed-decimal\\n */\\n function unpack(PackedFixed18 self) internal pure returns (Fixed18) {\\n return Fixed18.wrap(int256(PackedFixed18.unwrap(self)));\\n }\\n}\\n\",\"keccak256\":\"0xb52960cc8e3132e45d342bbbb1c6a96219022cd8557997933bd8250170268b64\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/PackedUFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"./UFixed18.sol\\\";\\n\\n/// @dev PackedUFixed18 type\\ntype PackedUFixed18 is uint128;\\nusing PackedUFixed18Lib for PackedUFixed18 global;\\n\\n/**\\n * @title PackedUFixed18Lib\\n * @dev A packed version of the UFixed18 which takes up half the storage space (two PackedUFixed18 can be packed\\n * into a single slot). Only valid within the range 0 <= x <= 3.4028237e+20.\\n * @notice Library for the packed unsigned fixed-decimal type.\\n */\\nlibrary PackedUFixed18Lib {\\n PackedUFixed18 public constant MAX = PackedUFixed18.wrap(type(uint128).max);\\n\\n /**\\n * @notice Creates an unpacked unsigned fixed-decimal from a packed unsigned fixed-decimal\\n * @param self packed unsigned fixed-decimal\\n * @return New unpacked unsigned fixed-decimal\\n */\\n function unpack(PackedUFixed18 self) internal pure returns (UFixed18) {\\n return UFixed18.wrap(uint256(PackedUFixed18.unwrap(self)));\\n }\\n}\\n\",\"keccak256\":\"0xb5c5cd32d6530b2fe75228b6be32ebcb7762f6d7988b85a6b85a289ce8256d51\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/UFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"./Fixed18.sol\\\";\\nimport \\\"./PackedUFixed18.sol\\\";\\n\\n/// @dev UFixed18 type\\ntype UFixed18 is uint256;\\nusing UFixed18Lib for UFixed18 global;\\ntype UFixed18Storage is bytes32;\\nusing UFixed18StorageLib for UFixed18Storage global;\\n\\n/**\\n * @title UFixed18Lib\\n * @notice Library for the unsigned fixed-decimal type.\\n */\\nlibrary UFixed18Lib {\\n error UFixed18UnderflowError(int256 value);\\n error UFixed18PackingOverflowError(uint256 value);\\n\\n uint256 private constant BASE = 1e18;\\n UFixed18 public constant ZERO = UFixed18.wrap(0);\\n UFixed18 public constant ONE = UFixed18.wrap(BASE);\\n UFixed18 public constant MAX = UFixed18.wrap(type(uint256).max);\\n\\n /**\\n * @notice Creates a unsigned fixed-decimal from a signed fixed-decimal\\n * @param a Signed fixed-decimal\\n * @return New unsigned fixed-decimal\\n */\\n function from(Fixed18 a) internal pure returns (UFixed18) {\\n int256 value = Fixed18.unwrap(a);\\n if (value < 0) revert UFixed18UnderflowError(value);\\n return UFixed18.wrap(uint256(value));\\n }\\n\\n /**\\n * @notice Creates a unsigned fixed-decimal from a unsigned integer\\n * @param a Unsigned number\\n * @return New unsigned fixed-decimal\\n */\\n function from(uint256 a) internal pure returns (UFixed18) {\\n return UFixed18.wrap(a * BASE);\\n }\\n\\n /**\\n * @notice Creates a packed unsigned fixed-decimal from an unsigned fixed-decimal\\n * @param a unsigned fixed-decimal\\n * @return New packed unsigned fixed-decimal\\n */\\n function pack(UFixed18 a) internal pure returns (PackedUFixed18) {\\n uint256 value = UFixed18.unwrap(a);\\n if (value > type(uint128).max) revert UFixed18PackingOverflowError(value);\\n return PackedUFixed18.wrap(uint128(value));\\n }\\n\\n /**\\n * @notice Returns whether the unsigned fixed-decimal is equal to zero.\\n * @param a Unsigned fixed-decimal\\n * @return Whether the unsigned fixed-decimal is zero.\\n */\\n function isZero(UFixed18 a) internal pure returns (bool) {\\n return UFixed18.unwrap(a) == 0;\\n }\\n\\n /**\\n * @notice Adds two unsigned fixed-decimals `a` and `b` together\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Resulting summed unsigned fixed-decimal\\n */\\n function add(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) + UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Subtracts unsigned fixed-decimal `b` from `a`\\n * @param a Unsigned fixed-decimal to subtract from\\n * @param b Unsigned fixed-decimal to subtract\\n * @return Resulting subtracted unsigned fixed-decimal\\n */\\n function sub(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) - UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Multiplies two unsigned fixed-decimals `a` and `b` together\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Resulting multiplied unsigned fixed-decimal\\n */\\n function mul(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / BASE);\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function div(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * BASE / UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0` and `MAX` for `n/0`.\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function unsafeDiv(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n if (isZero(b)) {\\n return isZero(a) ? ONE : MAX;\\n } else {\\n return div(a, b);\\n }\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First unsigned fixed-decimal\\n * @param b Unsigned number to multiply by\\n * @param c Unsigned number to divide by\\n * @return Resulting computation\\n */\\n function muldiv(UFixed18 a, uint256 b, uint256 c) internal pure returns (UFixed18) {\\n return muldiv(a, UFixed18.wrap(b), UFixed18.wrap(c));\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First unsigned fixed-decimal\\n * @param b Unsigned fixed-decimal to multiply by\\n * @param c Unsigned fixed-decimal to divide by\\n * @return Resulting computation\\n */\\n function muldiv(UFixed18 a, UFixed18 b, UFixed18 c) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / UFixed18.unwrap(c));\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is equal to `b`\\n */\\n function eq(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 1;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is greater than `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is greater than `b`\\n */\\n function gt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 2;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is less than `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is less than `b`\\n */\\n function lt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 0;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is greater than or equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is greater than or equal to `b`\\n */\\n function gte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return gt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is less than or equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is less than or equal to `b`\\n */\\n function lte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return lt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Compares the unsigned fixed-decimals `a` and `b`\\n * @dev Returns: 2 for greater than\\n * 1 for equal to\\n * 0 for less than\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Compare result of `a` and `b`\\n */\\n function compare(UFixed18 a, UFixed18 b) internal pure returns (uint256) {\\n (uint256 au, uint256 bu) = (UFixed18.unwrap(a), UFixed18.unwrap(b));\\n if (au > bu) return 2;\\n if (au < bu) return 0;\\n return 1;\\n }\\n\\n /**\\n * @notice Returns a unsigned fixed-decimal representing the ratio of `a` over `b`\\n * @param a First unsigned number\\n * @param b Second unsigned number\\n * @return Ratio of `a` over `b`\\n */\\n function ratio(uint256 a, uint256 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(a * BASE / b);\\n }\\n\\n /**\\n * @notice Returns the minimum of unsigned fixed-decimals `a` and `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Minimum of `a` and `b`\\n */\\n function min(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(Math.min(UFixed18.unwrap(a), UFixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Returns the maximum of unsigned fixed-decimals `a` and `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Maximum of `a` and `b`\\n */\\n function max(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(Math.max(UFixed18.unwrap(a), UFixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Converts the unsigned fixed-decimal into an integer, truncating any decimal portion\\n * @param a Unsigned fixed-decimal\\n * @return Truncated unsigned number\\n */\\n function truncate(UFixed18 a) internal pure returns (uint256) {\\n return UFixed18.unwrap(a) / BASE;\\n }\\n}\\n\\nlibrary UFixed18StorageLib {\\n function read(UFixed18Storage self) internal view returns (UFixed18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(UFixed18Storage self, UFixed18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x8ebef1e6c717f565b9ed545a876b5692b4007e6485c99f39d363f7405e591792\",\"license\":\"Apache-2.0\"},\"@equilibria/root/storage/UStorage.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"../number/types/UFixed18.sol\\\";\\n\\n/// @dev Stored boolean slot\\ntype BoolStorage is bytes32;\\nusing BoolStorageLib for BoolStorage global;\\n\\n/// @dev Stored uint256 slot\\ntype Uint256Storage is bytes32;\\nusing Uint256StorageLib for Uint256Storage global;\\n\\n/// @dev Stored int256 slot\\ntype Int256Storage is bytes32;\\nusing Int256StorageLib for Int256Storage global;\\n\\n/// @dev Stored address slot\\ntype AddressStorage is bytes32;\\nusing AddressStorageLib for AddressStorage global;\\n\\n/// @dev Stored bytes32 slot\\ntype Bytes32Storage is bytes32;\\nusing Bytes32StorageLib for Bytes32Storage global;\\n\\n/**\\n * @title BoolStorageLib\\n * @notice Library to manage storage and retrival of a boolean at a fixed storage slot\\n */\\nlibrary BoolStorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored bool value\\n */\\n function read(BoolStorage self) internal view returns (bool value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value boolean value to store\\n */\\n function store(BoolStorage self, bool value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\\n/**\\n * @title Uint256StorageLib\\n * @notice Library to manage storage and retrival of an uint256 at a fixed storage slot\\n */\\nlibrary Uint256StorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored uint256 value\\n */\\n function read(Uint256Storage self) internal view returns (uint256 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value uint256 value to store\\n */\\n function store(Uint256Storage self, uint256 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\\n/**\\n * @title Int256StorageLib\\n * @notice Library to manage storage and retrival of an int256 at a fixed storage slot\\n */\\nlibrary Int256StorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored int256 value\\n */\\n function read(Int256Storage self) internal view returns (int256 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value int256 value to store\\n */\\n function store(Int256Storage self, int256 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\\n/**\\n * @title AddressStorageLib\\n * @notice Library to manage storage and retrival of an address at a fixed storage slot\\n */\\nlibrary AddressStorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored address value\\n */\\n function read(AddressStorage self) internal view returns (address value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value address value to store\\n */\\n function store(AddressStorage self, address value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\\n/**\\n * @title Bytes32StorageLib\\n * @notice Library to manage storage and retrival of a bytes32 at a fixed storage slot\\n */\\nlibrary Bytes32StorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored bytes32 value\\n */\\n function read(Bytes32Storage self) internal view returns (bytes32 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value bytes32 value to store\\n */\\n function store(Bytes32Storage self, bytes32 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0xe2b8491d1b5aa93f7e059e1a8f156b0ab37fef9ed973be97a64f2eabfc2cc172\",\"license\":\"Apache-2.0\"},\"@equilibria/root/token/types/Token18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"../../number/types/UFixed18.sol\\\";\\n\\n/// @dev Token18\\ntype Token18 is address;\\nusing Token18Lib for Token18 global;\\ntype Token18Storage is bytes32;\\nusing Token18StorageLib for Token18Storage global;\\n\\n/**\\n * @title Token18Lib\\n * @notice Library to manage 18-decimal ERC20s that is compliant with the fixed-decimal types.\\n * @dev Maintains significant gas savings over other Token implementations since no conversion take place\\n */\\nlibrary Token18Lib {\\n using SafeERC20 for IERC20;\\n\\n Token18 public constant ZERO = Token18.wrap(address(0));\\n\\n /**\\n * @notice Returns whether a token is the zero address\\n * @param self Token to check for\\n * @return Whether the token is the zero address\\n */\\n function isZero(Token18 self) internal pure returns (bool) {\\n return Token18.unwrap(self) == Token18.unwrap(ZERO);\\n }\\n\\n /**\\n * @notice Returns whether the two tokens are equal\\n * @param a First token to compare\\n * @param b Second token to compare\\n * @return Whether the two tokens are equal\\n */\\n function eq(Token18 a, Token18 b) internal pure returns (bool) {\\n return Token18.unwrap(a) == Token18.unwrap(b);\\n }\\n\\n /**\\n * @notice Approves `grantee` to spend infinite tokens from the caller\\n * @param self Token to transfer\\n * @param grantee Address to allow spending\\n */\\n function approve(Token18 self, address grantee) internal {\\n IERC20(Token18.unwrap(self)).safeApprove(grantee, type(uint256).max);\\n }\\n\\n /**\\n * @notice Approves `grantee` to spend `amount` tokens from the caller\\n * @dev There are important race conditions to be aware of when using this function\\n with values other than 0. This will revert if moving from non-zero to non-zero amounts\\n See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/a55b7d13722e7ce850b626da2313f3e66ca1d101/contracts/token/ERC20/IERC20.sol#L57\\n * @param self Token to transfer\\n * @param grantee Address to allow spending\\n * @param amount Amount of tokens to approve to spend\\n */\\n function approve(Token18 self, address grantee, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeApprove(grantee, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers all held tokens from the caller to the `recipient`\\n * @param self Token to transfer\\n * @param recipient Address to receive the tokens\\n */\\n function push(Token18 self, address recipient) internal {\\n push(self, recipient, balanceOf(self, address(this)));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the caller to the `recipient`\\n * @param self Token to transfer\\n * @param recipient Address to transfer tokens to\\n * @param amount Amount of tokens to transfer\\n */\\n function push(Token18 self, address recipient, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransfer(recipient, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the `benefactor` to the caller\\n * @dev Reverts if trying to pull Ether\\n * @param self Token to transfer\\n * @param benefactor Address to transfer tokens from\\n * @param amount Amount of tokens to transfer\\n */\\n function pull(Token18 self, address benefactor, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, address(this), UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the `benefactor` to `recipient`\\n * @dev Reverts if trying to pull Ether\\n * @param self Token to transfer\\n * @param benefactor Address to transfer tokens from\\n * @param recipient Address to transfer tokens to\\n * @param amount Amount of tokens to transfer\\n */\\n function pullTo(Token18 self, address benefactor, address recipient, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, recipient, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Returns the name of the token\\n * @param self Token to check for\\n * @return Token name\\n */\\n function name(Token18 self) internal view returns (string memory) {\\n return IERC20Metadata(Token18.unwrap(self)).name();\\n }\\n\\n /**\\n * @notice Returns the symbol of the token\\n * @param self Token to check for\\n * @return Token symbol\\n */\\n function symbol(Token18 self) internal view returns (string memory) {\\n return IERC20Metadata(Token18.unwrap(self)).symbol();\\n }\\n\\n /**\\n * @notice Returns the `self` token balance of the caller\\n * @param self Token to check for\\n * @return Token balance of the caller\\n */\\n function balanceOf(Token18 self) internal view returns (UFixed18) {\\n return balanceOf(self, address(this));\\n }\\n\\n /**\\n * @notice Returns the `self` token balance of `account`\\n * @param self Token to check for\\n * @param account Account to check\\n * @return Token balance of the account\\n */\\n function balanceOf(Token18 self, address account) internal view returns (UFixed18) {\\n return UFixed18.wrap(IERC20(Token18.unwrap(self)).balanceOf(account));\\n }\\n}\\n\\nlibrary Token18StorageLib {\\n function read(Token18Storage self) internal view returns (Token18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(Token18Storage self, Token18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x6b12afaece814f0ab186200a4729e93eb685a21d3e9b5a3372ff283a7ad5dc23\",\"license\":\"Apache-2.0\"},\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/BeaconProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IBeacon.sol\\\";\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"../ERC1967/ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that gets the implementation address for each call from a {UpgradeableBeacon}.\\n *\\n * The beacon address is stored in storage slot `uint256(keccak256('eip1967.proxy.beacon')) - 1`, so that it doesn't\\n * conflict with the storage layout of the implementation behind the proxy.\\n *\\n * _Available since v3.4._\\n */\\ncontract BeaconProxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the proxy with `beacon`.\\n *\\n * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This\\n * will typically be an encoded function call, and allows initializating the storage of the proxy like a Solidity\\n * constructor.\\n *\\n * Requirements:\\n *\\n * - `beacon` must be a contract with the interface {IBeacon}.\\n */\\n constructor(address beacon, bytes memory data) payable {\\n assert(_BEACON_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.beacon\\\")) - 1));\\n _upgradeBeaconToAndCall(beacon, data, false);\\n }\\n\\n /**\\n * @dev Returns the current beacon address.\\n */\\n function _beacon() internal view virtual returns (address) {\\n return _getBeacon();\\n }\\n\\n /**\\n * @dev Returns the current implementation address of the associated beacon.\\n */\\n function _implementation() internal view virtual override returns (address) {\\n return IBeacon(_getBeacon()).implementation();\\n }\\n\\n /**\\n * @dev Changes the proxy to use a new beacon. Deprecated: see {_upgradeBeaconToAndCall}.\\n *\\n * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon.\\n *\\n * Requirements:\\n *\\n * - `beacon` must be a contract.\\n * - The implementation returned by `beacon` must be a contract.\\n */\\n function _setBeacon(address beacon, bytes memory data) internal virtual {\\n _upgradeBeaconToAndCall(beacon, data, false);\\n }\\n}\\n\",\"keccak256\":\"0x54878f0d2f40b5e13f84977bcd3c71d4c38581414e7efb4909cb16dd3ace392f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\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 amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` 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(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\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\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 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 using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\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 function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc3d946432c0ddbb1f846a0d3985be71299df331b91d06732152117f62f0be2b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // 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\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\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 ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\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(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\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 /**\\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 {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return 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 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 up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a / b + (a % b == 0 ? 0 : 1);\\n }\\n}\\n\",\"keccak256\":\"0xc995bddbca1ae19788db9f8b61e63385edd3fddf89693b612d5abd1a275974d2\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SignedMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/SignedMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard signed math utilities missing in the Solidity language.\\n */\\nlibrary SignedMath {\\n /**\\n * @dev Returns the largest of two signed numbers.\\n */\\n function max(int256 a, int256 b) internal pure returns (int256) {\\n return 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 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 // must be unchecked in order to support `n = type(int256).min`\\n return uint256(n >= 0 ? n : -n);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb3ebde1c8d27576db912d87c3560dab14adfb9cd001be95890ec4ba035e652e7\",\"license\":\"MIT\"},\"contracts/controller/Controller.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"@equilibria/root/control/unstructured/UInitializable.sol\\\";\\nimport \\\"@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol\\\";\\nimport \\\"../interfaces/IController.sol\\\";\\nimport \\\"../interfaces/ICollateral.sol\\\";\\nimport \\\"../interfaces/IIncentivizer.sol\\\";\\nimport \\\"../interfaces/IProduct.sol\\\";\\n\\n/**\\n * @title Controller\\n * @notice Manages creating new products and global protocol parameters.\\n */\\ncontract Controller is IController, UInitializable {\\n /// @dev Collateral contract address for the protocol\\n AddressStorage private constant _collateral = AddressStorage.wrap(keccak256(\\\"equilibria.perennial.Controller.collateral\\\"));\\n function collateral() public view returns (ICollateral) { return ICollateral(_collateral.read()); }\\n\\n /// @dev Incentivizer contract address for the protocol\\n AddressStorage private constant _incentivizer = AddressStorage.wrap(keccak256(\\\"equilibria.perennial.Controller.incentivizer\\\"));\\n function incentivizer() public view returns (IIncentivizer) { return IIncentivizer(_incentivizer.read()); }\\n\\n /// @dev Product implementation beacon address for the protocol\\n AddressStorage private constant _productBeacon = AddressStorage.wrap(keccak256(\\\"equilibria.perennial.Controller.productBeacon\\\"));\\n function productBeacon() public view returns (IBeacon) { return IBeacon(_productBeacon.read()); }\\n\\n /// @dev Percent of collected fees that go to the protocol treasury vs the product treasury\\n UFixed18Storage private constant _protocolFee = UFixed18Storage.wrap(keccak256(\\\"equilibria.perennial.Controller.protocolFee\\\"));\\n function protocolFee() public view returns (UFixed18) { return _protocolFee.read(); }\\n\\n /// @dev Minimum allowable funding fee for a product\\n UFixed18Storage private constant _minFundingFee = UFixed18Storage.wrap(keccak256(\\\"equilibria.perennial.Controller.minFundingFee\\\"));\\n function minFundingFee() public view returns (UFixed18) { return _minFundingFee.read(); }\\n\\n /// @dev Fee on maintenance for liquidation\\n UFixed18Storage private constant _liquidationFee = UFixed18Storage.wrap(keccak256(\\\"equilibria.perennial.Controller.liquidationFee\\\"));\\n function liquidationFee() public view returns (UFixed18) { return _liquidationFee.read(); }\\n\\n /// @dev Fee on incentivization programs\\n UFixed18Storage private constant _incentivizationFee = UFixed18Storage.wrap(keccak256(\\\"equilibria.perennial.Controller.incentivizationFee\\\"));\\n function incentivizationFee() public view returns (UFixed18) { return _incentivizationFee.read(); }\\n\\n /// @dev Minimum allowable collateral amount per user account\\n UFixed18Storage private constant _minCollateral = UFixed18Storage.wrap(keccak256(\\\"equilibria.perennial.Controller.minCollateral\\\"));\\n function minCollateral() public view returns (UFixed18) { return _minCollateral.read(); }\\n\\n /// @dev Maximum incentivization programs per product allowed\\n Uint256Storage private constant _programsPerProduct = Uint256Storage.wrap(keccak256(\\\"equilibria.perennial.Controller.programsPerProduct\\\"));\\n function programsPerProduct() public view returns (uint256) { return _programsPerProduct.read(); }\\n\\n /// @dev Protocol pauser address. address(0) defaults to owner(0)\\n AddressStorage private constant _pauser = AddressStorage.wrap(keccak256(\\\"equilibria.perennial.Controller.pauser\\\"));\\n function pauser() public view returns (address) {\\n address pauser_ = _pauser.read();\\n return pauser_ == address(0) ? owner() : pauser_;\\n }\\n\\n /// @dev The paused status of the protocol\\n BoolStorage private constant _paused = BoolStorage.wrap(keccak256(\\\"equilibria.perennial.Controller.paused\\\"));\\n function paused() public view returns (bool) { return _paused.read(); }\\n\\n /// @dev List of product coordinators\\n Coordinator[] private _coordinators;\\n\\n /// @dev Mapping of the coordinator for each product\\n mapping(IProduct => uint256) public coordinatorFor;\\n\\n /**\\n * @notice Initializes the contract state\\n * @dev Must be called atomically as part of the upgradeable proxy deployment to\\n * avoid front-running\\n * @param collateral_ Collateral contract address\\n * @param incentivizer_ Incentivizer contract address\\n * @param productBeacon_ Product implementation beacon address\\n */\\n function initialize(\\n ICollateral collateral_,\\n IIncentivizer incentivizer_,\\n IBeacon productBeacon_\\n ) external initializer(1) {\\n _createCoordinator();\\n\\n updateCollateral(collateral_);\\n updateIncentivizer(incentivizer_);\\n updateProductBeacon(productBeacon_);\\n }\\n\\n /**\\n * @notice Creates a new coordinator with `msg.sender` as the owner\\n * @dev Can only be called by the protocol owner\\n * @return New coordinator ID\\n */\\n function createCoordinator() external returns (uint256) {\\n return _createCoordinator();\\n }\\n\\n /**\\n * @notice Creates a new coordinator with `msg.sender` as the owner\\n * @dev `treasury` and `pauser` initialize as the 0-address, defaulting to the `owner`\\n * @return New coordinator ID\\n */\\n function _createCoordinator() private returns (uint256) {\\n uint256 coordinatorId = _coordinators.length;\\n\\n _coordinators.push(Coordinator({\\n pendingOwner: address(0),\\n owner: msg.sender,\\n treasury: address(0)\\n }));\\n\\n emit CoordinatorCreated(coordinatorId, msg.sender);\\n\\n return coordinatorId;\\n }\\n\\n /**\\n * @notice Updates the pending owner of an existing coordinator\\n * @dev Must be called by the coordinator's current owner\\n * @param coordinatorId Coordinator to update\\n * @param newPendingOwner New pending owner address\\n */\\n function updateCoordinatorPendingOwner(uint256 coordinatorId, address newPendingOwner) external onlyOwner(coordinatorId) {\\n _coordinators[coordinatorId].pendingOwner = newPendingOwner;\\n emit CoordinatorPendingOwnerUpdated(coordinatorId, newPendingOwner);\\n }\\n\\n /**\\n * @notice Accepts ownership over an existing coordinator\\n * @dev Must be called by the coordinator's pending owner\\n * @param coordinatorId Coordinator to update\\n */\\n function acceptCoordinatorOwner(uint256 coordinatorId) external {\\n Coordinator storage coordinator = _coordinators[coordinatorId];\\n address newPendingOwner = coordinator.pendingOwner;\\n\\n if (msg.sender != newPendingOwner) revert ControllerNotPendingOwnerError(coordinatorId);\\n\\n coordinator.pendingOwner = address(0);\\n coordinator.owner = newPendingOwner;\\n emit CoordinatorOwnerUpdated(coordinatorId, newPendingOwner);\\n }\\n\\n /**\\n * @notice Updates the treasury of an existing coordinator\\n * @dev Must be called by the coordinator's current owner. Defaults to the coordinator `owner` if set to address(0)\\n * @param coordinatorId Coordinator to update\\n * @param newTreasury New treasury address\\n */\\n function updateCoordinatorTreasury(uint256 coordinatorId, address newTreasury) external onlyOwner(coordinatorId) {\\n _coordinators[coordinatorId].treasury = newTreasury;\\n emit CoordinatorTreasuryUpdated(coordinatorId, newTreasury);\\n }\\n\\n /**\\n * @notice Creates a new product market with `provider`\\n * @dev Can only be called by the coordinator owner\\n * @param coordinatorId Coordinator that will own the product\\n * @param productInfo Product params used to initialize the product\\n * @return New product contract address\\n */\\n function createProduct(uint256 coordinatorId, IProduct.ProductInfo calldata productInfo)\\n external onlyOwner(coordinatorId) returns (IProduct) {\\n if (coordinatorId == 0) revert ControllerNoZeroCoordinatorError();\\n\\n BeaconProxy newProductProxy = new BeaconProxy(address(productBeacon()), abi.encodeCall(IProduct.initialize, productInfo));\\n IProduct newProduct = IProduct(address(newProductProxy));\\n coordinatorFor[newProduct] = coordinatorId;\\n emit ProductCreated(newProduct, productInfo);\\n\\n return newProduct;\\n }\\n\\n /**\\n * @notice Updates the Collateral contract address\\n * @param newCollateral New Collateral contract address\\n */\\n function updateCollateral(ICollateral newCollateral) public onlyOwner(0) {\\n if (!Address.isContract(address(newCollateral))) revert ControllerNotContractAddressError();\\n _collateral.store(address(newCollateral));\\n emit CollateralUpdated(newCollateral);\\n }\\n\\n /**\\n * @notice Updates the Incentivizer contract address\\n * @param newIncentivizer New Incentivizer contract address\\n */\\n function updateIncentivizer(IIncentivizer newIncentivizer) public onlyOwner(0) {\\n if (!Address.isContract(address(newIncentivizer))) revert ControllerNotContractAddressError();\\n _incentivizer.store(address(newIncentivizer));\\n emit IncentivizerUpdated(newIncentivizer);\\n }\\n\\n /**\\n * @notice Updates the Product implementation beacon address\\n * @param newProductBeacon New Product implementation beacon address\\n */\\n function updateProductBeacon(IBeacon newProductBeacon) public onlyOwner(0) {\\n if (!Address.isContract(address(newProductBeacon))) revert ControllerNotContractAddressError();\\n _productBeacon.store(address(newProductBeacon));\\n emit ProductBeaconUpdated(newProductBeacon);\\n }\\n\\n /**\\n * @notice Updates the protocol-product fee split\\n * @param newProtocolFee New protocol-product fee split\\n */\\n function updateProtocolFee(UFixed18 newProtocolFee) public onlyOwner(0) {\\n if (newProtocolFee.gt(UFixed18Lib.ONE)) revert ControllerInvalidProtocolFeeError();\\n\\n _protocolFee.store(newProtocolFee);\\n emit ProtocolFeeUpdated(newProtocolFee);\\n }\\n\\n /**\\n * @notice Updates the minimum allowed funding fee\\n * @param newMinFundingFee New minimum allowed funding fee\\n */\\n function updateMinFundingFee(UFixed18 newMinFundingFee) public onlyOwner(0) {\\n if (newMinFundingFee.gt(UFixed18Lib.ONE)) revert ControllerInvalidMinFundingFeeError();\\n\\n _minFundingFee.store(newMinFundingFee);\\n emit MinFundingFeeUpdated(newMinFundingFee);\\n }\\n\\n /**\\n * @notice Updates the liquidation fee\\n * @param newLiquidationFee New liquidation fee\\n */\\n function updateLiquidationFee(UFixed18 newLiquidationFee) public onlyOwner(0) {\\n if (newLiquidationFee.gt(UFixed18Lib.ONE)) revert ControllerInvalidLiquidationFeeError();\\n\\n _liquidationFee.store(newLiquidationFee);\\n emit LiquidationFeeUpdated(newLiquidationFee);\\n }\\n\\n /**\\n * @notice Updates the incentivization fee\\n * @param newIncentivizationFee New incentivization fee\\n */\\n function updateIncentivizationFee(UFixed18 newIncentivizationFee) public onlyOwner(0) {\\n if (newIncentivizationFee.gt(UFixed18Lib.ONE)) revert ControllerInvalidIncentivizationFeeError();\\n\\n _incentivizationFee.store(newIncentivizationFee);\\n emit IncentivizationFeeUpdated(newIncentivizationFee);\\n }\\n\\n /**\\n * @notice Updates the minimum allowed collateral amount per user account\\n * @param newMinCollateral New minimum allowed collateral amount\\n */\\n function updateMinCollateral(UFixed18 newMinCollateral) public onlyOwner(0) {\\n _minCollateral.store(newMinCollateral);\\n emit MinCollateralUpdated(newMinCollateral);\\n }\\n\\n /**\\n * @notice Updates the maximum incentivization programs per product allowed\\n * @param newProgramsPerProduct New maximum incentivization programs per product allowed\\n */\\n function updateProgramsPerProduct(uint256 newProgramsPerProduct) public onlyOwner(0) {\\n _programsPerProduct.store(newProgramsPerProduct);\\n emit ProgramsPerProductUpdated(newProgramsPerProduct);\\n }\\n\\n /**\\n * @notice Updates the protocol pauser address. Zero address defaults to owner(0)\\n * @param newPauser New protocol pauser address\\n */\\n function updatePauser(address newPauser) public onlyOwner(0) {\\n _pauser.store(newPauser);\\n emit PauserUpdated(newPauser);\\n }\\n\\n /**\\n * @notice Updates the protocol paused state\\n * @param newPaused New protocol paused state\\n */\\n function updatePaused(bool newPaused) public onlyPauser {\\n _paused.store(newPaused);\\n emit PausedUpdated(newPaused);\\n }\\n\\n /**\\n * @notice Returns whether a contract is a product\\n * @param product Contract address to check\\n * @return Whether a contract is a product\\n */\\n function isProduct(IProduct product) external view returns (bool) {\\n return coordinatorFor[product] != 0;\\n }\\n\\n /**\\n * @notice Returns coordinator state for coordinator `coordinatorId`\\n * @param coordinatorId Coordinator to return for\\n * @return Coordinator state\\n */\\n function coordinators(uint256 coordinatorId) external view returns (Coordinator memory) {\\n return _coordinators[coordinatorId];\\n }\\n\\n /**\\n * @notice Returns the pending owner of the protocol\\n * @return Owner of the protocol\\n */\\n function pendingOwner() public view returns (address) {\\n return pendingOwner(0);\\n }\\n\\n /**\\n * @notice Returns the pending owner of the coordinator `coordinatorId`\\n * @param coordinatorId Coordinator to return for\\n * @return Pending owner of the coordinator\\n */\\n function pendingOwner(uint256 coordinatorId) public view returns (address) {\\n return _coordinators[coordinatorId].pendingOwner;\\n }\\n\\n /**\\n * @notice Returns the owner of the protocol\\n * @return Owner of the protocol\\n */\\n function owner() public view returns (address) {\\n return owner(0);\\n }\\n\\n /**\\n * @notice Returns the owner of the coordinator `coordinatorId`\\n * @param coordinatorId Coordinator to return for\\n * @return Owner of the coordinator\\n */\\n function owner(uint256 coordinatorId) public view returns (address) {\\n return _coordinators[coordinatorId].owner;\\n }\\n\\n /**\\n * @notice Returns the owner of the product `product`\\n * @param product Product to return for\\n * @return Owner of the product\\n */\\n function owner(IProduct product) external view returns (address) {\\n return owner(coordinatorFor[product]);\\n }\\n\\n /**\\n * @notice Returns the treasury of the protocol\\n * @dev Defaults to the `owner` when `treasury` is unset\\n * @return Treasury of the protocol\\n */\\n function treasury() external view returns (address) {\\n return treasury(0);\\n }\\n\\n /**\\n * @notice Returns the treasury of the coordinator `coordinatorId`\\n * @dev Defaults to the `owner` when `treasury` is unset\\n * @param coordinatorId Coordinator to return for\\n * @return Treasury of the coordinator\\n */\\n function treasury(uint256 coordinatorId) public view returns (address) {\\n address _treasury = _coordinators[coordinatorId].treasury;\\n return _treasury == address(0) ? owner(coordinatorId) : _treasury;\\n }\\n\\n /**\\n * @notice Returns the treasury of the product `product`\\n * @dev Defaults to the `owner` when `treasury` is unset\\n * @param product Product to return for\\n * @return Treasury of the product\\n */\\n function treasury(IProduct product) external view returns (address) {\\n return treasury(coordinatorFor[product]);\\n }\\n\\n /// @dev Only allow owner of `coordinatorId` to call\\n modifier onlyOwner(uint256 coordinatorId) {\\n if (msg.sender != owner(coordinatorId)) revert ControllerNotOwnerError(coordinatorId);\\n\\n _;\\n }\\n\\n /// @dev Only allow the pauser to call\\n modifier onlyPauser {\\n if (msg.sender != pauser()) revert ControllerNotPauserError();\\n\\n _;\\n }\\n}\\n\",\"keccak256\":\"0x40cde49450e3c3e476490d5eddd34e5ad96956de89e7a18cfa900da5ab5696d4\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/ICollateral.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"./IController.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\n\\ninterface ICollateral {\\n event Deposit(address indexed user, IProduct indexed product, UFixed18 amount);\\n event Withdrawal(address indexed user, IProduct indexed product, UFixed18 amount);\\n event AccountSettle(IProduct indexed product, address indexed account, Fixed18 amount, UFixed18 newShortfall);\\n event ProductSettle(IProduct indexed product, UFixed18 protocolFee, UFixed18 productFee);\\n event Liquidation(address indexed user, IProduct indexed product, address liquidator, UFixed18 fee);\\n event ShortfallResolution(IProduct indexed product, UFixed18 amount);\\n event FeeClaim(address indexed account, UFixed18 amount);\\n\\n error CollateralCantLiquidate(UFixed18 totalMaintenance, UFixed18 totalCollateral);\\n error CollateralInsufficientCollateralError();\\n error CollateralUnderLimitError();\\n error CollateralZeroAddressError();\\n\\n function token() external view returns (Token18);\\n function fees(address account) external view returns (UFixed18);\\n function initialize(IController controller_) external;\\n function depositTo(address account, IProduct product, UFixed18 amount) external;\\n function withdrawTo(address account, IProduct product, UFixed18 amount) external;\\n function liquidate(address account, IProduct product) external;\\n function settleAccount(address account, Fixed18 amount) external;\\n function settleProduct(UFixed18 amount) external;\\n function collateral(address account, IProduct product) external view returns (UFixed18);\\n function collateral(IProduct product) external view returns (UFixed18);\\n function shortfall(IProduct product) external view returns (UFixed18);\\n function liquidatable(address account, IProduct product) external view returns (bool);\\n function liquidatableNext(address account, IProduct product) external view returns (bool);\\n function resolveShortfall(IProduct product, UFixed18 amount) external;\\n function claimFee() external;\\n}\\n\",\"keccak256\":\"0xa5e7fdda92702f748e6eb8701e522450035a98a05e5fc1cf66d51c52e397d914\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IContractPayoffProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\n\\ninterface IContractPayoffProvider {\\n function payoff(Fixed18 price) external view returns (Fixed18 payoff);\\n}\\n\",\"keccak256\":\"0xd73df106d032e976fd959ee6713240e36f54277ce5f215eaec8d5a2c6720a86b\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IController.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\\\";\\nimport \\\"./ICollateral.sol\\\";\\nimport \\\"./IIncentivizer.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\n\\ninterface IController {\\n /// @dev Coordinator of a one or many products\\n struct Coordinator {\\n /// @dev Pending owner of the product, can accept ownership\\n address pendingOwner;\\n\\n /// @dev Owner of the product, allowed to update select parameters\\n address owner;\\n\\n /// @dev Treasury of the product, collects fees\\n address treasury;\\n }\\n\\n event CollateralUpdated(ICollateral newCollateral);\\n event IncentivizerUpdated(IIncentivizer newIncentivizer);\\n event ProductBeaconUpdated(IBeacon newProductBeacon);\\n event ProtocolFeeUpdated(UFixed18 newProtocolFee);\\n event MinFundingFeeUpdated(UFixed18 newMinFundingFee);\\n event LiquidationFeeUpdated(UFixed18 newLiquidationFee);\\n event IncentivizationFeeUpdated(UFixed18 newIncentivizationFee);\\n event MinCollateralUpdated(UFixed18 newMinCollateral);\\n event ProgramsPerProductUpdated(uint256 newProgramsPerProduct);\\n event PauserUpdated(address newPauser);\\n event PausedUpdated(bool newPaused);\\n event CoordinatorPendingOwnerUpdated(uint256 indexed coordinatorId, address newPendingOwner);\\n event CoordinatorOwnerUpdated(uint256 indexed coordinatorId, address newOwner);\\n event CoordinatorTreasuryUpdated(uint256 indexed coordinatorId, address newTreasury);\\n event CoordinatorCreated(uint256 indexed coordinatorId, address owner);\\n event ProductCreated(IProduct indexed product, IProduct.ProductInfo productInfo);\\n\\n error ControllerNoZeroCoordinatorError();\\n error ControllerNotPauserError();\\n error ControllerNotOwnerError(uint256 controllerId);\\n error ControllerNotPendingOwnerError(uint256 controllerId);\\n error ControllerInvalidProtocolFeeError();\\n error ControllerInvalidMinFundingFeeError();\\n error ControllerInvalidLiquidationFeeError();\\n error ControllerInvalidIncentivizationFeeError();\\n error ControllerNotContractAddressError();\\n\\n function collateral() external view returns (ICollateral);\\n function incentivizer() external view returns (IIncentivizer);\\n function productBeacon() external view returns (IBeacon);\\n function coordinators(uint256 collateralId) external view returns (Coordinator memory);\\n function coordinatorFor(IProduct product) external view returns (uint256);\\n function protocolFee() external view returns (UFixed18);\\n function minFundingFee() external view returns (UFixed18);\\n function liquidationFee() external view returns (UFixed18);\\n function incentivizationFee() external view returns (UFixed18);\\n function minCollateral() external view returns (UFixed18);\\n function programsPerProduct() external view returns (uint256);\\n function pauser() external view returns (address);\\n function paused() external view returns (bool);\\n function initialize(ICollateral collateral_, IIncentivizer incentivizer_, IBeacon productBeacon_) external;\\n function createCoordinator() external returns (uint256);\\n function updateCoordinatorPendingOwner(uint256 coordinatorId, address newPendingOwner) external;\\n function acceptCoordinatorOwner(uint256 coordinatorId) external;\\n function updateCoordinatorTreasury(uint256 coordinatorId, address newTreasury) external;\\n function createProduct(uint256 coordinatorId, IProduct.ProductInfo calldata productInfo) external returns (IProduct);\\n function updateCollateral(ICollateral newCollateral) external;\\n function updateIncentivizer(IIncentivizer newIncentivizer) external;\\n function updateProductBeacon(IBeacon newProductBeacon) external;\\n function updateProtocolFee(UFixed18 newProtocolFee) external;\\n function updateMinFundingFee(UFixed18 newMinFundingFee) external;\\n function updateLiquidationFee(UFixed18 newLiquidationFee) external;\\n function updateIncentivizationFee(UFixed18 newIncentivizationFee) external;\\n function updateMinCollateral(UFixed18 newMinCollateral) external;\\n function updateProgramsPerProduct(uint256 newProductsPerProduct) external;\\n function updatePauser(address newPauser) external;\\n function updatePaused(bool newPaused) external;\\n function isProduct(IProduct product) external view returns (bool);\\n function owner() external view returns (address);\\n function owner(uint256 coordinatorId) external view returns (address);\\n function owner(IProduct product) external view returns (address);\\n function treasury() external view returns (address);\\n function treasury(uint256 coordinatorId) external view returns (address);\\n function treasury(IProduct product) external view returns (address);\\n}\\n\",\"keccak256\":\"0xaabd3740f2265499eea7aad9bd94f9892f53241e5dccce9a50c0e43ed2a6a7cc\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IIncentivizer.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./types/ProgramInfo.sol\\\";\\nimport \\\"./IController.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\n\\ninterface IIncentivizer {\\n event ProgramCreated(IProduct indexed product, uint256 indexed programId, ProgramInfo programInfo, UFixed18 programFeeAmount);\\n event ProgramStarted(IProduct indexed product, uint256 indexed programId, uint256 version);\\n event ProgramComplete(IProduct indexed product, uint256 indexed programId, uint256 version);\\n event Claim(IProduct indexed product, address indexed account, uint256 indexed programId, UFixed18 amount);\\n event FeeClaim(Token18 indexed token, UFixed18 amount);\\n\\n error IncentivizerNotAllowedError(IProduct product);\\n error IncentivizerTooManyProgramsError();\\n error IncentivizerNotProgramOwnerError(IProduct product, uint256 programId);\\n error IncentivizerInvalidProgramError(IProduct product, uint256 programId);\\n error IncentivizerBatchClaimArgumentMismatchError();\\n\\n function programInfos(IProduct product, uint256 programId) external view returns (ProgramInfo memory);\\n function fees(Token18 token) external view returns (UFixed18);\\n function initialize(IController controller_) external;\\n function create(IProduct product, ProgramInfo calldata info) external returns (uint256);\\n function complete(IProduct product, uint256 programId) external;\\n function sync(IOracleProvider.OracleVersion memory currentOracleVersion) external;\\n function syncAccount(address account, IOracleProvider.OracleVersion memory currentOracleVersion) external;\\n function claim(IProduct product, uint256[] calldata programIds) external;\\n function claim(IProduct[] calldata products, uint256[][] calldata programIds) external;\\n function claimFee(Token18[] calldata tokens) external;\\n function active(IProduct product) external view returns (uint256);\\n function count(IProduct product) external view returns (uint256);\\n function unclaimed(IProduct product, address account, uint256 programId) external view returns (UFixed18);\\n function available(IProduct product, uint256 programId) external view returns (UFixed18);\\n function versionStarted(IProduct product, uint256 programId) external view returns (uint256);\\n function versionComplete(IProduct product, uint256 programId) external view returns (uint256);\\n function owner(IProduct product, uint256 programId) external view returns (address);\\n function treasury(IProduct product, uint256 programId) external view returns (address);\\n}\\n\",\"keccak256\":\"0x2f95de90dbb3ad35dbfef304f765a622bffff9229868d2898eca8d49c78e8c2c\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IParamProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\\\";\\n\\ninterface IParamProvider {\\n event MaintenanceUpdated(UFixed18 newMaintenance);\\n event FundingFeeUpdated(UFixed18 newFundingFee);\\n event MakerFeeUpdated(UFixed18 newMakerFee);\\n event TakerFeeUpdated(UFixed18 newTakerFee);\\n event MakerLimitUpdated(UFixed18 newMakerLimit);\\n event JumpRateUtilizationCurveUpdated(\\n Fixed18 minRate,\\n Fixed18 maxRate,\\n Fixed18 targetRate,\\n UFixed18 targetUtilization\\n );\\n\\n error ParamProviderInvalidMakerFee();\\n error ParamProviderInvalidTakerFee();\\n error ParamProviderInvalidFundingFee();\\n \\n function maintenance() external view returns (UFixed18);\\n function updateMaintenance(UFixed18 newMaintenance) external;\\n function fundingFee() external view returns (UFixed18);\\n function updateFundingFee(UFixed18 newFundingFee) external;\\n function makerFee() external view returns (UFixed18);\\n function updateMakerFee(UFixed18 newMakerFee) external;\\n function takerFee() external view returns (UFixed18);\\n function updateTakerFee(UFixed18 newTakerFee) external;\\n function makerLimit() external view returns (UFixed18);\\n function updateMakerLimit(UFixed18 newMakerLimit) external;\\n function utilizationCurve() external view returns (JumpRateUtilizationCurve memory);\\n function updateUtilizationCurve(JumpRateUtilizationCurve memory newUtilizationCurve) external;\\n}\\n\",\"keccak256\":\"0x2e2d40d0cf55f167118867e41f740b9b40614d05da50fc9bc33a8cede3eaf03e\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IPayoffProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\n\\ninterface IPayoffProvider {\\n error PayoffProviderInvalidOracle();\\n error PayoffProviderInvalidPayoffDefinitionError();\\n\\n function oracle() external view returns (IOracleProvider);\\n function payoffDefinition() external view returns (PayoffDefinition memory);\\n function currentVersion() external view returns (IOracleProvider.OracleVersion memory);\\n function atVersion(uint256 oracleVersion) external view returns (IOracleProvider.OracleVersion memory);\\n}\\n\",\"keccak256\":\"0xb83d80d624aa9431763f80ecb4bf0214803e25334a7419d954f929e5d0ee7467\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IProduct.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\\\";\\nimport \\\"./IPayoffProvider.sol\\\";\\nimport \\\"./IParamProvider.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\nimport \\\"./types/Position.sol\\\";\\nimport \\\"./types/PrePosition.sol\\\";\\nimport \\\"./types/Accumulator.sol\\\";\\n\\ninterface IProduct is IPayoffProvider, IParamProvider {\\n /// @dev Product Creation parameters\\n struct ProductInfo {\\n /// @dev name of the product\\n string name;\\n\\n /// @dev symbol of the product\\n string symbol;\\n\\n /// @dev product payoff definition\\n PayoffDefinition payoffDefinition;\\n\\n /// @dev oracle address\\n IOracleProvider oracle;\\n\\n /// @dev product maintenance ratio\\n UFixed18 maintenance;\\n\\n /// @dev product funding fee\\n UFixed18 fundingFee;\\n\\n /// @dev product maker fee\\n UFixed18 makerFee;\\n\\n /// @dev product taker fee\\n UFixed18 takerFee;\\n\\n /// @dev product maker limit\\n UFixed18 makerLimit;\\n\\n /// @dev utulization curve definition\\n JumpRateUtilizationCurve utilizationCurve;\\n }\\n\\n event Settle(uint256 preVersion, uint256 toVersion);\\n event AccountSettle(address indexed account, uint256 preVersion, uint256 toVersion);\\n event MakeOpened(address indexed account, uint256 version, UFixed18 amount);\\n event TakeOpened(address indexed account, uint256 version, UFixed18 amount);\\n event MakeClosed(address indexed account, uint256 version, UFixed18 amount);\\n event TakeClosed(address indexed account, uint256 version, UFixed18 amount);\\n event ClosedUpdated(bool indexed newClosed, uint256 version);\\n\\n error ProductInsufficientLiquidityError(UFixed18 socializationFactor);\\n error ProductDoubleSidedError();\\n error ProductOverClosedError();\\n error ProductInsufficientCollateralError();\\n error ProductInLiquidationError();\\n error ProductMakerOverLimitError();\\n error ProductOracleBootstrappingError();\\n error ProductNotOwnerError();\\n error ProductInvalidOracle();\\n error ProductClosedError();\\n\\n function name() external view returns (string memory);\\n function symbol() external view returns (string memory);\\n function initialize(ProductInfo calldata productInfo_) external;\\n function settle() external;\\n function settleAccount(address account) external;\\n function openTake(UFixed18 amount) external;\\n function closeTake(UFixed18 amount) external;\\n function openMake(UFixed18 amount) external;\\n function closeMake(UFixed18 amount) external;\\n function closeAll(address account) external;\\n function maintenance(address account) external view returns (UFixed18);\\n function maintenanceNext(address account) external view returns (UFixed18);\\n function isClosed(address account) external view returns (bool);\\n function isLiquidating(address account) external view returns (bool);\\n function position(address account) external view returns (Position memory);\\n function pre(address account) external view returns (PrePosition memory);\\n function latestVersion() external view returns (uint256);\\n function positionAtVersion(uint256 oracleVersion) external view returns (Position memory);\\n function pre() external view returns (PrePosition memory);\\n function valueAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\\n function shareAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\\n function latestVersion(address account) external view returns (uint256);\\n function rate(Position memory position) external view returns (Fixed18);\\n function closed() external view returns (bool);\\n function updateClosed(bool newClosed) external;\\n}\\n\",\"keccak256\":\"0xe1e80b818eadf4cdb070362e40c7cf3863b50c4f944816af27848e319f587241\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/Accumulator.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"./PackedAccumulator.sol\\\";\\n\\n/// @dev Accumulator type\\nstruct Accumulator {\\n /// @dev maker accumulator per share\\n Fixed18 maker;\\n /// @dev taker accumulator per share\\n Fixed18 taker;\\n}\\nusing AccumulatorLib for Accumulator global;\\n\\n/**\\n * @title AccountAccumulatorLib\\n * @notice Library that surfaces math operations for the Accumulator type.\\n * @dev Accumulators track the cumulative change in position value over time for the maker and taker positions\\n * respectively. Account-level accumulators can then use two of these values `a` and `a'` to compute the\\n * change in position value since last sync. This change in value is then used to compute P&L and fees.\\n */\\nlibrary AccumulatorLib {\\n /**\\n * @notice Creates a packed accumulator from an accumulator\\n * @param self an accumulator\\n * @return New packed accumulator\\n */\\n function pack(Accumulator memory self) internal pure returns (PackedAccumulator memory) {\\n return PackedAccumulator({maker: self.maker.pack(), taker: self.taker.pack()});\\n }\\n\\n /**\\n * @notice Adds two accumulators together\\n * @param a The first accumulator to sum\\n * @param b The second accumulator to sum\\n * @return The resulting summed accumulator\\n */\\n function add(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\\n }\\n\\n /**\\n * @notice Subtracts accumulator `b` from `a`\\n * @param a The accumulator to subtract from\\n * @param b The accumulator to subtract\\n * @return The resulting subtracted accumulator\\n */\\n function sub(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\\n }\\n\\n /**\\n * @notice Multiplies two accumulators together\\n * @param a The first accumulator to multiply\\n * @param b The second accumulator to multiply\\n * @return The resulting multiplied accumulator\\n */\\n function mul(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.mul(b.maker), taker: a.taker.mul(b.taker)});\\n }\\n\\n /**\\n * @notice Sums the maker and taker together from a single accumulator\\n * @param self The struct to operate on\\n * @return The sum of its maker and taker\\n */\\n function sum(Accumulator memory self) internal pure returns (Fixed18) {\\n return self.maker.add(self.taker);\\n }\\n}\\n\",\"keccak256\":\"0x7ccd0a72aa593cefb9f4337cf312799f357b82fcb3f0379de0dc503d1cb7e387\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PackedAccumulator.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/PackedFixed18.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\n\\n/// @dev PackedAccumulator type\\nstruct PackedAccumulator {\\n /// @dev maker accumulator per share\\n PackedFixed18 maker;\\n /// @dev taker accumulator per share\\n PackedFixed18 taker;\\n}\\nusing PackedAccumulatorLib for PackedAccumulator global;\\n\\n/**\\n * @title PackedAccumulatorLib\\n * @dev A packed version of the Accumulator which takes up a single storage slot using `PackedFixed18` values.\\n * @notice Library for the packed Accumulator type.\\n */\\nlibrary PackedAccumulatorLib {\\n /**\\n * @notice Creates an accumulator from a packed accumulator\\n * @param self packed accumulator\\n * @return New accumulator\\n */\\n function unpack(PackedAccumulator memory self) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: self.maker.unpack(), taker: self.taker.unpack()});\\n }\\n}\\n\",\"keccak256\":\"0xd83f2822d4f6c818087a232b54007730992c34ff77377fc307a282f886e7cf65\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PackedPosition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/PackedUFixed18.sol\\\";\\nimport \\\"./Position.sol\\\";\\n\\n/// @dev PackedPosition type\\nstruct PackedPosition {\\n /// @dev Quantity of the maker position\\n PackedUFixed18 maker;\\n /// @dev Quantity of the taker position\\n PackedUFixed18 taker;\\n}\\nusing PackedPositionLib for PackedPosition global;\\n\\n/**\\n * @title PackedPositionLib\\n * @dev A packed version of the Position which takes up a single storage slot using `PackedFixed18` values.\\n * @notice Library for the packed Position type.\\n */\\nlibrary PackedPositionLib {\\n /**\\n * @notice Creates an position from a packed position\\n * @param self packed position\\n * @return New position\\n */\\n function unpack(PackedPosition memory self) internal pure returns (Position memory) {\\n return Position({maker: self.maker.unpack(), taker: self.taker.unpack()});\\n }\\n}\\n\",\"keccak256\":\"0x04968e6794f6244cb3415cea111d640273a81faea957872988d0cb580f45df1e\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PayoffDefinition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"@openzeppelin/contracts/utils/Address.sol\\\";\\nimport \\\"../../interfaces/IContractPayoffProvider.sol\\\";\\n\\n/// @dev PayoffDefinition tyoe\\nstruct PayoffDefinition {\\n PayoffDefinitionLib.PayoffType payoffType;\\n PayoffDefinitionLib.PayoffDirection payoffDirection;\\n bytes30 data;\\n}\\nusing PayoffDefinitionLib for PayoffDefinition global;\\ntype PayoffDefinitionStorage is bytes32;\\nusing PayoffDefinitionStorageLib for PayoffDefinitionStorage global;\\n\\n/**\\n * @title PayoffDefinitionLib\\n * @dev Library that surfaces logic for PayoffDefinition type functionality\\n * @notice Library for the PayoffDefinition type. Performs validity and price transformation\\n based on the payoff definition type.\\n */\\nlibrary PayoffDefinitionLib {\\n using Address for address;\\n\\n error PayoffDefinitionUnsupportedTransform(PayoffType payoffType, PayoffDirection payoffDirection);\\n error PayoffDefinitionNotContract(PayoffType payoffType, bytes30 data);\\n\\n /// @dev Payoff function type enum\\n enum PayoffType { PASSTHROUGH, CONTRACT }\\n enum PayoffDirection { LONG, SHORT }\\n\\n /**\\n * @notice Checks validity of the payoff definition\\n * @param self a payoff definition\\n * @return Whether the payoff definition is valid for it's given type\\n */\\n function valid(PayoffDefinition memory self) internal view returns (bool) {\\n if (self.payoffType == PayoffType.CONTRACT) return address(_providerContract(self)).isContract();\\n\\n // All other payoff types should have no data\\n return uint(bytes32(self.data)) == 0;\\n }\\n\\n /**\\n * @notice Transforms a price based on the payoff definition\\n * @param self a payoff definition\\n * @param price raw oracle price\\n * @return Price transformed by the payoff definition function\\n */\\n function transform(\\n PayoffDefinition memory self,\\n Fixed18 price\\n ) internal view returns (Fixed18) {\\n PayoffType payoffType = self.payoffType;\\n PayoffDirection payoffDirection = self.payoffDirection;\\n Fixed18 transformedPrice;\\n\\n // First get the price depending on the type\\n if (payoffType == PayoffType.PASSTHROUGH) transformedPrice = price;\\n else if (payoffType == PayoffType.CONTRACT) transformedPrice = _payoffFromContract(self, price);\\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\\n\\n // Then transform it depending on the direction flag\\n if (self.payoffDirection == PayoffDirection.LONG) return transformedPrice;\\n else if (self.payoffDirection == PayoffDirection.SHORT) return transformedPrice.mul(Fixed18Lib.NEG_ONE);\\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\\n }\\n\\n /**\\n * @notice Parses the data field into an address\\n * @dev Reverts if payoffType is not CONTRACT\\n * @param self a payoff definition\\n * @return IContractPayoffProvider address\\n */\\n function _providerContract(\\n PayoffDefinition memory self\\n ) private pure returns (IContractPayoffProvider) {\\n if (self.payoffType != PayoffType.CONTRACT) revert PayoffDefinitionNotContract(self.payoffType, self.data);\\n // Shift to pull the last 20 bytes, then cast to an address\\n return IContractPayoffProvider(address(bytes20(self.data << 80)));\\n }\\n\\n /**\\n * @notice Performs a price transformation by calling the underlying payoff contract\\n * @param self a payoff definition\\n * @param price raw oracle price\\n * @return Price transformed by the payoff definition function on the contract\\n */\\n function _payoffFromContract(\\n PayoffDefinition memory self,\\n Fixed18 price\\n ) private view returns (Fixed18) {\\n bytes memory ret = address(_providerContract(self)).functionStaticCall(\\n abi.encodeCall(IContractPayoffProvider.payoff, price)\\n );\\n return Fixed18.wrap(abi.decode(ret, (int256)));\\n }\\n}\\n\\n/**\\n * @title PayoffDefinitionStorageLib\\n * @notice Library that surfaces storage read and writes for the PayoffDefinition type\\n */\\nlibrary PayoffDefinitionStorageLib {\\n function read(PayoffDefinitionStorage self) internal view returns (PayoffDefinition memory) {\\n return _storagePointer(self);\\n }\\n\\n function store(PayoffDefinitionStorage self, PayoffDefinition memory value) internal {\\n PayoffDefinition storage storagePointer = _storagePointer(self);\\n\\n storagePointer.payoffType = value.payoffType;\\n storagePointer.payoffDirection = value.payoffDirection;\\n storagePointer.data = value.data;\\n }\\n\\n function _storagePointer(\\n PayoffDefinitionStorage self\\n ) private pure returns (PayoffDefinition storage pointer) {\\n assembly { pointer.slot := self }\\n }\\n}\\n\",\"keccak256\":\"0x4d3897f408f77381c5ae9990391465c8fd511ddf6ff3b39f6cb69d8c2bd554df\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/Position.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\nimport \\\"./PrePosition.sol\\\";\\nimport \\\"./PackedPosition.sol\\\";\\n\\n/// @dev Position type\\nstruct Position {\\n /// @dev Quantity of the maker position\\n UFixed18 maker;\\n /// @dev Quantity of the taker position\\n UFixed18 taker;\\n}\\nusing PositionLib for Position global;\\n\\n/**\\n * @title PositionLib\\n * @notice Library that surfaces math and settlement computations for the Position type.\\n * @dev Positions track the current quantity of the account's maker and taker positions respectively\\n * denominated as a unit of the product's payoff function.\\n */\\nlibrary PositionLib {\\n /**\\n * @notice Creates a packed position from an position\\n * @param self A position\\n * @return New packed position\\n */\\n function pack(Position memory self) internal pure returns (PackedPosition memory) {\\n return PackedPosition({maker: self.maker.pack(), taker: self.taker.pack()});\\n }\\n\\n /**\\n * @notice Returns whether the position is fully empty\\n * @param self A position\\n * @return Whether the position is empty\\n */\\n function isEmpty(Position memory self) internal pure returns (bool) {\\n return self.maker.isZero() && self.taker.isZero();\\n }\\n\\n /**\\n * @notice Adds position `a` and `b` together, returning the result\\n * @param a The first position to sum\\n * @param b The second position to sum\\n * @return Resulting summed position\\n */\\n function add(Position memory a, Position memory b) internal pure returns (Position memory) {\\n return Position({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\\n }\\n\\n /**\\n * @notice Subtracts position `b` from `a`, returning the result\\n * @param a The position to subtract from\\n * @param b The position to subtract\\n * @return Resulting subtracted position\\n */\\n function sub(Position memory a, Position memory b) internal pure returns (Position memory) {\\n return Position({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\\n }\\n\\n /**\\n * @notice Multiplies position `self` by accumulator `accumulator` and returns the resulting accumulator\\n * @param self The Position to operate on\\n * @param accumulator The accumulator to multiply by\\n * @return Resulting multiplied accumulator\\n */\\n function mul(Position memory self, Accumulator memory accumulator) internal pure returns (Accumulator memory) {\\n return Accumulator({\\n maker: Fixed18Lib.from(self.maker).mul(accumulator.maker),\\n taker: Fixed18Lib.from(self.taker).mul(accumulator.taker)\\n });\\n }\\n\\n /**\\n * @notice Scales position `self` by fixed-decimal `scale` and returns the resulting position\\n * @param self The Position to operate on\\n * @param scale The Fixed-decimal to scale by\\n * @return Resulting scaled position\\n */\\n function mul(Position memory self, UFixed18 scale) internal pure returns (Position memory) {\\n return Position({maker: self.maker.mul(scale), taker: self.taker.mul(scale)});\\n }\\n\\n /**\\n * @notice Divides position `self` by `b` and returns the resulting accumulator\\n * @param self The Position to operate on\\n * @param b The number to divide by\\n * @return Resulting divided accumulator\\n */\\n function div(Position memory self, uint256 b) internal pure returns (Accumulator memory) {\\n return Accumulator({\\n maker: Fixed18Lib.from(self.maker).div(Fixed18Lib.from(UFixed18Lib.from(b))),\\n taker: Fixed18Lib.from(self.taker).div(Fixed18Lib.from(UFixed18Lib.from(b)))\\n });\\n }\\n\\n /**\\n * @notice Returns the maximum of `self`'s maker and taker values\\n * @param self The struct to operate on\\n * @return Resulting maximum value\\n */\\n function max(Position memory self) internal pure returns (UFixed18) {\\n return UFixed18Lib.max(self.maker, self.taker);\\n }\\n\\n /**\\n * @notice Sums the maker and taker together from a single position\\n * @param self The struct to operate on\\n * @return The sum of its maker and taker\\n */\\n function sum(Position memory self) internal pure returns (UFixed18) {\\n return self.maker.add(self.taker);\\n }\\n\\n /**\\n * @notice Computes the next position after the pending-settlement position delta is included\\n * @param self The current Position\\n * @param pre The pending-settlement position delta\\n * @return Next Position\\n */\\n function next(Position memory self, PrePosition memory pre) internal pure returns (Position memory) {\\n return sub(add(self, pre.openPosition), pre.closePosition);\\n }\\n\\n /**\\n * @notice Returns the settled position at oracle version `toOracleVersion`\\n * @dev Checks if a new position is ready to be settled based on the provided `toOracleVersion`\\n * and `pre` and returns accordingly\\n * @param self The current Position\\n * @param pre The pending-settlement position delta\\n * @param toOracleVersion The oracle version to settle to\\n * @return Settled position at oracle version\\n * @return Fee accrued from opening or closing the position\\n * @return Whether a new position was settled\\n */\\n function settled(\\n Position memory self,\\n PrePosition memory pre,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal view returns (Position memory, UFixed18, bool) {\\n return pre.canSettle(toOracleVersion) ? (next(self, pre), pre.computeFee(toOracleVersion), true) : (self, UFixed18Lib.ZERO, false);\\n }\\n\\n /**\\n * @notice Returns the socialization factor for the current position\\n * @dev Socialization account for the case where `taker` > `maker` temporarily due to a liquidation\\n * on the maker side. This dampens the taker's exposure pro-rata to ensure that the maker side\\n * is never exposed over 1 x short.\\n * @param self The Position to operate on\\n * @return Socialization factor\\n */\\n function socializationFactor(Position memory self) internal pure returns (UFixed18) {\\n return self.taker.isZero() ? UFixed18Lib.ONE : UFixed18Lib.min(UFixed18Lib.ONE, self.maker.div(self.taker));\\n }\\n}\\n\",\"keccak256\":\"0x027fe392c4f56bf012ba2ca462fcf23e69f2c3b9d283c14089771813437af991\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PrePosition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./Position.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\n\\n/// @dev PrePosition type\\nstruct PrePosition {\\n /// @dev Oracle version at which the new position delta was recorded\\n uint256 oracleVersion;\\n\\n /// @dev Size of position to open at oracle version\\n Position openPosition;\\n\\n /// @dev Size of position to close at oracle version\\n Position closePosition;\\n}\\nusing PrePositionLib for PrePosition global;\\n\\n/**\\n * @title PrePositionLib\\n * @notice Library that manages a pre-settlement position delta.\\n * @dev PrePositions track the currently awaiting-settlement deltas to a settled Position. These are\\n * Primarily necessary to introduce lag into the settlement system such that oracle lag cannot be\\n * gamed to a user's advantage. When a user opens or closes a new position, it sits as a PrePosition\\n * for one oracle version until it's settle into the Position, making it then effective. PrePositions\\n * are automatically settled at the correct oracle version even if a flywheel call doesn't happen until\\n * several version into the future by using the historical version lookups in the corresponding \\\"Versioned\\\"\\n * global state types.\\n */\\nlibrary PrePositionLib {\\n /**\\n * @notice Returns whether there is no pending-settlement position delta\\n * @dev Can be \\\"empty\\\" even with a non-zero oracleVersion if a position is opened and\\n * closed in the same version netting out to a zero position delta\\n * @param self The struct to operate on\\n * @return Whether the pending-settlement position delta is empty\\n */\\n function isEmpty(PrePosition memory self) internal pure returns (bool) {\\n return self.openPosition.isEmpty() && self.closePosition.isEmpty();\\n }\\n\\n /**\\n * @notice Increments the maker side of the open position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The position amount to open\\n */\\n function openMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.openPosition.maker = self.openPosition.maker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netMake(self);\\n }\\n\\n /**\\n * @notice Increments the maker side of the close position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The maker position amount to close\\n */\\n function closeMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.closePosition.maker = self.closePosition.maker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netMake(self);\\n }\\n\\n /**\\n * @notice Increments the taker side of the open position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The taker position amount to open\\n */\\n function openTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.openPosition.taker = self.openPosition.taker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netTake(self);\\n }\\n\\n /**\\n * @notice Increments the taker side of the close position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The taker position amount to close\\n */\\n function closeTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.closePosition.taker = self.closePosition.taker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netTake(self);\\n }\\n\\n /**\\n * @notice Nets out the open and close on the maker side of the position delta\\n * @param self The struct to operate on\\n */\\n function _netMake(PrePosition storage self) private {\\n if (self.openPosition.maker.gt(self.closePosition.maker)) {\\n self.openPosition.maker = self.openPosition.maker.sub(self.closePosition.maker);\\n self.closePosition.maker = UFixed18Lib.ZERO;\\n } else {\\n self.closePosition.maker = self.closePosition.maker.sub(self.openPosition.maker);\\n self.openPosition.maker = UFixed18Lib.ZERO;\\n }\\n }\\n\\n /**\\n * @notice Nets out the open and close on the taker side of the position delta\\n * @param self The struct to operate on\\n */\\n function _netTake(PrePosition storage self) private {\\n if (self.openPosition.taker.gt(self.closePosition.taker)) {\\n self.openPosition.taker = self.openPosition.taker.sub(self.closePosition.taker);\\n self.closePosition.taker = UFixed18Lib.ZERO;\\n } else {\\n self.closePosition.taker = self.closePosition.taker.sub(self.openPosition.taker);\\n self.openPosition.taker = UFixed18Lib.ZERO;\\n }\\n }\\n\\n /**\\n * @notice Returns whether the the pending position delta can be settled at version `toOracleVersion`\\n * @dev Pending-settlement positions deltas can be settled (1) oracle version after they are recorded\\n * @param self The struct to operate on\\n * @param toOracleVersion The potential oracle version to settle\\n * @return Whether the position delta can be settled\\n */\\n function canSettle(\\n PrePosition memory self,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal pure returns (bool) {\\n return !isEmpty(self) && toOracleVersion.version > self.oracleVersion;\\n }\\n\\n /**\\n * @notice Computes the fee incurred for opening or closing the pending-settlement position\\n * @dev Must be called from a valid product to get the proper fee amounts\\n * @param self The struct to operate on\\n * @param toOracleVersion The oracle version at which settlement takes place\\n * @return positionFee The maker / taker fee incurred\\n */\\n function computeFee(\\n PrePosition memory self,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal view returns (UFixed18) {\\n Position memory positionDelta = self.openPosition.add(self.closePosition);\\n\\n (UFixed18 makerNotional, UFixed18 takerNotional) = (\\n Fixed18Lib.from(positionDelta.maker).mul(toOracleVersion.price).abs(),\\n Fixed18Lib.from(positionDelta.taker).mul(toOracleVersion.price).abs()\\n );\\n\\n IProduct product = IProduct(address(this));\\n return makerNotional.mul(product.makerFee()).add(takerNotional.mul(product.takerFee()));\\n }\\n\\n /**\\n * @notice Computes the next oracle version to settle\\n * @dev - If there is no pending-settlement position delta, returns the current oracle version\\n * - Otherwise returns the oracle version at which the pending-settlement position delta can be first settled\\n *\\n * Corresponds to point (b) in the Position settlement flow\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @return Next oracle version to settle\\n */\\n function settleVersion(PrePosition storage self, uint256 currentVersion) internal view returns (uint256) {\\n uint256 _oracleVersion = self.oracleVersion;\\n return _oracleVersion == 0 ? currentVersion : _oracleVersion + 1;\\n }\\n}\\n\",\"keccak256\":\"0xa6f83f7b5f8139ec874235c406debd086a152977493c08b7f280df6f1737fb96\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/ProgramInfo.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\nimport \\\"./Position.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\n\\n/// @dev ProgramInfo type\\nstruct ProgramInfo {\\n /// @dev Coordinator for this program\\n uint256 coordinatorId;\\n\\n /// @dev Amount of total maker and taker rewards\\n Position amount;\\n\\n /// @dev start timestamp of the program\\n uint256 start;\\n\\n /// @dev duration of the program (in seconds)\\n uint256 duration;\\n\\n /**\\n * @dev Reward ERC20 token contract\\n * @notice Perennial does not support non-standard ERC20s as reward tokens for incentive programs, including,\\n but not limited to: fee on transfer and rebase tokens. Using such a non-standard token will likely\\n result in loss of funds.\\n */\\n Token18 token;\\n}\\nusing ProgramInfoLib for ProgramInfo global;\\n\\n/**\\n * @title ProgramInfoLib\\n * @notice Library that snapshots the static information for a single program.\\n * @dev This information does not change during the operation of a program.\\n */\\nlibrary ProgramInfoLib {\\n uint256 private constant MIN_DURATION = 1 days;\\n uint256 private constant MAX_DURATION = 2 * 365 days;\\n\\n error ProgramInvalidStartError();\\n error ProgramInvalidDurationError();\\n\\n /**\\n * @notice Validates and creates a new Program\\n * @dev Reverts for invalid programInfos\\n * @param programInfo Un-sanitized static program information\\n */\\n function validate(ProgramInfo memory programInfo) internal view {\\n if (isStarted(programInfo, block.timestamp)) revert ProgramInvalidStartError();\\n if (programInfo.duration < MIN_DURATION || programInfo.duration > MAX_DURATION) revert ProgramInvalidDurationError();\\n }\\n\\n /**\\n * @notice Computes a new program info with the fee taken out of the amount\\n * @param programInfo Original program info\\n * @param incentivizationFee The incentivization fee\\n * @return New program info\\n * @return Fee amount\\n */\\n function deductFee(ProgramInfo memory programInfo, UFixed18 incentivizationFee)\\n internal pure returns (ProgramInfo memory, UFixed18) {\\n Position memory newProgramAmount = programInfo.amount.mul(UFixed18Lib.ONE.sub(incentivizationFee));\\n UFixed18 programFeeAmount = programInfo.amount.sub(newProgramAmount).sum();\\n programInfo.amount = newProgramAmount;\\n return (programInfo, programFeeAmount);\\n }\\n\\n /**\\n * @notice Returns the maker and taker amounts per position share\\n * @param self The ProgramInfo to operate on\\n * @return programFee Amounts per share\\n */\\n function amountPerShare(ProgramInfo memory self) internal pure returns (Accumulator memory) {\\n return self.amount.div(self.duration);\\n }\\n\\n /**\\n * @notice Returns whether the program has started by timestamp `timestamp`\\n * @param self The ProgramInfo to operate on\\n * @param timestamp Timestamp to check for\\n * @return Whether the program has started\\n */\\n function isStarted(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\\n return timestamp >= self.start;\\n }\\n\\n /**\\n * @notice Returns whether the program is completed by timestamp `timestamp`\\n * @param self The ProgramInfo to operate on\\n * @param timestamp Timestamp to check for\\n * @return Whether the program is completed\\n */\\n function isComplete(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\\n return timestamp >= (self.start + self.duration);\\n }\\n}\\n\",\"keccak256\":\"0x280fcaf931b49abaec46b95ccbabaaf856a4b8e8d036413c9c3b3af25585d161\",\"license\":\"Apache-2.0\"}},\"version\":1}", - "bytecode": "0x608060405234801561001057600080fd5b50612de7806100206000396000f3fe60806040523480156200001157600080fd5b5060043610620002e45760003560e01c80637a7da0041162000199578063a36a363011620000e9578063d809aa611162000097578063e30c3978116200007a578063e30c39781462000638578063e975c0c31462000642578063f8dfc2cc146200064c57600080fd5b8063d809aa611462000617578063d8dfeb45146200062e57600080fd5b8063b0e21e8a11620000cc578063b0e21e8a14620005ec578063ba2de9bc14620005f6578063c0c53b8b146200060057600080fd5b8063a36a363014620005cb578063af2757b714620005d557600080fd5b80638da5cb5b11620001475780639fd0506d116200012a5780639fd0506d1462000593578063a123c33e146200059d578063a1eef78e14620005b457600080fd5b80638da5cb5b14620005725780638fbf1803146200057c57600080fd5b80637d254e66116200017c5780637d254e66146200050a5780637d49c1b7146200052d5780637fd29192146200053757600080fd5b80637a7da00414620004dc5780637c01369014620004f357600080fd5b80634c5430a0116200025557806365e821e5116200020357806366c0623911620001e657806366c0623914620004b15780636fc6407c14620004bb57806375907f2814620004c557600080fd5b806365e821e51462000483578063666e1b39146200049a57600080fd5b80635c975abb11620002385780635c975abb14620004075780635f1cc005146200042257806361d027b3146200047957600080fd5b80634c5430a014620003d9578063554bab3c14620003f057600080fd5b80632d809cb611620002b35780633ceda01111620002965780633ceda01114620003925780634256dd7814620003ab578063478739ca14620003c257600080fd5b80632d809cb61462000371578063391d0c9c146200038857600080fd5b806308cdc2a814620002e95780630d57036114620003025780632933d89114620003435780632b800e3b146200035a575b600080fd5b62000300620002fa36600462001df6565b62000663565b005b620003196200031336600462001e1a565b62000734565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b620003006200035436600462001e6c565b62000926565b620003196200036b36600462001e6c565b620009fe565b620003196200038236600462001eac565b62000a42565b6200031962000a79565b6200039c62000aa9565b6040519081526020016200033a565b62000300620003bc36600462001e6c565b62000ad4565b62000300620003d336600462001e6c565b62000bf1565b62000319620003ea36600462001e6c565b62000d0e565b620003006200040136600462001eac565b62000d73565b6200041162000e5a565b60405190151581526020016200033a565b620004396200043336600462001e6c565b62000e85565b60408051825173ffffffffffffffffffffffffffffffffffffffff908116825260208085015182169083015292820151909216908201526060016200033a565b6200031962000f13565b620003006200049436600462001eac565b62000f21565b62000319620004ab36600462001eac565b62001057565b6200039c62001088565b6200031962001094565b62000300620004d636600462001e6c565b620010bf565b62000300620004ed36600462001eac565b620011dc565b620003006200050436600462001eac565b62001312565b6200039c6200051b36600462001eac565b60016020526000908152604090205481565b6200039c62001448565b620004116200054836600462001eac565b73ffffffffffffffffffffffffffffffffffffffff16600090815260016020526040902054151590565b6200031962001473565b620003006200058d36600462001e6c565b62001481565b6200031962001587565b62000319620005ae36600462001e6c565b620015e9565b62000300620005c536600462001e6c565b62001630565b6200039c62001701565b62000300620005e636600462001ecc565b6200172c565b6200039c6200183c565b6200039c62001867565b620003006200061136600462001ef4565b62001892565b620003006200062836600462001e6c565b620019d1565b6200031962001aee565b6200031962001b19565b6200039c62001b27565b620003006200065d36600462001ecc565b62001b52565b6200066d62001587565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614620006d2576040517f84f8637600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620006fc7ff201e8b56b5ea8f1176ce6f2699cbe9659ba7491e9460c9d358ddf61400b5de3829055565b60405181151581527f31311016d7204faff81880133e3db244ae8a8b9ce15e83e2432258226d15f9429060200160405180910390a150565b6000826200074281620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614620007af576040517ff0a882b5000000000000000000000000000000000000000000000000000000008152600481018290526024015b60405180910390fd5b83600003620007ea576040517f7244bc7800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000620007f662000a79565b8460405160240162000809919062002150565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167ff0b4095900000000000000000000000000000000000000000000000000000000179052516200088b9062001de8565b620008989291906200225b565b604051809103906000f080158015620008b5573d6000803e3d6000fd5b5073ffffffffffffffffffffffffffffffffffffffff8116600081815260016020526040908190208890555191925082917f09d535073bc2dc21c8fd680a2141218a65fb0acc46e88b9e5d96f114b734b004906200091590889062002150565b60405180910390a295945050505050565b60006200093381620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146200099c576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b620009c67f2859911faffd405cbcc22bdad2f67b54a86355c092452044dbab4f656aec3dc9839055565b6040518281527fd19fe8ad9152af12b174a60210fb798db0767d63973ebb97298dc44d67a5c82d906020015b60405180910390a15050565b600080828154811062000a155762000a15620022ef565b600091825260209091206003909102015473ffffffffffffffffffffffffffffffffffffffff1692915050565b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604081205462000a739062000d0e565b92915050565b600062000aa47f81565bc82d6e7196d38320713fd94f897c0e1a4c83974a2fbbbf9fbb55a6d8a75490565b905090565b600062000aa47f1f7147efa84c5ef8ccb713891d25247c732a9d5765ebc3bb6cb30d1f17d277f05490565b600062000ae181620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462000b4a576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b62000b5e82670de0b6b3a764000062001c65565b1562000b96576040517f3c5df10400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000bc07f7b1a264a02657d43e78b10f2a591a99a0fdf8a165fb72bbf762d965e9973f64e839055565b6040518281527fd10d75876659a287a59a6ccfa2e3fff42f84d94b542837acd30bc184d562de4090602001620009f2565b600062000bfe81620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462000c67576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b62000c7b82670de0b6b3a764000062001c65565b1562000cb3576040517f0c6b0ec800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000cdd7f6f35922f1b8609c81847a86ce8bb2528f73d722df88772b050ac89d3bc48707d839055565b6040518281527fdf7e6bc55eeb2668bd338e44a5abb721b1f98ad51f7a00baaa1b62f9383862d790602001620009f2565b6000806000838154811062000d275762000d27620022ef565b600091825260209091206002600390920201015473ffffffffffffffffffffffffffffffffffffffff169050801562000d61578062000d6c565b62000d6c83620015e9565b9392505050565b600062000d8081620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462000de9576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b62000e137fc641ae699093d5be5b0b167620fe782b911b5015c8c9f6e14207530ddda0d020839055565b60405173ffffffffffffffffffffffffffffffffffffffff831681527fa4336c0cb1e245b95ad204faed7e940d6dc999684fd8b5e1ff597a0c4efca8ab90602001620009f2565b600062000aa47ff201e8b56b5ea8f1176ce6f2699cbe9659ba7491e9460c9d358ddf61400b5de35490565b60408051606081018252600080825260208201819052918101919091526000828154811062000eb85762000eb8620022ef565b6000918252602091829020604080516060810182526003909302909101805473ffffffffffffffffffffffffffffffffffffffff90811684526001820154811694840194909452600201549092169181019190915292915050565b600062000aa4600062000d0e565b600062000f2e81620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462000f97576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b73ffffffffffffffffffffffffffffffffffffffff82163b62000fe6576040517fe939acbc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620010107fcbd1a41d9e21eb02a3acb8d57f9495422d3837dd84bf5dfbc51964fe540cff41839055565b60405173ffffffffffffffffffffffffffffffffffffffff831681527f18c973e70eca8db74eab2a3e0de3c4bffcc46c45f6f17f600e2d4d4f744e2a2b90602001620009f2565b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604081205462000a7390620015e9565b600062000aa462001c7d565b600062000aa47fcbd1a41d9e21eb02a3acb8d57f9495422d3837dd84bf5dfbc51964fe540cff415490565b6000620010cc81620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462001135576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b6200114982670de0b6b3a764000062001c65565b1562001181576040517fb4c4f79900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620011ab7fdf23e6978beb49efbffd02ffd26ec2f120b1e5be191aa5749bafaa170026fb09839055565b6040518281527f1a35ca75fc5ab34ae3487b3507e7453b6e4c15a69f2392939fbbcf8f64558ad190602001620009f2565b6000620011e981620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462001252576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b73ffffffffffffffffffffffffffffffffffffffff82163b620012a1576040517fe939acbc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620012cb7f9a67237eef0f801c1f3a0e6be772257326890fecbd39f68c5f7bb69ca7c408c3839055565b60405173ffffffffffffffffffffffffffffffffffffffff831681527fa0fe5cb0e8843811ca9f6123983dcdfd45a33b61892b9b8f380ed444078e299a90602001620009f2565b60006200131f81620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462001388576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b73ffffffffffffffffffffffffffffffffffffffff82163b620013d7576040517fe939acbc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620014017f81565bc82d6e7196d38320713fd94f897c0e1a4c83974a2fbbbf9fbb55a6d8a7839055565b60405173ffffffffffffffffffffffffffffffffffffffff831681527f36466d973cc33c9b726f867d2fc1f8cd56d58de206993f62ccba543a3429ea6290602001620009f2565b600062000aa47fd665791d8a3246c9a2360cb3de854da1c9536240e0380f1f5c2dd0e6b8b7c8605490565b600062000aa46000620015e9565b6000808281548110620014985762001498620022ef565b60009182526020909120600390910201805490915073ffffffffffffffffffffffffffffffffffffffff1633811462001501576040517f07f41a5f00000000000000000000000000000000000000000000000000000000815260048101849052602401620007a6565b81547fffffffffffffffffffffffff0000000000000000000000000000000000000000908116835560018301805473ffffffffffffffffffffffffffffffffffffffff841692168217905560405190815283907f87c983c6a4d6d9a68e6d99934d1fb50f760858298c06f8ed6b316f534e06faf4906020015b60405180910390a2505050565b600080620015b37fc641ae699093d5be5b0b167620fe782b911b5015c8c9f6e14207530ddda0d0205490565b905073ffffffffffffffffffffffffffffffffffffffff811615620015d95780620015e3565b620015e362001473565b91505090565b6000808281548110620016005762001600620022ef565b600091825260209091206001600390920201015473ffffffffffffffffffffffffffffffffffffffff1692915050565b60006200163d81620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614620016a6576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b620016d07fd665791d8a3246c9a2360cb3de854da1c9536240e0380f1f5c2dd0e6b8b7c860839055565b6040518281527f7e6452dce5202ad16be30ea14955296f7157b95e4ca48b73fc54d54601185adf90602001620009f2565b600062000aa47fdf23e6978beb49efbffd02ffd26ec2f120b1e5be191aa5749bafaa170026fb095490565b816200173881620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614620017a1576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b8160008481548110620017b857620017b8620022ef565b60009182526020918290206003919091020180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff938416179055604051918416825284917f0bffd4439c17923ee1b2b093be5394c42dcab0d9394e349a8d6a059c239ba60391016200157a565b600062000aa47f7b1a264a02657d43e78b10f2a591a99a0fdf8a165fb72bbf762d965e9973f64e5490565b600062000aa47f2859911faffd405cbcc22bdad2f67b54a86355c092452044dbab4f656aec3dc95490565b600180620018be7f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b5490565b10620018fa576040517f1e7a9d9500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b620019247f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b829055565b60017fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c556200195262001c7d565b506200195e84620011dc565b620019698362000f21565b620019748262001312565b60007fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c556040518181527fbe9b076dc5b65990cca9dd9d7366682482e7817a6f6bc7f4faf4dc32af497f329060200160405180910390a150505050565b6000620019de81620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462001a47576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b62001a5b82670de0b6b3a764000062001c65565b1562001a93576040517f7c3ceda900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62001abd7f1f7147efa84c5ef8ccb713891d25247c732a9d5765ebc3bb6cb30d1f17d277f0839055565b6040518281527f852c049e335a49416ecbcb0128935cc3832c307d450d206f0a2d0bf2b28ba2db90602001620009f2565b600062000aa47f9a67237eef0f801c1f3a0e6be772257326890fecbd39f68c5f7bb69ca7c408c35490565b600062000aa46000620009fe565b600062000aa47f6f35922f1b8609c81847a86ce8bb2528f73d722df88772b050ac89d3bc48707d5490565b8162001b5e81620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462001bc7576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b816000848154811062001bde5762001bde620022ef565b60009182526020918290206003919091020160020180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff938416179055604051918416825284917fffd31ccade46a73a57d8efd7d740bbf6aa67e50a158c98ad82a06ad31556cef491016200157a565b600062001c73838362001daf565b6002149392505050565b600080546040805160608101825283815233602080830182815283850187815260018701885587805293517f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5636003880290810180547fffffffffffffffffffffffff000000000000000000000000000000000000000090811673ffffffffffffffffffffffffffffffffffffffff9485161790915592517f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e56482018054851691841691909117905594517f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5659095018054909216941693909317909255915191825282917f645c9ae30d6a6aa6b2dace770fa0cfac2d8d44b9b036510e0a16aab39e6b5931910160405180910390a2919050565b600082828082111562001dc85760029250505062000a73565b8082101562001ddd5760009250505062000a73565b506001949350505050565b610a93806200231f83390190565b60006020828403121562001e0957600080fd5b8135801515811462000d6c57600080fd5b6000806040838503121562001e2e57600080fd5b82359150602083013567ffffffffffffffff81111562001e4d57600080fd5b83016101e0818603121562001e6157600080fd5b809150509250929050565b60006020828403121562001e7f57600080fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff8116811462001ea957600080fd5b50565b60006020828403121562001ebf57600080fd5b813562000d6c8162001e86565b6000806040838503121562001ee057600080fd5b82359150602083013562001e618162001e86565b60008060006060848603121562001f0a57600080fd5b833562001f178162001e86565b9250602084013562001f298162001e86565b9150604084013562001f3b8162001e86565b809150509250925092565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811262001f7c57600080fd5b830160208101925035905067ffffffffffffffff81111562001f9d57600080fd5b80360382131562001fad57600080fd5b9250929050565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b6002811062001ea957600080fd5b6002811062001ea9577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b8035620020508162001ffd565b6200205b816200200b565b825260208101356200206d8162001ffd565b62002078816200200b565b602083015260408101357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00008116808214620020b257600080fd5b80604085015250505050565b8035620020cb8162001e86565b919050565b8035600f81900b8114620020cb57600080fd5b620020ee81620020d0565b600f0b82526200210160208201620020d0565b600f0b60208301526200211760408201620020d0565b600f0b604083015260608101356fffffffffffffffffffffffffffffffff81168082146200214457600080fd5b80606085015250505050565b60208152600062002162838462001f46565b6101e060208501526200217b6102008501828462001fb4565b9150506200218d602085018562001f46565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0858403016040860152620021c483828462001fb4565b92505050620021da606084016040860162002043565b620021e860a08501620020be565b73ffffffffffffffffffffffffffffffffffffffff811660c08501525060c084013560e084015261010060e085013581850152610120818601358186015261014091508086013582860152506101608186013581860152620022516101808601828801620020e3565b5090949350505050565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b81811015620022a75785810183015185820160600152820162002289565b81811115620022ba576000606083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01692909201606001949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fdfe608060405260405162000a9338038062000a938339810160408190526200002691620004c6565b6200005360017fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d5162000594565b60008051602062000a4c83398151915214620000735762000073620005ba565b620000818282600062000089565b505062000641565b62000094836200015e565b6040516001600160a01b038416907f1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e90600090a2600082511180620000d65750805b15620001595762000157836001600160a01b0316635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200011f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001459190620005d0565b83620002ff60201b620000291760201c565b505b505050565b62000174816200032e60201b620000551760201c565b620001d45760405162461bcd60e51b815260206004820152602560248201527f455243313936373a206e657720626561636f6e206973206e6f74206120636f6e6044820152641d1c9858dd60da1b60648201526084015b60405180910390fd5b6200024e816001600160a01b0316635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000217573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200023d9190620005d0565b6200032e60201b620000551760201c565b620002b55760405162461bcd60e51b815260206004820152603060248201527f455243313936373a20626561636f6e20696d706c656d656e746174696f6e206960448201526f1cc81b9bdd08184818dbdb9d1c9858dd60821b6064820152608401620001cb565b80620002de60008051602062000a4c83398151915260001b6200033d60201b620000711760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b606062000327838360405180606001604052806027815260200162000a6c6027913962000340565b9392505050565b6001600160a01b03163b151590565b90565b60606001600160a01b0384163b620003aa5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401620001cb565b600080856001600160a01b031685604051620003c79190620005ee565b600060405180830381855af49150503d806000811462000404576040519150601f19603f3d011682016040523d82523d6000602084013e62000409565b606091505b5090925090506200041c82828662000426565b9695505050505050565b606083156200043757508162000327565b825115620004485782518084602001fd5b8160405162461bcd60e51b8152600401620001cb91906200060c565b80516001600160a01b03811681146200047c57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b83811015620004b45781810151838201526020016200049a565b83811115620001575750506000910152565b60008060408385031215620004da57600080fd5b620004e58362000464565b60208401519092506001600160401b03808211156200050357600080fd5b818501915085601f8301126200051857600080fd5b8151818111156200052d576200052d62000481565b604051601f8201601f19908116603f0116810190838211818310171562000558576200055862000481565b816040528281528860208487010111156200057257600080fd5b6200058583602083016020880162000497565b80955050505050509250929050565b600082821015620005b557634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b600060208284031215620005e357600080fd5b620003278262000464565b600082516200060281846020870162000497565b9190910192915050565b60208152600082518060208401526200062d81604085016020870162000497565b601f01601f19169190910160400192915050565b6103fb80620006516000396000f3fe60806040523661001357610011610017565b005b6100115b610027610022610074565b610127565b565b606061004e838360405180606001604052806027815260200161039f6027913961014b565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b90565b60006100b47fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d505473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff16635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156100fe573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061012291906102cb565b905090565b3660008037600080366000845af43d6000803e808015610146573d6000f35b3d6000fd5b606073ffffffffffffffffffffffffffffffffffffffff84163b6101f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6000808573ffffffffffffffffffffffffffffffffffffffff168560405161021e9190610331565b600060405180830381855af49150503d8060008114610259576040519150601f19603f3d011682016040523d82523d6000602084013e61025e565b606091505b509150915061026e828286610278565b9695505050505050565b6060831561028757508161004e565b8251156102975782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101ed919061034d565b6000602082840312156102dd57600080fd5b815173ffffffffffffffffffffffffffffffffffffffff8116811461004e57600080fd5b60005b8381101561031c578181015183820152602001610304565b8381111561032b576000848401525b50505050565b60008251610343818460208701610301565b9190910192915050565b602081526000825180602084015261036c816040850160208701610301565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212208ce966e1385eefb01b44b0d1cdba417199b04aa2fe5c746c59969a22757b9b3664736f6c634300080f0033a3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212207b63003df7f905db73bc6dfd429e1f3244bef25c4f88af0412ba6d9c9e0e7f9064736f6c634300080f0033", - "deployedBytecode": "0x60806040523480156200001157600080fd5b5060043610620002e45760003560e01c80637a7da0041162000199578063a36a363011620000e9578063d809aa611162000097578063e30c3978116200007a578063e30c39781462000638578063e975c0c31462000642578063f8dfc2cc146200064c57600080fd5b8063d809aa611462000617578063d8dfeb45146200062e57600080fd5b8063b0e21e8a11620000cc578063b0e21e8a14620005ec578063ba2de9bc14620005f6578063c0c53b8b146200060057600080fd5b8063a36a363014620005cb578063af2757b714620005d557600080fd5b80638da5cb5b11620001475780639fd0506d116200012a5780639fd0506d1462000593578063a123c33e146200059d578063a1eef78e14620005b457600080fd5b80638da5cb5b14620005725780638fbf1803146200057c57600080fd5b80637d254e66116200017c5780637d254e66146200050a5780637d49c1b7146200052d5780637fd29192146200053757600080fd5b80637a7da00414620004dc5780637c01369014620004f357600080fd5b80634c5430a0116200025557806365e821e5116200020357806366c0623911620001e657806366c0623914620004b15780636fc6407c14620004bb57806375907f2814620004c557600080fd5b806365e821e51462000483578063666e1b39146200049a57600080fd5b80635c975abb11620002385780635c975abb14620004075780635f1cc005146200042257806361d027b3146200047957600080fd5b80634c5430a014620003d9578063554bab3c14620003f057600080fd5b80632d809cb611620002b35780633ceda01111620002965780633ceda01114620003925780634256dd7814620003ab578063478739ca14620003c257600080fd5b80632d809cb61462000371578063391d0c9c146200038857600080fd5b806308cdc2a814620002e95780630d57036114620003025780632933d89114620003435780632b800e3b146200035a575b600080fd5b62000300620002fa36600462001df6565b62000663565b005b620003196200031336600462001e1a565b62000734565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b620003006200035436600462001e6c565b62000926565b620003196200036b36600462001e6c565b620009fe565b620003196200038236600462001eac565b62000a42565b6200031962000a79565b6200039c62000aa9565b6040519081526020016200033a565b62000300620003bc36600462001e6c565b62000ad4565b62000300620003d336600462001e6c565b62000bf1565b62000319620003ea36600462001e6c565b62000d0e565b620003006200040136600462001eac565b62000d73565b6200041162000e5a565b60405190151581526020016200033a565b620004396200043336600462001e6c565b62000e85565b60408051825173ffffffffffffffffffffffffffffffffffffffff908116825260208085015182169083015292820151909216908201526060016200033a565b6200031962000f13565b620003006200049436600462001eac565b62000f21565b62000319620004ab36600462001eac565b62001057565b6200039c62001088565b6200031962001094565b62000300620004d636600462001e6c565b620010bf565b62000300620004ed36600462001eac565b620011dc565b620003006200050436600462001eac565b62001312565b6200039c6200051b36600462001eac565b60016020526000908152604090205481565b6200039c62001448565b620004116200054836600462001eac565b73ffffffffffffffffffffffffffffffffffffffff16600090815260016020526040902054151590565b6200031962001473565b620003006200058d36600462001e6c565b62001481565b6200031962001587565b62000319620005ae36600462001e6c565b620015e9565b62000300620005c536600462001e6c565b62001630565b6200039c62001701565b62000300620005e636600462001ecc565b6200172c565b6200039c6200183c565b6200039c62001867565b620003006200061136600462001ef4565b62001892565b620003006200062836600462001e6c565b620019d1565b6200031962001aee565b6200031962001b19565b6200039c62001b27565b620003006200065d36600462001ecc565b62001b52565b6200066d62001587565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614620006d2576040517f84f8637600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620006fc7ff201e8b56b5ea8f1176ce6f2699cbe9659ba7491e9460c9d358ddf61400b5de3829055565b60405181151581527f31311016d7204faff81880133e3db244ae8a8b9ce15e83e2432258226d15f9429060200160405180910390a150565b6000826200074281620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614620007af576040517ff0a882b5000000000000000000000000000000000000000000000000000000008152600481018290526024015b60405180910390fd5b83600003620007ea576040517f7244bc7800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000620007f662000a79565b8460405160240162000809919062002150565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167ff0b4095900000000000000000000000000000000000000000000000000000000179052516200088b9062001de8565b620008989291906200225b565b604051809103906000f080158015620008b5573d6000803e3d6000fd5b5073ffffffffffffffffffffffffffffffffffffffff8116600081815260016020526040908190208890555191925082917f09d535073bc2dc21c8fd680a2141218a65fb0acc46e88b9e5d96f114b734b004906200091590889062002150565b60405180910390a295945050505050565b60006200093381620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146200099c576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b620009c67f2859911faffd405cbcc22bdad2f67b54a86355c092452044dbab4f656aec3dc9839055565b6040518281527fd19fe8ad9152af12b174a60210fb798db0767d63973ebb97298dc44d67a5c82d906020015b60405180910390a15050565b600080828154811062000a155762000a15620022ef565b600091825260209091206003909102015473ffffffffffffffffffffffffffffffffffffffff1692915050565b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604081205462000a739062000d0e565b92915050565b600062000aa47f81565bc82d6e7196d38320713fd94f897c0e1a4c83974a2fbbbf9fbb55a6d8a75490565b905090565b600062000aa47f1f7147efa84c5ef8ccb713891d25247c732a9d5765ebc3bb6cb30d1f17d277f05490565b600062000ae181620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462000b4a576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b62000b5e82670de0b6b3a764000062001c65565b1562000b96576040517f3c5df10400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000bc07f7b1a264a02657d43e78b10f2a591a99a0fdf8a165fb72bbf762d965e9973f64e839055565b6040518281527fd10d75876659a287a59a6ccfa2e3fff42f84d94b542837acd30bc184d562de4090602001620009f2565b600062000bfe81620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462000c67576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b62000c7b82670de0b6b3a764000062001c65565b1562000cb3576040517f0c6b0ec800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000cdd7f6f35922f1b8609c81847a86ce8bb2528f73d722df88772b050ac89d3bc48707d839055565b6040518281527fdf7e6bc55eeb2668bd338e44a5abb721b1f98ad51f7a00baaa1b62f9383862d790602001620009f2565b6000806000838154811062000d275762000d27620022ef565b600091825260209091206002600390920201015473ffffffffffffffffffffffffffffffffffffffff169050801562000d61578062000d6c565b62000d6c83620015e9565b9392505050565b600062000d8081620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462000de9576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b62000e137fc641ae699093d5be5b0b167620fe782b911b5015c8c9f6e14207530ddda0d020839055565b60405173ffffffffffffffffffffffffffffffffffffffff831681527fa4336c0cb1e245b95ad204faed7e940d6dc999684fd8b5e1ff597a0c4efca8ab90602001620009f2565b600062000aa47ff201e8b56b5ea8f1176ce6f2699cbe9659ba7491e9460c9d358ddf61400b5de35490565b60408051606081018252600080825260208201819052918101919091526000828154811062000eb85762000eb8620022ef565b6000918252602091829020604080516060810182526003909302909101805473ffffffffffffffffffffffffffffffffffffffff90811684526001820154811694840194909452600201549092169181019190915292915050565b600062000aa4600062000d0e565b600062000f2e81620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462000f97576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b73ffffffffffffffffffffffffffffffffffffffff82163b62000fe6576040517fe939acbc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620010107fcbd1a41d9e21eb02a3acb8d57f9495422d3837dd84bf5dfbc51964fe540cff41839055565b60405173ffffffffffffffffffffffffffffffffffffffff831681527f18c973e70eca8db74eab2a3e0de3c4bffcc46c45f6f17f600e2d4d4f744e2a2b90602001620009f2565b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604081205462000a7390620015e9565b600062000aa462001c7d565b600062000aa47fcbd1a41d9e21eb02a3acb8d57f9495422d3837dd84bf5dfbc51964fe540cff415490565b6000620010cc81620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462001135576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b6200114982670de0b6b3a764000062001c65565b1562001181576040517fb4c4f79900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620011ab7fdf23e6978beb49efbffd02ffd26ec2f120b1e5be191aa5749bafaa170026fb09839055565b6040518281527f1a35ca75fc5ab34ae3487b3507e7453b6e4c15a69f2392939fbbcf8f64558ad190602001620009f2565b6000620011e981620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462001252576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b73ffffffffffffffffffffffffffffffffffffffff82163b620012a1576040517fe939acbc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620012cb7f9a67237eef0f801c1f3a0e6be772257326890fecbd39f68c5f7bb69ca7c408c3839055565b60405173ffffffffffffffffffffffffffffffffffffffff831681527fa0fe5cb0e8843811ca9f6123983dcdfd45a33b61892b9b8f380ed444078e299a90602001620009f2565b60006200131f81620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462001388576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b73ffffffffffffffffffffffffffffffffffffffff82163b620013d7576040517fe939acbc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620014017f81565bc82d6e7196d38320713fd94f897c0e1a4c83974a2fbbbf9fbb55a6d8a7839055565b60405173ffffffffffffffffffffffffffffffffffffffff831681527f36466d973cc33c9b726f867d2fc1f8cd56d58de206993f62ccba543a3429ea6290602001620009f2565b600062000aa47fd665791d8a3246c9a2360cb3de854da1c9536240e0380f1f5c2dd0e6b8b7c8605490565b600062000aa46000620015e9565b6000808281548110620014985762001498620022ef565b60009182526020909120600390910201805490915073ffffffffffffffffffffffffffffffffffffffff1633811462001501576040517f07f41a5f00000000000000000000000000000000000000000000000000000000815260048101849052602401620007a6565b81547fffffffffffffffffffffffff0000000000000000000000000000000000000000908116835560018301805473ffffffffffffffffffffffffffffffffffffffff841692168217905560405190815283907f87c983c6a4d6d9a68e6d99934d1fb50f760858298c06f8ed6b316f534e06faf4906020015b60405180910390a2505050565b600080620015b37fc641ae699093d5be5b0b167620fe782b911b5015c8c9f6e14207530ddda0d0205490565b905073ffffffffffffffffffffffffffffffffffffffff811615620015d95780620015e3565b620015e362001473565b91505090565b6000808281548110620016005762001600620022ef565b600091825260209091206001600390920201015473ffffffffffffffffffffffffffffffffffffffff1692915050565b60006200163d81620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614620016a6576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b620016d07fd665791d8a3246c9a2360cb3de854da1c9536240e0380f1f5c2dd0e6b8b7c860839055565b6040518281527f7e6452dce5202ad16be30ea14955296f7157b95e4ca48b73fc54d54601185adf90602001620009f2565b600062000aa47fdf23e6978beb49efbffd02ffd26ec2f120b1e5be191aa5749bafaa170026fb095490565b816200173881620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614620017a1576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b8160008481548110620017b857620017b8620022ef565b60009182526020918290206003919091020180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff938416179055604051918416825284917f0bffd4439c17923ee1b2b093be5394c42dcab0d9394e349a8d6a059c239ba60391016200157a565b600062000aa47f7b1a264a02657d43e78b10f2a591a99a0fdf8a165fb72bbf762d965e9973f64e5490565b600062000aa47f2859911faffd405cbcc22bdad2f67b54a86355c092452044dbab4f656aec3dc95490565b600180620018be7f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b5490565b10620018fa576040517f1e7a9d9500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b620019247f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b829055565b60017fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c556200195262001c7d565b506200195e84620011dc565b620019698362000f21565b620019748262001312565b60007fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c556040518181527fbe9b076dc5b65990cca9dd9d7366682482e7817a6f6bc7f4faf4dc32af497f329060200160405180910390a150505050565b6000620019de81620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462001a47576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b62001a5b82670de0b6b3a764000062001c65565b1562001a93576040517f7c3ceda900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62001abd7f1f7147efa84c5ef8ccb713891d25247c732a9d5765ebc3bb6cb30d1f17d277f0839055565b6040518281527f852c049e335a49416ecbcb0128935cc3832c307d450d206f0a2d0bf2b28ba2db90602001620009f2565b600062000aa47f9a67237eef0f801c1f3a0e6be772257326890fecbd39f68c5f7bb69ca7c408c35490565b600062000aa46000620009fe565b600062000aa47f6f35922f1b8609c81847a86ce8bb2528f73d722df88772b050ac89d3bc48707d5490565b8162001b5e81620015e9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161462001bc7576040517ff0a882b500000000000000000000000000000000000000000000000000000000815260048101829052602401620007a6565b816000848154811062001bde5762001bde620022ef565b60009182526020918290206003919091020160020180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff938416179055604051918416825284917fffd31ccade46a73a57d8efd7d740bbf6aa67e50a158c98ad82a06ad31556cef491016200157a565b600062001c73838362001daf565b6002149392505050565b600080546040805160608101825283815233602080830182815283850187815260018701885587805293517f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5636003880290810180547fffffffffffffffffffffffff000000000000000000000000000000000000000090811673ffffffffffffffffffffffffffffffffffffffff9485161790915592517f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e56482018054851691841691909117905594517f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5659095018054909216941693909317909255915191825282917f645c9ae30d6a6aa6b2dace770fa0cfac2d8d44b9b036510e0a16aab39e6b5931910160405180910390a2919050565b600082828082111562001dc85760029250505062000a73565b8082101562001ddd5760009250505062000a73565b506001949350505050565b610a93806200231f83390190565b60006020828403121562001e0957600080fd5b8135801515811462000d6c57600080fd5b6000806040838503121562001e2e57600080fd5b82359150602083013567ffffffffffffffff81111562001e4d57600080fd5b83016101e0818603121562001e6157600080fd5b809150509250929050565b60006020828403121562001e7f57600080fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff8116811462001ea957600080fd5b50565b60006020828403121562001ebf57600080fd5b813562000d6c8162001e86565b6000806040838503121562001ee057600080fd5b82359150602083013562001e618162001e86565b60008060006060848603121562001f0a57600080fd5b833562001f178162001e86565b9250602084013562001f298162001e86565b9150604084013562001f3b8162001e86565b809150509250925092565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811262001f7c57600080fd5b830160208101925035905067ffffffffffffffff81111562001f9d57600080fd5b80360382131562001fad57600080fd5b9250929050565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b6002811062001ea957600080fd5b6002811062001ea9577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b8035620020508162001ffd565b6200205b816200200b565b825260208101356200206d8162001ffd565b62002078816200200b565b602083015260408101357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00008116808214620020b257600080fd5b80604085015250505050565b8035620020cb8162001e86565b919050565b8035600f81900b8114620020cb57600080fd5b620020ee81620020d0565b600f0b82526200210160208201620020d0565b600f0b60208301526200211760408201620020d0565b600f0b604083015260608101356fffffffffffffffffffffffffffffffff81168082146200214457600080fd5b80606085015250505050565b60208152600062002162838462001f46565b6101e060208501526200217b6102008501828462001fb4565b9150506200218d602085018562001f46565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0858403016040860152620021c483828462001fb4565b92505050620021da606084016040860162002043565b620021e860a08501620020be565b73ffffffffffffffffffffffffffffffffffffffff811660c08501525060c084013560e084015261010060e085013581850152610120818601358186015261014091508086013582860152506101608186013581860152620022516101808601828801620020e3565b5090949350505050565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b81811015620022a75785810183015185820160600152820162002289565b81811115620022ba576000606083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01692909201606001949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fdfe608060405260405162000a9338038062000a938339810160408190526200002691620004c6565b6200005360017fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d5162000594565b60008051602062000a4c83398151915214620000735762000073620005ba565b620000818282600062000089565b505062000641565b62000094836200015e565b6040516001600160a01b038416907f1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e90600090a2600082511180620000d65750805b15620001595762000157836001600160a01b0316635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200011f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001459190620005d0565b83620002ff60201b620000291760201c565b505b505050565b62000174816200032e60201b620000551760201c565b620001d45760405162461bcd60e51b815260206004820152602560248201527f455243313936373a206e657720626561636f6e206973206e6f74206120636f6e6044820152641d1c9858dd60da1b60648201526084015b60405180910390fd5b6200024e816001600160a01b0316635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000217573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200023d9190620005d0565b6200032e60201b620000551760201c565b620002b55760405162461bcd60e51b815260206004820152603060248201527f455243313936373a20626561636f6e20696d706c656d656e746174696f6e206960448201526f1cc81b9bdd08184818dbdb9d1c9858dd60821b6064820152608401620001cb565b80620002de60008051602062000a4c83398151915260001b6200033d60201b620000711760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b606062000327838360405180606001604052806027815260200162000a6c6027913962000340565b9392505050565b6001600160a01b03163b151590565b90565b60606001600160a01b0384163b620003aa5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401620001cb565b600080856001600160a01b031685604051620003c79190620005ee565b600060405180830381855af49150503d806000811462000404576040519150601f19603f3d011682016040523d82523d6000602084013e62000409565b606091505b5090925090506200041c82828662000426565b9695505050505050565b606083156200043757508162000327565b825115620004485782518084602001fd5b8160405162461bcd60e51b8152600401620001cb91906200060c565b80516001600160a01b03811681146200047c57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b83811015620004b45781810151838201526020016200049a565b83811115620001575750506000910152565b60008060408385031215620004da57600080fd5b620004e58362000464565b60208401519092506001600160401b03808211156200050357600080fd5b818501915085601f8301126200051857600080fd5b8151818111156200052d576200052d62000481565b604051601f8201601f19908116603f0116810190838211818310171562000558576200055862000481565b816040528281528860208487010111156200057257600080fd5b6200058583602083016020880162000497565b80955050505050509250929050565b600082821015620005b557634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b600060208284031215620005e357600080fd5b620003278262000464565b600082516200060281846020870162000497565b9190910192915050565b60208152600082518060208401526200062d81604085016020870162000497565b601f01601f19169190910160400192915050565b6103fb80620006516000396000f3fe60806040523661001357610011610017565b005b6100115b610027610022610074565b610127565b565b606061004e838360405180606001604052806027815260200161039f6027913961014b565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b90565b60006100b47fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d505473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff16635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156100fe573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061012291906102cb565b905090565b3660008037600080366000845af43d6000803e808015610146573d6000f35b3d6000fd5b606073ffffffffffffffffffffffffffffffffffffffff84163b6101f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6000808573ffffffffffffffffffffffffffffffffffffffff168560405161021e9190610331565b600060405180830381855af49150503d8060008114610259576040519150601f19603f3d011682016040523d82523d6000602084013e61025e565b606091505b509150915061026e828286610278565b9695505050505050565b6060831561028757508161004e565b8251156102975782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101ed919061034d565b6000602082840312156102dd57600080fd5b815173ffffffffffffffffffffffffffffffffffffffff8116811461004e57600080fd5b60005b8381101561031c578181015183820152602001610304565b8381111561032b576000848401525b50505050565b60008251610343818460208701610301565b9190910192915050565b602081526000825180602084015261036c816040850160208701610301565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212208ce966e1385eefb01b44b0d1cdba417199b04aa2fe5c746c59969a22757b9b3664736f6c634300080f0033a3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212207b63003df7f905db73bc6dfd429e1f3244bef25c4f88af0412ba6d9c9e0e7f9064736f6c634300080f0033", - "devdoc": { - "kind": "dev", - "methods": { - "acceptCoordinatorOwner(uint256)": { - "details": "Must be called by the coordinator's pending owner", - "params": { - "coordinatorId": "Coordinator to update" - } - }, - "coordinators(uint256)": { - "params": { - "coordinatorId": "Coordinator to return for" - }, - "returns": { - "_0": "Coordinator state" - } - }, - "createCoordinator()": { - "details": "Can only be called by the protocol owner", - "returns": { - "_0": "New coordinator ID" - } - }, - "createProduct(uint256,(string,string,(uint8,uint8,bytes30),address,uint256,uint256,uint256,uint256,uint256,(int128,int128,int128,uint128)))": { - "details": "Can only be called by the coordinator owner", - "params": { - "coordinatorId": "Coordinator that will own the product", - "productInfo": "Product params used to initialize the product" - }, - "returns": { - "_0": "New product contract address" - } - }, - "initialize(address,address,address)": { - "details": "Must be called atomically as part of the upgradeable proxy deployment to avoid front-running", - "params": { - "collateral_": "Collateral contract address", - "incentivizer_": "Incentivizer contract address", - "productBeacon_": "Product implementation beacon address" - } - }, - "isProduct(address)": { - "params": { - "product": "Contract address to check" - }, - "returns": { - "_0": "Whether a contract is a product" - } - }, - "owner()": { - "returns": { - "_0": "Owner of the protocol" - } - }, - "owner(address)": { - "params": { - "product": "Product to return for" - }, - "returns": { - "_0": "Owner of the product" - } - }, - "owner(uint256)": { - "params": { - "coordinatorId": "Coordinator to return for" - }, - "returns": { - "_0": "Owner of the coordinator" - } - }, - "pendingOwner()": { - "returns": { - "_0": "Owner of the protocol" - } - }, - "pendingOwner(uint256)": { - "params": { - "coordinatorId": "Coordinator to return for" - }, - "returns": { - "_0": "Pending owner of the coordinator" - } - }, - "treasury()": { - "details": "Defaults to the `owner` when `treasury` is unset", - "returns": { - "_0": "Treasury of the protocol" - } - }, - "treasury(address)": { - "details": "Defaults to the `owner` when `treasury` is unset", - "params": { - "product": "Product to return for" - }, - "returns": { - "_0": "Treasury of the product" - } - }, - "treasury(uint256)": { - "details": "Defaults to the `owner` when `treasury` is unset", - "params": { - "coordinatorId": "Coordinator to return for" - }, - "returns": { - "_0": "Treasury of the coordinator" - } - }, - "updateCollateral(address)": { - "params": { - "newCollateral": "New Collateral contract address" - } - }, - "updateCoordinatorPendingOwner(uint256,address)": { - "details": "Must be called by the coordinator's current owner", - "params": { - "coordinatorId": "Coordinator to update", - "newPendingOwner": "New pending owner address" - } - }, - "updateCoordinatorTreasury(uint256,address)": { - "details": "Must be called by the coordinator's current owner. Defaults to the coordinator `owner` if set to address(0)", - "params": { - "coordinatorId": "Coordinator to update", - "newTreasury": "New treasury address" - } - }, - "updateIncentivizationFee(uint256)": { - "params": { - "newIncentivizationFee": "New incentivization fee" - } - }, - "updateIncentivizer(address)": { - "params": { - "newIncentivizer": "New Incentivizer contract address" - } - }, - "updateLiquidationFee(uint256)": { - "params": { - "newLiquidationFee": "New liquidation fee" - } - }, - "updateMinCollateral(uint256)": { - "params": { - "newMinCollateral": "New minimum allowed collateral amount" - } - }, - "updateMinFundingFee(uint256)": { - "params": { - "newMinFundingFee": "New minimum allowed funding fee" - } - }, - "updatePaused(bool)": { - "params": { - "newPaused": "New protocol paused state" - } - }, - "updatePauser(address)": { - "params": { - "newPauser": "New protocol pauser address" - } - }, - "updateProductBeacon(address)": { - "params": { - "newProductBeacon": "New Product implementation beacon address" - } - }, - "updateProgramsPerProduct(uint256)": { - "params": { - "newProgramsPerProduct": "New maximum incentivization programs per product allowed" - } - }, - "updateProtocolFee(uint256)": { - "params": { - "newProtocolFee": "New protocol-product fee split" - } - } - }, - "stateVariables": { - "_collateral": { - "details": "Collateral contract address for the protocol" - }, - "_coordinators": { - "details": "List of product coordinators" - }, - "_incentivizationFee": { - "details": "Fee on incentivization programs" - }, - "_incentivizer": { - "details": "Incentivizer contract address for the protocol" - }, - "_liquidationFee": { - "details": "Fee on maintenance for liquidation" - }, - "_minCollateral": { - "details": "Minimum allowable collateral amount per user account" - }, - "_minFundingFee": { - "details": "Minimum allowable funding fee for a product" - }, - "_paused": { - "details": "The paused status of the protocol" - }, - "_pauser": { - "details": "Protocol pauser address. address(0) defaults to owner(0)" - }, - "_productBeacon": { - "details": "Product implementation beacon address for the protocol" - }, - "_programsPerProduct": { - "details": "Maximum incentivization programs per product allowed" - }, - "_protocolFee": { - "details": "Percent of collected fees that go to the protocol treasury vs the product treasury" - }, - "coordinatorFor": { - "details": "Mapping of the coordinator for each product" - } - }, - "title": "Controller", - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": { - "acceptCoordinatorOwner(uint256)": { - "notice": "Accepts ownership over an existing coordinator" - }, - "coordinators(uint256)": { - "notice": "Returns coordinator state for coordinator `coordinatorId`" - }, - "createCoordinator()": { - "notice": "Creates a new coordinator with `msg.sender` as the owner" - }, - "createProduct(uint256,(string,string,(uint8,uint8,bytes30),address,uint256,uint256,uint256,uint256,uint256,(int128,int128,int128,uint128)))": { - "notice": "Creates a new product market with `provider`" - }, - "initialize(address,address,address)": { - "notice": "Initializes the contract state" - }, - "isProduct(address)": { - "notice": "Returns whether a contract is a product" - }, - "owner()": { - "notice": "Returns the owner of the protocol" - }, - "owner(address)": { - "notice": "Returns the owner of the product `product`" - }, - "owner(uint256)": { - "notice": "Returns the owner of the coordinator `coordinatorId`" - }, - "pendingOwner()": { - "notice": "Returns the pending owner of the protocol" - }, - "pendingOwner(uint256)": { - "notice": "Returns the pending owner of the coordinator `coordinatorId`" - }, - "treasury()": { - "notice": "Returns the treasury of the protocol" - }, - "treasury(address)": { - "notice": "Returns the treasury of the product `product`" - }, - "treasury(uint256)": { - "notice": "Returns the treasury of the coordinator `coordinatorId`" - }, - "updateCollateral(address)": { - "notice": "Updates the Collateral contract address" - }, - "updateCoordinatorPendingOwner(uint256,address)": { - "notice": "Updates the pending owner of an existing coordinator" - }, - "updateCoordinatorTreasury(uint256,address)": { - "notice": "Updates the treasury of an existing coordinator" - }, - "updateIncentivizationFee(uint256)": { - "notice": "Updates the incentivization fee" - }, - "updateIncentivizer(address)": { - "notice": "Updates the Incentivizer contract address" - }, - "updateLiquidationFee(uint256)": { - "notice": "Updates the liquidation fee" - }, - "updateMinCollateral(uint256)": { - "notice": "Updates the minimum allowed collateral amount per user account" - }, - "updateMinFundingFee(uint256)": { - "notice": "Updates the minimum allowed funding fee" - }, - "updatePaused(bool)": { - "notice": "Updates the protocol paused state" - }, - "updatePauser(address)": { - "notice": "Updates the protocol pauser address. Zero address defaults to owner(0)" - }, - "updateProductBeacon(address)": { - "notice": "Updates the Product implementation beacon address" - }, - "updateProgramsPerProduct(uint256)": { - "notice": "Updates the maximum incentivization programs per product allowed" - }, - "updateProtocolFee(uint256)": { - "notice": "Updates the protocol-product fee split" - } - }, - "notice": "Manages creating new products and global protocol parameters.", - "version": 1 - }, - "storageLayout": { - "storage": [ - { - "astId": 11565, - "contract": "contracts/controller/Controller.sol:Controller", - "label": "_coordinators", - "offset": 0, - "slot": "0", - "type": "t_array(t_struct(Coordinator)14688_storage)dyn_storage" - }, - { - "astId": 11571, - "contract": "contracts/controller/Controller.sol:Controller", - "label": "coordinatorFor", - "offset": 0, - "slot": "1", - "type": "t_mapping(t_contract(IProduct)16058,t_uint256)" - } - ], - "types": { - "t_address": { - "encoding": "inplace", - "label": "address", - "numberOfBytes": "20" - }, - "t_array(t_struct(Coordinator)14688_storage)dyn_storage": { - "base": "t_struct(Coordinator)14688_storage", - "encoding": "dynamic_array", - "label": "struct IController.Coordinator[]", - "numberOfBytes": "32" - }, - "t_contract(IProduct)16058": { - "encoding": "inplace", - "label": "contract IProduct", - "numberOfBytes": "20" - }, - "t_mapping(t_contract(IProduct)16058,t_uint256)": { - "encoding": "mapping", - "key": "t_contract(IProduct)16058", - "label": "mapping(contract IProduct => uint256)", - "numberOfBytes": "32", - "value": "t_uint256" - }, - "t_struct(Coordinator)14688_storage": { - "encoding": "inplace", - "label": "struct IController.Coordinator", - "members": [ - { - "astId": 14681, - "contract": "contracts/controller/Controller.sol:Controller", - "label": "pendingOwner", - "offset": 0, - "slot": "0", - "type": "t_address" - }, - { - "astId": 14684, - "contract": "contracts/controller/Controller.sol:Controller", - "label": "owner", - "offset": 0, - "slot": "1", - "type": "t_address" - }, - { - "astId": 14687, - "contract": "contracts/controller/Controller.sol:Controller", - "label": "treasury", - "offset": 0, - "slot": "2", - "type": "t_address" - } - ], - "numberOfBytes": "96" - }, - "t_uint256": { - "encoding": "inplace", - "label": "uint256", - "numberOfBytes": "32" - } - } - } -} diff --git a/packages/perennial/deployments/kovan/Controller_Proxy.json b/packages/perennial/deployments/kovan/Controller_Proxy.json deleted file mode 100644 index e2253919e..000000000 --- a/packages/perennial/deployments/kovan/Controller_Proxy.json +++ /dev/null @@ -1,229 +0,0 @@ -{ - "address": "0x1927DE7c9765Ae74050D1d0aa8BB0e93D737F579", - "abi": [ - { - "inputs": [ - { - "internalType": "address", - "name": "_logic", - "type": "address" - }, - { - "internalType": "address", - "name": "admin_", - "type": "address" - }, - { - "internalType": "bytes", - "name": "_data", - "type": "bytes" - } - ], - "stateMutability": "payable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "previousAdmin", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "newAdmin", - "type": "address" - } - ], - "name": "AdminChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "beacon", - "type": "address" - } - ], - "name": "BeaconUpgraded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "implementation", - "type": "address" - } - ], - "name": "Upgraded", - "type": "event" - }, - { - "stateMutability": "payable", - "type": "fallback" - }, - { - "inputs": [], - "name": "admin", - "outputs": [ - { - "internalType": "address", - "name": "admin_", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newAdmin", - "type": "address" - } - ], - "name": "changeAdmin", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "implementation", - "outputs": [ - { - "internalType": "address", - "name": "implementation_", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newImplementation", - "type": "address" - } - ], - "name": "upgradeTo", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newImplementation", - "type": "address" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "upgradeToAndCall", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "stateMutability": "payable", - "type": "receive" - } - ], - "transactionHash": "0x60ce3a271de5d558155a1018817e9913c94b09432d93068ce95d3704dbab209a", - "receipt": { - "to": null, - "from": "0x66a7fDB96C583c59597de16d8b2B989231415339", - "contractAddress": "0x1927DE7c9765Ae74050D1d0aa8BB0e93D737F579", - "transactionIndex": 0, - "gasUsed": "690597", - "logsBloom": "0x00000000000000000000000000000000400000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000001000000000000000000000000000000000800000000000000000000000020000000000000000000000000000000000000000000000000020000000000000000000000000000000000400000000000000000200800000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x8518f79b693a3a83f7dc8ec021de1a1febcbe2b2d0096ac5c1dd89189b39d60d", - "transactionHash": "0x60ce3a271de5d558155a1018817e9913c94b09432d93068ce95d3704dbab209a", - "logs": [ - { - "transactionIndex": 0, - "blockNumber": 33203745, - "transactionHash": "0x60ce3a271de5d558155a1018817e9913c94b09432d93068ce95d3704dbab209a", - "address": "0x1927DE7c9765Ae74050D1d0aa8BB0e93D737F579", - "topics": [ - "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x0000000000000000000000000818e46c726810c2f7a1c513d0637a862bc0df6f" - ], - "data": "0x", - "logIndex": 0, - "blockHash": "0x8518f79b693a3a83f7dc8ec021de1a1febcbe2b2d0096ac5c1dd89189b39d60d" - }, - { - "transactionIndex": 0, - "blockNumber": 33203745, - "transactionHash": "0x60ce3a271de5d558155a1018817e9913c94b09432d93068ce95d3704dbab209a", - "address": "0x1927DE7c9765Ae74050D1d0aa8BB0e93D737F579", - "topics": ["0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f"], - "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffe829f928cb8c07961bfff04512ac0749d65d27", - "logIndex": 1, - "blockHash": "0x8518f79b693a3a83f7dc8ec021de1a1febcbe2b2d0096ac5c1dd89189b39d60d" - } - ], - "blockNumber": 33203745, - "cumulativeGasUsed": "690597", - "status": 1, - "byzantium": true - }, - "args": ["0x0818E46C726810c2f7a1C513D0637a862bc0df6F", "0xfFE829F928Cb8C07961bfFF04512ac0749d65d27", "0x"], - "numDeployments": 1, - "solcInputHash": "dd52f03d8fef7833844e4ba864fd9fba", - "metadata": "{\"compiler\":{\"version\":\"0.8.15+commit.e14f2714\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // 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\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\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 ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\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(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\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 /**\\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 {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x60806040526040516200112838038062001128833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b600080516020620010e1833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b600080516020620010c183398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b6200028c1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e98383604051806060016040528060278152602001620011016027913962000381565b9392505050565b60006200021a600080516020620010c183398151915260001b6200046760201b6200022e1760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd600080516020620010c183398151915260001b6200046760201b6200022e1760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b620002b81760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd600080516020620010e183398151915260001b6200046760201b6200022e1760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610a2980620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b610090366004610895565b610135565b61006b6100a33660046108b0565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b610101366004610895565b610231565b34801561011257600080fd5b506100bd61025e565b6101236102d4565b61013361012e6103ab565b6103b5565b565b61013d6103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481604051806020016040528060008152506000610419565b50565b61017461011b565b6101876103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610419915050565b505050565b6101e661011b565b60006101fd6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103ab565b905090565b61022e61011b565b90565b6102396103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481610444565b60006102686103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103d9565b60606102b183836040518060600160405280602781526020016109cd602791396104a5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6102dc6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102216105cd565b3660008037600080366000845af43d6000803e8080156103d4573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b610422836105f5565b60008251118061042f5750805b156101e65761043e838361028c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61046d6103d9565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161017481610642565b606073ffffffffffffffffffffffffffffffffffffffff84163b61054b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103a2565b6000808573ffffffffffffffffffffffffffffffffffffffff1685604051610573919061095f565b600060405180830381855af49150503d80600081146105ae576040519150601f19603f3d011682016040523d82523d6000602084013e6105b3565b606091505b50915091506105c382828661074e565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103fd565b6105fe816107a1565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff81166106e5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103a2565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060831561075d5750816102b1565b82511561076d5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a2919061097b565b73ffffffffffffffffffffffffffffffffffffffff81163b610845576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103a2565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610708565b803573ffffffffffffffffffffffffffffffffffffffff8116811461089057600080fd5b919050565b6000602082840312156108a757600080fd5b6102b18261086c565b6000806000604084860312156108c557600080fd5b6108ce8461086c565b9250602084013567ffffffffffffffff808211156108eb57600080fd5b818601915086601f8301126108ff57600080fd5b81358181111561090e57600080fd5b87602082850101111561092057600080fd5b6020830194508093505050509250925092565b60005b8381101561094e578181015183820152602001610936565b8381111561043e5750506000910152565b60008251610971818460208701610933565b9190910192915050565b602081526000825180602084015261099a816040850160208701610933565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a4b930408c511c08d53f1ec84bb13fe259938b06e5d586d6adc4fc27200abe6c64736f6c634300080f0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", - "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b610090366004610895565b610135565b61006b6100a33660046108b0565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b610101366004610895565b610231565b34801561011257600080fd5b506100bd61025e565b6101236102d4565b61013361012e6103ab565b6103b5565b565b61013d6103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481604051806020016040528060008152506000610419565b50565b61017461011b565b6101876103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610419915050565b505050565b6101e661011b565b60006101fd6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103ab565b905090565b61022e61011b565b90565b6102396103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481610444565b60006102686103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103d9565b60606102b183836040518060600160405280602781526020016109cd602791396104a5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6102dc6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102216105cd565b3660008037600080366000845af43d6000803e8080156103d4573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b610422836105f5565b60008251118061042f5750805b156101e65761043e838361028c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61046d6103d9565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161017481610642565b606073ffffffffffffffffffffffffffffffffffffffff84163b61054b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103a2565b6000808573ffffffffffffffffffffffffffffffffffffffff1685604051610573919061095f565b600060405180830381855af49150503d80600081146105ae576040519150601f19603f3d011682016040523d82523d6000602084013e6105b3565b606091505b50915091506105c382828661074e565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103fd565b6105fe816107a1565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff81166106e5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103a2565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060831561075d5750816102b1565b82511561076d5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a2919061097b565b73ffffffffffffffffffffffffffffffffffffffff81163b610845576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103a2565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610708565b803573ffffffffffffffffffffffffffffffffffffffff8116811461089057600080fd5b919050565b6000602082840312156108a757600080fd5b6102b18261086c565b6000806000604084860312156108c557600080fd5b6108ce8461086c565b9250602084013567ffffffffffffffff808211156108eb57600080fd5b818601915086601f8301126108ff57600080fd5b81358181111561090e57600080fd5b87602082850101111561092057600080fd5b6020830194508093505050509250925092565b60005b8381101561094e578181015183820152602001610936565b8381111561043e5750506000910152565b60008251610971818460208701610933565b9190910192915050565b602081526000825180602084015261099a816040850160208701610933565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a4b930408c511c08d53f1ec84bb13fe259938b06e5d586d6adc4fc27200abe6c64736f6c634300080f0033", - "devdoc": { - "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", - "kind": "dev", - "methods": { - "admin()": { - "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" - }, - "changeAdmin(address)": { - "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." - }, - "constructor": { - "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." - }, - "implementation()": { - "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" - }, - "upgradeTo(address)": { - "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." - }, - "upgradeToAndCall(address,bytes)": { - "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." - } - }, - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": {}, - "version": 1 - }, - "storageLayout": { - "storage": [], - "types": null - } -} diff --git a/packages/perennial/deployments/kovan/Forwarder.json b/packages/perennial/deployments/kovan/Forwarder.json deleted file mode 100644 index c5ef9cbbe..000000000 --- a/packages/perennial/deployments/kovan/Forwarder.json +++ /dev/null @@ -1,239 +0,0 @@ -{ - "address": "0x3E07fb7fC029ABf8B1d44b0aa8FFE6cA6C5C1606", - "abi": [ - { - "inputs": [ - { - "internalType": "Token6", - "name": "usdc_", - "type": "address" - }, - { - "internalType": "Token18", - "name": "dsu_", - "type": "address" - }, - { - "internalType": "contract IBatcher", - "name": "batcher_", - "type": "address" - }, - { - "internalType": "contract ICollateral", - "name": "collateral_", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [], - "name": "ForwarderNotContractAddressError", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "WrapAndDeposit", - "type": "event" - }, - { - "inputs": [], - "name": "DSU", - "outputs": [ - { - "internalType": "Token18", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "USDC", - "outputs": [ - { - "internalType": "Token6", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "batcher", - "outputs": [ - { - "internalType": "contract IBatcher", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "collateral", - "outputs": [ - { - "internalType": "contract ICollateral", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "wrapAndDeposit", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } - ], - "transactionHash": "0xe8ce05b92280435b6688759679f3f8015b58df6c35754b23c2705f8c8c78f3b7", - "receipt": { - "to": null, - "from": "0x66a7fDB96C583c59597de16d8b2B989231415339", - "contractAddress": "0x3E07fb7fC029ABf8B1d44b0aa8FFE6cA6C5C1606", - "transactionIndex": 1, - "gasUsed": "788417", - "logsBloom": "0x00020000000002000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000002000200000140000000800000000000000000000000000000000000000000000200000000000040000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000020000000000000000000000010000000000000010000000000000000000000000000000000000000040000", - "blockHash": "0x4c1ad4c788a84f77dbc80fbb0f1dbe1083f001ac0958129bfd5db4c5ca3c6e55", - "transactionHash": "0xe8ce05b92280435b6688759679f3f8015b58df6c35754b23c2705f8c8c78f3b7", - "logs": [ - { - "transactionIndex": 1, - "blockNumber": 33203896, - "transactionHash": "0xe8ce05b92280435b6688759679f3f8015b58df6c35754b23c2705f8c8c78f3b7", - "address": "0xb7a4F3E9097C08dA09517b5aB877F7a917224ede", - "topics": [ - "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", - "0x0000000000000000000000003e07fb7fc029abf8b1d44b0aa8ffe6ca6c5c1606", - "0x000000000000000000000000d9a05f4b6277cd968f60c05f498f6e3719469c2f" - ], - "data": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "logIndex": 0, - "blockHash": "0x4c1ad4c788a84f77dbc80fbb0f1dbe1083f001ac0958129bfd5db4c5ca3c6e55" - }, - { - "transactionIndex": 1, - "blockNumber": 33203896, - "transactionHash": "0xe8ce05b92280435b6688759679f3f8015b58df6c35754b23c2705f8c8c78f3b7", - "address": "0x1e7d42D73291A9580F1f9b6483928319CE1c3d75", - "topics": [ - "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", - "0x0000000000000000000000003e07fb7fc029abf8b1d44b0aa8ffe6ca6c5c1606", - "0x000000000000000000000000877682c7a8840d59a63a6227ed2aeb20c3ae7feb" - ], - "data": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "logIndex": 1, - "blockHash": "0x4c1ad4c788a84f77dbc80fbb0f1dbe1083f001ac0958129bfd5db4c5ca3c6e55" - } - ], - "blockNumber": 33203896, - "cumulativeGasUsed": "890583", - "status": 1, - "byzantium": true - }, - "args": [ - "0xb7a4F3E9097C08dA09517b5aB877F7a917224ede", - "0x1e7d42D73291A9580F1f9b6483928319CE1c3d75", - "0xd9a05F4b6277cD968F60C05f498F6e3719469c2f", - "0x877682C7a8840D59A63a6227ED2Aeb20C3ae7FeB" - ], - "numDeployments": 1, - "solcInputHash": "dd52f03d8fef7833844e4ba864fd9fba", - "metadata": "{\"compiler\":{\"version\":\"0.8.15+commit.e14f2714\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"Token6\",\"name\":\"usdc_\",\"type\":\"address\"},{\"internalType\":\"Token18\",\"name\":\"dsu_\",\"type\":\"address\"},{\"internalType\":\"contract IBatcher\",\"name\":\"batcher_\",\"type\":\"address\"},{\"internalType\":\"contract ICollateral\",\"name\":\"collateral_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"ForwarderNotContractAddressError\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"WrapAndDeposit\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DSU\",\"outputs\":[{\"internalType\":\"Token18\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"USDC\",\"outputs\":[{\"internalType\":\"Token6\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"batcher\",\"outputs\":[{\"internalType\":\"contract IBatcher\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"collateral\",\"outputs\":[{\"internalType\":\"contract ICollateral\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"wrapAndDeposit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"constructor\":{\"params\":{\"batcher_\":\"The USDC-to-DSU batcher contract address\",\"collateral_\":\"The perennial collateral contract address\",\"dsu_\":\"The DSU token contract address\",\"usdc_\":\"The USDC token contract address\"}},\"wrapAndDeposit(address,address,uint256)\":{\"params\":{\"account\":\"Account to deposit the collateral for\",\"amount\":\"18 decimals-normalized stablecoin (USDC, DSU) value of collateral to deposit\",\"product\":\"Product to credit the collateral to\"}}},\"stateVariables\":{\"batcher\":{\"details\":\"Contract that wraps USDC to DSU\"},\"collateral\":{\"details\":\"Contract managing state for collateral accounts in the protocol\"}},\"title\":\"Forwarder\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"constructor\":{\"notice\":\"Initializes the contract state\"},\"wrapAndDeposit(address,address,uint256)\":{\"notice\":\"Pulls `amount` of USDC from `msg.sender`'s balance, wraps it as DSU, and deposits it as collateral to `account`'s `product` account\"}},\"notice\":\"Facilitates collateral deposits to the protocol where the amount is supplied in USDC then wrapped as DSU before being deposited.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/forwarder/Forwarder.sol\":\"Forwarder\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@equilibria/emptyset-batcher/interfaces/IBatcher.sol\":{\"content\":\"//SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\n\\ninterface IBatcher {\\n event Wrap(address indexed to, UFixed18 amount);\\n event Unwrap(address indexed to, UFixed18 amount);\\n event Rebalance(UFixed18 newMinted, UFixed18 newRedeemed);\\n event Close(UFixed18 amount);\\n\\n error BatcherNotImplementedError();\\n error BatcherBalanceMismatchError(UFixed18 oldBalance, UFixed18 newBalance);\\n\\n function totalBalance() external view returns (UFixed18);\\n function wrap(UFixed18 amount, address to) external;\\n function unwrap(UFixed18 amount, address to) external;\\n function rebalance() external;\\n}\\n\",\"keccak256\":\"0x5d49c13991d92df22f77377b4ae98149bdfb588e04a084e00feec70569499c8b\",\"license\":\"Apache-2.0\"},\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\n\\ninterface IOracleProvider {\\n /// @dev A singular oracle version with its corresponding data\\n struct OracleVersion {\\n /// @dev The iterative version\\n uint256 version;\\n\\n /// @dev the timestamp of the oracle update\\n uint256 timestamp;\\n\\n /// @dev The oracle price of the corresponding version\\n Fixed18 price;\\n }\\n\\n function sync() external returns (OracleVersion memory);\\n function currentVersion() external view returns (OracleVersion memory);\\n function atVersion(uint256 oracleVersion) external view returns (OracleVersion memory);\\n}\\n\",\"keccak256\":\"0xde0f20d468ba8b91addfc356e13f2c74a4dc8abe68be323942217c723775d9c1\",\"license\":\"Apache-2.0\"},\"@equilibria/root/curve/CurveMath.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"../number/types/UFixed18.sol\\\";\\nimport \\\"../number/types/Fixed18.sol\\\";\\n\\n/**\\n * @title CurveMath\\n * @notice Library for managing math operations for utilization curves.\\n */\\nlibrary CurveMath {\\n error CurveMathOutOfBoundsError();\\n\\n /**\\n * @notice Computes a linear interpolation between two points\\n * @param startX First point's x-coordinate\\n * @param startY First point's y-coordinate\\n * @param endX Second point's x-coordinate\\n * @param endY Second point's y-coordinate\\n * @param targetX x-coordinate to interpolate\\n * @return y-coordinate for `targetX` along the line from (`startX`, `startY`) -> (`endX`, `endY`)\\n */\\n function linearInterpolation(\\n UFixed18 startX,\\n Fixed18 startY,\\n UFixed18 endX,\\n Fixed18 endY,\\n UFixed18 targetX\\n ) internal pure returns (Fixed18) {\\n if (targetX.lt(startX) || targetX.gt(endX)) revert CurveMathOutOfBoundsError();\\n\\n UFixed18 xRange = endX.sub(startX);\\n Fixed18 yRange = endY.sub(startY);\\n UFixed18 xRatio = targetX.sub(startX).div(xRange);\\n return yRange.mul(Fixed18Lib.from(xRatio)).add(startY);\\n }\\n}\\n\",\"keccak256\":\"0x60d159f9ddf0dbe81124ecad58bba734b4cf82877637ff8d9d7f3e92f2da4ded\",\"license\":\"Apache-2.0\"},\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"../CurveMath.sol\\\";\\nimport \\\"../../number/types/PackedUFixed18.sol\\\";\\nimport \\\"../../number/types/PackedFixed18.sol\\\";\\n\\n/// @dev JumpRateUtilizationCurve type\\nstruct JumpRateUtilizationCurve {\\n PackedFixed18 minRate;\\n PackedFixed18 maxRate;\\n PackedFixed18 targetRate;\\n PackedUFixed18 targetUtilization;\\n}\\nusing JumpRateUtilizationCurveLib for JumpRateUtilizationCurve global;\\ntype JumpRateUtilizationCurveStorage is bytes32;\\nusing JumpRateUtilizationCurveStorageLib for JumpRateUtilizationCurveStorage global;\\n\\n/**\\n * @title JumpRateUtilizationCurveLib\\n * @notice Library for the Jump Rate utilization curve type\\n */\\nlibrary JumpRateUtilizationCurveLib {\\n /**\\n * @notice Computes the corresponding rate for a utilization ratio\\n * @param utilization The utilization ratio\\n * @return The corresponding rate\\n */\\n function compute(JumpRateUtilizationCurve memory self, UFixed18 utilization) internal pure returns (Fixed18) {\\n UFixed18 targetUtilization = self.targetUtilization.unpack();\\n if (utilization.lt(targetUtilization)) {\\n return CurveMath.linearInterpolation(\\n UFixed18Lib.ZERO,\\n self.minRate.unpack(),\\n targetUtilization,\\n self.targetRate.unpack(),\\n utilization\\n );\\n }\\n if (utilization.lt(UFixed18Lib.ONE)) {\\n return CurveMath.linearInterpolation(\\n targetUtilization,\\n self.targetRate.unpack(),\\n UFixed18Lib.ONE,\\n self.maxRate.unpack(),\\n utilization\\n );\\n }\\n return self.maxRate.unpack();\\n }\\n}\\n\\nlibrary JumpRateUtilizationCurveStorageLib {\\n function read(JumpRateUtilizationCurveStorage self) internal view returns (JumpRateUtilizationCurve memory) {\\n return _storagePointer(self);\\n }\\n\\n function store(JumpRateUtilizationCurveStorage self, JumpRateUtilizationCurve memory value) internal {\\n JumpRateUtilizationCurve storage storagePointer = _storagePointer(self);\\n\\n storagePointer.minRate = value.minRate;\\n storagePointer.maxRate = value.maxRate;\\n storagePointer.targetRate = value.targetRate;\\n storagePointer.targetUtilization = value.targetUtilization;\\n }\\n\\n function _storagePointer(JumpRateUtilizationCurveStorage self)\\n private pure returns (JumpRateUtilizationCurve storage pointer) {\\n assembly { pointer.slot := self }\\n }\\n}\",\"keccak256\":\"0xae202813874bc306d51b3dab8194c86f6483bb20bf1f673ddaee16aa8de567ff\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/Fixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SignedMath.sol\\\";\\nimport \\\"./UFixed18.sol\\\";\\nimport \\\"./PackedFixed18.sol\\\";\\n\\n/// @dev Fixed18 type\\ntype Fixed18 is int256;\\nusing Fixed18Lib for Fixed18 global;\\ntype Fixed18Storage is bytes32;\\nusing Fixed18StorageLib for Fixed18Storage global;\\n\\n/**\\n * @title Fixed18Lib\\n * @notice Library for the signed fixed-decimal type.\\n */\\nlibrary Fixed18Lib {\\n error Fixed18OverflowError(uint256 value);\\n error Fixed18PackingOverflowError(int256 value);\\n error Fixed18PackingUnderflowError(int256 value);\\n\\n int256 private constant BASE = 1e18;\\n Fixed18 public constant ZERO = Fixed18.wrap(0);\\n Fixed18 public constant ONE = Fixed18.wrap(BASE);\\n Fixed18 public constant NEG_ONE = Fixed18.wrap(-1 * BASE);\\n Fixed18 public constant MAX = Fixed18.wrap(type(int256).max);\\n Fixed18 public constant MIN = Fixed18.wrap(type(int256).min);\\n\\n /**\\n * @notice Creates a signed fixed-decimal from an unsigned fixed-decimal\\n * @param a Unsigned fixed-decimal\\n * @return New signed fixed-decimal\\n */\\n function from(UFixed18 a) internal pure returns (Fixed18) {\\n uint256 value = UFixed18.unwrap(a);\\n if (value > uint256(type(int256).max)) revert Fixed18OverflowError(value);\\n return Fixed18.wrap(int256(value));\\n }\\n\\n /**\\n * @notice Creates a signed fixed-decimal from a sign and an unsigned fixed-decimal\\n * @param s Sign\\n * @param m Unsigned fixed-decimal magnitude\\n * @return New signed fixed-decimal\\n */\\n function from(int256 s, UFixed18 m) internal pure returns (Fixed18) {\\n if (s > 0) return from(m);\\n if (s < 0) return Fixed18.wrap(-1 * Fixed18.unwrap(from(m)));\\n return ZERO;\\n }\\n\\n /**\\n * @notice Creates a signed fixed-decimal from a signed integer\\n * @param a Signed number\\n * @return New signed fixed-decimal\\n */\\n function from(int256 a) internal pure returns (Fixed18) {\\n return Fixed18.wrap(a * BASE);\\n }\\n\\n /**\\n * @notice Creates a packed signed fixed-decimal from an signed fixed-decimal\\n * @param a signed fixed-decimal\\n * @return New packed signed fixed-decimal\\n */\\n function pack(Fixed18 a) internal pure returns (PackedFixed18) {\\n int256 value = Fixed18.unwrap(a);\\n if (value > type(int128).max) revert Fixed18PackingOverflowError(value);\\n if (value < type(int128).min) revert Fixed18PackingUnderflowError(value);\\n return PackedFixed18.wrap(int128(value));\\n }\\n\\n /**\\n * @notice Returns whether the signed fixed-decimal is equal to zero.\\n * @param a Signed fixed-decimal\\n * @return Whether the signed fixed-decimal is zero.\\n */\\n function isZero(Fixed18 a) internal pure returns (bool) {\\n return Fixed18.unwrap(a) == 0;\\n }\\n\\n /**\\n * @notice Adds two signed fixed-decimals `a` and `b` together\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Resulting summed signed fixed-decimal\\n */\\n function add(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) + Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Subtracts signed fixed-decimal `b` from `a`\\n * @param a Signed fixed-decimal to subtract from\\n * @param b Signed fixed-decimal to subtract\\n * @return Resulting subtracted signed fixed-decimal\\n */\\n function sub(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) - Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Multiplies two signed fixed-decimals `a` and `b` together\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Resulting multiplied signed fixed-decimal\\n */\\n function mul(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / BASE);\\n }\\n\\n /**\\n * @notice Divides signed fixed-decimal `a` by `b`\\n * @param a Signed fixed-decimal to divide\\n * @param b Signed fixed-decimal to divide by\\n * @return Resulting divided signed fixed-decimal\\n */\\n function div(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * BASE / Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0`, `MAX` for `n/0`, and `MIN` for `-n/0`.\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function unsafeDiv(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n if (isZero(b)) {\\n if (gt(a, ZERO)) return MAX;\\n if (lt(a, ZERO)) return MIN;\\n return ONE;\\n } else {\\n return div(a, b);\\n }\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First signed fixed-decimal\\n * @param b Signed number to multiply by\\n * @param c Signed number to divide by\\n * @return Resulting computation\\n */\\n function muldiv(Fixed18 a, int256 b, int256 c) internal pure returns (Fixed18) {\\n return muldiv(a, Fixed18.wrap(b), Fixed18.wrap(c));\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First signed fixed-decimal\\n * @param b Signed fixed-decimal to multiply by\\n * @param c Signed fixed-decimal to divide by\\n * @return Resulting computation\\n */\\n function muldiv(Fixed18 a, Fixed18 b, Fixed18 c) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / Fixed18.unwrap(c));\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is equal to `b`\\n */\\n function eq(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 1;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is greater than `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is greater than `b`\\n */\\n function gt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 2;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is less than `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is less than `b`\\n */\\n function lt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 0;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is greater than or equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is greater than or equal to `b`\\n */\\n function gte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return gt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is less than or equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is less than or equal to `b`\\n */\\n function lte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return lt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Compares the signed fixed-decimals `a` and `b`\\n * @dev Returns: 2 for greater than\\n * 1 for equal to\\n * 0 for less than\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Compare result of `a` and `b`\\n */\\n function compare(Fixed18 a, Fixed18 b) internal pure returns (uint256) {\\n (int256 au, int256 bu) = (Fixed18.unwrap(a), Fixed18.unwrap(b));\\n if (au > bu) return 2;\\n if (au < bu) return 0;\\n return 1;\\n }\\n\\n /**\\n * @notice Returns a signed fixed-decimal representing the ratio of `a` over `b`\\n * @param a First signed number\\n * @param b Second signed number\\n * @return Ratio of `a` over `b`\\n */\\n function ratio(int256 a, int256 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(a * BASE / b);\\n }\\n\\n /**\\n * @notice Returns the minimum of signed fixed-decimals `a` and `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Minimum of `a` and `b`\\n */\\n function min(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(SignedMath.min(Fixed18.unwrap(a), Fixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Returns the maximum of signed fixed-decimals `a` and `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Maximum of `a` and `b`\\n */\\n function max(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(SignedMath.max(Fixed18.unwrap(a), Fixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Converts the signed fixed-decimal into an integer, truncating any decimal portion\\n * @param a Signed fixed-decimal\\n * @return Truncated signed number\\n */\\n function truncate(Fixed18 a) internal pure returns (int256) {\\n return Fixed18.unwrap(a) / BASE;\\n }\\n\\n /**\\n * @notice Returns the sign of the signed fixed-decimal\\n * @dev Returns: -1 for negative\\n * 0 for zero\\n * 1 for positive\\n * @param a Signed fixed-decimal\\n * @return Sign of the signed fixed-decimal\\n */\\n function sign(Fixed18 a) internal pure returns (int256) {\\n if (Fixed18.unwrap(a) > 0) return 1;\\n if (Fixed18.unwrap(a) < 0) return -1;\\n return 0;\\n }\\n\\n /**\\n * @notice Returns the absolute value of the signed fixed-decimal\\n * @param a Signed fixed-decimal\\n * @return Absolute value of the signed fixed-decimal\\n */\\n function abs(Fixed18 a) internal pure returns (UFixed18) {\\n return UFixed18.wrap(SignedMath.abs(Fixed18.unwrap(a)));\\n }\\n}\\n\\nlibrary Fixed18StorageLib {\\n function read(Fixed18Storage self) internal view returns (Fixed18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(Fixed18Storage self, Fixed18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x613587461ef3437ef33229cdda7d34ea746278721baf06e20b2e43977f43174d\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/PackedFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"./Fixed18.sol\\\";\\n\\n/// @dev PackedFixed18 type\\ntype PackedFixed18 is int128;\\nusing PackedFixed18Lib for PackedFixed18 global;\\n\\n/**\\n * @title PackedFixed18Lib\\n * @dev A packed version of the Fixed18 which takes up half the storage space (two PackedFixed18 can be packed\\n * into a single slot). Only valid within the range -1.7014118e+20 <= x <= 1.7014118e+20.\\n * @notice Library for the packed signed fixed-decimal type.\\n */\\nlibrary PackedFixed18Lib {\\n PackedFixed18 public constant MAX = PackedFixed18.wrap(type(int128).max);\\n PackedFixed18 public constant MIN = PackedFixed18.wrap(type(int128).min);\\n\\n /**\\n * @notice Creates an unpacked signed fixed-decimal from a packed signed fixed-decimal\\n * @param self packed signed fixed-decimal\\n * @return New unpacked signed fixed-decimal\\n */\\n function unpack(PackedFixed18 self) internal pure returns (Fixed18) {\\n return Fixed18.wrap(int256(PackedFixed18.unwrap(self)));\\n }\\n}\\n\",\"keccak256\":\"0xb52960cc8e3132e45d342bbbb1c6a96219022cd8557997933bd8250170268b64\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/PackedUFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"./UFixed18.sol\\\";\\n\\n/// @dev PackedUFixed18 type\\ntype PackedUFixed18 is uint128;\\nusing PackedUFixed18Lib for PackedUFixed18 global;\\n\\n/**\\n * @title PackedUFixed18Lib\\n * @dev A packed version of the UFixed18 which takes up half the storage space (two PackedUFixed18 can be packed\\n * into a single slot). Only valid within the range 0 <= x <= 3.4028237e+20.\\n * @notice Library for the packed unsigned fixed-decimal type.\\n */\\nlibrary PackedUFixed18Lib {\\n PackedUFixed18 public constant MAX = PackedUFixed18.wrap(type(uint128).max);\\n\\n /**\\n * @notice Creates an unpacked unsigned fixed-decimal from a packed unsigned fixed-decimal\\n * @param self packed unsigned fixed-decimal\\n * @return New unpacked unsigned fixed-decimal\\n */\\n function unpack(PackedUFixed18 self) internal pure returns (UFixed18) {\\n return UFixed18.wrap(uint256(PackedUFixed18.unwrap(self)));\\n }\\n}\\n\",\"keccak256\":\"0xb5c5cd32d6530b2fe75228b6be32ebcb7762f6d7988b85a6b85a289ce8256d51\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/UFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"./Fixed18.sol\\\";\\nimport \\\"./PackedUFixed18.sol\\\";\\n\\n/// @dev UFixed18 type\\ntype UFixed18 is uint256;\\nusing UFixed18Lib for UFixed18 global;\\ntype UFixed18Storage is bytes32;\\nusing UFixed18StorageLib for UFixed18Storage global;\\n\\n/**\\n * @title UFixed18Lib\\n * @notice Library for the unsigned fixed-decimal type.\\n */\\nlibrary UFixed18Lib {\\n error UFixed18UnderflowError(int256 value);\\n error UFixed18PackingOverflowError(uint256 value);\\n\\n uint256 private constant BASE = 1e18;\\n UFixed18 public constant ZERO = UFixed18.wrap(0);\\n UFixed18 public constant ONE = UFixed18.wrap(BASE);\\n UFixed18 public constant MAX = UFixed18.wrap(type(uint256).max);\\n\\n /**\\n * @notice Creates a unsigned fixed-decimal from a signed fixed-decimal\\n * @param a Signed fixed-decimal\\n * @return New unsigned fixed-decimal\\n */\\n function from(Fixed18 a) internal pure returns (UFixed18) {\\n int256 value = Fixed18.unwrap(a);\\n if (value < 0) revert UFixed18UnderflowError(value);\\n return UFixed18.wrap(uint256(value));\\n }\\n\\n /**\\n * @notice Creates a unsigned fixed-decimal from a unsigned integer\\n * @param a Unsigned number\\n * @return New unsigned fixed-decimal\\n */\\n function from(uint256 a) internal pure returns (UFixed18) {\\n return UFixed18.wrap(a * BASE);\\n }\\n\\n /**\\n * @notice Creates a packed unsigned fixed-decimal from an unsigned fixed-decimal\\n * @param a unsigned fixed-decimal\\n * @return New packed unsigned fixed-decimal\\n */\\n function pack(UFixed18 a) internal pure returns (PackedUFixed18) {\\n uint256 value = UFixed18.unwrap(a);\\n if (value > type(uint128).max) revert UFixed18PackingOverflowError(value);\\n return PackedUFixed18.wrap(uint128(value));\\n }\\n\\n /**\\n * @notice Returns whether the unsigned fixed-decimal is equal to zero.\\n * @param a Unsigned fixed-decimal\\n * @return Whether the unsigned fixed-decimal is zero.\\n */\\n function isZero(UFixed18 a) internal pure returns (bool) {\\n return UFixed18.unwrap(a) == 0;\\n }\\n\\n /**\\n * @notice Adds two unsigned fixed-decimals `a` and `b` together\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Resulting summed unsigned fixed-decimal\\n */\\n function add(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) + UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Subtracts unsigned fixed-decimal `b` from `a`\\n * @param a Unsigned fixed-decimal to subtract from\\n * @param b Unsigned fixed-decimal to subtract\\n * @return Resulting subtracted unsigned fixed-decimal\\n */\\n function sub(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) - UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Multiplies two unsigned fixed-decimals `a` and `b` together\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Resulting multiplied unsigned fixed-decimal\\n */\\n function mul(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / BASE);\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function div(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * BASE / UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0` and `MAX` for `n/0`.\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function unsafeDiv(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n if (isZero(b)) {\\n return isZero(a) ? ONE : MAX;\\n } else {\\n return div(a, b);\\n }\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First unsigned fixed-decimal\\n * @param b Unsigned number to multiply by\\n * @param c Unsigned number to divide by\\n * @return Resulting computation\\n */\\n function muldiv(UFixed18 a, uint256 b, uint256 c) internal pure returns (UFixed18) {\\n return muldiv(a, UFixed18.wrap(b), UFixed18.wrap(c));\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First unsigned fixed-decimal\\n * @param b Unsigned fixed-decimal to multiply by\\n * @param c Unsigned fixed-decimal to divide by\\n * @return Resulting computation\\n */\\n function muldiv(UFixed18 a, UFixed18 b, UFixed18 c) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / UFixed18.unwrap(c));\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is equal to `b`\\n */\\n function eq(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 1;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is greater than `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is greater than `b`\\n */\\n function gt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 2;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is less than `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is less than `b`\\n */\\n function lt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 0;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is greater than or equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is greater than or equal to `b`\\n */\\n function gte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return gt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is less than or equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is less than or equal to `b`\\n */\\n function lte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return lt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Compares the unsigned fixed-decimals `a` and `b`\\n * @dev Returns: 2 for greater than\\n * 1 for equal to\\n * 0 for less than\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Compare result of `a` and `b`\\n */\\n function compare(UFixed18 a, UFixed18 b) internal pure returns (uint256) {\\n (uint256 au, uint256 bu) = (UFixed18.unwrap(a), UFixed18.unwrap(b));\\n if (au > bu) return 2;\\n if (au < bu) return 0;\\n return 1;\\n }\\n\\n /**\\n * @notice Returns a unsigned fixed-decimal representing the ratio of `a` over `b`\\n * @param a First unsigned number\\n * @param b Second unsigned number\\n * @return Ratio of `a` over `b`\\n */\\n function ratio(uint256 a, uint256 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(a * BASE / b);\\n }\\n\\n /**\\n * @notice Returns the minimum of unsigned fixed-decimals `a` and `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Minimum of `a` and `b`\\n */\\n function min(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(Math.min(UFixed18.unwrap(a), UFixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Returns the maximum of unsigned fixed-decimals `a` and `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Maximum of `a` and `b`\\n */\\n function max(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(Math.max(UFixed18.unwrap(a), UFixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Converts the unsigned fixed-decimal into an integer, truncating any decimal portion\\n * @param a Unsigned fixed-decimal\\n * @return Truncated unsigned number\\n */\\n function truncate(UFixed18 a) internal pure returns (uint256) {\\n return UFixed18.unwrap(a) / BASE;\\n }\\n}\\n\\nlibrary UFixed18StorageLib {\\n function read(UFixed18Storage self) internal view returns (UFixed18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(UFixed18Storage self, UFixed18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x8ebef1e6c717f565b9ed545a876b5692b4007e6485c99f39d363f7405e591792\",\"license\":\"Apache-2.0\"},\"@equilibria/root/token/types/Token18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"../../number/types/UFixed18.sol\\\";\\n\\n/// @dev Token18\\ntype Token18 is address;\\nusing Token18Lib for Token18 global;\\ntype Token18Storage is bytes32;\\nusing Token18StorageLib for Token18Storage global;\\n\\n/**\\n * @title Token18Lib\\n * @notice Library to manage 18-decimal ERC20s that is compliant with the fixed-decimal types.\\n * @dev Maintains significant gas savings over other Token implementations since no conversion take place\\n */\\nlibrary Token18Lib {\\n using SafeERC20 for IERC20;\\n\\n Token18 public constant ZERO = Token18.wrap(address(0));\\n\\n /**\\n * @notice Returns whether a token is the zero address\\n * @param self Token to check for\\n * @return Whether the token is the zero address\\n */\\n function isZero(Token18 self) internal pure returns (bool) {\\n return Token18.unwrap(self) == Token18.unwrap(ZERO);\\n }\\n\\n /**\\n * @notice Returns whether the two tokens are equal\\n * @param a First token to compare\\n * @param b Second token to compare\\n * @return Whether the two tokens are equal\\n */\\n function eq(Token18 a, Token18 b) internal pure returns (bool) {\\n return Token18.unwrap(a) == Token18.unwrap(b);\\n }\\n\\n /**\\n * @notice Approves `grantee` to spend infinite tokens from the caller\\n * @param self Token to transfer\\n * @param grantee Address to allow spending\\n */\\n function approve(Token18 self, address grantee) internal {\\n IERC20(Token18.unwrap(self)).safeApprove(grantee, type(uint256).max);\\n }\\n\\n /**\\n * @notice Approves `grantee` to spend `amount` tokens from the caller\\n * @dev There are important race conditions to be aware of when using this function\\n with values other than 0. This will revert if moving from non-zero to non-zero amounts\\n See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/a55b7d13722e7ce850b626da2313f3e66ca1d101/contracts/token/ERC20/IERC20.sol#L57\\n * @param self Token to transfer\\n * @param grantee Address to allow spending\\n * @param amount Amount of tokens to approve to spend\\n */\\n function approve(Token18 self, address grantee, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeApprove(grantee, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers all held tokens from the caller to the `recipient`\\n * @param self Token to transfer\\n * @param recipient Address to receive the tokens\\n */\\n function push(Token18 self, address recipient) internal {\\n push(self, recipient, balanceOf(self, address(this)));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the caller to the `recipient`\\n * @param self Token to transfer\\n * @param recipient Address to transfer tokens to\\n * @param amount Amount of tokens to transfer\\n */\\n function push(Token18 self, address recipient, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransfer(recipient, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the `benefactor` to the caller\\n * @dev Reverts if trying to pull Ether\\n * @param self Token to transfer\\n * @param benefactor Address to transfer tokens from\\n * @param amount Amount of tokens to transfer\\n */\\n function pull(Token18 self, address benefactor, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, address(this), UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the `benefactor` to `recipient`\\n * @dev Reverts if trying to pull Ether\\n * @param self Token to transfer\\n * @param benefactor Address to transfer tokens from\\n * @param recipient Address to transfer tokens to\\n * @param amount Amount of tokens to transfer\\n */\\n function pullTo(Token18 self, address benefactor, address recipient, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, recipient, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Returns the name of the token\\n * @param self Token to check for\\n * @return Token name\\n */\\n function name(Token18 self) internal view returns (string memory) {\\n return IERC20Metadata(Token18.unwrap(self)).name();\\n }\\n\\n /**\\n * @notice Returns the symbol of the token\\n * @param self Token to check for\\n * @return Token symbol\\n */\\n function symbol(Token18 self) internal view returns (string memory) {\\n return IERC20Metadata(Token18.unwrap(self)).symbol();\\n }\\n\\n /**\\n * @notice Returns the `self` token balance of the caller\\n * @param self Token to check for\\n * @return Token balance of the caller\\n */\\n function balanceOf(Token18 self) internal view returns (UFixed18) {\\n return balanceOf(self, address(this));\\n }\\n\\n /**\\n * @notice Returns the `self` token balance of `account`\\n * @param self Token to check for\\n * @param account Account to check\\n * @return Token balance of the account\\n */\\n function balanceOf(Token18 self, address account) internal view returns (UFixed18) {\\n return UFixed18.wrap(IERC20(Token18.unwrap(self)).balanceOf(account));\\n }\\n}\\n\\nlibrary Token18StorageLib {\\n function read(Token18Storage self) internal view returns (Token18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(Token18Storage self, Token18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x6b12afaece814f0ab186200a4729e93eb685a21d3e9b5a3372ff283a7ad5dc23\",\"license\":\"Apache-2.0\"},\"@equilibria/root/token/types/Token6.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"../../number/types/UFixed18.sol\\\";\\n\\n/// @dev Token6\\ntype Token6 is address;\\nusing Token6Lib for Token6 global;\\ntype Token6Storage is bytes32;\\nusing Token6StorageLib for Token6Storage global;\\n\\n/**\\n * @title Token6Lib\\n * @notice Library to manage 6-decimal ERC20s that is compliant with the fixed-decimal types.\\n * @dev Automatically converts from Base-6 token amounts to Base-18 UFixed18 amounts, with optional rounding\\n */\\nlibrary Token6Lib {\\n using SafeERC20 for IERC20;\\n\\n Token6 public constant ZERO = Token6.wrap(address(0));\\n\\n uint256 private constant OFFSET = 1e12;\\n\\n /**\\n * @notice Returns whether a token is the zero address\\n * @param self Token to check for\\n * @return Whether the token is the zero address\\n */\\n function isZero(Token6 self) internal pure returns (bool) {\\n return Token6.unwrap(self) == Token6.unwrap(ZERO);\\n }\\n\\n /**\\n * @notice Returns whether the two tokens are equal\\n * @param a First token to compare\\n * @param b Second token to compare\\n * @return Whether the two tokens are equal\\n */\\n function eq(Token6 a, Token6 b) internal pure returns (bool) {\\n return Token6.unwrap(a) == Token6.unwrap(b);\\n }\\n\\n /**\\n * @notice Approves `grantee` to spend infinite tokens from the caller\\n * @param self Token to transfer\\n * @param grantee Address to allow spending\\n */\\n function approve(Token6 self, address grantee) internal {\\n IERC20(Token6.unwrap(self)).safeApprove(grantee, type(uint256).max);\\n }\\n\\n /**\\n * @notice Approves `grantee` to spend `amount` tokens from the caller\\n * @dev There are important race conditions to be aware of when using this function\\n with values other than 0. This will revert if moving from non-zero to non-zero amounts\\n See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/a55b7d13722e7ce850b626da2313f3e66ca1d101/contracts/token/ERC20/IERC20.sol#L57\\n * @param self Token to transfer\\n * @param grantee Address to allow spending\\n * @param amount Amount of tokens to approve to spend\\n */\\n function approve(Token6 self, address grantee, UFixed18 amount) internal {\\n IERC20(Token6.unwrap(self)).safeApprove(grantee, toTokenAmount(amount, false));\\n }\\n\\n /**\\n * @notice Approves `grantee` to spend `amount` tokens from the caller\\n * @dev There are important race conditions to be aware of when using this function\\n with values other than 0. This will revert if moving from non-zero to non-zero amounts\\n See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/a55b7d13722e7ce850b626da2313f3e66ca1d101/contracts/token/ERC20/IERC20.sol#L57\\n * @param self Token to transfer\\n * @param grantee Address to allow spending\\n * @param amount Amount of tokens to approve to spend\\n * @param roundUp Whether to round decimal token amount up to the next unit\\n */\\n function approve(Token6 self, address grantee, UFixed18 amount, bool roundUp) internal {\\n IERC20(Token6.unwrap(self)).safeApprove(grantee, toTokenAmount(amount, roundUp));\\n }\\n\\n /**\\n * @notice Transfers all held tokens from the caller to the `recipient`\\n * @param self Token to transfer\\n * @param recipient Address to receive the tokens\\n */\\n function push(Token6 self, address recipient) internal {\\n push(self, recipient, balanceOf(self, address(this)));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the caller to the `recipient`\\n * @param self Token to transfer\\n * @param recipient Address to transfer tokens to\\n * @param amount Amount of tokens to transfer\\n */\\n function push(Token6 self, address recipient, UFixed18 amount) internal {\\n IERC20(Token6.unwrap(self)).safeTransfer(recipient, toTokenAmount(amount, false));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the caller to the `recipient`\\n * @param self Token to transfer\\n * @param recipient Address to transfer tokens to\\n * @param amount Amount of tokens to transfer\\n * @param roundUp Whether to round decimal token amount up to the next unit\\n */\\n function push(Token6 self, address recipient, UFixed18 amount, bool roundUp) internal {\\n IERC20(Token6.unwrap(self)).safeTransfer(recipient, toTokenAmount(amount, roundUp));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the `benefactor` to the caller\\n * @dev Reverts if trying to pull Ether\\n * @param self Token to transfer\\n * @param benefactor Address to transfer tokens from\\n * @param amount Amount of tokens to transfer\\n */\\n function pull(Token6 self, address benefactor, UFixed18 amount) internal {\\n IERC20(Token6.unwrap(self)).safeTransferFrom(benefactor, address(this), toTokenAmount(amount, false));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the `benefactor` to the caller\\n * @dev Reverts if trying to pull Ether\\n * @param self Token to transfer\\n * @param benefactor Address to transfer tokens from\\n * @param amount Amount of tokens to transfer\\n * @param roundUp Whether to round decimal token amount up to the next unit\\n */\\n function pull(Token6 self, address benefactor, UFixed18 amount, bool roundUp) internal {\\n IERC20(Token6.unwrap(self)).safeTransferFrom(benefactor, address(this), toTokenAmount(amount, roundUp));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the `benefactor` to `recipient`\\n * @dev Reverts if trying to pull Ether\\n * @param self Token to transfer\\n * @param benefactor Address to transfer tokens from\\n * @param recipient Address to transfer tokens to\\n * @param amount Amount of tokens to transfer\\n */\\n function pullTo(Token6 self, address benefactor, address recipient, UFixed18 amount) internal {\\n IERC20(Token6.unwrap(self)).safeTransferFrom(benefactor, recipient, toTokenAmount(amount, false));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the `benefactor` to `recipient`\\n * @dev Reverts if trying to pull Ether\\n * @param self Token to transfer\\n * @param benefactor Address to transfer tokens from\\n * @param recipient Address to transfer tokens to\\n * @param amount Amount of tokens to transfer\\n * @param roundUp Whether to round decimal token amount up to the next unit\\n */\\n function pullTo(Token6 self, address benefactor, address recipient, UFixed18 amount, bool roundUp) internal {\\n IERC20(Token6.unwrap(self)).safeTransferFrom(benefactor, recipient, toTokenAmount(amount, roundUp));\\n }\\n\\n /**\\n * @notice Returns the name of the token\\n * @param self Token to check for\\n * @return Token name\\n */\\n function name(Token6 self) internal view returns (string memory) {\\n return IERC20Metadata(Token6.unwrap(self)).name();\\n }\\n\\n /**\\n * @notice Returns the symbol of the token\\n * @param self Token to check for\\n * @return Token symbol\\n */\\n function symbol(Token6 self) internal view returns (string memory) {\\n return IERC20Metadata(Token6.unwrap(self)).symbol();\\n }\\n\\n /**\\n * @notice Returns the `self` token balance of the caller\\n * @param self Token to check for\\n * @return Token balance of the caller\\n */\\n function balanceOf(Token6 self) internal view returns (UFixed18) {\\n return balanceOf(self, address(this));\\n }\\n\\n /**\\n * @notice Returns the `self` token balance of `account`\\n * @param self Token to check for\\n * @param account Account to check\\n * @return Token balance of the account\\n */\\n function balanceOf(Token6 self, address account) internal view returns (UFixed18) {\\n return fromTokenAmount(IERC20(Token6.unwrap(self)).balanceOf(account));\\n }\\n\\n /**\\n * @notice Converts the unsigned fixed-decimal amount into the token amount according to\\n * it's defined decimals\\n * @dev Provides the ability to \\\"round up\\\" the token amount which is useful in situations where\\n * are swapping one token for another and don't want to give away \\\"free\\\" units due to rounding\\n * errors in the favor of the user.\\n * @param amount Amount to convert\\n * @param roundUp Whether to round decimal token amount up to the next unit\\n * @return Normalized token amount\\n */\\n function toTokenAmount(UFixed18 amount, bool roundUp) private pure returns (uint256) {\\n return roundUp ? Math.ceilDiv(UFixed18.unwrap(amount), OFFSET) : UFixed18.unwrap(amount) / OFFSET;\\n }\\n\\n /**\\n * @notice Converts the token amount into the unsigned fixed-decimal amount according to\\n * it's defined decimals\\n * @param amount Token amount to convert\\n * @return Normalized unsigned fixed-decimal amount\\n */\\n function fromTokenAmount(uint256 amount) private pure returns (UFixed18) {\\n return UFixed18.wrap(amount * OFFSET);\\n }\\n}\\n\\nlibrary Token6StorageLib {\\n function read(Token6Storage self) internal view returns (Token6 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(Token6Storage self, Token6 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x5ec7bee45a0e13f91ab2399472cf11136496073ad470cd70244855e12a7b6e65\",\"license\":\"Apache-2.0\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\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 amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` 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(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\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\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 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 using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\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 function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc3d946432c0ddbb1f846a0d3985be71299df331b91d06732152117f62f0be2b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // 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\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return 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 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 up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a / b + (a % b == 0 ? 0 : 1);\\n }\\n}\\n\",\"keccak256\":\"0xc995bddbca1ae19788db9f8b61e63385edd3fddf89693b612d5abd1a275974d2\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SignedMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/SignedMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard signed math utilities missing in the Solidity language.\\n */\\nlibrary SignedMath {\\n /**\\n * @dev Returns the largest of two signed numbers.\\n */\\n function max(int256 a, int256 b) internal pure returns (int256) {\\n return 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 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 // must be unchecked in order to support `n = type(int256).min`\\n return uint256(n >= 0 ? n : -n);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb3ebde1c8d27576db912d87c3560dab14adfb9cd001be95890ec4ba035e652e7\",\"license\":\"MIT\"},\"contracts/forwarder/Forwarder.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"../interfaces/IForwarder.sol\\\";\\n\\n/**\\n * @title Forwarder\\n * @notice Facilitates collateral deposits to the protocol where the amount is supplied\\n * in USDC then wrapped as DSU before being deposited.\\n */\\ncontract Forwarder is IForwarder {\\n // @dev USDC stablecoin\\n Token6 public immutable USDC; // solhint-disable-line var-name-mixedcase\\n\\n // @dev DSU stablecoin\\n Token18 public immutable DSU; // solhint-disable-line var-name-mixedcase\\n\\n /// @dev Contract that wraps USDC to DSU\\n IBatcher public immutable batcher;\\n\\n /// @dev Contract managing state for collateral accounts in the protocol\\n ICollateral public immutable collateral;\\n\\n /**\\n * @notice Initializes the contract state\\n * @param usdc_ The USDC token contract address\\n * @param dsu_ The DSU token contract address\\n * @param batcher_ The USDC-to-DSU batcher contract address\\n * @param collateral_ The perennial collateral contract address\\n */\\n constructor(\\n Token6 usdc_,\\n Token18 dsu_,\\n IBatcher batcher_,\\n ICollateral collateral_\\n ) {\\n if (!Address.isContract(Token6.unwrap(usdc_))) revert ForwarderNotContractAddressError();\\n if (!Address.isContract(Token18.unwrap(dsu_))) revert ForwarderNotContractAddressError();\\n if (!Address.isContract(address(batcher_))) revert ForwarderNotContractAddressError();\\n if (!Address.isContract(address(collateral_))) revert ForwarderNotContractAddressError();\\n\\n USDC = usdc_;\\n DSU = dsu_;\\n batcher = batcher_;\\n collateral = collateral_;\\n\\n USDC.approve(address(batcher));\\n DSU.approve(address(collateral));\\n }\\n\\n /**\\n * @notice Pulls `amount` of USDC from `msg.sender`'s balance, wraps it as DSU,\\n and deposits it as collateral to `account`'s `product` account\\n * @param account Account to deposit the collateral for\\n * @param product Product to credit the collateral to\\n * @param amount 18 decimals-normalized stablecoin (USDC, DSU) value of collateral to deposit\\n */\\n function wrapAndDeposit(\\n address account,\\n IProduct product,\\n UFixed18 amount\\n ) external {\\n USDC.pull(msg.sender, amount, true);\\n batcher.wrap(amount, address(this));\\n collateral.depositTo(account, product, amount);\\n emit WrapAndDeposit(account, product, amount);\\n }\\n}\\n\",\"keccak256\":\"0x69355a55b01b5d1c259f0106600873a5c93f34774292c160f86a547bce86b881\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/ICollateral.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"./IController.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\n\\ninterface ICollateral {\\n event Deposit(address indexed user, IProduct indexed product, UFixed18 amount);\\n event Withdrawal(address indexed user, IProduct indexed product, UFixed18 amount);\\n event AccountSettle(IProduct indexed product, address indexed account, Fixed18 amount, UFixed18 newShortfall);\\n event ProductSettle(IProduct indexed product, UFixed18 protocolFee, UFixed18 productFee);\\n event Liquidation(address indexed user, IProduct indexed product, address liquidator, UFixed18 fee);\\n event ShortfallResolution(IProduct indexed product, UFixed18 amount);\\n event FeeClaim(address indexed account, UFixed18 amount);\\n\\n error CollateralCantLiquidate(UFixed18 totalMaintenance, UFixed18 totalCollateral);\\n error CollateralInsufficientCollateralError();\\n error CollateralUnderLimitError();\\n error CollateralZeroAddressError();\\n\\n function token() external view returns (Token18);\\n function fees(address account) external view returns (UFixed18);\\n function initialize(IController controller_) external;\\n function depositTo(address account, IProduct product, UFixed18 amount) external;\\n function withdrawTo(address account, IProduct product, UFixed18 amount) external;\\n function liquidate(address account, IProduct product) external;\\n function settleAccount(address account, Fixed18 amount) external;\\n function settleProduct(UFixed18 amount) external;\\n function collateral(address account, IProduct product) external view returns (UFixed18);\\n function collateral(IProduct product) external view returns (UFixed18);\\n function shortfall(IProduct product) external view returns (UFixed18);\\n function liquidatable(address account, IProduct product) external view returns (bool);\\n function liquidatableNext(address account, IProduct product) external view returns (bool);\\n function resolveShortfall(IProduct product, UFixed18 amount) external;\\n function claimFee() external;\\n}\\n\",\"keccak256\":\"0xa5e7fdda92702f748e6eb8701e522450035a98a05e5fc1cf66d51c52e397d914\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IContractPayoffProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\n\\ninterface IContractPayoffProvider {\\n function payoff(Fixed18 price) external view returns (Fixed18 payoff);\\n}\\n\",\"keccak256\":\"0xd73df106d032e976fd959ee6713240e36f54277ce5f215eaec8d5a2c6720a86b\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IController.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\\\";\\nimport \\\"./ICollateral.sol\\\";\\nimport \\\"./IIncentivizer.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\n\\ninterface IController {\\n /// @dev Coordinator of a one or many products\\n struct Coordinator {\\n /// @dev Pending owner of the product, can accept ownership\\n address pendingOwner;\\n\\n /// @dev Owner of the product, allowed to update select parameters\\n address owner;\\n\\n /// @dev Treasury of the product, collects fees\\n address treasury;\\n }\\n\\n event CollateralUpdated(ICollateral newCollateral);\\n event IncentivizerUpdated(IIncentivizer newIncentivizer);\\n event ProductBeaconUpdated(IBeacon newProductBeacon);\\n event ProtocolFeeUpdated(UFixed18 newProtocolFee);\\n event MinFundingFeeUpdated(UFixed18 newMinFundingFee);\\n event LiquidationFeeUpdated(UFixed18 newLiquidationFee);\\n event IncentivizationFeeUpdated(UFixed18 newIncentivizationFee);\\n event MinCollateralUpdated(UFixed18 newMinCollateral);\\n event ProgramsPerProductUpdated(uint256 newProgramsPerProduct);\\n event PauserUpdated(address newPauser);\\n event PausedUpdated(bool newPaused);\\n event CoordinatorPendingOwnerUpdated(uint256 indexed coordinatorId, address newPendingOwner);\\n event CoordinatorOwnerUpdated(uint256 indexed coordinatorId, address newOwner);\\n event CoordinatorTreasuryUpdated(uint256 indexed coordinatorId, address newTreasury);\\n event CoordinatorCreated(uint256 indexed coordinatorId, address owner);\\n event ProductCreated(IProduct indexed product, IProduct.ProductInfo productInfo);\\n\\n error ControllerNoZeroCoordinatorError();\\n error ControllerNotPauserError();\\n error ControllerNotOwnerError(uint256 controllerId);\\n error ControllerNotPendingOwnerError(uint256 controllerId);\\n error ControllerInvalidProtocolFeeError();\\n error ControllerInvalidMinFundingFeeError();\\n error ControllerInvalidLiquidationFeeError();\\n error ControllerInvalidIncentivizationFeeError();\\n error ControllerNotContractAddressError();\\n\\n function collateral() external view returns (ICollateral);\\n function incentivizer() external view returns (IIncentivizer);\\n function productBeacon() external view returns (IBeacon);\\n function coordinators(uint256 collateralId) external view returns (Coordinator memory);\\n function coordinatorFor(IProduct product) external view returns (uint256);\\n function protocolFee() external view returns (UFixed18);\\n function minFundingFee() external view returns (UFixed18);\\n function liquidationFee() external view returns (UFixed18);\\n function incentivizationFee() external view returns (UFixed18);\\n function minCollateral() external view returns (UFixed18);\\n function programsPerProduct() external view returns (uint256);\\n function pauser() external view returns (address);\\n function paused() external view returns (bool);\\n function initialize(ICollateral collateral_, IIncentivizer incentivizer_, IBeacon productBeacon_) external;\\n function createCoordinator() external returns (uint256);\\n function updateCoordinatorPendingOwner(uint256 coordinatorId, address newPendingOwner) external;\\n function acceptCoordinatorOwner(uint256 coordinatorId) external;\\n function updateCoordinatorTreasury(uint256 coordinatorId, address newTreasury) external;\\n function createProduct(uint256 coordinatorId, IProduct.ProductInfo calldata productInfo) external returns (IProduct);\\n function updateCollateral(ICollateral newCollateral) external;\\n function updateIncentivizer(IIncentivizer newIncentivizer) external;\\n function updateProductBeacon(IBeacon newProductBeacon) external;\\n function updateProtocolFee(UFixed18 newProtocolFee) external;\\n function updateMinFundingFee(UFixed18 newMinFundingFee) external;\\n function updateLiquidationFee(UFixed18 newLiquidationFee) external;\\n function updateIncentivizationFee(UFixed18 newIncentivizationFee) external;\\n function updateMinCollateral(UFixed18 newMinCollateral) external;\\n function updateProgramsPerProduct(uint256 newProductsPerProduct) external;\\n function updatePauser(address newPauser) external;\\n function updatePaused(bool newPaused) external;\\n function isProduct(IProduct product) external view returns (bool);\\n function owner() external view returns (address);\\n function owner(uint256 coordinatorId) external view returns (address);\\n function owner(IProduct product) external view returns (address);\\n function treasury() external view returns (address);\\n function treasury(uint256 coordinatorId) external view returns (address);\\n function treasury(IProduct product) external view returns (address);\\n}\\n\",\"keccak256\":\"0xaabd3740f2265499eea7aad9bd94f9892f53241e5dccce9a50c0e43ed2a6a7cc\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IForwarder.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"@equilibria/root/token/types/Token6.sol\\\";\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/emptyset-batcher/interfaces/IBatcher.sol\\\";\\nimport \\\"./ICollateral.sol\\\";\\n\\ninterface IForwarder {\\n error ForwarderNotContractAddressError();\\n\\n event WrapAndDeposit(address indexed account, IProduct indexed product, UFixed18 amount);\\n\\n function USDC() external view returns (Token6); // solhint-disable-line func-name-mixedcase\\n function DSU() external view returns (Token18); // solhint-disable-line func-name-mixedcase\\n function batcher() external view returns (IBatcher);\\n function collateral() external view returns (ICollateral);\\n function wrapAndDeposit(address account, IProduct product, UFixed18 amount) external;\\n}\\n\",\"keccak256\":\"0x800026180c5f82bba4ecd57d91dc2eb364326de8ca5ed0e56308620d58b6bc61\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IIncentivizer.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./types/ProgramInfo.sol\\\";\\nimport \\\"./IController.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\n\\ninterface IIncentivizer {\\n event ProgramCreated(IProduct indexed product, uint256 indexed programId, ProgramInfo programInfo, UFixed18 programFeeAmount);\\n event ProgramStarted(IProduct indexed product, uint256 indexed programId, uint256 version);\\n event ProgramComplete(IProduct indexed product, uint256 indexed programId, uint256 version);\\n event Claim(IProduct indexed product, address indexed account, uint256 indexed programId, UFixed18 amount);\\n event FeeClaim(Token18 indexed token, UFixed18 amount);\\n\\n error IncentivizerNotAllowedError(IProduct product);\\n error IncentivizerTooManyProgramsError();\\n error IncentivizerNotProgramOwnerError(IProduct product, uint256 programId);\\n error IncentivizerInvalidProgramError(IProduct product, uint256 programId);\\n error IncentivizerBatchClaimArgumentMismatchError();\\n\\n function programInfos(IProduct product, uint256 programId) external view returns (ProgramInfo memory);\\n function fees(Token18 token) external view returns (UFixed18);\\n function initialize(IController controller_) external;\\n function create(IProduct product, ProgramInfo calldata info) external returns (uint256);\\n function complete(IProduct product, uint256 programId) external;\\n function sync(IOracleProvider.OracleVersion memory currentOracleVersion) external;\\n function syncAccount(address account, IOracleProvider.OracleVersion memory currentOracleVersion) external;\\n function claim(IProduct product, uint256[] calldata programIds) external;\\n function claim(IProduct[] calldata products, uint256[][] calldata programIds) external;\\n function claimFee(Token18[] calldata tokens) external;\\n function active(IProduct product) external view returns (uint256);\\n function count(IProduct product) external view returns (uint256);\\n function unclaimed(IProduct product, address account, uint256 programId) external view returns (UFixed18);\\n function available(IProduct product, uint256 programId) external view returns (UFixed18);\\n function versionStarted(IProduct product, uint256 programId) external view returns (uint256);\\n function versionComplete(IProduct product, uint256 programId) external view returns (uint256);\\n function owner(IProduct product, uint256 programId) external view returns (address);\\n function treasury(IProduct product, uint256 programId) external view returns (address);\\n}\\n\",\"keccak256\":\"0x2f95de90dbb3ad35dbfef304f765a622bffff9229868d2898eca8d49c78e8c2c\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IParamProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\\\";\\n\\ninterface IParamProvider {\\n event MaintenanceUpdated(UFixed18 newMaintenance);\\n event FundingFeeUpdated(UFixed18 newFundingFee);\\n event MakerFeeUpdated(UFixed18 newMakerFee);\\n event TakerFeeUpdated(UFixed18 newTakerFee);\\n event MakerLimitUpdated(UFixed18 newMakerLimit);\\n event JumpRateUtilizationCurveUpdated(\\n Fixed18 minRate,\\n Fixed18 maxRate,\\n Fixed18 targetRate,\\n UFixed18 targetUtilization\\n );\\n\\n error ParamProviderInvalidMakerFee();\\n error ParamProviderInvalidTakerFee();\\n error ParamProviderInvalidFundingFee();\\n \\n function maintenance() external view returns (UFixed18);\\n function updateMaintenance(UFixed18 newMaintenance) external;\\n function fundingFee() external view returns (UFixed18);\\n function updateFundingFee(UFixed18 newFundingFee) external;\\n function makerFee() external view returns (UFixed18);\\n function updateMakerFee(UFixed18 newMakerFee) external;\\n function takerFee() external view returns (UFixed18);\\n function updateTakerFee(UFixed18 newTakerFee) external;\\n function makerLimit() external view returns (UFixed18);\\n function updateMakerLimit(UFixed18 newMakerLimit) external;\\n function utilizationCurve() external view returns (JumpRateUtilizationCurve memory);\\n function updateUtilizationCurve(JumpRateUtilizationCurve memory newUtilizationCurve) external;\\n}\\n\",\"keccak256\":\"0x2e2d40d0cf55f167118867e41f740b9b40614d05da50fc9bc33a8cede3eaf03e\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IPayoffProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\n\\ninterface IPayoffProvider {\\n error PayoffProviderInvalidOracle();\\n error PayoffProviderInvalidPayoffDefinitionError();\\n\\n function oracle() external view returns (IOracleProvider);\\n function payoffDefinition() external view returns (PayoffDefinition memory);\\n function currentVersion() external view returns (IOracleProvider.OracleVersion memory);\\n function atVersion(uint256 oracleVersion) external view returns (IOracleProvider.OracleVersion memory);\\n}\\n\",\"keccak256\":\"0xb83d80d624aa9431763f80ecb4bf0214803e25334a7419d954f929e5d0ee7467\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IProduct.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\\\";\\nimport \\\"./IPayoffProvider.sol\\\";\\nimport \\\"./IParamProvider.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\nimport \\\"./types/Position.sol\\\";\\nimport \\\"./types/PrePosition.sol\\\";\\nimport \\\"./types/Accumulator.sol\\\";\\n\\ninterface IProduct is IPayoffProvider, IParamProvider {\\n /// @dev Product Creation parameters\\n struct ProductInfo {\\n /// @dev name of the product\\n string name;\\n\\n /// @dev symbol of the product\\n string symbol;\\n\\n /// @dev product payoff definition\\n PayoffDefinition payoffDefinition;\\n\\n /// @dev oracle address\\n IOracleProvider oracle;\\n\\n /// @dev product maintenance ratio\\n UFixed18 maintenance;\\n\\n /// @dev product funding fee\\n UFixed18 fundingFee;\\n\\n /// @dev product maker fee\\n UFixed18 makerFee;\\n\\n /// @dev product taker fee\\n UFixed18 takerFee;\\n\\n /// @dev product maker limit\\n UFixed18 makerLimit;\\n\\n /// @dev utulization curve definition\\n JumpRateUtilizationCurve utilizationCurve;\\n }\\n\\n event Settle(uint256 preVersion, uint256 toVersion);\\n event AccountSettle(address indexed account, uint256 preVersion, uint256 toVersion);\\n event MakeOpened(address indexed account, uint256 version, UFixed18 amount);\\n event TakeOpened(address indexed account, uint256 version, UFixed18 amount);\\n event MakeClosed(address indexed account, uint256 version, UFixed18 amount);\\n event TakeClosed(address indexed account, uint256 version, UFixed18 amount);\\n event ClosedUpdated(bool indexed newClosed, uint256 version);\\n\\n error ProductInsufficientLiquidityError(UFixed18 socializationFactor);\\n error ProductDoubleSidedError();\\n error ProductOverClosedError();\\n error ProductInsufficientCollateralError();\\n error ProductInLiquidationError();\\n error ProductMakerOverLimitError();\\n error ProductOracleBootstrappingError();\\n error ProductNotOwnerError();\\n error ProductInvalidOracle();\\n error ProductClosedError();\\n\\n function name() external view returns (string memory);\\n function symbol() external view returns (string memory);\\n function initialize(ProductInfo calldata productInfo_) external;\\n function settle() external;\\n function settleAccount(address account) external;\\n function openTake(UFixed18 amount) external;\\n function closeTake(UFixed18 amount) external;\\n function openMake(UFixed18 amount) external;\\n function closeMake(UFixed18 amount) external;\\n function closeAll(address account) external;\\n function maintenance(address account) external view returns (UFixed18);\\n function maintenanceNext(address account) external view returns (UFixed18);\\n function isClosed(address account) external view returns (bool);\\n function isLiquidating(address account) external view returns (bool);\\n function position(address account) external view returns (Position memory);\\n function pre(address account) external view returns (PrePosition memory);\\n function latestVersion() external view returns (uint256);\\n function positionAtVersion(uint256 oracleVersion) external view returns (Position memory);\\n function pre() external view returns (PrePosition memory);\\n function valueAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\\n function shareAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\\n function latestVersion(address account) external view returns (uint256);\\n function rate(Position memory position) external view returns (Fixed18);\\n function closed() external view returns (bool);\\n function updateClosed(bool newClosed) external;\\n}\\n\",\"keccak256\":\"0xe1e80b818eadf4cdb070362e40c7cf3863b50c4f944816af27848e319f587241\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/Accumulator.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"./PackedAccumulator.sol\\\";\\n\\n/// @dev Accumulator type\\nstruct Accumulator {\\n /// @dev maker accumulator per share\\n Fixed18 maker;\\n /// @dev taker accumulator per share\\n Fixed18 taker;\\n}\\nusing AccumulatorLib for Accumulator global;\\n\\n/**\\n * @title AccountAccumulatorLib\\n * @notice Library that surfaces math operations for the Accumulator type.\\n * @dev Accumulators track the cumulative change in position value over time for the maker and taker positions\\n * respectively. Account-level accumulators can then use two of these values `a` and `a'` to compute the\\n * change in position value since last sync. This change in value is then used to compute P&L and fees.\\n */\\nlibrary AccumulatorLib {\\n /**\\n * @notice Creates a packed accumulator from an accumulator\\n * @param self an accumulator\\n * @return New packed accumulator\\n */\\n function pack(Accumulator memory self) internal pure returns (PackedAccumulator memory) {\\n return PackedAccumulator({maker: self.maker.pack(), taker: self.taker.pack()});\\n }\\n\\n /**\\n * @notice Adds two accumulators together\\n * @param a The first accumulator to sum\\n * @param b The second accumulator to sum\\n * @return The resulting summed accumulator\\n */\\n function add(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\\n }\\n\\n /**\\n * @notice Subtracts accumulator `b` from `a`\\n * @param a The accumulator to subtract from\\n * @param b The accumulator to subtract\\n * @return The resulting subtracted accumulator\\n */\\n function sub(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\\n }\\n\\n /**\\n * @notice Multiplies two accumulators together\\n * @param a The first accumulator to multiply\\n * @param b The second accumulator to multiply\\n * @return The resulting multiplied accumulator\\n */\\n function mul(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.mul(b.maker), taker: a.taker.mul(b.taker)});\\n }\\n\\n /**\\n * @notice Sums the maker and taker together from a single accumulator\\n * @param self The struct to operate on\\n * @return The sum of its maker and taker\\n */\\n function sum(Accumulator memory self) internal pure returns (Fixed18) {\\n return self.maker.add(self.taker);\\n }\\n}\\n\",\"keccak256\":\"0x7ccd0a72aa593cefb9f4337cf312799f357b82fcb3f0379de0dc503d1cb7e387\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PackedAccumulator.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/PackedFixed18.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\n\\n/// @dev PackedAccumulator type\\nstruct PackedAccumulator {\\n /// @dev maker accumulator per share\\n PackedFixed18 maker;\\n /// @dev taker accumulator per share\\n PackedFixed18 taker;\\n}\\nusing PackedAccumulatorLib for PackedAccumulator global;\\n\\n/**\\n * @title PackedAccumulatorLib\\n * @dev A packed version of the Accumulator which takes up a single storage slot using `PackedFixed18` values.\\n * @notice Library for the packed Accumulator type.\\n */\\nlibrary PackedAccumulatorLib {\\n /**\\n * @notice Creates an accumulator from a packed accumulator\\n * @param self packed accumulator\\n * @return New accumulator\\n */\\n function unpack(PackedAccumulator memory self) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: self.maker.unpack(), taker: self.taker.unpack()});\\n }\\n}\\n\",\"keccak256\":\"0xd83f2822d4f6c818087a232b54007730992c34ff77377fc307a282f886e7cf65\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PackedPosition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/PackedUFixed18.sol\\\";\\nimport \\\"./Position.sol\\\";\\n\\n/// @dev PackedPosition type\\nstruct PackedPosition {\\n /// @dev Quantity of the maker position\\n PackedUFixed18 maker;\\n /// @dev Quantity of the taker position\\n PackedUFixed18 taker;\\n}\\nusing PackedPositionLib for PackedPosition global;\\n\\n/**\\n * @title PackedPositionLib\\n * @dev A packed version of the Position which takes up a single storage slot using `PackedFixed18` values.\\n * @notice Library for the packed Position type.\\n */\\nlibrary PackedPositionLib {\\n /**\\n * @notice Creates an position from a packed position\\n * @param self packed position\\n * @return New position\\n */\\n function unpack(PackedPosition memory self) internal pure returns (Position memory) {\\n return Position({maker: self.maker.unpack(), taker: self.taker.unpack()});\\n }\\n}\\n\",\"keccak256\":\"0x04968e6794f6244cb3415cea111d640273a81faea957872988d0cb580f45df1e\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PayoffDefinition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"@openzeppelin/contracts/utils/Address.sol\\\";\\nimport \\\"../../interfaces/IContractPayoffProvider.sol\\\";\\n\\n/// @dev PayoffDefinition tyoe\\nstruct PayoffDefinition {\\n PayoffDefinitionLib.PayoffType payoffType;\\n PayoffDefinitionLib.PayoffDirection payoffDirection;\\n bytes30 data;\\n}\\nusing PayoffDefinitionLib for PayoffDefinition global;\\ntype PayoffDefinitionStorage is bytes32;\\nusing PayoffDefinitionStorageLib for PayoffDefinitionStorage global;\\n\\n/**\\n * @title PayoffDefinitionLib\\n * @dev Library that surfaces logic for PayoffDefinition type functionality\\n * @notice Library for the PayoffDefinition type. Performs validity and price transformation\\n based on the payoff definition type.\\n */\\nlibrary PayoffDefinitionLib {\\n using Address for address;\\n\\n error PayoffDefinitionUnsupportedTransform(PayoffType payoffType, PayoffDirection payoffDirection);\\n error PayoffDefinitionNotContract(PayoffType payoffType, bytes30 data);\\n\\n /// @dev Payoff function type enum\\n enum PayoffType { PASSTHROUGH, CONTRACT }\\n enum PayoffDirection { LONG, SHORT }\\n\\n /**\\n * @notice Checks validity of the payoff definition\\n * @param self a payoff definition\\n * @return Whether the payoff definition is valid for it's given type\\n */\\n function valid(PayoffDefinition memory self) internal view returns (bool) {\\n if (self.payoffType == PayoffType.CONTRACT) return address(_providerContract(self)).isContract();\\n\\n // All other payoff types should have no data\\n return uint(bytes32(self.data)) == 0;\\n }\\n\\n /**\\n * @notice Transforms a price based on the payoff definition\\n * @param self a payoff definition\\n * @param price raw oracle price\\n * @return Price transformed by the payoff definition function\\n */\\n function transform(\\n PayoffDefinition memory self,\\n Fixed18 price\\n ) internal view returns (Fixed18) {\\n PayoffType payoffType = self.payoffType;\\n PayoffDirection payoffDirection = self.payoffDirection;\\n Fixed18 transformedPrice;\\n\\n // First get the price depending on the type\\n if (payoffType == PayoffType.PASSTHROUGH) transformedPrice = price;\\n else if (payoffType == PayoffType.CONTRACT) transformedPrice = _payoffFromContract(self, price);\\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\\n\\n // Then transform it depending on the direction flag\\n if (self.payoffDirection == PayoffDirection.LONG) return transformedPrice;\\n else if (self.payoffDirection == PayoffDirection.SHORT) return transformedPrice.mul(Fixed18Lib.NEG_ONE);\\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\\n }\\n\\n /**\\n * @notice Parses the data field into an address\\n * @dev Reverts if payoffType is not CONTRACT\\n * @param self a payoff definition\\n * @return IContractPayoffProvider address\\n */\\n function _providerContract(\\n PayoffDefinition memory self\\n ) private pure returns (IContractPayoffProvider) {\\n if (self.payoffType != PayoffType.CONTRACT) revert PayoffDefinitionNotContract(self.payoffType, self.data);\\n // Shift to pull the last 20 bytes, then cast to an address\\n return IContractPayoffProvider(address(bytes20(self.data << 80)));\\n }\\n\\n /**\\n * @notice Performs a price transformation by calling the underlying payoff contract\\n * @param self a payoff definition\\n * @param price raw oracle price\\n * @return Price transformed by the payoff definition function on the contract\\n */\\n function _payoffFromContract(\\n PayoffDefinition memory self,\\n Fixed18 price\\n ) private view returns (Fixed18) {\\n bytes memory ret = address(_providerContract(self)).functionStaticCall(\\n abi.encodeCall(IContractPayoffProvider.payoff, price)\\n );\\n return Fixed18.wrap(abi.decode(ret, (int256)));\\n }\\n}\\n\\n/**\\n * @title PayoffDefinitionStorageLib\\n * @notice Library that surfaces storage read and writes for the PayoffDefinition type\\n */\\nlibrary PayoffDefinitionStorageLib {\\n function read(PayoffDefinitionStorage self) internal view returns (PayoffDefinition memory) {\\n return _storagePointer(self);\\n }\\n\\n function store(PayoffDefinitionStorage self, PayoffDefinition memory value) internal {\\n PayoffDefinition storage storagePointer = _storagePointer(self);\\n\\n storagePointer.payoffType = value.payoffType;\\n storagePointer.payoffDirection = value.payoffDirection;\\n storagePointer.data = value.data;\\n }\\n\\n function _storagePointer(\\n PayoffDefinitionStorage self\\n ) private pure returns (PayoffDefinition storage pointer) {\\n assembly { pointer.slot := self }\\n }\\n}\\n\",\"keccak256\":\"0x4d3897f408f77381c5ae9990391465c8fd511ddf6ff3b39f6cb69d8c2bd554df\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/Position.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\nimport \\\"./PrePosition.sol\\\";\\nimport \\\"./PackedPosition.sol\\\";\\n\\n/// @dev Position type\\nstruct Position {\\n /// @dev Quantity of the maker position\\n UFixed18 maker;\\n /// @dev Quantity of the taker position\\n UFixed18 taker;\\n}\\nusing PositionLib for Position global;\\n\\n/**\\n * @title PositionLib\\n * @notice Library that surfaces math and settlement computations for the Position type.\\n * @dev Positions track the current quantity of the account's maker and taker positions respectively\\n * denominated as a unit of the product's payoff function.\\n */\\nlibrary PositionLib {\\n /**\\n * @notice Creates a packed position from an position\\n * @param self A position\\n * @return New packed position\\n */\\n function pack(Position memory self) internal pure returns (PackedPosition memory) {\\n return PackedPosition({maker: self.maker.pack(), taker: self.taker.pack()});\\n }\\n\\n /**\\n * @notice Returns whether the position is fully empty\\n * @param self A position\\n * @return Whether the position is empty\\n */\\n function isEmpty(Position memory self) internal pure returns (bool) {\\n return self.maker.isZero() && self.taker.isZero();\\n }\\n\\n /**\\n * @notice Adds position `a` and `b` together, returning the result\\n * @param a The first position to sum\\n * @param b The second position to sum\\n * @return Resulting summed position\\n */\\n function add(Position memory a, Position memory b) internal pure returns (Position memory) {\\n return Position({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\\n }\\n\\n /**\\n * @notice Subtracts position `b` from `a`, returning the result\\n * @param a The position to subtract from\\n * @param b The position to subtract\\n * @return Resulting subtracted position\\n */\\n function sub(Position memory a, Position memory b) internal pure returns (Position memory) {\\n return Position({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\\n }\\n\\n /**\\n * @notice Multiplies position `self` by accumulator `accumulator` and returns the resulting accumulator\\n * @param self The Position to operate on\\n * @param accumulator The accumulator to multiply by\\n * @return Resulting multiplied accumulator\\n */\\n function mul(Position memory self, Accumulator memory accumulator) internal pure returns (Accumulator memory) {\\n return Accumulator({\\n maker: Fixed18Lib.from(self.maker).mul(accumulator.maker),\\n taker: Fixed18Lib.from(self.taker).mul(accumulator.taker)\\n });\\n }\\n\\n /**\\n * @notice Scales position `self` by fixed-decimal `scale` and returns the resulting position\\n * @param self The Position to operate on\\n * @param scale The Fixed-decimal to scale by\\n * @return Resulting scaled position\\n */\\n function mul(Position memory self, UFixed18 scale) internal pure returns (Position memory) {\\n return Position({maker: self.maker.mul(scale), taker: self.taker.mul(scale)});\\n }\\n\\n /**\\n * @notice Divides position `self` by `b` and returns the resulting accumulator\\n * @param self The Position to operate on\\n * @param b The number to divide by\\n * @return Resulting divided accumulator\\n */\\n function div(Position memory self, uint256 b) internal pure returns (Accumulator memory) {\\n return Accumulator({\\n maker: Fixed18Lib.from(self.maker).div(Fixed18Lib.from(UFixed18Lib.from(b))),\\n taker: Fixed18Lib.from(self.taker).div(Fixed18Lib.from(UFixed18Lib.from(b)))\\n });\\n }\\n\\n /**\\n * @notice Returns the maximum of `self`'s maker and taker values\\n * @param self The struct to operate on\\n * @return Resulting maximum value\\n */\\n function max(Position memory self) internal pure returns (UFixed18) {\\n return UFixed18Lib.max(self.maker, self.taker);\\n }\\n\\n /**\\n * @notice Sums the maker and taker together from a single position\\n * @param self The struct to operate on\\n * @return The sum of its maker and taker\\n */\\n function sum(Position memory self) internal pure returns (UFixed18) {\\n return self.maker.add(self.taker);\\n }\\n\\n /**\\n * @notice Computes the next position after the pending-settlement position delta is included\\n * @param self The current Position\\n * @param pre The pending-settlement position delta\\n * @return Next Position\\n */\\n function next(Position memory self, PrePosition memory pre) internal pure returns (Position memory) {\\n return sub(add(self, pre.openPosition), pre.closePosition);\\n }\\n\\n /**\\n * @notice Returns the settled position at oracle version `toOracleVersion`\\n * @dev Checks if a new position is ready to be settled based on the provided `toOracleVersion`\\n * and `pre` and returns accordingly\\n * @param self The current Position\\n * @param pre The pending-settlement position delta\\n * @param toOracleVersion The oracle version to settle to\\n * @return Settled position at oracle version\\n * @return Fee accrued from opening or closing the position\\n * @return Whether a new position was settled\\n */\\n function settled(\\n Position memory self,\\n PrePosition memory pre,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal view returns (Position memory, UFixed18, bool) {\\n return pre.canSettle(toOracleVersion) ? (next(self, pre), pre.computeFee(toOracleVersion), true) : (self, UFixed18Lib.ZERO, false);\\n }\\n\\n /**\\n * @notice Returns the socialization factor for the current position\\n * @dev Socialization account for the case where `taker` > `maker` temporarily due to a liquidation\\n * on the maker side. This dampens the taker's exposure pro-rata to ensure that the maker side\\n * is never exposed over 1 x short.\\n * @param self The Position to operate on\\n * @return Socialization factor\\n */\\n function socializationFactor(Position memory self) internal pure returns (UFixed18) {\\n return self.taker.isZero() ? UFixed18Lib.ONE : UFixed18Lib.min(UFixed18Lib.ONE, self.maker.div(self.taker));\\n }\\n}\\n\",\"keccak256\":\"0x027fe392c4f56bf012ba2ca462fcf23e69f2c3b9d283c14089771813437af991\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PrePosition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./Position.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\n\\n/// @dev PrePosition type\\nstruct PrePosition {\\n /// @dev Oracle version at which the new position delta was recorded\\n uint256 oracleVersion;\\n\\n /// @dev Size of position to open at oracle version\\n Position openPosition;\\n\\n /// @dev Size of position to close at oracle version\\n Position closePosition;\\n}\\nusing PrePositionLib for PrePosition global;\\n\\n/**\\n * @title PrePositionLib\\n * @notice Library that manages a pre-settlement position delta.\\n * @dev PrePositions track the currently awaiting-settlement deltas to a settled Position. These are\\n * Primarily necessary to introduce lag into the settlement system such that oracle lag cannot be\\n * gamed to a user's advantage. When a user opens or closes a new position, it sits as a PrePosition\\n * for one oracle version until it's settle into the Position, making it then effective. PrePositions\\n * are automatically settled at the correct oracle version even if a flywheel call doesn't happen until\\n * several version into the future by using the historical version lookups in the corresponding \\\"Versioned\\\"\\n * global state types.\\n */\\nlibrary PrePositionLib {\\n /**\\n * @notice Returns whether there is no pending-settlement position delta\\n * @dev Can be \\\"empty\\\" even with a non-zero oracleVersion if a position is opened and\\n * closed in the same version netting out to a zero position delta\\n * @param self The struct to operate on\\n * @return Whether the pending-settlement position delta is empty\\n */\\n function isEmpty(PrePosition memory self) internal pure returns (bool) {\\n return self.openPosition.isEmpty() && self.closePosition.isEmpty();\\n }\\n\\n /**\\n * @notice Increments the maker side of the open position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The position amount to open\\n */\\n function openMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.openPosition.maker = self.openPosition.maker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netMake(self);\\n }\\n\\n /**\\n * @notice Increments the maker side of the close position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The maker position amount to close\\n */\\n function closeMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.closePosition.maker = self.closePosition.maker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netMake(self);\\n }\\n\\n /**\\n * @notice Increments the taker side of the open position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The taker position amount to open\\n */\\n function openTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.openPosition.taker = self.openPosition.taker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netTake(self);\\n }\\n\\n /**\\n * @notice Increments the taker side of the close position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The taker position amount to close\\n */\\n function closeTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.closePosition.taker = self.closePosition.taker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netTake(self);\\n }\\n\\n /**\\n * @notice Nets out the open and close on the maker side of the position delta\\n * @param self The struct to operate on\\n */\\n function _netMake(PrePosition storage self) private {\\n if (self.openPosition.maker.gt(self.closePosition.maker)) {\\n self.openPosition.maker = self.openPosition.maker.sub(self.closePosition.maker);\\n self.closePosition.maker = UFixed18Lib.ZERO;\\n } else {\\n self.closePosition.maker = self.closePosition.maker.sub(self.openPosition.maker);\\n self.openPosition.maker = UFixed18Lib.ZERO;\\n }\\n }\\n\\n /**\\n * @notice Nets out the open and close on the taker side of the position delta\\n * @param self The struct to operate on\\n */\\n function _netTake(PrePosition storage self) private {\\n if (self.openPosition.taker.gt(self.closePosition.taker)) {\\n self.openPosition.taker = self.openPosition.taker.sub(self.closePosition.taker);\\n self.closePosition.taker = UFixed18Lib.ZERO;\\n } else {\\n self.closePosition.taker = self.closePosition.taker.sub(self.openPosition.taker);\\n self.openPosition.taker = UFixed18Lib.ZERO;\\n }\\n }\\n\\n /**\\n * @notice Returns whether the the pending position delta can be settled at version `toOracleVersion`\\n * @dev Pending-settlement positions deltas can be settled (1) oracle version after they are recorded\\n * @param self The struct to operate on\\n * @param toOracleVersion The potential oracle version to settle\\n * @return Whether the position delta can be settled\\n */\\n function canSettle(\\n PrePosition memory self,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal pure returns (bool) {\\n return !isEmpty(self) && toOracleVersion.version > self.oracleVersion;\\n }\\n\\n /**\\n * @notice Computes the fee incurred for opening or closing the pending-settlement position\\n * @dev Must be called from a valid product to get the proper fee amounts\\n * @param self The struct to operate on\\n * @param toOracleVersion The oracle version at which settlement takes place\\n * @return positionFee The maker / taker fee incurred\\n */\\n function computeFee(\\n PrePosition memory self,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal view returns (UFixed18) {\\n Position memory positionDelta = self.openPosition.add(self.closePosition);\\n\\n (UFixed18 makerNotional, UFixed18 takerNotional) = (\\n Fixed18Lib.from(positionDelta.maker).mul(toOracleVersion.price).abs(),\\n Fixed18Lib.from(positionDelta.taker).mul(toOracleVersion.price).abs()\\n );\\n\\n IProduct product = IProduct(address(this));\\n return makerNotional.mul(product.makerFee()).add(takerNotional.mul(product.takerFee()));\\n }\\n\\n /**\\n * @notice Computes the next oracle version to settle\\n * @dev - If there is no pending-settlement position delta, returns the current oracle version\\n * - Otherwise returns the oracle version at which the pending-settlement position delta can be first settled\\n *\\n * Corresponds to point (b) in the Position settlement flow\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @return Next oracle version to settle\\n */\\n function settleVersion(PrePosition storage self, uint256 currentVersion) internal view returns (uint256) {\\n uint256 _oracleVersion = self.oracleVersion;\\n return _oracleVersion == 0 ? currentVersion : _oracleVersion + 1;\\n }\\n}\\n\",\"keccak256\":\"0xa6f83f7b5f8139ec874235c406debd086a152977493c08b7f280df6f1737fb96\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/ProgramInfo.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\nimport \\\"./Position.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\n\\n/// @dev ProgramInfo type\\nstruct ProgramInfo {\\n /// @dev Coordinator for this program\\n uint256 coordinatorId;\\n\\n /// @dev Amount of total maker and taker rewards\\n Position amount;\\n\\n /// @dev start timestamp of the program\\n uint256 start;\\n\\n /// @dev duration of the program (in seconds)\\n uint256 duration;\\n\\n /**\\n * @dev Reward ERC20 token contract\\n * @notice Perennial does not support non-standard ERC20s as reward tokens for incentive programs, including,\\n but not limited to: fee on transfer and rebase tokens. Using such a non-standard token will likely\\n result in loss of funds.\\n */\\n Token18 token;\\n}\\nusing ProgramInfoLib for ProgramInfo global;\\n\\n/**\\n * @title ProgramInfoLib\\n * @notice Library that snapshots the static information for a single program.\\n * @dev This information does not change during the operation of a program.\\n */\\nlibrary ProgramInfoLib {\\n uint256 private constant MIN_DURATION = 1 days;\\n uint256 private constant MAX_DURATION = 2 * 365 days;\\n\\n error ProgramInvalidStartError();\\n error ProgramInvalidDurationError();\\n\\n /**\\n * @notice Validates and creates a new Program\\n * @dev Reverts for invalid programInfos\\n * @param programInfo Un-sanitized static program information\\n */\\n function validate(ProgramInfo memory programInfo) internal view {\\n if (isStarted(programInfo, block.timestamp)) revert ProgramInvalidStartError();\\n if (programInfo.duration < MIN_DURATION || programInfo.duration > MAX_DURATION) revert ProgramInvalidDurationError();\\n }\\n\\n /**\\n * @notice Computes a new program info with the fee taken out of the amount\\n * @param programInfo Original program info\\n * @param incentivizationFee The incentivization fee\\n * @return New program info\\n * @return Fee amount\\n */\\n function deductFee(ProgramInfo memory programInfo, UFixed18 incentivizationFee)\\n internal pure returns (ProgramInfo memory, UFixed18) {\\n Position memory newProgramAmount = programInfo.amount.mul(UFixed18Lib.ONE.sub(incentivizationFee));\\n UFixed18 programFeeAmount = programInfo.amount.sub(newProgramAmount).sum();\\n programInfo.amount = newProgramAmount;\\n return (programInfo, programFeeAmount);\\n }\\n\\n /**\\n * @notice Returns the maker and taker amounts per position share\\n * @param self The ProgramInfo to operate on\\n * @return programFee Amounts per share\\n */\\n function amountPerShare(ProgramInfo memory self) internal pure returns (Accumulator memory) {\\n return self.amount.div(self.duration);\\n }\\n\\n /**\\n * @notice Returns whether the program has started by timestamp `timestamp`\\n * @param self The ProgramInfo to operate on\\n * @param timestamp Timestamp to check for\\n * @return Whether the program has started\\n */\\n function isStarted(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\\n return timestamp >= self.start;\\n }\\n\\n /**\\n * @notice Returns whether the program is completed by timestamp `timestamp`\\n * @param self The ProgramInfo to operate on\\n * @param timestamp Timestamp to check for\\n * @return Whether the program is completed\\n */\\n function isComplete(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\\n return timestamp >= (self.start + self.duration);\\n }\\n}\\n\",\"keccak256\":\"0x280fcaf931b49abaec46b95ccbabaaf856a4b8e8d036413c9c3b3af25585d161\",\"license\":\"Apache-2.0\"}},\"version\":1}", - "bytecode": "0x6101006040523480156200001257600080fd5b50604051620012ba380380620012ba83398101604081905262000035916200058a565b6200004b846200017160201b6200034b1760201c565b620000695760405163e5df3e0960e01b815260040160405180910390fd5b6200007f836200017160201b6200034b1760201c565b6200009d5760405163e5df3e0960e01b815260040160405180910390fd5b620000b3826200017160201b6200034b1760201c565b620000d15760405163e5df3e0960e01b815260040160405180910390fd5b620000e7816200017160201b6200034b1760201c565b620001055760405163e5df3e0960e01b815260040160405180910390fd5b6001600160a01b03848116608081905284821660a05283821660c081905291831660e052620001409162000180602090811b6200036717901c565b6200016760e05160a0516001600160a01b03166200018060201b620003671790919060201c565b50505050620006b6565b6001600160a01b03163b151590565b620001a781600019846001600160a01b0316620001ab60201b620003ac179092919060201c565b5050565b801580620002295750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa15801562000201573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620002279190620005f2565b155b620002a15760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e63650000000000000000000060648201526084015b60405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b0390811663095ea7b360e01b17909152620002f9918591620002fe16565b505050565b60006200035a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316620003dc60201b620005b6179092919060201c565b805190915015620002f957808060200190518101906200037b91906200060c565b620002f95760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840162000298565b6060620003ed8484600085620003f7565b90505b9392505050565b6060824710156200045a5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840162000298565b6001600160a01b0385163b620004b35760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640162000298565b600080866001600160a01b03168587604051620004d1919062000663565b60006040518083038185875af1925050503d806000811462000510576040519150601f19603f3d011682016040523d82523d6000602084013e62000515565b606091505b5090925090506200052882828662000533565b979650505050505050565b6060831562000544575081620003f0565b825115620005555782518084602001fd5b8160405162461bcd60e51b815260040162000298919062000681565b6001600160a01b03811681146200058757600080fd5b50565b60008060008060808587031215620005a157600080fd5b8451620005ae8162000571565b6020860151909450620005c18162000571565b6040860151909350620005d48162000571565b6060860151909250620005e78162000571565b939692955090935050565b6000602082840312156200060557600080fd5b5051919050565b6000602082840312156200061f57600080fd5b81518015158114620003f057600080fd5b60005b838110156200064d57818101518382015260200162000633565b838111156200065d576000848401525b50505050565b600082516200067781846020870162000630565b9190910192915050565b6020815260008251806020840152620006a281604085016020870162000630565b601f01601f19169190910160400192915050565b60805160a05160c05160e051610bb862000702600039600081816101240152610281015260008181607101526101be0152600060fd01526000818160d601526101600152610bb86000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c806389a302711161005057806389a30271146100d1578063a2060bcf146100f8578063d8dfeb451461011f57600080fd5b8063025a3a291461006c57806344bc170a146100bc575b600080fd5b6100937f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b6100cf6100ca3660046109d7565b610146565b005b6100937f000000000000000000000000000000000000000000000000000000000000000081565b6100937f000000000000000000000000000000000000000000000000000000000000000081565b6100937f000000000000000000000000000000000000000000000000000000000000000081565b61018973ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016338360016105cf565b6040517f13bac820000000000000000000000000000000000000000000000000000000008152600481018290523060248201527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16906313bac82090604401600060405180830381600087803b15801561021757600080fd5b505af115801561022b573d6000803e3d6000fd5b50506040517ff213159c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff86811660048301528581166024830152604482018590527f000000000000000000000000000000000000000000000000000000000000000016925063f213159c9150606401600060405180830381600087803b1580156102c757600080fd5b505af11580156102db573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8e7ce60e353ab1a4cc59ca4782bdc69e0565713d1824dce27e0de2e362147ed08360405161033e91815260200190565b60405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6103a873ffffffffffffffffffffffffffffffffffffffff8316827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6103ac565b5050565b80158061044c57506040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff838116602483015284169063dd62ed3e90604401602060405180830381865afa158015610426573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061044a9190610a18565b155b6104dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e63650000000000000000000060648201526084015b60405180910390fd5b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526105b19084907f095ea7b300000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152610603565b505050565b60606105c5848460008561070f565b90505b9392505050565b6105fd83306105de85856108a5565b73ffffffffffffffffffffffffffffffffffffffff88169291906108cf565b50505050565b6000610665826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166105b69092919063ffffffff16565b8051909150156105b157808060200190518101906106839190610a31565b6105b1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016104d4565b6060824710156107a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016104d4565b73ffffffffffffffffffffffffffffffffffffffff85163b61081f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016104d4565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516108489190610a7f565b60006040518083038185875af1925050503d8060008114610885576040519150601f19603f3d011682016040523d82523d6000602084013e61088a565b606091505b509150915061089a82828661092d565b979650505050505050565b6000816108c0576108bb64e8d4a5100084610aca565b6105c8565b6105c88364e8d4a51000610980565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526105fd9085907f23b872dd000000000000000000000000000000000000000000000000000000009060840161052f565b6060831561093c5750816105c8565b82511561094c5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104d49190610ade565b600061098c8284610b2f565b1561099857600161099b565b60005b60ff166109a88385610aca565b6105c89190610b43565b73ffffffffffffffffffffffffffffffffffffffff811681146109d457600080fd5b50565b6000806000606084860312156109ec57600080fd5b83356109f7816109b2565b92506020840135610a07816109b2565b929592945050506040919091013590565b600060208284031215610a2a57600080fd5b5051919050565b600060208284031215610a4357600080fd5b815180151581146105c857600080fd5b60005b83811015610a6e578181015183820152602001610a56565b838111156105fd5750506000910152565b60008251610a91818460208701610a53565b9190910192915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600082610ad957610ad9610a9b565b500490565b6020815260008251806020840152610afd816040850160208701610a53565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b600082610b3e57610b3e610a9b565b500690565b60008219821115610b7d577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b50019056fea2646970667358221220ec9c4186939b8bfc3bd6ef92257a35503ebc51f749f10b706ec9c0022f7b049664736f6c634300080f0033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100675760003560e01c806389a302711161005057806389a30271146100d1578063a2060bcf146100f8578063d8dfeb451461011f57600080fd5b8063025a3a291461006c57806344bc170a146100bc575b600080fd5b6100937f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b6100cf6100ca3660046109d7565b610146565b005b6100937f000000000000000000000000000000000000000000000000000000000000000081565b6100937f000000000000000000000000000000000000000000000000000000000000000081565b6100937f000000000000000000000000000000000000000000000000000000000000000081565b61018973ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016338360016105cf565b6040517f13bac820000000000000000000000000000000000000000000000000000000008152600481018290523060248201527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16906313bac82090604401600060405180830381600087803b15801561021757600080fd5b505af115801561022b573d6000803e3d6000fd5b50506040517ff213159c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff86811660048301528581166024830152604482018590527f000000000000000000000000000000000000000000000000000000000000000016925063f213159c9150606401600060405180830381600087803b1580156102c757600080fd5b505af11580156102db573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8e7ce60e353ab1a4cc59ca4782bdc69e0565713d1824dce27e0de2e362147ed08360405161033e91815260200190565b60405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6103a873ffffffffffffffffffffffffffffffffffffffff8316827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6103ac565b5050565b80158061044c57506040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff838116602483015284169063dd62ed3e90604401602060405180830381865afa158015610426573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061044a9190610a18565b155b6104dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e63650000000000000000000060648201526084015b60405180910390fd5b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526105b19084907f095ea7b300000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152610603565b505050565b60606105c5848460008561070f565b90505b9392505050565b6105fd83306105de85856108a5565b73ffffffffffffffffffffffffffffffffffffffff88169291906108cf565b50505050565b6000610665826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166105b69092919063ffffffff16565b8051909150156105b157808060200190518101906106839190610a31565b6105b1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016104d4565b6060824710156107a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016104d4565b73ffffffffffffffffffffffffffffffffffffffff85163b61081f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016104d4565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516108489190610a7f565b60006040518083038185875af1925050503d8060008114610885576040519150601f19603f3d011682016040523d82523d6000602084013e61088a565b606091505b509150915061089a82828661092d565b979650505050505050565b6000816108c0576108bb64e8d4a5100084610aca565b6105c8565b6105c88364e8d4a51000610980565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526105fd9085907f23b872dd000000000000000000000000000000000000000000000000000000009060840161052f565b6060831561093c5750816105c8565b82511561094c5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104d49190610ade565b600061098c8284610b2f565b1561099857600161099b565b60005b60ff166109a88385610aca565b6105c89190610b43565b73ffffffffffffffffffffffffffffffffffffffff811681146109d457600080fd5b50565b6000806000606084860312156109ec57600080fd5b83356109f7816109b2565b92506020840135610a07816109b2565b929592945050506040919091013590565b600060208284031215610a2a57600080fd5b5051919050565b600060208284031215610a4357600080fd5b815180151581146105c857600080fd5b60005b83811015610a6e578181015183820152602001610a56565b838111156105fd5750506000910152565b60008251610a91818460208701610a53565b9190910192915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600082610ad957610ad9610a9b565b500490565b6020815260008251806020840152610afd816040850160208701610a53565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b600082610b3e57610b3e610a9b565b500690565b60008219821115610b7d577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b50019056fea2646970667358221220ec9c4186939b8bfc3bd6ef92257a35503ebc51f749f10b706ec9c0022f7b049664736f6c634300080f0033", - "devdoc": { - "kind": "dev", - "methods": { - "constructor": { - "params": { - "batcher_": "The USDC-to-DSU batcher contract address", - "collateral_": "The perennial collateral contract address", - "dsu_": "The DSU token contract address", - "usdc_": "The USDC token contract address" - } - }, - "wrapAndDeposit(address,address,uint256)": { - "params": { - "account": "Account to deposit the collateral for", - "amount": "18 decimals-normalized stablecoin (USDC, DSU) value of collateral to deposit", - "product": "Product to credit the collateral to" - } - } - }, - "stateVariables": { - "batcher": { - "details": "Contract that wraps USDC to DSU" - }, - "collateral": { - "details": "Contract managing state for collateral accounts in the protocol" - } - }, - "title": "Forwarder", - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": { - "constructor": { - "notice": "Initializes the contract state" - }, - "wrapAndDeposit(address,address,uint256)": { - "notice": "Pulls `amount` of USDC from `msg.sender`'s balance, wraps it as DSU, and deposits it as collateral to `account`'s `product` account" - } - }, - "notice": "Facilitates collateral deposits to the protocol where the amount is supplied in USDC then wrapped as DSU before being deposited.", - "version": 1 - }, - "storageLayout": { - "storage": [], - "types": null - } -} diff --git a/packages/perennial/deployments/kovan/Incentivizer_Impl.json b/packages/perennial/deployments/kovan/Incentivizer_Impl.json deleted file mode 100644 index 49dc46064..000000000 --- a/packages/perennial/deployments/kovan/Incentivizer_Impl.json +++ /dev/null @@ -1,1361 +0,0 @@ -{ - "address": "0x38934b335543246A49F82dbf364C37BbC877d9f2", - "abi": [ - { - "inputs": [ - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Fixed18OverflowError", - "type": "error" - }, - { - "inputs": [], - "name": "IncentivizerBatchClaimArgumentMismatchError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "uint256", - "name": "programId", - "type": "uint256" - } - ], - "name": "IncentivizerInvalidProgramError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "IncentivizerNotAllowedError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "uint256", - "name": "programId", - "type": "uint256" - } - ], - "name": "IncentivizerNotProgramOwnerError", - "type": "error" - }, - { - "inputs": [], - "name": "IncentivizerTooManyProgramsError", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidControllerError", - "type": "error" - }, - { - "inputs": [], - "name": "NotCollateralError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - } - ], - "name": "NotOwnerError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "NotProductError", - "type": "error" - }, - { - "inputs": [], - "name": "PausedError", - "type": "error" - }, - { - "inputs": [], - "name": "ProgramInvalidDurationError", - "type": "error" - }, - { - "inputs": [], - "name": "ProgramInvalidStartError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "int256", - "name": "value", - "type": "int256" - } - ], - "name": "UFixed18UnderflowError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "version", - "type": "uint256" - } - ], - "name": "UInitializableAlreadyInitializedError", - "type": "error" - }, - { - "inputs": [], - "name": "UInitializableNotInitializingError", - "type": "error" - }, - { - "inputs": [], - "name": "UInitializableZeroVersionError", - "type": "error" - }, - { - "inputs": [], - "name": "UReentrancyGuardReentrantCallError", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "programId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "Claim", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "Token18", - "name": "token", - "type": "address" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "FeeClaim", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "version", - "type": "uint256" - } - ], - "name": "Initialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "programId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "version", - "type": "uint256" - } - ], - "name": "ProgramComplete", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "programId", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "amount", - "type": "tuple" - }, - { - "internalType": "uint256", - "name": "start", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "duration", - "type": "uint256" - }, - { - "internalType": "Token18", - "name": "token", - "type": "address" - } - ], - "indexed": false, - "internalType": "struct ProgramInfo", - "name": "programInfo", - "type": "tuple" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "programFeeAmount", - "type": "uint256" - } - ], - "name": "ProgramCreated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "programId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "version", - "type": "uint256" - } - ], - "name": "ProgramStarted", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "active", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "uint256", - "name": "programId", - "type": "uint256" - } - ], - "name": "available", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "uint256[]", - "name": "programIds", - "type": "uint256[]" - } - ], - "name": "claim", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct[]", - "name": "products", - "type": "address[]" - }, - { - "internalType": "uint256[][]", - "name": "programIds", - "type": "uint256[][]" - } - ], - "name": "claim", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "Token18[]", - "name": "tokens", - "type": "address[]" - } - ], - "name": "claimFee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "uint256", - "name": "programId", - "type": "uint256" - } - ], - "name": "complete", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "controller", - "outputs": [ - { - "internalType": "contract IController", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "count", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "components": [ - { - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "amount", - "type": "tuple" - }, - { - "internalType": "uint256", - "name": "start", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "duration", - "type": "uint256" - }, - { - "internalType": "Token18", - "name": "token", - "type": "address" - } - ], - "internalType": "struct ProgramInfo", - "name": "programInfo", - "type": "tuple" - } - ], - "name": "create", - "outputs": [ - { - "internalType": "uint256", - "name": "programId", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "Token18", - "name": "", - "type": "address" - } - ], - "name": "fees", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IController", - "name": "controller_", - "type": "address" - } - ], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "uint256", - "name": "programId", - "type": "uint256" - } - ], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "uint256", - "name": "programId", - "type": "uint256" - } - ], - "name": "programInfos", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "amount", - "type": "tuple" - }, - { - "internalType": "uint256", - "name": "start", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "duration", - "type": "uint256" - }, - { - "internalType": "Token18", - "name": "token", - "type": "address" - } - ], - "internalType": "struct ProgramInfo", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "version", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - }, - { - "internalType": "Fixed18", - "name": "price", - "type": "int256" - } - ], - "internalType": "struct IOracleProvider.OracleVersion", - "name": "currentOracleVersion", - "type": "tuple" - } - ], - "name": "sync", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "components": [ - { - "internalType": "uint256", - "name": "version", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - }, - { - "internalType": "Fixed18", - "name": "price", - "type": "int256" - } - ], - "internalType": "struct IOracleProvider.OracleVersion", - "name": "currentOracleVersion", - "type": "tuple" - } - ], - "name": "syncAccount", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "uint256", - "name": "programId", - "type": "uint256" - } - ], - "name": "treasury", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "uint256", - "name": "programId", - "type": "uint256" - } - ], - "name": "unclaimed", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "uint256", - "name": "programId", - "type": "uint256" - } - ], - "name": "versionComplete", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "uint256", - "name": "programId", - "type": "uint256" - } - ], - "name": "versionStarted", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - } - ], - "transactionHash": "0xd3365695662706f3d6dc73b0c6dd1d55be926dac803617b25bd5b8195cf404ea", - "receipt": { - "to": null, - "from": "0x66a7fDB96C583c59597de16d8b2B989231415339", - "contractAddress": "0x38934b335543246A49F82dbf364C37BbC877d9f2", - "transactionIndex": 0, - "gasUsed": "3676487", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xdb494541169bb2a2e420182fa4b5ae00c8b99439924ee789c6bdb0ed585459b6", - "transactionHash": "0xd3365695662706f3d6dc73b0c6dd1d55be926dac803617b25bd5b8195cf404ea", - "logs": [], - "blockNumber": 33203731, - "cumulativeGasUsed": "3676487", - "status": 1, - "byzantium": true - }, - "args": [], - "numDeployments": 1, - "solcInputHash": "dd52f03d8fef7833844e4ba864fd9fba", - "metadata": "{\"compiler\":{\"version\":\"0.8.15+commit.e14f2714\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Fixed18OverflowError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"IncentivizerBatchClaimArgumentMismatchError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"}],\"name\":\"IncentivizerInvalidProgramError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"IncentivizerNotAllowedError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"}],\"name\":\"IncentivizerNotProgramOwnerError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"IncentivizerTooManyProgramsError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidControllerError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotCollateralError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"}],\"name\":\"NotOwnerError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"NotProductError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"PausedError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ProgramInvalidDurationError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ProgramInvalidStartError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"int256\",\"name\":\"value\",\"type\":\"int256\"}],\"name\":\"UFixed18UnderflowError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"UInitializableAlreadyInitializedError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UInitializableNotInitializingError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UInitializableZeroVersionError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UReentrancyGuardReentrantCallError\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Claim\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"Token18\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"FeeClaim\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"ProgramComplete\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"amount\",\"type\":\"tuple\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"duration\",\"type\":\"uint256\"},{\"internalType\":\"Token18\",\"name\":\"token\",\"type\":\"address\"}],\"indexed\":false,\"internalType\":\"struct ProgramInfo\",\"name\":\"programInfo\",\"type\":\"tuple\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"programFeeAmount\",\"type\":\"uint256\"}],\"name\":\"ProgramCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"ProgramStarted\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"active\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"}],\"name\":\"available\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"programIds\",\"type\":\"uint256[]\"}],\"name\":\"claim\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct[]\",\"name\":\"products\",\"type\":\"address[]\"},{\"internalType\":\"uint256[][]\",\"name\":\"programIds\",\"type\":\"uint256[][]\"}],\"name\":\"claim\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"Token18[]\",\"name\":\"tokens\",\"type\":\"address[]\"}],\"name\":\"claimFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"}],\"name\":\"complete\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"controller\",\"outputs\":[{\"internalType\":\"contract IController\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"count\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"amount\",\"type\":\"tuple\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"duration\",\"type\":\"uint256\"},{\"internalType\":\"Token18\",\"name\":\"token\",\"type\":\"address\"}],\"internalType\":\"struct ProgramInfo\",\"name\":\"programInfo\",\"type\":\"tuple\"}],\"name\":\"create\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"Token18\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"fees\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IController\",\"name\":\"controller_\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"}],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"}],\"name\":\"programInfos\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"amount\",\"type\":\"tuple\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"duration\",\"type\":\"uint256\"},{\"internalType\":\"Token18\",\"name\":\"token\",\"type\":\"address\"}],\"internalType\":\"struct ProgramInfo\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"},{\"internalType\":\"Fixed18\",\"name\":\"price\",\"type\":\"int256\"}],\"internalType\":\"struct IOracleProvider.OracleVersion\",\"name\":\"currentOracleVersion\",\"type\":\"tuple\"}],\"name\":\"sync\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"},{\"internalType\":\"Fixed18\",\"name\":\"price\",\"type\":\"int256\"}],\"internalType\":\"struct IOracleProvider.OracleVersion\",\"name\":\"currentOracleVersion\",\"type\":\"tuple\"}],\"name\":\"syncAccount\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"}],\"name\":\"treasury\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"}],\"name\":\"unclaimed\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"}],\"name\":\"versionComplete\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"programId\",\"type\":\"uint256\"}],\"name\":\"versionStarted\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"active(address)\":{\"params\":{\"product\":\"Product to check for\"},\"returns\":{\"_0\":\"Number of active programs\"}},\"available(address,uint256)\":{\"params\":{\"product\":\"Product to return for\",\"programId\":\"Program to return for\"},\"returns\":{\"_0\":\"Available rewards for `programId`\"}},\"claim(address,uint256[])\":{\"params\":{\"product\":\"Product to claim rewards for\",\"programIds\":\"Programs to claim rewards for\"}},\"claim(address[],uint256[][])\":{\"params\":{\"products\":\"Products to claim rewards for\",\"programIds\":\"Programs to claim rewards for\"}},\"claimFee(address[])\":{\"params\":{\"tokens\":\"Tokens to claim fees for\"}},\"complete(address,uint256)\":{\"details\":\"Must be called as the program owner\",\"params\":{\"product\":\"Product that the program is running on\",\"programId\":\"Program to complete early\"}},\"count(address)\":{\"params\":{\"product\":\"Product to check for\"},\"returns\":{\"_0\":\"Number of programs (inactive or active)\"}},\"create(address,(uint256,(uint256,uint256),uint256,uint256,address))\":{\"details\":\"Must be called as the product or protocol owner\",\"params\":{\"product\":\"The product to create the new program on\",\"programInfo\":\"Parameters for the new program\"},\"returns\":{\"programId\":\"New program's ID\"}},\"initialize(address)\":{\"details\":\"Must be called atomically as part of the upgradeable proxy deployment to avoid front-running\",\"params\":{\"controller_\":\"Factory contract address\"}},\"owner(address,uint256)\":{\"params\":{\"product\":\"Product to return for\",\"programId\":\"Program to return for\"},\"returns\":{\"_0\":\"The owner of `programId`\"}},\"programInfos(address,uint256)\":{\"params\":{\"product\":\"Product to return for\",\"programId\":\"Program to return for\"},\"returns\":{\"_0\":\"Program info\"}},\"sync((uint256,uint256,int256))\":{\"details\":\"Called every settle() from each product\",\"params\":{\"currentOracleVersion\":\"The preloaded current oracle version\"}},\"syncAccount(address,(uint256,uint256,int256))\":{\"details\":\"Called immediately proceeding a position update in the corresponding product\",\"params\":{\"account\":\"Account to sync\",\"currentOracleVersion\":\"The preloaded current oracle version\"}},\"treasury(address,uint256)\":{\"params\":{\"product\":\"Product to return for\",\"programId\":\"Program to return for\"},\"returns\":{\"_0\":\"The treasury of `programId`\"}},\"unclaimed(address,address,uint256)\":{\"params\":{\"account\":\"Account to return for\",\"product\":\"Product to return for\",\"programId\":\"Program to return for\"},\"returns\":{\"_0\":\"`account`'s total unclaimed rewards for `programId`\"}},\"versionComplete(address,uint256)\":{\"params\":{\"product\":\"Product to return for\",\"programId\":\"Program to return for\"},\"returns\":{\"_0\":\"The version completed for `programId`\"}},\"versionStarted(address,uint256)\":{\"params\":{\"product\":\"Product to return for\",\"programId\":\"Program to return for\"},\"returns\":{\"_0\":\"The version started for `programId`\"}}},\"stateVariables\":{\"_products\":{\"details\":\"Product management state\"},\"fees\":{\"details\":\"Fees that have been collected, but remain unclaimed\"}},\"title\":\"Incentivizer\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"active(address)\":{\"notice\":\"Returns the quantity of active programs for a given product\"},\"available(address,uint256)\":{\"notice\":\"Returns available rewards for a specific program\"},\"claim(address,uint256[])\":{\"notice\":\"Claims all of `msg.sender`'s rewards for `product` programs\"},\"claim(address[],uint256[][])\":{\"notice\":\"Claims all of `msg.sender`'s rewards for a specific program\"},\"claimFee(address[])\":{\"notice\":\"Claims all `tokens` fees to the protocol treasury\"},\"complete(address,uint256)\":{\"notice\":\"Completes an in-progress program early\"},\"count(address)\":{\"notice\":\"Returns the quantity of programs for a given product\"},\"create(address,(uint256,(uint256,uint256),uint256,uint256,address))\":{\"notice\":\"Creates a new incentive program\"},\"initialize(address)\":{\"notice\":\"Initializes the contract state\"},\"owner(address,uint256)\":{\"notice\":\"Returns the owner of a specific program\"},\"programInfos(address,uint256)\":{\"notice\":\"Returns program info for program `programId`\"},\"sync((uint256,uint256,int256))\":{\"notice\":\"Starts and completes programs as they become available\"},\"syncAccount(address,(uint256,uint256,int256))\":{\"notice\":\"Settles unsettled balance for `account`\"},\"treasury(address,uint256)\":{\"notice\":\"Returns the treasury of a specific program\"},\"unclaimed(address,address,uint256)\":{\"notice\":\"Returns `account`'s total unclaimed rewards for a specific program\"},\"versionComplete(address,uint256)\":{\"notice\":\"Returns the version completed for a specific program\"},\"versionStarted(address,uint256)\":{\"notice\":\"Returns the version started for a specific program\"}},\"notice\":\"Manages logic and state for all incentive programs in the protocol.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/incentivizer/Incentivizer.sol\":\"Incentivizer\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\n\\ninterface IOracleProvider {\\n /// @dev A singular oracle version with its corresponding data\\n struct OracleVersion {\\n /// @dev The iterative version\\n uint256 version;\\n\\n /// @dev the timestamp of the oracle update\\n uint256 timestamp;\\n\\n /// @dev The oracle price of the corresponding version\\n Fixed18 price;\\n }\\n\\n function sync() external returns (OracleVersion memory);\\n function currentVersion() external view returns (OracleVersion memory);\\n function atVersion(uint256 oracleVersion) external view returns (OracleVersion memory);\\n}\\n\",\"keccak256\":\"0xde0f20d468ba8b91addfc356e13f2c74a4dc8abe68be323942217c723775d9c1\",\"license\":\"Apache-2.0\"},\"@equilibria/root/control/unstructured/UInitializable.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/Address.sol\\\";\\nimport \\\"../../storage/UStorage.sol\\\";\\n\\n/**\\n * @title UInitializable\\n * @notice Library to manage the initialization lifecycle of upgradeable contracts\\n * @dev `UInitializable` allows the creation of pseudo-constructors for upgradeable contracts. One\\n * `initializer` should be declared per top-level contract. Child contracts can use the `onlyInitializer`\\n * modifier to tag their internal initialization functions to ensure that they can only be called\\n * from a top-level `initializer` or a constructor.\\n */\\nabstract contract UInitializable {\\n error UInitializableZeroVersionError();\\n error UInitializableAlreadyInitializedError(uint256 version);\\n error UInitializableNotInitializingError();\\n\\n event Initialized(uint256 version);\\n\\n /// @dev The initialized flag\\n Uint256Storage private constant _version = Uint256Storage.wrap(keccak256(\\\"equilibria.root.UInitializable.version\\\"));\\n\\n /// @dev The initializing flag\\n BoolStorage private constant _initializing = BoolStorage.wrap(keccak256(\\\"equilibria.root.UInitializable.initializing\\\"));\\n\\n /// @dev Can only be called once per version, `version` is 1-indexed\\n modifier initializer(uint256 version) {\\n if (version == 0) revert UInitializableZeroVersionError();\\n if (_version.read() >= version) revert UInitializableAlreadyInitializedError(version);\\n\\n _version.store(version);\\n _initializing.store(true);\\n\\n _;\\n\\n _initializing.store(false);\\n emit Initialized(version);\\n }\\n\\n /// @dev Can only be called from an initializer or constructor\\n modifier onlyInitializer() {\\n if (!_constructing() && !_initializing.read()) revert UInitializableNotInitializingError();\\n _;\\n }\\n\\n /**\\n * @notice Returns whether the contract is currently being constructed\\n * @dev {Address.isContract} returns false for contracts currently in the process of being constructed\\n * @return Whether the contract is currently being constructed\\n */\\n function _constructing() private view returns (bool) {\\n return !Address.isContract(address(this));\\n }\\n}\\n\",\"keccak256\":\"0xd2743d8fcc220ed2ccdc0bba1db0a3e107741bd5c0cac47ca8c0b5a00ba2fd7f\",\"license\":\"Apache-2.0\"},\"@equilibria/root/control/unstructured/UReentrancyGuard.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"./UInitializable.sol\\\";\\nimport \\\"../../storage/UStorage.sol\\\";\\n\\n/**\\n * @dev Contract module that helps prevent reentrant calls to a function.\\n *\\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\\n * available, which can be applied to functions to make sure there are no nested\\n * (reentrant) calls to them.\\n *\\n * Note that because there is a single `nonReentrant` guard, functions marked as\\n * `nonReentrant` may not call one another. This can be worked around by making\\n * those functions `private`, and then adding `external` `nonReentrant` entry\\n * points to them.\\n *\\n * TIP: If you would like to learn more about reentrancy and alternative ways\\n * to protect against it, check out our blog post\\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\\n *\\n * NOTE: This contract has been extended from the Open Zeppelin library to include an\\n * unstructured storage pattern, so that it can be safely mixed in with upgradeable\\n * contracts without affecting their storage patterns through inheritance.\\n */\\nabstract contract UReentrancyGuard is UInitializable {\\n error UReentrancyGuardReentrantCallError();\\n\\n uint256 private constant _NOT_ENTERED = 1;\\n uint256 private constant _ENTERED = 2;\\n\\n /**\\n * @dev unstructured storage slot for the reentrancy status\\n */\\n Uint256Storage private constant _status = Uint256Storage.wrap(keccak256(\\\"equilibria.root.UReentrancyGuard.status\\\"));\\n\\n /**\\n * @dev Initializes the contract setting the status to _NOT_ENTERED.\\n */\\n function __UReentrancyGuard__initialize() internal onlyInitializer {\\n _status.store(_NOT_ENTERED);\\n }\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n * Calling a `nonReentrant` function from another `nonReentrant`\\n * function is not supported. It is possible to prevent this from happening\\n * by making the `nonReentrant` function external, and make it call a\\n * `private` function that does the actual work.\\n */\\n modifier nonReentrant() {\\n // On the first call to nonReentrant, _notEntered will be true\\n if (_status.read() == _ENTERED) revert UReentrancyGuardReentrantCallError();\\n\\n // Any calls to nonReentrant after this point will fail\\n _status.store(_ENTERED);\\n\\n _;\\n\\n // By storing the original value once again, a refund is triggered (see\\n // https://eips.ethereum.org/EIPS/eip-2200)\\n _status.store(_NOT_ENTERED);\\n }\\n}\\n\",\"keccak256\":\"0x4962245ca8fdda3dc40c0f942a3568d90fb69428a6927b058018b01c90eb9fc9\",\"license\":\"Apache-2.0\"},\"@equilibria/root/curve/CurveMath.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"../number/types/UFixed18.sol\\\";\\nimport \\\"../number/types/Fixed18.sol\\\";\\n\\n/**\\n * @title CurveMath\\n * @notice Library for managing math operations for utilization curves.\\n */\\nlibrary CurveMath {\\n error CurveMathOutOfBoundsError();\\n\\n /**\\n * @notice Computes a linear interpolation between two points\\n * @param startX First point's x-coordinate\\n * @param startY First point's y-coordinate\\n * @param endX Second point's x-coordinate\\n * @param endY Second point's y-coordinate\\n * @param targetX x-coordinate to interpolate\\n * @return y-coordinate for `targetX` along the line from (`startX`, `startY`) -> (`endX`, `endY`)\\n */\\n function linearInterpolation(\\n UFixed18 startX,\\n Fixed18 startY,\\n UFixed18 endX,\\n Fixed18 endY,\\n UFixed18 targetX\\n ) internal pure returns (Fixed18) {\\n if (targetX.lt(startX) || targetX.gt(endX)) revert CurveMathOutOfBoundsError();\\n\\n UFixed18 xRange = endX.sub(startX);\\n Fixed18 yRange = endY.sub(startY);\\n UFixed18 xRatio = targetX.sub(startX).div(xRange);\\n return yRange.mul(Fixed18Lib.from(xRatio)).add(startY);\\n }\\n}\\n\",\"keccak256\":\"0x60d159f9ddf0dbe81124ecad58bba734b4cf82877637ff8d9d7f3e92f2da4ded\",\"license\":\"Apache-2.0\"},\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"../CurveMath.sol\\\";\\nimport \\\"../../number/types/PackedUFixed18.sol\\\";\\nimport \\\"../../number/types/PackedFixed18.sol\\\";\\n\\n/// @dev JumpRateUtilizationCurve type\\nstruct JumpRateUtilizationCurve {\\n PackedFixed18 minRate;\\n PackedFixed18 maxRate;\\n PackedFixed18 targetRate;\\n PackedUFixed18 targetUtilization;\\n}\\nusing JumpRateUtilizationCurveLib for JumpRateUtilizationCurve global;\\ntype JumpRateUtilizationCurveStorage is bytes32;\\nusing JumpRateUtilizationCurveStorageLib for JumpRateUtilizationCurveStorage global;\\n\\n/**\\n * @title JumpRateUtilizationCurveLib\\n * @notice Library for the Jump Rate utilization curve type\\n */\\nlibrary JumpRateUtilizationCurveLib {\\n /**\\n * @notice Computes the corresponding rate for a utilization ratio\\n * @param utilization The utilization ratio\\n * @return The corresponding rate\\n */\\n function compute(JumpRateUtilizationCurve memory self, UFixed18 utilization) internal pure returns (Fixed18) {\\n UFixed18 targetUtilization = self.targetUtilization.unpack();\\n if (utilization.lt(targetUtilization)) {\\n return CurveMath.linearInterpolation(\\n UFixed18Lib.ZERO,\\n self.minRate.unpack(),\\n targetUtilization,\\n self.targetRate.unpack(),\\n utilization\\n );\\n }\\n if (utilization.lt(UFixed18Lib.ONE)) {\\n return CurveMath.linearInterpolation(\\n targetUtilization,\\n self.targetRate.unpack(),\\n UFixed18Lib.ONE,\\n self.maxRate.unpack(),\\n utilization\\n );\\n }\\n return self.maxRate.unpack();\\n }\\n}\\n\\nlibrary JumpRateUtilizationCurveStorageLib {\\n function read(JumpRateUtilizationCurveStorage self) internal view returns (JumpRateUtilizationCurve memory) {\\n return _storagePointer(self);\\n }\\n\\n function store(JumpRateUtilizationCurveStorage self, JumpRateUtilizationCurve memory value) internal {\\n JumpRateUtilizationCurve storage storagePointer = _storagePointer(self);\\n\\n storagePointer.minRate = value.minRate;\\n storagePointer.maxRate = value.maxRate;\\n storagePointer.targetRate = value.targetRate;\\n storagePointer.targetUtilization = value.targetUtilization;\\n }\\n\\n function _storagePointer(JumpRateUtilizationCurveStorage self)\\n private pure returns (JumpRateUtilizationCurve storage pointer) {\\n assembly { pointer.slot := self }\\n }\\n}\",\"keccak256\":\"0xae202813874bc306d51b3dab8194c86f6483bb20bf1f673ddaee16aa8de567ff\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/Fixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SignedMath.sol\\\";\\nimport \\\"./UFixed18.sol\\\";\\nimport \\\"./PackedFixed18.sol\\\";\\n\\n/// @dev Fixed18 type\\ntype Fixed18 is int256;\\nusing Fixed18Lib for Fixed18 global;\\ntype Fixed18Storage is bytes32;\\nusing Fixed18StorageLib for Fixed18Storage global;\\n\\n/**\\n * @title Fixed18Lib\\n * @notice Library for the signed fixed-decimal type.\\n */\\nlibrary Fixed18Lib {\\n error Fixed18OverflowError(uint256 value);\\n error Fixed18PackingOverflowError(int256 value);\\n error Fixed18PackingUnderflowError(int256 value);\\n\\n int256 private constant BASE = 1e18;\\n Fixed18 public constant ZERO = Fixed18.wrap(0);\\n Fixed18 public constant ONE = Fixed18.wrap(BASE);\\n Fixed18 public constant NEG_ONE = Fixed18.wrap(-1 * BASE);\\n Fixed18 public constant MAX = Fixed18.wrap(type(int256).max);\\n Fixed18 public constant MIN = Fixed18.wrap(type(int256).min);\\n\\n /**\\n * @notice Creates a signed fixed-decimal from an unsigned fixed-decimal\\n * @param a Unsigned fixed-decimal\\n * @return New signed fixed-decimal\\n */\\n function from(UFixed18 a) internal pure returns (Fixed18) {\\n uint256 value = UFixed18.unwrap(a);\\n if (value > uint256(type(int256).max)) revert Fixed18OverflowError(value);\\n return Fixed18.wrap(int256(value));\\n }\\n\\n /**\\n * @notice Creates a signed fixed-decimal from a sign and an unsigned fixed-decimal\\n * @param s Sign\\n * @param m Unsigned fixed-decimal magnitude\\n * @return New signed fixed-decimal\\n */\\n function from(int256 s, UFixed18 m) internal pure returns (Fixed18) {\\n if (s > 0) return from(m);\\n if (s < 0) return Fixed18.wrap(-1 * Fixed18.unwrap(from(m)));\\n return ZERO;\\n }\\n\\n /**\\n * @notice Creates a signed fixed-decimal from a signed integer\\n * @param a Signed number\\n * @return New signed fixed-decimal\\n */\\n function from(int256 a) internal pure returns (Fixed18) {\\n return Fixed18.wrap(a * BASE);\\n }\\n\\n /**\\n * @notice Creates a packed signed fixed-decimal from an signed fixed-decimal\\n * @param a signed fixed-decimal\\n * @return New packed signed fixed-decimal\\n */\\n function pack(Fixed18 a) internal pure returns (PackedFixed18) {\\n int256 value = Fixed18.unwrap(a);\\n if (value > type(int128).max) revert Fixed18PackingOverflowError(value);\\n if (value < type(int128).min) revert Fixed18PackingUnderflowError(value);\\n return PackedFixed18.wrap(int128(value));\\n }\\n\\n /**\\n * @notice Returns whether the signed fixed-decimal is equal to zero.\\n * @param a Signed fixed-decimal\\n * @return Whether the signed fixed-decimal is zero.\\n */\\n function isZero(Fixed18 a) internal pure returns (bool) {\\n return Fixed18.unwrap(a) == 0;\\n }\\n\\n /**\\n * @notice Adds two signed fixed-decimals `a` and `b` together\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Resulting summed signed fixed-decimal\\n */\\n function add(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) + Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Subtracts signed fixed-decimal `b` from `a`\\n * @param a Signed fixed-decimal to subtract from\\n * @param b Signed fixed-decimal to subtract\\n * @return Resulting subtracted signed fixed-decimal\\n */\\n function sub(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) - Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Multiplies two signed fixed-decimals `a` and `b` together\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Resulting multiplied signed fixed-decimal\\n */\\n function mul(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / BASE);\\n }\\n\\n /**\\n * @notice Divides signed fixed-decimal `a` by `b`\\n * @param a Signed fixed-decimal to divide\\n * @param b Signed fixed-decimal to divide by\\n * @return Resulting divided signed fixed-decimal\\n */\\n function div(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * BASE / Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0`, `MAX` for `n/0`, and `MIN` for `-n/0`.\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function unsafeDiv(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n if (isZero(b)) {\\n if (gt(a, ZERO)) return MAX;\\n if (lt(a, ZERO)) return MIN;\\n return ONE;\\n } else {\\n return div(a, b);\\n }\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First signed fixed-decimal\\n * @param b Signed number to multiply by\\n * @param c Signed number to divide by\\n * @return Resulting computation\\n */\\n function muldiv(Fixed18 a, int256 b, int256 c) internal pure returns (Fixed18) {\\n return muldiv(a, Fixed18.wrap(b), Fixed18.wrap(c));\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First signed fixed-decimal\\n * @param b Signed fixed-decimal to multiply by\\n * @param c Signed fixed-decimal to divide by\\n * @return Resulting computation\\n */\\n function muldiv(Fixed18 a, Fixed18 b, Fixed18 c) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / Fixed18.unwrap(c));\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is equal to `b`\\n */\\n function eq(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 1;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is greater than `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is greater than `b`\\n */\\n function gt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 2;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is less than `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is less than `b`\\n */\\n function lt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 0;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is greater than or equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is greater than or equal to `b`\\n */\\n function gte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return gt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is less than or equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is less than or equal to `b`\\n */\\n function lte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return lt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Compares the signed fixed-decimals `a` and `b`\\n * @dev Returns: 2 for greater than\\n * 1 for equal to\\n * 0 for less than\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Compare result of `a` and `b`\\n */\\n function compare(Fixed18 a, Fixed18 b) internal pure returns (uint256) {\\n (int256 au, int256 bu) = (Fixed18.unwrap(a), Fixed18.unwrap(b));\\n if (au > bu) return 2;\\n if (au < bu) return 0;\\n return 1;\\n }\\n\\n /**\\n * @notice Returns a signed fixed-decimal representing the ratio of `a` over `b`\\n * @param a First signed number\\n * @param b Second signed number\\n * @return Ratio of `a` over `b`\\n */\\n function ratio(int256 a, int256 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(a * BASE / b);\\n }\\n\\n /**\\n * @notice Returns the minimum of signed fixed-decimals `a` and `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Minimum of `a` and `b`\\n */\\n function min(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(SignedMath.min(Fixed18.unwrap(a), Fixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Returns the maximum of signed fixed-decimals `a` and `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Maximum of `a` and `b`\\n */\\n function max(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(SignedMath.max(Fixed18.unwrap(a), Fixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Converts the signed fixed-decimal into an integer, truncating any decimal portion\\n * @param a Signed fixed-decimal\\n * @return Truncated signed number\\n */\\n function truncate(Fixed18 a) internal pure returns (int256) {\\n return Fixed18.unwrap(a) / BASE;\\n }\\n\\n /**\\n * @notice Returns the sign of the signed fixed-decimal\\n * @dev Returns: -1 for negative\\n * 0 for zero\\n * 1 for positive\\n * @param a Signed fixed-decimal\\n * @return Sign of the signed fixed-decimal\\n */\\n function sign(Fixed18 a) internal pure returns (int256) {\\n if (Fixed18.unwrap(a) > 0) return 1;\\n if (Fixed18.unwrap(a) < 0) return -1;\\n return 0;\\n }\\n\\n /**\\n * @notice Returns the absolute value of the signed fixed-decimal\\n * @param a Signed fixed-decimal\\n * @return Absolute value of the signed fixed-decimal\\n */\\n function abs(Fixed18 a) internal pure returns (UFixed18) {\\n return UFixed18.wrap(SignedMath.abs(Fixed18.unwrap(a)));\\n }\\n}\\n\\nlibrary Fixed18StorageLib {\\n function read(Fixed18Storage self) internal view returns (Fixed18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(Fixed18Storage self, Fixed18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x613587461ef3437ef33229cdda7d34ea746278721baf06e20b2e43977f43174d\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/PackedFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"./Fixed18.sol\\\";\\n\\n/// @dev PackedFixed18 type\\ntype PackedFixed18 is int128;\\nusing PackedFixed18Lib for PackedFixed18 global;\\n\\n/**\\n * @title PackedFixed18Lib\\n * @dev A packed version of the Fixed18 which takes up half the storage space (two PackedFixed18 can be packed\\n * into a single slot). Only valid within the range -1.7014118e+20 <= x <= 1.7014118e+20.\\n * @notice Library for the packed signed fixed-decimal type.\\n */\\nlibrary PackedFixed18Lib {\\n PackedFixed18 public constant MAX = PackedFixed18.wrap(type(int128).max);\\n PackedFixed18 public constant MIN = PackedFixed18.wrap(type(int128).min);\\n\\n /**\\n * @notice Creates an unpacked signed fixed-decimal from a packed signed fixed-decimal\\n * @param self packed signed fixed-decimal\\n * @return New unpacked signed fixed-decimal\\n */\\n function unpack(PackedFixed18 self) internal pure returns (Fixed18) {\\n return Fixed18.wrap(int256(PackedFixed18.unwrap(self)));\\n }\\n}\\n\",\"keccak256\":\"0xb52960cc8e3132e45d342bbbb1c6a96219022cd8557997933bd8250170268b64\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/PackedUFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"./UFixed18.sol\\\";\\n\\n/// @dev PackedUFixed18 type\\ntype PackedUFixed18 is uint128;\\nusing PackedUFixed18Lib for PackedUFixed18 global;\\n\\n/**\\n * @title PackedUFixed18Lib\\n * @dev A packed version of the UFixed18 which takes up half the storage space (two PackedUFixed18 can be packed\\n * into a single slot). Only valid within the range 0 <= x <= 3.4028237e+20.\\n * @notice Library for the packed unsigned fixed-decimal type.\\n */\\nlibrary PackedUFixed18Lib {\\n PackedUFixed18 public constant MAX = PackedUFixed18.wrap(type(uint128).max);\\n\\n /**\\n * @notice Creates an unpacked unsigned fixed-decimal from a packed unsigned fixed-decimal\\n * @param self packed unsigned fixed-decimal\\n * @return New unpacked unsigned fixed-decimal\\n */\\n function unpack(PackedUFixed18 self) internal pure returns (UFixed18) {\\n return UFixed18.wrap(uint256(PackedUFixed18.unwrap(self)));\\n }\\n}\\n\",\"keccak256\":\"0xb5c5cd32d6530b2fe75228b6be32ebcb7762f6d7988b85a6b85a289ce8256d51\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/UFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"./Fixed18.sol\\\";\\nimport \\\"./PackedUFixed18.sol\\\";\\n\\n/// @dev UFixed18 type\\ntype UFixed18 is uint256;\\nusing UFixed18Lib for UFixed18 global;\\ntype UFixed18Storage is bytes32;\\nusing UFixed18StorageLib for UFixed18Storage global;\\n\\n/**\\n * @title UFixed18Lib\\n * @notice Library for the unsigned fixed-decimal type.\\n */\\nlibrary UFixed18Lib {\\n error UFixed18UnderflowError(int256 value);\\n error UFixed18PackingOverflowError(uint256 value);\\n\\n uint256 private constant BASE = 1e18;\\n UFixed18 public constant ZERO = UFixed18.wrap(0);\\n UFixed18 public constant ONE = UFixed18.wrap(BASE);\\n UFixed18 public constant MAX = UFixed18.wrap(type(uint256).max);\\n\\n /**\\n * @notice Creates a unsigned fixed-decimal from a signed fixed-decimal\\n * @param a Signed fixed-decimal\\n * @return New unsigned fixed-decimal\\n */\\n function from(Fixed18 a) internal pure returns (UFixed18) {\\n int256 value = Fixed18.unwrap(a);\\n if (value < 0) revert UFixed18UnderflowError(value);\\n return UFixed18.wrap(uint256(value));\\n }\\n\\n /**\\n * @notice Creates a unsigned fixed-decimal from a unsigned integer\\n * @param a Unsigned number\\n * @return New unsigned fixed-decimal\\n */\\n function from(uint256 a) internal pure returns (UFixed18) {\\n return UFixed18.wrap(a * BASE);\\n }\\n\\n /**\\n * @notice Creates a packed unsigned fixed-decimal from an unsigned fixed-decimal\\n * @param a unsigned fixed-decimal\\n * @return New packed unsigned fixed-decimal\\n */\\n function pack(UFixed18 a) internal pure returns (PackedUFixed18) {\\n uint256 value = UFixed18.unwrap(a);\\n if (value > type(uint128).max) revert UFixed18PackingOverflowError(value);\\n return PackedUFixed18.wrap(uint128(value));\\n }\\n\\n /**\\n * @notice Returns whether the unsigned fixed-decimal is equal to zero.\\n * @param a Unsigned fixed-decimal\\n * @return Whether the unsigned fixed-decimal is zero.\\n */\\n function isZero(UFixed18 a) internal pure returns (bool) {\\n return UFixed18.unwrap(a) == 0;\\n }\\n\\n /**\\n * @notice Adds two unsigned fixed-decimals `a` and `b` together\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Resulting summed unsigned fixed-decimal\\n */\\n function add(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) + UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Subtracts unsigned fixed-decimal `b` from `a`\\n * @param a Unsigned fixed-decimal to subtract from\\n * @param b Unsigned fixed-decimal to subtract\\n * @return Resulting subtracted unsigned fixed-decimal\\n */\\n function sub(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) - UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Multiplies two unsigned fixed-decimals `a` and `b` together\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Resulting multiplied unsigned fixed-decimal\\n */\\n function mul(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / BASE);\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function div(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * BASE / UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0` and `MAX` for `n/0`.\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function unsafeDiv(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n if (isZero(b)) {\\n return isZero(a) ? ONE : MAX;\\n } else {\\n return div(a, b);\\n }\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First unsigned fixed-decimal\\n * @param b Unsigned number to multiply by\\n * @param c Unsigned number to divide by\\n * @return Resulting computation\\n */\\n function muldiv(UFixed18 a, uint256 b, uint256 c) internal pure returns (UFixed18) {\\n return muldiv(a, UFixed18.wrap(b), UFixed18.wrap(c));\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First unsigned fixed-decimal\\n * @param b Unsigned fixed-decimal to multiply by\\n * @param c Unsigned fixed-decimal to divide by\\n * @return Resulting computation\\n */\\n function muldiv(UFixed18 a, UFixed18 b, UFixed18 c) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / UFixed18.unwrap(c));\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is equal to `b`\\n */\\n function eq(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 1;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is greater than `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is greater than `b`\\n */\\n function gt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 2;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is less than `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is less than `b`\\n */\\n function lt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 0;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is greater than or equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is greater than or equal to `b`\\n */\\n function gte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return gt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is less than or equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is less than or equal to `b`\\n */\\n function lte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return lt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Compares the unsigned fixed-decimals `a` and `b`\\n * @dev Returns: 2 for greater than\\n * 1 for equal to\\n * 0 for less than\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Compare result of `a` and `b`\\n */\\n function compare(UFixed18 a, UFixed18 b) internal pure returns (uint256) {\\n (uint256 au, uint256 bu) = (UFixed18.unwrap(a), UFixed18.unwrap(b));\\n if (au > bu) return 2;\\n if (au < bu) return 0;\\n return 1;\\n }\\n\\n /**\\n * @notice Returns a unsigned fixed-decimal representing the ratio of `a` over `b`\\n * @param a First unsigned number\\n * @param b Second unsigned number\\n * @return Ratio of `a` over `b`\\n */\\n function ratio(uint256 a, uint256 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(a * BASE / b);\\n }\\n\\n /**\\n * @notice Returns the minimum of unsigned fixed-decimals `a` and `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Minimum of `a` and `b`\\n */\\n function min(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(Math.min(UFixed18.unwrap(a), UFixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Returns the maximum of unsigned fixed-decimals `a` and `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Maximum of `a` and `b`\\n */\\n function max(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(Math.max(UFixed18.unwrap(a), UFixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Converts the unsigned fixed-decimal into an integer, truncating any decimal portion\\n * @param a Unsigned fixed-decimal\\n * @return Truncated unsigned number\\n */\\n function truncate(UFixed18 a) internal pure returns (uint256) {\\n return UFixed18.unwrap(a) / BASE;\\n }\\n}\\n\\nlibrary UFixed18StorageLib {\\n function read(UFixed18Storage self) internal view returns (UFixed18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(UFixed18Storage self, UFixed18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x8ebef1e6c717f565b9ed545a876b5692b4007e6485c99f39d363f7405e591792\",\"license\":\"Apache-2.0\"},\"@equilibria/root/storage/UStorage.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"../number/types/UFixed18.sol\\\";\\n\\n/// @dev Stored boolean slot\\ntype BoolStorage is bytes32;\\nusing BoolStorageLib for BoolStorage global;\\n\\n/// @dev Stored uint256 slot\\ntype Uint256Storage is bytes32;\\nusing Uint256StorageLib for Uint256Storage global;\\n\\n/// @dev Stored int256 slot\\ntype Int256Storage is bytes32;\\nusing Int256StorageLib for Int256Storage global;\\n\\n/// @dev Stored address slot\\ntype AddressStorage is bytes32;\\nusing AddressStorageLib for AddressStorage global;\\n\\n/// @dev Stored bytes32 slot\\ntype Bytes32Storage is bytes32;\\nusing Bytes32StorageLib for Bytes32Storage global;\\n\\n/**\\n * @title BoolStorageLib\\n * @notice Library to manage storage and retrival of a boolean at a fixed storage slot\\n */\\nlibrary BoolStorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored bool value\\n */\\n function read(BoolStorage self) internal view returns (bool value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value boolean value to store\\n */\\n function store(BoolStorage self, bool value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\\n/**\\n * @title Uint256StorageLib\\n * @notice Library to manage storage and retrival of an uint256 at a fixed storage slot\\n */\\nlibrary Uint256StorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored uint256 value\\n */\\n function read(Uint256Storage self) internal view returns (uint256 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value uint256 value to store\\n */\\n function store(Uint256Storage self, uint256 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\\n/**\\n * @title Int256StorageLib\\n * @notice Library to manage storage and retrival of an int256 at a fixed storage slot\\n */\\nlibrary Int256StorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored int256 value\\n */\\n function read(Int256Storage self) internal view returns (int256 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value int256 value to store\\n */\\n function store(Int256Storage self, int256 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\\n/**\\n * @title AddressStorageLib\\n * @notice Library to manage storage and retrival of an address at a fixed storage slot\\n */\\nlibrary AddressStorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored address value\\n */\\n function read(AddressStorage self) internal view returns (address value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value address value to store\\n */\\n function store(AddressStorage self, address value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\\n/**\\n * @title Bytes32StorageLib\\n * @notice Library to manage storage and retrival of a bytes32 at a fixed storage slot\\n */\\nlibrary Bytes32StorageLib {\\n /**\\n * @notice Retrieves the stored value\\n * @param self Storage slot\\n * @return value Stored bytes32 value\\n */\\n function read(Bytes32Storage self) internal view returns (bytes32 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n /**\\n * @notice Stores the value at the specific slot\\n * @param self Storage slot\\n * @param value bytes32 value to store\\n */\\n function store(Bytes32Storage self, bytes32 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0xe2b8491d1b5aa93f7e059e1a8f156b0ab37fef9ed973be97a64f2eabfc2cc172\",\"license\":\"Apache-2.0\"},\"@equilibria/root/token/types/Token18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"../../number/types/UFixed18.sol\\\";\\n\\n/// @dev Token18\\ntype Token18 is address;\\nusing Token18Lib for Token18 global;\\ntype Token18Storage is bytes32;\\nusing Token18StorageLib for Token18Storage global;\\n\\n/**\\n * @title Token18Lib\\n * @notice Library to manage 18-decimal ERC20s that is compliant with the fixed-decimal types.\\n * @dev Maintains significant gas savings over other Token implementations since no conversion take place\\n */\\nlibrary Token18Lib {\\n using SafeERC20 for IERC20;\\n\\n Token18 public constant ZERO = Token18.wrap(address(0));\\n\\n /**\\n * @notice Returns whether a token is the zero address\\n * @param self Token to check for\\n * @return Whether the token is the zero address\\n */\\n function isZero(Token18 self) internal pure returns (bool) {\\n return Token18.unwrap(self) == Token18.unwrap(ZERO);\\n }\\n\\n /**\\n * @notice Returns whether the two tokens are equal\\n * @param a First token to compare\\n * @param b Second token to compare\\n * @return Whether the two tokens are equal\\n */\\n function eq(Token18 a, Token18 b) internal pure returns (bool) {\\n return Token18.unwrap(a) == Token18.unwrap(b);\\n }\\n\\n /**\\n * @notice Approves `grantee` to spend infinite tokens from the caller\\n * @param self Token to transfer\\n * @param grantee Address to allow spending\\n */\\n function approve(Token18 self, address grantee) internal {\\n IERC20(Token18.unwrap(self)).safeApprove(grantee, type(uint256).max);\\n }\\n\\n /**\\n * @notice Approves `grantee` to spend `amount` tokens from the caller\\n * @dev There are important race conditions to be aware of when using this function\\n with values other than 0. This will revert if moving from non-zero to non-zero amounts\\n See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/a55b7d13722e7ce850b626da2313f3e66ca1d101/contracts/token/ERC20/IERC20.sol#L57\\n * @param self Token to transfer\\n * @param grantee Address to allow spending\\n * @param amount Amount of tokens to approve to spend\\n */\\n function approve(Token18 self, address grantee, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeApprove(grantee, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers all held tokens from the caller to the `recipient`\\n * @param self Token to transfer\\n * @param recipient Address to receive the tokens\\n */\\n function push(Token18 self, address recipient) internal {\\n push(self, recipient, balanceOf(self, address(this)));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the caller to the `recipient`\\n * @param self Token to transfer\\n * @param recipient Address to transfer tokens to\\n * @param amount Amount of tokens to transfer\\n */\\n function push(Token18 self, address recipient, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransfer(recipient, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the `benefactor` to the caller\\n * @dev Reverts if trying to pull Ether\\n * @param self Token to transfer\\n * @param benefactor Address to transfer tokens from\\n * @param amount Amount of tokens to transfer\\n */\\n function pull(Token18 self, address benefactor, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, address(this), UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the `benefactor` to `recipient`\\n * @dev Reverts if trying to pull Ether\\n * @param self Token to transfer\\n * @param benefactor Address to transfer tokens from\\n * @param recipient Address to transfer tokens to\\n * @param amount Amount of tokens to transfer\\n */\\n function pullTo(Token18 self, address benefactor, address recipient, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, recipient, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Returns the name of the token\\n * @param self Token to check for\\n * @return Token name\\n */\\n function name(Token18 self) internal view returns (string memory) {\\n return IERC20Metadata(Token18.unwrap(self)).name();\\n }\\n\\n /**\\n * @notice Returns the symbol of the token\\n * @param self Token to check for\\n * @return Token symbol\\n */\\n function symbol(Token18 self) internal view returns (string memory) {\\n return IERC20Metadata(Token18.unwrap(self)).symbol();\\n }\\n\\n /**\\n * @notice Returns the `self` token balance of the caller\\n * @param self Token to check for\\n * @return Token balance of the caller\\n */\\n function balanceOf(Token18 self) internal view returns (UFixed18) {\\n return balanceOf(self, address(this));\\n }\\n\\n /**\\n * @notice Returns the `self` token balance of `account`\\n * @param self Token to check for\\n * @param account Account to check\\n * @return Token balance of the account\\n */\\n function balanceOf(Token18 self, address account) internal view returns (UFixed18) {\\n return UFixed18.wrap(IERC20(Token18.unwrap(self)).balanceOf(account));\\n }\\n}\\n\\nlibrary Token18StorageLib {\\n function read(Token18Storage self) internal view returns (Token18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(Token18Storage self, Token18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x6b12afaece814f0ab186200a4729e93eb685a21d3e9b5a3372ff283a7ad5dc23\",\"license\":\"Apache-2.0\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\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 amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` 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(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\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\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 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 using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\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 function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc3d946432c0ddbb1f846a0d3985be71299df331b91d06732152117f62f0be2b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // 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\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return 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 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 up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a / b + (a % b == 0 ? 0 : 1);\\n }\\n}\\n\",\"keccak256\":\"0xc995bddbca1ae19788db9f8b61e63385edd3fddf89693b612d5abd1a275974d2\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SignedMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/SignedMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard signed math utilities missing in the Solidity language.\\n */\\nlibrary SignedMath {\\n /**\\n * @dev Returns the largest of two signed numbers.\\n */\\n function max(int256 a, int256 b) internal pure returns (int256) {\\n return 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 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 // must be unchecked in order to support `n = type(int256).min`\\n return uint256(n >= 0 ? n : -n);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb3ebde1c8d27576db912d87c3560dab14adfb9cd001be95890ec4ba035e652e7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/structs/EnumerableSet.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping(bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) {\\n // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n if (lastIndex != toDeleteIndex) {\\n bytes32 lastValue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastValue;\\n // Update the index for the moved value\\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n return _values(set._inner);\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0xacac2065b3ed1facff1163435890d4a6bcdc474e857e8e2c91ae5fb50418f723\",\"license\":\"MIT\"},\"contracts/controller/UControllerProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"@equilibria/root/control/unstructured/UInitializable.sol\\\";\\nimport \\\"@equilibria/root/storage/UStorage.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/Address.sol\\\";\\nimport \\\"../interfaces/IController.sol\\\";\\nimport \\\"../interfaces/IProduct.sol\\\";\\n\\n/**\\n * @title UControllerProvider\\n * @notice Mix-in that manages a controller pointer and associated permissioning modifiers.\\n * @dev Uses unstructured storage so that it is safe to mix-in to upgreadable contracts without modifying\\n * their storage layout.\\n */\\nabstract contract UControllerProvider is UInitializable {\\n error NotOwnerError(uint256 coordinatorId);\\n error NotProductError(IProduct product);\\n error NotCollateralError();\\n error PausedError();\\n error InvalidControllerError();\\n\\n /// @dev The controller contract address\\n AddressStorage private constant _controller = AddressStorage.wrap(keccak256(\\\"equilibria.perennial.UControllerProvider.controller\\\"));\\n function controller() public view returns (IController) { return IController(_controller.read()); }\\n\\n /**\\n * @notice Initializes the contract state\\n * @param controller_ Protocol Controller contract address\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function __UControllerProvider__initialize(IController controller_) internal onlyInitializer {\\n if (!Address.isContract(address(controller_))) revert InvalidControllerError();\\n _controller.store(address(controller_));\\n }\\n\\n /// @dev Only allow a valid product contract to call\\n modifier onlyProduct {\\n if (!controller().isProduct(IProduct(msg.sender))) revert NotProductError(IProduct(msg.sender));\\n\\n _;\\n }\\n\\n /// @dev Verify that `product` is a valid product contract\\n modifier isProduct(IProduct product) {\\n if (!controller().isProduct(product)) revert NotProductError(product);\\n\\n _;\\n }\\n\\n /// @dev Only allow the Collateral contract to call\\n modifier onlyCollateral {\\n if (msg.sender != address(controller().collateral())) revert NotCollateralError();\\n\\n _;\\n }\\n\\n /// @dev Only allow the coordinator owner to call\\n modifier onlyOwner(uint256 coordinatorId) {\\n if (msg.sender != controller().owner(coordinatorId)) revert NotOwnerError(coordinatorId);\\n\\n _;\\n }\\n\\n /// @dev Only allow if the protocol is currently unpaused\\n modifier notPaused() {\\n if (controller().paused()) revert PausedError();\\n\\n _;\\n }\\n}\\n\",\"keccak256\":\"0x10c6f4ae1a3a511aad470e40c61de5b2171f4151e2dea000acd2ffbd26dcbc2a\",\"license\":\"Apache-2.0\"},\"contracts/incentivizer/Incentivizer.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"@equilibria/root/control/unstructured/UInitializable.sol\\\";\\nimport \\\"@equilibria/root/control/unstructured/UReentrancyGuard.sol\\\";\\nimport \\\"../interfaces/IIncentivizer.sol\\\";\\nimport \\\"../interfaces/IController.sol\\\";\\nimport \\\"../controller/UControllerProvider.sol\\\";\\nimport \\\"./types/ProductManager.sol\\\";\\n\\n/**\\n * @title Incentivizer\\n * @notice Manages logic and state for all incentive programs in the protocol.\\n */\\ncontract Incentivizer is IIncentivizer, UInitializable, UControllerProvider, UReentrancyGuard {\\n /// @dev Product management state\\n mapping(IProduct => ProductManager) private _products;\\n\\n /// @dev Fees that have been collected, but remain unclaimed\\n mapping(Token18 => UFixed18) public fees;\\n\\n /**\\n * @notice Initializes the contract state\\n * @dev Must be called atomically as part of the upgradeable proxy deployment to\\n * avoid front-running\\n * @param controller_ Factory contract address\\n */\\n function initialize(IController controller_) external initializer(1) {\\n __UControllerProvider__initialize(controller_);\\n __UReentrancyGuard__initialize();\\n }\\n\\n /**\\n * @notice Creates a new incentive program\\n * @dev Must be called as the product or protocol owner\\n * @param product The product to create the new program on\\n * @param programInfo Parameters for the new program\\n * @return programId New program's ID\\n */\\n function create(IProduct product, ProgramInfo calldata programInfo)\\n external\\n nonReentrant\\n isProduct(product)\\n notPaused\\n onlyOwner(programInfo.coordinatorId)\\n returns (uint256 programId) {\\n IController _controller = controller();\\n\\n // Validate\\n if (programInfo.coordinatorId != 0 && programInfo.coordinatorId != _controller.coordinatorFor(product))\\n revert IncentivizerNotAllowedError(product);\\n if (active(product) >= _controller.programsPerProduct())\\n revert IncentivizerTooManyProgramsError();\\n ProgramInfoLib.validate(programInfo);\\n\\n // Take fee\\n (ProgramInfo memory newProgramInfo, UFixed18 programFeeAmount) = ProgramInfoLib.deductFee(programInfo, _controller.incentivizationFee());\\n fees[newProgramInfo.token] = fees[newProgramInfo.token].add(programFeeAmount);\\n\\n // Register program\\n programId = _products[product].register(newProgramInfo);\\n\\n // Charge creator\\n newProgramInfo.token.pull(msg.sender, programInfo.amount.sum());\\n\\n emit ProgramCreated(\\n product,\\n programId,\\n newProgramInfo,\\n programFeeAmount\\n );\\n }\\n\\n /**\\n * @notice Completes an in-progress program early\\n * @dev Must be called as the program owner\\n * @param product Product that the program is running on\\n * @param programId Program to complete early\\n */\\n function complete(IProduct product, uint256 programId)\\n external\\n nonReentrant\\n isProgram(product, programId)\\n notPaused\\n onlyProgramOwner(product, programId)\\n {\\n ProductManagerLib.SyncResult memory syncResult = _products[product].complete(product, programId);\\n _handleSyncResult(product, syncResult);\\n }\\n\\n /**\\n * @notice Starts and completes programs as they become available\\n * @dev Called every settle() from each product\\n * @param currentOracleVersion The preloaded current oracle version\\n */\\n function sync(IOracleProvider.OracleVersion memory currentOracleVersion) external onlyProduct {\\n IProduct product = IProduct(msg.sender);\\n\\n ProductManagerLib.SyncResult[] memory syncResults = _products[product].sync(product, currentOracleVersion);\\n for (uint256 i = 0; i < syncResults.length; i++) {\\n _handleSyncResult(product, syncResults[i]);\\n }\\n }\\n\\n /**\\n * @notice Handles refunding and event emitting on program start and completion\\n * @param product Product that the program is running on\\n * @param syncResult The data from the sync event to handle\\n */\\n function _handleSyncResult(IProduct product, ProductManagerLib.SyncResult memory syncResult) private {\\n uint256 programId = syncResult.programId;\\n if (!syncResult.refundAmount.isZero())\\n _products[product].token(programId).push(treasury(product, programId), syncResult.refundAmount);\\n if (syncResult.versionStarted != 0)\\n emit ProgramStarted(product, programId, syncResult.versionStarted);\\n if (syncResult.versionComplete != 0)\\n emit ProgramComplete(product, programId, syncResult.versionComplete);\\n }\\n\\n /**\\n * @notice Settles unsettled balance for `account`\\n * @dev Called immediately proceeding a position update in the corresponding product\\n * @param account Account to sync\\n * @param currentOracleVersion The preloaded current oracle version\\n */\\n function syncAccount(\\n address account,\\n IOracleProvider.OracleVersion memory currentOracleVersion\\n ) external onlyProduct {\\n IProduct product = IProduct(msg.sender);\\n _products[product].syncAccount(product, account, currentOracleVersion);\\n }\\n\\n /**\\n * @notice Claims all of `msg.sender`'s rewards for `product` programs\\n * @param product Product to claim rewards for\\n * @param programIds Programs to claim rewards for\\n */\\n function claim(IProduct product, uint256[] calldata programIds)\\n external\\n nonReentrant\\n {\\n _claimProduct(product, programIds);\\n }\\n\\n /**\\n * @notice Claims all of `msg.sender`'s rewards for a specific program\\n * @param products Products to claim rewards for\\n * @param programIds Programs to claim rewards for\\n */\\n function claim(IProduct[] calldata products, uint256[][] calldata programIds)\\n external\\n nonReentrant\\n {\\n if (products.length != programIds.length) revert IncentivizerBatchClaimArgumentMismatchError();\\n for (uint256 i; i < products.length; i++) {\\n _claimProduct(products[i], programIds[i]);\\n }\\n }\\n\\n /**\\n * @notice Claims all of `msg.sender`'s rewards for `product` programs\\n * @dev Internal helper with validation checks\\n * @param product Product to claim rewards for\\n * @param programIds Programs to claim rewards for\\n */\\n function _claimProduct(IProduct product, uint256[] memory programIds)\\n private\\n isProduct(product)\\n notPaused\\n settleForAccount(msg.sender, product)\\n {\\n for (uint256 i; i < programIds.length; i++) {\\n _claimProgram(product, programIds[i]);\\n }\\n }\\n\\n /**\\n * @notice Claims all of `msg.sender`'s rewards for `programId` on `product`\\n * @dev Internal helper with validation checks\\n * @param product Product to claim rewards for\\n * @param programId Program to claim rewards for\\n */\\n function _claimProgram(IProduct product, uint256 programId)\\n private\\n isProgram(product, programId)\\n {\\n ProductManager storage productManager = _products[product];\\n UFixed18 claimAmount = productManager.claim(msg.sender, programId);\\n productManager.token(programId).push(msg.sender, claimAmount);\\n emit Claim(product, msg.sender, programId, claimAmount);\\n }\\n\\n /**\\n * @notice Claims all `tokens` fees to the protocol treasury\\n * @param tokens Tokens to claim fees for\\n */\\n function claimFee(Token18[] calldata tokens) external notPaused {\\n for(uint256 i; i < tokens.length; i++) {\\n Token18 token = tokens[i];\\n UFixed18 amount = fees[token];\\n\\n fees[token] = UFixed18Lib.ZERO;\\n token.push(controller().treasury(), amount);\\n\\n emit FeeClaim(token, amount);\\n }\\n }\\n\\n /**\\n * @notice Returns the quantity of active programs for a given product\\n * @param product Product to check for\\n * @return Number of active programs\\n */\\n function active(IProduct product) public view returns (uint256) {\\n return _products[product].active();\\n }\\n\\n /**\\n * @notice Returns the quantity of programs for a given product\\n * @param product Product to check for\\n * @return Number of programs (inactive or active)\\n */\\n function count(IProduct product) external view returns (uint256) {\\n return _products[product].programInfos.length;\\n }\\n\\n /**\\n * @notice Returns program info for program `programId`\\n * @param product Product to return for\\n * @param programId Program to return for\\n * @return Program info\\n */\\n function programInfos(IProduct product, uint256 programId) external view returns (ProgramInfo memory) {\\n return _products[product].programInfos[programId];\\n }\\n\\n /**\\n * @notice Returns `account`'s total unclaimed rewards for a specific program\\n * @param product Product to return for\\n * @param account Account to return for\\n * @param programId Program to return for\\n * @return `account`'s total unclaimed rewards for `programId`\\n */\\n function unclaimed(IProduct product, address account, uint256 programId) external view returns (UFixed18) {\\n return _products[product].unclaimed(account, programId);\\n }\\n\\n /**\\n * @notice Returns available rewards for a specific program\\n * @param product Product to return for\\n * @param programId Program to return for\\n * @return Available rewards for `programId`\\n */\\n function available(IProduct product, uint256 programId) external view returns (UFixed18) {\\n return _products[product].programs[programId].available;\\n }\\n\\n /**\\n * @notice Returns the version started for a specific program\\n * @param product Product to return for\\n * @param programId Program to return for\\n * @return The version started for `programId`\\n */\\n function versionStarted(IProduct product, uint256 programId) external view returns (uint256) {\\n return _products[product].programs[programId].versionStarted;\\n }\\n\\n /**\\n * @notice Returns the version completed for a specific program\\n * @param product Product to return for\\n * @param programId Program to return for\\n * @return The version completed for `programId`\\n */\\n function versionComplete(IProduct product, uint256 programId) external view returns (uint256) {\\n return _products[product].programs[programId].versionComplete;\\n }\\n\\n /**\\n * @notice Returns the owner of a specific program\\n * @param product Product to return for\\n * @param programId Program to return for\\n * @return The owner of `programId`\\n */\\n function owner(IProduct product, uint256 programId) public view returns (address) {\\n return controller().owner(_products[product].programInfos[programId].coordinatorId);\\n }\\n\\n /**\\n * @notice Returns the treasury of a specific program\\n * @param product Product to return for\\n * @param programId Program to return for\\n * @return The treasury of `programId`\\n */\\n function treasury(IProduct product, uint256 programId) public view returns (address) {\\n return controller().treasury(_products[product].programInfos[programId].coordinatorId);\\n }\\n\\n /// @dev Helper to fully settle an account's state\\n modifier settleForAccount(address account, IProduct product) {\\n product.settleAccount(account);\\n\\n _;\\n }\\n\\n /// @dev Only allow the owner of `programId` to call\\n modifier onlyProgramOwner(IProduct product, uint256 programId) {\\n if (msg.sender != owner(product, programId)) revert IncentivizerNotProgramOwnerError(product, programId);\\n\\n _;\\n }\\n\\n /// @dev Only allow a valid `programId`\\n modifier isProgram(IProduct product, uint256 programId) {\\n if (!_products[product].valid(programId)) revert IncentivizerInvalidProgramError(product, programId);\\n\\n _;\\n }\\n}\\n\",\"keccak256\":\"0x7b22c1099ba0a72ca4ef8d87cfc2fbb66cf0c28e43faa59a6af71369d8a06aa9\",\"license\":\"Apache-2.0\"},\"contracts/incentivizer/types/ProductManager.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\nimport \\\"./Program.sol\\\";\\n\\n/// @dev ProductManager type\\nstruct ProductManager {\\n /// @dev Static program state\\n ProgramInfo[] programInfos;\\n\\n /// @dev Dynamic program state\\n mapping(uint256 => Program) programs;\\n\\n /// @dev Mapping of all active programs for each product\\n EnumerableSet.UintSet activePrograms;\\n\\n /// @dev Mapping of all active programs for each user\\n mapping(address => EnumerableSet.UintSet) activeProgramsFor;\\n\\n /// @dev Mapping of the next program to watch for for each user\\n mapping(address => uint256) nextProgramFor;\\n}\\nusing ProductManagerLib for ProductManager global;\\n\\n/**\\n * @title ProductManagerLib\\n * @notice Library that manages each product's incentivization state and logic.\\n */\\nlibrary ProductManagerLib {\\n using EnumerableSet for EnumerableSet.UintSet;\\n\\n /// @dev Result data for a sync event\\n struct SyncResult {\\n /// @dev The programId that was updated\\n uint256 programId;\\n\\n /// @dev If non-zero, the new versionStart value of the program\\n uint256 versionStarted;\\n\\n /// @dev If non-zero, the new versionComplete value of the program\\n uint256 versionComplete;\\n\\n /// @dev If non-zero, the amount to refund due to completion\\n UFixed18 refundAmount;\\n }\\n\\n /**\\n * @notice Registers a new program on this product\\n * @param self The Product manager to operate on\\n * @param programInfo The static program info\\n * @return programId The new program's ID\\n */\\n function register(\\n ProductManager storage self,\\n ProgramInfo memory programInfo\\n ) internal returns (uint256 programId) {\\n programId = self.programInfos.length;\\n self.programInfos.push(programInfo);\\n self.programs[programId].initialize(programInfo);\\n self.activePrograms.add(programId);\\n }\\n\\n /**\\n * @notice Syncs this product with the latest data\\n * @param self The Program manager to operate on\\n * @param product This Product\\n * @param currentOracleVersion The preloaded current oracle version\\n */\\n function sync(\\n ProductManager storage self,\\n IProduct product,\\n IOracleProvider.OracleVersion memory currentOracleVersion\\n ) internal returns (SyncResult[] memory results) {\\n\\n uint256[] memory activeProgramIds = self.activePrograms.values();\\n results = new SyncResult[](activeProgramIds.length);\\n\\n for (uint256 i; i < activeProgramIds.length; i++) {\\n // Load program\\n uint256 programId = activeProgramIds[i];\\n ProgramInfo memory programInfo = self.programInfos[programId];\\n Program storage program = self.programs[programId];\\n\\n // If timestamp-started, grab current version (first version after start)\\n uint256 versionStarted;\\n if (program.versionStarted == 0 && programInfo.isStarted(currentOracleVersion.timestamp)) {\\n versionStarted = _start(self, programId, currentOracleVersion);\\n }\\n\\n // If timestamp-completed, grab previous version (last version before completion)\\n uint256 versionComplete;\\n UFixed18 refundAmount;\\n if (program.versionComplete == 0 && programInfo.isComplete(currentOracleVersion.timestamp)) {\\n (versionComplete, refundAmount) = _complete(self, product, programId);\\n }\\n\\n // Save result\\n results[i] = SyncResult(programId, versionStarted, versionComplete, refundAmount);\\n }\\n }\\n\\n /**\\n * @notice Syncs an account for this product with the latest data\\n * @dev Assumes that sync() has already been called as part of the transaction flow\\n * @param self The Program manager to operate on\\n * @param product This Product\\n * @param account The account to sync\\n * @param currentOracleVersion The preloaded current oracle version\\n */\\n function syncAccount(\\n ProductManager storage self,\\n IProduct product,\\n address account,\\n IOracleProvider.OracleVersion memory currentOracleVersion\\n ) internal {\\n\\n // Add any unseen programs\\n uint256 fromProgramId = self.nextProgramFor[account];\\n uint256 toProgramId = self.programInfos.length;\\n for (uint256 programId = fromProgramId; programId < toProgramId; programId++) {\\n self.activeProgramsFor[account].add(programId);\\n }\\n self.nextProgramFor[account] = toProgramId;\\n\\n // Settle programs\\n uint256[] memory activeProgramIds = self.activeProgramsFor[account].values();\\n for (uint256 i; i < activeProgramIds.length; i++) {\\n uint256 programId = activeProgramIds[i];\\n Program storage program = self.programs[programId];\\n program.settle(product, self.programInfos[programId], account, currentOracleVersion);\\n if (!self.activePrograms.contains(programId) && currentOracleVersion.version >= program.versionComplete) {\\n self.activeProgramsFor[account].remove(programId);\\n }\\n }\\n }\\n\\n /**\\n * @notice Returns the quantity of active programs for this product\\n * @param self The Program manager to operate on\\n * @return The quantity of active programs\\n */\\n function active(ProductManager storage self) internal view returns (uint256) {\\n return self.activePrograms.length();\\n }\\n\\n /**\\n * @notice Forces the specified program to complete if it hasn't already\\n * @param self The Program manager to operate on\\n * @param product The Product to operate on\\n * @param programId The Program to complete\\n * @return result The sync result data from completion\\n */\\n function complete(\\n ProductManager storage self,\\n IProduct product,\\n uint256 programId\\n ) internal returns (SyncResult memory result) {\\n Program storage program = self.programs[programId];\\n\\n // If not started, start first\\n if (program.versionStarted == 0) {\\n result.versionStarted = _start(self, programId, product.currentVersion());\\n }\\n\\n // If not completed already, complete\\n if (program.versionComplete == 0) {\\n (result.versionComplete, result.refundAmount) = _complete(self, product, programId);\\n }\\n }\\n\\n /**\\n * @notice Starts the program\\n * @dev Rewards do not start accruing until the program has started\\n * Internal helper, does not prevent incorrectly-timed starting\\n * @param self The Program manager to operate on\\n * @param programId The Program to start\\n * @param currentOracleVersion The effective starting oracle version\\n * @return versionStarted The version that the program started\\n */\\n function _start(\\n ProductManager storage self,\\n uint256 programId,\\n IOracleProvider.OracleVersion memory currentOracleVersion\\n ) internal returns (uint256 versionStarted) {\\n versionStarted = currentOracleVersion.version;\\n self.programs[programId].start(currentOracleVersion.version);\\n }\\n\\n /**\\n * @notice Completes the program\\n * @dev Completion stops rewards from accruing\\n * Internal helper, does not prevent incorrectly-timed completion\\n * @param self The Program manager to operate on\\n * @param product The Product to operate on\\n * @param programId The Program to complete\\n * @return versionComplete The version that the program complete\\n * @return refundAmount The refunded token amount\\n */\\n function _complete(\\n ProductManager storage self,\\n IProduct product,\\n uint256 programId\\n ) internal returns (uint256 versionComplete, UFixed18 refundAmount) {\\n (versionComplete, refundAmount) = self.programs[programId].complete(product, self.programInfos[programId]);\\n self.activePrograms.remove(programId);\\n }\\n\\n /**\\n * @notice Claims all of `account`'s rewards for a specific program\\n * @param self The Program manager to operate on\\n * @param account Account to claim rewards for\\n * @param programId Program to claim rewards for\\n * @return Amount claimed\\n */\\n function claim(ProductManager storage self, address account, uint256 programId) internal returns (UFixed18) {\\n return self.programs[programId].claim(account);\\n }\\n\\n /**\\n * @notice Returns the total amount of unclaimed rewards for account `account`\\n * @param self The Program manager to operate on\\n * @param account The account to check for\\n * @param programId The Program to check for\\n * @return Total amount of unclaimed rewards for account\\n */\\n function unclaimed(ProductManager storage self, address account, uint256 programId) internal view returns (UFixed18) {\\n if (!valid(self, programId)) return (UFixed18Lib.ZERO);\\n return self.programs[programId].settled[account];\\n }\\n\\n /**\\n * @notice Returns the token denominatino of the program's rewards\\n * @param self The Program manager to operate on\\n * @param programId The Program to check for\\n * @return The token for the program\\n */\\n function token(ProductManager storage self, uint256 programId) internal view returns (Token18) {\\n return self.programInfos[programId].token;\\n }\\n\\n /**\\n * @notice Returns whether the supplied programId is valid\\n * @param self The Program manager to operate on\\n * @param programId The Program to check for\\n * @return Whether the supplied programId is valid\\n */\\n function valid(ProductManager storage self, uint256 programId) internal view returns (bool) {\\n return programId < self.programInfos.length;\\n }\\n}\\n\",\"keccak256\":\"0x7db9fa9c04ec523c44d0aab52c8cd779a2b752e77bf16e0d90e4e0c159e24275\",\"license\":\"Apache-2.0\"},\"contracts/incentivizer/types/Program.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"../../interfaces/types/ProgramInfo.sol\\\";\\n\\n/// @dev Program type\\nstruct Program {\\n /// @dev Mapping of latest rewards settled for each account\\n mapping(address => UFixed18) settled;\\n\\n /// @dev Total amount of rewards yet to be claimed\\n UFixed18 available;\\n\\n /// @dev Oracle version that the program started, 0 when hasn't started\\n uint256 versionStarted;\\n\\n /// @dev Oracle version that the program completed, 0 is still ongoing\\n uint256 versionComplete;\\n}\\nusing ProgramLib for Program global;\\n\\n/**\\n * @title ProgramLib\\n * @notice Library that manages all of the mutable state for a single incentivization program.\\n */\\nlibrary ProgramLib {\\n /**\\n * @notice Initializes the program state\\n * @param self The Program to operate on\\n * @param programInfo Static program information\\n */\\n function initialize(Program storage self, ProgramInfo memory programInfo) internal {\\n self.available = programInfo.amount.sum();\\n }\\n\\n /**\\n * @notice Starts the program\\n * @dev Rewards do not start accruing until the program has started accruing\\n * Does not stop double-starting\\n * @param self The Program to operate on\\n * @param oracleVersion The effective starting oracle version\\n */\\n function start(Program storage self, uint256 oracleVersion) internal {\\n self.versionStarted = oracleVersion;\\n }\\n\\n /**\\n * @notice Completes the program\\n * @dev Completion stops rewards from accruing\\n * Does not prevent double-completion\\n * @param self The Program to operate on\\n * @param product The Product to operate on\\n * @param programInfo Static program information\\n * @return versionComplete The version that the program completed on\\n * @return refundAmount The refund amount from the program\\n */\\n function complete(\\n Program storage self,\\n IProduct product,\\n ProgramInfo memory programInfo\\n ) internal returns (uint256 versionComplete, UFixed18 refundAmount) {\\n uint256 versionStarted = self.versionStarted;\\n versionComplete = Math.max(versionStarted, product.latestVersion());\\n self.versionComplete = versionComplete;\\n\\n IOracleProvider.OracleVersion memory fromOracleVersion = product.atVersion(versionStarted);\\n IOracleProvider.OracleVersion memory toOracleVersion = product.atVersion(versionComplete);\\n\\n uint256 inactiveDuration = programInfo.duration - (toOracleVersion.timestamp - fromOracleVersion.timestamp);\\n refundAmount = programInfo.amount.sum().muldiv(inactiveDuration, programInfo.duration);\\n self.available = self.available.sub(refundAmount);\\n }\\n\\n /**\\n * @notice Settles unclaimed rewards for account `account`\\n * @param self The Program to operate on\\n * @param product The Product to operate on\\n * @param programInfo Static program information\\n * @param account The account to settle for\\n * @param currentOracleVersion The preloaded current oracle version\\n */\\n function settle(\\n Program storage self,\\n IProduct product,\\n ProgramInfo memory programInfo,\\n address account,\\n IOracleProvider.OracleVersion memory currentOracleVersion\\n ) internal {\\n UFixed18 unsettledAmount = _unsettled(self, product, programInfo, account, currentOracleVersion);\\n self.settled[account] = self.settled[account].add(unsettledAmount);\\n self.available = self.available.sub(unsettledAmount);\\n }\\n\\n /**\\n * @notice Claims settled rewards for account `account`\\n * @param self The Program to operate on\\n * @param account The account to claim for\\n */\\n function claim(Program storage self, address account) internal returns (UFixed18 claimedAmount) {\\n claimedAmount = self.settled[account];\\n self.settled[account] = UFixed18Lib.ZERO;\\n }\\n\\n /**\\n * @notice Returns the unsettled amount of unclaimed rewards for account `account`\\n * @dev Clears when a program is closed\\n * Assumes that position is unchanged since last settlement, must be settled prior to user position update\\n * @param self The Program to operate on\\n * @param product The Product to operate on\\n * @param programInfo Static program information\\n * @param account The account to claim for\\n * @param currentOracleVersion Current oracle version\\n * @return amount Amount of unsettled rewards for account\\n */\\n function _unsettled(\\n Program storage self,\\n IProduct product,\\n ProgramInfo memory programInfo,\\n address account,\\n IOracleProvider.OracleVersion memory currentOracleVersion\\n ) private view returns (UFixed18 amount) {\\n // program stage overview\\n //\\n // V = latest user settle version, V' = current user settle version\\n // S = versionStarted, E = versionEnded\\n //\\n // (1) V V' S E program not yet started\\n // (2) V S V' E use versionStarted -> V' for userShareDelta\\n // (3) S V V' E use V -> V' for userShareDelta\\n // (4) S V E V' use V -> versionComplete for userShareDelta\\n // (5) S E V V' program already completed\\n // (6) V S E V' use versionStarted -> versionComplete for userShareDelta\\n //\\n // NOTE: V == S and V' == E both default to the inner case\\n\\n (uint256 _versionStarted, uint256 _versionComplete) = (\\n self.versionStarted == 0 ? currentOracleVersion.version : self.versionStarted, // start must be no earlier than current version\\n self.versionComplete == 0 ? type(uint256).max : self.versionComplete // we don't know when completion occurs\\n );\\n\\n // accruing must start between self.versionStarted and self.versionComplete\\n uint256 fromVersion = Math.min(_versionComplete, Math.max(_versionStarted, product.latestVersion(account)));\\n // accruing must complete between self.versionStarted and self.versionComplete, we know self.versionStarted must be no earlier than current version\\n uint256 toVersion = Math.min(_versionComplete, currentOracleVersion.version);\\n\\n Accumulator memory globalShareDelta = product.shareAtVersion(toVersion).sub(product.shareAtVersion(fromVersion));\\n Accumulator memory computedUserShareDelta = product.position(account).mul(globalShareDelta);\\n amount = UFixed18Lib.from(programInfo.amountPerShare().mul(computedUserShareDelta).sum());\\n }\\n}\\n\",\"keccak256\":\"0xbc1acfcb2160ba7e08e515ef88bced2ef4acedba57bd55b55117fc05e4747fa5\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/ICollateral.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"./IController.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\n\\ninterface ICollateral {\\n event Deposit(address indexed user, IProduct indexed product, UFixed18 amount);\\n event Withdrawal(address indexed user, IProduct indexed product, UFixed18 amount);\\n event AccountSettle(IProduct indexed product, address indexed account, Fixed18 amount, UFixed18 newShortfall);\\n event ProductSettle(IProduct indexed product, UFixed18 protocolFee, UFixed18 productFee);\\n event Liquidation(address indexed user, IProduct indexed product, address liquidator, UFixed18 fee);\\n event ShortfallResolution(IProduct indexed product, UFixed18 amount);\\n event FeeClaim(address indexed account, UFixed18 amount);\\n\\n error CollateralCantLiquidate(UFixed18 totalMaintenance, UFixed18 totalCollateral);\\n error CollateralInsufficientCollateralError();\\n error CollateralUnderLimitError();\\n error CollateralZeroAddressError();\\n\\n function token() external view returns (Token18);\\n function fees(address account) external view returns (UFixed18);\\n function initialize(IController controller_) external;\\n function depositTo(address account, IProduct product, UFixed18 amount) external;\\n function withdrawTo(address account, IProduct product, UFixed18 amount) external;\\n function liquidate(address account, IProduct product) external;\\n function settleAccount(address account, Fixed18 amount) external;\\n function settleProduct(UFixed18 amount) external;\\n function collateral(address account, IProduct product) external view returns (UFixed18);\\n function collateral(IProduct product) external view returns (UFixed18);\\n function shortfall(IProduct product) external view returns (UFixed18);\\n function liquidatable(address account, IProduct product) external view returns (bool);\\n function liquidatableNext(address account, IProduct product) external view returns (bool);\\n function resolveShortfall(IProduct product, UFixed18 amount) external;\\n function claimFee() external;\\n}\\n\",\"keccak256\":\"0xa5e7fdda92702f748e6eb8701e522450035a98a05e5fc1cf66d51c52e397d914\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IContractPayoffProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\n\\ninterface IContractPayoffProvider {\\n function payoff(Fixed18 price) external view returns (Fixed18 payoff);\\n}\\n\",\"keccak256\":\"0xd73df106d032e976fd959ee6713240e36f54277ce5f215eaec8d5a2c6720a86b\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IController.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\\\";\\nimport \\\"./ICollateral.sol\\\";\\nimport \\\"./IIncentivizer.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\n\\ninterface IController {\\n /// @dev Coordinator of a one or many products\\n struct Coordinator {\\n /// @dev Pending owner of the product, can accept ownership\\n address pendingOwner;\\n\\n /// @dev Owner of the product, allowed to update select parameters\\n address owner;\\n\\n /// @dev Treasury of the product, collects fees\\n address treasury;\\n }\\n\\n event CollateralUpdated(ICollateral newCollateral);\\n event IncentivizerUpdated(IIncentivizer newIncentivizer);\\n event ProductBeaconUpdated(IBeacon newProductBeacon);\\n event ProtocolFeeUpdated(UFixed18 newProtocolFee);\\n event MinFundingFeeUpdated(UFixed18 newMinFundingFee);\\n event LiquidationFeeUpdated(UFixed18 newLiquidationFee);\\n event IncentivizationFeeUpdated(UFixed18 newIncentivizationFee);\\n event MinCollateralUpdated(UFixed18 newMinCollateral);\\n event ProgramsPerProductUpdated(uint256 newProgramsPerProduct);\\n event PauserUpdated(address newPauser);\\n event PausedUpdated(bool newPaused);\\n event CoordinatorPendingOwnerUpdated(uint256 indexed coordinatorId, address newPendingOwner);\\n event CoordinatorOwnerUpdated(uint256 indexed coordinatorId, address newOwner);\\n event CoordinatorTreasuryUpdated(uint256 indexed coordinatorId, address newTreasury);\\n event CoordinatorCreated(uint256 indexed coordinatorId, address owner);\\n event ProductCreated(IProduct indexed product, IProduct.ProductInfo productInfo);\\n\\n error ControllerNoZeroCoordinatorError();\\n error ControllerNotPauserError();\\n error ControllerNotOwnerError(uint256 controllerId);\\n error ControllerNotPendingOwnerError(uint256 controllerId);\\n error ControllerInvalidProtocolFeeError();\\n error ControllerInvalidMinFundingFeeError();\\n error ControllerInvalidLiquidationFeeError();\\n error ControllerInvalidIncentivizationFeeError();\\n error ControllerNotContractAddressError();\\n\\n function collateral() external view returns (ICollateral);\\n function incentivizer() external view returns (IIncentivizer);\\n function productBeacon() external view returns (IBeacon);\\n function coordinators(uint256 collateralId) external view returns (Coordinator memory);\\n function coordinatorFor(IProduct product) external view returns (uint256);\\n function protocolFee() external view returns (UFixed18);\\n function minFundingFee() external view returns (UFixed18);\\n function liquidationFee() external view returns (UFixed18);\\n function incentivizationFee() external view returns (UFixed18);\\n function minCollateral() external view returns (UFixed18);\\n function programsPerProduct() external view returns (uint256);\\n function pauser() external view returns (address);\\n function paused() external view returns (bool);\\n function initialize(ICollateral collateral_, IIncentivizer incentivizer_, IBeacon productBeacon_) external;\\n function createCoordinator() external returns (uint256);\\n function updateCoordinatorPendingOwner(uint256 coordinatorId, address newPendingOwner) external;\\n function acceptCoordinatorOwner(uint256 coordinatorId) external;\\n function updateCoordinatorTreasury(uint256 coordinatorId, address newTreasury) external;\\n function createProduct(uint256 coordinatorId, IProduct.ProductInfo calldata productInfo) external returns (IProduct);\\n function updateCollateral(ICollateral newCollateral) external;\\n function updateIncentivizer(IIncentivizer newIncentivizer) external;\\n function updateProductBeacon(IBeacon newProductBeacon) external;\\n function updateProtocolFee(UFixed18 newProtocolFee) external;\\n function updateMinFundingFee(UFixed18 newMinFundingFee) external;\\n function updateLiquidationFee(UFixed18 newLiquidationFee) external;\\n function updateIncentivizationFee(UFixed18 newIncentivizationFee) external;\\n function updateMinCollateral(UFixed18 newMinCollateral) external;\\n function updateProgramsPerProduct(uint256 newProductsPerProduct) external;\\n function updatePauser(address newPauser) external;\\n function updatePaused(bool newPaused) external;\\n function isProduct(IProduct product) external view returns (bool);\\n function owner() external view returns (address);\\n function owner(uint256 coordinatorId) external view returns (address);\\n function owner(IProduct product) external view returns (address);\\n function treasury() external view returns (address);\\n function treasury(uint256 coordinatorId) external view returns (address);\\n function treasury(IProduct product) external view returns (address);\\n}\\n\",\"keccak256\":\"0xaabd3740f2265499eea7aad9bd94f9892f53241e5dccce9a50c0e43ed2a6a7cc\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IIncentivizer.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./types/ProgramInfo.sol\\\";\\nimport \\\"./IController.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\n\\ninterface IIncentivizer {\\n event ProgramCreated(IProduct indexed product, uint256 indexed programId, ProgramInfo programInfo, UFixed18 programFeeAmount);\\n event ProgramStarted(IProduct indexed product, uint256 indexed programId, uint256 version);\\n event ProgramComplete(IProduct indexed product, uint256 indexed programId, uint256 version);\\n event Claim(IProduct indexed product, address indexed account, uint256 indexed programId, UFixed18 amount);\\n event FeeClaim(Token18 indexed token, UFixed18 amount);\\n\\n error IncentivizerNotAllowedError(IProduct product);\\n error IncentivizerTooManyProgramsError();\\n error IncentivizerNotProgramOwnerError(IProduct product, uint256 programId);\\n error IncentivizerInvalidProgramError(IProduct product, uint256 programId);\\n error IncentivizerBatchClaimArgumentMismatchError();\\n\\n function programInfos(IProduct product, uint256 programId) external view returns (ProgramInfo memory);\\n function fees(Token18 token) external view returns (UFixed18);\\n function initialize(IController controller_) external;\\n function create(IProduct product, ProgramInfo calldata info) external returns (uint256);\\n function complete(IProduct product, uint256 programId) external;\\n function sync(IOracleProvider.OracleVersion memory currentOracleVersion) external;\\n function syncAccount(address account, IOracleProvider.OracleVersion memory currentOracleVersion) external;\\n function claim(IProduct product, uint256[] calldata programIds) external;\\n function claim(IProduct[] calldata products, uint256[][] calldata programIds) external;\\n function claimFee(Token18[] calldata tokens) external;\\n function active(IProduct product) external view returns (uint256);\\n function count(IProduct product) external view returns (uint256);\\n function unclaimed(IProduct product, address account, uint256 programId) external view returns (UFixed18);\\n function available(IProduct product, uint256 programId) external view returns (UFixed18);\\n function versionStarted(IProduct product, uint256 programId) external view returns (uint256);\\n function versionComplete(IProduct product, uint256 programId) external view returns (uint256);\\n function owner(IProduct product, uint256 programId) external view returns (address);\\n function treasury(IProduct product, uint256 programId) external view returns (address);\\n}\\n\",\"keccak256\":\"0x2f95de90dbb3ad35dbfef304f765a622bffff9229868d2898eca8d49c78e8c2c\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IParamProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\\\";\\n\\ninterface IParamProvider {\\n event MaintenanceUpdated(UFixed18 newMaintenance);\\n event FundingFeeUpdated(UFixed18 newFundingFee);\\n event MakerFeeUpdated(UFixed18 newMakerFee);\\n event TakerFeeUpdated(UFixed18 newTakerFee);\\n event MakerLimitUpdated(UFixed18 newMakerLimit);\\n event JumpRateUtilizationCurveUpdated(\\n Fixed18 minRate,\\n Fixed18 maxRate,\\n Fixed18 targetRate,\\n UFixed18 targetUtilization\\n );\\n\\n error ParamProviderInvalidMakerFee();\\n error ParamProviderInvalidTakerFee();\\n error ParamProviderInvalidFundingFee();\\n \\n function maintenance() external view returns (UFixed18);\\n function updateMaintenance(UFixed18 newMaintenance) external;\\n function fundingFee() external view returns (UFixed18);\\n function updateFundingFee(UFixed18 newFundingFee) external;\\n function makerFee() external view returns (UFixed18);\\n function updateMakerFee(UFixed18 newMakerFee) external;\\n function takerFee() external view returns (UFixed18);\\n function updateTakerFee(UFixed18 newTakerFee) external;\\n function makerLimit() external view returns (UFixed18);\\n function updateMakerLimit(UFixed18 newMakerLimit) external;\\n function utilizationCurve() external view returns (JumpRateUtilizationCurve memory);\\n function updateUtilizationCurve(JumpRateUtilizationCurve memory newUtilizationCurve) external;\\n}\\n\",\"keccak256\":\"0x2e2d40d0cf55f167118867e41f740b9b40614d05da50fc9bc33a8cede3eaf03e\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IPayoffProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\n\\ninterface IPayoffProvider {\\n error PayoffProviderInvalidOracle();\\n error PayoffProviderInvalidPayoffDefinitionError();\\n\\n function oracle() external view returns (IOracleProvider);\\n function payoffDefinition() external view returns (PayoffDefinition memory);\\n function currentVersion() external view returns (IOracleProvider.OracleVersion memory);\\n function atVersion(uint256 oracleVersion) external view returns (IOracleProvider.OracleVersion memory);\\n}\\n\",\"keccak256\":\"0xb83d80d624aa9431763f80ecb4bf0214803e25334a7419d954f929e5d0ee7467\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IProduct.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\\\";\\nimport \\\"./IPayoffProvider.sol\\\";\\nimport \\\"./IParamProvider.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\nimport \\\"./types/Position.sol\\\";\\nimport \\\"./types/PrePosition.sol\\\";\\nimport \\\"./types/Accumulator.sol\\\";\\n\\ninterface IProduct is IPayoffProvider, IParamProvider {\\n /// @dev Product Creation parameters\\n struct ProductInfo {\\n /// @dev name of the product\\n string name;\\n\\n /// @dev symbol of the product\\n string symbol;\\n\\n /// @dev product payoff definition\\n PayoffDefinition payoffDefinition;\\n\\n /// @dev oracle address\\n IOracleProvider oracle;\\n\\n /// @dev product maintenance ratio\\n UFixed18 maintenance;\\n\\n /// @dev product funding fee\\n UFixed18 fundingFee;\\n\\n /// @dev product maker fee\\n UFixed18 makerFee;\\n\\n /// @dev product taker fee\\n UFixed18 takerFee;\\n\\n /// @dev product maker limit\\n UFixed18 makerLimit;\\n\\n /// @dev utulization curve definition\\n JumpRateUtilizationCurve utilizationCurve;\\n }\\n\\n event Settle(uint256 preVersion, uint256 toVersion);\\n event AccountSettle(address indexed account, uint256 preVersion, uint256 toVersion);\\n event MakeOpened(address indexed account, uint256 version, UFixed18 amount);\\n event TakeOpened(address indexed account, uint256 version, UFixed18 amount);\\n event MakeClosed(address indexed account, uint256 version, UFixed18 amount);\\n event TakeClosed(address indexed account, uint256 version, UFixed18 amount);\\n event ClosedUpdated(bool indexed newClosed, uint256 version);\\n\\n error ProductInsufficientLiquidityError(UFixed18 socializationFactor);\\n error ProductDoubleSidedError();\\n error ProductOverClosedError();\\n error ProductInsufficientCollateralError();\\n error ProductInLiquidationError();\\n error ProductMakerOverLimitError();\\n error ProductOracleBootstrappingError();\\n error ProductNotOwnerError();\\n error ProductInvalidOracle();\\n error ProductClosedError();\\n\\n function name() external view returns (string memory);\\n function symbol() external view returns (string memory);\\n function initialize(ProductInfo calldata productInfo_) external;\\n function settle() external;\\n function settleAccount(address account) external;\\n function openTake(UFixed18 amount) external;\\n function closeTake(UFixed18 amount) external;\\n function openMake(UFixed18 amount) external;\\n function closeMake(UFixed18 amount) external;\\n function closeAll(address account) external;\\n function maintenance(address account) external view returns (UFixed18);\\n function maintenanceNext(address account) external view returns (UFixed18);\\n function isClosed(address account) external view returns (bool);\\n function isLiquidating(address account) external view returns (bool);\\n function position(address account) external view returns (Position memory);\\n function pre(address account) external view returns (PrePosition memory);\\n function latestVersion() external view returns (uint256);\\n function positionAtVersion(uint256 oracleVersion) external view returns (Position memory);\\n function pre() external view returns (PrePosition memory);\\n function valueAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\\n function shareAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\\n function latestVersion(address account) external view returns (uint256);\\n function rate(Position memory position) external view returns (Fixed18);\\n function closed() external view returns (bool);\\n function updateClosed(bool newClosed) external;\\n}\\n\",\"keccak256\":\"0xe1e80b818eadf4cdb070362e40c7cf3863b50c4f944816af27848e319f587241\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/Accumulator.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"./PackedAccumulator.sol\\\";\\n\\n/// @dev Accumulator type\\nstruct Accumulator {\\n /// @dev maker accumulator per share\\n Fixed18 maker;\\n /// @dev taker accumulator per share\\n Fixed18 taker;\\n}\\nusing AccumulatorLib for Accumulator global;\\n\\n/**\\n * @title AccountAccumulatorLib\\n * @notice Library that surfaces math operations for the Accumulator type.\\n * @dev Accumulators track the cumulative change in position value over time for the maker and taker positions\\n * respectively. Account-level accumulators can then use two of these values `a` and `a'` to compute the\\n * change in position value since last sync. This change in value is then used to compute P&L and fees.\\n */\\nlibrary AccumulatorLib {\\n /**\\n * @notice Creates a packed accumulator from an accumulator\\n * @param self an accumulator\\n * @return New packed accumulator\\n */\\n function pack(Accumulator memory self) internal pure returns (PackedAccumulator memory) {\\n return PackedAccumulator({maker: self.maker.pack(), taker: self.taker.pack()});\\n }\\n\\n /**\\n * @notice Adds two accumulators together\\n * @param a The first accumulator to sum\\n * @param b The second accumulator to sum\\n * @return The resulting summed accumulator\\n */\\n function add(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\\n }\\n\\n /**\\n * @notice Subtracts accumulator `b` from `a`\\n * @param a The accumulator to subtract from\\n * @param b The accumulator to subtract\\n * @return The resulting subtracted accumulator\\n */\\n function sub(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\\n }\\n\\n /**\\n * @notice Multiplies two accumulators together\\n * @param a The first accumulator to multiply\\n * @param b The second accumulator to multiply\\n * @return The resulting multiplied accumulator\\n */\\n function mul(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.mul(b.maker), taker: a.taker.mul(b.taker)});\\n }\\n\\n /**\\n * @notice Sums the maker and taker together from a single accumulator\\n * @param self The struct to operate on\\n * @return The sum of its maker and taker\\n */\\n function sum(Accumulator memory self) internal pure returns (Fixed18) {\\n return self.maker.add(self.taker);\\n }\\n}\\n\",\"keccak256\":\"0x7ccd0a72aa593cefb9f4337cf312799f357b82fcb3f0379de0dc503d1cb7e387\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PackedAccumulator.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/PackedFixed18.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\n\\n/// @dev PackedAccumulator type\\nstruct PackedAccumulator {\\n /// @dev maker accumulator per share\\n PackedFixed18 maker;\\n /// @dev taker accumulator per share\\n PackedFixed18 taker;\\n}\\nusing PackedAccumulatorLib for PackedAccumulator global;\\n\\n/**\\n * @title PackedAccumulatorLib\\n * @dev A packed version of the Accumulator which takes up a single storage slot using `PackedFixed18` values.\\n * @notice Library for the packed Accumulator type.\\n */\\nlibrary PackedAccumulatorLib {\\n /**\\n * @notice Creates an accumulator from a packed accumulator\\n * @param self packed accumulator\\n * @return New accumulator\\n */\\n function unpack(PackedAccumulator memory self) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: self.maker.unpack(), taker: self.taker.unpack()});\\n }\\n}\\n\",\"keccak256\":\"0xd83f2822d4f6c818087a232b54007730992c34ff77377fc307a282f886e7cf65\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PackedPosition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/PackedUFixed18.sol\\\";\\nimport \\\"./Position.sol\\\";\\n\\n/// @dev PackedPosition type\\nstruct PackedPosition {\\n /// @dev Quantity of the maker position\\n PackedUFixed18 maker;\\n /// @dev Quantity of the taker position\\n PackedUFixed18 taker;\\n}\\nusing PackedPositionLib for PackedPosition global;\\n\\n/**\\n * @title PackedPositionLib\\n * @dev A packed version of the Position which takes up a single storage slot using `PackedFixed18` values.\\n * @notice Library for the packed Position type.\\n */\\nlibrary PackedPositionLib {\\n /**\\n * @notice Creates an position from a packed position\\n * @param self packed position\\n * @return New position\\n */\\n function unpack(PackedPosition memory self) internal pure returns (Position memory) {\\n return Position({maker: self.maker.unpack(), taker: self.taker.unpack()});\\n }\\n}\\n\",\"keccak256\":\"0x04968e6794f6244cb3415cea111d640273a81faea957872988d0cb580f45df1e\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PayoffDefinition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"@openzeppelin/contracts/utils/Address.sol\\\";\\nimport \\\"../../interfaces/IContractPayoffProvider.sol\\\";\\n\\n/// @dev PayoffDefinition tyoe\\nstruct PayoffDefinition {\\n PayoffDefinitionLib.PayoffType payoffType;\\n PayoffDefinitionLib.PayoffDirection payoffDirection;\\n bytes30 data;\\n}\\nusing PayoffDefinitionLib for PayoffDefinition global;\\ntype PayoffDefinitionStorage is bytes32;\\nusing PayoffDefinitionStorageLib for PayoffDefinitionStorage global;\\n\\n/**\\n * @title PayoffDefinitionLib\\n * @dev Library that surfaces logic for PayoffDefinition type functionality\\n * @notice Library for the PayoffDefinition type. Performs validity and price transformation\\n based on the payoff definition type.\\n */\\nlibrary PayoffDefinitionLib {\\n using Address for address;\\n\\n error PayoffDefinitionUnsupportedTransform(PayoffType payoffType, PayoffDirection payoffDirection);\\n error PayoffDefinitionNotContract(PayoffType payoffType, bytes30 data);\\n\\n /// @dev Payoff function type enum\\n enum PayoffType { PASSTHROUGH, CONTRACT }\\n enum PayoffDirection { LONG, SHORT }\\n\\n /**\\n * @notice Checks validity of the payoff definition\\n * @param self a payoff definition\\n * @return Whether the payoff definition is valid for it's given type\\n */\\n function valid(PayoffDefinition memory self) internal view returns (bool) {\\n if (self.payoffType == PayoffType.CONTRACT) return address(_providerContract(self)).isContract();\\n\\n // All other payoff types should have no data\\n return uint(bytes32(self.data)) == 0;\\n }\\n\\n /**\\n * @notice Transforms a price based on the payoff definition\\n * @param self a payoff definition\\n * @param price raw oracle price\\n * @return Price transformed by the payoff definition function\\n */\\n function transform(\\n PayoffDefinition memory self,\\n Fixed18 price\\n ) internal view returns (Fixed18) {\\n PayoffType payoffType = self.payoffType;\\n PayoffDirection payoffDirection = self.payoffDirection;\\n Fixed18 transformedPrice;\\n\\n // First get the price depending on the type\\n if (payoffType == PayoffType.PASSTHROUGH) transformedPrice = price;\\n else if (payoffType == PayoffType.CONTRACT) transformedPrice = _payoffFromContract(self, price);\\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\\n\\n // Then transform it depending on the direction flag\\n if (self.payoffDirection == PayoffDirection.LONG) return transformedPrice;\\n else if (self.payoffDirection == PayoffDirection.SHORT) return transformedPrice.mul(Fixed18Lib.NEG_ONE);\\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\\n }\\n\\n /**\\n * @notice Parses the data field into an address\\n * @dev Reverts if payoffType is not CONTRACT\\n * @param self a payoff definition\\n * @return IContractPayoffProvider address\\n */\\n function _providerContract(\\n PayoffDefinition memory self\\n ) private pure returns (IContractPayoffProvider) {\\n if (self.payoffType != PayoffType.CONTRACT) revert PayoffDefinitionNotContract(self.payoffType, self.data);\\n // Shift to pull the last 20 bytes, then cast to an address\\n return IContractPayoffProvider(address(bytes20(self.data << 80)));\\n }\\n\\n /**\\n * @notice Performs a price transformation by calling the underlying payoff contract\\n * @param self a payoff definition\\n * @param price raw oracle price\\n * @return Price transformed by the payoff definition function on the contract\\n */\\n function _payoffFromContract(\\n PayoffDefinition memory self,\\n Fixed18 price\\n ) private view returns (Fixed18) {\\n bytes memory ret = address(_providerContract(self)).functionStaticCall(\\n abi.encodeCall(IContractPayoffProvider.payoff, price)\\n );\\n return Fixed18.wrap(abi.decode(ret, (int256)));\\n }\\n}\\n\\n/**\\n * @title PayoffDefinitionStorageLib\\n * @notice Library that surfaces storage read and writes for the PayoffDefinition type\\n */\\nlibrary PayoffDefinitionStorageLib {\\n function read(PayoffDefinitionStorage self) internal view returns (PayoffDefinition memory) {\\n return _storagePointer(self);\\n }\\n\\n function store(PayoffDefinitionStorage self, PayoffDefinition memory value) internal {\\n PayoffDefinition storage storagePointer = _storagePointer(self);\\n\\n storagePointer.payoffType = value.payoffType;\\n storagePointer.payoffDirection = value.payoffDirection;\\n storagePointer.data = value.data;\\n }\\n\\n function _storagePointer(\\n PayoffDefinitionStorage self\\n ) private pure returns (PayoffDefinition storage pointer) {\\n assembly { pointer.slot := self }\\n }\\n}\\n\",\"keccak256\":\"0x4d3897f408f77381c5ae9990391465c8fd511ddf6ff3b39f6cb69d8c2bd554df\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/Position.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\nimport \\\"./PrePosition.sol\\\";\\nimport \\\"./PackedPosition.sol\\\";\\n\\n/// @dev Position type\\nstruct Position {\\n /// @dev Quantity of the maker position\\n UFixed18 maker;\\n /// @dev Quantity of the taker position\\n UFixed18 taker;\\n}\\nusing PositionLib for Position global;\\n\\n/**\\n * @title PositionLib\\n * @notice Library that surfaces math and settlement computations for the Position type.\\n * @dev Positions track the current quantity of the account's maker and taker positions respectively\\n * denominated as a unit of the product's payoff function.\\n */\\nlibrary PositionLib {\\n /**\\n * @notice Creates a packed position from an position\\n * @param self A position\\n * @return New packed position\\n */\\n function pack(Position memory self) internal pure returns (PackedPosition memory) {\\n return PackedPosition({maker: self.maker.pack(), taker: self.taker.pack()});\\n }\\n\\n /**\\n * @notice Returns whether the position is fully empty\\n * @param self A position\\n * @return Whether the position is empty\\n */\\n function isEmpty(Position memory self) internal pure returns (bool) {\\n return self.maker.isZero() && self.taker.isZero();\\n }\\n\\n /**\\n * @notice Adds position `a` and `b` together, returning the result\\n * @param a The first position to sum\\n * @param b The second position to sum\\n * @return Resulting summed position\\n */\\n function add(Position memory a, Position memory b) internal pure returns (Position memory) {\\n return Position({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\\n }\\n\\n /**\\n * @notice Subtracts position `b` from `a`, returning the result\\n * @param a The position to subtract from\\n * @param b The position to subtract\\n * @return Resulting subtracted position\\n */\\n function sub(Position memory a, Position memory b) internal pure returns (Position memory) {\\n return Position({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\\n }\\n\\n /**\\n * @notice Multiplies position `self` by accumulator `accumulator` and returns the resulting accumulator\\n * @param self The Position to operate on\\n * @param accumulator The accumulator to multiply by\\n * @return Resulting multiplied accumulator\\n */\\n function mul(Position memory self, Accumulator memory accumulator) internal pure returns (Accumulator memory) {\\n return Accumulator({\\n maker: Fixed18Lib.from(self.maker).mul(accumulator.maker),\\n taker: Fixed18Lib.from(self.taker).mul(accumulator.taker)\\n });\\n }\\n\\n /**\\n * @notice Scales position `self` by fixed-decimal `scale` and returns the resulting position\\n * @param self The Position to operate on\\n * @param scale The Fixed-decimal to scale by\\n * @return Resulting scaled position\\n */\\n function mul(Position memory self, UFixed18 scale) internal pure returns (Position memory) {\\n return Position({maker: self.maker.mul(scale), taker: self.taker.mul(scale)});\\n }\\n\\n /**\\n * @notice Divides position `self` by `b` and returns the resulting accumulator\\n * @param self The Position to operate on\\n * @param b The number to divide by\\n * @return Resulting divided accumulator\\n */\\n function div(Position memory self, uint256 b) internal pure returns (Accumulator memory) {\\n return Accumulator({\\n maker: Fixed18Lib.from(self.maker).div(Fixed18Lib.from(UFixed18Lib.from(b))),\\n taker: Fixed18Lib.from(self.taker).div(Fixed18Lib.from(UFixed18Lib.from(b)))\\n });\\n }\\n\\n /**\\n * @notice Returns the maximum of `self`'s maker and taker values\\n * @param self The struct to operate on\\n * @return Resulting maximum value\\n */\\n function max(Position memory self) internal pure returns (UFixed18) {\\n return UFixed18Lib.max(self.maker, self.taker);\\n }\\n\\n /**\\n * @notice Sums the maker and taker together from a single position\\n * @param self The struct to operate on\\n * @return The sum of its maker and taker\\n */\\n function sum(Position memory self) internal pure returns (UFixed18) {\\n return self.maker.add(self.taker);\\n }\\n\\n /**\\n * @notice Computes the next position after the pending-settlement position delta is included\\n * @param self The current Position\\n * @param pre The pending-settlement position delta\\n * @return Next Position\\n */\\n function next(Position memory self, PrePosition memory pre) internal pure returns (Position memory) {\\n return sub(add(self, pre.openPosition), pre.closePosition);\\n }\\n\\n /**\\n * @notice Returns the settled position at oracle version `toOracleVersion`\\n * @dev Checks if a new position is ready to be settled based on the provided `toOracleVersion`\\n * and `pre` and returns accordingly\\n * @param self The current Position\\n * @param pre The pending-settlement position delta\\n * @param toOracleVersion The oracle version to settle to\\n * @return Settled position at oracle version\\n * @return Fee accrued from opening or closing the position\\n * @return Whether a new position was settled\\n */\\n function settled(\\n Position memory self,\\n PrePosition memory pre,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal view returns (Position memory, UFixed18, bool) {\\n return pre.canSettle(toOracleVersion) ? (next(self, pre), pre.computeFee(toOracleVersion), true) : (self, UFixed18Lib.ZERO, false);\\n }\\n\\n /**\\n * @notice Returns the socialization factor for the current position\\n * @dev Socialization account for the case where `taker` > `maker` temporarily due to a liquidation\\n * on the maker side. This dampens the taker's exposure pro-rata to ensure that the maker side\\n * is never exposed over 1 x short.\\n * @param self The Position to operate on\\n * @return Socialization factor\\n */\\n function socializationFactor(Position memory self) internal pure returns (UFixed18) {\\n return self.taker.isZero() ? UFixed18Lib.ONE : UFixed18Lib.min(UFixed18Lib.ONE, self.maker.div(self.taker));\\n }\\n}\\n\",\"keccak256\":\"0x027fe392c4f56bf012ba2ca462fcf23e69f2c3b9d283c14089771813437af991\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PrePosition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./Position.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\n\\n/// @dev PrePosition type\\nstruct PrePosition {\\n /// @dev Oracle version at which the new position delta was recorded\\n uint256 oracleVersion;\\n\\n /// @dev Size of position to open at oracle version\\n Position openPosition;\\n\\n /// @dev Size of position to close at oracle version\\n Position closePosition;\\n}\\nusing PrePositionLib for PrePosition global;\\n\\n/**\\n * @title PrePositionLib\\n * @notice Library that manages a pre-settlement position delta.\\n * @dev PrePositions track the currently awaiting-settlement deltas to a settled Position. These are\\n * Primarily necessary to introduce lag into the settlement system such that oracle lag cannot be\\n * gamed to a user's advantage. When a user opens or closes a new position, it sits as a PrePosition\\n * for one oracle version until it's settle into the Position, making it then effective. PrePositions\\n * are automatically settled at the correct oracle version even if a flywheel call doesn't happen until\\n * several version into the future by using the historical version lookups in the corresponding \\\"Versioned\\\"\\n * global state types.\\n */\\nlibrary PrePositionLib {\\n /**\\n * @notice Returns whether there is no pending-settlement position delta\\n * @dev Can be \\\"empty\\\" even with a non-zero oracleVersion if a position is opened and\\n * closed in the same version netting out to a zero position delta\\n * @param self The struct to operate on\\n * @return Whether the pending-settlement position delta is empty\\n */\\n function isEmpty(PrePosition memory self) internal pure returns (bool) {\\n return self.openPosition.isEmpty() && self.closePosition.isEmpty();\\n }\\n\\n /**\\n * @notice Increments the maker side of the open position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The position amount to open\\n */\\n function openMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.openPosition.maker = self.openPosition.maker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netMake(self);\\n }\\n\\n /**\\n * @notice Increments the maker side of the close position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The maker position amount to close\\n */\\n function closeMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.closePosition.maker = self.closePosition.maker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netMake(self);\\n }\\n\\n /**\\n * @notice Increments the taker side of the open position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The taker position amount to open\\n */\\n function openTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.openPosition.taker = self.openPosition.taker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netTake(self);\\n }\\n\\n /**\\n * @notice Increments the taker side of the close position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The taker position amount to close\\n */\\n function closeTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.closePosition.taker = self.closePosition.taker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netTake(self);\\n }\\n\\n /**\\n * @notice Nets out the open and close on the maker side of the position delta\\n * @param self The struct to operate on\\n */\\n function _netMake(PrePosition storage self) private {\\n if (self.openPosition.maker.gt(self.closePosition.maker)) {\\n self.openPosition.maker = self.openPosition.maker.sub(self.closePosition.maker);\\n self.closePosition.maker = UFixed18Lib.ZERO;\\n } else {\\n self.closePosition.maker = self.closePosition.maker.sub(self.openPosition.maker);\\n self.openPosition.maker = UFixed18Lib.ZERO;\\n }\\n }\\n\\n /**\\n * @notice Nets out the open and close on the taker side of the position delta\\n * @param self The struct to operate on\\n */\\n function _netTake(PrePosition storage self) private {\\n if (self.openPosition.taker.gt(self.closePosition.taker)) {\\n self.openPosition.taker = self.openPosition.taker.sub(self.closePosition.taker);\\n self.closePosition.taker = UFixed18Lib.ZERO;\\n } else {\\n self.closePosition.taker = self.closePosition.taker.sub(self.openPosition.taker);\\n self.openPosition.taker = UFixed18Lib.ZERO;\\n }\\n }\\n\\n /**\\n * @notice Returns whether the the pending position delta can be settled at version `toOracleVersion`\\n * @dev Pending-settlement positions deltas can be settled (1) oracle version after they are recorded\\n * @param self The struct to operate on\\n * @param toOracleVersion The potential oracle version to settle\\n * @return Whether the position delta can be settled\\n */\\n function canSettle(\\n PrePosition memory self,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal pure returns (bool) {\\n return !isEmpty(self) && toOracleVersion.version > self.oracleVersion;\\n }\\n\\n /**\\n * @notice Computes the fee incurred for opening or closing the pending-settlement position\\n * @dev Must be called from a valid product to get the proper fee amounts\\n * @param self The struct to operate on\\n * @param toOracleVersion The oracle version at which settlement takes place\\n * @return positionFee The maker / taker fee incurred\\n */\\n function computeFee(\\n PrePosition memory self,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal view returns (UFixed18) {\\n Position memory positionDelta = self.openPosition.add(self.closePosition);\\n\\n (UFixed18 makerNotional, UFixed18 takerNotional) = (\\n Fixed18Lib.from(positionDelta.maker).mul(toOracleVersion.price).abs(),\\n Fixed18Lib.from(positionDelta.taker).mul(toOracleVersion.price).abs()\\n );\\n\\n IProduct product = IProduct(address(this));\\n return makerNotional.mul(product.makerFee()).add(takerNotional.mul(product.takerFee()));\\n }\\n\\n /**\\n * @notice Computes the next oracle version to settle\\n * @dev - If there is no pending-settlement position delta, returns the current oracle version\\n * - Otherwise returns the oracle version at which the pending-settlement position delta can be first settled\\n *\\n * Corresponds to point (b) in the Position settlement flow\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @return Next oracle version to settle\\n */\\n function settleVersion(PrePosition storage self, uint256 currentVersion) internal view returns (uint256) {\\n uint256 _oracleVersion = self.oracleVersion;\\n return _oracleVersion == 0 ? currentVersion : _oracleVersion + 1;\\n }\\n}\\n\",\"keccak256\":\"0xa6f83f7b5f8139ec874235c406debd086a152977493c08b7f280df6f1737fb96\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/ProgramInfo.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\nimport \\\"./Position.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\n\\n/// @dev ProgramInfo type\\nstruct ProgramInfo {\\n /// @dev Coordinator for this program\\n uint256 coordinatorId;\\n\\n /// @dev Amount of total maker and taker rewards\\n Position amount;\\n\\n /// @dev start timestamp of the program\\n uint256 start;\\n\\n /// @dev duration of the program (in seconds)\\n uint256 duration;\\n\\n /**\\n * @dev Reward ERC20 token contract\\n * @notice Perennial does not support non-standard ERC20s as reward tokens for incentive programs, including,\\n but not limited to: fee on transfer and rebase tokens. Using such a non-standard token will likely\\n result in loss of funds.\\n */\\n Token18 token;\\n}\\nusing ProgramInfoLib for ProgramInfo global;\\n\\n/**\\n * @title ProgramInfoLib\\n * @notice Library that snapshots the static information for a single program.\\n * @dev This information does not change during the operation of a program.\\n */\\nlibrary ProgramInfoLib {\\n uint256 private constant MIN_DURATION = 1 days;\\n uint256 private constant MAX_DURATION = 2 * 365 days;\\n\\n error ProgramInvalidStartError();\\n error ProgramInvalidDurationError();\\n\\n /**\\n * @notice Validates and creates a new Program\\n * @dev Reverts for invalid programInfos\\n * @param programInfo Un-sanitized static program information\\n */\\n function validate(ProgramInfo memory programInfo) internal view {\\n if (isStarted(programInfo, block.timestamp)) revert ProgramInvalidStartError();\\n if (programInfo.duration < MIN_DURATION || programInfo.duration > MAX_DURATION) revert ProgramInvalidDurationError();\\n }\\n\\n /**\\n * @notice Computes a new program info with the fee taken out of the amount\\n * @param programInfo Original program info\\n * @param incentivizationFee The incentivization fee\\n * @return New program info\\n * @return Fee amount\\n */\\n function deductFee(ProgramInfo memory programInfo, UFixed18 incentivizationFee)\\n internal pure returns (ProgramInfo memory, UFixed18) {\\n Position memory newProgramAmount = programInfo.amount.mul(UFixed18Lib.ONE.sub(incentivizationFee));\\n UFixed18 programFeeAmount = programInfo.amount.sub(newProgramAmount).sum();\\n programInfo.amount = newProgramAmount;\\n return (programInfo, programFeeAmount);\\n }\\n\\n /**\\n * @notice Returns the maker and taker amounts per position share\\n * @param self The ProgramInfo to operate on\\n * @return programFee Amounts per share\\n */\\n function amountPerShare(ProgramInfo memory self) internal pure returns (Accumulator memory) {\\n return self.amount.div(self.duration);\\n }\\n\\n /**\\n * @notice Returns whether the program has started by timestamp `timestamp`\\n * @param self The ProgramInfo to operate on\\n * @param timestamp Timestamp to check for\\n * @return Whether the program has started\\n */\\n function isStarted(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\\n return timestamp >= self.start;\\n }\\n\\n /**\\n * @notice Returns whether the program is completed by timestamp `timestamp`\\n * @param self The ProgramInfo to operate on\\n * @param timestamp Timestamp to check for\\n * @return Whether the program is completed\\n */\\n function isComplete(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\\n return timestamp >= (self.start + self.duration);\\n }\\n}\\n\",\"keccak256\":\"0x280fcaf931b49abaec46b95ccbabaaf856a4b8e8d036413c9c3b3af25585d161\",\"license\":\"Apache-2.0\"}},\"version\":1}", - "bytecode": "0x608060405234801561001057600080fd5b506141e7806100206000396000f3fe608060405234801561001057600080fd5b50600436106101515760003560e01c806370f3f08b116100cd578063d758869111610081578063f77c479111610066578063f77c479114610325578063f8724aba1461032d578063faaebd211461037557600080fd5b8063d7588691146102ff578063e1e5a82e1461031257600080fd5b8063a55ff01d116100b2578063a55ff01d146102c6578063b774b601146102d9578063c4d66de8146102ec57600080fd5b806370f3f08b1461026b57806390672ad8146102b357600080fd5b80632c3e50e5116101245780634ea71327116101095780634ea713271461023257806366f8162e146102455780636da0d5401461025857600080fd5b80632c3e50e5146101ff578063457182781461021f57600080fd5b806305d85eda14610156578063095c82411461019f578063144dcdd1146101b25780631830349c146101ea575b600080fd5b61018c6101643660046136a4565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6040519081526020015b60405180910390f35b61018c6101ad3660046136c1565b610395565b6101c56101c03660046136c1565b6103d1565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610196565b6101fd6101f83660046137ef565b6104c0565b005b61021261020d3660046136c1565b6105b5565b6040516101969190613825565b6101fd61022d3660046138c6565b61066f565b61018c6102403660046136a4565b61075a565b61018c61025336600461391b565b610788565b6101c56102663660046136c1565b6107c0565b61018c6102793660046136c1565b73ffffffffffffffffffffffffffffffffffffffff9190911660009081526020818152604080832093835260019093019052206003015490565b6101fd6102c136600461395c565b610837565b6101fd6102d43660046139c8565b6109c3565b6101fd6102e73660046139e4565b610af0565b6101fd6102fa3660046136a4565b610cfa565b61018c61030d366004613a26565b610e18565b6101fd6103203660046136c1565b6114b6565b6101c5611771565b61018c61033b3660046136c1565b73ffffffffffffffffffffffffffffffffffffffff9190911660009081526020818152604080832093835260019384019091529020015490565b61018c6103833660046136a4565b60016020526000908152604090205481565b73ffffffffffffffffffffffffffffffffffffffff82166000908152602081815260408083208484526001019091529020600201545b92915050565b60006103db611771565b73ffffffffffffffffffffffffffffffffffffffff16634c5430a06000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001848154811061044857610448613a85565b9060005260206000209060060201600001546040518263ffffffff1660e01b815260040161047891815260200190565b602060405180830381865afa158015610495573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104b99190613ab4565b9392505050565b6104c8611771565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff9190911690637fd2919290602401602060405180830381865afa158015610534573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105589190613ad1565b610595576040517f4d5325650000000000000000000000000000000000000000000000000000000081523360048201526024015b60405180910390fd5b3360008181526020819052604090206105b0908285856117a0565b505050565b6105bd613622565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090208054839081106105f4576105f4613a85565b60009182526020918290206040805160a0810182526006909302909101805483528151808301835260018201548152600282015481860152938301939093526003830154908201526004820154606082015260059091015473ffffffffffffffffffffffffffffffffffffffff166080820152905092915050565b60026106997f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b036106d0576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755610731838383808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506119ad92505050565b60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755505050565b73ffffffffffffffffffffffffffffffffffffffff811660009081526020819052604081206103cb90611c10565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604081206107b8908484611c1e565b949350505050565b60006107ca611771565b73ffffffffffffffffffffffffffffffffffffffff1663a123c33e6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001848154811061044857610448613a85565b60026108617f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03610898576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7558281146108f5576040517f90fb223000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b838110156109975761098585858381811061091557610915613a85565b905060200201602081019061092a91906136a4565b84848481811061093c5761093c613a85565b905060200281019061094e9190613af3565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506119ad92505050565b8061098f81613b8a565b9150506108f8565b5060017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7555b50505050565b6109cb611771565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff9190911690637fd2919290602401602060405180830381865afa158015610a37573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a5b9190613ad1565b610a93576040517f4d53256500000000000000000000000000000000000000000000000000000000815233600482015260240161058c565b336000818152602081905260408120610aad908385611c71565b905060005b81518110156109bd57610ade83838381518110610ad157610ad1613a85565b6020026020010151611e85565b80610ae881613b8a565b915050610ab2565b610af8611771565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b669190613ad1565b15610b9d576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b818110156105b0576000838383818110610bbc57610bbc613a85565b9050602002016020810190610bd191906136a4565b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604081208054919055909150610c95610c09611771565b73ffffffffffffffffffffffffffffffffffffffff166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c779190613ab4565b73ffffffffffffffffffffffffffffffffffffffff84169083611fb3565b8173ffffffffffffffffffffffffffffffffffffffff167f10df095d1434aed409b2f33d2a6a8456f8b0824633cc12a1b43032085aadc41d82604051610cdd91815260200190565b60405180910390a250508080610cf290613b8a565b915050610ba0565b600180610d257f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b5490565b10610d5f576040517f1e7a9d950000000000000000000000000000000000000000000000000000000081526004810182905260240161058c565b610d887f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b829055565b60017fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c55610db582611fd4565b610dbd6120b4565b60007fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c556040518181527fbe9b076dc5b65990cca9dd9d7366682482e7817a6f6bc7f4faf4dc32af497f329060200160405180910390a15050565b60006002610e447f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03610e7b576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75582610ea8611771565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301529190911690637fd2919290602401602060405180830381865afa158015610f16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f3a9190613ad1565b610f88576040517f4d53256500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8216600482015260240161058c565b610f90611771565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ffe9190613ad1565b15611035576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b823561103f611771565b73ffffffffffffffffffffffffffffffffffffffff1663a123c33e826040518263ffffffff1660e01b815260040161107991815260200190565b602060405180830381865afa158015611096573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ba9190613ab4565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611121576040517f48f62f3c0000000000000000000000000000000000000000000000000000000081526004810182905260240161058c565b600061112b611771565b90508435158015906111cd57506040517f7d254e6600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8781166004830152821690637d254e6690602401602060405180830381865afa1580156111a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111c89190613bc2565b853514155b1561121c576040517fe264a52400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8716600482015260240161058c565b8073ffffffffffffffffffffffffffffffffffffffff16637d49c1b76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611267573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061128b9190613bc2565b6112948761075a565b106112cb576040517f1651519200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6112e26112dd36879003870187613c51565b612140565b60008061136b6112f736899003890189613c51565b8473ffffffffffffffffffffffffffffffffffffffff16633ceda0116040518163ffffffff1660e01b8152600401602060405180830381865afa158015611342573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113669190613bc2565b6121d0565b608082015173ffffffffffffffffffffffffffffffffffffffff1660009081526001602052604090205491935091506113a4908261222f565b608083015173ffffffffffffffffffffffffffffffffffffffff908116600090815260016020908152604080832094909455918b16815290819052206113ea908361223b565b955061142c3361140a611405368b90038b0160208c01613cf4565b6122f5565b608085015173ffffffffffffffffffffffffffffffffffffffff169190612309565b858873ffffffffffffffffffffffffffffffffffffffff167fee8233a38e17998eb73ba822048e13762f2b68729ef94c45133866ee75754dc68484604051611475929190613d10565b60405180910390a350505050506103cb60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d76119a990919063ffffffff16565b60026114e07f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03611517576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75573ffffffffffffffffffffffffffffffffffffffff82166000908152602081905260409020548290829081106115bc576040517fd063582900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff831660048201526024810182905260440161058c565b6115c4611771565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561160e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116329190613ad1565b15611669576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b838361167582826107c0565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146116f8576040517fa17e375200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff831660048201526024810182905260440161058c565b73ffffffffffffffffffffffffffffffffffffffff8616600090815260208190526040812061172890888861232b565b90506117348782611e85565b505050505061176d60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d76119a990919063ffffffff16565b5050565b600061179b7f0e555410d8128dff796eab5d29b97dd593ce9cab44a71b64c08244579ea605335490565b905090565b73ffffffffffffffffffffffffffffffffffffffff821660009081526005850160205260409020548454815b818110156118185773ffffffffffffffffffffffffffffffffffffffff851660009081526004880160205260409020611805908261241b565b508061181081613b8a565b9150506117cc565b5073ffffffffffffffffffffffffffffffffffffffff84166000908152600587016020908152604080832084905560048901909152812061185890612427565b905060005b815181101561199f57600082828151811061187a5761187a613a85565b6020026020010151905060008960010160008381526020019081526020016000209050611933898b60000184815481106118b6576118b6613a85565b60009182526020918290206040805160a0810182526006909302909101805483528151808301835260018201548152600282015481860152938301939093526003830154908201526004820154606082015260059091015473ffffffffffffffffffffffffffffffffffffffff1660808201528391908b8b612434565b61194060028b01836124bb565b15801561195257506003810154875110155b1561198a5773ffffffffffffffffffffffffffffffffffffffff8816600090815260048b016020526040902061198890836124d3565b505b5050808061199790613b8a565b91505061185d565b5050505050505050565b9055565b816119b6611771565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301529190911690637fd2919290602401602060405180830381865afa158015611a24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a489190613ad1565b611a96576040517f4d53256500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8216600482015260240161058c565b611a9e611771565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ae8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b0c9190613ad1565b15611b43576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517ff667f897000000000000000000000000000000000000000000000000000000008152336004820181905290849073ffffffffffffffffffffffffffffffffffffffff82169063f667f89790602401600060405180830381600087803b158015611baf57600080fd5b505af1158015611bc3573d6000803e3d6000fd5b5050505060005b8451811015611c0857611bf686868381518110611be957611be9613a85565b60200260200101516124df565b80611c0081613b8a565b915050611bca565b505050505050565b60006103cb82600201612612565b6000611c2b848390541190565b611c37575060006104b9565b506000818152600184016020908152604080832073ffffffffffffffffffffffffffffffffffffffff861684529091529020549392505050565b60606000611c8185600201612427565b9050805167ffffffffffffffff811115611c9d57611c9d6136ed565b604051908082528060200260200182016040528015611cf957816020015b611ce66040518060800160405280600081526020016000815260200160008152602001600081525090565b815260200190600190039081611cbb5790505b50915060005b8151811015611e7c576000828281518110611d1c57611d1c613a85565b602002602001015190506000876000018281548110611d3d57611d3d613a85565b600091825260208083206040805160a08101825260069094029091018054845281518083018352600180830154825260028084015483870152868601929092526003830154868501526004830154606087015260059092015473ffffffffffffffffffffffffffffffffffffffff166080860152878652908d019092528320908101549193509190158015611dda57506020880151604084015111155b15611ded57611dea8a858a61261c565b90505b60008083600301546000148015611e0f575060208a0151611e0f908690612639565b15611e2557611e1f8c8c88612659565b90925090505b604051806080016040528087815260200184815260200183815260200182815250898881518110611e5857611e58613a85565b60200260200101819052505050505050508080611e7490613b8a565b915050611cff565b50509392505050565b8051606082015115611eef57611eef611e9e84836103d1565b606084015173ffffffffffffffffffffffffffffffffffffffff86166000908152602081905260409020611ed29085612715565b73ffffffffffffffffffffffffffffffffffffffff169190611fb3565b602082015115611f4f57808373ffffffffffffffffffffffffffffffffffffffff167f1239d8c1165187259e281474a9ae5bb87fabb197873589de0a2645ae5e2261da8460200151604051611f4691815260200190565b60405180910390a35b6040820151156105b057808373ffffffffffffffffffffffffffffffffffffffff167fc590246f839a70d2279ef40b9e46b50bb20789c016f823abca87b69963f225848460400151604051611fa691815260200190565b60405180910390a3505050565b6105b073ffffffffffffffffffffffffffffffffffffffff8416838361275d565b303b1515801561200357507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b1561203a576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff81163b612088576040517f14878b6900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6120b17f0e555410d8128dff796eab5d29b97dd593ce9cab44a71b64c08244579ea60533829055565b50565b303b151580156120e357507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b1561211a576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755565b6040810151421061217d576040517f0a5af16500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620151808160600151108061219957506303c267008160600151115b156120b1576040517f72cd3d6300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6121d8613622565b6000806121fb6121f0670de0b6b3a764000086612831565b60208701519061283d565b9050600061221961140583886020015161288e90919063ffffffff16565b60208701929092525084925090505b9250929050565b60006104b98284613d79565b815460018082018455600084815260208082208551600686029091019081558582015180518286015582015160028201556040808701516003830155606087015160048301556080870151600590920180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff909316929092179091558483529286019052206122e190836128dc565b6122ee600284018261241b565b5092915050565b602081015181516000916103cb919061222f565b6105b073ffffffffffffffffffffffffffffffffffffffff84168330846128f5565b6123566040518060800160405280600081526020016000815260200160008152602001600081525090565b6000828152600185016020526040812060028101549091036123f1576123eb85848673ffffffffffffffffffffffffffffffffffffffff16639d888e866040518163ffffffff1660e01b8152600401606060405180830381865afa1580156123c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123e69190613d91565b61261c565b60208301525b806003015460000361241357612408858585612659565b606084015260408301525b509392505050565b60006104b98383612953565b606060006104b9836129a2565b600061244386868686866129fe565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260208890526040902054909150612476908261222f565b73ffffffffffffffffffffffffffffffffffffffff841660009081526020889052604090205560018601546124ab9082612831565b8660010181905550505050505050565b600081815260018301602052604081205415156104b9565b60006104b98383612cff565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260208190526040902054829082908110612560576040517fd063582900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff831660048201526024810182905260440161058c565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260208190526040812090612591823387612df2565b90506125a23382611ed28589612715565b843373ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167f865ca08d59f5cb456e85cd2f7ef63664ea4f73327414e9d8152c4158b0e946458460405161260291815260200190565b60405180910390a4505050505050565b60006103cb825490565b8051600083815260018501602052604090206002018190556104b9565b60008260600151836040015161264f9190613d79565b9091101592915050565b6000806126fa8486600001858154811061267557612675613a85565b600091825260208083206040805160a081018252600690940290910180548452815180830183526001808301548252600283015482860152858501919091526003820154858401526004820154606086015260059091015473ffffffffffffffffffffffffffffffffffffffff1660808501528985528b019091529091209190612e2e565b909250905061270c60028601846124d3565b50935093915050565b600082600001828154811061272c5761272c613a85565b600091825260209091206006909102016005015473ffffffffffffffffffffffffffffffffffffffff169392505050565b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526105b09084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152613026565b60006104b98284613e14565b604080518082019091526000808252602082015260408051808201909152835181906128699085613132565b815260200161288584866020015161313290919063ffffffff16565b90529392505050565b6040805180820190915260008082526020820152604080518082019091528251845182916128bc9190612831565b81526020016128858460200151866020015161283190919063ffffffff16565b6128e981602001516122f5565b82600101819055505050565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526109bd9085907f23b872dd00000000000000000000000000000000000000000000000000000000906084016127af565b600081815260018301602052604081205461299a575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556103cb565b5060006103cb565b6060816000018054806020026020016040519081016040528092919081815260200182805480156129f257602002820191906000526020600020905b8154815260200190600101908083116129de575b50505050509050919050565b60008060008760020154600014612a19578760020154612a1c565b83515b600389015415612a30578860030154612a52565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff5b6040517f8e480b2000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8881166004830152929450909250600091612b01918491612afc9187918d1690638e480b2090602401602060405180830381865afa158015612ad3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612af79190613bc2565b613151565b613168565b90506000612b13838760000151613168565b90506000612c298a73ffffffffffffffffffffffffffffffffffffffff1663476fa96d856040518263ffffffff1660e01b8152600401612b5591815260200190565b6040805180830381865afa158015612b71573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b959190613e2b565b6040517f476fa96d0000000000000000000000000000000000000000000000000000000081526004810185905273ffffffffffffffffffffffffffffffffffffffff8d169063476fa96d906024016040805180830381865afa158015612bff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c239190613e2b565b90613177565b6040517fb7648fb900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8a81166004830152919250600091612cca9184918e169063b7648fb9906024016040805180830381865afa158015612ca0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cc49190613e2b565b906131c5565b9050612cef612cea612ce583612cdf8e613219565b90613240565b61328e565b6132a2565b9c9b505050505050505050505050565b60008181526001830160205260408120548015612de8576000612d23600183613e14565b8554909150600090612d3790600190613e14565b9050818114612d9c576000866000018281548110612d5757612d57613a85565b9060005260206000200154905080876000018481548110612d7a57612d7a613a85565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612dad57612dad613e5d565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506103cb565b60009150506103cb565b6000818152600184016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8616845290915281208054908290556107b8565b600080600085600201549050612e89818673ffffffffffffffffffffffffffffffffffffffff1663c07f47d46040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ad3573d6000803e3d6000fd5b600387018190556040517f7ece075d0000000000000000000000000000000000000000000000000000000081526004810183905290935060009073ffffffffffffffffffffffffffffffffffffffff871690637ece075d90602401606060405180830381865afa158015612f01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f259190613d91565b6040517f7ece075d0000000000000000000000000000000000000000000000000000000081526004810186905290915060009073ffffffffffffffffffffffffffffffffffffffff881690637ece075d90602401606060405180830381865afa158015612f96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fba9190613d91565b9050600082602001518260200151612fd29190613e14565b8760600151612fe19190613e14565b9050613000818860600151612ff98a602001516122f5565b91906132e2565b60018a01549095506130129086612831565b896001018190555050505050935093915050565b6000613088826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166132ef9092919063ffffffff16565b8051909150156105b057808060200190518101906130a69190613ad1565b6105b0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840161058c565b6000670de0b6b3a76400006131478385613e8c565b6104b99190613ef8565b60008183101561316157816104b9565b5090919050565b600081831061316157816104b9565b6040805180820190915260008082526020820152604080518082019091528251845182916131a591906132fe565b8152602001612885846020015186602001516132fe90919063ffffffff16565b604080518082019091526000808252602082015260405180604001604052806131ff84600001516131f9876000015161330a565b90613369565b815260200161288584602001516131f9876020015161330a565b6040805180820190915260008082526020820152606082015160208301516103cb91613388565b60408051808201909152600080825260208201526040805180820190915282518451829161326e9190613369565b81526020016128858460200151866020015161336990919063ffffffff16565b602081015181516000916103cb91906133ed565b600081818112156103cb576040517f501f289e0000000000000000000000000000000000000000000000000000000081526004810182905260240161058c565b60006107b88484846133f9565b60606107b88484600085613410565b60006104b98284613f0c565b6000817f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8111156103cb576040517ea07eb50000000000000000000000000000000000000000000000000000000081526004810182905260240161058c565b6000670de0b6b3a764000061337e8385613f80565b6104b9919061403c565b604080518082019091526000808252602082015260405180604001604052806133cc6133bb6133b6866135a6565b61330a565b86516133c69061330a565b906135ba565b81526020016128856133e06133b6866135a6565b6133c6876020015161330a565b60006104b982846140a4565b6000816134068486613e8c565b6107b89190613ef8565b6060824710156134a2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c0000000000000000000000000000000000000000000000000000606482015260840161058c565b73ffffffffffffffffffffffffffffffffffffffff85163b613520576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161058c565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516135499190614144565b60006040518083038185875af1925050503d8060008114613586576040519150601f19603f3d011682016040523d82523d6000602084013e61358b565b606091505b509150915061359b8282866135cf565b979650505050505050565b60006103cb670de0b6b3a764000083613e8c565b60008161337e670de0b6b3a764000085613f80565b606083156135de5750816104b9565b8251156135ee5782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161058c9190614160565b6040518060a0016040528060008152602001613651604051806040016040528060008152602001600081525090565b81526020016000815260200160008152602001600073ffffffffffffffffffffffffffffffffffffffff1681525090565b73ffffffffffffffffffffffffffffffffffffffff811681146120b157600080fd5b6000602082840312156136b657600080fd5b81356104b981613682565b600080604083850312156136d457600080fd5b82356136df81613682565b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040805190810167ffffffffffffffff81118282101715613766577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405290565b60006060828403121561377e57600080fd5b6040516060810181811067ffffffffffffffff821117156137c8577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b80604052508091508235815260208301356020820152604083013560408201525092915050565b6000806080838503121561380257600080fd5b823561380d81613682565b915061381c846020850161376c565b90509250929050565b60c081016103cb8284805182526020810151805160208401526020810151604084015250604081015160608301526060810151608083015273ffffffffffffffffffffffffffffffffffffffff60808201511660a08301525050565b60008083601f84011261389357600080fd5b50813567ffffffffffffffff8111156138ab57600080fd5b6020830191508360208260051b850101111561222857600080fd5b6000806000604084860312156138db57600080fd5b83356138e681613682565b9250602084013567ffffffffffffffff81111561390257600080fd5b61390e86828701613881565b9497909650939450505050565b60008060006060848603121561393057600080fd5b833561393b81613682565b9250602084013561394b81613682565b929592945050506040919091013590565b6000806000806040858703121561397257600080fd5b843567ffffffffffffffff8082111561398a57600080fd5b61399688838901613881565b909650945060208701359150808211156139af57600080fd5b506139bc87828801613881565b95989497509550505050565b6000606082840312156139da57600080fd5b6104b9838361376c565b600080602083850312156139f757600080fd5b823567ffffffffffffffff811115613a0e57600080fd5b613a1a85828601613881565b90969095509350505050565b60008082840360e0811215613a3a57600080fd5b8335613a4581613682565b925060c07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe082011215613a7757600080fd5b506020830190509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600060208284031215613ac657600080fd5b81516104b981613682565b600060208284031215613ae357600080fd5b815180151581146104b957600080fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112613b2857600080fd5b83018035915067ffffffffffffffff821115613b4357600080fd5b6020019150600581901b360382131561222857600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203613bbb57613bbb613b5b565b5060010190565b600060208284031215613bd457600080fd5b5051919050565b600060408284031215613bed57600080fd5b6040516040810181811067ffffffffffffffff82111715613c37577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604052823581526020928301359281019290925250919050565b600060c08284031215613c6357600080fd5b60405160a0810181811067ffffffffffffffff82111715613cad577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405282358152613cc18460208501613bdb565b6020820152606083013560408201526080830135606082015260a0830135613ce881613682565b60808201529392505050565b600060408284031215613d0657600080fd5b6104b98383613bdb565b60e08101613d6c8285805182526020810151805160208401526020810151604084015250604081015160608301526060810151608083015273ffffffffffffffffffffffffffffffffffffffff60808201511660a08301525050565b8260c08301529392505050565b60008219821115613d8c57613d8c613b5b565b500190565b600060608284031215613da357600080fd5b6040516060810181811067ffffffffffffffff82111715613ded577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b80604052508251815260208301516020820152604083015160408201528091505092915050565b600082821015613e2657613e26613b5b565b500390565b600060408284031215613e3d57600080fd5b613e4561371c565b82518152602083015160208201528091505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613ec457613ec4613b5b565b500290565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600082613f0757613f07613ec9565b500490565b6000808312837f800000000000000000000000000000000000000000000000000000000000000001831281151615613f4657613f46613b5b565b837f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff018313811615613f7a57613f7a613b5b565b50500390565b60007f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600084136000841385830485118282161615613fc157613fc1613b5b565b7f80000000000000000000000000000000000000000000000000000000000000006000871286820588128184161615613ffc57613ffc613b5b565b6000871292508782058712848416161561401857614018613b5b565b8785058712818416161561402e5761402e613b5b565b505050929093029392505050565b60008261404b5761404b613ec9565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83147f80000000000000000000000000000000000000000000000000000000000000008314161561409f5761409f613b5b565b500590565b6000808212827f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038413811516156140de576140de613b5b565b827f800000000000000000000000000000000000000000000000000000000000000003841281161561411257614112613b5b565b50500190565b60005b8381101561413357818101518382015260200161411b565b838111156109bd5750506000910152565b60008251614156818460208701614118565b9190910192915050565b602081526000825180602084015261417f816040850160208701614118565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fea2646970667358221220831c6b889a16c321a2b85f3e8d7e805b9de07b7c96d87d8c2eeb97c9c669aa1264736f6c634300080f0033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101515760003560e01c806370f3f08b116100cd578063d758869111610081578063f77c479111610066578063f77c479114610325578063f8724aba1461032d578063faaebd211461037557600080fd5b8063d7588691146102ff578063e1e5a82e1461031257600080fd5b8063a55ff01d116100b2578063a55ff01d146102c6578063b774b601146102d9578063c4d66de8146102ec57600080fd5b806370f3f08b1461026b57806390672ad8146102b357600080fd5b80632c3e50e5116101245780634ea71327116101095780634ea713271461023257806366f8162e146102455780636da0d5401461025857600080fd5b80632c3e50e5146101ff578063457182781461021f57600080fd5b806305d85eda14610156578063095c82411461019f578063144dcdd1146101b25780631830349c146101ea575b600080fd5b61018c6101643660046136a4565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6040519081526020015b60405180910390f35b61018c6101ad3660046136c1565b610395565b6101c56101c03660046136c1565b6103d1565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610196565b6101fd6101f83660046137ef565b6104c0565b005b61021261020d3660046136c1565b6105b5565b6040516101969190613825565b6101fd61022d3660046138c6565b61066f565b61018c6102403660046136a4565b61075a565b61018c61025336600461391b565b610788565b6101c56102663660046136c1565b6107c0565b61018c6102793660046136c1565b73ffffffffffffffffffffffffffffffffffffffff9190911660009081526020818152604080832093835260019093019052206003015490565b6101fd6102c136600461395c565b610837565b6101fd6102d43660046139c8565b6109c3565b6101fd6102e73660046139e4565b610af0565b6101fd6102fa3660046136a4565b610cfa565b61018c61030d366004613a26565b610e18565b6101fd6103203660046136c1565b6114b6565b6101c5611771565b61018c61033b3660046136c1565b73ffffffffffffffffffffffffffffffffffffffff9190911660009081526020818152604080832093835260019384019091529020015490565b61018c6103833660046136a4565b60016020526000908152604090205481565b73ffffffffffffffffffffffffffffffffffffffff82166000908152602081815260408083208484526001019091529020600201545b92915050565b60006103db611771565b73ffffffffffffffffffffffffffffffffffffffff16634c5430a06000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001848154811061044857610448613a85565b9060005260206000209060060201600001546040518263ffffffff1660e01b815260040161047891815260200190565b602060405180830381865afa158015610495573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104b99190613ab4565b9392505050565b6104c8611771565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff9190911690637fd2919290602401602060405180830381865afa158015610534573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105589190613ad1565b610595576040517f4d5325650000000000000000000000000000000000000000000000000000000081523360048201526024015b60405180910390fd5b3360008181526020819052604090206105b0908285856117a0565b505050565b6105bd613622565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090208054839081106105f4576105f4613a85565b60009182526020918290206040805160a0810182526006909302909101805483528151808301835260018201548152600282015481860152938301939093526003830154908201526004820154606082015260059091015473ffffffffffffffffffffffffffffffffffffffff166080820152905092915050565b60026106997f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b036106d0576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755610731838383808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506119ad92505050565b60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755505050565b73ffffffffffffffffffffffffffffffffffffffff811660009081526020819052604081206103cb90611c10565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604081206107b8908484611c1e565b949350505050565b60006107ca611771565b73ffffffffffffffffffffffffffffffffffffffff1663a123c33e6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001848154811061044857610448613a85565b60026108617f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03610898576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7558281146108f5576040517f90fb223000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b838110156109975761098585858381811061091557610915613a85565b905060200201602081019061092a91906136a4565b84848481811061093c5761093c613a85565b905060200281019061094e9190613af3565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506119ad92505050565b8061098f81613b8a565b9150506108f8565b5060017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7555b50505050565b6109cb611771565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff9190911690637fd2919290602401602060405180830381865afa158015610a37573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a5b9190613ad1565b610a93576040517f4d53256500000000000000000000000000000000000000000000000000000000815233600482015260240161058c565b336000818152602081905260408120610aad908385611c71565b905060005b81518110156109bd57610ade83838381518110610ad157610ad1613a85565b6020026020010151611e85565b80610ae881613b8a565b915050610ab2565b610af8611771565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b669190613ad1565b15610b9d576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b818110156105b0576000838383818110610bbc57610bbc613a85565b9050602002016020810190610bd191906136a4565b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604081208054919055909150610c95610c09611771565b73ffffffffffffffffffffffffffffffffffffffff166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c779190613ab4565b73ffffffffffffffffffffffffffffffffffffffff84169083611fb3565b8173ffffffffffffffffffffffffffffffffffffffff167f10df095d1434aed409b2f33d2a6a8456f8b0824633cc12a1b43032085aadc41d82604051610cdd91815260200190565b60405180910390a250508080610cf290613b8a565b915050610ba0565b600180610d257f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b5490565b10610d5f576040517f1e7a9d950000000000000000000000000000000000000000000000000000000081526004810182905260240161058c565b610d887f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b829055565b60017fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c55610db582611fd4565b610dbd6120b4565b60007fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c556040518181527fbe9b076dc5b65990cca9dd9d7366682482e7817a6f6bc7f4faf4dc32af497f329060200160405180910390a15050565b60006002610e447f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03610e7b576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75582610ea8611771565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301529190911690637fd2919290602401602060405180830381865afa158015610f16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f3a9190613ad1565b610f88576040517f4d53256500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8216600482015260240161058c565b610f90611771565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ffe9190613ad1565b15611035576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b823561103f611771565b73ffffffffffffffffffffffffffffffffffffffff1663a123c33e826040518263ffffffff1660e01b815260040161107991815260200190565b602060405180830381865afa158015611096573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ba9190613ab4565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611121576040517f48f62f3c0000000000000000000000000000000000000000000000000000000081526004810182905260240161058c565b600061112b611771565b90508435158015906111cd57506040517f7d254e6600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8781166004830152821690637d254e6690602401602060405180830381865afa1580156111a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111c89190613bc2565b853514155b1561121c576040517fe264a52400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8716600482015260240161058c565b8073ffffffffffffffffffffffffffffffffffffffff16637d49c1b76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611267573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061128b9190613bc2565b6112948761075a565b106112cb576040517f1651519200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6112e26112dd36879003870187613c51565b612140565b60008061136b6112f736899003890189613c51565b8473ffffffffffffffffffffffffffffffffffffffff16633ceda0116040518163ffffffff1660e01b8152600401602060405180830381865afa158015611342573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113669190613bc2565b6121d0565b608082015173ffffffffffffffffffffffffffffffffffffffff1660009081526001602052604090205491935091506113a4908261222f565b608083015173ffffffffffffffffffffffffffffffffffffffff908116600090815260016020908152604080832094909455918b16815290819052206113ea908361223b565b955061142c3361140a611405368b90038b0160208c01613cf4565b6122f5565b608085015173ffffffffffffffffffffffffffffffffffffffff169190612309565b858873ffffffffffffffffffffffffffffffffffffffff167fee8233a38e17998eb73ba822048e13762f2b68729ef94c45133866ee75754dc68484604051611475929190613d10565b60405180910390a350505050506103cb60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d76119a990919063ffffffff16565b60026114e07f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03611517576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75573ffffffffffffffffffffffffffffffffffffffff82166000908152602081905260409020548290829081106115bc576040517fd063582900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff831660048201526024810182905260440161058c565b6115c4611771565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561160e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116329190613ad1565b15611669576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b838361167582826107c0565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146116f8576040517fa17e375200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff831660048201526024810182905260440161058c565b73ffffffffffffffffffffffffffffffffffffffff8616600090815260208190526040812061172890888861232b565b90506117348782611e85565b505050505061176d60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d76119a990919063ffffffff16565b5050565b600061179b7f0e555410d8128dff796eab5d29b97dd593ce9cab44a71b64c08244579ea605335490565b905090565b73ffffffffffffffffffffffffffffffffffffffff821660009081526005850160205260409020548454815b818110156118185773ffffffffffffffffffffffffffffffffffffffff851660009081526004880160205260409020611805908261241b565b508061181081613b8a565b9150506117cc565b5073ffffffffffffffffffffffffffffffffffffffff84166000908152600587016020908152604080832084905560048901909152812061185890612427565b905060005b815181101561199f57600082828151811061187a5761187a613a85565b6020026020010151905060008960010160008381526020019081526020016000209050611933898b60000184815481106118b6576118b6613a85565b60009182526020918290206040805160a0810182526006909302909101805483528151808301835260018201548152600282015481860152938301939093526003830154908201526004820154606082015260059091015473ffffffffffffffffffffffffffffffffffffffff1660808201528391908b8b612434565b61194060028b01836124bb565b15801561195257506003810154875110155b1561198a5773ffffffffffffffffffffffffffffffffffffffff8816600090815260048b016020526040902061198890836124d3565b505b5050808061199790613b8a565b91505061185d565b5050505050505050565b9055565b816119b6611771565b6040517f7fd2919200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301529190911690637fd2919290602401602060405180830381865afa158015611a24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a489190613ad1565b611a96576040517f4d53256500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8216600482015260240161058c565b611a9e611771565b73ffffffffffffffffffffffffffffffffffffffff16635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ae8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b0c9190613ad1565b15611b43576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517ff667f897000000000000000000000000000000000000000000000000000000008152336004820181905290849073ffffffffffffffffffffffffffffffffffffffff82169063f667f89790602401600060405180830381600087803b158015611baf57600080fd5b505af1158015611bc3573d6000803e3d6000fd5b5050505060005b8451811015611c0857611bf686868381518110611be957611be9613a85565b60200260200101516124df565b80611c0081613b8a565b915050611bca565b505050505050565b60006103cb82600201612612565b6000611c2b848390541190565b611c37575060006104b9565b506000818152600184016020908152604080832073ffffffffffffffffffffffffffffffffffffffff861684529091529020549392505050565b60606000611c8185600201612427565b9050805167ffffffffffffffff811115611c9d57611c9d6136ed565b604051908082528060200260200182016040528015611cf957816020015b611ce66040518060800160405280600081526020016000815260200160008152602001600081525090565b815260200190600190039081611cbb5790505b50915060005b8151811015611e7c576000828281518110611d1c57611d1c613a85565b602002602001015190506000876000018281548110611d3d57611d3d613a85565b600091825260208083206040805160a08101825260069094029091018054845281518083018352600180830154825260028084015483870152868601929092526003830154868501526004830154606087015260059092015473ffffffffffffffffffffffffffffffffffffffff166080860152878652908d019092528320908101549193509190158015611dda57506020880151604084015111155b15611ded57611dea8a858a61261c565b90505b60008083600301546000148015611e0f575060208a0151611e0f908690612639565b15611e2557611e1f8c8c88612659565b90925090505b604051806080016040528087815260200184815260200183815260200182815250898881518110611e5857611e58613a85565b60200260200101819052505050505050508080611e7490613b8a565b915050611cff565b50509392505050565b8051606082015115611eef57611eef611e9e84836103d1565b606084015173ffffffffffffffffffffffffffffffffffffffff86166000908152602081905260409020611ed29085612715565b73ffffffffffffffffffffffffffffffffffffffff169190611fb3565b602082015115611f4f57808373ffffffffffffffffffffffffffffffffffffffff167f1239d8c1165187259e281474a9ae5bb87fabb197873589de0a2645ae5e2261da8460200151604051611f4691815260200190565b60405180910390a35b6040820151156105b057808373ffffffffffffffffffffffffffffffffffffffff167fc590246f839a70d2279ef40b9e46b50bb20789c016f823abca87b69963f225848460400151604051611fa691815260200190565b60405180910390a3505050565b6105b073ffffffffffffffffffffffffffffffffffffffff8416838361275d565b303b1515801561200357507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b1561203a576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff81163b612088576040517f14878b6900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6120b17f0e555410d8128dff796eab5d29b97dd593ce9cab44a71b64c08244579ea60533829055565b50565b303b151580156120e357507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b1561211a576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755565b6040810151421061217d576040517f0a5af16500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620151808160600151108061219957506303c267008160600151115b156120b1576040517f72cd3d6300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6121d8613622565b6000806121fb6121f0670de0b6b3a764000086612831565b60208701519061283d565b9050600061221961140583886020015161288e90919063ffffffff16565b60208701929092525084925090505b9250929050565b60006104b98284613d79565b815460018082018455600084815260208082208551600686029091019081558582015180518286015582015160028201556040808701516003830155606087015160048301556080870151600590920180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff909316929092179091558483529286019052206122e190836128dc565b6122ee600284018261241b565b5092915050565b602081015181516000916103cb919061222f565b6105b073ffffffffffffffffffffffffffffffffffffffff84168330846128f5565b6123566040518060800160405280600081526020016000815260200160008152602001600081525090565b6000828152600185016020526040812060028101549091036123f1576123eb85848673ffffffffffffffffffffffffffffffffffffffff16639d888e866040518163ffffffff1660e01b8152600401606060405180830381865afa1580156123c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123e69190613d91565b61261c565b60208301525b806003015460000361241357612408858585612659565b606084015260408301525b509392505050565b60006104b98383612953565b606060006104b9836129a2565b600061244386868686866129fe565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260208890526040902054909150612476908261222f565b73ffffffffffffffffffffffffffffffffffffffff841660009081526020889052604090205560018601546124ab9082612831565b8660010181905550505050505050565b600081815260018301602052604081205415156104b9565b60006104b98383612cff565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260208190526040902054829082908110612560576040517fd063582900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff831660048201526024810182905260440161058c565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260208190526040812090612591823387612df2565b90506125a23382611ed28589612715565b843373ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167f865ca08d59f5cb456e85cd2f7ef63664ea4f73327414e9d8152c4158b0e946458460405161260291815260200190565b60405180910390a4505050505050565b60006103cb825490565b8051600083815260018501602052604090206002018190556104b9565b60008260600151836040015161264f9190613d79565b9091101592915050565b6000806126fa8486600001858154811061267557612675613a85565b600091825260208083206040805160a081018252600690940290910180548452815180830183526001808301548252600283015482860152858501919091526003820154858401526004820154606086015260059091015473ffffffffffffffffffffffffffffffffffffffff1660808501528985528b019091529091209190612e2e565b909250905061270c60028601846124d3565b50935093915050565b600082600001828154811061272c5761272c613a85565b600091825260209091206006909102016005015473ffffffffffffffffffffffffffffffffffffffff169392505050565b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526105b09084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152613026565b60006104b98284613e14565b604080518082019091526000808252602082015260408051808201909152835181906128699085613132565b815260200161288584866020015161313290919063ffffffff16565b90529392505050565b6040805180820190915260008082526020820152604080518082019091528251845182916128bc9190612831565b81526020016128858460200151866020015161283190919063ffffffff16565b6128e981602001516122f5565b82600101819055505050565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526109bd9085907f23b872dd00000000000000000000000000000000000000000000000000000000906084016127af565b600081815260018301602052604081205461299a575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556103cb565b5060006103cb565b6060816000018054806020026020016040519081016040528092919081815260200182805480156129f257602002820191906000526020600020905b8154815260200190600101908083116129de575b50505050509050919050565b60008060008760020154600014612a19578760020154612a1c565b83515b600389015415612a30578860030154612a52565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff5b6040517f8e480b2000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8881166004830152929450909250600091612b01918491612afc9187918d1690638e480b2090602401602060405180830381865afa158015612ad3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612af79190613bc2565b613151565b613168565b90506000612b13838760000151613168565b90506000612c298a73ffffffffffffffffffffffffffffffffffffffff1663476fa96d856040518263ffffffff1660e01b8152600401612b5591815260200190565b6040805180830381865afa158015612b71573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b959190613e2b565b6040517f476fa96d0000000000000000000000000000000000000000000000000000000081526004810185905273ffffffffffffffffffffffffffffffffffffffff8d169063476fa96d906024016040805180830381865afa158015612bff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c239190613e2b565b90613177565b6040517fb7648fb900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8a81166004830152919250600091612cca9184918e169063b7648fb9906024016040805180830381865afa158015612ca0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cc49190613e2b565b906131c5565b9050612cef612cea612ce583612cdf8e613219565b90613240565b61328e565b6132a2565b9c9b505050505050505050505050565b60008181526001830160205260408120548015612de8576000612d23600183613e14565b8554909150600090612d3790600190613e14565b9050818114612d9c576000866000018281548110612d5757612d57613a85565b9060005260206000200154905080876000018481548110612d7a57612d7a613a85565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612dad57612dad613e5d565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506103cb565b60009150506103cb565b6000818152600184016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8616845290915281208054908290556107b8565b600080600085600201549050612e89818673ffffffffffffffffffffffffffffffffffffffff1663c07f47d46040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ad3573d6000803e3d6000fd5b600387018190556040517f7ece075d0000000000000000000000000000000000000000000000000000000081526004810183905290935060009073ffffffffffffffffffffffffffffffffffffffff871690637ece075d90602401606060405180830381865afa158015612f01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f259190613d91565b6040517f7ece075d0000000000000000000000000000000000000000000000000000000081526004810186905290915060009073ffffffffffffffffffffffffffffffffffffffff881690637ece075d90602401606060405180830381865afa158015612f96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fba9190613d91565b9050600082602001518260200151612fd29190613e14565b8760600151612fe19190613e14565b9050613000818860600151612ff98a602001516122f5565b91906132e2565b60018a01549095506130129086612831565b896001018190555050505050935093915050565b6000613088826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166132ef9092919063ffffffff16565b8051909150156105b057808060200190518101906130a69190613ad1565b6105b0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840161058c565b6000670de0b6b3a76400006131478385613e8c565b6104b99190613ef8565b60008183101561316157816104b9565b5090919050565b600081831061316157816104b9565b6040805180820190915260008082526020820152604080518082019091528251845182916131a591906132fe565b8152602001612885846020015186602001516132fe90919063ffffffff16565b604080518082019091526000808252602082015260405180604001604052806131ff84600001516131f9876000015161330a565b90613369565b815260200161288584602001516131f9876020015161330a565b6040805180820190915260008082526020820152606082015160208301516103cb91613388565b60408051808201909152600080825260208201526040805180820190915282518451829161326e9190613369565b81526020016128858460200151866020015161336990919063ffffffff16565b602081015181516000916103cb91906133ed565b600081818112156103cb576040517f501f289e0000000000000000000000000000000000000000000000000000000081526004810182905260240161058c565b60006107b88484846133f9565b60606107b88484600085613410565b60006104b98284613f0c565b6000817f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8111156103cb576040517ea07eb50000000000000000000000000000000000000000000000000000000081526004810182905260240161058c565b6000670de0b6b3a764000061337e8385613f80565b6104b9919061403c565b604080518082019091526000808252602082015260405180604001604052806133cc6133bb6133b6866135a6565b61330a565b86516133c69061330a565b906135ba565b81526020016128856133e06133b6866135a6565b6133c6876020015161330a565b60006104b982846140a4565b6000816134068486613e8c565b6107b89190613ef8565b6060824710156134a2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c0000000000000000000000000000000000000000000000000000606482015260840161058c565b73ffffffffffffffffffffffffffffffffffffffff85163b613520576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161058c565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516135499190614144565b60006040518083038185875af1925050503d8060008114613586576040519150601f19603f3d011682016040523d82523d6000602084013e61358b565b606091505b509150915061359b8282866135cf565b979650505050505050565b60006103cb670de0b6b3a764000083613e8c565b60008161337e670de0b6b3a764000085613f80565b606083156135de5750816104b9565b8251156135ee5782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161058c9190614160565b6040518060a0016040528060008152602001613651604051806040016040528060008152602001600081525090565b81526020016000815260200160008152602001600073ffffffffffffffffffffffffffffffffffffffff1681525090565b73ffffffffffffffffffffffffffffffffffffffff811681146120b157600080fd5b6000602082840312156136b657600080fd5b81356104b981613682565b600080604083850312156136d457600080fd5b82356136df81613682565b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040805190810167ffffffffffffffff81118282101715613766577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405290565b60006060828403121561377e57600080fd5b6040516060810181811067ffffffffffffffff821117156137c8577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b80604052508091508235815260208301356020820152604083013560408201525092915050565b6000806080838503121561380257600080fd5b823561380d81613682565b915061381c846020850161376c565b90509250929050565b60c081016103cb8284805182526020810151805160208401526020810151604084015250604081015160608301526060810151608083015273ffffffffffffffffffffffffffffffffffffffff60808201511660a08301525050565b60008083601f84011261389357600080fd5b50813567ffffffffffffffff8111156138ab57600080fd5b6020830191508360208260051b850101111561222857600080fd5b6000806000604084860312156138db57600080fd5b83356138e681613682565b9250602084013567ffffffffffffffff81111561390257600080fd5b61390e86828701613881565b9497909650939450505050565b60008060006060848603121561393057600080fd5b833561393b81613682565b9250602084013561394b81613682565b929592945050506040919091013590565b6000806000806040858703121561397257600080fd5b843567ffffffffffffffff8082111561398a57600080fd5b61399688838901613881565b909650945060208701359150808211156139af57600080fd5b506139bc87828801613881565b95989497509550505050565b6000606082840312156139da57600080fd5b6104b9838361376c565b600080602083850312156139f757600080fd5b823567ffffffffffffffff811115613a0e57600080fd5b613a1a85828601613881565b90969095509350505050565b60008082840360e0811215613a3a57600080fd5b8335613a4581613682565b925060c07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe082011215613a7757600080fd5b506020830190509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600060208284031215613ac657600080fd5b81516104b981613682565b600060208284031215613ae357600080fd5b815180151581146104b957600080fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112613b2857600080fd5b83018035915067ffffffffffffffff821115613b4357600080fd5b6020019150600581901b360382131561222857600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203613bbb57613bbb613b5b565b5060010190565b600060208284031215613bd457600080fd5b5051919050565b600060408284031215613bed57600080fd5b6040516040810181811067ffffffffffffffff82111715613c37577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604052823581526020928301359281019290925250919050565b600060c08284031215613c6357600080fd5b60405160a0810181811067ffffffffffffffff82111715613cad577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405282358152613cc18460208501613bdb565b6020820152606083013560408201526080830135606082015260a0830135613ce881613682565b60808201529392505050565b600060408284031215613d0657600080fd5b6104b98383613bdb565b60e08101613d6c8285805182526020810151805160208401526020810151604084015250604081015160608301526060810151608083015273ffffffffffffffffffffffffffffffffffffffff60808201511660a08301525050565b8260c08301529392505050565b60008219821115613d8c57613d8c613b5b565b500190565b600060608284031215613da357600080fd5b6040516060810181811067ffffffffffffffff82111715613ded577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b80604052508251815260208301516020820152604083015160408201528091505092915050565b600082821015613e2657613e26613b5b565b500390565b600060408284031215613e3d57600080fd5b613e4561371c565b82518152602083015160208201528091505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613ec457613ec4613b5b565b500290565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600082613f0757613f07613ec9565b500490565b6000808312837f800000000000000000000000000000000000000000000000000000000000000001831281151615613f4657613f46613b5b565b837f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff018313811615613f7a57613f7a613b5b565b50500390565b60007f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600084136000841385830485118282161615613fc157613fc1613b5b565b7f80000000000000000000000000000000000000000000000000000000000000006000871286820588128184161615613ffc57613ffc613b5b565b6000871292508782058712848416161561401857614018613b5b565b8785058712818416161561402e5761402e613b5b565b505050929093029392505050565b60008261404b5761404b613ec9565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83147f80000000000000000000000000000000000000000000000000000000000000008314161561409f5761409f613b5b565b500590565b6000808212827f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038413811516156140de576140de613b5b565b827f800000000000000000000000000000000000000000000000000000000000000003841281161561411257614112613b5b565b50500190565b60005b8381101561413357818101518382015260200161411b565b838111156109bd5750506000910152565b60008251614156818460208701614118565b9190910192915050565b602081526000825180602084015261417f816040850160208701614118565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fea2646970667358221220831c6b889a16c321a2b85f3e8d7e805b9de07b7c96d87d8c2eeb97c9c669aa1264736f6c634300080f0033", - "devdoc": { - "kind": "dev", - "methods": { - "active(address)": { - "params": { - "product": "Product to check for" - }, - "returns": { - "_0": "Number of active programs" - } - }, - "available(address,uint256)": { - "params": { - "product": "Product to return for", - "programId": "Program to return for" - }, - "returns": { - "_0": "Available rewards for `programId`" - } - }, - "claim(address,uint256[])": { - "params": { - "product": "Product to claim rewards for", - "programIds": "Programs to claim rewards for" - } - }, - "claim(address[],uint256[][])": { - "params": { - "products": "Products to claim rewards for", - "programIds": "Programs to claim rewards for" - } - }, - "claimFee(address[])": { - "params": { - "tokens": "Tokens to claim fees for" - } - }, - "complete(address,uint256)": { - "details": "Must be called as the program owner", - "params": { - "product": "Product that the program is running on", - "programId": "Program to complete early" - } - }, - "count(address)": { - "params": { - "product": "Product to check for" - }, - "returns": { - "_0": "Number of programs (inactive or active)" - } - }, - "create(address,(uint256,(uint256,uint256),uint256,uint256,address))": { - "details": "Must be called as the product or protocol owner", - "params": { - "product": "The product to create the new program on", - "programInfo": "Parameters for the new program" - }, - "returns": { - "programId": "New program's ID" - } - }, - "initialize(address)": { - "details": "Must be called atomically as part of the upgradeable proxy deployment to avoid front-running", - "params": { - "controller_": "Factory contract address" - } - }, - "owner(address,uint256)": { - "params": { - "product": "Product to return for", - "programId": "Program to return for" - }, - "returns": { - "_0": "The owner of `programId`" - } - }, - "programInfos(address,uint256)": { - "params": { - "product": "Product to return for", - "programId": "Program to return for" - }, - "returns": { - "_0": "Program info" - } - }, - "sync((uint256,uint256,int256))": { - "details": "Called every settle() from each product", - "params": { - "currentOracleVersion": "The preloaded current oracle version" - } - }, - "syncAccount(address,(uint256,uint256,int256))": { - "details": "Called immediately proceeding a position update in the corresponding product", - "params": { - "account": "Account to sync", - "currentOracleVersion": "The preloaded current oracle version" - } - }, - "treasury(address,uint256)": { - "params": { - "product": "Product to return for", - "programId": "Program to return for" - }, - "returns": { - "_0": "The treasury of `programId`" - } - }, - "unclaimed(address,address,uint256)": { - "params": { - "account": "Account to return for", - "product": "Product to return for", - "programId": "Program to return for" - }, - "returns": { - "_0": "`account`'s total unclaimed rewards for `programId`" - } - }, - "versionComplete(address,uint256)": { - "params": { - "product": "Product to return for", - "programId": "Program to return for" - }, - "returns": { - "_0": "The version completed for `programId`" - } - }, - "versionStarted(address,uint256)": { - "params": { - "product": "Product to return for", - "programId": "Program to return for" - }, - "returns": { - "_0": "The version started for `programId`" - } - } - }, - "stateVariables": { - "_products": { - "details": "Product management state" - }, - "fees": { - "details": "Fees that have been collected, but remain unclaimed" - } - }, - "title": "Incentivizer", - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": { - "active(address)": { - "notice": "Returns the quantity of active programs for a given product" - }, - "available(address,uint256)": { - "notice": "Returns available rewards for a specific program" - }, - "claim(address,uint256[])": { - "notice": "Claims all of `msg.sender`'s rewards for `product` programs" - }, - "claim(address[],uint256[][])": { - "notice": "Claims all of `msg.sender`'s rewards for a specific program" - }, - "claimFee(address[])": { - "notice": "Claims all `tokens` fees to the protocol treasury" - }, - "complete(address,uint256)": { - "notice": "Completes an in-progress program early" - }, - "count(address)": { - "notice": "Returns the quantity of programs for a given product" - }, - "create(address,(uint256,(uint256,uint256),uint256,uint256,address))": { - "notice": "Creates a new incentive program" - }, - "initialize(address)": { - "notice": "Initializes the contract state" - }, - "owner(address,uint256)": { - "notice": "Returns the owner of a specific program" - }, - "programInfos(address,uint256)": { - "notice": "Returns program info for program `programId`" - }, - "sync((uint256,uint256,int256))": { - "notice": "Starts and completes programs as they become available" - }, - "syncAccount(address,(uint256,uint256,int256))": { - "notice": "Settles unsettled balance for `account`" - }, - "treasury(address,uint256)": { - "notice": "Returns the treasury of a specific program" - }, - "unclaimed(address,address,uint256)": { - "notice": "Returns `account`'s total unclaimed rewards for a specific program" - }, - "versionComplete(address,uint256)": { - "notice": "Returns the version completed for a specific program" - }, - "versionStarted(address,uint256)": { - "notice": "Returns the version started for a specific program" - } - }, - "notice": "Manages logic and state for all incentive programs in the protocol.", - "version": 1 - }, - "storageLayout": { - "storage": [ - { - "astId": 12696, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "_products", - "offset": 0, - "slot": "0", - "type": "t_mapping(t_contract(IProduct)16058,t_struct(ProductManager)13513_storage)" - }, - { - "astId": 12703, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "fees", - "offset": 0, - "slot": "1", - "type": "t_mapping(t_userDefinedValueType(Token18)4011,t_userDefinedValueType(UFixed18)3224)" - } - ], - "types": { - "t_address": { - "encoding": "inplace", - "label": "address", - "numberOfBytes": "20" - }, - "t_array(t_bytes32)dyn_storage": { - "base": "t_bytes32", - "encoding": "dynamic_array", - "label": "bytes32[]", - "numberOfBytes": "32" - }, - "t_array(t_struct(ProgramInfo)17434_storage)dyn_storage": { - "base": "t_struct(ProgramInfo)17434_storage", - "encoding": "dynamic_array", - "label": "struct ProgramInfo[]", - "numberOfBytes": "32" - }, - "t_bytes32": { - "encoding": "inplace", - "label": "bytes32", - "numberOfBytes": "32" - }, - "t_contract(IProduct)16058": { - "encoding": "inplace", - "label": "contract IProduct", - "numberOfBytes": "20" - }, - "t_mapping(t_address,t_struct(UintSet)10257_storage)": { - "encoding": "mapping", - "key": "t_address", - "label": "mapping(address => struct EnumerableSet.UintSet)", - "numberOfBytes": "32", - "value": "t_struct(UintSet)10257_storage" - }, - "t_mapping(t_address,t_uint256)": { - "encoding": "mapping", - "key": "t_address", - "label": "mapping(address => uint256)", - "numberOfBytes": "32", - "value": "t_uint256" - }, - "t_mapping(t_address,t_userDefinedValueType(UFixed18)3224)": { - "encoding": "mapping", - "key": "t_address", - "label": "mapping(address => UFixed18)", - "numberOfBytes": "32", - "value": "t_userDefinedValueType(UFixed18)3224" - }, - "t_mapping(t_bytes32,t_uint256)": { - "encoding": "mapping", - "key": "t_bytes32", - "label": "mapping(bytes32 => uint256)", - "numberOfBytes": "32", - "value": "t_uint256" - }, - "t_mapping(t_contract(IProduct)16058,t_struct(ProductManager)13513_storage)": { - "encoding": "mapping", - "key": "t_contract(IProduct)16058", - "label": "mapping(contract IProduct => struct ProductManager)", - "numberOfBytes": "32", - "value": "t_struct(ProductManager)13513_storage" - }, - "t_mapping(t_uint256,t_struct(Program)14108_storage)": { - "encoding": "mapping", - "key": "t_uint256", - "label": "mapping(uint256 => struct Program)", - "numberOfBytes": "32", - "value": "t_struct(Program)14108_storage" - }, - "t_mapping(t_userDefinedValueType(Token18)4011,t_userDefinedValueType(UFixed18)3224)": { - "encoding": "mapping", - "key": "t_userDefinedValueType(Token18)4011", - "label": "mapping(Token18 => UFixed18)", - "numberOfBytes": "32", - "value": "t_userDefinedValueType(UFixed18)3224" - }, - "t_struct(Position)16613_storage": { - "encoding": "inplace", - "label": "struct Position", - "members": [ - { - "astId": 16608, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "maker", - "offset": 0, - "slot": "0", - "type": "t_userDefinedValueType(UFixed18)3224" - }, - { - "astId": 16612, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "taker", - "offset": 0, - "slot": "1", - "type": "t_userDefinedValueType(UFixed18)3224" - } - ], - "numberOfBytes": "64" - }, - "t_struct(ProductManager)13513_storage": { - "encoding": "inplace", - "label": "struct ProductManager", - "members": [ - { - "astId": 13491, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "programInfos", - "offset": 0, - "slot": "0", - "type": "t_array(t_struct(ProgramInfo)17434_storage)dyn_storage" - }, - { - "astId": 13497, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "programs", - "offset": 0, - "slot": "1", - "type": "t_mapping(t_uint256,t_struct(Program)14108_storage)" - }, - { - "astId": 13501, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "activePrograms", - "offset": 0, - "slot": "2", - "type": "t_struct(UintSet)10257_storage" - }, - { - "astId": 13507, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "activeProgramsFor", - "offset": 0, - "slot": "4", - "type": "t_mapping(t_address,t_struct(UintSet)10257_storage)" - }, - { - "astId": 13512, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "nextProgramFor", - "offset": 0, - "slot": "5", - "type": "t_mapping(t_address,t_uint256)" - } - ], - "numberOfBytes": "192" - }, - "t_struct(Program)14108_storage": { - "encoding": "inplace", - "label": "struct Program", - "members": [ - { - "astId": 14097, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "settled", - "offset": 0, - "slot": "0", - "type": "t_mapping(t_address,t_userDefinedValueType(UFixed18)3224)" - }, - { - "astId": 14101, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "available", - "offset": 0, - "slot": "1", - "type": "t_userDefinedValueType(UFixed18)3224" - }, - { - "astId": 14104, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "versionStarted", - "offset": 0, - "slot": "2", - "type": "t_uint256" - }, - { - "astId": 14107, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "versionComplete", - "offset": 0, - "slot": "3", - "type": "t_uint256" - } - ], - "numberOfBytes": "128" - }, - "t_struct(ProgramInfo)17434_storage": { - "encoding": "inplace", - "label": "struct ProgramInfo", - "members": [ - { - "astId": 17419, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "coordinatorId", - "offset": 0, - "slot": "0", - "type": "t_uint256" - }, - { - "astId": 17423, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "amount", - "offset": 0, - "slot": "1", - "type": "t_struct(Position)16613_storage" - }, - { - "astId": 17426, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "start", - "offset": 0, - "slot": "3", - "type": "t_uint256" - }, - { - "astId": 17429, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "duration", - "offset": 0, - "slot": "4", - "type": "t_uint256" - }, - { - "astId": 17433, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "token", - "offset": 0, - "slot": "5", - "type": "t_userDefinedValueType(Token18)4011" - } - ], - "numberOfBytes": "192" - }, - "t_struct(Set)9799_storage": { - "encoding": "inplace", - "label": "struct EnumerableSet.Set", - "members": [ - { - "astId": 9794, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "_values", - "offset": 0, - "slot": "0", - "type": "t_array(t_bytes32)dyn_storage" - }, - { - "astId": 9798, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "_indexes", - "offset": 0, - "slot": "1", - "type": "t_mapping(t_bytes32,t_uint256)" - } - ], - "numberOfBytes": "64" - }, - "t_struct(UintSet)10257_storage": { - "encoding": "inplace", - "label": "struct EnumerableSet.UintSet", - "members": [ - { - "astId": 10256, - "contract": "contracts/incentivizer/Incentivizer.sol:Incentivizer", - "label": "_inner", - "offset": 0, - "slot": "0", - "type": "t_struct(Set)9799_storage" - } - ], - "numberOfBytes": "64" - }, - "t_uint256": { - "encoding": "inplace", - "label": "uint256", - "numberOfBytes": "32" - }, - "t_userDefinedValueType(Token18)4011": { - "encoding": "inplace", - "label": "Token18", - "numberOfBytes": "20" - }, - "t_userDefinedValueType(UFixed18)3224": { - "encoding": "inplace", - "label": "UFixed18", - "numberOfBytes": "32" - } - } - } -} diff --git a/packages/perennial/deployments/kovan/Incentivizer_Proxy.json b/packages/perennial/deployments/kovan/Incentivizer_Proxy.json deleted file mode 100644 index 282c8e821..000000000 --- a/packages/perennial/deployments/kovan/Incentivizer_Proxy.json +++ /dev/null @@ -1,229 +0,0 @@ -{ - "address": "0xEeBeFCb9184297025dC71949012997AD853F22F0", - "abi": [ - { - "inputs": [ - { - "internalType": "address", - "name": "_logic", - "type": "address" - }, - { - "internalType": "address", - "name": "admin_", - "type": "address" - }, - { - "internalType": "bytes", - "name": "_data", - "type": "bytes" - } - ], - "stateMutability": "payable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "previousAdmin", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "newAdmin", - "type": "address" - } - ], - "name": "AdminChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "beacon", - "type": "address" - } - ], - "name": "BeaconUpgraded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "implementation", - "type": "address" - } - ], - "name": "Upgraded", - "type": "event" - }, - { - "stateMutability": "payable", - "type": "fallback" - }, - { - "inputs": [], - "name": "admin", - "outputs": [ - { - "internalType": "address", - "name": "admin_", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newAdmin", - "type": "address" - } - ], - "name": "changeAdmin", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "implementation", - "outputs": [ - { - "internalType": "address", - "name": "implementation_", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newImplementation", - "type": "address" - } - ], - "name": "upgradeTo", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newImplementation", - "type": "address" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "upgradeToAndCall", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "stateMutability": "payable", - "type": "receive" - } - ], - "transactionHash": "0x69b6d7205e174c73a8d6c42cf12e2507b1bfe64988680afdc524b8ee9346ed27", - "receipt": { - "to": null, - "from": "0x66a7fDB96C583c59597de16d8b2B989231415339", - "contractAddress": "0xEeBeFCb9184297025dC71949012997AD853F22F0", - "transactionIndex": 0, - "gasUsed": "690597", - "logsBloom": "0x00000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000200000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000800010000000000400000000000000000000000000000000000000000000000000400000000020000000000002000000000000000000000400002000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xe5fe4b34bc201c58678816202927ec28ca4b404e056dae71a9ded4e7e4348b87", - "transactionHash": "0x69b6d7205e174c73a8d6c42cf12e2507b1bfe64988680afdc524b8ee9346ed27", - "logs": [ - { - "transactionIndex": 0, - "blockNumber": 33203742, - "transactionHash": "0x69b6d7205e174c73a8d6c42cf12e2507b1bfe64988680afdc524b8ee9346ed27", - "address": "0xEeBeFCb9184297025dC71949012997AD853F22F0", - "topics": [ - "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x00000000000000000000000038934b335543246a49f82dbf364c37bbc877d9f2" - ], - "data": "0x", - "logIndex": 0, - "blockHash": "0xe5fe4b34bc201c58678816202927ec28ca4b404e056dae71a9ded4e7e4348b87" - }, - { - "transactionIndex": 0, - "blockNumber": 33203742, - "transactionHash": "0x69b6d7205e174c73a8d6c42cf12e2507b1bfe64988680afdc524b8ee9346ed27", - "address": "0xEeBeFCb9184297025dC71949012997AD853F22F0", - "topics": ["0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f"], - "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffe829f928cb8c07961bfff04512ac0749d65d27", - "logIndex": 1, - "blockHash": "0xe5fe4b34bc201c58678816202927ec28ca4b404e056dae71a9ded4e7e4348b87" - } - ], - "blockNumber": 33203742, - "cumulativeGasUsed": "690597", - "status": 1, - "byzantium": true - }, - "args": ["0x38934b335543246A49F82dbf364C37BbC877d9f2", "0xfFE829F928Cb8C07961bfFF04512ac0749d65d27", "0x"], - "numDeployments": 1, - "solcInputHash": "dd52f03d8fef7833844e4ba864fd9fba", - "metadata": "{\"compiler\":{\"version\":\"0.8.15+commit.e14f2714\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // 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\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\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 ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\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(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\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 /**\\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 {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x60806040526040516200112838038062001128833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b600080516020620010e1833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b600080516020620010c183398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b6200028c1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e98383604051806060016040528060278152602001620011016027913962000381565b9392505050565b60006200021a600080516020620010c183398151915260001b6200046760201b6200022e1760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd600080516020620010c183398151915260001b6200046760201b6200022e1760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b620002b81760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd600080516020620010e183398151915260001b6200046760201b6200022e1760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610a2980620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b610090366004610895565b610135565b61006b6100a33660046108b0565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b610101366004610895565b610231565b34801561011257600080fd5b506100bd61025e565b6101236102d4565b61013361012e6103ab565b6103b5565b565b61013d6103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481604051806020016040528060008152506000610419565b50565b61017461011b565b6101876103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610419915050565b505050565b6101e661011b565b60006101fd6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103ab565b905090565b61022e61011b565b90565b6102396103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481610444565b60006102686103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103d9565b60606102b183836040518060600160405280602781526020016109cd602791396104a5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6102dc6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102216105cd565b3660008037600080366000845af43d6000803e8080156103d4573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b610422836105f5565b60008251118061042f5750805b156101e65761043e838361028c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61046d6103d9565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161017481610642565b606073ffffffffffffffffffffffffffffffffffffffff84163b61054b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103a2565b6000808573ffffffffffffffffffffffffffffffffffffffff1685604051610573919061095f565b600060405180830381855af49150503d80600081146105ae576040519150601f19603f3d011682016040523d82523d6000602084013e6105b3565b606091505b50915091506105c382828661074e565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103fd565b6105fe816107a1565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff81166106e5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103a2565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060831561075d5750816102b1565b82511561076d5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a2919061097b565b73ffffffffffffffffffffffffffffffffffffffff81163b610845576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103a2565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610708565b803573ffffffffffffffffffffffffffffffffffffffff8116811461089057600080fd5b919050565b6000602082840312156108a757600080fd5b6102b18261086c565b6000806000604084860312156108c557600080fd5b6108ce8461086c565b9250602084013567ffffffffffffffff808211156108eb57600080fd5b818601915086601f8301126108ff57600080fd5b81358181111561090e57600080fd5b87602082850101111561092057600080fd5b6020830194508093505050509250925092565b60005b8381101561094e578181015183820152602001610936565b8381111561043e5750506000910152565b60008251610971818460208701610933565b9190910192915050565b602081526000825180602084015261099a816040850160208701610933565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a4b930408c511c08d53f1ec84bb13fe259938b06e5d586d6adc4fc27200abe6c64736f6c634300080f0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", - "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b610090366004610895565b610135565b61006b6100a33660046108b0565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b610101366004610895565b610231565b34801561011257600080fd5b506100bd61025e565b6101236102d4565b61013361012e6103ab565b6103b5565b565b61013d6103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481604051806020016040528060008152506000610419565b50565b61017461011b565b6101876103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610419915050565b505050565b6101e661011b565b60006101fd6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103ab565b905090565b61022e61011b565b90565b6102396103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481610444565b60006102686103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103d9565b60606102b183836040518060600160405280602781526020016109cd602791396104a5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6102dc6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102216105cd565b3660008037600080366000845af43d6000803e8080156103d4573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b610422836105f5565b60008251118061042f5750805b156101e65761043e838361028c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61046d6103d9565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161017481610642565b606073ffffffffffffffffffffffffffffffffffffffff84163b61054b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103a2565b6000808573ffffffffffffffffffffffffffffffffffffffff1685604051610573919061095f565b600060405180830381855af49150503d80600081146105ae576040519150601f19603f3d011682016040523d82523d6000602084013e6105b3565b606091505b50915091506105c382828661074e565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103fd565b6105fe816107a1565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff81166106e5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103a2565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060831561075d5750816102b1565b82511561076d5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a2919061097b565b73ffffffffffffffffffffffffffffffffffffffff81163b610845576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103a2565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610708565b803573ffffffffffffffffffffffffffffffffffffffff8116811461089057600080fd5b919050565b6000602082840312156108a757600080fd5b6102b18261086c565b6000806000604084860312156108c557600080fd5b6108ce8461086c565b9250602084013567ffffffffffffffff808211156108eb57600080fd5b818601915086601f8301126108ff57600080fd5b81358181111561090e57600080fd5b87602082850101111561092057600080fd5b6020830194508093505050509250925092565b60005b8381101561094e578181015183820152602001610936565b8381111561043e5750506000910152565b60008251610971818460208701610933565b9190910192915050565b602081526000825180602084015261099a816040850160208701610933565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a4b930408c511c08d53f1ec84bb13fe259938b06e5d586d6adc4fc27200abe6c64736f6c634300080f0033", - "devdoc": { - "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", - "kind": "dev", - "methods": { - "admin()": { - "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" - }, - "changeAdmin(address)": { - "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." - }, - "constructor": { - "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." - }, - "implementation()": { - "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" - }, - "upgradeTo(address)": { - "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." - }, - "upgradeToAndCall(address,bytes)": { - "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." - } - }, - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": {}, - "version": 1 - }, - "storageLayout": { - "storage": [], - "types": null - } -} diff --git a/packages/perennial/deployments/kovan/PerennialLens_V01.json b/packages/perennial/deployments/kovan/PerennialLens_V01.json deleted file mode 100644 index 2c989292e..000000000 --- a/packages/perennial/deployments/kovan/PerennialLens_V01.json +++ /dev/null @@ -1,2246 +0,0 @@ -{ - "address": "0xCe2a0EC283be5AB085F57f4d398E0922BE0F7254", - "abi": [ - { - "inputs": [ - { - "internalType": "contract IController", - "name": "_controller", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "uint256[]", - "name": "versions", - "type": "uint256[]" - } - ], - "name": "atVersions", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "version", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - }, - { - "internalType": "Fixed18", - "name": "price", - "type": "int256" - } - ], - "internalType": "struct IOracleProvider.OracleVersion[]", - "name": "prices", - "type": "tuple[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "collateral", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "collateral", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "collateral", - "outputs": [ - { - "internalType": "contract ICollateral", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "controller", - "outputs": [ - { - "internalType": "contract IController", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "dailyRate", - "outputs": [ - { - "internalType": "Fixed18", - "name": "", - "type": "int256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "exposure", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "fees", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "fees", - "outputs": [ - { - "internalType": "UFixed18", - "name": "protocolFees", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "productFees", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "globalPosition", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "oracleVersion", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "openPosition", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "closePosition", - "type": "tuple" - } - ], - "internalType": "struct PrePosition", - "name": "", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "info", - "outputs": [ - { - "components": [ - { - "internalType": "string", - "name": "name", - "type": "string" - }, - { - "internalType": "string", - "name": "symbol", - "type": "string" - }, - { - "components": [ - { - "internalType": "enum PayoffDefinitionLib.PayoffType", - "name": "payoffType", - "type": "uint8" - }, - { - "internalType": "enum PayoffDefinitionLib.PayoffDirection", - "name": "payoffDirection", - "type": "uint8" - }, - { - "internalType": "bytes30", - "name": "data", - "type": "bytes30" - } - ], - "internalType": "struct PayoffDefinition", - "name": "payoffDefinition", - "type": "tuple" - }, - { - "internalType": "contract IOracleProvider", - "name": "oracle", - "type": "address" - }, - { - "internalType": "UFixed18", - "name": "maintenance", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "fundingFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "makerFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "takerFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "makerLimit", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "PackedFixed18", - "name": "minRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "maxRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "targetRate", - "type": "int128" - }, - { - "internalType": "PackedUFixed18", - "name": "targetUtilization", - "type": "uint128" - } - ], - "internalType": "struct JumpRateUtilizationCurve", - "name": "utilizationCurve", - "type": "tuple" - } - ], - "internalType": "struct IProduct.ProductInfo", - "name": "_info", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "latestVersion", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "version", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - }, - { - "internalType": "Fixed18", - "name": "price", - "type": "int256" - } - ], - "internalType": "struct IOracleProvider.OracleVersion", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "liquidatable", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "liquidating", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "maintenance", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "UFixed18", - "name": "positionSize", - "type": "uint256" - } - ], - "name": "maintenanceRequired", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "openInterest", - "outputs": [ - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "openInterest", - "outputs": [ - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "position", - "outputs": [ - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "position", - "outputs": [ - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "pre", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "oracleVersion", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "openPosition", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "closePosition", - "type": "tuple" - } - ], - "internalType": "struct PrePosition", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "pre", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "oracleVersion", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "openPosition", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "closePosition", - "type": "tuple" - } - ], - "internalType": "struct PrePosition", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "rate", - "outputs": [ - { - "internalType": "Fixed18", - "name": "", - "type": "int256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "shortfall", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "snapshot", - "outputs": [ - { - "components": [ - { - "internalType": "address", - "name": "productAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "userAddress", - "type": "address" - }, - { - "internalType": "UFixed18", - "name": "collateral", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "maintenance", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "uint256", - "name": "oracleVersion", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "openPosition", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "closePosition", - "type": "tuple" - } - ], - "internalType": "struct PrePosition", - "name": "pre", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "position", - "type": "tuple" - }, - { - "internalType": "bool", - "name": "liquidatable", - "type": "bool" - }, - { - "internalType": "bool", - "name": "liquidating", - "type": "bool" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "openInterest", - "type": "tuple" - }, - { - "internalType": "UFixed18", - "name": "fees", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "exposure", - "type": "uint256" - } - ], - "internalType": "struct IPerennialLens.UserProductSnapshot", - "name": "_snapshot", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "snapshot", - "outputs": [ - { - "components": [ - { - "components": [ - { - "internalType": "string", - "name": "name", - "type": "string" - }, - { - "internalType": "string", - "name": "symbol", - "type": "string" - }, - { - "components": [ - { - "internalType": "enum PayoffDefinitionLib.PayoffType", - "name": "payoffType", - "type": "uint8" - }, - { - "internalType": "enum PayoffDefinitionLib.PayoffDirection", - "name": "payoffDirection", - "type": "uint8" - }, - { - "internalType": "bytes30", - "name": "data", - "type": "bytes30" - } - ], - "internalType": "struct PayoffDefinition", - "name": "payoffDefinition", - "type": "tuple" - }, - { - "internalType": "contract IOracleProvider", - "name": "oracle", - "type": "address" - }, - { - "internalType": "UFixed18", - "name": "maintenance", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "fundingFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "makerFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "takerFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "makerLimit", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "PackedFixed18", - "name": "minRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "maxRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "targetRate", - "type": "int128" - }, - { - "internalType": "PackedUFixed18", - "name": "targetUtilization", - "type": "uint128" - } - ], - "internalType": "struct JumpRateUtilizationCurve", - "name": "utilizationCurve", - "type": "tuple" - } - ], - "internalType": "struct IProduct.ProductInfo", - "name": "productInfo", - "type": "tuple" - }, - { - "internalType": "address", - "name": "productAddress", - "type": "address" - }, - { - "internalType": "Fixed18", - "name": "rate", - "type": "int256" - }, - { - "internalType": "Fixed18", - "name": "dailyRate", - "type": "int256" - }, - { - "components": [ - { - "internalType": "uint256", - "name": "version", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - }, - { - "internalType": "Fixed18", - "name": "price", - "type": "int256" - } - ], - "internalType": "struct IOracleProvider.OracleVersion", - "name": "latestVersion", - "type": "tuple" - }, - { - "internalType": "UFixed18", - "name": "maintenance", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "collateral", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "shortfall", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "uint256", - "name": "oracleVersion", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "openPosition", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "closePosition", - "type": "tuple" - } - ], - "internalType": "struct PrePosition", - "name": "pre", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "position", - "type": "tuple" - }, - { - "internalType": "UFixed18", - "name": "productFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "protocolFee", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "openInterest", - "type": "tuple" - } - ], - "internalType": "struct IPerennialLens.ProductSnapshot", - "name": "_snapshot", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct[]", - "name": "productAddresses", - "type": "address[]" - } - ], - "name": "snapshots", - "outputs": [ - { - "components": [ - { - "internalType": "address", - "name": "productAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "userAddress", - "type": "address" - }, - { - "internalType": "UFixed18", - "name": "collateral", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "maintenance", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "uint256", - "name": "oracleVersion", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "openPosition", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "closePosition", - "type": "tuple" - } - ], - "internalType": "struct PrePosition", - "name": "pre", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "position", - "type": "tuple" - }, - { - "internalType": "bool", - "name": "liquidatable", - "type": "bool" - }, - { - "internalType": "bool", - "name": "liquidating", - "type": "bool" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "openInterest", - "type": "tuple" - }, - { - "internalType": "UFixed18", - "name": "fees", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "exposure", - "type": "uint256" - } - ], - "internalType": "struct IPerennialLens.UserProductSnapshot[]", - "name": "_snapshots", - "type": "tuple[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct[]", - "name": "productAddresses", - "type": "address[]" - } - ], - "name": "snapshots", - "outputs": [ - { - "components": [ - { - "components": [ - { - "internalType": "string", - "name": "name", - "type": "string" - }, - { - "internalType": "string", - "name": "symbol", - "type": "string" - }, - { - "components": [ - { - "internalType": "enum PayoffDefinitionLib.PayoffType", - "name": "payoffType", - "type": "uint8" - }, - { - "internalType": "enum PayoffDefinitionLib.PayoffDirection", - "name": "payoffDirection", - "type": "uint8" - }, - { - "internalType": "bytes30", - "name": "data", - "type": "bytes30" - } - ], - "internalType": "struct PayoffDefinition", - "name": "payoffDefinition", - "type": "tuple" - }, - { - "internalType": "contract IOracleProvider", - "name": "oracle", - "type": "address" - }, - { - "internalType": "UFixed18", - "name": "maintenance", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "fundingFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "makerFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "takerFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "makerLimit", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "PackedFixed18", - "name": "minRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "maxRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "targetRate", - "type": "int128" - }, - { - "internalType": "PackedUFixed18", - "name": "targetUtilization", - "type": "uint128" - } - ], - "internalType": "struct JumpRateUtilizationCurve", - "name": "utilizationCurve", - "type": "tuple" - } - ], - "internalType": "struct IProduct.ProductInfo", - "name": "productInfo", - "type": "tuple" - }, - { - "internalType": "address", - "name": "productAddress", - "type": "address" - }, - { - "internalType": "Fixed18", - "name": "rate", - "type": "int256" - }, - { - "internalType": "Fixed18", - "name": "dailyRate", - "type": "int256" - }, - { - "components": [ - { - "internalType": "uint256", - "name": "version", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - }, - { - "internalType": "Fixed18", - "name": "price", - "type": "int256" - } - ], - "internalType": "struct IOracleProvider.OracleVersion", - "name": "latestVersion", - "type": "tuple" - }, - { - "internalType": "UFixed18", - "name": "maintenance", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "collateral", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "shortfall", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "uint256", - "name": "oracleVersion", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "openPosition", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "closePosition", - "type": "tuple" - } - ], - "internalType": "struct PrePosition", - "name": "pre", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "position", - "type": "tuple" - }, - { - "internalType": "UFixed18", - "name": "productFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "protocolFee", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "openInterest", - "type": "tuple" - } - ], - "internalType": "struct IPerennialLens.ProductSnapshot[]", - "name": "_snapshots", - "type": "tuple[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "unclaimedIncentiveRewards", - "outputs": [ - { - "internalType": "Token18[]", - "name": "tokens", - "type": "address[]" - }, - { - "internalType": "UFixed18[]", - "name": "amounts", - "type": "uint256[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - }, - { - "internalType": "uint256[]", - "name": "programIds", - "type": "uint256[]" - } - ], - "name": "unclaimedIncentiveRewards", - "outputs": [ - { - "internalType": "Token18[]", - "name": "tokens", - "type": "address[]" - }, - { - "internalType": "UFixed18[]", - "name": "amounts", - "type": "uint256[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "userPosition", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "oracleVersion", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "openPosition", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "closePosition", - "type": "tuple" - } - ], - "internalType": "struct PrePosition", - "name": "", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "function" - } - ], - "transactionHash": "0x9ad7b0b825fbc79c082f3dead380bb63ca7113803df5a8db98567efbc3814770", - "receipt": { - "to": null, - "from": "0x66a7fdb96c583c59597de16d8b2b989231415339", - "contractAddress": "0x68f680607a5c32cab860f84f5f5e9f9497f66535", - "transactionIndex": "0x0", - "gasUsed": "0x4d5b67", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x19b97f05a225cb3ec4f8718544af9051965b7ea09c165b4aa09a67ee932cb5e9", - "transactionHash": "0x55e7b2d656159c75187e024ea14a7390eb9e4295ef7e2301e9a0baba6f53d1d3", - "logs": [], - "blockNumber": "0x2057456", - "cumulativeGasUsed": "0x4d5b67", - "status": "0x1" - }, - "args": ["0x1927DE7c9765Ae74050D1d0aa8BB0e93D737F579"], - "numDeployments": 1, - "solcInputHash": "dd0d601ac153d6a2cb60f335fa990f18", - "metadata": "{\"compiler\":{\"version\":\"0.8.15+commit.e14f2714\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract IController\",\"name\":\"_controller\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"versions\",\"type\":\"uint256[]\"}],\"name\":\"atVersions\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"},{\"internalType\":\"Fixed18\",\"name\":\"price\",\"type\":\"int256\"}],\"internalType\":\"struct IOracleProvider.OracleVersion[]\",\"name\":\"prices\",\"type\":\"tuple[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"collateral\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"collateral\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"collateral\",\"outputs\":[{\"internalType\":\"contract ICollateral\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"controller\",\"outputs\":[{\"internalType\":\"contract IController\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"dailyRate\",\"outputs\":[{\"internalType\":\"Fixed18\",\"name\":\"\",\"type\":\"int256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"exposure\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"fees\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"fees\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"protocolFees\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"productFees\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"globalPosition\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"oracleVersion\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"openPosition\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"closePosition\",\"type\":\"tuple\"}],\"internalType\":\"struct PrePosition\",\"name\":\"\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"info\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"},{\"components\":[{\"internalType\":\"enum PayoffDefinitionLib.PayoffType\",\"name\":\"payoffType\",\"type\":\"uint8\"},{\"internalType\":\"enum PayoffDefinitionLib.PayoffDirection\",\"name\":\"payoffDirection\",\"type\":\"uint8\"},{\"internalType\":\"bytes30\",\"name\":\"data\",\"type\":\"bytes30\"}],\"internalType\":\"struct PayoffDefinition\",\"name\":\"payoffDefinition\",\"type\":\"tuple\"},{\"internalType\":\"contract IOracleProvider\",\"name\":\"oracle\",\"type\":\"address\"},{\"internalType\":\"UFixed18\",\"name\":\"maintenance\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"fundingFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"makerFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"takerFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"makerLimit\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"PackedFixed18\",\"name\":\"minRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"maxRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"targetRate\",\"type\":\"int128\"},{\"internalType\":\"PackedUFixed18\",\"name\":\"targetUtilization\",\"type\":\"uint128\"}],\"internalType\":\"struct JumpRateUtilizationCurve\",\"name\":\"utilizationCurve\",\"type\":\"tuple\"}],\"internalType\":\"struct IProduct.ProductInfo\",\"name\":\"_info\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"latestVersion\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"},{\"internalType\":\"Fixed18\",\"name\":\"price\",\"type\":\"int256\"}],\"internalType\":\"struct IOracleProvider.OracleVersion\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"liquidatable\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"maintenance\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"UFixed18\",\"name\":\"positionSize\",\"type\":\"uint256\"}],\"name\":\"maintenanceRequired\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"openInterest\",\"outputs\":[{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"openInterest\",\"outputs\":[{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"position\",\"outputs\":[{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"position\",\"outputs\":[{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"pre\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"oracleVersion\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"openPosition\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"closePosition\",\"type\":\"tuple\"}],\"internalType\":\"struct PrePosition\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"pre\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"oracleVersion\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"openPosition\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"closePosition\",\"type\":\"tuple\"}],\"internalType\":\"struct PrePosition\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"rate\",\"outputs\":[{\"internalType\":\"Fixed18\",\"name\":\"\",\"type\":\"int256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"shortfall\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"snapshot\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"productAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"},{\"internalType\":\"UFixed18\",\"name\":\"collateral\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"maintenance\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"oracleVersion\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"openPosition\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"closePosition\",\"type\":\"tuple\"}],\"internalType\":\"struct PrePosition\",\"name\":\"pre\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"position\",\"type\":\"tuple\"},{\"internalType\":\"bool\",\"name\":\"liquidatable\",\"type\":\"bool\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"openInterest\",\"type\":\"tuple\"},{\"internalType\":\"UFixed18\",\"name\":\"fees\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"exposure\",\"type\":\"uint256\"}],\"internalType\":\"struct IPerennialLens.UserProductSnapshot\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"snapshot\",\"outputs\":[{\"components\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"},{\"components\":[{\"internalType\":\"enum PayoffDefinitionLib.PayoffType\",\"name\":\"payoffType\",\"type\":\"uint8\"},{\"internalType\":\"enum PayoffDefinitionLib.PayoffDirection\",\"name\":\"payoffDirection\",\"type\":\"uint8\"},{\"internalType\":\"bytes30\",\"name\":\"data\",\"type\":\"bytes30\"}],\"internalType\":\"struct PayoffDefinition\",\"name\":\"payoffDefinition\",\"type\":\"tuple\"},{\"internalType\":\"contract IOracleProvider\",\"name\":\"oracle\",\"type\":\"address\"},{\"internalType\":\"UFixed18\",\"name\":\"maintenance\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"fundingFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"makerFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"takerFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"makerLimit\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"PackedFixed18\",\"name\":\"minRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"maxRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"targetRate\",\"type\":\"int128\"},{\"internalType\":\"PackedUFixed18\",\"name\":\"targetUtilization\",\"type\":\"uint128\"}],\"internalType\":\"struct JumpRateUtilizationCurve\",\"name\":\"utilizationCurve\",\"type\":\"tuple\"}],\"internalType\":\"struct IProduct.ProductInfo\",\"name\":\"productInfo\",\"type\":\"tuple\"},{\"internalType\":\"address\",\"name\":\"productAddress\",\"type\":\"address\"},{\"internalType\":\"Fixed18\",\"name\":\"rate\",\"type\":\"int256\"},{\"internalType\":\"Fixed18\",\"name\":\"dailyRate\",\"type\":\"int256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"},{\"internalType\":\"Fixed18\",\"name\":\"price\",\"type\":\"int256\"}],\"internalType\":\"struct IOracleProvider.OracleVersion\",\"name\":\"latestVersion\",\"type\":\"tuple\"},{\"internalType\":\"UFixed18\",\"name\":\"maintenance\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"collateral\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"shortfall\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"oracleVersion\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"openPosition\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"closePosition\",\"type\":\"tuple\"}],\"internalType\":\"struct PrePosition\",\"name\":\"pre\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"position\",\"type\":\"tuple\"},{\"internalType\":\"UFixed18\",\"name\":\"productFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"protocolFee\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"openInterest\",\"type\":\"tuple\"}],\"internalType\":\"struct IPerennialLens.ProductSnapshot\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct[]\",\"name\":\"productAddresses\",\"type\":\"address[]\"}],\"name\":\"snapshots\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"productAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"},{\"internalType\":\"UFixed18\",\"name\":\"collateral\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"maintenance\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"oracleVersion\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"openPosition\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"closePosition\",\"type\":\"tuple\"}],\"internalType\":\"struct PrePosition\",\"name\":\"pre\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"position\",\"type\":\"tuple\"},{\"internalType\":\"bool\",\"name\":\"liquidatable\",\"type\":\"bool\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"openInterest\",\"type\":\"tuple\"},{\"internalType\":\"UFixed18\",\"name\":\"fees\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"exposure\",\"type\":\"uint256\"}],\"internalType\":\"struct IPerennialLens.UserProductSnapshot[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct[]\",\"name\":\"productAddresses\",\"type\":\"address[]\"}],\"name\":\"snapshots\",\"outputs\":[{\"components\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"},{\"components\":[{\"internalType\":\"enum PayoffDefinitionLib.PayoffType\",\"name\":\"payoffType\",\"type\":\"uint8\"},{\"internalType\":\"enum PayoffDefinitionLib.PayoffDirection\",\"name\":\"payoffDirection\",\"type\":\"uint8\"},{\"internalType\":\"bytes30\",\"name\":\"data\",\"type\":\"bytes30\"}],\"internalType\":\"struct PayoffDefinition\",\"name\":\"payoffDefinition\",\"type\":\"tuple\"},{\"internalType\":\"contract IOracleProvider\",\"name\":\"oracle\",\"type\":\"address\"},{\"internalType\":\"UFixed18\",\"name\":\"maintenance\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"fundingFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"makerFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"takerFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"makerLimit\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"PackedFixed18\",\"name\":\"minRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"maxRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"targetRate\",\"type\":\"int128\"},{\"internalType\":\"PackedUFixed18\",\"name\":\"targetUtilization\",\"type\":\"uint128\"}],\"internalType\":\"struct JumpRateUtilizationCurve\",\"name\":\"utilizationCurve\",\"type\":\"tuple\"}],\"internalType\":\"struct IProduct.ProductInfo\",\"name\":\"productInfo\",\"type\":\"tuple\"},{\"internalType\":\"address\",\"name\":\"productAddress\",\"type\":\"address\"},{\"internalType\":\"Fixed18\",\"name\":\"rate\",\"type\":\"int256\"},{\"internalType\":\"Fixed18\",\"name\":\"dailyRate\",\"type\":\"int256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"},{\"internalType\":\"Fixed18\",\"name\":\"price\",\"type\":\"int256\"}],\"internalType\":\"struct IOracleProvider.OracleVersion\",\"name\":\"latestVersion\",\"type\":\"tuple\"},{\"internalType\":\"UFixed18\",\"name\":\"maintenance\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"collateral\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"shortfall\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"oracleVersion\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"openPosition\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"closePosition\",\"type\":\"tuple\"}],\"internalType\":\"struct PrePosition\",\"name\":\"pre\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"position\",\"type\":\"tuple\"},{\"internalType\":\"UFixed18\",\"name\":\"productFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"protocolFee\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"openInterest\",\"type\":\"tuple\"}],\"internalType\":\"struct IPerennialLens.ProductSnapshot[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"unclaimedIncentiveRewards\",\"outputs\":[{\"internalType\":\"Token18[]\",\"name\":\"tokens\",\"type\":\"address[]\"},{\"internalType\":\"UFixed18[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"programIds\",\"type\":\"uint256[]\"}],\"name\":\"unclaimedIncentiveRewards\",\"outputs\":[{\"internalType\":\"Token18[]\",\"name\":\"tokens\",\"type\":\"address[]\"},{\"internalType\":\"UFixed18[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"userPosition\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"oracleVersion\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"openPosition\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"closePosition\",\"type\":\"tuple\"}],\"internalType\":\"struct PrePosition\",\"name\":\"\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"atVersions(address,uint256[])\":{\"params\":{\"product\":\"Product address\",\"versions\":\"Oracle versions to query\"},\"returns\":{\"prices\":\"Product prices at specified versions\"}},\"collateral()\":{\"returns\":{\"_0\":\"Protocol collateral address\"}},\"collateral(address)\":{\"params\":{\"product\":\"Product address\"},\"returns\":{\"_0\":\"Total collateral for product\"}},\"collateral(address,address)\":{\"params\":{\"account\":\"Account address\",\"product\":\"Product address\"},\"returns\":{\"_0\":\"User deposited collateral for product\"}},\"constructor\":{\"params\":{\"_controller\":\"Protocol controller address\"}},\"dailyRate(address)\":{\"params\":{\"product\":\"Product address\"},\"returns\":{\"_0\":\"Product current funding extrapolated to a daily rate\"}},\"exposure(address,address)\":{\"params\":{\"account\":\"Account address\",\"product\":\"Product address\"},\"returns\":{\"_0\":\"User's exposure (openInterest * utilization) after settle\"}},\"fees(address)\":{\"params\":{\"product\":\"Product address\"},\"returns\":{\"productFees\":\"fees accrued by the product owner\",\"protocolFees\":\"fees accrued by the protocol\"}},\"fees(address,address)\":{\"params\":{\"account\":\"Account address\",\"product\":\"Product address\"},\"returns\":{\"_0\":\"sum of all fees accrued by the account\"}},\"globalPosition(address)\":{\"params\":{\"product\":\"Product address\"},\"returns\":{\"_0\":\"Product pre-position\",\"_1\":\"Product position\"}},\"info(address)\":{\"params\":{\"product\":\"Product address\"},\"returns\":{\"_info\":\"of the product\"}},\"latestVersion(address)\":{\"params\":{\"product\":\"Product address\"},\"returns\":{\"_0\":\"Product latest price\"}},\"liquidatable(address,address)\":{\"params\":{\"account\":\"Account address\",\"product\":\"Product address\"},\"returns\":{\"_0\":\"Whether or not the user's position eligible to be liquidated\"}},\"maintenance(address,address)\":{\"params\":{\"account\":\"Account address\",\"product\":\"Product address\"},\"returns\":{\"_0\":\"Maximum of user maintenance, and maintenanceNext\"}},\"maintenanceRequired(address,address,uint256)\":{\"params\":{\"account\":\"Account address\",\"positionSize\":\"size of position for maintenance calculation\",\"product\":\"Product address\"},\"returns\":{\"_0\":\"Maintenance required for position in product\"}},\"name(address)\":{\"params\":{\"product\":\"Product address\"},\"returns\":{\"_0\":\"Name of the product\"}},\"openInterest(address)\":{\"params\":{\"product\":\"Product address\"},\"returns\":{\"_0\":\"Product maker and taker position multiplied by latest price after settle\"}},\"openInterest(address,address)\":{\"params\":{\"account\":\"Account address\",\"product\":\"Product address\"},\"returns\":{\"_0\":\"User's maker or taker position multiplied by latest price after settle\"}},\"position(address)\":{\"params\":{\"product\":\"Product address\"},\"returns\":{\"_0\":\"product position\"}},\"position(address,address)\":{\"params\":{\"account\":\"Account address\",\"product\":\"Product address\"},\"returns\":{\"_0\":\"User position\"}},\"pre(address)\":{\"params\":{\"product\":\"Product address\"},\"returns\":{\"_0\":\"Product pre-position\"}},\"pre(address,address)\":{\"params\":{\"account\":\"Account address\",\"product\":\"Product address\"},\"returns\":{\"_0\":\"User pre-position\"}},\"rate(address)\":{\"params\":{\"product\":\"Product address\"},\"returns\":{\"_0\":\"Product current funding rate\"}},\"shortfall(address)\":{\"params\":{\"product\":\"Product address\"},\"returns\":{\"_0\":\"Total shortfall for product\"}},\"snapshot(address)\":{\"params\":{\"product\":\"Product address\"},\"returns\":{\"_0\":\"Snapshot for the product after settle\"}},\"snapshot(address,address)\":{\"params\":{\"account\":\"User addresses\",\"product\":\"Product address\"},\"returns\":{\"_0\":\"UserSnapshot for the product after settle\"}},\"snapshots(address,address[])\":{\"params\":{\"account\":\"User addresses\",\"productAddresses\":\"Product addresses\"},\"returns\":{\"_0\":\"UserSnapshot for each product after settle\"}},\"snapshots(address[])\":{\"params\":{\"productAddresses\":\"Product addresses\"},\"returns\":{\"_0\":\"Snapshot for each product after settle\"}},\"symbol(address)\":{\"params\":{\"product\":\"Product address\"},\"returns\":{\"_0\":\"Symbol of the product\"}},\"unclaimedIncentiveRewards(address,address)\":{\"params\":{\"account\":\"Account address\",\"product\":\"Product address\"},\"returns\":{\"amounts\":\"Token amounts of unclaimed incentive rewards for given product\",\"tokens\":\"Token addresses of unclaimed incentive rewards for given product\"}},\"unclaimedIncentiveRewards(address,address,uint256[])\":{\"params\":{\"account\":\"Account address\",\"product\":\"Product address\",\"programIds\":\"Program IDs to query\"},\"returns\":{\"amounts\":\"Token amounts of unclaimed incentive rewards for given program IDs\",\"tokens\":\"Token addresses of unclaimed incentive rewards for given program IDs\"}},\"userPosition(address,address)\":{\"params\":{\"account\":\"Account address\",\"product\":\"Product address\"},\"returns\":{\"_0\":\"User pre-position\",\"_1\":\"User position\"}}},\"stateVariables\":{\"controller\":{\"return\":\"Protocol controller\",\"returns\":{\"_0\":\"Protocol controller\"}}},\"title\":\"Lens contract to conveniently pull protocol data\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"atVersions(address,uint256[])\":{\"notice\":\"Prices of product at specified versions after settle\"},\"collateral()\":{\"notice\":\"Protocol collateral address\"},\"collateral(address)\":{\"notice\":\"Product total collateral amount after settle\"},\"collateral(address,address)\":{\"notice\":\"User collateral amount for product after settle\"},\"controller()\":{\"notice\":\"Protocol controller\"},\"dailyRate(address)\":{\"notice\":\"Product funding extrapolated to a daily rate after settle\"},\"exposure(address,address)\":{\"notice\":\"User's exposure in product after settle\"},\"fees(address)\":{\"notice\":\"Fees accumulated by product and protocol treasuries after settle\"},\"fees(address,address)\":{\"notice\":\"Fees accumulated by account after settle\"},\"globalPosition(address)\":{\"notice\":\"Product pre-position and position after settle\"},\"info(address)\":{\"notice\":\"Returns the info of the provided `product`\"},\"latestVersion(address)\":{\"notice\":\"Current price of product after settle\"},\"liquidatable(address,address)\":{\"notice\":\"User liquidatble status for product after settle\"},\"maintenance(address,address)\":{\"notice\":\"User maintenance amount for product after settle\"},\"maintenanceRequired(address,address,uint256)\":{\"notice\":\"User's maintenance required for position size in product after settle\"},\"name(address)\":{\"notice\":\"Returns the name of the provided `product`\"},\"openInterest(address)\":{\"notice\":\"Product total open interest after settle\"},\"openInterest(address,address)\":{\"notice\":\"User's open interest in product after settle\"},\"position(address)\":{\"notice\":\"Product position after settle\"},\"position(address,address)\":{\"notice\":\"User position for product after settle\"},\"pre(address)\":{\"notice\":\"Product pre position after settle\"},\"pre(address,address)\":{\"notice\":\"User pre position for product after settle\"},\"rate(address)\":{\"notice\":\"Product funding rate after settle\"},\"shortfall(address)\":{\"notice\":\"Product total shortfall amount after settle\"},\"snapshot(address)\":{\"notice\":\"Returns the snapshot of the provided `product`\"},\"snapshot(address,address)\":{\"notice\":\"Returns the user snapshot for the provided `product`\"},\"snapshots(address,address[])\":{\"notice\":\"Returns the user snapshots for the provided `productAddresses`\"},\"snapshots(address[])\":{\"notice\":\"Returns the snapshots of the provided `productAddresses`\"},\"symbol(address)\":{\"notice\":\"Returns the symbol of the provided `product`\"},\"unclaimedIncentiveRewards(address,address)\":{\"notice\":\"User's unclaimed rewards for all programs for product after settle\"},\"unclaimedIncentiveRewards(address,address,uint256[])\":{\"notice\":\"User's unclaimed rewards for provided programs for product after settle\"},\"userPosition(address,address)\":{\"notice\":\"User pre-position and position for product after settle\"}},\"notice\":\"All functions should be called using `callStatic`\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/lens/PerennialLens.sol\":\"PerennialLens\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":false,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\n\\ninterface IOracleProvider {\\n /// @dev A singular oracle version with its corresponding data\\n struct OracleVersion {\\n /// @dev The iterative version\\n uint256 version;\\n\\n /// @dev the timestamp of the oracle update\\n uint256 timestamp;\\n\\n /// @dev The oracle price of the corresponding version\\n Fixed18 price;\\n }\\n\\n function sync() external returns (OracleVersion memory);\\n function currentVersion() external view returns (OracleVersion memory);\\n function atVersion(uint256 oracleVersion) external view returns (OracleVersion memory);\\n}\\n\",\"keccak256\":\"0xde0f20d468ba8b91addfc356e13f2c74a4dc8abe68be323942217c723775d9c1\",\"license\":\"Apache-2.0\"},\"@equilibria/root/curve/CurveMath.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"../number/types/UFixed18.sol\\\";\\nimport \\\"../number/types/Fixed18.sol\\\";\\n\\n/**\\n * @title CurveMath\\n * @notice Library for managing math operations for utilization curves.\\n */\\nlibrary CurveMath {\\n error CurveMathOutOfBoundsError();\\n\\n /**\\n * @notice Computes a linear interpolation between two points\\n * @param startX First point's x-coordinate\\n * @param startY First point's y-coordinate\\n * @param endX Second point's x-coordinate\\n * @param endY Second point's y-coordinate\\n * @param targetX x-coordinate to interpolate\\n * @return y-coordinate for `targetX` along the line from (`startX`, `startY`) -> (`endX`, `endY`)\\n */\\n function linearInterpolation(\\n UFixed18 startX,\\n Fixed18 startY,\\n UFixed18 endX,\\n Fixed18 endY,\\n UFixed18 targetX\\n ) internal pure returns (Fixed18) {\\n if (targetX.lt(startX) || targetX.gt(endX)) revert CurveMathOutOfBoundsError();\\n\\n UFixed18 xRange = endX.sub(startX);\\n Fixed18 yRange = endY.sub(startY);\\n UFixed18 xRatio = targetX.sub(startX).div(xRange);\\n return yRange.mul(Fixed18Lib.from(xRatio)).add(startY);\\n }\\n}\\n\",\"keccak256\":\"0x60d159f9ddf0dbe81124ecad58bba734b4cf82877637ff8d9d7f3e92f2da4ded\",\"license\":\"Apache-2.0\"},\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"../CurveMath.sol\\\";\\nimport \\\"../../number/types/PackedUFixed18.sol\\\";\\nimport \\\"../../number/types/PackedFixed18.sol\\\";\\n\\n/// @dev JumpRateUtilizationCurve type\\nstruct JumpRateUtilizationCurve {\\n PackedFixed18 minRate;\\n PackedFixed18 maxRate;\\n PackedFixed18 targetRate;\\n PackedUFixed18 targetUtilization;\\n}\\nusing JumpRateUtilizationCurveLib for JumpRateUtilizationCurve global;\\ntype JumpRateUtilizationCurveStorage is bytes32;\\nusing JumpRateUtilizationCurveStorageLib for JumpRateUtilizationCurveStorage global;\\n\\n/**\\n * @title JumpRateUtilizationCurveLib\\n * @notice Library for the Jump Rate utilization curve type\\n */\\nlibrary JumpRateUtilizationCurveLib {\\n /**\\n * @notice Computes the corresponding rate for a utilization ratio\\n * @param utilization The utilization ratio\\n * @return The corresponding rate\\n */\\n function compute(JumpRateUtilizationCurve memory self, UFixed18 utilization) internal pure returns (Fixed18) {\\n UFixed18 targetUtilization = self.targetUtilization.unpack();\\n if (utilization.lt(targetUtilization)) {\\n return CurveMath.linearInterpolation(\\n UFixed18Lib.ZERO,\\n self.minRate.unpack(),\\n targetUtilization,\\n self.targetRate.unpack(),\\n utilization\\n );\\n }\\n if (utilization.lt(UFixed18Lib.ONE)) {\\n return CurveMath.linearInterpolation(\\n targetUtilization,\\n self.targetRate.unpack(),\\n UFixed18Lib.ONE,\\n self.maxRate.unpack(),\\n utilization\\n );\\n }\\n return self.maxRate.unpack();\\n }\\n}\\n\\nlibrary JumpRateUtilizationCurveStorageLib {\\n function read(JumpRateUtilizationCurveStorage self) internal view returns (JumpRateUtilizationCurve memory) {\\n return _storagePointer(self);\\n }\\n\\n function store(JumpRateUtilizationCurveStorage self, JumpRateUtilizationCurve memory value) internal {\\n JumpRateUtilizationCurve storage storagePointer = _storagePointer(self);\\n\\n storagePointer.minRate = value.minRate;\\n storagePointer.maxRate = value.maxRate;\\n storagePointer.targetRate = value.targetRate;\\n storagePointer.targetUtilization = value.targetUtilization;\\n }\\n\\n function _storagePointer(JumpRateUtilizationCurveStorage self)\\n private pure returns (JumpRateUtilizationCurve storage pointer) {\\n assembly { pointer.slot := self }\\n }\\n}\",\"keccak256\":\"0xae202813874bc306d51b3dab8194c86f6483bb20bf1f673ddaee16aa8de567ff\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/Fixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SignedMath.sol\\\";\\nimport \\\"./UFixed18.sol\\\";\\nimport \\\"./PackedFixed18.sol\\\";\\n\\n/// @dev Fixed18 type\\ntype Fixed18 is int256;\\nusing Fixed18Lib for Fixed18 global;\\ntype Fixed18Storage is bytes32;\\nusing Fixed18StorageLib for Fixed18Storage global;\\n\\n/**\\n * @title Fixed18Lib\\n * @notice Library for the signed fixed-decimal type.\\n */\\nlibrary Fixed18Lib {\\n error Fixed18OverflowError(uint256 value);\\n error Fixed18PackingOverflowError(int256 value);\\n error Fixed18PackingUnderflowError(int256 value);\\n\\n int256 private constant BASE = 1e18;\\n Fixed18 public constant ZERO = Fixed18.wrap(0);\\n Fixed18 public constant ONE = Fixed18.wrap(BASE);\\n Fixed18 public constant NEG_ONE = Fixed18.wrap(-1 * BASE);\\n Fixed18 public constant MAX = Fixed18.wrap(type(int256).max);\\n Fixed18 public constant MIN = Fixed18.wrap(type(int256).min);\\n\\n /**\\n * @notice Creates a signed fixed-decimal from an unsigned fixed-decimal\\n * @param a Unsigned fixed-decimal\\n * @return New signed fixed-decimal\\n */\\n function from(UFixed18 a) internal pure returns (Fixed18) {\\n uint256 value = UFixed18.unwrap(a);\\n if (value > uint256(type(int256).max)) revert Fixed18OverflowError(value);\\n return Fixed18.wrap(int256(value));\\n }\\n\\n /**\\n * @notice Creates a signed fixed-decimal from a sign and an unsigned fixed-decimal\\n * @param s Sign\\n * @param m Unsigned fixed-decimal magnitude\\n * @return New signed fixed-decimal\\n */\\n function from(int256 s, UFixed18 m) internal pure returns (Fixed18) {\\n if (s > 0) return from(m);\\n if (s < 0) return Fixed18.wrap(-1 * Fixed18.unwrap(from(m)));\\n return ZERO;\\n }\\n\\n /**\\n * @notice Creates a signed fixed-decimal from a signed integer\\n * @param a Signed number\\n * @return New signed fixed-decimal\\n */\\n function from(int256 a) internal pure returns (Fixed18) {\\n return Fixed18.wrap(a * BASE);\\n }\\n\\n /**\\n * @notice Creates a packed signed fixed-decimal from an signed fixed-decimal\\n * @param a signed fixed-decimal\\n * @return New packed signed fixed-decimal\\n */\\n function pack(Fixed18 a) internal pure returns (PackedFixed18) {\\n int256 value = Fixed18.unwrap(a);\\n if (value > type(int128).max) revert Fixed18PackingOverflowError(value);\\n if (value < type(int128).min) revert Fixed18PackingUnderflowError(value);\\n return PackedFixed18.wrap(int128(value));\\n }\\n\\n /**\\n * @notice Returns whether the signed fixed-decimal is equal to zero.\\n * @param a Signed fixed-decimal\\n * @return Whether the signed fixed-decimal is zero.\\n */\\n function isZero(Fixed18 a) internal pure returns (bool) {\\n return Fixed18.unwrap(a) == 0;\\n }\\n\\n /**\\n * @notice Adds two signed fixed-decimals `a` and `b` together\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Resulting summed signed fixed-decimal\\n */\\n function add(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) + Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Subtracts signed fixed-decimal `b` from `a`\\n * @param a Signed fixed-decimal to subtract from\\n * @param b Signed fixed-decimal to subtract\\n * @return Resulting subtracted signed fixed-decimal\\n */\\n function sub(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) - Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Multiplies two signed fixed-decimals `a` and `b` together\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Resulting multiplied signed fixed-decimal\\n */\\n function mul(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / BASE);\\n }\\n\\n /**\\n * @notice Divides signed fixed-decimal `a` by `b`\\n * @param a Signed fixed-decimal to divide\\n * @param b Signed fixed-decimal to divide by\\n * @return Resulting divided signed fixed-decimal\\n */\\n function div(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * BASE / Fixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0`, `MAX` for `n/0`, and `MIN` for `-n/0`.\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function unsafeDiv(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n if (isZero(b)) {\\n if (gt(a, ZERO)) return MAX;\\n if (lt(a, ZERO)) return MIN;\\n return ONE;\\n } else {\\n return div(a, b);\\n }\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First signed fixed-decimal\\n * @param b Signed number to multiply by\\n * @param c Signed number to divide by\\n * @return Resulting computation\\n */\\n function muldiv(Fixed18 a, int256 b, int256 c) internal pure returns (Fixed18) {\\n return muldiv(a, Fixed18.wrap(b), Fixed18.wrap(c));\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First signed fixed-decimal\\n * @param b Signed fixed-decimal to multiply by\\n * @param c Signed fixed-decimal to divide by\\n * @return Resulting computation\\n */\\n function muldiv(Fixed18 a, Fixed18 b, Fixed18 c) internal pure returns (Fixed18) {\\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / Fixed18.unwrap(c));\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is equal to `b`\\n */\\n function eq(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 1;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is greater than `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is greater than `b`\\n */\\n function gt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 2;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is less than `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is less than `b`\\n */\\n function lt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 0;\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is greater than or equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is greater than or equal to `b`\\n */\\n function gte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return gt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Returns whether signed fixed-decimal `a` is less than or equal to `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Whether `a` is less than or equal to `b`\\n */\\n function lte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\\n return lt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Compares the signed fixed-decimals `a` and `b`\\n * @dev Returns: 2 for greater than\\n * 1 for equal to\\n * 0 for less than\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Compare result of `a` and `b`\\n */\\n function compare(Fixed18 a, Fixed18 b) internal pure returns (uint256) {\\n (int256 au, int256 bu) = (Fixed18.unwrap(a), Fixed18.unwrap(b));\\n if (au > bu) return 2;\\n if (au < bu) return 0;\\n return 1;\\n }\\n\\n /**\\n * @notice Returns a signed fixed-decimal representing the ratio of `a` over `b`\\n * @param a First signed number\\n * @param b Second signed number\\n * @return Ratio of `a` over `b`\\n */\\n function ratio(int256 a, int256 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(a * BASE / b);\\n }\\n\\n /**\\n * @notice Returns the minimum of signed fixed-decimals `a` and `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Minimum of `a` and `b`\\n */\\n function min(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(SignedMath.min(Fixed18.unwrap(a), Fixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Returns the maximum of signed fixed-decimals `a` and `b`\\n * @param a First signed fixed-decimal\\n * @param b Second signed fixed-decimal\\n * @return Maximum of `a` and `b`\\n */\\n function max(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\\n return Fixed18.wrap(SignedMath.max(Fixed18.unwrap(a), Fixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Converts the signed fixed-decimal into an integer, truncating any decimal portion\\n * @param a Signed fixed-decimal\\n * @return Truncated signed number\\n */\\n function truncate(Fixed18 a) internal pure returns (int256) {\\n return Fixed18.unwrap(a) / BASE;\\n }\\n\\n /**\\n * @notice Returns the sign of the signed fixed-decimal\\n * @dev Returns: -1 for negative\\n * 0 for zero\\n * 1 for positive\\n * @param a Signed fixed-decimal\\n * @return Sign of the signed fixed-decimal\\n */\\n function sign(Fixed18 a) internal pure returns (int256) {\\n if (Fixed18.unwrap(a) > 0) return 1;\\n if (Fixed18.unwrap(a) < 0) return -1;\\n return 0;\\n }\\n\\n /**\\n * @notice Returns the absolute value of the signed fixed-decimal\\n * @param a Signed fixed-decimal\\n * @return Absolute value of the signed fixed-decimal\\n */\\n function abs(Fixed18 a) internal pure returns (UFixed18) {\\n return UFixed18.wrap(SignedMath.abs(Fixed18.unwrap(a)));\\n }\\n}\\n\\nlibrary Fixed18StorageLib {\\n function read(Fixed18Storage self) internal view returns (Fixed18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(Fixed18Storage self, Fixed18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x613587461ef3437ef33229cdda7d34ea746278721baf06e20b2e43977f43174d\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/PackedFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"./Fixed18.sol\\\";\\n\\n/// @dev PackedFixed18 type\\ntype PackedFixed18 is int128;\\nusing PackedFixed18Lib for PackedFixed18 global;\\n\\n/**\\n * @title PackedFixed18Lib\\n * @dev A packed version of the Fixed18 which takes up half the storage space (two PackedFixed18 can be packed\\n * into a single slot). Only valid within the range -1.7014118e+20 <= x <= 1.7014118e+20.\\n * @notice Library for the packed signed fixed-decimal type.\\n */\\nlibrary PackedFixed18Lib {\\n PackedFixed18 public constant MAX = PackedFixed18.wrap(type(int128).max);\\n PackedFixed18 public constant MIN = PackedFixed18.wrap(type(int128).min);\\n\\n /**\\n * @notice Creates an unpacked signed fixed-decimal from a packed signed fixed-decimal\\n * @param self packed signed fixed-decimal\\n * @return New unpacked signed fixed-decimal\\n */\\n function unpack(PackedFixed18 self) internal pure returns (Fixed18) {\\n return Fixed18.wrap(int256(PackedFixed18.unwrap(self)));\\n }\\n}\\n\",\"keccak256\":\"0xb52960cc8e3132e45d342bbbb1c6a96219022cd8557997933bd8250170268b64\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/PackedUFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"./UFixed18.sol\\\";\\n\\n/// @dev PackedUFixed18 type\\ntype PackedUFixed18 is uint128;\\nusing PackedUFixed18Lib for PackedUFixed18 global;\\n\\n/**\\n * @title PackedUFixed18Lib\\n * @dev A packed version of the UFixed18 which takes up half the storage space (two PackedUFixed18 can be packed\\n * into a single slot). Only valid within the range 0 <= x <= 3.4028237e+20.\\n * @notice Library for the packed unsigned fixed-decimal type.\\n */\\nlibrary PackedUFixed18Lib {\\n PackedUFixed18 public constant MAX = PackedUFixed18.wrap(type(uint128).max);\\n\\n /**\\n * @notice Creates an unpacked unsigned fixed-decimal from a packed unsigned fixed-decimal\\n * @param self packed unsigned fixed-decimal\\n * @return New unpacked unsigned fixed-decimal\\n */\\n function unpack(PackedUFixed18 self) internal pure returns (UFixed18) {\\n return UFixed18.wrap(uint256(PackedUFixed18.unwrap(self)));\\n }\\n}\\n\",\"keccak256\":\"0xb5c5cd32d6530b2fe75228b6be32ebcb7762f6d7988b85a6b85a289ce8256d51\",\"license\":\"Apache-2.0\"},\"@equilibria/root/number/types/UFixed18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"./Fixed18.sol\\\";\\nimport \\\"./PackedUFixed18.sol\\\";\\n\\n/// @dev UFixed18 type\\ntype UFixed18 is uint256;\\nusing UFixed18Lib for UFixed18 global;\\ntype UFixed18Storage is bytes32;\\nusing UFixed18StorageLib for UFixed18Storage global;\\n\\n/**\\n * @title UFixed18Lib\\n * @notice Library for the unsigned fixed-decimal type.\\n */\\nlibrary UFixed18Lib {\\n error UFixed18UnderflowError(int256 value);\\n error UFixed18PackingOverflowError(uint256 value);\\n\\n uint256 private constant BASE = 1e18;\\n UFixed18 public constant ZERO = UFixed18.wrap(0);\\n UFixed18 public constant ONE = UFixed18.wrap(BASE);\\n UFixed18 public constant MAX = UFixed18.wrap(type(uint256).max);\\n\\n /**\\n * @notice Creates a unsigned fixed-decimal from a signed fixed-decimal\\n * @param a Signed fixed-decimal\\n * @return New unsigned fixed-decimal\\n */\\n function from(Fixed18 a) internal pure returns (UFixed18) {\\n int256 value = Fixed18.unwrap(a);\\n if (value < 0) revert UFixed18UnderflowError(value);\\n return UFixed18.wrap(uint256(value));\\n }\\n\\n /**\\n * @notice Creates a unsigned fixed-decimal from a unsigned integer\\n * @param a Unsigned number\\n * @return New unsigned fixed-decimal\\n */\\n function from(uint256 a) internal pure returns (UFixed18) {\\n return UFixed18.wrap(a * BASE);\\n }\\n\\n /**\\n * @notice Creates a packed unsigned fixed-decimal from an unsigned fixed-decimal\\n * @param a unsigned fixed-decimal\\n * @return New packed unsigned fixed-decimal\\n */\\n function pack(UFixed18 a) internal pure returns (PackedUFixed18) {\\n uint256 value = UFixed18.unwrap(a);\\n if (value > type(uint128).max) revert UFixed18PackingOverflowError(value);\\n return PackedUFixed18.wrap(uint128(value));\\n }\\n\\n /**\\n * @notice Returns whether the unsigned fixed-decimal is equal to zero.\\n * @param a Unsigned fixed-decimal\\n * @return Whether the unsigned fixed-decimal is zero.\\n */\\n function isZero(UFixed18 a) internal pure returns (bool) {\\n return UFixed18.unwrap(a) == 0;\\n }\\n\\n /**\\n * @notice Adds two unsigned fixed-decimals `a` and `b` together\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Resulting summed unsigned fixed-decimal\\n */\\n function add(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) + UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Subtracts unsigned fixed-decimal `b` from `a`\\n * @param a Unsigned fixed-decimal to subtract from\\n * @param b Unsigned fixed-decimal to subtract\\n * @return Resulting subtracted unsigned fixed-decimal\\n */\\n function sub(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) - UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Multiplies two unsigned fixed-decimals `a` and `b` together\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Resulting multiplied unsigned fixed-decimal\\n */\\n function mul(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / BASE);\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function div(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * BASE / UFixed18.unwrap(b));\\n }\\n\\n /**\\n * @notice Divides unsigned fixed-decimal `a` by `b`\\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0` and `MAX` for `n/0`.\\n * @param a Unsigned fixed-decimal to divide\\n * @param b Unsigned fixed-decimal to divide by\\n * @return Resulting divided unsigned fixed-decimal\\n */\\n function unsafeDiv(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n if (isZero(b)) {\\n return isZero(a) ? ONE : MAX;\\n } else {\\n return div(a, b);\\n }\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First unsigned fixed-decimal\\n * @param b Unsigned number to multiply by\\n * @param c Unsigned number to divide by\\n * @return Resulting computation\\n */\\n function muldiv(UFixed18 a, uint256 b, uint256 c) internal pure returns (UFixed18) {\\n return muldiv(a, UFixed18.wrap(b), UFixed18.wrap(c));\\n }\\n\\n /**\\n * @notice Computes a * b / c without loss of precision due to BASE conversion\\n * @param a First unsigned fixed-decimal\\n * @param b Unsigned fixed-decimal to multiply by\\n * @param c Unsigned fixed-decimal to divide by\\n * @return Resulting computation\\n */\\n function muldiv(UFixed18 a, UFixed18 b, UFixed18 c) internal pure returns (UFixed18) {\\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / UFixed18.unwrap(c));\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is equal to `b`\\n */\\n function eq(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 1;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is greater than `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is greater than `b`\\n */\\n function gt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 2;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is less than `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is less than `b`\\n */\\n function lt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return compare(a, b) == 0;\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is greater than or equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is greater than or equal to `b`\\n */\\n function gte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return gt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Returns whether unsigned fixed-decimal `a` is less than or equal to `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Whether `a` is less than or equal to `b`\\n */\\n function lte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\\n return lt(a, b) || eq(a, b);\\n }\\n\\n /**\\n * @notice Compares the unsigned fixed-decimals `a` and `b`\\n * @dev Returns: 2 for greater than\\n * 1 for equal to\\n * 0 for less than\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Compare result of `a` and `b`\\n */\\n function compare(UFixed18 a, UFixed18 b) internal pure returns (uint256) {\\n (uint256 au, uint256 bu) = (UFixed18.unwrap(a), UFixed18.unwrap(b));\\n if (au > bu) return 2;\\n if (au < bu) return 0;\\n return 1;\\n }\\n\\n /**\\n * @notice Returns a unsigned fixed-decimal representing the ratio of `a` over `b`\\n * @param a First unsigned number\\n * @param b Second unsigned number\\n * @return Ratio of `a` over `b`\\n */\\n function ratio(uint256 a, uint256 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(a * BASE / b);\\n }\\n\\n /**\\n * @notice Returns the minimum of unsigned fixed-decimals `a` and `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Minimum of `a` and `b`\\n */\\n function min(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(Math.min(UFixed18.unwrap(a), UFixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Returns the maximum of unsigned fixed-decimals `a` and `b`\\n * @param a First unsigned fixed-decimal\\n * @param b Second unsigned fixed-decimal\\n * @return Maximum of `a` and `b`\\n */\\n function max(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\\n return UFixed18.wrap(Math.max(UFixed18.unwrap(a), UFixed18.unwrap(b)));\\n }\\n\\n /**\\n * @notice Converts the unsigned fixed-decimal into an integer, truncating any decimal portion\\n * @param a Unsigned fixed-decimal\\n * @return Truncated unsigned number\\n */\\n function truncate(UFixed18 a) internal pure returns (uint256) {\\n return UFixed18.unwrap(a) / BASE;\\n }\\n}\\n\\nlibrary UFixed18StorageLib {\\n function read(UFixed18Storage self) internal view returns (UFixed18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(UFixed18Storage self, UFixed18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x8ebef1e6c717f565b9ed545a876b5692b4007e6485c99f39d363f7405e591792\",\"license\":\"Apache-2.0\"},\"@equilibria/root/token/types/Token18.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"../../number/types/UFixed18.sol\\\";\\n\\n/// @dev Token18\\ntype Token18 is address;\\nusing Token18Lib for Token18 global;\\ntype Token18Storage is bytes32;\\nusing Token18StorageLib for Token18Storage global;\\n\\n/**\\n * @title Token18Lib\\n * @notice Library to manage 18-decimal ERC20s that is compliant with the fixed-decimal types.\\n * @dev Maintains significant gas savings over other Token implementations since no conversion take place\\n */\\nlibrary Token18Lib {\\n using SafeERC20 for IERC20;\\n\\n Token18 public constant ZERO = Token18.wrap(address(0));\\n\\n /**\\n * @notice Returns whether a token is the zero address\\n * @param self Token to check for\\n * @return Whether the token is the zero address\\n */\\n function isZero(Token18 self) internal pure returns (bool) {\\n return Token18.unwrap(self) == Token18.unwrap(ZERO);\\n }\\n\\n /**\\n * @notice Returns whether the two tokens are equal\\n * @param a First token to compare\\n * @param b Second token to compare\\n * @return Whether the two tokens are equal\\n */\\n function eq(Token18 a, Token18 b) internal pure returns (bool) {\\n return Token18.unwrap(a) == Token18.unwrap(b);\\n }\\n\\n /**\\n * @notice Approves `grantee` to spend infinite tokens from the caller\\n * @param self Token to transfer\\n * @param grantee Address to allow spending\\n */\\n function approve(Token18 self, address grantee) internal {\\n IERC20(Token18.unwrap(self)).safeApprove(grantee, type(uint256).max);\\n }\\n\\n /**\\n * @notice Approves `grantee` to spend `amount` tokens from the caller\\n * @dev There are important race conditions to be aware of when using this function\\n with values other than 0. This will revert if moving from non-zero to non-zero amounts\\n See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/a55b7d13722e7ce850b626da2313f3e66ca1d101/contracts/token/ERC20/IERC20.sol#L57\\n * @param self Token to transfer\\n * @param grantee Address to allow spending\\n * @param amount Amount of tokens to approve to spend\\n */\\n function approve(Token18 self, address grantee, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeApprove(grantee, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers all held tokens from the caller to the `recipient`\\n * @param self Token to transfer\\n * @param recipient Address to receive the tokens\\n */\\n function push(Token18 self, address recipient) internal {\\n push(self, recipient, balanceOf(self, address(this)));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the caller to the `recipient`\\n * @param self Token to transfer\\n * @param recipient Address to transfer tokens to\\n * @param amount Amount of tokens to transfer\\n */\\n function push(Token18 self, address recipient, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransfer(recipient, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the `benefactor` to the caller\\n * @dev Reverts if trying to pull Ether\\n * @param self Token to transfer\\n * @param benefactor Address to transfer tokens from\\n * @param amount Amount of tokens to transfer\\n */\\n function pull(Token18 self, address benefactor, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, address(this), UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Transfers `amount` tokens from the `benefactor` to `recipient`\\n * @dev Reverts if trying to pull Ether\\n * @param self Token to transfer\\n * @param benefactor Address to transfer tokens from\\n * @param recipient Address to transfer tokens to\\n * @param amount Amount of tokens to transfer\\n */\\n function pullTo(Token18 self, address benefactor, address recipient, UFixed18 amount) internal {\\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, recipient, UFixed18.unwrap(amount));\\n }\\n\\n /**\\n * @notice Returns the name of the token\\n * @param self Token to check for\\n * @return Token name\\n */\\n function name(Token18 self) internal view returns (string memory) {\\n return IERC20Metadata(Token18.unwrap(self)).name();\\n }\\n\\n /**\\n * @notice Returns the symbol of the token\\n * @param self Token to check for\\n * @return Token symbol\\n */\\n function symbol(Token18 self) internal view returns (string memory) {\\n return IERC20Metadata(Token18.unwrap(self)).symbol();\\n }\\n\\n /**\\n * @notice Returns the `self` token balance of the caller\\n * @param self Token to check for\\n * @return Token balance of the caller\\n */\\n function balanceOf(Token18 self) internal view returns (UFixed18) {\\n return balanceOf(self, address(this));\\n }\\n\\n /**\\n * @notice Returns the `self` token balance of `account`\\n * @param self Token to check for\\n * @param account Account to check\\n * @return Token balance of the account\\n */\\n function balanceOf(Token18 self, address account) internal view returns (UFixed18) {\\n return UFixed18.wrap(IERC20(Token18.unwrap(self)).balanceOf(account));\\n }\\n}\\n\\nlibrary Token18StorageLib {\\n function read(Token18Storage self) internal view returns (Token18 value) {\\n assembly {\\n value := sload(self)\\n }\\n }\\n\\n function store(Token18Storage self, Token18 value) internal {\\n assembly {\\n sstore(self, value)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x6b12afaece814f0ab186200a4729e93eb685a21d3e9b5a3372ff283a7ad5dc23\",\"license\":\"Apache-2.0\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\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 amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` 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(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\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\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 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 using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\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 function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc3d946432c0ddbb1f846a0d3985be71299df331b91d06732152117f62f0be2b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // 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\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return 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 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 up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a / b + (a % b == 0 ? 0 : 1);\\n }\\n}\\n\",\"keccak256\":\"0xc995bddbca1ae19788db9f8b61e63385edd3fddf89693b612d5abd1a275974d2\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SignedMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/SignedMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard signed math utilities missing in the Solidity language.\\n */\\nlibrary SignedMath {\\n /**\\n * @dev Returns the largest of two signed numbers.\\n */\\n function max(int256 a, int256 b) internal pure returns (int256) {\\n return 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 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 // must be unchecked in order to support `n = type(int256).min`\\n return uint256(n >= 0 ? n : -n);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb3ebde1c8d27576db912d87c3560dab14adfb9cd001be95890ec4ba035e652e7\",\"license\":\"MIT\"},\"contracts/interfaces/ICollateral.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"./IController.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\n\\ninterface ICollateral {\\n event Deposit(address indexed user, IProduct indexed product, UFixed18 amount);\\n event Withdrawal(address indexed user, IProduct indexed product, UFixed18 amount);\\n event AccountSettle(IProduct indexed product, address indexed account, Fixed18 amount, UFixed18 newShortfall);\\n event ProductSettle(IProduct indexed product, UFixed18 protocolFee, UFixed18 productFee);\\n event Liquidation(address indexed user, IProduct indexed product, address liquidator, UFixed18 fee);\\n event ShortfallResolution(IProduct indexed product, UFixed18 amount);\\n event FeeClaim(address indexed account, UFixed18 amount);\\n\\n error CollateralCantLiquidate(UFixed18 totalMaintenance, UFixed18 totalCollateral);\\n error CollateralInsufficientCollateralError();\\n error CollateralUnderLimitError();\\n error CollateralZeroAddressError();\\n\\n function token() external view returns (Token18);\\n function fees(address account) external view returns (UFixed18);\\n function initialize(IController controller_) external;\\n function depositTo(address account, IProduct product, UFixed18 amount) external;\\n function withdrawTo(address account, IProduct product, UFixed18 amount) external;\\n function liquidate(address account, IProduct product) external;\\n function settleAccount(address account, Fixed18 amount) external;\\n function settleProduct(UFixed18 amount) external;\\n function collateral(address account, IProduct product) external view returns (UFixed18);\\n function collateral(IProduct product) external view returns (UFixed18);\\n function shortfall(IProduct product) external view returns (UFixed18);\\n function liquidatable(address account, IProduct product) external view returns (bool);\\n function liquidatableNext(address account, IProduct product) external view returns (bool);\\n function resolveShortfall(IProduct product, UFixed18 amount) external;\\n function claimFee() external;\\n}\\n\",\"keccak256\":\"0xa5e7fdda92702f748e6eb8701e522450035a98a05e5fc1cf66d51c52e397d914\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IContractPayoffProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\n\\ninterface IContractPayoffProvider {\\n function payoff(Fixed18 price) external view returns (Fixed18 payoff);\\n}\\n\",\"keccak256\":\"0xd73df106d032e976fd959ee6713240e36f54277ce5f215eaec8d5a2c6720a86b\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IController.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\\\";\\nimport \\\"./ICollateral.sol\\\";\\nimport \\\"./IIncentivizer.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\n\\ninterface IController {\\n /// @dev Coordinator of a one or many products\\n struct Coordinator {\\n /// @dev Pending owner of the product, can accept ownership\\n address pendingOwner;\\n\\n /// @dev Owner of the product, allowed to update select parameters\\n address owner;\\n\\n /// @dev Treasury of the product, collects fees\\n address treasury;\\n }\\n\\n event CollateralUpdated(ICollateral newCollateral);\\n event IncentivizerUpdated(IIncentivizer newIncentivizer);\\n event ProductBeaconUpdated(IBeacon newProductBeacon);\\n event ProtocolFeeUpdated(UFixed18 newProtocolFee);\\n event MinFundingFeeUpdated(UFixed18 newMinFundingFee);\\n event LiquidationFeeUpdated(UFixed18 newLiquidationFee);\\n event IncentivizationFeeUpdated(UFixed18 newIncentivizationFee);\\n event MinCollateralUpdated(UFixed18 newMinCollateral);\\n event ProgramsPerProductUpdated(uint256 newProgramsPerProduct);\\n event PauserUpdated(address newPauser);\\n event PausedUpdated(bool newPaused);\\n event CoordinatorPendingOwnerUpdated(uint256 indexed coordinatorId, address newPendingOwner);\\n event CoordinatorOwnerUpdated(uint256 indexed coordinatorId, address newOwner);\\n event CoordinatorTreasuryUpdated(uint256 indexed coordinatorId, address newTreasury);\\n event CoordinatorCreated(uint256 indexed coordinatorId, address owner);\\n event ProductCreated(IProduct indexed product, IProduct.ProductInfo productInfo);\\n\\n error ControllerNoZeroCoordinatorError();\\n error ControllerNotPauserError();\\n error ControllerNotOwnerError(uint256 controllerId);\\n error ControllerNotPendingOwnerError(uint256 controllerId);\\n error ControllerInvalidProtocolFeeError();\\n error ControllerInvalidMinFundingFeeError();\\n error ControllerInvalidLiquidationFeeError();\\n error ControllerInvalidIncentivizationFeeError();\\n error ControllerNotContractAddressError();\\n\\n function collateral() external view returns (ICollateral);\\n function incentivizer() external view returns (IIncentivizer);\\n function productBeacon() external view returns (IBeacon);\\n function coordinators(uint256 collateralId) external view returns (Coordinator memory);\\n function coordinatorFor(IProduct product) external view returns (uint256);\\n function protocolFee() external view returns (UFixed18);\\n function minFundingFee() external view returns (UFixed18);\\n function liquidationFee() external view returns (UFixed18);\\n function incentivizationFee() external view returns (UFixed18);\\n function minCollateral() external view returns (UFixed18);\\n function programsPerProduct() external view returns (uint256);\\n function pauser() external view returns (address);\\n function paused() external view returns (bool);\\n function initialize(ICollateral collateral_, IIncentivizer incentivizer_, IBeacon productBeacon_) external;\\n function createCoordinator() external returns (uint256);\\n function updateCoordinatorPendingOwner(uint256 coordinatorId, address newPendingOwner) external;\\n function acceptCoordinatorOwner(uint256 coordinatorId) external;\\n function updateCoordinatorTreasury(uint256 coordinatorId, address newTreasury) external;\\n function createProduct(uint256 coordinatorId, IProduct.ProductInfo calldata productInfo) external returns (IProduct);\\n function updateCollateral(ICollateral newCollateral) external;\\n function updateIncentivizer(IIncentivizer newIncentivizer) external;\\n function updateProductBeacon(IBeacon newProductBeacon) external;\\n function updateProtocolFee(UFixed18 newProtocolFee) external;\\n function updateMinFundingFee(UFixed18 newMinFundingFee) external;\\n function updateLiquidationFee(UFixed18 newLiquidationFee) external;\\n function updateIncentivizationFee(UFixed18 newIncentivizationFee) external;\\n function updateMinCollateral(UFixed18 newMinCollateral) external;\\n function updateProgramsPerProduct(uint256 newProductsPerProduct) external;\\n function updatePauser(address newPauser) external;\\n function updatePaused(bool newPaused) external;\\n function isProduct(IProduct product) external view returns (bool);\\n function owner() external view returns (address);\\n function owner(uint256 coordinatorId) external view returns (address);\\n function owner(IProduct product) external view returns (address);\\n function treasury() external view returns (address);\\n function treasury(uint256 coordinatorId) external view returns (address);\\n function treasury(IProduct product) external view returns (address);\\n}\\n\",\"keccak256\":\"0xaabd3740f2265499eea7aad9bd94f9892f53241e5dccce9a50c0e43ed2a6a7cc\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IIncentivizer.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./types/ProgramInfo.sol\\\";\\nimport \\\"./IController.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\n\\ninterface IIncentivizer {\\n event ProgramCreated(IProduct indexed product, uint256 indexed programId, ProgramInfo programInfo, UFixed18 programFeeAmount);\\n event ProgramStarted(IProduct indexed product, uint256 indexed programId, uint256 version);\\n event ProgramComplete(IProduct indexed product, uint256 indexed programId, uint256 version);\\n event Claim(IProduct indexed product, address indexed account, uint256 indexed programId, UFixed18 amount);\\n event FeeClaim(Token18 indexed token, UFixed18 amount);\\n\\n error IncentivizerNotAllowedError(IProduct product);\\n error IncentivizerTooManyProgramsError();\\n error IncentivizerNotProgramOwnerError(IProduct product, uint256 programId);\\n error IncentivizerInvalidProgramError(IProduct product, uint256 programId);\\n error IncentivizerBatchClaimArgumentMismatchError();\\n\\n function programInfos(IProduct product, uint256 programId) external view returns (ProgramInfo memory);\\n function fees(Token18 token) external view returns (UFixed18);\\n function initialize(IController controller_) external;\\n function create(IProduct product, ProgramInfo calldata info) external returns (uint256);\\n function complete(IProduct product, uint256 programId) external;\\n function sync(IOracleProvider.OracleVersion memory currentOracleVersion) external;\\n function syncAccount(address account, IOracleProvider.OracleVersion memory currentOracleVersion) external;\\n function claim(IProduct product, uint256[] calldata programIds) external;\\n function claim(IProduct[] calldata products, uint256[][] calldata programIds) external;\\n function claimFee(Token18[] calldata tokens) external;\\n function active(IProduct product) external view returns (uint256);\\n function count(IProduct product) external view returns (uint256);\\n function unclaimed(IProduct product, address account, uint256 programId) external view returns (UFixed18);\\n function available(IProduct product, uint256 programId) external view returns (UFixed18);\\n function versionStarted(IProduct product, uint256 programId) external view returns (uint256);\\n function versionComplete(IProduct product, uint256 programId) external view returns (uint256);\\n function owner(IProduct product, uint256 programId) external view returns (address);\\n function treasury(IProduct product, uint256 programId) external view returns (address);\\n}\\n\",\"keccak256\":\"0x2f95de90dbb3ad35dbfef304f765a622bffff9229868d2898eca8d49c78e8c2c\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IParamProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\\\";\\n\\ninterface IParamProvider {\\n event MaintenanceUpdated(UFixed18 newMaintenance);\\n event FundingFeeUpdated(UFixed18 newFundingFee);\\n event MakerFeeUpdated(UFixed18 newMakerFee);\\n event TakerFeeUpdated(UFixed18 newTakerFee);\\n event MakerLimitUpdated(UFixed18 newMakerLimit);\\n event JumpRateUtilizationCurveUpdated(\\n Fixed18 minRate,\\n Fixed18 maxRate,\\n Fixed18 targetRate,\\n UFixed18 targetUtilization\\n );\\n\\n error ParamProviderInvalidMakerFee();\\n error ParamProviderInvalidTakerFee();\\n error ParamProviderInvalidFundingFee();\\n \\n function maintenance() external view returns (UFixed18);\\n function updateMaintenance(UFixed18 newMaintenance) external;\\n function fundingFee() external view returns (UFixed18);\\n function updateFundingFee(UFixed18 newFundingFee) external;\\n function makerFee() external view returns (UFixed18);\\n function updateMakerFee(UFixed18 newMakerFee) external;\\n function takerFee() external view returns (UFixed18);\\n function updateTakerFee(UFixed18 newTakerFee) external;\\n function makerLimit() external view returns (UFixed18);\\n function updateMakerLimit(UFixed18 newMakerLimit) external;\\n function utilizationCurve() external view returns (JumpRateUtilizationCurve memory);\\n function updateUtilizationCurve(JumpRateUtilizationCurve memory newUtilizationCurve) external;\\n}\\n\",\"keccak256\":\"0x2e2d40d0cf55f167118867e41f740b9b40614d05da50fc9bc33a8cede3eaf03e\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IPayoffProvider.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\n\\ninterface IPayoffProvider {\\n error PayoffProviderInvalidOracle();\\n error PayoffProviderInvalidPayoffDefinitionError();\\n\\n function oracle() external view returns (IOracleProvider);\\n function payoffDefinition() external view returns (PayoffDefinition memory);\\n function currentVersion() external view returns (IOracleProvider.OracleVersion memory);\\n function atVersion(uint256 oracleVersion) external view returns (IOracleProvider.OracleVersion memory);\\n}\\n\",\"keccak256\":\"0xb83d80d624aa9431763f80ecb4bf0214803e25334a7419d954f929e5d0ee7467\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IPerennialLens.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./IProduct.sol\\\";\\nimport \\\"./ICollateral.sol\\\";\\nimport \\\"./IController.sol\\\";\\n\\n/**\\n * @title Lens contract to conveniently pull protocol, product, and userproduct data\\n * @notice All functions should be called using `callStatic`\\n */\\ninterface IPerennialLens {\\n /// @dev Snapshot of Product information\\n struct ProductSnapshot {\\n IProduct.ProductInfo productInfo;\\n address productAddress;\\n Fixed18 rate;\\n Fixed18 dailyRate;\\n IOracleProvider.OracleVersion latestVersion;\\n UFixed18 maintenance;\\n UFixed18 collateral;\\n UFixed18 shortfall;\\n PrePosition pre;\\n Position position;\\n UFixed18 productFee;\\n UFixed18 protocolFee;\\n Position openInterest;\\n }\\n\\n /// @dev Snapshot of User state for a Product\\n struct UserProductSnapshot {\\n address productAddress;\\n address userAddress;\\n UFixed18 collateral;\\n UFixed18 maintenance;\\n PrePosition pre;\\n Position position;\\n bool liquidatable;\\n Position openInterest;\\n UFixed18 fees;\\n UFixed18 exposure;\\n }\\n\\n // Protocol Values\\n function controller() external view returns (IController);\\n function collateral() external view returns (ICollateral);\\n\\n // Snapshot Functions for batch values\\n function snapshots(IProduct[] calldata productAddresses) external returns (ProductSnapshot[] memory);\\n function snapshot(IProduct product) external returns (ProductSnapshot memory);\\n function snapshots(address account, IProduct[] calldata productAddresses) external returns (UserProductSnapshot[] memory);\\n function snapshot(address account, IProduct product) external returns (UserProductSnapshot memory);\\n\\n // Product Values\\n function name(IProduct product) external view returns (string memory);\\n function symbol(IProduct product) external view returns (string memory);\\n function info(IProduct product) external view returns (IProduct.ProductInfo memory _info);\\n function collateral(IProduct product) external returns (UFixed18);\\n function shortfall(IProduct product) external returns (UFixed18);\\n function pre(IProduct product) external returns (PrePosition memory);\\n function fees(IProduct product) external returns (UFixed18 protocolFees, UFixed18 productFees);\\n function position(IProduct product) external returns (Position memory);\\n function globalPosition(IProduct product) external returns (PrePosition memory, Position memory);\\n function latestVersion(IProduct product) external returns (IOracleProvider.OracleVersion memory);\\n function atVersions(IProduct product, uint[] memory versions) external returns (IOracleProvider.OracleVersion[] memory prices);\\n function rate(IProduct product) external returns (Fixed18);\\n function openInterest(IProduct product) external returns (Position memory);\\n function dailyRate(IProduct product) external returns (Fixed18);\\n\\n // UserProduct Values\\n function collateral(address account, IProduct product) external returns (UFixed18);\\n function maintenance(address account, IProduct product) external returns (UFixed18);\\n function liquidatable(address account, IProduct product) external returns (bool);\\n function pre(address account, IProduct product) external returns (PrePosition memory);\\n function position(address account, IProduct product) external returns (Position memory);\\n function userPosition(address account, IProduct product) external returns (PrePosition memory, Position memory);\\n function fees(address account, IProduct product) external returns (UFixed18);\\n function openInterest(address account, IProduct product) external returns (Position memory);\\n function exposure(address account, IProduct product) external returns (UFixed18);\\n function maintenanceRequired(\\n address account,\\n IProduct product,\\n UFixed18 positionSize\\n ) external returns (UFixed18);\\n function unclaimedIncentiveRewards(address account, IProduct product)\\n external\\n returns (Token18[] memory tokens, UFixed18[] memory amounts);\\n function unclaimedIncentiveRewards(\\n address account,\\n IProduct product,\\n uint256[] calldata programIds\\n ) external returns (Token18[] memory tokens, UFixed18[] memory amounts);\\n}\\n\",\"keccak256\":\"0x64c8a3d6ce3f0ffd0e48bdf694f00d715b147ad481e472fb8206190c6a1e8671\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IProduct.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\\\";\\nimport \\\"./IPayoffProvider.sol\\\";\\nimport \\\"./IParamProvider.sol\\\";\\nimport \\\"./types/PayoffDefinition.sol\\\";\\nimport \\\"./types/Position.sol\\\";\\nimport \\\"./types/PrePosition.sol\\\";\\nimport \\\"./types/Accumulator.sol\\\";\\n\\ninterface IProduct is IPayoffProvider, IParamProvider {\\n /// @dev Product Creation parameters\\n struct ProductInfo {\\n /// @dev name of the product\\n string name;\\n\\n /// @dev symbol of the product\\n string symbol;\\n\\n /// @dev product payoff definition\\n PayoffDefinition payoffDefinition;\\n\\n /// @dev oracle address\\n IOracleProvider oracle;\\n\\n /// @dev product maintenance ratio\\n UFixed18 maintenance;\\n\\n /// @dev product funding fee\\n UFixed18 fundingFee;\\n\\n /// @dev product maker fee\\n UFixed18 makerFee;\\n\\n /// @dev product taker fee\\n UFixed18 takerFee;\\n\\n /// @dev product maker limit\\n UFixed18 makerLimit;\\n\\n /// @dev utulization curve definition\\n JumpRateUtilizationCurve utilizationCurve;\\n }\\n\\n event Settle(uint256 preVersion, uint256 toVersion);\\n event AccountSettle(address indexed account, uint256 preVersion, uint256 toVersion);\\n event MakeOpened(address indexed account, uint256 version, UFixed18 amount);\\n event TakeOpened(address indexed account, uint256 version, UFixed18 amount);\\n event MakeClosed(address indexed account, uint256 version, UFixed18 amount);\\n event TakeClosed(address indexed account, uint256 version, UFixed18 amount);\\n event ClosedUpdated(bool indexed newClosed, uint256 version);\\n\\n error ProductInsufficientLiquidityError(UFixed18 socializationFactor);\\n error ProductDoubleSidedError();\\n error ProductOverClosedError();\\n error ProductInsufficientCollateralError();\\n error ProductInLiquidationError();\\n error ProductMakerOverLimitError();\\n error ProductOracleBootstrappingError();\\n error ProductNotOwnerError();\\n error ProductInvalidOracle();\\n error ProductClosedError();\\n\\n function name() external view returns (string memory);\\n function symbol() external view returns (string memory);\\n function initialize(ProductInfo calldata productInfo_) external;\\n function settle() external;\\n function settleAccount(address account) external;\\n function openTake(UFixed18 amount) external;\\n function closeTake(UFixed18 amount) external;\\n function openMake(UFixed18 amount) external;\\n function closeMake(UFixed18 amount) external;\\n function closeAll(address account) external;\\n function maintenance(address account) external view returns (UFixed18);\\n function maintenanceNext(address account) external view returns (UFixed18);\\n function isClosed(address account) external view returns (bool);\\n function isLiquidating(address account) external view returns (bool);\\n function position(address account) external view returns (Position memory);\\n function pre(address account) external view returns (PrePosition memory);\\n function latestVersion() external view returns (uint256);\\n function positionAtVersion(uint256 oracleVersion) external view returns (Position memory);\\n function pre() external view returns (PrePosition memory);\\n function valueAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\\n function shareAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\\n function latestVersion(address account) external view returns (uint256);\\n function rate(Position memory position) external view returns (Fixed18);\\n function closed() external view returns (bool);\\n function updateClosed(bool newClosed) external;\\n}\\n\",\"keccak256\":\"0xe1e80b818eadf4cdb070362e40c7cf3863b50c4f944816af27848e319f587241\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/Accumulator.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/Fixed18.sol\\\";\\nimport \\\"./PackedAccumulator.sol\\\";\\n\\n/// @dev Accumulator type\\nstruct Accumulator {\\n /// @dev maker accumulator per share\\n Fixed18 maker;\\n /// @dev taker accumulator per share\\n Fixed18 taker;\\n}\\nusing AccumulatorLib for Accumulator global;\\n\\n/**\\n * @title AccountAccumulatorLib\\n * @notice Library that surfaces math operations for the Accumulator type.\\n * @dev Accumulators track the cumulative change in position value over time for the maker and taker positions\\n * respectively. Account-level accumulators can then use two of these values `a` and `a'` to compute the\\n * change in position value since last sync. This change in value is then used to compute P&L and fees.\\n */\\nlibrary AccumulatorLib {\\n /**\\n * @notice Creates a packed accumulator from an accumulator\\n * @param self an accumulator\\n * @return New packed accumulator\\n */\\n function pack(Accumulator memory self) internal pure returns (PackedAccumulator memory) {\\n return PackedAccumulator({maker: self.maker.pack(), taker: self.taker.pack()});\\n }\\n\\n /**\\n * @notice Adds two accumulators together\\n * @param a The first accumulator to sum\\n * @param b The second accumulator to sum\\n * @return The resulting summed accumulator\\n */\\n function add(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\\n }\\n\\n /**\\n * @notice Subtracts accumulator `b` from `a`\\n * @param a The accumulator to subtract from\\n * @param b The accumulator to subtract\\n * @return The resulting subtracted accumulator\\n */\\n function sub(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\\n }\\n\\n /**\\n * @notice Multiplies two accumulators together\\n * @param a The first accumulator to multiply\\n * @param b The second accumulator to multiply\\n * @return The resulting multiplied accumulator\\n */\\n function mul(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: a.maker.mul(b.maker), taker: a.taker.mul(b.taker)});\\n }\\n\\n /**\\n * @notice Sums the maker and taker together from a single accumulator\\n * @param self The struct to operate on\\n * @return The sum of its maker and taker\\n */\\n function sum(Accumulator memory self) internal pure returns (Fixed18) {\\n return self.maker.add(self.taker);\\n }\\n}\\n\",\"keccak256\":\"0x7ccd0a72aa593cefb9f4337cf312799f357b82fcb3f0379de0dc503d1cb7e387\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PackedAccumulator.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/PackedFixed18.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\n\\n/// @dev PackedAccumulator type\\nstruct PackedAccumulator {\\n /// @dev maker accumulator per share\\n PackedFixed18 maker;\\n /// @dev taker accumulator per share\\n PackedFixed18 taker;\\n}\\nusing PackedAccumulatorLib for PackedAccumulator global;\\n\\n/**\\n * @title PackedAccumulatorLib\\n * @dev A packed version of the Accumulator which takes up a single storage slot using `PackedFixed18` values.\\n * @notice Library for the packed Accumulator type.\\n */\\nlibrary PackedAccumulatorLib {\\n /**\\n * @notice Creates an accumulator from a packed accumulator\\n * @param self packed accumulator\\n * @return New accumulator\\n */\\n function unpack(PackedAccumulator memory self) internal pure returns (Accumulator memory) {\\n return Accumulator({maker: self.maker.unpack(), taker: self.taker.unpack()});\\n }\\n}\\n\",\"keccak256\":\"0xd83f2822d4f6c818087a232b54007730992c34ff77377fc307a282f886e7cf65\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PackedPosition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/PackedUFixed18.sol\\\";\\nimport \\\"./Position.sol\\\";\\n\\n/// @dev PackedPosition type\\nstruct PackedPosition {\\n /// @dev Quantity of the maker position\\n PackedUFixed18 maker;\\n /// @dev Quantity of the taker position\\n PackedUFixed18 taker;\\n}\\nusing PackedPositionLib for PackedPosition global;\\n\\n/**\\n * @title PackedPositionLib\\n * @dev A packed version of the Position which takes up a single storage slot using `PackedFixed18` values.\\n * @notice Library for the packed Position type.\\n */\\nlibrary PackedPositionLib {\\n /**\\n * @notice Creates an position from a packed position\\n * @param self packed position\\n * @return New position\\n */\\n function unpack(PackedPosition memory self) internal pure returns (Position memory) {\\n return Position({maker: self.maker.unpack(), taker: self.taker.unpack()});\\n }\\n}\\n\",\"keccak256\":\"0x04968e6794f6244cb3415cea111d640273a81faea957872988d0cb580f45df1e\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PayoffDefinition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"@openzeppelin/contracts/utils/Address.sol\\\";\\nimport \\\"../../interfaces/IContractPayoffProvider.sol\\\";\\n\\n/// @dev PayoffDefinition tyoe\\nstruct PayoffDefinition {\\n PayoffDefinitionLib.PayoffType payoffType;\\n PayoffDefinitionLib.PayoffDirection payoffDirection;\\n bytes30 data;\\n}\\nusing PayoffDefinitionLib for PayoffDefinition global;\\ntype PayoffDefinitionStorage is bytes32;\\nusing PayoffDefinitionStorageLib for PayoffDefinitionStorage global;\\n\\n/**\\n * @title PayoffDefinitionLib\\n * @dev Library that surfaces logic for PayoffDefinition type functionality\\n * @notice Library for the PayoffDefinition type. Performs validity and price transformation\\n based on the payoff definition type.\\n */\\nlibrary PayoffDefinitionLib {\\n using Address for address;\\n\\n error PayoffDefinitionUnsupportedTransform(PayoffType payoffType, PayoffDirection payoffDirection);\\n error PayoffDefinitionNotContract(PayoffType payoffType, bytes30 data);\\n\\n /// @dev Payoff function type enum\\n enum PayoffType { PASSTHROUGH, CONTRACT }\\n enum PayoffDirection { LONG, SHORT }\\n\\n /**\\n * @notice Checks validity of the payoff definition\\n * @param self a payoff definition\\n * @return Whether the payoff definition is valid for it's given type\\n */\\n function valid(PayoffDefinition memory self) internal view returns (bool) {\\n if (self.payoffType == PayoffType.CONTRACT) return address(_providerContract(self)).isContract();\\n\\n // All other payoff types should have no data\\n return uint(bytes32(self.data)) == 0;\\n }\\n\\n /**\\n * @notice Transforms a price based on the payoff definition\\n * @param self a payoff definition\\n * @param price raw oracle price\\n * @return Price transformed by the payoff definition function\\n */\\n function transform(\\n PayoffDefinition memory self,\\n Fixed18 price\\n ) internal view returns (Fixed18) {\\n PayoffType payoffType = self.payoffType;\\n PayoffDirection payoffDirection = self.payoffDirection;\\n Fixed18 transformedPrice;\\n\\n // First get the price depending on the type\\n if (payoffType == PayoffType.PASSTHROUGH) transformedPrice = price;\\n else if (payoffType == PayoffType.CONTRACT) transformedPrice = _payoffFromContract(self, price);\\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\\n\\n // Then transform it depending on the direction flag\\n if (self.payoffDirection == PayoffDirection.LONG) return transformedPrice;\\n else if (self.payoffDirection == PayoffDirection.SHORT) return transformedPrice.mul(Fixed18Lib.NEG_ONE);\\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\\n }\\n\\n /**\\n * @notice Parses the data field into an address\\n * @dev Reverts if payoffType is not CONTRACT\\n * @param self a payoff definition\\n * @return IContractPayoffProvider address\\n */\\n function _providerContract(\\n PayoffDefinition memory self\\n ) private pure returns (IContractPayoffProvider) {\\n if (self.payoffType != PayoffType.CONTRACT) revert PayoffDefinitionNotContract(self.payoffType, self.data);\\n // Shift to pull the last 20 bytes, then cast to an address\\n return IContractPayoffProvider(address(bytes20(self.data << 80)));\\n }\\n\\n /**\\n * @notice Performs a price transformation by calling the underlying payoff contract\\n * @param self a payoff definition\\n * @param price raw oracle price\\n * @return Price transformed by the payoff definition function on the contract\\n */\\n function _payoffFromContract(\\n PayoffDefinition memory self,\\n Fixed18 price\\n ) private view returns (Fixed18) {\\n bytes memory ret = address(_providerContract(self)).functionStaticCall(\\n abi.encodeCall(IContractPayoffProvider.payoff, price)\\n );\\n return Fixed18.wrap(abi.decode(ret, (int256)));\\n }\\n}\\n\\n/**\\n * @title PayoffDefinitionStorageLib\\n * @notice Library that surfaces storage read and writes for the PayoffDefinition type\\n */\\nlibrary PayoffDefinitionStorageLib {\\n function read(PayoffDefinitionStorage self) internal view returns (PayoffDefinition memory) {\\n return _storagePointer(self);\\n }\\n\\n function store(PayoffDefinitionStorage self, PayoffDefinition memory value) internal {\\n PayoffDefinition storage storagePointer = _storagePointer(self);\\n\\n storagePointer.payoffType = value.payoffType;\\n storagePointer.payoffDirection = value.payoffDirection;\\n storagePointer.data = value.data;\\n }\\n\\n function _storagePointer(\\n PayoffDefinitionStorage self\\n ) private pure returns (PayoffDefinition storage pointer) {\\n assembly { pointer.slot := self }\\n }\\n}\\n\",\"keccak256\":\"0x4d3897f408f77381c5ae9990391465c8fd511ddf6ff3b39f6cb69d8c2bd554df\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/Position.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\nimport \\\"./PrePosition.sol\\\";\\nimport \\\"./PackedPosition.sol\\\";\\n\\n/// @dev Position type\\nstruct Position {\\n /// @dev Quantity of the maker position\\n UFixed18 maker;\\n /// @dev Quantity of the taker position\\n UFixed18 taker;\\n}\\nusing PositionLib for Position global;\\n\\n/**\\n * @title PositionLib\\n * @notice Library that surfaces math and settlement computations for the Position type.\\n * @dev Positions track the current quantity of the account's maker and taker positions respectively\\n * denominated as a unit of the product's payoff function.\\n */\\nlibrary PositionLib {\\n /**\\n * @notice Creates a packed position from an position\\n * @param self A position\\n * @return New packed position\\n */\\n function pack(Position memory self) internal pure returns (PackedPosition memory) {\\n return PackedPosition({maker: self.maker.pack(), taker: self.taker.pack()});\\n }\\n\\n /**\\n * @notice Returns whether the position is fully empty\\n * @param self A position\\n * @return Whether the position is empty\\n */\\n function isEmpty(Position memory self) internal pure returns (bool) {\\n return self.maker.isZero() && self.taker.isZero();\\n }\\n\\n /**\\n * @notice Adds position `a` and `b` together, returning the result\\n * @param a The first position to sum\\n * @param b The second position to sum\\n * @return Resulting summed position\\n */\\n function add(Position memory a, Position memory b) internal pure returns (Position memory) {\\n return Position({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\\n }\\n\\n /**\\n * @notice Subtracts position `b` from `a`, returning the result\\n * @param a The position to subtract from\\n * @param b The position to subtract\\n * @return Resulting subtracted position\\n */\\n function sub(Position memory a, Position memory b) internal pure returns (Position memory) {\\n return Position({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\\n }\\n\\n /**\\n * @notice Multiplies position `self` by accumulator `accumulator` and returns the resulting accumulator\\n * @param self The Position to operate on\\n * @param accumulator The accumulator to multiply by\\n * @return Resulting multiplied accumulator\\n */\\n function mul(Position memory self, Accumulator memory accumulator) internal pure returns (Accumulator memory) {\\n return Accumulator({\\n maker: Fixed18Lib.from(self.maker).mul(accumulator.maker),\\n taker: Fixed18Lib.from(self.taker).mul(accumulator.taker)\\n });\\n }\\n\\n /**\\n * @notice Scales position `self` by fixed-decimal `scale` and returns the resulting position\\n * @param self The Position to operate on\\n * @param scale The Fixed-decimal to scale by\\n * @return Resulting scaled position\\n */\\n function mul(Position memory self, UFixed18 scale) internal pure returns (Position memory) {\\n return Position({maker: self.maker.mul(scale), taker: self.taker.mul(scale)});\\n }\\n\\n /**\\n * @notice Divides position `self` by `b` and returns the resulting accumulator\\n * @param self The Position to operate on\\n * @param b The number to divide by\\n * @return Resulting divided accumulator\\n */\\n function div(Position memory self, uint256 b) internal pure returns (Accumulator memory) {\\n return Accumulator({\\n maker: Fixed18Lib.from(self.maker).div(Fixed18Lib.from(UFixed18Lib.from(b))),\\n taker: Fixed18Lib.from(self.taker).div(Fixed18Lib.from(UFixed18Lib.from(b)))\\n });\\n }\\n\\n /**\\n * @notice Returns the maximum of `self`'s maker and taker values\\n * @param self The struct to operate on\\n * @return Resulting maximum value\\n */\\n function max(Position memory self) internal pure returns (UFixed18) {\\n return UFixed18Lib.max(self.maker, self.taker);\\n }\\n\\n /**\\n * @notice Sums the maker and taker together from a single position\\n * @param self The struct to operate on\\n * @return The sum of its maker and taker\\n */\\n function sum(Position memory self) internal pure returns (UFixed18) {\\n return self.maker.add(self.taker);\\n }\\n\\n /**\\n * @notice Computes the next position after the pending-settlement position delta is included\\n * @param self The current Position\\n * @param pre The pending-settlement position delta\\n * @return Next Position\\n */\\n function next(Position memory self, PrePosition memory pre) internal pure returns (Position memory) {\\n return sub(add(self, pre.openPosition), pre.closePosition);\\n }\\n\\n /**\\n * @notice Returns the settled position at oracle version `toOracleVersion`\\n * @dev Checks if a new position is ready to be settled based on the provided `toOracleVersion`\\n * and `pre` and returns accordingly\\n * @param self The current Position\\n * @param pre The pending-settlement position delta\\n * @param toOracleVersion The oracle version to settle to\\n * @return Settled position at oracle version\\n * @return Fee accrued from opening or closing the position\\n * @return Whether a new position was settled\\n */\\n function settled(\\n Position memory self,\\n PrePosition memory pre,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal view returns (Position memory, UFixed18, bool) {\\n return pre.canSettle(toOracleVersion) ? (next(self, pre), pre.computeFee(toOracleVersion), true) : (self, UFixed18Lib.ZERO, false);\\n }\\n\\n /**\\n * @notice Returns the socialization factor for the current position\\n * @dev Socialization account for the case where `taker` > `maker` temporarily due to a liquidation\\n * on the maker side. This dampens the taker's exposure pro-rata to ensure that the maker side\\n * is never exposed over 1 x short.\\n * @param self The Position to operate on\\n * @return Socialization factor\\n */\\n function socializationFactor(Position memory self) internal pure returns (UFixed18) {\\n return self.taker.isZero() ? UFixed18Lib.ONE : UFixed18Lib.min(UFixed18Lib.ONE, self.maker.div(self.taker));\\n }\\n}\\n\",\"keccak256\":\"0x027fe392c4f56bf012ba2ca462fcf23e69f2c3b9d283c14089771813437af991\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/PrePosition.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/number/types/UFixed18.sol\\\";\\nimport \\\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\\\";\\nimport \\\"./Position.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\n\\n/// @dev PrePosition type\\nstruct PrePosition {\\n /// @dev Oracle version at which the new position delta was recorded\\n uint256 oracleVersion;\\n\\n /// @dev Size of position to open at oracle version\\n Position openPosition;\\n\\n /// @dev Size of position to close at oracle version\\n Position closePosition;\\n}\\nusing PrePositionLib for PrePosition global;\\n\\n/**\\n * @title PrePositionLib\\n * @notice Library that manages a pre-settlement position delta.\\n * @dev PrePositions track the currently awaiting-settlement deltas to a settled Position. These are\\n * Primarily necessary to introduce lag into the settlement system such that oracle lag cannot be\\n * gamed to a user's advantage. When a user opens or closes a new position, it sits as a PrePosition\\n * for one oracle version until it's settle into the Position, making it then effective. PrePositions\\n * are automatically settled at the correct oracle version even if a flywheel call doesn't happen until\\n * several version into the future by using the historical version lookups in the corresponding \\\"Versioned\\\"\\n * global state types.\\n */\\nlibrary PrePositionLib {\\n /**\\n * @notice Returns whether there is no pending-settlement position delta\\n * @dev Can be \\\"empty\\\" even with a non-zero oracleVersion if a position is opened and\\n * closed in the same version netting out to a zero position delta\\n * @param self The struct to operate on\\n * @return Whether the pending-settlement position delta is empty\\n */\\n function isEmpty(PrePosition memory self) internal pure returns (bool) {\\n return self.openPosition.isEmpty() && self.closePosition.isEmpty();\\n }\\n\\n /**\\n * @notice Increments the maker side of the open position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The position amount to open\\n */\\n function openMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.openPosition.maker = self.openPosition.maker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netMake(self);\\n }\\n\\n /**\\n * @notice Increments the maker side of the close position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The maker position amount to close\\n */\\n function closeMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.closePosition.maker = self.closePosition.maker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netMake(self);\\n }\\n\\n /**\\n * @notice Increments the taker side of the open position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The taker position amount to open\\n */\\n function openTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.openPosition.taker = self.openPosition.taker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netTake(self);\\n }\\n\\n /**\\n * @notice Increments the taker side of the close position delta\\n * @dev Nets out open and close deltas to minimize the size of each\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @param amount The taker position amount to close\\n */\\n function closeTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\\n self.closePosition.taker = self.closePosition.taker.add(amount);\\n self.oracleVersion = currentVersion;\\n _netTake(self);\\n }\\n\\n /**\\n * @notice Nets out the open and close on the maker side of the position delta\\n * @param self The struct to operate on\\n */\\n function _netMake(PrePosition storage self) private {\\n if (self.openPosition.maker.gt(self.closePosition.maker)) {\\n self.openPosition.maker = self.openPosition.maker.sub(self.closePosition.maker);\\n self.closePosition.maker = UFixed18Lib.ZERO;\\n } else {\\n self.closePosition.maker = self.closePosition.maker.sub(self.openPosition.maker);\\n self.openPosition.maker = UFixed18Lib.ZERO;\\n }\\n }\\n\\n /**\\n * @notice Nets out the open and close on the taker side of the position delta\\n * @param self The struct to operate on\\n */\\n function _netTake(PrePosition storage self) private {\\n if (self.openPosition.taker.gt(self.closePosition.taker)) {\\n self.openPosition.taker = self.openPosition.taker.sub(self.closePosition.taker);\\n self.closePosition.taker = UFixed18Lib.ZERO;\\n } else {\\n self.closePosition.taker = self.closePosition.taker.sub(self.openPosition.taker);\\n self.openPosition.taker = UFixed18Lib.ZERO;\\n }\\n }\\n\\n /**\\n * @notice Returns whether the the pending position delta can be settled at version `toOracleVersion`\\n * @dev Pending-settlement positions deltas can be settled (1) oracle version after they are recorded\\n * @param self The struct to operate on\\n * @param toOracleVersion The potential oracle version to settle\\n * @return Whether the position delta can be settled\\n */\\n function canSettle(\\n PrePosition memory self,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal pure returns (bool) {\\n return !isEmpty(self) && toOracleVersion.version > self.oracleVersion;\\n }\\n\\n /**\\n * @notice Computes the fee incurred for opening or closing the pending-settlement position\\n * @dev Must be called from a valid product to get the proper fee amounts\\n * @param self The struct to operate on\\n * @param toOracleVersion The oracle version at which settlement takes place\\n * @return positionFee The maker / taker fee incurred\\n */\\n function computeFee(\\n PrePosition memory self,\\n IOracleProvider.OracleVersion memory toOracleVersion\\n ) internal view returns (UFixed18) {\\n Position memory positionDelta = self.openPosition.add(self.closePosition);\\n\\n (UFixed18 makerNotional, UFixed18 takerNotional) = (\\n Fixed18Lib.from(positionDelta.maker).mul(toOracleVersion.price).abs(),\\n Fixed18Lib.from(positionDelta.taker).mul(toOracleVersion.price).abs()\\n );\\n\\n IProduct product = IProduct(address(this));\\n return makerNotional.mul(product.makerFee()).add(takerNotional.mul(product.takerFee()));\\n }\\n\\n /**\\n * @notice Computes the next oracle version to settle\\n * @dev - If there is no pending-settlement position delta, returns the current oracle version\\n * - Otherwise returns the oracle version at which the pending-settlement position delta can be first settled\\n *\\n * Corresponds to point (b) in the Position settlement flow\\n * @param self The struct to operate on\\n * @param currentVersion The current oracle version index\\n * @return Next oracle version to settle\\n */\\n function settleVersion(PrePosition storage self, uint256 currentVersion) internal view returns (uint256) {\\n uint256 _oracleVersion = self.oracleVersion;\\n return _oracleVersion == 0 ? currentVersion : _oracleVersion + 1;\\n }\\n}\\n\",\"keccak256\":\"0xa6f83f7b5f8139ec874235c406debd086a152977493c08b7f280df6f1737fb96\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/types/ProgramInfo.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.13;\\n\\nimport \\\"@equilibria/root/token/types/Token18.sol\\\";\\nimport \\\"../IProduct.sol\\\";\\nimport \\\"./Position.sol\\\";\\nimport \\\"./Accumulator.sol\\\";\\n\\n/// @dev ProgramInfo type\\nstruct ProgramInfo {\\n /// @dev Coordinator for this program\\n uint256 coordinatorId;\\n\\n /// @dev Amount of total maker and taker rewards\\n Position amount;\\n\\n /// @dev start timestamp of the program\\n uint256 start;\\n\\n /// @dev duration of the program (in seconds)\\n uint256 duration;\\n\\n /**\\n * @dev Reward ERC20 token contract\\n * @notice Perennial does not support non-standard ERC20s as reward tokens for incentive programs, including,\\n but not limited to: fee on transfer and rebase tokens. Using such a non-standard token will likely\\n result in loss of funds.\\n */\\n Token18 token;\\n}\\nusing ProgramInfoLib for ProgramInfo global;\\n\\n/**\\n * @title ProgramInfoLib\\n * @notice Library that snapshots the static information for a single program.\\n * @dev This information does not change during the operation of a program.\\n */\\nlibrary ProgramInfoLib {\\n uint256 private constant MIN_DURATION = 1 days;\\n uint256 private constant MAX_DURATION = 2 * 365 days;\\n\\n error ProgramInvalidStartError();\\n error ProgramInvalidDurationError();\\n\\n /**\\n * @notice Validates and creates a new Program\\n * @dev Reverts for invalid programInfos\\n * @param programInfo Un-sanitized static program information\\n */\\n function validate(ProgramInfo memory programInfo) internal view {\\n if (isStarted(programInfo, block.timestamp)) revert ProgramInvalidStartError();\\n if (programInfo.duration < MIN_DURATION || programInfo.duration > MAX_DURATION) revert ProgramInvalidDurationError();\\n }\\n\\n /**\\n * @notice Computes a new program info with the fee taken out of the amount\\n * @param programInfo Original program info\\n * @param incentivizationFee The incentivization fee\\n * @return New program info\\n * @return Fee amount\\n */\\n function deductFee(ProgramInfo memory programInfo, UFixed18 incentivizationFee)\\n internal pure returns (ProgramInfo memory, UFixed18) {\\n Position memory newProgramAmount = programInfo.amount.mul(UFixed18Lib.ONE.sub(incentivizationFee));\\n UFixed18 programFeeAmount = programInfo.amount.sub(newProgramAmount).sum();\\n programInfo.amount = newProgramAmount;\\n return (programInfo, programFeeAmount);\\n }\\n\\n /**\\n * @notice Returns the maker and taker amounts per position share\\n * @param self The ProgramInfo to operate on\\n * @return programFee Amounts per share\\n */\\n function amountPerShare(ProgramInfo memory self) internal pure returns (Accumulator memory) {\\n return self.amount.div(self.duration);\\n }\\n\\n /**\\n * @notice Returns whether the program has started by timestamp `timestamp`\\n * @param self The ProgramInfo to operate on\\n * @param timestamp Timestamp to check for\\n * @return Whether the program has started\\n */\\n function isStarted(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\\n return timestamp >= self.start;\\n }\\n\\n /**\\n * @notice Returns whether the program is completed by timestamp `timestamp`\\n * @param self The ProgramInfo to operate on\\n * @param timestamp Timestamp to check for\\n * @return Whether the program is completed\\n */\\n function isComplete(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\\n return timestamp >= (self.start + self.duration);\\n }\\n}\\n\",\"keccak256\":\"0x280fcaf931b49abaec46b95ccbabaaf856a4b8e8d036413c9c3b3af25585d161\",\"license\":\"Apache-2.0\"},\"contracts/lens/PerennialLens.sol\":{\"content\":\"// SPDX-License-Identifier: Apache-2.0\\npragma solidity 0.8.15;\\n\\nimport \\\"../interfaces/IPerennialLens.sol\\\";\\n\\n/**\\n * @title Lens contract to conveniently pull protocol data\\n * @notice All functions should be called using `callStatic`\\n */\\ncontract PerennialLens is IPerennialLens {\\n /**\\n * @notice Protocol controller\\n * @return Protocol controller\\n */\\n IController public immutable controller;\\n\\n /// @param _controller Protocol controller address\\n constructor(IController _controller) {\\n controller = _controller;\\n }\\n\\n /**\\n * @notice Protocol collateral address\\n * @return Protocol collateral address\\n */\\n function collateral() public view returns (ICollateral) {\\n return controller.collateral();\\n }\\n\\n /**\\n * Snapshot Functions\\n */\\n\\n /**\\n * @notice Returns the snapshots of the provided `productAddresses`\\n * @param productAddresses Product addresses\\n * @return Snapshot for each product after settle\\n */\\n function snapshots(IProduct[] calldata productAddresses) public returns (ProductSnapshot[] memory) {\\n ProductSnapshot[] memory _snapshots = new ProductSnapshot[](productAddresses.length);\\n for (uint256 i = 0; i < productAddresses.length; i++) {\\n _snapshots[i] = snapshot(productAddresses[i]);\\n }\\n\\n return _snapshots;\\n }\\n\\n /**\\n * @notice Returns the snapshot of the provided `product`\\n * @param product Product address\\n * @return Snapshot for the product after settle\\n */\\n function snapshot(IProduct product) public settle(product) returns (ProductSnapshot memory) {\\n ProductSnapshot memory _snapshot;\\n\\n _snapshot.productInfo = info(product);\\n _snapshot.productAddress = address(product);\\n _snapshot.rate = rate(product);\\n _snapshot.dailyRate = dailyRate(product);\\n _snapshot.latestVersion = latestVersion(product);\\n _snapshot.maintenance = product.maintenance();\\n _snapshot.collateral = collateral(product);\\n _snapshot.shortfall = shortfall(product);\\n _snapshot.pre = pre(product);\\n _snapshot.position = position(product);\\n (UFixed18 productFee, UFixed18 protocolFee) = fees(product);\\n _snapshot.productFee = productFee;\\n _snapshot.protocolFee = protocolFee;\\n _snapshot.openInterest = openInterest(product);\\n\\n return _snapshot;\\n }\\n\\n /**\\n * @notice Returns the user snapshots for the provided `productAddresses`\\n * @param account User addresses\\n * @param productAddresses Product addresses\\n * @return UserSnapshot for each product after settle\\n */\\n function snapshots(address account, IProduct[] memory productAddresses)\\n public returns (UserProductSnapshot[] memory)\\n {\\n UserProductSnapshot[] memory _snapshots = new UserProductSnapshot[](productAddresses.length);\\n for (uint256 i = 0; i < productAddresses.length; i++) {\\n _snapshots[i] = snapshot(account, productAddresses[i]);\\n }\\n\\n return _snapshots;\\n }\\n\\n /**\\n * @notice Returns the user snapshot for the provided `product`\\n * @param account User addresses\\n * @param product Product address\\n * @return UserSnapshot for the product after settle\\n */\\n function snapshot(address account, IProduct product)\\n public\\n settleAccount(account, product)\\n returns (UserProductSnapshot memory)\\n {\\n UserProductSnapshot memory _snapshot;\\n\\n _snapshot.productAddress = address(product);\\n _snapshot.userAddress = account;\\n _snapshot.collateral = collateral(account, product);\\n _snapshot.maintenance = maintenance(account, product);\\n _snapshot.pre = pre(account, product);\\n _snapshot.position = position(account, product);\\n _snapshot.liquidatable = liquidatable(account, product);\\n _snapshot.openInterest = openInterest(account, product);\\n _snapshot.fees = fees(account, product);\\n _snapshot.exposure = exposure(account, product);\\n\\n return _snapshot;\\n }\\n\\n /**\\n * End Snapshot Functions\\n */\\n\\n /**\\n * Product Individual Fields Functions\\n */\\n\\n /**\\n * @notice Returns the name of the provided `product`\\n * @param product Product address\\n * @return Name of the product\\n */\\n function name(IProduct product) public view returns (string memory) {\\n return product.name();\\n }\\n\\n /**\\n * @notice Returns the symbol of the provided `product`\\n * @param product Product address\\n * @return Symbol of the product\\n */\\n function symbol(IProduct product) public view returns (string memory) {\\n return product.symbol();\\n }\\n\\n /**\\n * @notice Returns the info of the provided `product`\\n * @param product Product address\\n * @return _info of the product\\n */\\n function info(IProduct product) public view returns (IProduct.ProductInfo memory _info) {\\n _info.name = name(product);\\n _info.symbol = symbol(product);\\n _info.payoffDefinition = product.payoffDefinition();\\n _info.oracle = product.oracle();\\n _info.maintenance = product.maintenance();\\n _info.fundingFee = product.fundingFee();\\n _info.makerFee = product.makerFee();\\n _info.takerFee = product.takerFee();\\n _info.makerLimit = product.makerLimit();\\n _info.utilizationCurve = product.utilizationCurve();\\n }\\n\\n /**\\n * @notice Product total collateral amount after settle\\n * @param product Product address\\n * @return Total collateral for product\\n */\\n function collateral(IProduct product) public settle(product) returns (UFixed18) {\\n return collateral().collateral(product);\\n }\\n\\n /**\\n * @notice Product total shortfall amount after settle\\n * @param product Product address\\n * @return Total shortfall for product\\n */\\n function shortfall(IProduct product) public settle(product) returns (UFixed18) {\\n return collateral().shortfall(product);\\n }\\n\\n /**\\n * @notice Product pre position after settle\\n * @param product Product address\\n * @return Product pre-position\\n */\\n function pre(IProduct product) public settle(product) returns (PrePosition memory) {\\n return product.pre();\\n }\\n\\n /**\\n * @notice Product position after settle\\n * @param product Product address\\n * @return product position\\n */\\n function position(IProduct product) public settle(product) returns (Position memory) {\\n return _latestPosition(product);\\n }\\n\\n /**\\n * @notice Product pre-position and position after settle\\n * @param product Product address\\n * @return Product pre-position\\n * @return Product position\\n */\\n function globalPosition(IProduct product) public settle(product) returns (PrePosition memory, Position memory) {\\n return (product.pre(), _latestPosition(product));\\n }\\n\\n /**\\n * @notice Current price of product after settle\\n * @param product Product address\\n * @return Product latest price\\n */\\n function latestVersion(IProduct product) public settle(product) returns (IOracleProvider.OracleVersion memory) {\\n return _latestVersion(product);\\n }\\n\\n /**\\n * @notice Prices of product at specified versions after settle\\n * @param product Product address\\n * @param versions Oracle versions to query\\n * @return prices Product prices at specified versions\\n */\\n function atVersions(IProduct product, uint256[] memory versions)\\n public\\n settle(product)\\n returns (IOracleProvider.OracleVersion[] memory prices)\\n {\\n prices = new IOracleProvider.OracleVersion[](versions.length);\\n for (uint256 i = 0; i < versions.length; i++) {\\n prices[i] = product.atVersion(versions[i]);\\n }\\n }\\n\\n /**\\n * @notice Product funding rate after settle\\n * @param product Product address\\n * @return Product current funding rate\\n */\\n function rate(IProduct product) public settle(product) returns (Fixed18) {\\n Position memory position_ = _latestPosition(product);\\n return product.rate(position_);\\n }\\n\\n /**\\n * @notice Product funding extrapolated to a daily rate after settle\\n * @param product Product address\\n * @return Product current funding extrapolated to a daily rate\\n */\\n function dailyRate(IProduct product) public settle(product) returns (Fixed18) {\\n Position memory position_ = _latestPosition(product);\\n return product.rate(position_).mul(Fixed18Lib.from(60 * 60 * 24));\\n }\\n\\n /**\\n * @notice Fees accumulated by product and protocol treasuries after settle\\n * @param product Product address\\n * @return protocolFees fees accrued by the protocol\\n * @return productFees fees accrued by the product owner\\n */\\n function fees(IProduct product) public settle(product) returns (UFixed18 protocolFees, UFixed18 productFees) {\\n address protocolTreasury = controller.treasury();\\n address productTreasury = controller.treasury(product);\\n\\n protocolFees = collateral().fees(protocolTreasury);\\n productFees = collateral().fees(productTreasury);\\n }\\n\\n /**\\n * @notice Product total open interest after settle\\n * @param product Product address\\n * @return Product maker and taker position multiplied by latest price after settle\\n */\\n function openInterest(IProduct product) public settle(product) returns (Position memory) {\\n return _latestPosition(product).mul(_latestVersion(product).price.abs());\\n }\\n\\n /**\\n * End Product Individual Fields Functions\\n */\\n\\n /**\\n * UserProduct Individual Fields Functions\\n */\\n\\n /**\\n * @notice User collateral amount for product after settle\\n * @param account Account address\\n * @param product Product address\\n * @return User deposited collateral for product\\n */\\n function collateral(address account, IProduct product) public settleAccount(account, product) returns (UFixed18) {\\n return collateral().collateral(account, product);\\n }\\n\\n /**\\n * @notice User maintenance amount for product after settle\\n * @param account Account address\\n * @param product Product address\\n * @return Maximum of user maintenance, and maintenanceNext\\n */\\n function maintenance(address account, IProduct product) public settleAccount(account, product) returns (UFixed18) {\\n return UFixed18Lib.max(product.maintenance(account), product.maintenanceNext(account));\\n }\\n\\n /**\\n * @notice User liquidatble status for product after settle\\n * @param account Account address\\n * @param product Product address\\n * @return Whether or not the user's position eligible to be liquidated\\n */\\n function liquidatable(address account, IProduct product) public settleAccount(account, product) returns (bool) {\\n return collateral().liquidatable(account, product);\\n }\\n\\n /**\\n * @notice User pre position for product after settle\\n * @param account Account address\\n * @param product Product address\\n * @return User pre-position\\n */\\n function pre(address account, IProduct product)\\n public\\n settleAccount(account, product)\\n returns (PrePosition memory)\\n {\\n return product.pre(account);\\n }\\n\\n /**\\n * @notice User position for product after settle\\n * @param account Account address\\n * @param product Product address\\n * @return User position\\n */\\n function position(address account, IProduct product)\\n public\\n settleAccount(account, product)\\n returns (Position memory)\\n {\\n return product.position(account);\\n }\\n\\n /**\\n * @notice User pre-position and position for product after settle\\n * @param account Account address\\n * @param product Product address\\n * @return User pre-position\\n * @return User position\\n */\\n function userPosition(address account, IProduct product)\\n public\\n settleAccount(account, product)\\n returns (PrePosition memory, Position memory)\\n {\\n return (product.pre(account), product.position(account));\\n }\\n\\n /**\\n * @notice Fees accumulated by account after settle\\n * @param account Account address\\n * @param product Product address\\n * @return sum of all fees accrued by the account\\n */\\n function fees(address account, IProduct product) public settleAccount(account, product) returns (UFixed18) {\\n return collateral().fees(account);\\n }\\n\\n /**\\n * @notice User's open interest in product after settle\\n * @param account Account address\\n * @param product Product address\\n * @return User's maker or taker position multiplied by latest price after settle\\n */\\n function openInterest(address account, IProduct product)\\n public\\n settleAccount(account, product)\\n returns (Position memory)\\n {\\n return product.position(account).mul(_latestVersion(product).price.abs());\\n }\\n\\n /**\\n * @notice User's exposure in product after settle\\n * @param account Account address\\n * @param product Product address\\n * @return User's exposure (openInterest * utilization) after settle\\n */\\n function exposure(address account, IProduct product) public settleAccount(account, product) returns (UFixed18) {\\n (, Position memory _pos) = globalPosition(product);\\n if (_pos.maker.eq(UFixed18Lib.ZERO)) { return UFixed18Lib.ZERO; }\\n\\n UFixed18 utilization = _pos.taker.div(_pos.maker);\\n Position memory _openInterest = openInterest(account, product);\\n\\n return utilization.mul(_openInterest.maker.gte(UFixed18Lib.ZERO) ? _openInterest.maker : _openInterest.taker);\\n }\\n\\n /**\\n * @notice User's maintenance required for position size in product after settle\\n * @param account Account address\\n * @param product Product address\\n * @param positionSize size of position for maintenance calculation\\n * @return Maintenance required for position in product\\n */\\n function maintenanceRequired(\\n address account,\\n IProduct product,\\n UFixed18 positionSize\\n ) public settleAccount(account, product) returns (UFixed18) {\\n UFixed18 notional = positionSize.mul(_latestVersion(product).price.abs());\\n return notional.mul(product.maintenance());\\n }\\n\\n /**\\n * @notice User's unclaimed rewards for all programs for product after settle\\n * @param account Account address\\n * @param product Product address\\n * @return tokens Token addresses of unclaimed incentive rewards for given product\\n * @return amounts Token amounts of unclaimed incentive rewards for given product\\n */\\n function unclaimedIncentiveRewards(address account, IProduct product)\\n public\\n settleAccount(account, product)\\n returns (Token18[] memory tokens, UFixed18[] memory amounts)\\n {\\n IIncentivizer incentivizer = controller.incentivizer();\\n\\n uint256 programsLength = incentivizer.count(product);\\n tokens = new Token18[](programsLength);\\n amounts = new UFixed18[](programsLength);\\n for (uint256 i = 0; i < programsLength; i++) {\\n ProgramInfo memory programInfo = incentivizer.programInfos(product, i);\\n tokens[i] = programInfo.token;\\n amounts[i] = incentivizer.unclaimed(product, account, i);\\n }\\n }\\n\\n /**\\n * @notice User's unclaimed rewards for provided programs for product after settle\\n * @param account Account address\\n * @param product Product address\\n * @param programIds Program IDs to query\\n * @return tokens Token addresses of unclaimed incentive rewards for given program IDs\\n * @return amounts Token amounts of unclaimed incentive rewards for given program IDs\\n */\\n function unclaimedIncentiveRewards(\\n address account,\\n IProduct product,\\n uint256[] calldata programIds\\n ) public settleAccount(account, product) returns (Token18[] memory tokens, UFixed18[] memory amounts) {\\n IIncentivizer incentivizer = controller.incentivizer();\\n tokens = new Token18[](programIds.length);\\n amounts = new UFixed18[](programIds.length);\\n for (uint256 i = 0; i < programIds.length; i++) {\\n ProgramInfo memory programInfo = incentivizer.programInfos(product, programIds[i]);\\n tokens[i] = programInfo.token;\\n amounts[i] = incentivizer.unclaimed(product, account, programIds[i]);\\n }\\n }\\n\\n /**\\n * End UserProduct Individual Fields Functions\\n */\\n\\n /**\\n * Private Helper Functions\\n */\\n\\n /**\\n * @notice Returns the Product's latest position\\n * @dev Private function, does not call settle itself\\n * @param product Product address\\n * @return Latest position for the product\\n */\\n function _latestPosition(IProduct product) private view returns (Position memory) {\\n return product.positionAtVersion(product.latestVersion());\\n }\\n\\n /**\\n * @notice Returns the Product's latest version\\n * @dev Private function, does not call settle itself\\n * @param product Product address\\n * @return Latest version for the product\\n */\\n function _latestVersion(IProduct product) private view returns (IOracleProvider.OracleVersion memory) {\\n return product.atVersion(product.latestVersion());\\n }\\n\\n /**\\n * End Private Helper Functions\\n */\\n\\n /**\\n * Modifier Functions\\n */\\n\\n /// @dev Settles the product\\n modifier settle(IProduct product) {\\n product.settle();\\n _;\\n }\\n\\n /// @dev Settles the product. product.settleAccount also settles the product\\n modifier settleAccount(address account, IProduct product) {\\n product.settleAccount(account);\\n _;\\n }\\n\\n /**\\n * End Modifier Functions\\n */\\n}\\n\",\"keccak256\":\"0xde79efaa7b24def388ce78eef9384b1328f2157266a73f453299ec34aaaaa324\",\"license\":\"Apache-2.0\"}},\"version\":1}", - "bytecode": "0x60a06040523480156200001157600080fd5b5060405162005d6738038062005d678339818101604052810190620000379190620000f0565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250505062000122565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620000a48262000077565b9050919050565b6000620000b88262000097565b9050919050565b620000ca81620000ab565b8114620000d657600080fd5b50565b600081519050620000ea81620000bf565b92915050565b60006020828403121562000109576200010862000072565b5b60006200011984828501620000d9565b91505092915050565b608051615c066200016160003960008181611a360152818161288201528181612ba101528181612c3701528181612f9a015261302d0152615c066000f3fe608060405234801561001057600080fd5b506004361061020b5760003560e01c80638f5edc081161012a578063b7a98f97116100bd578063edd8ca7b1161008c578063f77c479111610071578063f77c4791146107a1578063f8083f56146107bf578063faaebd21146107f05761020b565b8063edd8ca7b14610741578063f5c06e1b146107715761020b565b8063b7a98f9714610693578063cc218ece146106c3578063d8dfeb45146106f3578063e9c6b4c1146107115761020b565b8063a5fdc5de116100f9578063a5fdc5de146105d3578063a86e357614610603578063b4d6f78114610633578063b7648fb9146106635761020b565b80638f5edc08146105135780639b9ac2cb146105435780639bc02857146105735780639be2a567146105a35761020b565b806337e710ac116101a25780637e64cc13116101715780637e64cc131461045257806382df39de146104835780638e076924146104b35780638e480b20146104e35761020b565b806337e710ac14610391578063540027e6146103c15780636878353e146103f15780636efef085146104225761020b565b80631e0c6fb9116101de5780631e0c6fb9146102d1578063204e94b014610301578063237e58991461033157806326512160146103615761020b565b80630198489214610210578063036790c0146102405780630aae7a6b146102715780630ba9d8ca146102a1575b600080fd5b61022a60048036038101906102259190613899565b610821565b604051610237919061395f565b60405180910390f35b61025a60048036038101906102559190613899565b61089e565b604051610268929190613a75565b60405180910390f35b61028b60048036038101906102869190613899565b610991565b6040516102989190613e3c565b60405180910390f35b6102bb60048036038101906102b69190613899565b610dae565b6040516102c89190613e99565b60405180910390f35b6102eb60048036038101906102e69190613899565b610ea1565b6040516102f89190613eb4565b60405180910390f35b61031b60048036038101906103169190613efb565b610f81565b604051610328919061408b565b60405180910390f35b61034b60048036038101906103469190613efb565b611125565b60405161035891906140b6565b60405180910390f35b61037b60048036038101906103769190613899565b611246565b6040516103889190614320565b60405180910390f35b6103ab60048036038101906103a69190613efb565b61142d565b6040516103b891906140b6565b60405180910390f35b6103db60048036038101906103d69190613899565b6115a2565b6040516103e89190613e99565b60405180910390f35b61040b60048036038101906104069190613efb565b6116b2565b604051610419929190613a75565b60405180910390f35b61043c600480360381019061043791906144b6565b61182f565b60405161044991906145c1565b60405180910390f35b61046c60048036038101906104679190613efb565b6119c2565b60405161047a929190614762565b60405180910390f35b61049d60048036038101906104989190613efb565b611d73565b6040516104aa91906147a8565b60405180910390f35b6104cd60048036038101906104c891906147ef565b611e6f565b6040516104da91906140b6565b60405180910390f35b6104fd60048036038101906104f89190613899565b611f96565b60405161050a9190614884565b60405180910390f35b61052d60048036038101906105289190614962565b612010565b60405161053a9190614b52565b60405180910390f35b61055d60048036038101906105589190613efb565b6120d1565b60405161056a91906140b6565b60405180910390f35b61058d60048036038101906105889190614bcf565b6121cb565b60405161059a9190614df9565b60405180910390f35b6105bd60048036038101906105b89190613efb565b61229c565b6040516105ca9190613eb4565b60405180910390f35b6105ed60048036038101906105e89190613899565b612395565b6040516105fa91906140b6565b60405180910390f35b61061d60048036038101906106189190613899565b612481565b60405161062a919061395f565b60405180910390f35b61064d60048036038101906106489190613899565b6124fe565b60405161065a91906140b6565b60405180910390f35b61067d60048036038101906106789190613899565b6125ea565b60405161068a9190614e1b565b60405180910390f35b6106ad60048036038101906106a89190613efb565b612664565b6040516106ba9190614e1b565b60405180910390f35b6106dd60048036038101906106d89190613efb565b612782565b6040516106ea91906140b6565b60405180910390f35b6106fb61287e565b6040516107089190614e57565b60405180910390f35b61072b60048036038101906107269190613efb565b612914565b6040516107389190614e1b565b60405180910390f35b61075b60048036038101906107569190613899565b612a0c565b6040516107689190614e1b565b60405180910390f35b61078b60048036038101906107869190613efb565b612aac565b60405161079891906147a8565b60405180910390f35b6107a9612b9f565b6040516107b69190614e93565b60405180910390f35b6107d960048036038101906107d49190614f04565b612bc3565b6040516107e7929190614762565b60405180910390f35b61080a60048036038101906108059190613899565b612f32565b604051610818929190614f78565b60405180910390f35b60608173ffffffffffffffffffffffffffffffffffffffff166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa15801561086e573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906108979190615047565b9050919050565b6108a6613573565b6108ae6135a0565b828073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156108f757600080fd5b505af115801561090b573d6000803e3d6000fd5b505050508373ffffffffffffffffffffffffffffffffffffffff166359ea287d6040518163ffffffff1660e01b815260040160a060405180830381865afa15801561095a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061097e9190615173565b610987856131d5565b9250925050915091565b6109996135ba565b6109a282610821565b81600001819052506109b382612481565b81602001819052508173ffffffffffffffffffffffffffffffffffffffff166305d5c1cb6040518163ffffffff1660e01b8152600401606060405180830381865afa158015610a06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a2a919061527a565b81604001819052508173ffffffffffffffffffffffffffffffffffffffff16637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a7d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aa191906152e5565b816060019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508173ffffffffffffffffffffffffffffffffffffffff16636c376cc56040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b23573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b479190615312565b8160800181815250508173ffffffffffffffffffffffffffffffffffffffff16635d16e1206040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b9b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bbf9190615312565b8160a00181815250508173ffffffffffffffffffffffffffffffffffffffff1663fc741c7c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c379190615312565b8160c00181815250508173ffffffffffffffffffffffffffffffffffffffff166343f0179b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c8b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610caf9190615312565b8160e00181815250508173ffffffffffffffffffffffffffffffffffffffff1663193775676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d03573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d279190615312565b816101000181815250508173ffffffffffffffffffffffffffffffffffffffff1663a12e1b336040518163ffffffff1660e01b8152600401608060405180830381865afa158015610d7c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da0919061540f565b816101200181905250919050565b6000818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610df957600080fd5b505af1158015610e0d573d6000803e3d6000fd5b505050506000610e1c846131d5565b90508373ffffffffffffffffffffffffffffffffffffffff166360ec91d6826040518263ffffffff1660e01b8152600401610e579190614e1b565b602060405180830381865afa158015610e74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e989190615468565b92505050919050565b610ea9613573565b818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610ef257600080fd5b505af1158015610f06573d6000803e3d6000fd5b505050508273ffffffffffffffffffffffffffffffffffffffff166359ea287d6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610f55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f799190615173565b915050919050565b610f8961362f565b82828073ffffffffffffffffffffffffffffffffffffffff1663f667f897836040518263ffffffff1660e01b8152600401610fc491906154a4565b600060405180830381600087803b158015610fde57600080fd5b505af1158015610ff2573d6000803e3d6000fd5b5050505083836000019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505084836020019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506110708585612782565b836040018181525050611083858561142d565b836060018181525050611096858561229c565b83608001819052506110a88585612914565b8360a001819052506110ba8585611d73565b8360c00190151590811515815250506110d38585612aac565b8360e00190151590811515815250506110ec8585612664565b8361010001819052506110ff85856120d1565b836101200181815250506111138585611125565b83610140018181525050505092915050565b600082828073ffffffffffffffffffffffffffffffffffffffff1663f667f897836040518263ffffffff1660e01b815260040161116291906154a4565b600060405180830381600087803b15801561117c57600080fd5b505af1158015611190573d6000803e3d6000fd5b5050505060006111a08686612664565b90506111ba600082602001516132cb90919063ffffffff16565b156111cc57806020015193505061123e565b60006111d78661089e565b9150506111f2600082600001516132e290919063ffffffff16565b156112025760009450505061123e565b600061121f826000015183602001516132f990919063ffffffff16565b905061123883600001518261332290919063ffffffff16565b95505050505b505092915050565b61124e6136cb565b818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561129757600080fd5b505af11580156112ab573d6000803e3d6000fd5b505050506112b883610991565b826000018190525082826020019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505061130183610dae565b826040018181525050611313836115a2565b82606001818152505061132583611f96565b82608001819052508273ffffffffffffffffffffffffffffffffffffffff16636c376cc56040518163ffffffff1660e01b8152600401602060405180830381865afa158015611378573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061139c9190615312565b8260a00181815250506113ae83612395565b8260c00181815250506113c0836124fe565b8260e00181815250506113d283610ea1565b8261010001819052506113e4836125ea565b8261012001819052506000806113f985612f32565b915091508184610140018181525050808461016001818152505061141c85612a0c565b846101800181905250505050919050565b600082828073ffffffffffffffffffffffffffffffffffffffff1663f667f897836040518263ffffffff1660e01b815260040161146a91906154a4565b600060405180830381600087803b15801561148457600080fd5b505af1158015611498573d6000803e3d6000fd5b505050506115988473ffffffffffffffffffffffffffffffffffffffff166391689024876040518263ffffffff1660e01b81526004016114d891906154a4565b602060405180830381865afa1580156114f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115199190615312565b8573ffffffffffffffffffffffffffffffffffffffff1663ab582f29886040518263ffffffff1660e01b815260040161155291906154a4565b602060405180830381865afa15801561156f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115939190615312565b61334b565b9250505092915050565b6000818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156115ed57600080fd5b505af1158015611601573d6000803e3d6000fd5b505050506000611610846131d5565b90506116a96116216201518061335f565b8573ffffffffffffffffffffffffffffffffffffffff166360ec91d6846040518263ffffffff1660e01b815260040161165a9190614e1b565b602060405180830381865afa158015611677573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061169b9190615468565b61337c90919063ffffffff16565b92505050919050565b6116ba613573565b6116c26135a0565b83838073ffffffffffffffffffffffffffffffffffffffff1663f667f897836040518263ffffffff1660e01b81526004016116fd91906154a4565b600060405180830381600087803b15801561171757600080fd5b505af115801561172b573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff16631e0c6fb9876040518263ffffffff1660e01b815260040161176891906154a4565b60a060405180830381865afa158015611785573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117a99190615173565b8573ffffffffffffffffffffffffffffffffffffffff1663b7648fb9886040518263ffffffff1660e01b81526004016117e291906154a4565b6040805180830381865afa1580156117fe573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061182291906154bf565b9350935050509250929050565b6060828073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561187a57600080fd5b505af115801561188e573d6000803e3d6000fd5b50505050825167ffffffffffffffff8111156118ad576118ac614347565b5b6040519080825280602002602001820160405280156118e657816020015b6118d3613767565b8152602001906001900390816118cb5790505b50915060005b83518110156119ba578473ffffffffffffffffffffffffffffffffffffffff16637ece075d858381518110611924576119236154ec565b5b60200260200101516040518263ffffffff1660e01b8152600401611948919061552a565b606060405180830381865afa158015611965573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061198991906155a9565b83828151811061199c5761199b6154ec565b5b602002602001018190525080806119b290615605565b9150506118ec565b505092915050565b60608083838073ffffffffffffffffffffffffffffffffffffffff1663f667f897836040518263ffffffff1660e01b8152600401611a0091906154a4565b600060405180830381600087803b158015611a1a57600080fd5b505af1158015611a2e573d6000803e3d6000fd5b5050505060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16636fc6407c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a9f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ac3919061568b565b905060008173ffffffffffffffffffffffffffffffffffffffff166305d85eda886040518263ffffffff1660e01b8152600401611b0091906156d9565b602060405180830381865afa158015611b1d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b4191906156f4565b90508067ffffffffffffffff811115611b5d57611b5c614347565b5b604051908082528060200260200182016040528015611b8b5781602001602082028036833780820191505090505b5095508067ffffffffffffffff811115611ba857611ba7614347565b5b604051908082528060200260200182016040528015611bd65781602001602082028036833780820191505090505b50945060005b81811015611d675760008373ffffffffffffffffffffffffffffffffffffffff16632c3e50e58a846040518363ffffffff1660e01b8152600401611c21929190615721565b60c060405180830381865afa158015611c3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c629190615802565b90508060800151888381518110611c7c57611c7b6154ec565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508373ffffffffffffffffffffffffffffffffffffffff166366f8162e8a8c856040518463ffffffff1660e01b8152600401611cf39392919061582f565b602060405180830381865afa158015611d10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d349190615312565b878381518110611d4757611d466154ec565b5b602002602001018181525050508080611d5f90615605565b915050611bdc565b50505050509250929050565b600082828073ffffffffffffffffffffffffffffffffffffffff1663f667f897836040518263ffffffff1660e01b8152600401611db091906154a4565b600060405180830381600087803b158015611dca57600080fd5b505af1158015611dde573d6000803e3d6000fd5b50505050611dea61287e565b73ffffffffffffffffffffffffffffffffffffffff166382df39de86866040518363ffffffff1660e01b8152600401611e24929190615866565b602060405180830381865afa158015611e41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e6591906158bb565b9250505092915050565b600083838073ffffffffffffffffffffffffffffffffffffffff1663f667f897836040518263ffffffff1660e01b8152600401611eac91906154a4565b600060405180830381600087803b158015611ec657600080fd5b505af1158015611eda573d6000803e3d6000fd5b505050506000611f07611ef8611eef886133a5565b6040015161349c565b8661332290919063ffffffff16565b9050611f8a8673ffffffffffffffffffffffffffffffffffffffff16636c376cc56040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f7b9190615312565b8261332290919063ffffffff16565b93505050509392505050565b611f9e613767565b818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611fe757600080fd5b505af1158015611ffb573d6000803e3d6000fd5b50505050612008836133a5565b915050919050565b6060815167ffffffffffffffff81111561202d5761202c614347565b5b60405190808252806020026020018201604052801561206657816020015b61205361362f565b81526020019060019003908161204b5790505b50905060005b82518110156120ca576120998484838151811061208c5761208b6154ec565b5b6020026020010151610f81565b8282815181106120ac576120ab6154ec565b5b602002602001018190525080806120c290615605565b91505061206c565b5092915050565b600082828073ffffffffffffffffffffffffffffffffffffffff1663f667f897836040518263ffffffff1660e01b815260040161210e91906154a4565b600060405180830381600087803b15801561212857600080fd5b505af115801561213c573d6000803e3d6000fd5b5050505061214861287e565b73ffffffffffffffffffffffffffffffffffffffff1663faaebd21866040518263ffffffff1660e01b815260040161218091906154a4565b602060405180830381865afa15801561219d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121c19190615312565b9250505092915050565b60608282905067ffffffffffffffff8111156121ea576121e9614347565b5b60405190808252806020026020018201604052801561222357816020015b6122106136cb565b8152602001906001900390816122085790505b50905060005b838390508110156122955761226484848381811061224a576122496154ec565b5b905060200201602081019061225f9190613899565b611246565b828281518110612277576122766154ec565b5b6020026020010181905250808061228d90615605565b915050612229565b5092915050565b6122a4613573565b82828073ffffffffffffffffffffffffffffffffffffffff1663f667f897836040518263ffffffff1660e01b81526004016122df91906154a4565b600060405180830381600087803b1580156122f957600080fd5b505af115801561230d573d6000803e3d6000fd5b505050508373ffffffffffffffffffffffffffffffffffffffff16631e0c6fb9866040518263ffffffff1660e01b815260040161234a91906154a4565b60a060405180830381865afa158015612367573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061238b9190615173565b9250505092915050565b6000818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156123e057600080fd5b505af11580156123f4573d6000803e3d6000fd5b5050505061240061287e565b73ffffffffffffffffffffffffffffffffffffffff1663a5fdc5de846040518263ffffffff1660e01b815260040161243891906156d9565b602060405180830381865afa158015612455573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124799190615312565b915050919050565b60608173ffffffffffffffffffffffffffffffffffffffff166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa1580156124ce573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906124f79190615047565b9050919050565b6000818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561254957600080fd5b505af115801561255d573d6000803e3d6000fd5b5050505061256961287e565b73ffffffffffffffffffffffffffffffffffffffff1663b4d6f781846040518263ffffffff1660e01b81526004016125a191906156d9565b602060405180830381865afa1580156125be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125e29190615312565b915050919050565b6125f26135a0565b818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561263b57600080fd5b505af115801561264f573d6000803e3d6000fd5b5050505061265c836131d5565b915050919050565b61266c6135a0565b82828073ffffffffffffffffffffffffffffffffffffffff1663f667f897836040518263ffffffff1660e01b81526004016126a791906154a4565b600060405180830381600087803b1580156126c157600080fd5b505af11580156126d5573d6000803e3d6000fd5b505050506127786126f16126e8866133a5565b6040015161349c565b8573ffffffffffffffffffffffffffffffffffffffff1663b7648fb9886040518263ffffffff1660e01b815260040161272a91906154a4565b6040805180830381865afa158015612746573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061276a91906154bf565b6134ae90919063ffffffff16565b9250505092915050565b600082828073ffffffffffffffffffffffffffffffffffffffff1663f667f897836040518263ffffffff1660e01b81526004016127bf91906154a4565b600060405180830381600087803b1580156127d957600080fd5b505af11580156127ed573d6000803e3d6000fd5b505050506127f961287e565b73ffffffffffffffffffffffffffffffffffffffff1663cc218ece86866040518363ffffffff1660e01b8152600401612833929190615866565b602060405180830381865afa158015612850573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128749190615312565b9250505092915050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa1580156128eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061290f9190615926565b905090565b61291c6135a0565b82828073ffffffffffffffffffffffffffffffffffffffff1663f667f897836040518263ffffffff1660e01b815260040161295791906154a4565b600060405180830381600087803b15801561297157600080fd5b505af1158015612985573d6000803e3d6000fd5b505050508373ffffffffffffffffffffffffffffffffffffffff1663b7648fb9866040518263ffffffff1660e01b81526004016129c291906154a4565b6040805180830381865afa1580156129de573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a0291906154bf565b9250505092915050565b612a146135a0565b818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b158015612a5d57600080fd5b505af1158015612a71573d6000803e3d6000fd5b50505050612aa4612a8d612a84856133a5565b6040015161349c565b612a96856131d5565b6134ae90919063ffffffff16565b915050919050565b600082828073ffffffffffffffffffffffffffffffffffffffff1663f667f897836040518263ffffffff1660e01b8152600401612ae991906154a4565b600060405180830381600087803b158015612b0357600080fd5b505af1158015612b17573d6000803e3d6000fd5b505050508373ffffffffffffffffffffffffffffffffffffffff166358ca6f98866040518263ffffffff1660e01b8152600401612b5491906154a4565b602060405180830381865afa158015612b71573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b9591906158bb565b9250505092915050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60608085858073ffffffffffffffffffffffffffffffffffffffff1663f667f897836040518263ffffffff1660e01b8152600401612c0191906154a4565b600060405180830381600087803b158015612c1b57600080fd5b505af1158015612c2f573d6000803e3d6000fd5b5050505060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16636fc6407c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ca0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cc4919061568b565b90508686905067ffffffffffffffff811115612ce357612ce2614347565b5b604051908082528060200260200182016040528015612d115781602001602082028036833780820191505090505b5094508686905067ffffffffffffffff811115612d3157612d30614347565b5b604051908082528060200260200182016040528015612d5f5781602001602082028036833780820191505090505b50935060005b87879050811015612f255760008273ffffffffffffffffffffffffffffffffffffffff16632c3e50e58b8b8b86818110612da257612da16154ec565b5b905060200201356040518363ffffffff1660e01b8152600401612dc6929190615721565b60c060405180830381865afa158015612de3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e079190615802565b90508060800151878381518110612e2157612e206154ec565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508273ffffffffffffffffffffffffffffffffffffffff166366f8162e8b8d8c8c87818110612e8c57612e8b6154ec565b5b905060200201356040518463ffffffff1660e01b8152600401612eb19392919061582f565b602060405180830381865afa158015612ece573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ef29190615312565b868381518110612f0557612f046154ec565b5b602002602001018181525050508080612f1d90615605565b915050612d65565b5050505094509492505050565b600080828073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b158015612f7e57600080fd5b505af1158015612f92573d6000803e3d6000fd5b5050505060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015613003573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130279190615968565b905060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16632d809cb6876040518263ffffffff1660e01b815260040161308491906156d9565b602060405180830381865afa1580156130a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130c59190615968565b90506130cf61287e565b73ffffffffffffffffffffffffffffffffffffffff1663faaebd21836040518263ffffffff1660e01b815260040161310791906154a4565b602060405180830381865afa158015613124573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131489190615312565b945061315261287e565b73ffffffffffffffffffffffffffffffffffffffff1663faaebd21826040518263ffffffff1660e01b815260040161318a91906154a4565b602060405180830381865afa1580156131a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131cb9190615312565b9350505050915091565b6131dd6135a0565b8173ffffffffffffffffffffffffffffffffffffffff16639a427d038373ffffffffffffffffffffffffffffffffffffffff1663c07f47d46040518163ffffffff1660e01b8152600401602060405180830381865afa158015613244573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061326891906156f4565b6040518263ffffffff1660e01b8152600401613284919061552a565b6040805180830381865afa1580156132a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132c491906154bf565b9050919050565b600060026132d984846134ff565b14905092915050565b600060016132f084846134ff565b14905092915050565b600081670de0b6b3a7640000846133109190615995565b61331a9190615a1e565b905092915050565b6000670de0b6b3a764000082846133399190615995565b6133439190615a1e565b905092915050565b6000613357838361353d565b905092915050565b6000670de0b6b3a7640000826133759190615a4f565b9050919050565b6000670de0b6b3a764000082846133939190615a4f565b61339d9190615b66565b905092915050565b6133ad613767565b8173ffffffffffffffffffffffffffffffffffffffff16637ece075d8373ffffffffffffffffffffffffffffffffffffffff1663c07f47d46040518163ffffffff1660e01b8152600401602060405180830381865afa158015613414573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061343891906156f4565b6040518263ffffffff1660e01b8152600401613454919061552a565b606060405180830381865afa158015613471573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061349591906155a9565b9050919050565b60006134a782613557565b9050919050565b6134b66135a0565b60405180604001604052806134d884866000015161332290919063ffffffff16565b81526020016134f484866020015161332290919063ffffffff16565b815250905092915050565b60008060008484915091508082111561351d57600292505050613537565b8082101561353057600092505050613537565b6001925050505b92915050565b60008183101561354d578161354f565b825b905092915050565b60008082121561356a578160000361356c565b815b9050919050565b60405180606001604052806000815260200161358d6135a0565b815260200161359a6135a0565b81525090565b604051806040016040528060008152602001600081525090565b60405180610140016040528060608152602001606081526020016135dc613788565b8152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001600081526020016000815260200160008152602001600081526020016136296137d2565b81525090565b604051806101600160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600081526020016000815260200161368b613573565b81526020016136986135a0565b81526020016000151581526020016000151581526020016136b76135a0565b815260200160008152602001600081525090565b604051806101a001604052806136df6135ba565b8152602001600073ffffffffffffffffffffffffffffffffffffffff1681526020016000815260200160008152602001613717613767565b8152602001600081526020016000815260200160008152602001613739613573565b81526020016137466135a0565b815260200160008152602001600081526020016137616135a0565b81525090565b60405180606001604052806000815260200160008152602001600081525090565b6040518060600160405280600060018111156137a7576137a6613ae8565b5b8152602001600060018111156137c0576137bf613ae8565b5b8152602001600061ffff191681525090565b60405180608001604052806000600f0b81526020016000600f0b81526020016000600f0b815260200160006fffffffffffffffffffffffffffffffff1681525090565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061385482613829565b9050919050565b600061386682613849565b9050919050565b6138768161385b565b811461388157600080fd5b50565b6000813590506138938161386d565b92915050565b6000602082840312156138af576138ae61381f565b5b60006138bd84828501613884565b91505092915050565b600081519050919050565b600082825260208201905092915050565b60005b838110156139005780820151818401526020810190506138e5565b8381111561390f576000848401525b50505050565b6000601f19601f8301169050919050565b6000613931826138c6565b61393b81856138d1565b935061394b8185602086016138e2565b61395481613915565b840191505092915050565b600060208201905081810360008301526139798184613926565b905092915050565b6000819050919050565b61399481613981565b82525050565b6000819050919050565b60006139bf6139ba6139b584613981565b61399a565b613981565b9050919050565b6139cf816139a4565b82525050565b6040820160008201516139eb60008501826139c6565b5060208201516139fe60208501826139c6565b50505050565b60a082016000820151613a1a600085018261398b565b506020820151613a2d60208501826139d5565b506040820151613a4060608501826139d5565b50505050565b604082016000820151613a5c60008501826139c6565b506020820151613a6f60208501826139c6565b50505050565b600060e082019050613a8a6000830185613a04565b613a9760a0830184613a46565b9392505050565b600082825260208201905092915050565b6000613aba826138c6565b613ac48185613a9e565b9350613ad48185602086016138e2565b613add81613915565b840191505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60028110613b2857613b27613ae8565b5b50565b6000819050613b3982613b17565b919050565b6000613b4982613b2b565b9050919050565b613b5981613b3e565b82525050565b60028110613b7057613b6f613ae8565b5b50565b6000819050613b8182613b5f565b919050565b6000613b9182613b73565b9050919050565b613ba181613b86565b82525050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000082169050919050565b613bdc81613ba7565b82525050565b606082016000820151613bf86000850182613b50565b506020820151613c0b6020850182613b98565b506040820151613c1e6040850182613bd3565b50505050565b6000613c3f613c3a613c3584613829565b61399a565b613829565b9050919050565b6000613c5182613c24565b9050919050565b6000613c6382613c46565b9050919050565b613c7381613c58565b82525050565b600081600f0b9050919050565b6000613ca1613c9c613c9784613c79565b61399a565b613c79565b9050919050565b613cb181613c86565b82525050565b60006fffffffffffffffffffffffffffffffff82169050919050565b6000613cee613ce9613ce484613cb7565b61399a565b613cb7565b9050919050565b613cfe81613cd3565b82525050565b608082016000820151613d1a6000850182613ca8565b506020820151613d2d6020850182613ca8565b506040820151613d406040850182613ca8565b506060820151613d536060850182613cf5565b50505050565b60006101e0830160008301518482036000860152613d778282613aaf565b91505060208301518482036020860152613d918282613aaf565b9150506040830151613da66040860182613be2565b506060830151613db960a0860182613c6a565b506080830151613dcc60c08601826139c6565b5060a0830151613ddf60e08601826139c6565b5060c0830151613df36101008601826139c6565b5060e0830151613e076101208601826139c6565b50610100830151613e1c6101408601826139c6565b50610120830151613e31610160860182613d04565b508091505092915050565b60006020820190508181036000830152613e568184613d59565b905092915050565b6000819050919050565b6000613e83613e7e613e7984613e5e565b61399a565b613e5e565b9050919050565b613e9381613e68565b82525050565b6000602082019050613eae6000830184613e8a565b92915050565b600060a082019050613ec96000830184613a04565b92915050565b613ed881613849565b8114613ee357600080fd5b50565b600081359050613ef581613ecf565b92915050565b60008060408385031215613f1257613f1161381f565b5b6000613f2085828601613ee6565b9250506020613f3185828601613884565b9150509250929050565b613f4481613849565b82525050565b60a082016000820151613f60600085018261398b565b506020820151613f7360208501826139d5565b506040820151613f8660608501826139d5565b50505050565b60008115159050919050565b613fa181613f8c565b82525050565b61022082016000820151613fbe6000850182613f3b565b506020820151613fd16020850182613f3b565b506040820151613fe460408501826139c6565b506060820151613ff760608501826139c6565b50608082015161400a6080850182613f4a565b5060a082015161401e6101208501826139d5565b5060c0820151614032610160850182613f98565b5060e0820151614046610180850182613f98565b5061010082015161405b6101a08501826139d5565b506101208201516140706101e08501826139c6565b506101408201516140856102008501826139c6565b50505050565b6000610220820190506140a16000830184613fa7565b92915050565b6140b0816139a4565b82525050565b60006020820190506140cb60008301846140a7565b92915050565b60006101e08301600083015184820360008601526140ef8282613aaf565b915050602083015184820360208601526141098282613aaf565b915050604083015161411e6040860182613be2565b50606083015161413160a0860182613c6a565b50608083015161414460c08601826139c6565b5060a083015161415760e08601826139c6565b5060c083015161416b6101008601826139c6565b5060e083015161417f6101208601826139c6565b506101008301516141946101408601826139c6565b506101208301516141a9610160860182613d04565b508091505092915050565b6141bd81613e68565b82525050565b6060820160008201516141d9600085018261398b565b5060208201516141ec602085018261398b565b5060408201516141ff60408501826141b4565b50505050565b60006102a083016000830151848203600086015261422382826140d1565b91505060208301516142386020860182613f3b565b50604083015161424b60408601826141b4565b50606083015161425e60608601826141b4565b50608083015161427160808601826141c3565b5060a083015161428460e08601826139c6565b5060c08301516142986101008601826139c6565b5060e08301516142ac6101208601826139c6565b506101008301516142c1610140860182613f4a565b506101208301516142d66101e08601826139d5565b506101408301516142eb6102208601826139c6565b506101608301516143006102408601826139c6565b506101808301516143156102608601826139d5565b508091505092915050565b6000602082019050818103600083015261433a8184614205565b905092915050565b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61437f82613915565b810181811067ffffffffffffffff8211171561439e5761439d614347565b5b80604052505050565b60006143b1613815565b90506143bd8282614376565b919050565b600067ffffffffffffffff8211156143dd576143dc614347565b5b602082029050602081019050919050565b600080fd5b6143fc81613981565b811461440757600080fd5b50565b600081359050614419816143f3565b92915050565b600061443261442d846143c2565b6143a7565b90508083825260208201905060208402830185811115614455576144546143ee565b5b835b8181101561447e578061446a888261440a565b845260208401935050602081019050614457565b5050509392505050565b600082601f83011261449d5761449c614342565b5b81356144ad84826020860161441f565b91505092915050565b600080604083850312156144cd576144cc61381f565b5b60006144db85828601613884565b925050602083013567ffffffffffffffff8111156144fc576144fb613824565b5b61450885828601614488565b9150509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b600061454a83836141c3565b60608301905092915050565b6000602082019050919050565b600061456e82614512565b614578818561451d565b93506145838361452e565b8060005b838110156145b457815161459b888261453e565b97506145a683614556565b925050600181019050614587565b5085935050505092915050565b600060208201905081810360008301526145db8184614563565b905092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b600061461a82613c46565b9050919050565b61462a8161460f565b82525050565b600061463c8383614621565b60208301905092915050565b6000602082019050919050565b6000614660826145e3565b61466a81856145ee565b9350614675836145ff565b8060005b838110156146a657815161468d8882614630565b975061469883614648565b925050600181019050614679565b5085935050505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60006146eb83836139c6565b60208301905092915050565b6000602082019050919050565b600061470f826146b3565b61471981856146be565b9350614724836146cf565b8060005b8381101561475557815161473c88826146df565b9750614747836146f7565b925050600181019050614728565b5085935050505092915050565b6000604082019050818103600083015261477c8185614655565b905081810360208301526147908184614704565b90509392505050565b6147a281613f8c565b82525050565b60006020820190506147bd6000830184614799565b92915050565b6147cc81613981565b81146147d757600080fd5b50565b6000813590506147e9816147c3565b92915050565b6000806000606084860312156148085761480761381f565b5b600061481686828701613ee6565b935050602061482786828701613884565b9250506040614838868287016147da565b9150509250925092565b606082016000820151614858600085018261398b565b50602082015161486b602085018261398b565b50604082015161487e60408501826141b4565b50505050565b60006060820190506148996000830184614842565b92915050565b600067ffffffffffffffff8211156148ba576148b9614347565b5b602082029050602081019050919050565b60006148de6148d98461489f565b6143a7565b90508083825260208201905060208402830185811115614901576149006143ee565b5b835b8181101561492a57806149168882613884565b845260208401935050602081019050614903565b5050509392505050565b600082601f83011261494957614948614342565b5b81356149598482602086016148cb565b91505092915050565b600080604083850312156149795761497861381f565b5b600061498785828601613ee6565b925050602083013567ffffffffffffffff8111156149a8576149a7613824565b5b6149b485828601614934565b9150509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b61022082016000820151614a016000850182613f3b565b506020820151614a146020850182613f3b565b506040820151614a2760408501826139c6565b506060820151614a3a60608501826139c6565b506080820151614a4d6080850182613f4a565b5060a0820151614a616101208501826139d5565b5060c0820151614a75610160850182613f98565b5060e0820151614a89610180850182613f98565b50610100820151614a9e6101a08501826139d5565b50610120820151614ab36101e08501826139c6565b50610140820151614ac86102008501826139c6565b50505050565b6000614ada83836149ea565b6102208301905092915050565b6000602082019050919050565b6000614aff826149be565b614b0981856149c9565b9350614b14836149da565b8060005b83811015614b45578151614b2c8882614ace565b9750614b3783614ae7565b925050600181019050614b18565b5085935050505092915050565b60006020820190508181036000830152614b6c8184614af4565b905092915050565b600080fd5b60008083601f840112614b8f57614b8e614342565b5b8235905067ffffffffffffffff811115614bac57614bab614b74565b5b602083019150836020820283011115614bc857614bc76143ee565b5b9250929050565b60008060208385031215614be657614be561381f565b5b600083013567ffffffffffffffff811115614c0457614c03613824565b5b614c1085828601614b79565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60006102a0830160008301518482036000860152614c6682826140d1565b9150506020830151614c7b6020860182613f3b565b506040830151614c8e60408601826141b4565b506060830151614ca160608601826141b4565b506080830151614cb460808601826141c3565b5060a0830151614cc760e08601826139c6565b5060c0830151614cdb6101008601826139c6565b5060e0830151614cef6101208601826139c6565b50610100830151614d04610140860182613f4a565b50610120830151614d196101e08601826139d5565b50610140830151614d2e6102208601826139c6565b50610160830151614d436102408601826139c6565b50610180830151614d586102608601826139d5565b508091505092915050565b6000614d6f8383614c48565b905092915050565b6000602082019050919050565b6000614d8f82614c1c565b614d998185614c27565b935083602082028501614dab85614c38565b8060005b85811015614de75784840389528151614dc88582614d63565b9450614dd383614d77565b925060208a01995050600181019050614daf565b50829750879550505050505092915050565b60006020820190508181036000830152614e138184614d84565b905092915050565b6000604082019050614e306000830184613a46565b92915050565b6000614e4182613c46565b9050919050565b614e5181614e36565b82525050565b6000602082019050614e6c6000830184614e48565b92915050565b6000614e7d82613c46565b9050919050565b614e8d81614e72565b82525050565b6000602082019050614ea86000830184614e84565b92915050565b60008083601f840112614ec457614ec3614342565b5b8235905067ffffffffffffffff811115614ee157614ee0614b74565b5b602083019150836020820283011115614efd57614efc6143ee565b5b9250929050565b60008060008060608587031215614f1e57614f1d61381f565b5b6000614f2c87828801613ee6565b9450506020614f3d87828801613884565b935050604085013567ffffffffffffffff811115614f5e57614f5d613824565b5b614f6a87828801614eae565b925092505092959194509250565b6000604082019050614f8d60008301856140a7565b614f9a60208301846140a7565b9392505050565b600080fd5b600067ffffffffffffffff821115614fc157614fc0614347565b5b614fca82613915565b9050602081019050919050565b6000614fea614fe584614fa6565b6143a7565b90508281526020810184848401111561500657615005614fa1565b5b6150118482856138e2565b509392505050565b600082601f83011261502e5761502d614342565b5b815161503e848260208601614fd7565b91505092915050565b60006020828403121561505d5761505c61381f565b5b600082015167ffffffffffffffff81111561507b5761507a613824565b5b61508784828501615019565b91505092915050565b600080fd5b6000815190506150a4816143f3565b92915050565b6000815190506150b9816147c3565b92915050565b6000604082840312156150d5576150d4615090565b5b6150df60406143a7565b905060006150ef848285016150aa565b6000830152506020615103848285016150aa565b60208301525092915050565b600060a0828403121561512557615124615090565b5b61512f60606143a7565b9050600061513f84828501615095565b6000830152506020615153848285016150bf565b6020830152506060615167848285016150bf565b60408301525092915050565b600060a082840312156151895761518861381f565b5b60006151978482850161510f565b91505092915050565b600281106151ad57600080fd5b50565b6000815190506151bf816151a0565b92915050565b600281106151d257600080fd5b50565b6000815190506151e4816151c5565b92915050565b6151f381613ba7565b81146151fe57600080fd5b50565b600081519050615210816151ea565b92915050565b60006060828403121561522c5761522b615090565b5b61523660606143a7565b90506000615246848285016151b0565b600083015250602061525a848285016151d5565b602083015250604061526e84828501615201565b60408301525092915050565b6000606082840312156152905761528f61381f565b5b600061529e84828501615216565b91505092915050565b60006152b282613849565b9050919050565b6152c2816152a7565b81146152cd57600080fd5b50565b6000815190506152df816152b9565b92915050565b6000602082840312156152fb576152fa61381f565b5b6000615309848285016152d0565b91505092915050565b6000602082840312156153285761532761381f565b5b6000615336848285016150aa565b91505092915050565b61534881613c79565b811461535357600080fd5b50565b6000815190506153658161533f565b92915050565b61537481613cb7565b811461537f57600080fd5b50565b6000815190506153918161536b565b92915050565b6000608082840312156153ad576153ac615090565b5b6153b760806143a7565b905060006153c784828501615356565b60008301525060206153db84828501615356565b60208301525060406153ef84828501615356565b604083015250606061540384828501615382565b60608301525092915050565b6000608082840312156154255761542461381f565b5b600061543384828501615397565b91505092915050565b61544581613e5e565b811461545057600080fd5b50565b6000815190506154628161543c565b92915050565b60006020828403121561547e5761547d61381f565b5b600061548c84828501615453565b91505092915050565b61549e81613849565b82525050565b60006020820190506154b96000830184615495565b92915050565b6000604082840312156154d5576154d461381f565b5b60006154e3848285016150bf565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b61552481613981565b82525050565b600060208201905061553f600083018461551b565b92915050565b60006060828403121561555b5761555a615090565b5b61556560606143a7565b9050600061557584828501615095565b600083015250602061558984828501615095565b602083015250604061559d84828501615453565b60408301525092915050565b6000606082840312156155bf576155be61381f565b5b60006155cd84828501615545565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061561082613981565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203615642576156416155d6565b5b600182019050919050565b600061565882613849565b9050919050565b6156688161564d565b811461567357600080fd5b50565b6000815190506156858161565f565b92915050565b6000602082840312156156a1576156a061381f565b5b60006156af84828501615676565b91505092915050565b60006156c382613c46565b9050919050565b6156d3816156b8565b82525050565b60006020820190506156ee60008301846156ca565b92915050565b60006020828403121561570a5761570961381f565b5b600061571884828501615095565b91505092915050565b600060408201905061573660008301856156ca565b615743602083018461551b565b9392505050565b61575381613849565b811461575e57600080fd5b50565b6000815190506157708161574a565b92915050565b600060c0828403121561578c5761578b615090565b5b61579660a06143a7565b905060006157a684828501615095565b60008301525060206157ba848285016150bf565b60208301525060606157ce84828501615095565b60408301525060806157e284828501615095565b60608301525060a06157f684828501615761565b60808301525092915050565b600060c082840312156158185761581761381f565b5b600061582684828501615776565b91505092915050565b600060608201905061584460008301866156ca565b6158516020830185615495565b61585e604083018461551b565b949350505050565b600060408201905061587b6000830185615495565b61588860208301846156ca565b9392505050565b61589881613f8c565b81146158a357600080fd5b50565b6000815190506158b58161588f565b92915050565b6000602082840312156158d1576158d061381f565b5b60006158df848285016158a6565b91505092915050565b60006158f382613849565b9050919050565b615903816158e8565b811461590e57600080fd5b50565b600081519050615920816158fa565b92915050565b60006020828403121561593c5761593b61381f565b5b600061594a84828501615911565b91505092915050565b60008151905061596281613ecf565b92915050565b60006020828403121561597e5761597d61381f565b5b600061598c84828501615953565b91505092915050565b60006159a082613981565b91506159ab83613981565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156159e4576159e36155d6565b5b828202905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000615a2982613981565b9150615a3483613981565b925082615a4457615a436159ef565b5b828204905092915050565b6000615a5a82613e5e565b9150615a6583613e5e565b9250827f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482116000841360008413161615615aa457615aa36155d6565b5b817f80000000000000000000000000000000000000000000000000000000000000000583126000841260008413161615615ae157615ae06155d6565b5b827f80000000000000000000000000000000000000000000000000000000000000000582126000841360008412161615615b1e57615b1d6155d6565b5b827f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0582126000841260008412161615615b5b57615b5a6155d6565b5b828202905092915050565b6000615b7182613e5e565b9150615b7c83613e5e565b925082615b8c57615b8b6159ef565b5b600160000383147f800000000000000000000000000000000000000000000000000000000000000083141615615bc557615bc46155d6565b5b82820590509291505056fea2646970667358221220e650dd4b391677aa40c90d4f7f374c06bf08ad9fbde8ed1f78d106103771142064736f6c634300080f0033", - "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061020b5760003560e01c80638f5edc081161012a578063b7a98f97116100bd578063edd8ca7b1161008c578063f77c479111610071578063f77c4791146107a1578063f8083f56146107bf578063faaebd21146107f05761020b565b8063edd8ca7b14610741578063f5c06e1b146107715761020b565b8063b7a98f9714610693578063cc218ece146106c3578063d8dfeb45146106f3578063e9c6b4c1146107115761020b565b8063a5fdc5de116100f9578063a5fdc5de146105d3578063a86e357614610603578063b4d6f78114610633578063b7648fb9146106635761020b565b80638f5edc08146105135780639b9ac2cb146105435780639bc02857146105735780639be2a567146105a35761020b565b806337e710ac116101a25780637e64cc13116101715780637e64cc131461045257806382df39de146104835780638e076924146104b35780638e480b20146104e35761020b565b806337e710ac14610391578063540027e6146103c15780636878353e146103f15780636efef085146104225761020b565b80631e0c6fb9116101de5780631e0c6fb9146102d1578063204e94b014610301578063237e58991461033157806326512160146103615761020b565b80630198489214610210578063036790c0146102405780630aae7a6b146102715780630ba9d8ca146102a1575b600080fd5b61022a60048036038101906102259190613899565b610821565b604051610237919061395f565b60405180910390f35b61025a60048036038101906102559190613899565b61089e565b604051610268929190613a75565b60405180910390f35b61028b60048036038101906102869190613899565b610991565b6040516102989190613e3c565b60405180910390f35b6102bb60048036038101906102b69190613899565b610dae565b6040516102c89190613e99565b60405180910390f35b6102eb60048036038101906102e69190613899565b610ea1565b6040516102f89190613eb4565b60405180910390f35b61031b60048036038101906103169190613efb565b610f81565b604051610328919061408b565b60405180910390f35b61034b60048036038101906103469190613efb565b611125565b60405161035891906140b6565b60405180910390f35b61037b60048036038101906103769190613899565b611246565b6040516103889190614320565b60405180910390f35b6103ab60048036038101906103a69190613efb565b61142d565b6040516103b891906140b6565b60405180910390f35b6103db60048036038101906103d69190613899565b6115a2565b6040516103e89190613e99565b60405180910390f35b61040b60048036038101906104069190613efb565b6116b2565b604051610419929190613a75565b60405180910390f35b61043c600480360381019061043791906144b6565b61182f565b60405161044991906145c1565b60405180910390f35b61046c60048036038101906104679190613efb565b6119c2565b60405161047a929190614762565b60405180910390f35b61049d60048036038101906104989190613efb565b611d73565b6040516104aa91906147a8565b60405180910390f35b6104cd60048036038101906104c891906147ef565b611e6f565b6040516104da91906140b6565b60405180910390f35b6104fd60048036038101906104f89190613899565b611f96565b60405161050a9190614884565b60405180910390f35b61052d60048036038101906105289190614962565b612010565b60405161053a9190614b52565b60405180910390f35b61055d60048036038101906105589190613efb565b6120d1565b60405161056a91906140b6565b60405180910390f35b61058d60048036038101906105889190614bcf565b6121cb565b60405161059a9190614df9565b60405180910390f35b6105bd60048036038101906105b89190613efb565b61229c565b6040516105ca9190613eb4565b60405180910390f35b6105ed60048036038101906105e89190613899565b612395565b6040516105fa91906140b6565b60405180910390f35b61061d60048036038101906106189190613899565b612481565b60405161062a919061395f565b60405180910390f35b61064d60048036038101906106489190613899565b6124fe565b60405161065a91906140b6565b60405180910390f35b61067d60048036038101906106789190613899565b6125ea565b60405161068a9190614e1b565b60405180910390f35b6106ad60048036038101906106a89190613efb565b612664565b6040516106ba9190614e1b565b60405180910390f35b6106dd60048036038101906106d89190613efb565b612782565b6040516106ea91906140b6565b60405180910390f35b6106fb61287e565b6040516107089190614e57565b60405180910390f35b61072b60048036038101906107269190613efb565b612914565b6040516107389190614e1b565b60405180910390f35b61075b60048036038101906107569190613899565b612a0c565b6040516107689190614e1b565b60405180910390f35b61078b60048036038101906107869190613efb565b612aac565b60405161079891906147a8565b60405180910390f35b6107a9612b9f565b6040516107b69190614e93565b60405180910390f35b6107d960048036038101906107d49190614f04565b612bc3565b6040516107e7929190614762565b60405180910390f35b61080a60048036038101906108059190613899565b612f32565b604051610818929190614f78565b60405180910390f35b60608173ffffffffffffffffffffffffffffffffffffffff166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa15801561086e573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906108979190615047565b9050919050565b6108a6613573565b6108ae6135a0565b828073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156108f757600080fd5b505af115801561090b573d6000803e3d6000fd5b505050508373ffffffffffffffffffffffffffffffffffffffff166359ea287d6040518163ffffffff1660e01b815260040160a060405180830381865afa15801561095a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061097e9190615173565b610987856131d5565b9250925050915091565b6109996135ba565b6109a282610821565b81600001819052506109b382612481565b81602001819052508173ffffffffffffffffffffffffffffffffffffffff166305d5c1cb6040518163ffffffff1660e01b8152600401606060405180830381865afa158015610a06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a2a919061527a565b81604001819052508173ffffffffffffffffffffffffffffffffffffffff16637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a7d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aa191906152e5565b816060019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508173ffffffffffffffffffffffffffffffffffffffff16636c376cc56040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b23573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b479190615312565b8160800181815250508173ffffffffffffffffffffffffffffffffffffffff16635d16e1206040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b9b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bbf9190615312565b8160a00181815250508173ffffffffffffffffffffffffffffffffffffffff1663fc741c7c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c379190615312565b8160c00181815250508173ffffffffffffffffffffffffffffffffffffffff166343f0179b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c8b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610caf9190615312565b8160e00181815250508173ffffffffffffffffffffffffffffffffffffffff1663193775676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d03573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d279190615312565b816101000181815250508173ffffffffffffffffffffffffffffffffffffffff1663a12e1b336040518163ffffffff1660e01b8152600401608060405180830381865afa158015610d7c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da0919061540f565b816101200181905250919050565b6000818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610df957600080fd5b505af1158015610e0d573d6000803e3d6000fd5b505050506000610e1c846131d5565b90508373ffffffffffffffffffffffffffffffffffffffff166360ec91d6826040518263ffffffff1660e01b8152600401610e579190614e1b565b602060405180830381865afa158015610e74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e989190615468565b92505050919050565b610ea9613573565b818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610ef257600080fd5b505af1158015610f06573d6000803e3d6000fd5b505050508273ffffffffffffffffffffffffffffffffffffffff166359ea287d6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610f55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f799190615173565b915050919050565b610f8961362f565b82828073ffffffffffffffffffffffffffffffffffffffff1663f667f897836040518263ffffffff1660e01b8152600401610fc491906154a4565b600060405180830381600087803b158015610fde57600080fd5b505af1158015610ff2573d6000803e3d6000fd5b5050505083836000019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505084836020019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506110708585612782565b836040018181525050611083858561142d565b836060018181525050611096858561229c565b83608001819052506110a88585612914565b8360a001819052506110ba8585611d73565b8360c00190151590811515815250506110d38585612aac565b8360e00190151590811515815250506110ec8585612664565b8361010001819052506110ff85856120d1565b836101200181815250506111138585611125565b83610140018181525050505092915050565b600082828073ffffffffffffffffffffffffffffffffffffffff1663f667f897836040518263ffffffff1660e01b815260040161116291906154a4565b600060405180830381600087803b15801561117c57600080fd5b505af1158015611190573d6000803e3d6000fd5b5050505060006111a08686612664565b90506111ba600082602001516132cb90919063ffffffff16565b156111cc57806020015193505061123e565b60006111d78661089e565b9150506111f2600082600001516132e290919063ffffffff16565b156112025760009450505061123e565b600061121f826000015183602001516132f990919063ffffffff16565b905061123883600001518261332290919063ffffffff16565b95505050505b505092915050565b61124e6136cb565b818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561129757600080fd5b505af11580156112ab573d6000803e3d6000fd5b505050506112b883610991565b826000018190525082826020019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505061130183610dae565b826040018181525050611313836115a2565b82606001818152505061132583611f96565b82608001819052508273ffffffffffffffffffffffffffffffffffffffff16636c376cc56040518163ffffffff1660e01b8152600401602060405180830381865afa158015611378573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061139c9190615312565b8260a00181815250506113ae83612395565b8260c00181815250506113c0836124fe565b8260e00181815250506113d283610ea1565b8261010001819052506113e4836125ea565b8261012001819052506000806113f985612f32565b915091508184610140018181525050808461016001818152505061141c85612a0c565b846101800181905250505050919050565b600082828073ffffffffffffffffffffffffffffffffffffffff1663f667f897836040518263ffffffff1660e01b815260040161146a91906154a4565b600060405180830381600087803b15801561148457600080fd5b505af1158015611498573d6000803e3d6000fd5b505050506115988473ffffffffffffffffffffffffffffffffffffffff166391689024876040518263ffffffff1660e01b81526004016114d891906154a4565b602060405180830381865afa1580156114f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115199190615312565b8573ffffffffffffffffffffffffffffffffffffffff1663ab582f29886040518263ffffffff1660e01b815260040161155291906154a4565b602060405180830381865afa15801561156f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115939190615312565b61334b565b9250505092915050565b6000818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156115ed57600080fd5b505af1158015611601573d6000803e3d6000fd5b505050506000611610846131d5565b90506116a96116216201518061335f565b8573ffffffffffffffffffffffffffffffffffffffff166360ec91d6846040518263ffffffff1660e01b815260040161165a9190614e1b565b602060405180830381865afa158015611677573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061169b9190615468565b61337c90919063ffffffff16565b92505050919050565b6116ba613573565b6116c26135a0565b83838073ffffffffffffffffffffffffffffffffffffffff1663f667f897836040518263ffffffff1660e01b81526004016116fd91906154a4565b600060405180830381600087803b15801561171757600080fd5b505af115801561172b573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff16631e0c6fb9876040518263ffffffff1660e01b815260040161176891906154a4565b60a060405180830381865afa158015611785573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117a99190615173565b8573ffffffffffffffffffffffffffffffffffffffff1663b7648fb9886040518263ffffffff1660e01b81526004016117e291906154a4565b6040805180830381865afa1580156117fe573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061182291906154bf565b9350935050509250929050565b6060828073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561187a57600080fd5b505af115801561188e573d6000803e3d6000fd5b50505050825167ffffffffffffffff8111156118ad576118ac614347565b5b6040519080825280602002602001820160405280156118e657816020015b6118d3613767565b8152602001906001900390816118cb5790505b50915060005b83518110156119ba578473ffffffffffffffffffffffffffffffffffffffff16637ece075d858381518110611924576119236154ec565b5b60200260200101516040518263ffffffff1660e01b8152600401611948919061552a565b606060405180830381865afa158015611965573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061198991906155a9565b83828151811061199c5761199b6154ec565b5b602002602001018190525080806119b290615605565b9150506118ec565b505092915050565b60608083838073ffffffffffffffffffffffffffffffffffffffff1663f667f897836040518263ffffffff1660e01b8152600401611a0091906154a4565b600060405180830381600087803b158015611a1a57600080fd5b505af1158015611a2e573d6000803e3d6000fd5b5050505060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16636fc6407c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a9f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ac3919061568b565b905060008173ffffffffffffffffffffffffffffffffffffffff166305d85eda886040518263ffffffff1660e01b8152600401611b0091906156d9565b602060405180830381865afa158015611b1d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b4191906156f4565b90508067ffffffffffffffff811115611b5d57611b5c614347565b5b604051908082528060200260200182016040528015611b8b5781602001602082028036833780820191505090505b5095508067ffffffffffffffff811115611ba857611ba7614347565b5b604051908082528060200260200182016040528015611bd65781602001602082028036833780820191505090505b50945060005b81811015611d675760008373ffffffffffffffffffffffffffffffffffffffff16632c3e50e58a846040518363ffffffff1660e01b8152600401611c21929190615721565b60c060405180830381865afa158015611c3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c629190615802565b90508060800151888381518110611c7c57611c7b6154ec565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508373ffffffffffffffffffffffffffffffffffffffff166366f8162e8a8c856040518463ffffffff1660e01b8152600401611cf39392919061582f565b602060405180830381865afa158015611d10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d349190615312565b878381518110611d4757611d466154ec565b5b602002602001018181525050508080611d5f90615605565b915050611bdc565b50505050509250929050565b600082828073ffffffffffffffffffffffffffffffffffffffff1663f667f897836040518263ffffffff1660e01b8152600401611db091906154a4565b600060405180830381600087803b158015611dca57600080fd5b505af1158015611dde573d6000803e3d6000fd5b50505050611dea61287e565b73ffffffffffffffffffffffffffffffffffffffff166382df39de86866040518363ffffffff1660e01b8152600401611e24929190615866565b602060405180830381865afa158015611e41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e6591906158bb565b9250505092915050565b600083838073ffffffffffffffffffffffffffffffffffffffff1663f667f897836040518263ffffffff1660e01b8152600401611eac91906154a4565b600060405180830381600087803b158015611ec657600080fd5b505af1158015611eda573d6000803e3d6000fd5b505050506000611f07611ef8611eef886133a5565b6040015161349c565b8661332290919063ffffffff16565b9050611f8a8673ffffffffffffffffffffffffffffffffffffffff16636c376cc56040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f7b9190615312565b8261332290919063ffffffff16565b93505050509392505050565b611f9e613767565b818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611fe757600080fd5b505af1158015611ffb573d6000803e3d6000fd5b50505050612008836133a5565b915050919050565b6060815167ffffffffffffffff81111561202d5761202c614347565b5b60405190808252806020026020018201604052801561206657816020015b61205361362f565b81526020019060019003908161204b5790505b50905060005b82518110156120ca576120998484838151811061208c5761208b6154ec565b5b6020026020010151610f81565b8282815181106120ac576120ab6154ec565b5b602002602001018190525080806120c290615605565b91505061206c565b5092915050565b600082828073ffffffffffffffffffffffffffffffffffffffff1663f667f897836040518263ffffffff1660e01b815260040161210e91906154a4565b600060405180830381600087803b15801561212857600080fd5b505af115801561213c573d6000803e3d6000fd5b5050505061214861287e565b73ffffffffffffffffffffffffffffffffffffffff1663faaebd21866040518263ffffffff1660e01b815260040161218091906154a4565b602060405180830381865afa15801561219d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121c19190615312565b9250505092915050565b60608282905067ffffffffffffffff8111156121ea576121e9614347565b5b60405190808252806020026020018201604052801561222357816020015b6122106136cb565b8152602001906001900390816122085790505b50905060005b838390508110156122955761226484848381811061224a576122496154ec565b5b905060200201602081019061225f9190613899565b611246565b828281518110612277576122766154ec565b5b6020026020010181905250808061228d90615605565b915050612229565b5092915050565b6122a4613573565b82828073ffffffffffffffffffffffffffffffffffffffff1663f667f897836040518263ffffffff1660e01b81526004016122df91906154a4565b600060405180830381600087803b1580156122f957600080fd5b505af115801561230d573d6000803e3d6000fd5b505050508373ffffffffffffffffffffffffffffffffffffffff16631e0c6fb9866040518263ffffffff1660e01b815260040161234a91906154a4565b60a060405180830381865afa158015612367573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061238b9190615173565b9250505092915050565b6000818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156123e057600080fd5b505af11580156123f4573d6000803e3d6000fd5b5050505061240061287e565b73ffffffffffffffffffffffffffffffffffffffff1663a5fdc5de846040518263ffffffff1660e01b815260040161243891906156d9565b602060405180830381865afa158015612455573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124799190615312565b915050919050565b60608173ffffffffffffffffffffffffffffffffffffffff166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa1580156124ce573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906124f79190615047565b9050919050565b6000818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561254957600080fd5b505af115801561255d573d6000803e3d6000fd5b5050505061256961287e565b73ffffffffffffffffffffffffffffffffffffffff1663b4d6f781846040518263ffffffff1660e01b81526004016125a191906156d9565b602060405180830381865afa1580156125be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125e29190615312565b915050919050565b6125f26135a0565b818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561263b57600080fd5b505af115801561264f573d6000803e3d6000fd5b5050505061265c836131d5565b915050919050565b61266c6135a0565b82828073ffffffffffffffffffffffffffffffffffffffff1663f667f897836040518263ffffffff1660e01b81526004016126a791906154a4565b600060405180830381600087803b1580156126c157600080fd5b505af11580156126d5573d6000803e3d6000fd5b505050506127786126f16126e8866133a5565b6040015161349c565b8573ffffffffffffffffffffffffffffffffffffffff1663b7648fb9886040518263ffffffff1660e01b815260040161272a91906154a4565b6040805180830381865afa158015612746573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061276a91906154bf565b6134ae90919063ffffffff16565b9250505092915050565b600082828073ffffffffffffffffffffffffffffffffffffffff1663f667f897836040518263ffffffff1660e01b81526004016127bf91906154a4565b600060405180830381600087803b1580156127d957600080fd5b505af11580156127ed573d6000803e3d6000fd5b505050506127f961287e565b73ffffffffffffffffffffffffffffffffffffffff1663cc218ece86866040518363ffffffff1660e01b8152600401612833929190615866565b602060405180830381865afa158015612850573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128749190615312565b9250505092915050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa1580156128eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061290f9190615926565b905090565b61291c6135a0565b82828073ffffffffffffffffffffffffffffffffffffffff1663f667f897836040518263ffffffff1660e01b815260040161295791906154a4565b600060405180830381600087803b15801561297157600080fd5b505af1158015612985573d6000803e3d6000fd5b505050508373ffffffffffffffffffffffffffffffffffffffff1663b7648fb9866040518263ffffffff1660e01b81526004016129c291906154a4565b6040805180830381865afa1580156129de573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a0291906154bf565b9250505092915050565b612a146135a0565b818073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b158015612a5d57600080fd5b505af1158015612a71573d6000803e3d6000fd5b50505050612aa4612a8d612a84856133a5565b6040015161349c565b612a96856131d5565b6134ae90919063ffffffff16565b915050919050565b600082828073ffffffffffffffffffffffffffffffffffffffff1663f667f897836040518263ffffffff1660e01b8152600401612ae991906154a4565b600060405180830381600087803b158015612b0357600080fd5b505af1158015612b17573d6000803e3d6000fd5b505050508373ffffffffffffffffffffffffffffffffffffffff166358ca6f98866040518263ffffffff1660e01b8152600401612b5491906154a4565b602060405180830381865afa158015612b71573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b9591906158bb565b9250505092915050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60608085858073ffffffffffffffffffffffffffffffffffffffff1663f667f897836040518263ffffffff1660e01b8152600401612c0191906154a4565b600060405180830381600087803b158015612c1b57600080fd5b505af1158015612c2f573d6000803e3d6000fd5b5050505060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16636fc6407c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ca0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cc4919061568b565b90508686905067ffffffffffffffff811115612ce357612ce2614347565b5b604051908082528060200260200182016040528015612d115781602001602082028036833780820191505090505b5094508686905067ffffffffffffffff811115612d3157612d30614347565b5b604051908082528060200260200182016040528015612d5f5781602001602082028036833780820191505090505b50935060005b87879050811015612f255760008273ffffffffffffffffffffffffffffffffffffffff16632c3e50e58b8b8b86818110612da257612da16154ec565b5b905060200201356040518363ffffffff1660e01b8152600401612dc6929190615721565b60c060405180830381865afa158015612de3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e079190615802565b90508060800151878381518110612e2157612e206154ec565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508273ffffffffffffffffffffffffffffffffffffffff166366f8162e8b8d8c8c87818110612e8c57612e8b6154ec565b5b905060200201356040518463ffffffff1660e01b8152600401612eb19392919061582f565b602060405180830381865afa158015612ece573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ef29190615312565b868381518110612f0557612f046154ec565b5b602002602001018181525050508080612f1d90615605565b915050612d65565b5050505094509492505050565b600080828073ffffffffffffffffffffffffffffffffffffffff166311da60b46040518163ffffffff1660e01b8152600401600060405180830381600087803b158015612f7e57600080fd5b505af1158015612f92573d6000803e3d6000fd5b5050505060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015613003573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130279190615968565b905060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16632d809cb6876040518263ffffffff1660e01b815260040161308491906156d9565b602060405180830381865afa1580156130a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130c59190615968565b90506130cf61287e565b73ffffffffffffffffffffffffffffffffffffffff1663faaebd21836040518263ffffffff1660e01b815260040161310791906154a4565b602060405180830381865afa158015613124573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131489190615312565b945061315261287e565b73ffffffffffffffffffffffffffffffffffffffff1663faaebd21826040518263ffffffff1660e01b815260040161318a91906154a4565b602060405180830381865afa1580156131a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131cb9190615312565b9350505050915091565b6131dd6135a0565b8173ffffffffffffffffffffffffffffffffffffffff16639a427d038373ffffffffffffffffffffffffffffffffffffffff1663c07f47d46040518163ffffffff1660e01b8152600401602060405180830381865afa158015613244573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061326891906156f4565b6040518263ffffffff1660e01b8152600401613284919061552a565b6040805180830381865afa1580156132a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132c491906154bf565b9050919050565b600060026132d984846134ff565b14905092915050565b600060016132f084846134ff565b14905092915050565b600081670de0b6b3a7640000846133109190615995565b61331a9190615a1e565b905092915050565b6000670de0b6b3a764000082846133399190615995565b6133439190615a1e565b905092915050565b6000613357838361353d565b905092915050565b6000670de0b6b3a7640000826133759190615a4f565b9050919050565b6000670de0b6b3a764000082846133939190615a4f565b61339d9190615b66565b905092915050565b6133ad613767565b8173ffffffffffffffffffffffffffffffffffffffff16637ece075d8373ffffffffffffffffffffffffffffffffffffffff1663c07f47d46040518163ffffffff1660e01b8152600401602060405180830381865afa158015613414573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061343891906156f4565b6040518263ffffffff1660e01b8152600401613454919061552a565b606060405180830381865afa158015613471573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061349591906155a9565b9050919050565b60006134a782613557565b9050919050565b6134b66135a0565b60405180604001604052806134d884866000015161332290919063ffffffff16565b81526020016134f484866020015161332290919063ffffffff16565b815250905092915050565b60008060008484915091508082111561351d57600292505050613537565b8082101561353057600092505050613537565b6001925050505b92915050565b60008183101561354d578161354f565b825b905092915050565b60008082121561356a578160000361356c565b815b9050919050565b60405180606001604052806000815260200161358d6135a0565b815260200161359a6135a0565b81525090565b604051806040016040528060008152602001600081525090565b60405180610140016040528060608152602001606081526020016135dc613788565b8152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001600081526020016000815260200160008152602001600081526020016136296137d2565b81525090565b604051806101600160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600081526020016000815260200161368b613573565b81526020016136986135a0565b81526020016000151581526020016000151581526020016136b76135a0565b815260200160008152602001600081525090565b604051806101a001604052806136df6135ba565b8152602001600073ffffffffffffffffffffffffffffffffffffffff1681526020016000815260200160008152602001613717613767565b8152602001600081526020016000815260200160008152602001613739613573565b81526020016137466135a0565b815260200160008152602001600081526020016137616135a0565b81525090565b60405180606001604052806000815260200160008152602001600081525090565b6040518060600160405280600060018111156137a7576137a6613ae8565b5b8152602001600060018111156137c0576137bf613ae8565b5b8152602001600061ffff191681525090565b60405180608001604052806000600f0b81526020016000600f0b81526020016000600f0b815260200160006fffffffffffffffffffffffffffffffff1681525090565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061385482613829565b9050919050565b600061386682613849565b9050919050565b6138768161385b565b811461388157600080fd5b50565b6000813590506138938161386d565b92915050565b6000602082840312156138af576138ae61381f565b5b60006138bd84828501613884565b91505092915050565b600081519050919050565b600082825260208201905092915050565b60005b838110156139005780820151818401526020810190506138e5565b8381111561390f576000848401525b50505050565b6000601f19601f8301169050919050565b6000613931826138c6565b61393b81856138d1565b935061394b8185602086016138e2565b61395481613915565b840191505092915050565b600060208201905081810360008301526139798184613926565b905092915050565b6000819050919050565b61399481613981565b82525050565b6000819050919050565b60006139bf6139ba6139b584613981565b61399a565b613981565b9050919050565b6139cf816139a4565b82525050565b6040820160008201516139eb60008501826139c6565b5060208201516139fe60208501826139c6565b50505050565b60a082016000820151613a1a600085018261398b565b506020820151613a2d60208501826139d5565b506040820151613a4060608501826139d5565b50505050565b604082016000820151613a5c60008501826139c6565b506020820151613a6f60208501826139c6565b50505050565b600060e082019050613a8a6000830185613a04565b613a9760a0830184613a46565b9392505050565b600082825260208201905092915050565b6000613aba826138c6565b613ac48185613a9e565b9350613ad48185602086016138e2565b613add81613915565b840191505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60028110613b2857613b27613ae8565b5b50565b6000819050613b3982613b17565b919050565b6000613b4982613b2b565b9050919050565b613b5981613b3e565b82525050565b60028110613b7057613b6f613ae8565b5b50565b6000819050613b8182613b5f565b919050565b6000613b9182613b73565b9050919050565b613ba181613b86565b82525050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000082169050919050565b613bdc81613ba7565b82525050565b606082016000820151613bf86000850182613b50565b506020820151613c0b6020850182613b98565b506040820151613c1e6040850182613bd3565b50505050565b6000613c3f613c3a613c3584613829565b61399a565b613829565b9050919050565b6000613c5182613c24565b9050919050565b6000613c6382613c46565b9050919050565b613c7381613c58565b82525050565b600081600f0b9050919050565b6000613ca1613c9c613c9784613c79565b61399a565b613c79565b9050919050565b613cb181613c86565b82525050565b60006fffffffffffffffffffffffffffffffff82169050919050565b6000613cee613ce9613ce484613cb7565b61399a565b613cb7565b9050919050565b613cfe81613cd3565b82525050565b608082016000820151613d1a6000850182613ca8565b506020820151613d2d6020850182613ca8565b506040820151613d406040850182613ca8565b506060820151613d536060850182613cf5565b50505050565b60006101e0830160008301518482036000860152613d778282613aaf565b91505060208301518482036020860152613d918282613aaf565b9150506040830151613da66040860182613be2565b506060830151613db960a0860182613c6a565b506080830151613dcc60c08601826139c6565b5060a0830151613ddf60e08601826139c6565b5060c0830151613df36101008601826139c6565b5060e0830151613e076101208601826139c6565b50610100830151613e1c6101408601826139c6565b50610120830151613e31610160860182613d04565b508091505092915050565b60006020820190508181036000830152613e568184613d59565b905092915050565b6000819050919050565b6000613e83613e7e613e7984613e5e565b61399a565b613e5e565b9050919050565b613e9381613e68565b82525050565b6000602082019050613eae6000830184613e8a565b92915050565b600060a082019050613ec96000830184613a04565b92915050565b613ed881613849565b8114613ee357600080fd5b50565b600081359050613ef581613ecf565b92915050565b60008060408385031215613f1257613f1161381f565b5b6000613f2085828601613ee6565b9250506020613f3185828601613884565b9150509250929050565b613f4481613849565b82525050565b60a082016000820151613f60600085018261398b565b506020820151613f7360208501826139d5565b506040820151613f8660608501826139d5565b50505050565b60008115159050919050565b613fa181613f8c565b82525050565b61022082016000820151613fbe6000850182613f3b565b506020820151613fd16020850182613f3b565b506040820151613fe460408501826139c6565b506060820151613ff760608501826139c6565b50608082015161400a6080850182613f4a565b5060a082015161401e6101208501826139d5565b5060c0820151614032610160850182613f98565b5060e0820151614046610180850182613f98565b5061010082015161405b6101a08501826139d5565b506101208201516140706101e08501826139c6565b506101408201516140856102008501826139c6565b50505050565b6000610220820190506140a16000830184613fa7565b92915050565b6140b0816139a4565b82525050565b60006020820190506140cb60008301846140a7565b92915050565b60006101e08301600083015184820360008601526140ef8282613aaf565b915050602083015184820360208601526141098282613aaf565b915050604083015161411e6040860182613be2565b50606083015161413160a0860182613c6a565b50608083015161414460c08601826139c6565b5060a083015161415760e08601826139c6565b5060c083015161416b6101008601826139c6565b5060e083015161417f6101208601826139c6565b506101008301516141946101408601826139c6565b506101208301516141a9610160860182613d04565b508091505092915050565b6141bd81613e68565b82525050565b6060820160008201516141d9600085018261398b565b5060208201516141ec602085018261398b565b5060408201516141ff60408501826141b4565b50505050565b60006102a083016000830151848203600086015261422382826140d1565b91505060208301516142386020860182613f3b565b50604083015161424b60408601826141b4565b50606083015161425e60608601826141b4565b50608083015161427160808601826141c3565b5060a083015161428460e08601826139c6565b5060c08301516142986101008601826139c6565b5060e08301516142ac6101208601826139c6565b506101008301516142c1610140860182613f4a565b506101208301516142d66101e08601826139d5565b506101408301516142eb6102208601826139c6565b506101608301516143006102408601826139c6565b506101808301516143156102608601826139d5565b508091505092915050565b6000602082019050818103600083015261433a8184614205565b905092915050565b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61437f82613915565b810181811067ffffffffffffffff8211171561439e5761439d614347565b5b80604052505050565b60006143b1613815565b90506143bd8282614376565b919050565b600067ffffffffffffffff8211156143dd576143dc614347565b5b602082029050602081019050919050565b600080fd5b6143fc81613981565b811461440757600080fd5b50565b600081359050614419816143f3565b92915050565b600061443261442d846143c2565b6143a7565b90508083825260208201905060208402830185811115614455576144546143ee565b5b835b8181101561447e578061446a888261440a565b845260208401935050602081019050614457565b5050509392505050565b600082601f83011261449d5761449c614342565b5b81356144ad84826020860161441f565b91505092915050565b600080604083850312156144cd576144cc61381f565b5b60006144db85828601613884565b925050602083013567ffffffffffffffff8111156144fc576144fb613824565b5b61450885828601614488565b9150509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b600061454a83836141c3565b60608301905092915050565b6000602082019050919050565b600061456e82614512565b614578818561451d565b93506145838361452e565b8060005b838110156145b457815161459b888261453e565b97506145a683614556565b925050600181019050614587565b5085935050505092915050565b600060208201905081810360008301526145db8184614563565b905092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b600061461a82613c46565b9050919050565b61462a8161460f565b82525050565b600061463c8383614621565b60208301905092915050565b6000602082019050919050565b6000614660826145e3565b61466a81856145ee565b9350614675836145ff565b8060005b838110156146a657815161468d8882614630565b975061469883614648565b925050600181019050614679565b5085935050505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60006146eb83836139c6565b60208301905092915050565b6000602082019050919050565b600061470f826146b3565b61471981856146be565b9350614724836146cf565b8060005b8381101561475557815161473c88826146df565b9750614747836146f7565b925050600181019050614728565b5085935050505092915050565b6000604082019050818103600083015261477c8185614655565b905081810360208301526147908184614704565b90509392505050565b6147a281613f8c565b82525050565b60006020820190506147bd6000830184614799565b92915050565b6147cc81613981565b81146147d757600080fd5b50565b6000813590506147e9816147c3565b92915050565b6000806000606084860312156148085761480761381f565b5b600061481686828701613ee6565b935050602061482786828701613884565b9250506040614838868287016147da565b9150509250925092565b606082016000820151614858600085018261398b565b50602082015161486b602085018261398b565b50604082015161487e60408501826141b4565b50505050565b60006060820190506148996000830184614842565b92915050565b600067ffffffffffffffff8211156148ba576148b9614347565b5b602082029050602081019050919050565b60006148de6148d98461489f565b6143a7565b90508083825260208201905060208402830185811115614901576149006143ee565b5b835b8181101561492a57806149168882613884565b845260208401935050602081019050614903565b5050509392505050565b600082601f83011261494957614948614342565b5b81356149598482602086016148cb565b91505092915050565b600080604083850312156149795761497861381f565b5b600061498785828601613ee6565b925050602083013567ffffffffffffffff8111156149a8576149a7613824565b5b6149b485828601614934565b9150509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b61022082016000820151614a016000850182613f3b565b506020820151614a146020850182613f3b565b506040820151614a2760408501826139c6565b506060820151614a3a60608501826139c6565b506080820151614a4d6080850182613f4a565b5060a0820151614a616101208501826139d5565b5060c0820151614a75610160850182613f98565b5060e0820151614a89610180850182613f98565b50610100820151614a9e6101a08501826139d5565b50610120820151614ab36101e08501826139c6565b50610140820151614ac86102008501826139c6565b50505050565b6000614ada83836149ea565b6102208301905092915050565b6000602082019050919050565b6000614aff826149be565b614b0981856149c9565b9350614b14836149da565b8060005b83811015614b45578151614b2c8882614ace565b9750614b3783614ae7565b925050600181019050614b18565b5085935050505092915050565b60006020820190508181036000830152614b6c8184614af4565b905092915050565b600080fd5b60008083601f840112614b8f57614b8e614342565b5b8235905067ffffffffffffffff811115614bac57614bab614b74565b5b602083019150836020820283011115614bc857614bc76143ee565b5b9250929050565b60008060208385031215614be657614be561381f565b5b600083013567ffffffffffffffff811115614c0457614c03613824565b5b614c1085828601614b79565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60006102a0830160008301518482036000860152614c6682826140d1565b9150506020830151614c7b6020860182613f3b565b506040830151614c8e60408601826141b4565b506060830151614ca160608601826141b4565b506080830151614cb460808601826141c3565b5060a0830151614cc760e08601826139c6565b5060c0830151614cdb6101008601826139c6565b5060e0830151614cef6101208601826139c6565b50610100830151614d04610140860182613f4a565b50610120830151614d196101e08601826139d5565b50610140830151614d2e6102208601826139c6565b50610160830151614d436102408601826139c6565b50610180830151614d586102608601826139d5565b508091505092915050565b6000614d6f8383614c48565b905092915050565b6000602082019050919050565b6000614d8f82614c1c565b614d998185614c27565b935083602082028501614dab85614c38565b8060005b85811015614de75784840389528151614dc88582614d63565b9450614dd383614d77565b925060208a01995050600181019050614daf565b50829750879550505050505092915050565b60006020820190508181036000830152614e138184614d84565b905092915050565b6000604082019050614e306000830184613a46565b92915050565b6000614e4182613c46565b9050919050565b614e5181614e36565b82525050565b6000602082019050614e6c6000830184614e48565b92915050565b6000614e7d82613c46565b9050919050565b614e8d81614e72565b82525050565b6000602082019050614ea86000830184614e84565b92915050565b60008083601f840112614ec457614ec3614342565b5b8235905067ffffffffffffffff811115614ee157614ee0614b74565b5b602083019150836020820283011115614efd57614efc6143ee565b5b9250929050565b60008060008060608587031215614f1e57614f1d61381f565b5b6000614f2c87828801613ee6565b9450506020614f3d87828801613884565b935050604085013567ffffffffffffffff811115614f5e57614f5d613824565b5b614f6a87828801614eae565b925092505092959194509250565b6000604082019050614f8d60008301856140a7565b614f9a60208301846140a7565b9392505050565b600080fd5b600067ffffffffffffffff821115614fc157614fc0614347565b5b614fca82613915565b9050602081019050919050565b6000614fea614fe584614fa6565b6143a7565b90508281526020810184848401111561500657615005614fa1565b5b6150118482856138e2565b509392505050565b600082601f83011261502e5761502d614342565b5b815161503e848260208601614fd7565b91505092915050565b60006020828403121561505d5761505c61381f565b5b600082015167ffffffffffffffff81111561507b5761507a613824565b5b61508784828501615019565b91505092915050565b600080fd5b6000815190506150a4816143f3565b92915050565b6000815190506150b9816147c3565b92915050565b6000604082840312156150d5576150d4615090565b5b6150df60406143a7565b905060006150ef848285016150aa565b6000830152506020615103848285016150aa565b60208301525092915050565b600060a0828403121561512557615124615090565b5b61512f60606143a7565b9050600061513f84828501615095565b6000830152506020615153848285016150bf565b6020830152506060615167848285016150bf565b60408301525092915050565b600060a082840312156151895761518861381f565b5b60006151978482850161510f565b91505092915050565b600281106151ad57600080fd5b50565b6000815190506151bf816151a0565b92915050565b600281106151d257600080fd5b50565b6000815190506151e4816151c5565b92915050565b6151f381613ba7565b81146151fe57600080fd5b50565b600081519050615210816151ea565b92915050565b60006060828403121561522c5761522b615090565b5b61523660606143a7565b90506000615246848285016151b0565b600083015250602061525a848285016151d5565b602083015250604061526e84828501615201565b60408301525092915050565b6000606082840312156152905761528f61381f565b5b600061529e84828501615216565b91505092915050565b60006152b282613849565b9050919050565b6152c2816152a7565b81146152cd57600080fd5b50565b6000815190506152df816152b9565b92915050565b6000602082840312156152fb576152fa61381f565b5b6000615309848285016152d0565b91505092915050565b6000602082840312156153285761532761381f565b5b6000615336848285016150aa565b91505092915050565b61534881613c79565b811461535357600080fd5b50565b6000815190506153658161533f565b92915050565b61537481613cb7565b811461537f57600080fd5b50565b6000815190506153918161536b565b92915050565b6000608082840312156153ad576153ac615090565b5b6153b760806143a7565b905060006153c784828501615356565b60008301525060206153db84828501615356565b60208301525060406153ef84828501615356565b604083015250606061540384828501615382565b60608301525092915050565b6000608082840312156154255761542461381f565b5b600061543384828501615397565b91505092915050565b61544581613e5e565b811461545057600080fd5b50565b6000815190506154628161543c565b92915050565b60006020828403121561547e5761547d61381f565b5b600061548c84828501615453565b91505092915050565b61549e81613849565b82525050565b60006020820190506154b96000830184615495565b92915050565b6000604082840312156154d5576154d461381f565b5b60006154e3848285016150bf565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b61552481613981565b82525050565b600060208201905061553f600083018461551b565b92915050565b60006060828403121561555b5761555a615090565b5b61556560606143a7565b9050600061557584828501615095565b600083015250602061558984828501615095565b602083015250604061559d84828501615453565b60408301525092915050565b6000606082840312156155bf576155be61381f565b5b60006155cd84828501615545565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061561082613981565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203615642576156416155d6565b5b600182019050919050565b600061565882613849565b9050919050565b6156688161564d565b811461567357600080fd5b50565b6000815190506156858161565f565b92915050565b6000602082840312156156a1576156a061381f565b5b60006156af84828501615676565b91505092915050565b60006156c382613c46565b9050919050565b6156d3816156b8565b82525050565b60006020820190506156ee60008301846156ca565b92915050565b60006020828403121561570a5761570961381f565b5b600061571884828501615095565b91505092915050565b600060408201905061573660008301856156ca565b615743602083018461551b565b9392505050565b61575381613849565b811461575e57600080fd5b50565b6000815190506157708161574a565b92915050565b600060c0828403121561578c5761578b615090565b5b61579660a06143a7565b905060006157a684828501615095565b60008301525060206157ba848285016150bf565b60208301525060606157ce84828501615095565b60408301525060806157e284828501615095565b60608301525060a06157f684828501615761565b60808301525092915050565b600060c082840312156158185761581761381f565b5b600061582684828501615776565b91505092915050565b600060608201905061584460008301866156ca565b6158516020830185615495565b61585e604083018461551b565b949350505050565b600060408201905061587b6000830185615495565b61588860208301846156ca565b9392505050565b61589881613f8c565b81146158a357600080fd5b50565b6000815190506158b58161588f565b92915050565b6000602082840312156158d1576158d061381f565b5b60006158df848285016158a6565b91505092915050565b60006158f382613849565b9050919050565b615903816158e8565b811461590e57600080fd5b50565b600081519050615920816158fa565b92915050565b60006020828403121561593c5761593b61381f565b5b600061594a84828501615911565b91505092915050565b60008151905061596281613ecf565b92915050565b60006020828403121561597e5761597d61381f565b5b600061598c84828501615953565b91505092915050565b60006159a082613981565b91506159ab83613981565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156159e4576159e36155d6565b5b828202905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000615a2982613981565b9150615a3483613981565b925082615a4457615a436159ef565b5b828204905092915050565b6000615a5a82613e5e565b9150615a6583613e5e565b9250827f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482116000841360008413161615615aa457615aa36155d6565b5b817f80000000000000000000000000000000000000000000000000000000000000000583126000841260008413161615615ae157615ae06155d6565b5b827f80000000000000000000000000000000000000000000000000000000000000000582126000841360008412161615615b1e57615b1d6155d6565b5b827f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0582126000841260008412161615615b5b57615b5a6155d6565b5b828202905092915050565b6000615b7182613e5e565b9150615b7c83613e5e565b925082615b8c57615b8b6159ef565b5b600160000383147f800000000000000000000000000000000000000000000000000000000000000083141615615bc557615bc46155d6565b5b82820590509291505056fea2646970667358221220e650dd4b391677aa40c90d4f7f374c06bf08ad9fbde8ed1f78d106103771142064736f6c634300080f0033", - "devdoc": { - "kind": "dev", - "methods": { - "atVersions(address,uint256[])": { - "params": { - "product": "Product address", - "versions": "Oracle versions to query" - }, - "returns": { - "prices": "Product prices at specified versions" - } - }, - "collateral()": { - "returns": { - "_0": "Protocol collateral address" - } - }, - "collateral(address)": { - "params": { - "product": "Product address" - }, - "returns": { - "_0": "Total collateral for product" - } - }, - "collateral(address,address)": { - "params": { - "account": "Account address", - "product": "Product address" - }, - "returns": { - "_0": "User deposited collateral for product" - } - }, - "constructor": { - "params": { - "_controller": "Protocol controller address" - } - }, - "dailyRate(address)": { - "params": { - "product": "Product address" - }, - "returns": { - "_0": "Product current funding extrapolated to a daily rate" - } - }, - "exposure(address,address)": { - "params": { - "account": "Account address", - "product": "Product address" - }, - "returns": { - "_0": "User's exposure (openInterest * utilization) after settle" - } - }, - "fees(address)": { - "params": { - "product": "Product address" - }, - "returns": { - "productFees": "fees accrued by the product owner", - "protocolFees": "fees accrued by the protocol" - } - }, - "fees(address,address)": { - "params": { - "account": "Account address", - "product": "Product address" - }, - "returns": { - "_0": "sum of all fees accrued by the account" - } - }, - "globalPosition(address)": { - "params": { - "product": "Product address" - }, - "returns": { - "_0": "Product pre-position", - "_1": "Product position" - } - }, - "info(address)": { - "params": { - "product": "Product address" - }, - "returns": { - "_info": "of the product" - } - }, - "latestVersion(address)": { - "params": { - "product": "Product address" - }, - "returns": { - "_0": "Product latest price" - } - }, - "liquidatable(address,address)": { - "params": { - "account": "Account address", - "product": "Product address" - }, - "returns": { - "_0": "Whether or not the user's position eligible to be liquidated" - } - }, - "maintenance(address,address)": { - "params": { - "account": "Account address", - "product": "Product address" - }, - "returns": { - "_0": "Maximum of user maintenance, and maintenanceNext" - } - }, - "maintenanceRequired(address,address,uint256)": { - "params": { - "account": "Account address", - "positionSize": "size of position for maintenance calculation", - "product": "Product address" - }, - "returns": { - "_0": "Maintenance required for position in product" - } - }, - "name(address)": { - "params": { - "product": "Product address" - }, - "returns": { - "_0": "Name of the product" - } - }, - "openInterest(address)": { - "params": { - "product": "Product address" - }, - "returns": { - "_0": "Product maker and taker position multiplied by latest price after settle" - } - }, - "openInterest(address,address)": { - "params": { - "account": "Account address", - "product": "Product address" - }, - "returns": { - "_0": "User's maker or taker position multiplied by latest price after settle" - } - }, - "position(address)": { - "params": { - "product": "Product address" - }, - "returns": { - "_0": "product position" - } - }, - "position(address,address)": { - "params": { - "account": "Account address", - "product": "Product address" - }, - "returns": { - "_0": "User position" - } - }, - "pre(address)": { - "params": { - "product": "Product address" - }, - "returns": { - "_0": "Product pre-position" - } - }, - "pre(address,address)": { - "params": { - "account": "Account address", - "product": "Product address" - }, - "returns": { - "_0": "User pre-position" - } - }, - "rate(address)": { - "params": { - "product": "Product address" - }, - "returns": { - "_0": "Product current funding rate" - } - }, - "shortfall(address)": { - "params": { - "product": "Product address" - }, - "returns": { - "_0": "Total shortfall for product" - } - }, - "snapshot(address)": { - "params": { - "product": "Product address" - }, - "returns": { - "_0": "Snapshot for the product after settle" - } - }, - "snapshot(address,address)": { - "params": { - "account": "User addresses", - "product": "Product address" - }, - "returns": { - "_0": "UserSnapshot for the product after settle" - } - }, - "snapshots(address,address[])": { - "params": { - "account": "User addresses", - "productAddresses": "Product addresses" - }, - "returns": { - "_0": "UserSnapshot for each product after settle" - } - }, - "snapshots(address[])": { - "params": { - "productAddresses": "Product addresses" - }, - "returns": { - "_0": "Snapshot for each product after settle" - } - }, - "symbol(address)": { - "params": { - "product": "Product address" - }, - "returns": { - "_0": "Symbol of the product" - } - }, - "unclaimedIncentiveRewards(address,address)": { - "params": { - "account": "Account address", - "product": "Product address" - }, - "returns": { - "amounts": "Token amounts of unclaimed incentive rewards for given product", - "tokens": "Token addresses of unclaimed incentive rewards for given product" - } - }, - "unclaimedIncentiveRewards(address,address,uint256[])": { - "params": { - "account": "Account address", - "product": "Product address", - "programIds": "Program IDs to query" - }, - "returns": { - "amounts": "Token amounts of unclaimed incentive rewards for given program IDs", - "tokens": "Token addresses of unclaimed incentive rewards for given program IDs" - } - }, - "userPosition(address,address)": { - "params": { - "account": "Account address", - "product": "Product address" - }, - "returns": { - "_0": "User pre-position", - "_1": "User position" - } - } - }, - "stateVariables": { - "controller": { - "return": "Protocol controller", - "returns": { - "_0": "Protocol controller" - } - } - }, - "title": "Lens contract to conveniently pull protocol data", - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": { - "atVersions(address,uint256[])": { - "notice": "Prices of product at specified versions after settle" - }, - "collateral()": { - "notice": "Protocol collateral address" - }, - "collateral(address)": { - "notice": "Product total collateral amount after settle" - }, - "collateral(address,address)": { - "notice": "User collateral amount for product after settle" - }, - "controller()": { - "notice": "Protocol controller" - }, - "dailyRate(address)": { - "notice": "Product funding extrapolated to a daily rate after settle" - }, - "exposure(address,address)": { - "notice": "User's exposure in product after settle" - }, - "fees(address)": { - "notice": "Fees accumulated by product and protocol treasuries after settle" - }, - "fees(address,address)": { - "notice": "Fees accumulated by account after settle" - }, - "globalPosition(address)": { - "notice": "Product pre-position and position after settle" - }, - "info(address)": { - "notice": "Returns the info of the provided `product`" - }, - "latestVersion(address)": { - "notice": "Current price of product after settle" - }, - "liquidatable(address,address)": { - "notice": "User liquidatble status for product after settle" - }, - "maintenance(address,address)": { - "notice": "User maintenance amount for product after settle" - }, - "maintenanceRequired(address,address,uint256)": { - "notice": "User's maintenance required for position size in product after settle" - }, - "name(address)": { - "notice": "Returns the name of the provided `product`" - }, - "openInterest(address)": { - "notice": "Product total open interest after settle" - }, - "openInterest(address,address)": { - "notice": "User's open interest in product after settle" - }, - "position(address)": { - "notice": "Product position after settle" - }, - "position(address,address)": { - "notice": "User position for product after settle" - }, - "pre(address)": { - "notice": "Product pre position after settle" - }, - "pre(address,address)": { - "notice": "User pre position for product after settle" - }, - "rate(address)": { - "notice": "Product funding rate after settle" - }, - "shortfall(address)": { - "notice": "Product total shortfall amount after settle" - }, - "snapshot(address)": { - "notice": "Returns the snapshot of the provided `product`" - }, - "snapshot(address,address)": { - "notice": "Returns the user snapshot for the provided `product`" - }, - "snapshots(address,address[])": { - "notice": "Returns the user snapshots for the provided `productAddresses`" - }, - "snapshots(address[])": { - "notice": "Returns the snapshots of the provided `productAddresses`" - }, - "symbol(address)": { - "notice": "Returns the symbol of the provided `product`" - }, - "unclaimedIncentiveRewards(address,address)": { - "notice": "User's unclaimed rewards for all programs for product after settle" - }, - "unclaimedIncentiveRewards(address,address,uint256[])": { - "notice": "User's unclaimed rewards for provided programs for product after settle" - }, - "userPosition(address,address)": { - "notice": "User pre-position and position for product after settle" - } - }, - "notice": "All functions should be called using `callStatic`", - "version": 1 - }, - "storageLayout": { - "storage": [], - "types": null - } -} diff --git a/packages/perennial/deployments/kovan/Product_Impl.json b/packages/perennial/deployments/kovan/Product_Impl.json deleted file mode 100644 index 76d6c3ada..000000000 --- a/packages/perennial/deployments/kovan/Product_Impl.json +++ /dev/null @@ -1,1464 +0,0 @@ -{ - "address": "0x2C19eac953048801FfE1358D109A1Ac2aF7930fD", - "abi": [ - { - "inputs": [], - "name": "CurveMathOutOfBoundsError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Fixed18OverflowError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "int256", - "name": "value", - "type": "int256" - } - ], - "name": "Fixed18PackingOverflowError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "int256", - "name": "value", - "type": "int256" - } - ], - "name": "Fixed18PackingUnderflowError", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidControllerError", - "type": "error" - }, - { - "inputs": [], - "name": "NotCollateralError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "coordinatorId", - "type": "uint256" - } - ], - "name": "NotOwnerError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "contract IProduct", - "name": "product", - "type": "address" - } - ], - "name": "NotProductError", - "type": "error" - }, - { - "inputs": [], - "name": "ParamProviderInvalidFundingFee", - "type": "error" - }, - { - "inputs": [], - "name": "ParamProviderInvalidMakerFee", - "type": "error" - }, - { - "inputs": [], - "name": "ParamProviderInvalidTakerFee", - "type": "error" - }, - { - "inputs": [], - "name": "PausedError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "enum PayoffDefinitionLib.PayoffType", - "name": "payoffType", - "type": "uint8" - }, - { - "internalType": "bytes30", - "name": "data", - "type": "bytes30" - } - ], - "name": "PayoffDefinitionNotContract", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "enum PayoffDefinitionLib.PayoffType", - "name": "payoffType", - "type": "uint8" - }, - { - "internalType": "enum PayoffDefinitionLib.PayoffDirection", - "name": "payoffDirection", - "type": "uint8" - } - ], - "name": "PayoffDefinitionUnsupportedTransform", - "type": "error" - }, - { - "inputs": [], - "name": "PayoffProviderInvalidOracle", - "type": "error" - }, - { - "inputs": [], - "name": "PayoffProviderInvalidPayoffDefinitionError", - "type": "error" - }, - { - "inputs": [], - "name": "ProductClosedError", - "type": "error" - }, - { - "inputs": [], - "name": "ProductDoubleSidedError", - "type": "error" - }, - { - "inputs": [], - "name": "ProductInLiquidationError", - "type": "error" - }, - { - "inputs": [], - "name": "ProductInsufficientCollateralError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "socializationFactor", - "type": "uint256" - } - ], - "name": "ProductInsufficientLiquidityError", - "type": "error" - }, - { - "inputs": [], - "name": "ProductInvalidOracle", - "type": "error" - }, - { - "inputs": [], - "name": "ProductMakerOverLimitError", - "type": "error" - }, - { - "inputs": [], - "name": "ProductNotOwnerError", - "type": "error" - }, - { - "inputs": [], - "name": "ProductOracleBootstrappingError", - "type": "error" - }, - { - "inputs": [], - "name": "ProductOverClosedError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "UFixed18PackingOverflowError", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "version", - "type": "uint256" - } - ], - "name": "UInitializableAlreadyInitializedError", - "type": "error" - }, - { - "inputs": [], - "name": "UInitializableNotInitializingError", - "type": "error" - }, - { - "inputs": [], - "name": "UInitializableZeroVersionError", - "type": "error" - }, - { - "inputs": [], - "name": "UReentrancyGuardReentrantCallError", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "preVersion", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "toVersion", - "type": "uint256" - } - ], - "name": "AccountSettle", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bool", - "name": "newClosed", - "type": "bool" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "version", - "type": "uint256" - } - ], - "name": "ClosedUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "UFixed18", - "name": "newFundingFee", - "type": "uint256" - } - ], - "name": "FundingFeeUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "version", - "type": "uint256" - } - ], - "name": "Initialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "Fixed18", - "name": "minRate", - "type": "int256" - }, - { - "indexed": false, - "internalType": "Fixed18", - "name": "maxRate", - "type": "int256" - }, - { - "indexed": false, - "internalType": "Fixed18", - "name": "targetRate", - "type": "int256" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "targetUtilization", - "type": "uint256" - } - ], - "name": "JumpRateUtilizationCurveUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "UFixed18", - "name": "newMaintenance", - "type": "uint256" - } - ], - "name": "MaintenanceUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "version", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "MakeClosed", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "version", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "MakeOpened", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "UFixed18", - "name": "newMakerFee", - "type": "uint256" - } - ], - "name": "MakerFeeUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "UFixed18", - "name": "newMakerLimit", - "type": "uint256" - } - ], - "name": "MakerLimitUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "preVersion", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "toVersion", - "type": "uint256" - } - ], - "name": "Settle", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "version", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "TakeClosed", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "version", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "TakeOpened", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "UFixed18", - "name": "newTakerFee", - "type": "uint256" - } - ], - "name": "TakerFeeUpdated", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "oracleVersion", - "type": "uint256" - } - ], - "name": "atVersion", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "version", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - }, - { - "internalType": "Fixed18", - "name": "price", - "type": "int256" - } - ], - "internalType": "struct IOracleProvider.OracleVersion", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "closeAll", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "closeMake", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "closeTake", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "closed", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "controller", - "outputs": [ - { - "internalType": "contract IController", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "currentVersion", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "version", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - }, - { - "internalType": "Fixed18", - "name": "price", - "type": "int256" - } - ], - "internalType": "struct IOracleProvider.OracleVersion", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "fundingFee", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "string", - "name": "name", - "type": "string" - }, - { - "internalType": "string", - "name": "symbol", - "type": "string" - }, - { - "components": [ - { - "internalType": "enum PayoffDefinitionLib.PayoffType", - "name": "payoffType", - "type": "uint8" - }, - { - "internalType": "enum PayoffDefinitionLib.PayoffDirection", - "name": "payoffDirection", - "type": "uint8" - }, - { - "internalType": "bytes30", - "name": "data", - "type": "bytes30" - } - ], - "internalType": "struct PayoffDefinition", - "name": "payoffDefinition", - "type": "tuple" - }, - { - "internalType": "contract IOracleProvider", - "name": "oracle", - "type": "address" - }, - { - "internalType": "UFixed18", - "name": "maintenance", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "fundingFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "makerFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "takerFee", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "makerLimit", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "PackedFixed18", - "name": "minRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "maxRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "targetRate", - "type": "int128" - }, - { - "internalType": "PackedUFixed18", - "name": "targetUtilization", - "type": "uint128" - } - ], - "internalType": "struct JumpRateUtilizationCurve", - "name": "utilizationCurve", - "type": "tuple" - } - ], - "internalType": "struct IProduct.ProductInfo", - "name": "productInfo_", - "type": "tuple" - } - ], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "isClosed", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "isLiquidating", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "latestVersion", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "latestVersion", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "maintenance", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "maintenance", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "maintenanceNext", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "makerFee", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "makerLimit", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "openMake", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "amount", - "type": "uint256" - } - ], - "name": "openTake", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "oracle", - "outputs": [ - { - "internalType": "contract IOracleProvider", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "payoffDefinition", - "outputs": [ - { - "components": [ - { - "internalType": "enum PayoffDefinitionLib.PayoffType", - "name": "payoffType", - "type": "uint8" - }, - { - "internalType": "enum PayoffDefinitionLib.PayoffDirection", - "name": "payoffDirection", - "type": "uint8" - }, - { - "internalType": "bytes30", - "name": "data", - "type": "bytes30" - } - ], - "internalType": "struct PayoffDefinition", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "position", - "outputs": [ - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "oracleVersion", - "type": "uint256" - } - ], - "name": "positionAtVersion", - "outputs": [ - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "pre", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "oracleVersion", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "openPosition", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "closePosition", - "type": "tuple" - } - ], - "internalType": "struct PrePosition", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "pre", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "oracleVersion", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "openPosition", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "closePosition", - "type": "tuple" - } - ], - "internalType": "struct PrePosition", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "UFixed18", - "name": "maker", - "type": "uint256" - }, - { - "internalType": "UFixed18", - "name": "taker", - "type": "uint256" - } - ], - "internalType": "struct Position", - "name": "position_", - "type": "tuple" - } - ], - "name": "rate", - "outputs": [ - { - "internalType": "Fixed18", - "name": "", - "type": "int256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "settle", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "settleAccount", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "oracleVersion", - "type": "uint256" - } - ], - "name": "shareAtVersion", - "outputs": [ - { - "components": [ - { - "internalType": "Fixed18", - "name": "maker", - "type": "int256" - }, - { - "internalType": "Fixed18", - "name": "taker", - "type": "int256" - } - ], - "internalType": "struct Accumulator", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "takerFee", - "outputs": [ - { - "internalType": "UFixed18", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bool", - "name": "newClosed", - "type": "bool" - } - ], - "name": "updateClosed", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "newFundingFee", - "type": "uint256" - } - ], - "name": "updateFundingFee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "newMaintenance", - "type": "uint256" - } - ], - "name": "updateMaintenance", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "newMakerFee", - "type": "uint256" - } - ], - "name": "updateMakerFee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "newMakerLimit", - "type": "uint256" - } - ], - "name": "updateMakerLimit", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "UFixed18", - "name": "newTakerFee", - "type": "uint256" - } - ], - "name": "updateTakerFee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "PackedFixed18", - "name": "minRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "maxRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "targetRate", - "type": "int128" - }, - { - "internalType": "PackedUFixed18", - "name": "targetUtilization", - "type": "uint128" - } - ], - "internalType": "struct JumpRateUtilizationCurve", - "name": "newUtilizationCurve", - "type": "tuple" - } - ], - "name": "updateUtilizationCurve", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "utilizationCurve", - "outputs": [ - { - "components": [ - { - "internalType": "PackedFixed18", - "name": "minRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "maxRate", - "type": "int128" - }, - { - "internalType": "PackedFixed18", - "name": "targetRate", - "type": "int128" - }, - { - "internalType": "PackedUFixed18", - "name": "targetUtilization", - "type": "uint128" - } - ], - "internalType": "struct JumpRateUtilizationCurve", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "oracleVersion", - "type": "uint256" - } - ], - "name": "valueAtVersion", - "outputs": [ - { - "components": [ - { - "internalType": "Fixed18", - "name": "maker", - "type": "int256" - }, - { - "internalType": "Fixed18", - "name": "taker", - "type": "int256" - } - ], - "internalType": "struct Accumulator", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - } - ], - "transactionHash": "0x12f4dadb4cd8bf710b67a6f7332b328848e23eee8b57f9e3558265f3e0630826", - "receipt": { - "to": null, - "from": "0x66a7fDB96C583c59597de16d8b2B989231415339", - "contractAddress": "0x2C19eac953048801FfE1358D109A1Ac2aF7930fD", - "transactionIndex": 0, - "gasUsed": "5279435", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xee285a771588a6cb886e54867234435075212fe98a791d2cb99e00194b8948d1", - "transactionHash": "0x12f4dadb4cd8bf710b67a6f7332b328848e23eee8b57f9e3558265f3e0630826", - "logs": [], - "blockNumber": 33203730, - "cumulativeGasUsed": "5279435", - "status": 1, - "byzantium": true - }, - "args": [], - "numDeployments": 1, - "solcInputHash": "40214df36850e11c061b57b4ce3f83e9", - "metadata": "{\"compiler\":{\"version\":\"0.8.15+commit.e14f2714\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"CurveMathOutOfBoundsError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Fixed18OverflowError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"int256\",\"name\":\"value\",\"type\":\"int256\"}],\"name\":\"Fixed18PackingOverflowError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"int256\",\"name\":\"value\",\"type\":\"int256\"}],\"name\":\"Fixed18PackingUnderflowError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidControllerError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotCollateralError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"coordinatorId\",\"type\":\"uint256\"}],\"name\":\"NotOwnerError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"contract IProduct\",\"name\":\"product\",\"type\":\"address\"}],\"name\":\"NotProductError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ParamProviderInvalidFundingFee\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ParamProviderInvalidMakerFee\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ParamProviderInvalidTakerFee\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"PausedError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"enum PayoffDefinitionLib.PayoffType\",\"name\":\"payoffType\",\"type\":\"uint8\"},{\"internalType\":\"bytes30\",\"name\":\"data\",\"type\":\"bytes30\"}],\"name\":\"PayoffDefinitionNotContract\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"enum PayoffDefinitionLib.PayoffType\",\"name\":\"payoffType\",\"type\":\"uint8\"},{\"internalType\":\"enum PayoffDefinitionLib.PayoffDirection\",\"name\":\"payoffDirection\",\"type\":\"uint8\"}],\"name\":\"PayoffDefinitionUnsupportedTransform\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"PayoffProviderInvalidOracle\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"PayoffProviderInvalidPayoffDefinitionError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ProductClosedError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ProductDoubleSidedError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ProductInLiquidationError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ProductInsufficientCollateralError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"socializationFactor\",\"type\":\"uint256\"}],\"name\":\"ProductInsufficientLiquidityError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ProductInvalidOracle\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ProductMakerOverLimitError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ProductNotOwnerError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ProductOracleBootstrappingError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ProductOverClosedError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"UFixed18PackingOverflowError\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"UInitializableAlreadyInitializedError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UInitializableNotInitializingError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UInitializableZeroVersionError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UReentrancyGuardReentrantCallError\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"preVersion\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"toVersion\",\"type\":\"uint256\"}],\"name\":\"AccountSettle\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bool\",\"name\":\"newClosed\",\"type\":\"bool\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"ClosedUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"newFundingFee\",\"type\":\"uint256\"}],\"name\":\"FundingFeeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"Fixed18\",\"name\":\"minRate\",\"type\":\"int256\"},{\"indexed\":false,\"internalType\":\"Fixed18\",\"name\":\"maxRate\",\"type\":\"int256\"},{\"indexed\":false,\"internalType\":\"Fixed18\",\"name\":\"targetRate\",\"type\":\"int256\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"targetUtilization\",\"type\":\"uint256\"}],\"name\":\"JumpRateUtilizationCurveUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"newMaintenance\",\"type\":\"uint256\"}],\"name\":\"MaintenanceUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MakeClosed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MakeOpened\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"newMakerFee\",\"type\":\"uint256\"}],\"name\":\"MakerFeeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"newMakerLimit\",\"type\":\"uint256\"}],\"name\":\"MakerLimitUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"preVersion\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"toVersion\",\"type\":\"uint256\"}],\"name\":\"Settle\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TakeClosed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TakeOpened\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"UFixed18\",\"name\":\"newTakerFee\",\"type\":\"uint256\"}],\"name\":\"TakerFeeUpdated\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"oracleVersion\",\"type\":\"uint256\"}],\"name\":\"atVersion\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"},{\"internalType\":\"Fixed18\",\"name\":\"price\",\"type\":\"int256\"}],\"internalType\":\"struct IOracleProvider.OracleVersion\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"closeAll\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"closeMake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"closeTake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"closed\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"controller\",\"outputs\":[{\"internalType\":\"contract IController\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"currentVersion\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"},{\"internalType\":\"Fixed18\",\"name\":\"price\",\"type\":\"int256\"}],\"internalType\":\"struct IOracleProvider.OracleVersion\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"fundingFee\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"},{\"components\":[{\"internalType\":\"enum PayoffDefinitionLib.PayoffType\",\"name\":\"payoffType\",\"type\":\"uint8\"},{\"internalType\":\"enum PayoffDefinitionLib.PayoffDirection\",\"name\":\"payoffDirection\",\"type\":\"uint8\"},{\"internalType\":\"bytes30\",\"name\":\"data\",\"type\":\"bytes30\"}],\"internalType\":\"struct PayoffDefinition\",\"name\":\"payoffDefinition\",\"type\":\"tuple\"},{\"internalType\":\"contract IOracleProvider\",\"name\":\"oracle\",\"type\":\"address\"},{\"internalType\":\"UFixed18\",\"name\":\"maintenance\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"fundingFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"makerFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"takerFee\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"makerLimit\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"PackedFixed18\",\"name\":\"minRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"maxRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"targetRate\",\"type\":\"int128\"},{\"internalType\":\"PackedUFixed18\",\"name\":\"targetUtilization\",\"type\":\"uint128\"}],\"internalType\":\"struct JumpRateUtilizationCurve\",\"name\":\"utilizationCurve\",\"type\":\"tuple\"}],\"internalType\":\"struct IProduct.ProductInfo\",\"name\":\"productInfo_\",\"type\":\"tuple\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"isClosed\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"isLiquidating\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"latestVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestVersion\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"maintenance\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"maintenance\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"maintenanceNext\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"makerFee\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"makerLimit\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"openMake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"openTake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"oracle\",\"outputs\":[{\"internalType\":\"contract IOracleProvider\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"payoffDefinition\",\"outputs\":[{\"components\":[{\"internalType\":\"enum PayoffDefinitionLib.PayoffType\",\"name\":\"payoffType\",\"type\":\"uint8\"},{\"internalType\":\"enum PayoffDefinitionLib.PayoffDirection\",\"name\":\"payoffDirection\",\"type\":\"uint8\"},{\"internalType\":\"bytes30\",\"name\":\"data\",\"type\":\"bytes30\"}],\"internalType\":\"struct PayoffDefinition\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"position\",\"outputs\":[{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"oracleVersion\",\"type\":\"uint256\"}],\"name\":\"positionAtVersion\",\"outputs\":[{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"pre\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"oracleVersion\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"openPosition\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"closePosition\",\"type\":\"tuple\"}],\"internalType\":\"struct PrePosition\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pre\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"oracleVersion\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"openPosition\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"closePosition\",\"type\":\"tuple\"}],\"internalType\":\"struct PrePosition\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"UFixed18\",\"name\":\"maker\",\"type\":\"uint256\"},{\"internalType\":\"UFixed18\",\"name\":\"taker\",\"type\":\"uint256\"}],\"internalType\":\"struct Position\",\"name\":\"position_\",\"type\":\"tuple\"}],\"name\":\"rate\",\"outputs\":[{\"internalType\":\"Fixed18\",\"name\":\"\",\"type\":\"int256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"settle\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"settleAccount\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"oracleVersion\",\"type\":\"uint256\"}],\"name\":\"shareAtVersion\",\"outputs\":[{\"components\":[{\"internalType\":\"Fixed18\",\"name\":\"maker\",\"type\":\"int256\"},{\"internalType\":\"Fixed18\",\"name\":\"taker\",\"type\":\"int256\"}],\"internalType\":\"struct Accumulator\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"takerFee\",\"outputs\":[{\"internalType\":\"UFixed18\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"newClosed\",\"type\":\"bool\"}],\"name\":\"updateClosed\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"newFundingFee\",\"type\":\"uint256\"}],\"name\":\"updateFundingFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"newMaintenance\",\"type\":\"uint256\"}],\"name\":\"updateMaintenance\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"newMakerFee\",\"type\":\"uint256\"}],\"name\":\"updateMakerFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"newMakerLimit\",\"type\":\"uint256\"}],\"name\":\"updateMakerLimit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"UFixed18\",\"name\":\"newTakerFee\",\"type\":\"uint256\"}],\"name\":\"updateTakerFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"PackedFixed18\",\"name\":\"minRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"maxRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"targetRate\",\"type\":\"int128\"},{\"internalType\":\"PackedUFixed18\",\"name\":\"targetUtilization\",\"type\":\"uint128\"}],\"internalType\":\"struct JumpRateUtilizationCurve\",\"name\":\"newUtilizationCurve\",\"type\":\"tuple\"}],\"name\":\"updateUtilizationCurve\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"utilizationCurve\",\"outputs\":[{\"components\":[{\"internalType\":\"PackedFixed18\",\"name\":\"minRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"maxRate\",\"type\":\"int128\"},{\"internalType\":\"PackedFixed18\",\"name\":\"targetRate\",\"type\":\"int128\"},{\"internalType\":\"PackedUFixed18\",\"name\":\"targetUtilization\",\"type\":\"uint128\"}],\"internalType\":\"struct JumpRateUtilizationCurve\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"oracleVersion\",\"type\":\"uint256\"}],\"name\":\"valueAtVersion\",\"outputs\":[{\"components\":[{\"internalType\":\"Fixed18\",\"name\":\"maker\",\"type\":\"int256\"},{\"internalType\":\"Fixed18\",\"name\":\"taker\",\"type\":\"int256\"}],\"internalType\":\"struct Accumulator\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Cloned by the Controller contract to launch new product markets.\",\"kind\":\"dev\",\"methods\":{\"atVersion(uint256)\":{\"params\":{\"oracleVersion\":\"Oracle version to return for\"},\"returns\":{\"_0\":\"Oracle version at `oracleVersion` with price transformed by payoff function\"}},\"closeAll(address)\":{\"details\":\"Only callable by the Collateral contract as part of the liquidation flow\",\"params\":{\"account\":\"Account to close out\"}},\"closeMake(uint256)\":{\"params\":{\"amount\":\"Amount of the position to close\"}},\"closeTake(uint256)\":{\"params\":{\"amount\":\"Amount of the position to close\"}},\"currentVersion()\":{\"returns\":{\"_0\":\"Current oracle version transformed by the payoff definition\"}},\"initialize((string,string,(uint8,uint8,bytes30),address,uint256,uint256,uint256,uint256,uint256,(int128,int128,int128,uint128)))\":{\"params\":{\"productInfo_\":\"Product initialization params\"}},\"isClosed(address)\":{\"params\":{\"account\":\"Account to return for\"},\"returns\":{\"_0\":\"The the account is closed\"}},\"isLiquidating(address)\":{\"params\":{\"account\":\"Account to return for\"},\"returns\":{\"_0\":\"Whether the account is in liquidation\"}},\"latestVersion()\":{\"returns\":{\"_0\":\"Latest settled oracle version of the product\"}},\"latestVersion(address)\":{\"params\":{\"account\":\"Account to return for\"},\"returns\":{\"_0\":\"Latest settled oracle version of the account\"}},\"maintenance(address)\":{\"params\":{\"account\":\"Account to return for\"},\"returns\":{\"_0\":\"The current maintenance requirement\"}},\"maintenanceNext(address)\":{\"details\":\"Assumes no price change and no funding, used to protect user from over-opening\",\"params\":{\"account\":\"Account to return for\"},\"returns\":{\"_0\":\"The next maintenance requirement\"}},\"openMake(uint256)\":{\"params\":{\"amount\":\"Amount of the position to open\"}},\"openTake(uint256)\":{\"params\":{\"amount\":\"Amount of the position to open\"}},\"position(address)\":{\"params\":{\"account\":\"Account to return for\"},\"returns\":{\"_0\":\"Current position of the account\"}},\"positionAtVersion(uint256)\":{\"details\":\"Only valid for the version at which a global settlement occurred\",\"params\":{\"oracleVersion\":\"Oracle version to return for\"},\"returns\":{\"_0\":\"Global position at oracle version\"}},\"pre()\":{\"returns\":{\"_0\":\"Global pending-settlement position\"}},\"pre(address)\":{\"params\":{\"account\":\"Account to return for\"},\"returns\":{\"_0\":\"Current pre-position of the account\"}},\"rate((uint256,uint256))\":{\"details\":\"Handles 0-maker/taker edge cases\",\"params\":{\"position_\":\"Position to base utilization on\"},\"returns\":{\"_0\":\"The per-second rate\"}},\"settleAccount(address)\":{\"params\":{\"account\":\"Account to settle\"}},\"shareAtVersion(uint256)\":{\"details\":\"Only valid for the version at which a global settlement occurred\",\"params\":{\"oracleVersion\":\"Oracle version to return for\"},\"returns\":{\"_0\":\"Global accumulator share at oracle version\"}},\"updateClosed(bool)\":{\"details\":\"only callable by product owner. Settles the product before flipping the flag\",\"params\":{\"newClosed\":\"new closed value\"}},\"updateFundingFee(uint256)\":{\"details\":\"only callable by product owner\",\"params\":{\"newFundingFee\":\"new funding fee value\"}},\"updateMaintenance(uint256)\":{\"details\":\"only callable by product owner\",\"params\":{\"newMaintenance\":\"new maintenance value\"}},\"updateMakerFee(uint256)\":{\"details\":\"only callable by product owner\",\"params\":{\"newMakerFee\":\"new maker fee value\"}},\"updateMakerLimit(uint256)\":{\"details\":\"only callable by product owner\",\"params\":{\"newMakerLimit\":\"new maker limit value\"}},\"updateTakerFee(uint256)\":{\"details\":\"only callable by product owner\",\"params\":{\"newTakerFee\":\"new taker fee value\"}},\"updateUtilizationCurve((int128,int128,int128,uint128))\":{\"details\":\"only callable by product owner\",\"params\":{\"newUtilizationCurve\":\"new utilization curve value\"}},\"valueAtVersion(uint256)\":{\"details\":\"Only valid for the version at which a global settlement occurred\",\"params\":{\"oracleVersion\":\"Oracle version to return for\"},\"returns\":{\"_0\":\"Global accumulator value at oracle version\"}}},\"stateVariables\":{\"_accumulator\":{\"details\":\"The global accumulator state for the product\"},\"_accumulators\":{\"details\":\"The individual accumulator state for each account\"},\"_closed\":{\"details\":\"Whether or not the product is closed\"},\"_position\":{\"details\":\"The global position state for the product\"},\"_positions\":{\"details\":\"The individual position state for each account\"},\"name\":{\"details\":\"The name of the product\"},\"symbol\":{\"details\":\"The symbol of the product\"}},\"title\":\"Product\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"atVersion(uint256)\":{\"notice\":\"Returns the oracle version at `oracleVersion` transformed by the payoff definition\"},\"closeAll(address)\":{\"notice\":\"Closes all open and pending positions, locking for liquidation\"},\"closeMake(uint256)\":{\"notice\":\"Closes a maker position for `msg.sender`\"},\"closeTake(uint256)\":{\"notice\":\"Closes a taker position for `msg.sender`\"},\"currentVersion()\":{\"notice\":\"Returns the current oracle version transformed by the payoff definition\"},\"initialize((string,string,(uint8,uint8,bytes30),address,uint256,uint256,uint256,uint256,uint256,(int128,int128,int128,uint128)))\":{\"notice\":\"Initializes the contract state\"},\"isClosed(address)\":{\"notice\":\"Returns whether `account` has a completely zero'd position\"},\"isLiquidating(address)\":{\"notice\":\"Returns whether `account` is currently locked for an in-progress liquidation\"},\"latestVersion()\":{\"notice\":\"Returns the global latest settled oracle version\"},\"latestVersion(address)\":{\"notice\":\"Returns `account`'s latest settled oracle version\"},\"maintenance(address)\":{\"notice\":\"Returns the maintenance requirement for `account`\"},\"maintenanceNext(address)\":{\"notice\":\"Returns the maintenance requirement for `account` after next settlement\"},\"openMake(uint256)\":{\"notice\":\"Opens a maker position for `msg.sender`\"},\"openTake(uint256)\":{\"notice\":\"Opens a taker position for `msg.sender`\"},\"position(address)\":{\"notice\":\"Returns `account`'s current position\"},\"positionAtVersion(uint256)\":{\"notice\":\"Returns the global position at oracleVersion `oracleVersion`\"},\"pre()\":{\"notice\":\"Returns the current global pending-settlement position\"},\"pre(address)\":{\"notice\":\"Returns `account`'s current pending-settlement position\"},\"rate((uint256,uint256))\":{\"notice\":\"Returns The per-second rate based on the provided `position`\"},\"settle()\":{\"notice\":\"Surfaces global settlement externally\"},\"settleAccount(address)\":{\"notice\":\"Surfaces account settlement externally\"},\"shareAtVersion(uint256)\":{\"notice\":\"Returns the global accumulator share at oracleVersion `oracleVersion`\"},\"updateClosed(bool)\":{\"notice\":\"Updates product closed state\"},\"updateFundingFee(uint256)\":{\"notice\":\"Updates the funding fee to `newFundingFee`\"},\"updateMaintenance(uint256)\":{\"notice\":\"Updates the maintenance to `newMaintenance`\"},\"updateMakerFee(uint256)\":{\"notice\":\"Updates the maker fee to `newMakerFee`\"},\"updateMakerLimit(uint256)\":{\"notice\":\"Updates the maker limit to `newMakerLimit`\"},\"updateTakerFee(uint256)\":{\"notice\":\"Updates the taker fee to `newTakerFee`\"},\"updateUtilizationCurve((int128,int128,int128,uint128))\":{\"notice\":\"Updates the utilization curve to `newUtilizationCurve`\"},\"valueAtVersion(uint256)\":{\"notice\":\"Returns the global accumulator value at oracleVersion `oracleVersion`\"}},\"notice\":\"Manages logic and state for a single product market.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/product/Product.sol\":\"Product\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":5800},\"remappings\":[]},\"sources\":{\"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\":{\"keccak256\":\"0xde0f20d468ba8b91addfc356e13f2c74a4dc8abe68be323942217c723775d9c1\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://a0b0ac97b512059cde8dae4c46391389075ff0fae475dead9ad5245c84c54271\",\"dweb:/ipfs/QmawgiGSqJ6ox8fSM9KVBPdwtjheGEytB7EpLDV1dqqey4\"]},\"@equilibria/root/control/unstructured/UInitializable.sol\":{\"keccak256\":\"0xd2743d8fcc220ed2ccdc0bba1db0a3e107741bd5c0cac47ca8c0b5a00ba2fd7f\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://56aadd6e4d60dde940c2d1dd0f4d39aaca7666850a8af9f288c81cb36ef780d3\",\"dweb:/ipfs/QmSFeJURqupzavfsCTZJHQKDYDnzQnyGAA24oeDCDHpJz4\"]},\"@equilibria/root/control/unstructured/UReentrancyGuard.sol\":{\"keccak256\":\"0x4962245ca8fdda3dc40c0f942a3568d90fb69428a6927b058018b01c90eb9fc9\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://2fc71fcb0176819e0266d3e9ffc9f02548b8513d360d29aeb951577b997caed7\",\"dweb:/ipfs/QmQtdTj4akRn6ZNzQYB1KsxzgdewJGrZNaZp4WYGqbquZA\"]},\"@equilibria/root/curve/CurveMath.sol\":{\"keccak256\":\"0x60d159f9ddf0dbe81124ecad58bba734b4cf82877637ff8d9d7f3e92f2da4ded\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://21ec7d55c7edb5e33a8448f90f8229a69e3ad88ce36f174515008ef6a01aa6d3\",\"dweb:/ipfs/QmNR72iJ8ayUBg8KiwDEdU5bsPf2UU9APPXG4bU1Ehq6zk\"]},\"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\":{\"keccak256\":\"0xae202813874bc306d51b3dab8194c86f6483bb20bf1f673ddaee16aa8de567ff\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://078af55f041677c10be7eb87c4c4d7683288b2c04b936bccca9929315b4e7b45\",\"dweb:/ipfs/QmbmQsXNmfVxL95qHFQiaEQpt8PHohnpLdd94T3THYFubF\"]},\"@equilibria/root/number/types/Fixed18.sol\":{\"keccak256\":\"0x613587461ef3437ef33229cdda7d34ea746278721baf06e20b2e43977f43174d\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://630392f0e52d45747543e562ed58962bfa70c867031bdc2f304193072afbd618\",\"dweb:/ipfs/QmT1Zrvart6MYLvf4XqZUjm99L5AfuBcczV27ed3V4AvbW\"]},\"@equilibria/root/number/types/PackedFixed18.sol\":{\"keccak256\":\"0xb52960cc8e3132e45d342bbbb1c6a96219022cd8557997933bd8250170268b64\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://d3dde781dcb4cd5b7aff0d1a2b5d38bd9a321afd371aed6f88e4b4b2bc2a5984\",\"dweb:/ipfs/QmYaAukn1c8tE21HC2N415XZxT1H8zMQeoUoxh3iJTgxyA\"]},\"@equilibria/root/number/types/PackedUFixed18.sol\":{\"keccak256\":\"0xb5c5cd32d6530b2fe75228b6be32ebcb7762f6d7988b85a6b85a289ce8256d51\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://162ccf052216233008e732f0059d7cfde5c0aa70a5d4cf6549b1840f2ea791cc\",\"dweb:/ipfs/QmT95S1UHQbsT2ehAG42tLw4RUwCGijQ4fTkndL126yJmE\"]},\"@equilibria/root/number/types/UFixed18.sol\":{\"keccak256\":\"0x8ebef1e6c717f565b9ed545a876b5692b4007e6485c99f39d363f7405e591792\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://eb72bd190425ef3165df4c255617dfccb494563b3f9953c91aa8c4619cce779f\",\"dweb:/ipfs/QmZdmxTZh8DtGZeE1xzrPxSDNnicRTXpPgG97AsbE3TA3C\"]},\"@equilibria/root/storage/UStorage.sol\":{\"keccak256\":\"0xe2b8491d1b5aa93f7e059e1a8f156b0ab37fef9ed973be97a64f2eabfc2cc172\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://67fd3b83c6e94369d5a75c8fbd15341c4f0c12d6612dc222bc4d82882c1c0f93\",\"dweb:/ipfs/QmNj8i2c5mZysTxoQWg2A21iWyYna6okSHQjHvp6ycQ1Mh\"]},\"@equilibria/root/token/types/Token18.sol\":{\"keccak256\":\"0x6b12afaece814f0ab186200a4729e93eb685a21d3e9b5a3372ff283a7ad5dc23\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://e0118aeb6adc917b2ceadb82cc3a7a56d144ce4c8479296a4b288998c95e23e8\",\"dweb:/ipfs/QmcuREZS6RQU4brXKJ6cYE9dadqMJkrSrRDS7uEVau9eLJ\"]},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://ada1e030c0231db8d143b44ce92b4d1158eedb087880cad6d8cc7bd7ebe7b354\",\"dweb:/ipfs/QmWZ2NHZweRpz1U9GF6R1h65ri76dnX7fNxLBeM2t5N5Ce\"]},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://5a7d5b1ef5d8d5889ad2ed89d8619c09383b80b72ab226e0fe7bde1636481e34\",\"dweb:/ipfs/QmebXWgtEfumQGBdVeM6c71McLixYXQP5Bk6kKXuoY4Bmr\"]},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://5a376d3dda2cb70536c0a45c208b29b34ac560c4cb4f513a42079f96ba47d2dd\",\"dweb:/ipfs/QmZQg6gn1sUpM8wHzwNvSnihumUCAhxD119MpXeKp8B9s8\"]},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"keccak256\":\"0xc3d946432c0ddbb1f846a0d3985be71299df331b91d06732152117f62f0be2b5\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://4632c341a06ba5c079b51ca5a915efab4e6ab57735b37839b3e8365ff806a43e\",\"dweb:/ipfs/QmTHT3xHYed2wajEoA5qu7ii2BxLpPhQZHwAhtLK5Z7ANK\"]},\"@openzeppelin/contracts/utils/Address.sol\":{\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b3a57d0854b2fdce6ebff933a48dca2445643d1eccfc27f00292e937f26c6a58\",\"dweb:/ipfs/QmW45rZooS9TqR4YXUbjRbtf2Bpb5ouSarBvfW1LdGprvV\"]},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"keccak256\":\"0xc995bddbca1ae19788db9f8b61e63385edd3fddf89693b612d5abd1a275974d2\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://ab84f13e6e6e0823854a0cddd49e96df052092d5919f95587607f0ed28a64cb6\",\"dweb:/ipfs/QmbNtqAq23ZDjCzHukQaa7B3y6rcobscm6FZF5PMQXcnVr\"]},\"@openzeppelin/contracts/utils/math/SignedMath.sol\":{\"keccak256\":\"0xb3ebde1c8d27576db912d87c3560dab14adfb9cd001be95890ec4ba035e652e7\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://a709421c4f5d4677db8216055d2d4dac96a613efdb08178a9f7041f0c5cef689\",\"dweb:/ipfs/QmYs2rStvVLDnSJs8HgaMD1ABwoKKWdiVbQyNfLfFWTjTy\"]},\"contracts/controller/UControllerProvider.sol\":{\"keccak256\":\"0x10c6f4ae1a3a511aad470e40c61de5b2171f4151e2dea000acd2ffbd26dcbc2a\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://0f6930c5f0c59189036d86ccf31c7b37016609039ee90cb7605c624c6eed9f8c\",\"dweb:/ipfs/QmcyMMxLKJThDwFP6aAyNDnzNvNUQ6Tx8pq5jeRZdDVwum\"]},\"contracts/interfaces/ICollateral.sol\":{\"keccak256\":\"0xa5e7fdda92702f748e6eb8701e522450035a98a05e5fc1cf66d51c52e397d914\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://76143bc752720d136b0c0ed40c10832ec652f5010bfd988ea623135922eec8a6\",\"dweb:/ipfs/QmSrfhqoNhairnMHdVwdFWLhnAPutLf4k27LbiNuohafek\"]},\"contracts/interfaces/IContractPayoffProvider.sol\":{\"keccak256\":\"0xd73df106d032e976fd959ee6713240e36f54277ce5f215eaec8d5a2c6720a86b\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://b7932019acd64c5310eb266645d9bf9d13ba414ad4cbb8399b5c5fd5702d5d14\",\"dweb:/ipfs/QmVCXi3HXbGxm3kd6MsMULEFjtq8ecWvtREXnkgPgQFNnr\"]},\"contracts/interfaces/IController.sol\":{\"keccak256\":\"0xaabd3740f2265499eea7aad9bd94f9892f53241e5dccce9a50c0e43ed2a6a7cc\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://6164157218ab6f1fb8eb9d292931f83d1406862d0aa985d769efce4906514055\",\"dweb:/ipfs/Qmdq1JVqAX64hE4G7TjLxE5ByH1MT3DhWx9UgsNdcYxt2n\"]},\"contracts/interfaces/IIncentivizer.sol\":{\"keccak256\":\"0x2f95de90dbb3ad35dbfef304f765a622bffff9229868d2898eca8d49c78e8c2c\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://b354084581017fc041d0eab38567493fcb7cddf992550acc2b146a0287a82772\",\"dweb:/ipfs/QmS3eugykAdw5FVUuytnN8d8Rk7vB1LGCL6gCGkj6UaHux\"]},\"contracts/interfaces/IParamProvider.sol\":{\"keccak256\":\"0x2e2d40d0cf55f167118867e41f740b9b40614d05da50fc9bc33a8cede3eaf03e\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://d434bd33927b71335e773b840b7772ea23efd29ac7fb5ab8c21eb2d3f0a8f1cb\",\"dweb:/ipfs/QmSDV6q7SUx74QbZCj5ZScya2kxSB9c2LQFRTRLztpNuJX\"]},\"contracts/interfaces/IPayoffProvider.sol\":{\"keccak256\":\"0xb83d80d624aa9431763f80ecb4bf0214803e25334a7419d954f929e5d0ee7467\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://f16b186a5424f44735d8ee59ddfa188bdee5691b3a4284d0d2c15cb9506accc3\",\"dweb:/ipfs/QmPa26YHbU2kweKyQKqAJfKCe4BfBzHa5AT5CSJQyLJHxx\"]},\"contracts/interfaces/IProduct.sol\":{\"keccak256\":\"0xe1e80b818eadf4cdb070362e40c7cf3863b50c4f944816af27848e319f587241\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://14d6de071435afe4de7681b47dc90857ec43de3d4c5c33f3abf46275cd8b7685\",\"dweb:/ipfs/QmTsrhFR3w5roiZdPsS26vynE3SNMZEhViT1WnDLAy1GKF\"]},\"contracts/interfaces/types/Accumulator.sol\":{\"keccak256\":\"0x7ccd0a72aa593cefb9f4337cf312799f357b82fcb3f0379de0dc503d1cb7e387\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://884ee8101d531f8f596620dbe6f513bdaea06c5d113865fabb26131320286341\",\"dweb:/ipfs/QmRKjXfdTPqErTBz4xFvZMTVX88jxKKw14f1rcfAF7Z2Mr\"]},\"contracts/interfaces/types/PackedAccumulator.sol\":{\"keccak256\":\"0xd83f2822d4f6c818087a232b54007730992c34ff77377fc307a282f886e7cf65\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://0c9c635aa32e6feac02cd3d979f21dd01d70fce677da803958a5f7bf8262177d\",\"dweb:/ipfs/QmQnYbmci8WqyBNzvY7cer56Kwf9PU2Rt3GNn5rdzDQzRa\"]},\"contracts/interfaces/types/PackedPosition.sol\":{\"keccak256\":\"0x04968e6794f6244cb3415cea111d640273a81faea957872988d0cb580f45df1e\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://86c7a1c999d14ef22410bca74c51d3fbdf5ad0160a38eaad89c5e38361b981d0\",\"dweb:/ipfs/QmehdLThnFyoEv79C5xoSPmGFPxjmFvMjcCY94BD2iYmKN\"]},\"contracts/interfaces/types/PayoffDefinition.sol\":{\"keccak256\":\"0x4d3897f408f77381c5ae9990391465c8fd511ddf6ff3b39f6cb69d8c2bd554df\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://9c287e7508600fbf3abd6fd5b5c9294d2d349f59205f2e43e8305d76365058fe\",\"dweb:/ipfs/QmQkcD6bsR2JuhuYfnisE6TaySUKbf6dy939cD4VyT1vQj\"]},\"contracts/interfaces/types/Position.sol\":{\"keccak256\":\"0x027fe392c4f56bf012ba2ca462fcf23e69f2c3b9d283c14089771813437af991\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://d9300f5e81b30795fe38e993fb53fb6aa4ba829088e3e1c151baf5e4207d75cf\",\"dweb:/ipfs/QmSLkhCdGQauQrnBEae8xkXKEhaGZFVHjw29zEWhqCsT85\"]},\"contracts/interfaces/types/PrePosition.sol\":{\"keccak256\":\"0xa6f83f7b5f8139ec874235c406debd086a152977493c08b7f280df6f1737fb96\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://ac7d2a81f5be22873b059396dadcc11b55cabfb4df645066fc62e9f4023886e0\",\"dweb:/ipfs/QmXb33RkGN3pxSmFooZCfp92AJ6cPhgwXCM2DVJkb2W2EP\"]},\"contracts/interfaces/types/ProgramInfo.sol\":{\"keccak256\":\"0x280fcaf931b49abaec46b95ccbabaaf856a4b8e8d036413c9c3b3af25585d161\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://e755bb9bb2fa8c2f2b20226c214cf7306dfa3d84c7cfc275104b7c546d86334b\",\"dweb:/ipfs/QmbFuHfUek97FYpVQF9hP9pUZUVyTaqejvpZAzbikFWVxn\"]},\"contracts/product/Product.sol\":{\"keccak256\":\"0xab85bf0ecb604f5addc50582321f26cdde4f2694390b8ab23aad6f287542d9a2\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://b45829a6be3b45a4b5ea43877936aeff2e3ab48ec4947fe217ec15d79dd77e26\",\"dweb:/ipfs/QmT7WfRrdJDGs8LDLYvviiyJmtxNoMRXftAfPffPxg4f8V\"]},\"contracts/product/UParamProvider.sol\":{\"keccak256\":\"0x504c7d258d932adac2da0cfd17100a7109bd51476f10dcf976d9349003955d31\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://35d53ba11f2ddc4f993c4e52221b0a3e661d3129be26d2db65fa1a5595b74e7f\",\"dweb:/ipfs/QmP6qjtW72N1QSwZd4cPDfFYkqsSuy7oBsPXoLP1ca8PdF\"]},\"contracts/product/UPayoffProvider.sol\":{\"keccak256\":\"0x4faaf5519887fcf551f380b8475a6bc23e07891f35be4582096f296be532d71e\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://9d867e2da89fbf322b387326ecf3f1ddbd81d564d43ec12bed5b7c9fc3517b9c\",\"dweb:/ipfs/QmbnqZimkiCQ3T9FyRtB5Tmh7c1S11xwzSUZcFGJJwv82V\"]},\"contracts/product/types/accumulator/AccountAccumulator.sol\":{\"keccak256\":\"0x93ef06694990ed66672505461ed11a7229d622a8d3c36726884fc9505efb7471\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://d81f01965df38b8677cf9b522f25f1ad43cfa893e481567ecbc31a4a1bde54ff\",\"dweb:/ipfs/QmVFTHo1V2RmQyCDGcL7vNazhwyNxQcSVMHsnY9RjA2Ac6\"]},\"contracts/product/types/accumulator/VersionedAccumulator.sol\":{\"keccak256\":\"0xa51cccef3b5f2075f22793322508e65cedb99cd52104373bdf140c683c256d4a\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://8d961a276280623b502558cb5a914d8ad13dc96e3729347dba5abf0dc1cd6329\",\"dweb:/ipfs/QmRHUEqCWr5g4YohDbjQUFXrfnsLYcuh7FbWuAqeEGu6FU\"]},\"contracts/product/types/position/AccountPosition.sol\":{\"keccak256\":\"0xf1c2e1686ecf354e5a234e4289785453bf3476d07c5331f1460763b31373f5bf\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://215f7c9fc348aef6b640293fc702155021e1143d83589e743ea98d09aa923228\",\"dweb:/ipfs/QmPPijhx4UZ1Q2mBDTHrajNShwYSgN3Ft19gCKBf9knhZA\"]},\"contracts/product/types/position/VersionedPosition.sol\":{\"keccak256\":\"0x64314e810d2549f411f944c72f8b102fed1efb8c35b8fa49fbd70ca86b270870\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://946df2aa4daf2f635edb56550f43c81aad25c685368f9fbba9a169305df58c32\",\"dweb:/ipfs/QmXEE7p2Rp8K61ULcMivdc1rn2JJFu2JpQdBSBCFfPVKr7\"]}},\"version\":1}", - "bytecode": "0x608060405234801561001057600080fd5b50615ef280620000216000396000f3fe608060405234801561001057600080fd5b50600436106102de5760003560e01c806373b88f3b11610186578063a12e1b33116100e3578063e1c3c98d11610097578063f6b3200811610071578063f6b3200814610692578063f77c4791146106a5578063fc741c7c146106ad57600080fd5b8063e1c3c98d14610659578063f0b409591461066c578063f667f8971461067f57600080fd5b8063b7648fb9116100c8578063b7648fb9146105e9578063c07f47d41461063e578063d7d7d6b81461064657600080fd5b8063a12e1b331461057b578063ab582f29146105d657600080fd5b80638e480b201161013a57806395d89b411161011f57806395d89b411461054b5780639a427d03146105535780639d888e861461057357600080fd5b80638e480b201461050f578063916890241461053857600080fd5b80637dc0d1d01161016b5780637dc0d1d0146104bc5780637ece075d146104dc5780638c94b48f146104fc57600080fd5b806373b88f3b1461049657806376f37001146104a957600080fd5b8063476fa96d1161023f57806359ea287d116101f3578063611c71b4116101cd578063611c71b4146104685780636943b0171461047b5780636c376cc51461048e57600080fd5b806359ea287d146104455780635d16e1201461044d57806360ec91d61461045557600080fd5b806358ca6f981161022457806358ca6f98146103eb57806359218fe91461042a578063597e1fb51461043d57600080fd5b8063476fa96d146103c557806356bc1ad4146103d857600080fd5b80631e0c6fb911610296578063212e0ad31161027b578063212e0ad3146103975780633e17b8c7146103aa57806343f0179b146103bd57600080fd5b80631e0c6fb91461034957806320fe9c3c1461036957600080fd5b806311da60b4116102c757806311da60b414610316578063153261e514610320578063193775671461033357600080fd5b806305d5c1cb146102e357806306fdde0314610301575b600080fd5b6102eb6106b5565b6040516102f891906155ad565b60405180910390f35b610309610708565b6040516102f89190615619565b61031e610796565b005b61031e61032e36600461564c565b6108ea565b61033b610a21565b6040519081526020016102f8565b61035c610357366004615679565b610a4b565b6040516102f89190615696565b61037c6103773660046156d0565b610abd565b604080518251815260209283015192810192909252016102f8565b61031e6103a53660046156f7565b610ae2565b61031e6103b83660046156d0565b610c6d565b61033b610d8d565b61037c6103d33660046156d0565b610db7565b61031e6103e63660046156d0565b610dd6565b61041a6103f9366004615679565b6001600160a01b031660009081526002602052604090206007015460ff1690565b60405190151581526020016102f8565b61031e6104383660046156d0565b610ef6565b61041a6111d2565b61035c6111fc565b61033b611253565b61033b610463366004615714565b61127d565b61031e6104763660046156d0565b6112c6565b61041a610489366004615679565b6113e6565b61033b611485565b61031e6104a43660046156d0565b6114af565b61031e6104b73660046156d0565b611863565b6104c4611a45565b6040516001600160a01b0390911681526020016102f8565b6104ef6104ea3660046156d0565b611a6f565b6040516102f89190615726565b61031e61050a3660046156d0565b611b11565b61033b61051d366004615679565b6001600160a01b031660009081526009602052604090205490565b61033b610546366004615679565b611c31565b610309611c52565b6105666105613660046156d0565b611c5f565b6040516102f89190615747565b6104ef611c7e565b610583611cea565b6040516102f8919060006080820190508251600f0b82526020830151600f0b60208301526040830151600f0b60408301526fffffffffffffffffffffffffffffffff606084015116606083015292915050565b61033b6105e4366004615679565b611db7565b6105666105f7366004615679565b6040805180820190915260008082526020820152506001600160a01b0316600090815260026020908152604091829020825180840190935280548352600101549082015290565b600a5461033b565b61031e6106543660046156d0565b611dd8565b61031e6106673660046156d0565b61229c565b61031e61067a36600461575e565b6123bc565b61031e61068d366004615679565b612562565b61031e6106a0366004615679565b6126c5565b6104c4612884565b61033b6128ae565b6106da6040805160608101909152806000815260200160008152600060209091015290565b6107037f630ac9ad193fa8d8f5a7207eefdee35934d664003a3d4c286a591e065a62034e6128d8565b905090565b600080546107159061579a565b80601f01602080910402602001604051908101604052809291908181526020018280546107419061579a565b801561078e5780601f106107635761010080835404028352916020019161078e565b820191906000526020600020905b81548152906001019060200180831161077157829003601f168201915b505050505081565b60026107c07f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b036107f7576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755610823612884565b6001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610860573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061088491906157e7565b156108bb576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6108c3612985565b5060017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755565b60006108f4612884565b604051633e92a73360e11b81523060048201526001600160a01b039190911690637d254e6690602401602060405180830381865afa15801561093a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061095e9190615804565b905033610969612884565b6001600160a01b031663a123c33e836040518263ffffffff1660e01b815260040161099691815260200190565b602060405180830381865afa1580156109b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d7919061581d565b6001600160a01b031614610a065760405163123d8bcf60e21b8152600481018290526024015b60405180910390fd5b610a1d610a18368490038401846158a9565b612c51565b5050565b60006107037f897858f7b7d3c8b4e7a700b401ad192a110353a60c809946583c0d62cda7f0b75490565b610a536154f1565b506001600160a01b031660009081526002602081815260409283902083516060810185529281015483528351808501855260038201548152600482015481840152838301528351808501855260058201548152600690910154918101919091529181019190915290565b6040805180820190915260008082526020820152610adc600a83612d4e565b92915050565b6000610aec612884565b604051633e92a73360e11b81523060048201526001600160a01b039190911690637d254e6690602401602060405180830381865afa158015610b32573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b569190615804565b905033610b61612884565b6001600160a01b031663a123c33e836040518263ffffffff1660e01b8152600401610b8e91815260200190565b602060405180830381865afa158015610bab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bcf919061581d565b6001600160a01b031614610bf95760405163123d8bcf60e21b8152600481018290526024016109fd565b6000610c03612985565b9050610c2e7fbdea2cc426745068386b3804e5b401ae87ffbae9dbf293944b5307f507040c79849055565b8051604051908152831515907f482763b305ee10cd21c16c0cbeed259f2e4fcacdc9767cef16dc1fbe483d3488906020015b60405180910390a2505050565b6000610c77612884565b604051633e92a73360e11b81523060048201526001600160a01b039190911690637d254e6690602401602060405180830381865afa158015610cbd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ce19190615804565b905033610cec612884565b6001600160a01b031663a123c33e836040518263ffffffff1660e01b8152600401610d1991815260200190565b602060405180830381865afa158015610d36573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d5a919061581d565b6001600160a01b031614610d845760405163123d8bcf60e21b8152600481018290526024016109fd565b610a1d82612dad565b60006107037f1d7cfd39841edd73967db6350efae442ebd8c6e1bfca55faa52b046d39b7e4935490565b6040805180820190915260008082526020820152610adc600a83612e4f565b6000610de0612884565b604051633e92a73360e11b81523060048201526001600160a01b039190911690637d254e6690602401602060405180830381865afa158015610e26573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e4a9190615804565b905033610e55612884565b6001600160a01b031663a123c33e836040518263ffffffff1660e01b8152600401610e8291815260200190565b602060405180830381865afa158015610e9f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ec3919061581d565b6001600160a01b031614610eed5760405163123d8bcf60e21b8152600481018290526024016109fd565b610a1d82612ea7565b6002610f207f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03610f57576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755610f83612884565b6001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fc0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fe491906157e7565b1561101b576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336000611026612985565b90506110328282612f00565b3360009081526002602052604090206007015460ff161561107f576040517f6830d4d700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61108933846132fe565b3360009081526002602052604090206110a190613380565b156110d8576040517f3975ab9300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6110e06111d2565b6111a65760408051606081018252600454815281518083018352600554815260065460208281019190915280830191909152825180840184526007548152600854918101919091529181019190915260009061114890611142610561600a5490565b906133ef565b905060006111558261341e565b905061116981670de0b6b3a7640000613467565b156111a3576040517fd8b8b951000000000000000000000000000000000000000000000000000000008152600481018290526024016109fd565b50505b505060017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75550565b50565b60006107037fbdea2cc426745068386b3804e5b401ae87ffbae9dbf293944b5307f507040c795490565b6112046154f1565b5060408051606081018252600454815281518083018352600554815260065460208281019190915280830191909152825180840184526007548152600854918101919091529181019190915290565b60006107037face7e947336f94057b47a9ab5531b0363e85c8d36c05c7d915ec8e525fd159d85490565b60008061128f6020840135843561347b565b905060006112a58261129f611cea565b906134ab565b90506112be6112b76301e13380613542565b8290613556565b949350505050565b60006112d0612884565b604051633e92a73360e11b81523060048201526001600160a01b039190911690637d254e6690602401602060405180830381865afa158015611316573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061133a9190615804565b905033611345612884565b6001600160a01b031663a123c33e836040518263ffffffff1660e01b815260040161137291815260200190565b602060405180830381865afa15801561138f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b3919061581d565b6001600160a01b0316146113dd5760405163123d8bcf60e21b8152600481018290526024016109fd565b610a1d82613575565b6001600160a01b0381166000908152600260208181526040808420815160a0810183528154606080830191825260018401546080840152908252835190810184529482015485528251808401845260038301548152600483015481860152858501528251808401845260058301548152600683015481860152858401529283019390935260079092015460ff16151591810191909152610adc90613617565b60006107037f968cf792ff9a89745e4746179e93a7b9d7f08b0ff8366fd6f6dbd524ef1074645490565b60026114d97f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03611510576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75561153c612884565b6001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611579573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061159d91906157e7565b156115d4576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6115dc6111d2565b15611613576040517fded15dbf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b33600061161e612985565b905061162a8282612f00565b3360009081526002602052604090206007015460ff1615611677576040517f6830d4d700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611682600a5490565b3360009081526002602081905260409091209192506116a391018286613638565b6116af60048286613638565b604080518281526020810186905233917fb9726781b72c53f23217f424d70445b222951f008aeac7eece8139caed71ed2d910160405180910390a2506116f3612884565b6001600160a01b031663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa158015611730573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611754919061581d565b6040517fe41191800000000000000000000000000000000000000000000000000000000081523360048201523060248201526001600160a01b03919091169063e411918090604401602060405180830381865afa1580156117b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117dd91906157e7565b15611814576040517f24a21d2900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b33600090815260026020526040902061182c9061365d565b156110d8576040517f90898fd100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600261188d7f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b036118c4576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7556118f0612884565b6001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561192d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061195191906157e7565b15611988576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336000611993612985565b905061199f8282612f00565b3360009081526002602052604090206007015460ff16156119ec576040517f6830d4d700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6119f633846136bc565b336000908152600260205260409020611a0e90613380565b156111a6576040517f3975ab9300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006107037f6c0d5e3cd81753b1b21f67f61d56a97aae7a3e0179486d114788ad4576f532665490565b611a9360405180606001604052806000815260200160008152602001600081525090565b610adc611a9e611a45565b6001600160a01b0316637ece075d846040518263ffffffff1660e01b8152600401611acb91815260200190565b606060405180830381865afa158015611ae8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b0c919061593d565b61373e565b6000611b1b612884565b604051633e92a73360e11b81523060048201526001600160a01b039190911690637d254e6690602401602060405180830381865afa158015611b61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b859190615804565b905033611b90612884565b6001600160a01b031663a123c33e836040518263ffffffff1660e01b8152600401611bbd91815260200190565b602060405180830381865afa158015611bda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bfe919061581d565b6001600160a01b031614611c285760405163123d8bcf60e21b8152600481018290526024016109fd565b610a1d82613781565b6001600160a01b0381166000908152600260205260408120610adc906137da565b600180546107159061579a565b6040805180820190915260008082526020820152610adc600383613813565b611ca260405180606001604052806000815260200160008152602001600081525090565b610703611cad611a45565b6001600160a01b0316639d888e866040518163ffffffff1660e01b8152600401606060405180830381865afa158015611ae8573d6000803e3d6000fd5b6040805160808101825260008082526020820181905291810182905260608101919091526107037f917d72d9b73e141a5f0eff6b5933a24665154df6903ed198d591afc8ac62f8f660408051608081018252600080825260208201819052918101829052606081019190915281604080516080810182528254600f81810b835270010000000000000000000000000000000091829004810b60208401526001909401549384900b9282019290925291046fffffffffffffffffffffffffffffffff16606082015292915050565b6001600160a01b0381166000908152600260205260408120610adc90613879565b6002611e027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03611e39576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755611e65612884565b6001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ea2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ec691906157e7565b15611efd576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611f056111d2565b15611f3c576040517fded15dbf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336000611f47612985565b9050611f538282612f00565b600a54600003611f8f576040517fc25d67ab00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3360009081526002602052604090206007015460ff1615611fdc576040517f6830d4d700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611fe7600a5490565b336000908152600260208190526040909120919250612008910182866138f3565b612014600482866138f3565b604080518281526020810186905233917ff98b31465ac12e92b5cb136ade913276c267463c4395bb1a3999bc88fb837806910160405180910390a250612058612884565b6001600160a01b031663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa158015612095573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120b9919061581d565b6040517fe41191800000000000000000000000000000000000000000000000000000000081523360048201523060248201526001600160a01b03919091169063e411918090604401602060405180830381865afa15801561211e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061214291906157e7565b15612179576040517f24a21d2900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3360009081526002602052604090206121919061365d565b156121c8576040517f90898fd100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60408051606081018252600454815281518083018352600554815260065460208281019190915280830191909152825180840184526007548152600854918101919091529181019190915260009061222690611142610561600a5490565b905061223b612233610a21565b825190613913565b15612272576040517fcefd0e5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505060017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7555050565b60006122a6612884565b604051633e92a73360e11b81523060048201526001600160a01b039190911690637d254e6690602401602060405180830381865afa1580156122ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123109190615804565b90503361231b612884565b6001600160a01b031663a123c33e836040518263ffffffff1660e01b815260040161234891815260200190565b602060405180830381865afa158015612365573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612389919061581d565b6001600160a01b0316146123b35760405163123d8bcf60e21b8152600481018290526024016109fd565b610a1d82613929565b6001806123e77f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b5490565b10612421576040517f1e7a9d95000000000000000000000000000000000000000000000000000000008152600481018290526024016109fd565b61244a7f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b829055565b60017fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c55612477336139cb565b61249361248a60c0840160a08501615679565b83604001613a9b565b61249b613bf1565b6124d260c083013560e08401356101008501356101208601356101408701356124cd3689900389016101608a016158a9565b613c7d565b6124dc8280615979565b6000916124ea919083615a2b565b506124f86020830183615979565b600191612506919083615a2b565b5060007fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c556040518181527fbe9b076dc5b65990cca9dd9d7366682482e7817a6f6bc7f4faf4dc32af497f329060200160405180910390a15050565b600261258c7f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b036125c3576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7556125ef612884565b6001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561262c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061265091906157e7565b15612687576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000612691612985565b905061269d8282612f00565b5060017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75550565b6126cd612884565b6001600160a01b031663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa15801561270a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061272e919061581d565b6001600160a01b0316336001600160a01b031614612778576040517f40cbe9b100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6127806111d2565b156127b7576040517fded15dbf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060006127c2612985565b90506127ce8282612f00565b6001600160a01b0383166000908152600260208181526040808420815160608101835293810154845281518083018352600382015481526004820154818501528484015281518083018352600582015481526006820154818501528483015281518083019092528054825260018101549282019290925290929161285291906133ef565b90506128628582600001516132fe565b6128708582602001516136bc565b50600701805460ff19166001179055505050565b60006107037f0e555410d8128dff796eab5d29b97dd593ce9cab44a71b64c08244579ea605335490565b60006107037f5a294f9055e9dc7a18078b4e0139086766d723c3cd728bd59cc1f3b589741ed25490565b6128fd6040805160608101909152806000815260200160008152600060209091015290565b604080516060810190915282548390829060ff16600181111561292257612922615547565b600181111561293357612933615547565b81528154602090910190610100900460ff16600181111561295657612956615547565b600181111561296757612967615547565b8152905462010000900460101b61ffff191660209091015292915050565b6129a960405180606001604052806000815260200160008152602001600081525090565b60006129b3612884565b90506129bd613d21565b915060006129ca600a5490565b835190915081036129da57505090565b60006129e582611a6f565b84519091506000906129f990600490613d8f565b9050600085600001518214612a1657612a1182611a6f565b612a18565b855b9050846001600160a01b0316636fc6407c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a58573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a7c919061581d565b6001600160a01b031663a55ff01d876040518263ffffffff1660e01b8152600401612aa79190615726565b600060405180830381600087803b158015612ac157600080fd5b505af1158015612ad5573d6000803e3d6000fd5b505050506000612ae3613db2565b90506000612b00612af9600a8460038988613e2e565b8290613f72565b9050612b11612af960038886613f7e565b8851845191925014612b4357612b2f612af9600a846003878d613e2e565b8351909150612b41906003908a613f7e565b505b866001600160a01b031663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ba5919061581d565b6001600160a01b0316637f3dd53b826040518263ffffffff1660e01b8152600401612bd291815260200190565b600060405180830381600087803b158015612bec57600080fd5b505af1158015612c00573d6000803e3d6000fd5b505084518a516040517f88a84ea6dd274b386afd27dbbe11b6192b25017f5e60bb8c4053dfddb45c294d9450612c3f9350918252602082015260400190565b60405180910390a15050505050505090565b805160208201516fffffffffffffffffffffffffffffffff9182167001000000000000000000000000000000009183168202177f917d72d9b73e141a5f0eff6b5933a24665154df6903ed198d591afc8ac62f8f65560408301516060840151908316921602177f917d72d9b73e141a5f0eff6b5933a24665154df6903ed198d591afc8ac62f8f75580517f0887cb99bfd5017bb9e8282cc29d17176a4f1e542f869a03a5617919fb74620b90600f0b6020830151600f0b6040840151600f0b60608501516fffffffffffffffffffffffffffffffff166040805194855260208501939093529183015260608201526080015b60405180910390a150565b6040805180820182526000808252602080830182905284825260018601815290839020835180850190945254600f81810b8552700100000000000000000000000000000000909104900b9083015290612da69061407c565b9392505050565b612dbf81670de0b6b3a7640000613913565b15612df6576040517fccbac87e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612e1f7f5a294f9055e9dc7a18078b4e0139086766d723c3cd728bd59cc1f3b589741ed2829055565b6040518181527f3ffba897342f8382491dd8984c684cc237d3c045298d4cec8ad0fd7262aa91f190602001612d43565b6040805180820182526000808252602080830182905284825260028601815290839020835180850190945254600f81810b8552700100000000000000000000000000000000909104900b9083015290612da69061407c565b612ed07f968cf792ff9a89745e4746179e93a7b9d7f08b0ff8366fd6f6dbd524ef107464829055565b6040518181527f5339371c8d31c4fb29fd4ad6b3bf89793839a3dfae45035ef23a635916dafc6590602001612d43565b6000612f0a612884565b8251909150612f2e846001600160a01b031660009081526009602052604090205490565b03612f3857505050565b81516001600160a01b038416600090815260026020819052604082209192612f639290910190613d8f565b9050600083600001518214612f8057612f7b82611a6f565b612f82565b835b90506000836001600160a01b0316636fc6407c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612fc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fe8919061581d565b6001600160a01b0316631830349c87846040518363ffffffff1660e01b8152600401613015929190615aec565b600060405180830381600087803b15801561302f57600080fd5b505af1158015613043573d6000803e3d6000fd5b5050506001600160a01b038716600090815260026020908152604080832086516009909352922061308c93506130859261308092600a91906140b8565b614121565b8290614131565b6001600160a01b03871660009081526002602052604090209091506130c5906130be906130b9908561413d565b614201565b8290614260565b85518351919250146131ce57836001600160a01b0316636fc6407c6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561310f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613133919061581d565b6001600160a01b0316631830349c87876040518363ffffffff1660e01b8152600401613160929190615aec565b600060405180830381600087803b15801561317a57600080fd5b505af115801561318e573d6000803e3d6000fd5b5050506001600160a01b03871660009081526002602090815260408083208951600990935292206131cb93506130859261308092600a91906140b8565b90505b836001600160a01b031663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa15801561320c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613230919061581d565b6040517fc9cb48de0000000000000000000000000000000000000000000000000000000081526001600160a01b03888116600483015260248201849052919091169063c9cb48de90604401600060405180830381600087803b15801561329557600080fd5b505af11580156132a9573d6000803e3d6000fd5b5050835187516040805192835260208301919091526001600160a01b038a1693507f9d7055d24918d8c2fd08660a27bf31d4086fa71a51cd07874276470223aa480f92500160405180910390a2505050505050565b6000613309600a5490565b6001600160a01b03841660009081526002602081905260409091209192506133339101828461426c565b61333f6004828461426c565b60408051828152602081018490526001600160a01b038516917f39854479080fac0b5e7c0ecedb0fb02308a72a43cd102c6b9f918653d34003679101610c60565b60408051808201825260038301548152600483015460208083019190915282518084019093528354835260018401549083015260009182916133c2919061428c565b805160058501549192506133d69190613913565b80612da6575060208101516006840154612da691613913565b6040805180820190915260008082526020820152612da661341484846020015161428c565b83604001516142e3565b600061342c82602001511590565b613458576020820151825161345391670de0b6b3a76400009161344e91614331565b614350565b610adc565b670de0b6b3a764000092915050565b6000613473838361435c565b159392505050565b6000816134a15782156134905760001961349a565b670de0b6b3a76400005b9050610adc565b61349a8383614331565b60608201516000906fffffffffffffffffffffffffffffffff166134cf8382613467565b156134f95783516134f190600090600f0b60408701518490600f0b5b87614391565b915050610adc565b61350b83670de0b6b3a7640000613467565b156135355760408401516134f1908290600f0b6020870151670de0b6b3a764000090600f0b6134eb565b50505060200151600f0b90565b6000610adc670de0b6b3a764000083615b4c565b60008161356b670de0b6b3a764000085615b4c565b612da69190615c37565b61358781670de0b6b3a7640000613913565b156135be576040517f4589bde600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6135e77f1d7cfd39841edd73967db6350efae442ebd8c6e1bfca55faa52b046d39b7e493829055565b6040518181527f587b2c669227029fa59d08b2061678cdf5536e8709f7760940e5cf5f24336e4690602001612d43565b60006136268260200151614442565b8015610adc57508151610adc90614461565b60028301546136479082613f72565b600284015581835561365883614479565b505050565b8054600090819015801561367357506003830154155b801561368157506005830154155b600184015490915060009015801561369b57506004840154155b80156136a957506006840154155b9050811580156112be5750159392505050565b60006136c7600a5490565b6001600160a01b03841660009081526002602081905260409091209192506136f1910182846144d5565b6136fd600482846144d5565b60408051828152602081018490526001600160a01b038516917f63625b85818a29587ee919ee6a968ee0b32f3513f2884b3968001062ba49eb6b9101610c60565b61376260405180606001604052806000815260200160008152602001600081525090565b61377882604001516137726106b5565b906144f5565b60408301525090565b6137aa7f897858f7b7d3c8b4e7a700b401ad192a110353a60c809946583c0d62cda7f0b7829055565b6040518181527ff6bebbfbe342f87db90e223fb3dd70b26b082ed4266f1673b509dfeca0a7697a90602001612d43565b600781015460009060ff16156137f257506000919050565b604080518082019091528254815260018301546020820152610adc906145ec565b6040805180820190915260008082526020820152600082815260208481526040918290208251808401909352546fffffffffffffffffffffffffffffffff80821684527001000000000000000000000000000000009091041690820152612da6906146f3565b60408051606081018252600283015481528151808301835260038401548152600484015460208281019190915280830191909152825180840184526005850154815260068501548183015282840152825180840190935283548352600184015490830152600091610adc916138ee91906133ef565b6145ec565b60018301546139029082613f72565b600184015581835561365883614749565b600061391f838361435c565b6002149392505050565b61393b81670de0b6b3a7640000613913565b15613972576040517f82894f6b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61399b7face7e947336f94057b47a9ab5531b0363e85c8d36c05c7d915ec8e525fd159d8829055565b6040518181527ffb8fb3fd721f9e0d7396f8475680125318fb14fffa561a1ab43dfa329f2fd98a90602001612d43565b303b151580156139fa57507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b15613a31576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0381163b613a72576040517f14878b6900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6111cf7f0e555410d8128dff796eab5d29b97dd593ce9cab44a71b64c08244579ea60533829055565b303b15158015613aca57507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b15613b01576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0382163b613b42576040517fd26af10d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b613b6b7f6c0d5e3cd81753b1b21f67f61d56a97aae7a3e0179486d114788ad4576f53266839055565b613b82613b7d36839003830183615c8e565b6147a5565b613bb8576040517f9a51fe8f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610a1d613bca36839003830183615c8e565b7f630ac9ad193fa8d8f5a7207eefdee35934d664003a3d4c286a591e065a62034e906147ea565b303b15158015613c2057507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b15613c57576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755565b303b15158015613cac57507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b15613ce3576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b613cec86612ea7565b613cf585613929565b613cfe84612dad565b613d0783613575565b613d1082613781565b613d1981612c51565b505050505050565b613d4560405180606001604052806000815260200160008152602001600081525090565b610703613d50611a45565b6001600160a01b031663fff6cae96040518163ffffffff1660e01b81526004016060604051808303816000875af1158015611ae8573d6000803e3d6000fd5b81546000908015613daa57613da5816001615cea565b6112be565b509092915050565b6000610703613dbf612884565b6001600160a01b031663e975c0c36040518163ffffffff1660e01b8152600401602060405180830381865afa158015613dfc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e209190615804565b613e28611253565b90614873565b81516000908190613e40908690613813565b9050613e5f604051806040016040528060008152602001600081525090565b613e6b8783878761487f565b93509050613e84613e7d838787614b14565b8290614c7c565b90506000613e93838787614cca565b9050613eb5613eb083613eaa8c8a60000151612d4e565b90614c7c565b614d4f565b8551600090815260018b0160209081526040909120825192909101516fffffffffffffffffffffffffffffffff9081167001000000000000000000000000000000000292169190911790558551613f1790613eb0908390613eaa908d90612e4f565b8551600090815260028b0160209081526040909120825192909101516fffffffffffffffffffffffffffffffff9081167001000000000000000000000000000000000292169190911790555050915190955550929392505050565b6000612da68284615cea565b60408051606081018252600185015481528151808301835260028601548152600386015460208281019190915280830191909152825180840184526004870154815260058701549181019190915291810191909152600090819081908190613ff29086613feb8a8a613813565b9190614d9b565b92509250925061400183614def565b8551600090815260208981526040909120825192909101516fffffffffffffffffffffffffffffffff90811670010000000000000000000000000000000002921691909117905580156140725760006001880181905560028801819055600388018190556004880181905560058801555b5095945050505050565b60408051808201909152600080825260208201526040805180820190915282518190600f0b8152602084810151910190600f0b5b905292915050565b604080518082019091526000808252602082015284546000906140f0906140e0908790612d4e565b6140ea8786612d4e565b90614e59565b6040805180820190915285548152600186015460208201529091506141159082614ea7565b92909555509392505050565b60208101518151600091610adc91905b6000612da68284615d02565b6040805160608101825260028401548152815180830183526003850154815260048501546020828101919091528083019190915282518084018452600586015481526006860154818301528284015282518084019093528454835260018501549083015260009182916141b1919085614d9b565b8251875560209092015160018701559250905080156141fa57600060028501819055600385018190556004850181905560058501819055600685015560078401805460ff191690555b5092915050565b6000817f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811115610adc576040517ea07eb5000000000000000000000000000000000000000000000000000000008152600481018290526024016109fd565b6000612da68284615d76565b600383015461427b9082613f72565b600384015581835561365883614749565b6040805180820190915260008082526020820152604080518082019091528251845182916142ba9190613f72565b81526020016142da84602001518660200151613f7290919063ffffffff16565b90529392505050565b6040805180820190915260008082526020820152604080518082019091528251845182916143119190614ef5565b81526020016142da84602001518660200151614ef590919063ffffffff16565b600081614346670de0b6b3a764000085615dea565b612da69190615e09565b6000612da68383614f01565b600082828082111561437357600292505050610adc565b8082101561438657600092505050610adc565b506001949350505050565b600061439d8287613467565b806143ad57506143ad8285613913565b156143e4576040517f0db0f7cb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006143f08588614ef5565b905060006143fe8588614260565b9050600061441683614410878c614ef5565b90614331565b90506144358861442f61442884614201565b8590614f17565b90614131565b9998505050505050505050565b60006144518260200151614461565b8015610adc5750610adc82604001515b8051600090158015610adc5750602082015115610adc565b6004810154600282015461448c91613913565b156144b357600481015460028201546144a491614ef5565b60028201556000600482015550565b600281015460048201546144c691614ef5565b60048201556000600282015550565b60048301546144e49082613f72565b600484015581835561365883614479565b8151602083015160009190828083600181111561451457614514615547565b03614520575083614580565b600183600181111561453457614534615547565b0361454a576145438686614f2c565b9050614580565b82826040517f7ebf97b40000000000000000000000000000000000000000000000000000000081526004016109fd929190615e1d565b60008660200151600181111561459857614598615547565b036145a7579250610adc915050565b6001866020015160018111156145bf576145bf615547565b0361454a576145e26145db670de0b6b3a7640000600019615b4c565b8290614f17565b9350505050610adc565b6000803090506000816001600160a01b0316639d888e866040518163ffffffff1660e01b8152600401606060405180830381865afa158015614632573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614656919061593d565b604001519050600061467c614677836146716130b989614fcb565b90614f17565b614fdf565b90506146ea836001600160a01b0316636c376cc56040518163ffffffff1660e01b8152600401602060405180830381865afa1580156146bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906146e39190615804565b8290614fea565b95945050505050565b604080518082019091526000808252602082015260408051808201909152825181906fffffffffffffffffffffffffffffffff1681526020848101519101906fffffffffffffffffffffffffffffffff166140b0565b6003810154600182015461475c91613913565b15614783576003810154600182015461477491614ef5565b60018201556000600382015550565b6001810154600382015461479691614ef5565b60038201556000600182015550565b60006001825160018111156147bc576147bc615547565b036147dc57610adc6147cd83614fff565b6001600160a01b03163b151590565b506040015161ffff19161590565b80518254839190829060ff19166001838181111561480a5761480a615547565b02179055506020820151815482907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff1661010083600181111561484f5761484f615547565b0217905550604090910151815460109190911c620100000261ffff90911617905550565b6000612da6838361506a565b60408051808201909152600080825260208201526000306001600160a01b031663597e1fb56040518163ffffffff1660e01b8152600401602060405180830381865afa1580156148d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148f791906157e7565b1561491957505060408051808201909152600080825260208201819052614b0b565b602085015161493f57505060408051808201909152600080825260208201819052614b0b565b845161496257505060408051808201909152600080825260208201819052614b0b565b6000846020015184602001516149789190615e43565b9050600061499461467787604001516146718a60200151614201565b905060006149ab6149a48961341e565b8390614fea565b90506000614a3b6149be6130b98661507a565b6040517f60ec91d600000000000000000000000000000000000000000000000000000000815230906360ec91d6906149fa908e90600401615747565b602060405180830381865afa158015614a17573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906146719190615804565b90506000614a52614a4b84614201565b8390614f17565b9050614a678b614a6183614fdf565b90614fea565b95506000614a8f614a778361508e565b614a8a89614a8486614fdf565b90614ef5565b6150ba565b9050600080614a9d8461508e565b129050614ac3614ab08d60000151614201565b82614abb5783614abd565b845b90613556565b8952614afe614adc670de0b6b3a7640000600019615b4c565b614671614aec8f60200151614201565b84614af75786614abd565b8590613556565b60208a0152505050505050505b94509492505050565b6040805180820190915260008082526020820152306001600160a01b031663597e1fb56040518163ffffffff1660e01b8152600401602060405180830381865afa158015614b66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614b8a91906157e7565b15614ba957506040805180820190915260008082526020820152612da6565b6020840151614bcc57506040805180820190915260008082526020820152612da6565b8351614bec57506040805180820190915260008082526020820152612da6565b6000614c098460400151846040015161426090919063ffffffff16565b90506000614c1d614a4b8760200151614201565b90506000614c30614a4b6130b98961341e565b9050614c59614c49670de0b6b3a7640000600019615b4c565b614671614abb8a60000151614201565b84526020870151614c6d906112b790614201565b60208501525050509392505050565b604080518082019091526000808252602082015260408051808201909152825184518291614caa9190614131565b81526020016142da8460200151866020015161413190919063ffffffff16565b6040805180820190915260008082526020820152600083602001518360200151614cf49190615e43565b855190915015614d1757614d126130b986600001516144108461507a565b614d1a565b60005b8252602085015115614d3f57614d3a6130b986602001516144108461507a565b614d42565b60005b6020830152509392505050565b60408051808201909152600080825260208201526040518060400160405280614d7b84600001516150f4565b600f0b8152602001614d9084602001516150f4565b600f0b905292915050565b6040805180820190915260008082526020820152600080614dbc85856151a1565b614dc95785600080614de0565b614dd386866133ef565b614ddd86866151bd565b60015b92509250925093509350939050565b60408051808201909152600080825260208201526040518060400160405280614e1b8460000151615305565b6fffffffffffffffffffffffffffffffff168152602001614e3f8460200151615305565b6fffffffffffffffffffffffffffffffff16905292915050565b604080518082019091526000808252602082015260408051808201909152825184518291614e879190614260565b81526020016142da8460200151866020015161426090919063ffffffff16565b60408051808201909152600080825260208201526040518060400160405280614edb84600001516146718760000151614201565b81526020016142da84602001516146718760200151614201565b6000612da68284615e43565b6000818310614f105781612da6565b5090919050565b6000670de0b6b3a764000061356b8385615b4c565b600080614fb583604051602401614f4591815260200190565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fd7c7a93500000000000000000000000000000000000000000000000000000000179052614fa686614fff565b6001600160a01b031690615355565b9050808060200190518101906112be9190615804565b6000610adc82600001518360200151614873565b6000610adc8261537a565b6000670de0b6b3a76400006143468385615dea565b600060018251600181111561501657615016615547565b1461505657815160408084015190517f4f5b470e0000000000000000000000000000000000000000000000000000000081526109fd929190600401615e5a565b506040015160101c6001600160a01b031690565b600081831015614f105781612da6565b6000610adc670de0b6b3a764000083615dea565b6000808213156150a057506001919050565b60008212156150b25750600019919050565b506000919050565b6000808313156150cd5761349a82614201565b60008312156150eb576150df82614201565b61349a90600019615b4c565b50600092915050565b6000816f7fffffffffffffffffffffffffffffff811315615144576040517f59aeb746000000000000000000000000000000000000000000000000000000008152600481018290526024016109fd565b7fffffffffffffffffffffffffffffffff80000000000000000000000000000000811215610adc576040517f4e02165d000000000000000000000000000000000000000000000000000000008152600481018290526024016109fd565b60006151ac83614442565b158015612da6575050905190511190565b6000806151db8460400151856020015161428c90919063ffffffff16565b90506000806151f861467786604001516146718660000151614201565b61521061467787604001516146718760200151614201565b9150915060003090506152fa615288826001600160a01b03166343f0179b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561525d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906152819190615804565b8490614fea565b6152f4836001600160a01b031663fc741c7c6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156152c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906152ed9190615804565b8690614fea565b90613f72565b979650505050505050565b6000816fffffffffffffffffffffffffffffffff811115610adc576040517f53851291000000000000000000000000000000000000000000000000000000008152600481018290526024016109fd565b6060612da68383604051806060016040528060258152602001615e9860259139615391565b60008082121561538d5781600003610adc565b5090565b60606001600160a01b0384163b615429576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f416464726573733a207374617469632063616c6c20746f206e6f6e2d636f6e7460448201527f726163740000000000000000000000000000000000000000000000000000000060648201526084016109fd565b600080856001600160a01b0316856040516154449190615e7b565b600060405180830381855afa9150503d806000811461547f576040519150601f19603f3d011682016040523d82523d6000602084013e615484565b606091505b509150915061549482828661549e565b9695505050505050565b606083156154ad575081612da6565b8251156154bd5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109fd9190615619565b604051806060016040528060008152602001615520604051806040016040528060008152602001600081525090565b8152602001615542604051806040016040528060008152602001600081525090565b905290565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b600281106111cf577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b815160608201906155bd81615576565b825260208301516155cd81615576565b8060208401525061ffff19604084015116604083015292915050565b60005b838110156156045781810151838201526020016155ec565b83811115615613576000848401525b50505050565b60208152600082518060208401526156388160408501602087016155e9565b601f01601f19169190910160400192915050565b60006080828403121561565e57600080fd5b50919050565b6001600160a01b03811681146111cf57600080fd5b60006020828403121561568b57600080fd5b8135612da681615664565b8151815260208083015180518284015290810151604083015260a082019050604083015180516060840152602081015160808401526141fa565b6000602082840312156156e257600080fd5b5035919050565b80151581146111cf57600080fd5b60006020828403121561570957600080fd5b8135612da6816156e9565b60006040828403121561565e57600080fd5b81518152602080830151908201526040808301519082015260608101610adc565b815181526020808301519082015260408101610adc565b60006020828403121561577057600080fd5b813567ffffffffffffffff81111561578757600080fd5b82016101e08185031215612da657600080fd5b600181811c908216806157ae57607f821691505b60208210810361565e577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000602082840312156157f957600080fd5b8151612da6816156e9565b60006020828403121561581657600080fd5b5051919050565b60006020828403121561582f57600080fd5b8151612da681615664565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516060810167ffffffffffffffff8111828210171561588c5761588c61583a565b60405290565b8035600f81900b81146158a457600080fd5b919050565b6000608082840312156158bb57600080fd5b6040516080810181811067ffffffffffffffff821117156158de576158de61583a565b6040526158ea83615892565b81526158f860208401615892565b602082015261590960408401615892565b604082015260608301356fffffffffffffffffffffffffffffffff8116811461593157600080fd5b60608201529392505050565b60006060828403121561594f57600080fd5b615957615869565b8251815260208301516020820152604083015160408201528091505092915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126159ae57600080fd5b83018035915067ffffffffffffffff8211156159c957600080fd5b6020019150368190038213156159de57600080fd5b9250929050565b601f82111561365857600081815260208120601f850160051c81016020861015615a0c5750805b601f850160051c820191505b81811015613d1957828155600101615a18565b67ffffffffffffffff831115615a4357615a4361583a565b615a5783615a51835461579a565b836159e5565b6000601f841160018114615a8b5760008515615a735750838201355b600019600387901b1c1916600186901b178355615ae5565b600083815260209020601f19861690835b82811015615abc5786850135825560209485019460019092019101615a9c565b5086821015615ad95760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b6001600160a01b038316815260808101612da660208301848051825260208082015190830152604090810151910152565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600084136000841385830485118282161615615b8d57615b8d615b1d565b7f80000000000000000000000000000000000000000000000000000000000000006000871286820588128184161615615bc857615bc8615b1d565b60008712925087820587128484161615615be457615be4615b1d565b87850587128184161615615bfa57615bfa615b1d565b505050929093029392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600082615c4657615c46615c08565b60001983147f800000000000000000000000000000000000000000000000000000000000000083141615615c7c57615c7c615b1d565b500590565b600281106111cf57600080fd5b600060608284031215615ca057600080fd5b615ca8615869565b8235615cb381615c81565b81526020830135615cc381615c81565b6020820152604083013561ffff1981168114615cde57600080fd5b60408201529392505050565b60008219821115615cfd57615cfd615b1d565b500190565b6000808212827f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03841381151615615d3c57615d3c615b1d565b827f8000000000000000000000000000000000000000000000000000000000000000038412811615615d7057615d70615b1d565b50500190565b6000808312837f800000000000000000000000000000000000000000000000000000000000000001831281151615615db057615db0615b1d565b837f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff018313811615615de457615de4615b1d565b50500390565b6000816000190483118215151615615e0457615e04615b1d565b500290565b600082615e1857615e18615c08565b500490565b60408101615e2a84615576565b838252615e3683615576565b8260208301529392505050565b600082821015615e5557615e55615b1d565b500390565b60408101615e6784615576565b92815261ffff199190911660209091015290565b60008251615e8d8184602087016155e9565b919091019291505056fe416464726573733a206c6f772d6c6576656c207374617469632063616c6c206661696c6564a2646970667358221220c8f28337b68a0a25a9b849842eef3dea5522fe30a7a3178bfe70c89801c2062264736f6c634300080f0033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106102de5760003560e01c806373b88f3b11610186578063a12e1b33116100e3578063e1c3c98d11610097578063f6b3200811610071578063f6b3200814610692578063f77c4791146106a5578063fc741c7c146106ad57600080fd5b8063e1c3c98d14610659578063f0b409591461066c578063f667f8971461067f57600080fd5b8063b7648fb9116100c8578063b7648fb9146105e9578063c07f47d41461063e578063d7d7d6b81461064657600080fd5b8063a12e1b331461057b578063ab582f29146105d657600080fd5b80638e480b201161013a57806395d89b411161011f57806395d89b411461054b5780639a427d03146105535780639d888e861461057357600080fd5b80638e480b201461050f578063916890241461053857600080fd5b80637dc0d1d01161016b5780637dc0d1d0146104bc5780637ece075d146104dc5780638c94b48f146104fc57600080fd5b806373b88f3b1461049657806376f37001146104a957600080fd5b8063476fa96d1161023f57806359ea287d116101f3578063611c71b4116101cd578063611c71b4146104685780636943b0171461047b5780636c376cc51461048e57600080fd5b806359ea287d146104455780635d16e1201461044d57806360ec91d61461045557600080fd5b806358ca6f981161022457806358ca6f98146103eb57806359218fe91461042a578063597e1fb51461043d57600080fd5b8063476fa96d146103c557806356bc1ad4146103d857600080fd5b80631e0c6fb911610296578063212e0ad31161027b578063212e0ad3146103975780633e17b8c7146103aa57806343f0179b146103bd57600080fd5b80631e0c6fb91461034957806320fe9c3c1461036957600080fd5b806311da60b4116102c757806311da60b414610316578063153261e514610320578063193775671461033357600080fd5b806305d5c1cb146102e357806306fdde0314610301575b600080fd5b6102eb6106b5565b6040516102f891906155ad565b60405180910390f35b610309610708565b6040516102f89190615619565b61031e610796565b005b61031e61032e36600461564c565b6108ea565b61033b610a21565b6040519081526020016102f8565b61035c610357366004615679565b610a4b565b6040516102f89190615696565b61037c6103773660046156d0565b610abd565b604080518251815260209283015192810192909252016102f8565b61031e6103a53660046156f7565b610ae2565b61031e6103b83660046156d0565b610c6d565b61033b610d8d565b61037c6103d33660046156d0565b610db7565b61031e6103e63660046156d0565b610dd6565b61041a6103f9366004615679565b6001600160a01b031660009081526002602052604090206007015460ff1690565b60405190151581526020016102f8565b61031e6104383660046156d0565b610ef6565b61041a6111d2565b61035c6111fc565b61033b611253565b61033b610463366004615714565b61127d565b61031e6104763660046156d0565b6112c6565b61041a610489366004615679565b6113e6565b61033b611485565b61031e6104a43660046156d0565b6114af565b61031e6104b73660046156d0565b611863565b6104c4611a45565b6040516001600160a01b0390911681526020016102f8565b6104ef6104ea3660046156d0565b611a6f565b6040516102f89190615726565b61031e61050a3660046156d0565b611b11565b61033b61051d366004615679565b6001600160a01b031660009081526009602052604090205490565b61033b610546366004615679565b611c31565b610309611c52565b6105666105613660046156d0565b611c5f565b6040516102f89190615747565b6104ef611c7e565b610583611cea565b6040516102f8919060006080820190508251600f0b82526020830151600f0b60208301526040830151600f0b60408301526fffffffffffffffffffffffffffffffff606084015116606083015292915050565b61033b6105e4366004615679565b611db7565b6105666105f7366004615679565b6040805180820190915260008082526020820152506001600160a01b0316600090815260026020908152604091829020825180840190935280548352600101549082015290565b600a5461033b565b61031e6106543660046156d0565b611dd8565b61031e6106673660046156d0565b61229c565b61031e61067a36600461575e565b6123bc565b61031e61068d366004615679565b612562565b61031e6106a0366004615679565b6126c5565b6104c4612884565b61033b6128ae565b6106da6040805160608101909152806000815260200160008152600060209091015290565b6107037f630ac9ad193fa8d8f5a7207eefdee35934d664003a3d4c286a591e065a62034e6128d8565b905090565b600080546107159061579a565b80601f01602080910402602001604051908101604052809291908181526020018280546107419061579a565b801561078e5780601f106107635761010080835404028352916020019161078e565b820191906000526020600020905b81548152906001019060200180831161077157829003601f168201915b505050505081565b60026107c07f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b036107f7576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755610823612884565b6001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610860573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061088491906157e7565b156108bb576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6108c3612985565b5060017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755565b60006108f4612884565b604051633e92a73360e11b81523060048201526001600160a01b039190911690637d254e6690602401602060405180830381865afa15801561093a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061095e9190615804565b905033610969612884565b6001600160a01b031663a123c33e836040518263ffffffff1660e01b815260040161099691815260200190565b602060405180830381865afa1580156109b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d7919061581d565b6001600160a01b031614610a065760405163123d8bcf60e21b8152600481018290526024015b60405180910390fd5b610a1d610a18368490038401846158a9565b612c51565b5050565b60006107037f897858f7b7d3c8b4e7a700b401ad192a110353a60c809946583c0d62cda7f0b75490565b610a536154f1565b506001600160a01b031660009081526002602081815260409283902083516060810185529281015483528351808501855260038201548152600482015481840152838301528351808501855260058201548152600690910154918101919091529181019190915290565b6040805180820190915260008082526020820152610adc600a83612d4e565b92915050565b6000610aec612884565b604051633e92a73360e11b81523060048201526001600160a01b039190911690637d254e6690602401602060405180830381865afa158015610b32573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b569190615804565b905033610b61612884565b6001600160a01b031663a123c33e836040518263ffffffff1660e01b8152600401610b8e91815260200190565b602060405180830381865afa158015610bab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bcf919061581d565b6001600160a01b031614610bf95760405163123d8bcf60e21b8152600481018290526024016109fd565b6000610c03612985565b9050610c2e7fbdea2cc426745068386b3804e5b401ae87ffbae9dbf293944b5307f507040c79849055565b8051604051908152831515907f482763b305ee10cd21c16c0cbeed259f2e4fcacdc9767cef16dc1fbe483d3488906020015b60405180910390a2505050565b6000610c77612884565b604051633e92a73360e11b81523060048201526001600160a01b039190911690637d254e6690602401602060405180830381865afa158015610cbd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ce19190615804565b905033610cec612884565b6001600160a01b031663a123c33e836040518263ffffffff1660e01b8152600401610d1991815260200190565b602060405180830381865afa158015610d36573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d5a919061581d565b6001600160a01b031614610d845760405163123d8bcf60e21b8152600481018290526024016109fd565b610a1d82612dad565b60006107037f1d7cfd39841edd73967db6350efae442ebd8c6e1bfca55faa52b046d39b7e4935490565b6040805180820190915260008082526020820152610adc600a83612e4f565b6000610de0612884565b604051633e92a73360e11b81523060048201526001600160a01b039190911690637d254e6690602401602060405180830381865afa158015610e26573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e4a9190615804565b905033610e55612884565b6001600160a01b031663a123c33e836040518263ffffffff1660e01b8152600401610e8291815260200190565b602060405180830381865afa158015610e9f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ec3919061581d565b6001600160a01b031614610eed5760405163123d8bcf60e21b8152600481018290526024016109fd565b610a1d82612ea7565b6002610f207f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03610f57576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755610f83612884565b6001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fc0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fe491906157e7565b1561101b576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336000611026612985565b90506110328282612f00565b3360009081526002602052604090206007015460ff161561107f576040517f6830d4d700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61108933846132fe565b3360009081526002602052604090206110a190613380565b156110d8576040517f3975ab9300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6110e06111d2565b6111a65760408051606081018252600454815281518083018352600554815260065460208281019190915280830191909152825180840184526007548152600854918101919091529181019190915260009061114890611142610561600a5490565b906133ef565b905060006111558261341e565b905061116981670de0b6b3a7640000613467565b156111a3576040517fd8b8b951000000000000000000000000000000000000000000000000000000008152600481018290526024016109fd565b50505b505060017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75550565b50565b60006107037fbdea2cc426745068386b3804e5b401ae87ffbae9dbf293944b5307f507040c795490565b6112046154f1565b5060408051606081018252600454815281518083018352600554815260065460208281019190915280830191909152825180840184526007548152600854918101919091529181019190915290565b60006107037face7e947336f94057b47a9ab5531b0363e85c8d36c05c7d915ec8e525fd159d85490565b60008061128f6020840135843561347b565b905060006112a58261129f611cea565b906134ab565b90506112be6112b76301e13380613542565b8290613556565b949350505050565b60006112d0612884565b604051633e92a73360e11b81523060048201526001600160a01b039190911690637d254e6690602401602060405180830381865afa158015611316573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061133a9190615804565b905033611345612884565b6001600160a01b031663a123c33e836040518263ffffffff1660e01b815260040161137291815260200190565b602060405180830381865afa15801561138f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b3919061581d565b6001600160a01b0316146113dd5760405163123d8bcf60e21b8152600481018290526024016109fd565b610a1d82613575565b6001600160a01b0381166000908152600260208181526040808420815160a0810183528154606080830191825260018401546080840152908252835190810184529482015485528251808401845260038301548152600483015481860152858501528251808401845260058301548152600683015481860152858401529283019390935260079092015460ff16151591810191909152610adc90613617565b60006107037f968cf792ff9a89745e4746179e93a7b9d7f08b0ff8366fd6f6dbd524ef1074645490565b60026114d97f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03611510576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75561153c612884565b6001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611579573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061159d91906157e7565b156115d4576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6115dc6111d2565b15611613576040517fded15dbf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b33600061161e612985565b905061162a8282612f00565b3360009081526002602052604090206007015460ff1615611677576040517f6830d4d700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611682600a5490565b3360009081526002602081905260409091209192506116a391018286613638565b6116af60048286613638565b604080518281526020810186905233917fb9726781b72c53f23217f424d70445b222951f008aeac7eece8139caed71ed2d910160405180910390a2506116f3612884565b6001600160a01b031663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa158015611730573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611754919061581d565b6040517fe41191800000000000000000000000000000000000000000000000000000000081523360048201523060248201526001600160a01b03919091169063e411918090604401602060405180830381865afa1580156117b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117dd91906157e7565b15611814576040517f24a21d2900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b33600090815260026020526040902061182c9061365d565b156110d8576040517f90898fd100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600261188d7f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b036118c4576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7556118f0612884565b6001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561192d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061195191906157e7565b15611988576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336000611993612985565b905061199f8282612f00565b3360009081526002602052604090206007015460ff16156119ec576040517f6830d4d700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6119f633846136bc565b336000908152600260205260409020611a0e90613380565b156111a6576040517f3975ab9300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006107037f6c0d5e3cd81753b1b21f67f61d56a97aae7a3e0179486d114788ad4576f532665490565b611a9360405180606001604052806000815260200160008152602001600081525090565b610adc611a9e611a45565b6001600160a01b0316637ece075d846040518263ffffffff1660e01b8152600401611acb91815260200190565b606060405180830381865afa158015611ae8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b0c919061593d565b61373e565b6000611b1b612884565b604051633e92a73360e11b81523060048201526001600160a01b039190911690637d254e6690602401602060405180830381865afa158015611b61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b859190615804565b905033611b90612884565b6001600160a01b031663a123c33e836040518263ffffffff1660e01b8152600401611bbd91815260200190565b602060405180830381865afa158015611bda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bfe919061581d565b6001600160a01b031614611c285760405163123d8bcf60e21b8152600481018290526024016109fd565b610a1d82613781565b6001600160a01b0381166000908152600260205260408120610adc906137da565b600180546107159061579a565b6040805180820190915260008082526020820152610adc600383613813565b611ca260405180606001604052806000815260200160008152602001600081525090565b610703611cad611a45565b6001600160a01b0316639d888e866040518163ffffffff1660e01b8152600401606060405180830381865afa158015611ae8573d6000803e3d6000fd5b6040805160808101825260008082526020820181905291810182905260608101919091526107037f917d72d9b73e141a5f0eff6b5933a24665154df6903ed198d591afc8ac62f8f660408051608081018252600080825260208201819052918101829052606081019190915281604080516080810182528254600f81810b835270010000000000000000000000000000000091829004810b60208401526001909401549384900b9282019290925291046fffffffffffffffffffffffffffffffff16606082015292915050565b6001600160a01b0381166000908152600260205260408120610adc90613879565b6002611e027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b03611e39576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755611e65612884565b6001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ea2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ec691906157e7565b15611efd576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611f056111d2565b15611f3c576040517fded15dbf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336000611f47612985565b9050611f538282612f00565b600a54600003611f8f576040517fc25d67ab00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3360009081526002602052604090206007015460ff1615611fdc576040517f6830d4d700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611fe7600a5490565b336000908152600260208190526040909120919250612008910182866138f3565b612014600482866138f3565b604080518281526020810186905233917ff98b31465ac12e92b5cb136ade913276c267463c4395bb1a3999bc88fb837806910160405180910390a250612058612884565b6001600160a01b031663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa158015612095573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120b9919061581d565b6040517fe41191800000000000000000000000000000000000000000000000000000000081523360048201523060248201526001600160a01b03919091169063e411918090604401602060405180830381865afa15801561211e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061214291906157e7565b15612179576040517f24a21d2900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3360009081526002602052604090206121919061365d565b156121c8576040517f90898fd100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60408051606081018252600454815281518083018352600554815260065460208281019190915280830191909152825180840184526007548152600854918101919091529181019190915260009061222690611142610561600a5490565b905061223b612233610a21565b825190613913565b15612272576040517fcefd0e5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505060017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7555050565b60006122a6612884565b604051633e92a73360e11b81523060048201526001600160a01b039190911690637d254e6690602401602060405180830381865afa1580156122ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123109190615804565b90503361231b612884565b6001600160a01b031663a123c33e836040518263ffffffff1660e01b815260040161234891815260200190565b602060405180830381865afa158015612365573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612389919061581d565b6001600160a01b0316146123b35760405163123d8bcf60e21b8152600481018290526024016109fd565b610a1d82613929565b6001806123e77f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b5490565b10612421576040517f1e7a9d95000000000000000000000000000000000000000000000000000000008152600481018290526024016109fd565b61244a7f5db5abc19987c2b3729df7961b62b6bb0bae886dd47e3ce25bb3a3af34c6d80b829055565b60017fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c55612477336139cb565b61249361248a60c0840160a08501615679565b83604001613a9b565b61249b613bf1565b6124d260c083013560e08401356101008501356101208601356101408701356124cd3689900389016101608a016158a9565b613c7d565b6124dc8280615979565b6000916124ea919083615a2b565b506124f86020830183615979565b600191612506919083615a2b565b5060007fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c556040518181527fbe9b076dc5b65990cca9dd9d7366682482e7817a6f6bc7f4faf4dc32af497f329060200160405180910390a15050565b600261258c7f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75490565b036125c3576040517ff320323600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60027f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d7556125ef612884565b6001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561262c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061265091906157e7565b15612687576040517feced32bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000612691612985565b905061269d8282612f00565b5060017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d75550565b6126cd612884565b6001600160a01b031663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa15801561270a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061272e919061581d565b6001600160a01b0316336001600160a01b031614612778576040517f40cbe9b100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6127806111d2565b156127b7576040517fded15dbf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060006127c2612985565b90506127ce8282612f00565b6001600160a01b0383166000908152600260208181526040808420815160608101835293810154845281518083018352600382015481526004820154818501528484015281518083018352600582015481526006820154818501528483015281518083019092528054825260018101549282019290925290929161285291906133ef565b90506128628582600001516132fe565b6128708582602001516136bc565b50600701805460ff19166001179055505050565b60006107037f0e555410d8128dff796eab5d29b97dd593ce9cab44a71b64c08244579ea605335490565b60006107037f5a294f9055e9dc7a18078b4e0139086766d723c3cd728bd59cc1f3b589741ed25490565b6128fd6040805160608101909152806000815260200160008152600060209091015290565b604080516060810190915282548390829060ff16600181111561292257612922615547565b600181111561293357612933615547565b81528154602090910190610100900460ff16600181111561295657612956615547565b600181111561296757612967615547565b8152905462010000900460101b61ffff191660209091015292915050565b6129a960405180606001604052806000815260200160008152602001600081525090565b60006129b3612884565b90506129bd613d21565b915060006129ca600a5490565b835190915081036129da57505090565b60006129e582611a6f565b84519091506000906129f990600490613d8f565b9050600085600001518214612a1657612a1182611a6f565b612a18565b855b9050846001600160a01b0316636fc6407c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a58573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a7c919061581d565b6001600160a01b031663a55ff01d876040518263ffffffff1660e01b8152600401612aa79190615726565b600060405180830381600087803b158015612ac157600080fd5b505af1158015612ad5573d6000803e3d6000fd5b505050506000612ae3613db2565b90506000612b00612af9600a8460038988613e2e565b8290613f72565b9050612b11612af960038886613f7e565b8851845191925014612b4357612b2f612af9600a846003878d613e2e565b8351909150612b41906003908a613f7e565b505b866001600160a01b031663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ba5919061581d565b6001600160a01b0316637f3dd53b826040518263ffffffff1660e01b8152600401612bd291815260200190565b600060405180830381600087803b158015612bec57600080fd5b505af1158015612c00573d6000803e3d6000fd5b505084518a516040517f88a84ea6dd274b386afd27dbbe11b6192b25017f5e60bb8c4053dfddb45c294d9450612c3f9350918252602082015260400190565b60405180910390a15050505050505090565b805160208201516fffffffffffffffffffffffffffffffff9182167001000000000000000000000000000000009183168202177f917d72d9b73e141a5f0eff6b5933a24665154df6903ed198d591afc8ac62f8f65560408301516060840151908316921602177f917d72d9b73e141a5f0eff6b5933a24665154df6903ed198d591afc8ac62f8f75580517f0887cb99bfd5017bb9e8282cc29d17176a4f1e542f869a03a5617919fb74620b90600f0b6020830151600f0b6040840151600f0b60608501516fffffffffffffffffffffffffffffffff166040805194855260208501939093529183015260608201526080015b60405180910390a150565b6040805180820182526000808252602080830182905284825260018601815290839020835180850190945254600f81810b8552700100000000000000000000000000000000909104900b9083015290612da69061407c565b9392505050565b612dbf81670de0b6b3a7640000613913565b15612df6576040517fccbac87e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612e1f7f5a294f9055e9dc7a18078b4e0139086766d723c3cd728bd59cc1f3b589741ed2829055565b6040518181527f3ffba897342f8382491dd8984c684cc237d3c045298d4cec8ad0fd7262aa91f190602001612d43565b6040805180820182526000808252602080830182905284825260028601815290839020835180850190945254600f81810b8552700100000000000000000000000000000000909104900b9083015290612da69061407c565b612ed07f968cf792ff9a89745e4746179e93a7b9d7f08b0ff8366fd6f6dbd524ef107464829055565b6040518181527f5339371c8d31c4fb29fd4ad6b3bf89793839a3dfae45035ef23a635916dafc6590602001612d43565b6000612f0a612884565b8251909150612f2e846001600160a01b031660009081526009602052604090205490565b03612f3857505050565b81516001600160a01b038416600090815260026020819052604082209192612f639290910190613d8f565b9050600083600001518214612f8057612f7b82611a6f565b612f82565b835b90506000836001600160a01b0316636fc6407c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612fc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fe8919061581d565b6001600160a01b0316631830349c87846040518363ffffffff1660e01b8152600401613015929190615aec565b600060405180830381600087803b15801561302f57600080fd5b505af1158015613043573d6000803e3d6000fd5b5050506001600160a01b038716600090815260026020908152604080832086516009909352922061308c93506130859261308092600a91906140b8565b614121565b8290614131565b6001600160a01b03871660009081526002602052604090209091506130c5906130be906130b9908561413d565b614201565b8290614260565b85518351919250146131ce57836001600160a01b0316636fc6407c6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561310f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613133919061581d565b6001600160a01b0316631830349c87876040518363ffffffff1660e01b8152600401613160929190615aec565b600060405180830381600087803b15801561317a57600080fd5b505af115801561318e573d6000803e3d6000fd5b5050506001600160a01b03871660009081526002602090815260408083208951600990935292206131cb93506130859261308092600a91906140b8565b90505b836001600160a01b031663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa15801561320c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613230919061581d565b6040517fc9cb48de0000000000000000000000000000000000000000000000000000000081526001600160a01b03888116600483015260248201849052919091169063c9cb48de90604401600060405180830381600087803b15801561329557600080fd5b505af11580156132a9573d6000803e3d6000fd5b5050835187516040805192835260208301919091526001600160a01b038a1693507f9d7055d24918d8c2fd08660a27bf31d4086fa71a51cd07874276470223aa480f92500160405180910390a2505050505050565b6000613309600a5490565b6001600160a01b03841660009081526002602081905260409091209192506133339101828461426c565b61333f6004828461426c565b60408051828152602081018490526001600160a01b038516917f39854479080fac0b5e7c0ecedb0fb02308a72a43cd102c6b9f918653d34003679101610c60565b60408051808201825260038301548152600483015460208083019190915282518084019093528354835260018401549083015260009182916133c2919061428c565b805160058501549192506133d69190613913565b80612da6575060208101516006840154612da691613913565b6040805180820190915260008082526020820152612da661341484846020015161428c565b83604001516142e3565b600061342c82602001511590565b613458576020820151825161345391670de0b6b3a76400009161344e91614331565b614350565b610adc565b670de0b6b3a764000092915050565b6000613473838361435c565b159392505050565b6000816134a15782156134905760001961349a565b670de0b6b3a76400005b9050610adc565b61349a8383614331565b60608201516000906fffffffffffffffffffffffffffffffff166134cf8382613467565b156134f95783516134f190600090600f0b60408701518490600f0b5b87614391565b915050610adc565b61350b83670de0b6b3a7640000613467565b156135355760408401516134f1908290600f0b6020870151670de0b6b3a764000090600f0b6134eb565b50505060200151600f0b90565b6000610adc670de0b6b3a764000083615b4c565b60008161356b670de0b6b3a764000085615b4c565b612da69190615c37565b61358781670de0b6b3a7640000613913565b156135be576040517f4589bde600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6135e77f1d7cfd39841edd73967db6350efae442ebd8c6e1bfca55faa52b046d39b7e493829055565b6040518181527f587b2c669227029fa59d08b2061678cdf5536e8709f7760940e5cf5f24336e4690602001612d43565b60006136268260200151614442565b8015610adc57508151610adc90614461565b60028301546136479082613f72565b600284015581835561365883614479565b505050565b8054600090819015801561367357506003830154155b801561368157506005830154155b600184015490915060009015801561369b57506004840154155b80156136a957506006840154155b9050811580156112be5750159392505050565b60006136c7600a5490565b6001600160a01b03841660009081526002602081905260409091209192506136f1910182846144d5565b6136fd600482846144d5565b60408051828152602081018490526001600160a01b038516917f63625b85818a29587ee919ee6a968ee0b32f3513f2884b3968001062ba49eb6b9101610c60565b61376260405180606001604052806000815260200160008152602001600081525090565b61377882604001516137726106b5565b906144f5565b60408301525090565b6137aa7f897858f7b7d3c8b4e7a700b401ad192a110353a60c809946583c0d62cda7f0b7829055565b6040518181527ff6bebbfbe342f87db90e223fb3dd70b26b082ed4266f1673b509dfeca0a7697a90602001612d43565b600781015460009060ff16156137f257506000919050565b604080518082019091528254815260018301546020820152610adc906145ec565b6040805180820190915260008082526020820152600082815260208481526040918290208251808401909352546fffffffffffffffffffffffffffffffff80821684527001000000000000000000000000000000009091041690820152612da6906146f3565b60408051606081018252600283015481528151808301835260038401548152600484015460208281019190915280830191909152825180840184526005850154815260068501548183015282840152825180840190935283548352600184015490830152600091610adc916138ee91906133ef565b6145ec565b60018301546139029082613f72565b600184015581835561365883614749565b600061391f838361435c565b6002149392505050565b61393b81670de0b6b3a7640000613913565b15613972576040517f82894f6b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61399b7face7e947336f94057b47a9ab5531b0363e85c8d36c05c7d915ec8e525fd159d8829055565b6040518181527ffb8fb3fd721f9e0d7396f8475680125318fb14fffa561a1ab43dfa329f2fd98a90602001612d43565b303b151580156139fa57507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b15613a31576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0381163b613a72576040517f14878b6900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6111cf7f0e555410d8128dff796eab5d29b97dd593ce9cab44a71b64c08244579ea60533829055565b303b15158015613aca57507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b15613b01576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0382163b613b42576040517fd26af10d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b613b6b7f6c0d5e3cd81753b1b21f67f61d56a97aae7a3e0179486d114788ad4576f53266839055565b613b82613b7d36839003830183615c8e565b6147a5565b613bb8576040517f9a51fe8f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610a1d613bca36839003830183615c8e565b7f630ac9ad193fa8d8f5a7207eefdee35934d664003a3d4c286a591e065a62034e906147ea565b303b15158015613c2057507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b15613c57576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60017f1b30fe15febd596dffd21d4da0657732eea42b4b5a9789e3e6daab3d570999d755565b303b15158015613cac57507fad57d7911b7e3d6c3c79a68ba909a7f4ba41f9485e5207b12dee0d0c6af5398c54155b15613ce3576040517f689f12a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b613cec86612ea7565b613cf585613929565b613cfe84612dad565b613d0783613575565b613d1082613781565b613d1981612c51565b505050505050565b613d4560405180606001604052806000815260200160008152602001600081525090565b610703613d50611a45565b6001600160a01b031663fff6cae96040518163ffffffff1660e01b81526004016060604051808303816000875af1158015611ae8573d6000803e3d6000fd5b81546000908015613daa57613da5816001615cea565b6112be565b509092915050565b6000610703613dbf612884565b6001600160a01b031663e975c0c36040518163ffffffff1660e01b8152600401602060405180830381865afa158015613dfc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e209190615804565b613e28611253565b90614873565b81516000908190613e40908690613813565b9050613e5f604051806040016040528060008152602001600081525090565b613e6b8783878761487f565b93509050613e84613e7d838787614b14565b8290614c7c565b90506000613e93838787614cca565b9050613eb5613eb083613eaa8c8a60000151612d4e565b90614c7c565b614d4f565b8551600090815260018b0160209081526040909120825192909101516fffffffffffffffffffffffffffffffff9081167001000000000000000000000000000000000292169190911790558551613f1790613eb0908390613eaa908d90612e4f565b8551600090815260028b0160209081526040909120825192909101516fffffffffffffffffffffffffffffffff9081167001000000000000000000000000000000000292169190911790555050915190955550929392505050565b6000612da68284615cea565b60408051606081018252600185015481528151808301835260028601548152600386015460208281019190915280830191909152825180840184526004870154815260058701549181019190915291810191909152600090819081908190613ff29086613feb8a8a613813565b9190614d9b565b92509250925061400183614def565b8551600090815260208981526040909120825192909101516fffffffffffffffffffffffffffffffff90811670010000000000000000000000000000000002921691909117905580156140725760006001880181905560028801819055600388018190556004880181905560058801555b5095945050505050565b60408051808201909152600080825260208201526040805180820190915282518190600f0b8152602084810151910190600f0b5b905292915050565b604080518082019091526000808252602082015284546000906140f0906140e0908790612d4e565b6140ea8786612d4e565b90614e59565b6040805180820190915285548152600186015460208201529091506141159082614ea7565b92909555509392505050565b60208101518151600091610adc91905b6000612da68284615d02565b6040805160608101825260028401548152815180830183526003850154815260048501546020828101919091528083019190915282518084018452600586015481526006860154818301528284015282518084019093528454835260018501549083015260009182916141b1919085614d9b565b8251875560209092015160018701559250905080156141fa57600060028501819055600385018190556004850181905560058501819055600685015560078401805460ff191690555b5092915050565b6000817f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811115610adc576040517ea07eb5000000000000000000000000000000000000000000000000000000008152600481018290526024016109fd565b6000612da68284615d76565b600383015461427b9082613f72565b600384015581835561365883614749565b6040805180820190915260008082526020820152604080518082019091528251845182916142ba9190613f72565b81526020016142da84602001518660200151613f7290919063ffffffff16565b90529392505050565b6040805180820190915260008082526020820152604080518082019091528251845182916143119190614ef5565b81526020016142da84602001518660200151614ef590919063ffffffff16565b600081614346670de0b6b3a764000085615dea565b612da69190615e09565b6000612da68383614f01565b600082828082111561437357600292505050610adc565b8082101561438657600092505050610adc565b506001949350505050565b600061439d8287613467565b806143ad57506143ad8285613913565b156143e4576040517f0db0f7cb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006143f08588614ef5565b905060006143fe8588614260565b9050600061441683614410878c614ef5565b90614331565b90506144358861442f61442884614201565b8590614f17565b90614131565b9998505050505050505050565b60006144518260200151614461565b8015610adc5750610adc82604001515b8051600090158015610adc5750602082015115610adc565b6004810154600282015461448c91613913565b156144b357600481015460028201546144a491614ef5565b60028201556000600482015550565b600281015460048201546144c691614ef5565b60048201556000600282015550565b60048301546144e49082613f72565b600484015581835561365883614479565b8151602083015160009190828083600181111561451457614514615547565b03614520575083614580565b600183600181111561453457614534615547565b0361454a576145438686614f2c565b9050614580565b82826040517f7ebf97b40000000000000000000000000000000000000000000000000000000081526004016109fd929190615e1d565b60008660200151600181111561459857614598615547565b036145a7579250610adc915050565b6001866020015160018111156145bf576145bf615547565b0361454a576145e26145db670de0b6b3a7640000600019615b4c565b8290614f17565b9350505050610adc565b6000803090506000816001600160a01b0316639d888e866040518163ffffffff1660e01b8152600401606060405180830381865afa158015614632573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614656919061593d565b604001519050600061467c614677836146716130b989614fcb565b90614f17565b614fdf565b90506146ea836001600160a01b0316636c376cc56040518163ffffffff1660e01b8152600401602060405180830381865afa1580156146bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906146e39190615804565b8290614fea565b95945050505050565b604080518082019091526000808252602082015260408051808201909152825181906fffffffffffffffffffffffffffffffff1681526020848101519101906fffffffffffffffffffffffffffffffff166140b0565b6003810154600182015461475c91613913565b15614783576003810154600182015461477491614ef5565b60018201556000600382015550565b6001810154600382015461479691614ef5565b60038201556000600182015550565b60006001825160018111156147bc576147bc615547565b036147dc57610adc6147cd83614fff565b6001600160a01b03163b151590565b506040015161ffff19161590565b80518254839190829060ff19166001838181111561480a5761480a615547565b02179055506020820151815482907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff1661010083600181111561484f5761484f615547565b0217905550604090910151815460109190911c620100000261ffff90911617905550565b6000612da6838361506a565b60408051808201909152600080825260208201526000306001600160a01b031663597e1fb56040518163ffffffff1660e01b8152600401602060405180830381865afa1580156148d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148f791906157e7565b1561491957505060408051808201909152600080825260208201819052614b0b565b602085015161493f57505060408051808201909152600080825260208201819052614b0b565b845161496257505060408051808201909152600080825260208201819052614b0b565b6000846020015184602001516149789190615e43565b9050600061499461467787604001516146718a60200151614201565b905060006149ab6149a48961341e565b8390614fea565b90506000614a3b6149be6130b98661507a565b6040517f60ec91d600000000000000000000000000000000000000000000000000000000815230906360ec91d6906149fa908e90600401615747565b602060405180830381865afa158015614a17573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906146719190615804565b90506000614a52614a4b84614201565b8390614f17565b9050614a678b614a6183614fdf565b90614fea565b95506000614a8f614a778361508e565b614a8a89614a8486614fdf565b90614ef5565b6150ba565b9050600080614a9d8461508e565b129050614ac3614ab08d60000151614201565b82614abb5783614abd565b845b90613556565b8952614afe614adc670de0b6b3a7640000600019615b4c565b614671614aec8f60200151614201565b84614af75786614abd565b8590613556565b60208a0152505050505050505b94509492505050565b6040805180820190915260008082526020820152306001600160a01b031663597e1fb56040518163ffffffff1660e01b8152600401602060405180830381865afa158015614b66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614b8a91906157e7565b15614ba957506040805180820190915260008082526020820152612da6565b6020840151614bcc57506040805180820190915260008082526020820152612da6565b8351614bec57506040805180820190915260008082526020820152612da6565b6000614c098460400151846040015161426090919063ffffffff16565b90506000614c1d614a4b8760200151614201565b90506000614c30614a4b6130b98961341e565b9050614c59614c49670de0b6b3a7640000600019615b4c565b614671614abb8a60000151614201565b84526020870151614c6d906112b790614201565b60208501525050509392505050565b604080518082019091526000808252602082015260408051808201909152825184518291614caa9190614131565b81526020016142da8460200151866020015161413190919063ffffffff16565b6040805180820190915260008082526020820152600083602001518360200151614cf49190615e43565b855190915015614d1757614d126130b986600001516144108461507a565b614d1a565b60005b8252602085015115614d3f57614d3a6130b986602001516144108461507a565b614d42565b60005b6020830152509392505050565b60408051808201909152600080825260208201526040518060400160405280614d7b84600001516150f4565b600f0b8152602001614d9084602001516150f4565b600f0b905292915050565b6040805180820190915260008082526020820152600080614dbc85856151a1565b614dc95785600080614de0565b614dd386866133ef565b614ddd86866151bd565b60015b92509250925093509350939050565b60408051808201909152600080825260208201526040518060400160405280614e1b8460000151615305565b6fffffffffffffffffffffffffffffffff168152602001614e3f8460200151615305565b6fffffffffffffffffffffffffffffffff16905292915050565b604080518082019091526000808252602082015260408051808201909152825184518291614e879190614260565b81526020016142da8460200151866020015161426090919063ffffffff16565b60408051808201909152600080825260208201526040518060400160405280614edb84600001516146718760000151614201565b81526020016142da84602001516146718760200151614201565b6000612da68284615e43565b6000818310614f105781612da6565b5090919050565b6000670de0b6b3a764000061356b8385615b4c565b600080614fb583604051602401614f4591815260200190565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fd7c7a93500000000000000000000000000000000000000000000000000000000179052614fa686614fff565b6001600160a01b031690615355565b9050808060200190518101906112be9190615804565b6000610adc82600001518360200151614873565b6000610adc8261537a565b6000670de0b6b3a76400006143468385615dea565b600060018251600181111561501657615016615547565b1461505657815160408084015190517f4f5b470e0000000000000000000000000000000000000000000000000000000081526109fd929190600401615e5a565b506040015160101c6001600160a01b031690565b600081831015614f105781612da6565b6000610adc670de0b6b3a764000083615dea565b6000808213156150a057506001919050565b60008212156150b25750600019919050565b506000919050565b6000808313156150cd5761349a82614201565b60008312156150eb576150df82614201565b61349a90600019615b4c565b50600092915050565b6000816f7fffffffffffffffffffffffffffffff811315615144576040517f59aeb746000000000000000000000000000000000000000000000000000000008152600481018290526024016109fd565b7fffffffffffffffffffffffffffffffff80000000000000000000000000000000811215610adc576040517f4e02165d000000000000000000000000000000000000000000000000000000008152600481018290526024016109fd565b60006151ac83614442565b158015612da6575050905190511190565b6000806151db8460400151856020015161428c90919063ffffffff16565b90506000806151f861467786604001516146718660000151614201565b61521061467787604001516146718760200151614201565b9150915060003090506152fa615288826001600160a01b03166343f0179b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561525d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906152819190615804565b8490614fea565b6152f4836001600160a01b031663fc741c7c6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156152c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906152ed9190615804565b8690614fea565b90613f72565b979650505050505050565b6000816fffffffffffffffffffffffffffffffff811115610adc576040517f53851291000000000000000000000000000000000000000000000000000000008152600481018290526024016109fd565b6060612da68383604051806060016040528060258152602001615e9860259139615391565b60008082121561538d5781600003610adc565b5090565b60606001600160a01b0384163b615429576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f416464726573733a207374617469632063616c6c20746f206e6f6e2d636f6e7460448201527f726163740000000000000000000000000000000000000000000000000000000060648201526084016109fd565b600080856001600160a01b0316856040516154449190615e7b565b600060405180830381855afa9150503d806000811461547f576040519150601f19603f3d011682016040523d82523d6000602084013e615484565b606091505b509150915061549482828661549e565b9695505050505050565b606083156154ad575081612da6565b8251156154bd5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109fd9190615619565b604051806060016040528060008152602001615520604051806040016040528060008152602001600081525090565b8152602001615542604051806040016040528060008152602001600081525090565b905290565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b600281106111cf577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b815160608201906155bd81615576565b825260208301516155cd81615576565b8060208401525061ffff19604084015116604083015292915050565b60005b838110156156045781810151838201526020016155ec565b83811115615613576000848401525b50505050565b60208152600082518060208401526156388160408501602087016155e9565b601f01601f19169190910160400192915050565b60006080828403121561565e57600080fd5b50919050565b6001600160a01b03811681146111cf57600080fd5b60006020828403121561568b57600080fd5b8135612da681615664565b8151815260208083015180518284015290810151604083015260a082019050604083015180516060840152602081015160808401526141fa565b6000602082840312156156e257600080fd5b5035919050565b80151581146111cf57600080fd5b60006020828403121561570957600080fd5b8135612da6816156e9565b60006040828403121561565e57600080fd5b81518152602080830151908201526040808301519082015260608101610adc565b815181526020808301519082015260408101610adc565b60006020828403121561577057600080fd5b813567ffffffffffffffff81111561578757600080fd5b82016101e08185031215612da657600080fd5b600181811c908216806157ae57607f821691505b60208210810361565e577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000602082840312156157f957600080fd5b8151612da6816156e9565b60006020828403121561581657600080fd5b5051919050565b60006020828403121561582f57600080fd5b8151612da681615664565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516060810167ffffffffffffffff8111828210171561588c5761588c61583a565b60405290565b8035600f81900b81146158a457600080fd5b919050565b6000608082840312156158bb57600080fd5b6040516080810181811067ffffffffffffffff821117156158de576158de61583a565b6040526158ea83615892565b81526158f860208401615892565b602082015261590960408401615892565b604082015260608301356fffffffffffffffffffffffffffffffff8116811461593157600080fd5b60608201529392505050565b60006060828403121561594f57600080fd5b615957615869565b8251815260208301516020820152604083015160408201528091505092915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126159ae57600080fd5b83018035915067ffffffffffffffff8211156159c957600080fd5b6020019150368190038213156159de57600080fd5b9250929050565b601f82111561365857600081815260208120601f850160051c81016020861015615a0c5750805b601f850160051c820191505b81811015613d1957828155600101615a18565b67ffffffffffffffff831115615a4357615a4361583a565b615a5783615a51835461579a565b836159e5565b6000601f841160018114615a8b5760008515615a735750838201355b600019600387901b1c1916600186901b178355615ae5565b600083815260209020601f19861690835b82811015615abc5786850135825560209485019460019092019101615a9c565b5086821015615ad95760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b6001600160a01b038316815260808101612da660208301848051825260208082015190830152604090810151910152565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600084136000841385830485118282161615615b8d57615b8d615b1d565b7f80000000000000000000000000000000000000000000000000000000000000006000871286820588128184161615615bc857615bc8615b1d565b60008712925087820587128484161615615be457615be4615b1d565b87850587128184161615615bfa57615bfa615b1d565b505050929093029392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600082615c4657615c46615c08565b60001983147f800000000000000000000000000000000000000000000000000000000000000083141615615c7c57615c7c615b1d565b500590565b600281106111cf57600080fd5b600060608284031215615ca057600080fd5b615ca8615869565b8235615cb381615c81565b81526020830135615cc381615c81565b6020820152604083013561ffff1981168114615cde57600080fd5b60408201529392505050565b60008219821115615cfd57615cfd615b1d565b500190565b6000808212827f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03841381151615615d3c57615d3c615b1d565b827f8000000000000000000000000000000000000000000000000000000000000000038412811615615d7057615d70615b1d565b50500190565b6000808312837f800000000000000000000000000000000000000000000000000000000000000001831281151615615db057615db0615b1d565b837f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff018313811615615de457615de4615b1d565b50500390565b6000816000190483118215151615615e0457615e04615b1d565b500290565b600082615e1857615e18615c08565b500490565b60408101615e2a84615576565b838252615e3683615576565b8260208301529392505050565b600082821015615e5557615e55615b1d565b500390565b60408101615e6784615576565b92815261ffff199190911660209091015290565b60008251615e8d8184602087016155e9565b919091019291505056fe416464726573733a206c6f772d6c6576656c207374617469632063616c6c206661696c6564a2646970667358221220c8f28337b68a0a25a9b849842eef3dea5522fe30a7a3178bfe70c89801c2062264736f6c634300080f0033" -} diff --git a/packages/perennial/deployments/kovan/ProxyAdmin.json b/packages/perennial/deployments/kovan/ProxyAdmin.json deleted file mode 100644 index b2f6bb63f..000000000 --- a/packages/perennial/deployments/kovan/ProxyAdmin.json +++ /dev/null @@ -1,246 +0,0 @@ -{ - "address": "0xfFE829F928Cb8C07961bfFF04512ac0749d65d27", - "abi": [ - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "contract TransparentUpgradeableProxy", - "name": "proxy", - "type": "address" - }, - { - "internalType": "address", - "name": "newAdmin", - "type": "address" - } - ], - "name": "changeProxyAdmin", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract TransparentUpgradeableProxy", - "name": "proxy", - "type": "address" - } - ], - "name": "getProxyAdmin", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract TransparentUpgradeableProxy", - "name": "proxy", - "type": "address" - } - ], - "name": "getProxyImplementation", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract TransparentUpgradeableProxy", - "name": "proxy", - "type": "address" - }, - { - "internalType": "address", - "name": "implementation", - "type": "address" - } - ], - "name": "upgrade", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract TransparentUpgradeableProxy", - "name": "proxy", - "type": "address" - }, - { - "internalType": "address", - "name": "implementation", - "type": "address" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "upgradeAndCall", - "outputs": [], - "stateMutability": "payable", - "type": "function" - } - ], - "transactionHash": "0x9b138c53d702ffc40b524881774981cf3976de6fb2665fdce31dc5bce1a6b408", - "receipt": { - "to": null, - "from": "0x66a7fDB96C583c59597de16d8b2B989231415339", - "contractAddress": "0xfFE829F928Cb8C07961bfFF04512ac0749d65d27", - "transactionIndex": 0, - "gasUsed": "642227", - "logsBloom": "0x00000000000000000000000000000100000000000000000080800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000400000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000004000000000000000000000000000000000000000000000000", - "blockHash": "0x629561205f4e9067b2b120fee55dfd9b13366f66c68ea41c7e48429856881530", - "transactionHash": "0x9b138c53d702ffc40b524881774981cf3976de6fb2665fdce31dc5bce1a6b408", - "logs": [ - { - "transactionIndex": 0, - "blockNumber": 33203734, - "transactionHash": "0x9b138c53d702ffc40b524881774981cf3976de6fb2665fdce31dc5bce1a6b408", - "address": "0xfFE829F928Cb8C07961bfFF04512ac0749d65d27", - "topics": [ - "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x00000000000000000000000066a7fdb96c583c59597de16d8b2b989231415339" - ], - "data": "0x", - "logIndex": 0, - "blockHash": "0x629561205f4e9067b2b120fee55dfd9b13366f66c68ea41c7e48429856881530" - } - ], - "blockNumber": 33203734, - "cumulativeGasUsed": "642227", - "status": 1, - "byzantium": true - }, - "args": [], - "numDeployments": 1, - "solcInputHash": "dd52f03d8fef7833844e4ba864fd9fba", - "metadata": "{\"compiler\":{\"version\":\"0.8.15+commit.e14f2714\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"contract TransparentUpgradeableProxy\",\"name\":\"proxy\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeProxyAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract TransparentUpgradeableProxy\",\"name\":\"proxy\",\"type\":\"address\"}],\"name\":\"getProxyAdmin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract TransparentUpgradeableProxy\",\"name\":\"proxy\",\"type\":\"address\"}],\"name\":\"getProxyImplementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract TransparentUpgradeableProxy\",\"name\":\"proxy\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"upgrade\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract TransparentUpgradeableProxy\",\"name\":\"proxy\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.\",\"kind\":\"dev\",\"methods\":{\"changeProxyAdmin(address,address)\":{\"details\":\"Changes the admin of `proxy` to `newAdmin`. Requirements: - This contract must be the current admin of `proxy`.\"},\"getProxyAdmin(address)\":{\"details\":\"Returns the current admin of `proxy`. Requirements: - This contract must be the admin of `proxy`.\"},\"getProxyImplementation(address)\":{\"details\":\"Returns the current implementation of `proxy`. Requirements: - This contract must be the admin of `proxy`.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"upgrade(address,address)\":{\"details\":\"Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}. Requirements: - This contract must be the admin of `proxy`.\"},\"upgradeAndCall(address,address,bytes)\":{\"details\":\"Upgrades `proxy` to `implementation` and calls a function on the new implementation. See {TransparentUpgradeableProxy-upgradeToAndCall}. Requirements: - This contract must be the admin of `proxy`.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol\":\"ProxyAdmin\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0x24e0364e503a9bbde94c715d26573a76f14cd2a202d45f96f52134ab806b67b9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/ProxyAdmin.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./TransparentUpgradeableProxy.sol\\\";\\nimport \\\"../../access/Ownable.sol\\\";\\n\\n/**\\n * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an\\n * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.\\n */\\ncontract ProxyAdmin is Ownable {\\n /**\\n * @dev Returns the current implementation of `proxy`.\\n *\\n * Requirements:\\n *\\n * - This contract must be the admin of `proxy`.\\n */\\n function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\\n // We need to manually run the static call since the getter cannot be flagged as view\\n // bytes4(keccak256(\\\"implementation()\\\")) == 0x5c60da1b\\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\\\"5c60da1b\\\");\\n require(success);\\n return abi.decode(returndata, (address));\\n }\\n\\n /**\\n * @dev Returns the current admin of `proxy`.\\n *\\n * Requirements:\\n *\\n * - This contract must be the admin of `proxy`.\\n */\\n function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\\n // We need to manually run the static call since the getter cannot be flagged as view\\n // bytes4(keccak256(\\\"admin()\\\")) == 0xf851a440\\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\\\"f851a440\\\");\\n require(success);\\n return abi.decode(returndata, (address));\\n }\\n\\n /**\\n * @dev Changes the admin of `proxy` to `newAdmin`.\\n *\\n * Requirements:\\n *\\n * - This contract must be the current admin of `proxy`.\\n */\\n function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {\\n proxy.changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.\\n *\\n * Requirements:\\n *\\n * - This contract must be the admin of `proxy`.\\n */\\n function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {\\n proxy.upgradeTo(implementation);\\n }\\n\\n /**\\n * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See\\n * {TransparentUpgradeableProxy-upgradeToAndCall}.\\n *\\n * Requirements:\\n *\\n * - This contract must be the admin of `proxy`.\\n */\\n function upgradeAndCall(\\n TransparentUpgradeableProxy proxy,\\n address implementation,\\n bytes memory data\\n ) public payable virtual onlyOwner {\\n proxy.upgradeToAndCall{value: msg.value}(implementation, data);\\n }\\n}\\n\",\"keccak256\":\"0x33b8603bfbef7f33d9308b79c79aa3db7eb19525fd1addd764285e834ca275d7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // 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\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\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 ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\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(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\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 /**\\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 {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x608060405234801561001057600080fd5b5061001a3361001f565b61006f565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b610a488061007e6000396000f3fe60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461012b57806399a88ec41461013e578063f2fde38b1461015e578063f3b7dead1461017e57600080fd5b8063204e1c7a14610080578063715018a6146100c95780637eff275e146100e05780638da5cb5b14610100575b600080fd5b34801561008c57600080fd5b506100a061009b3660046107e4565b61019e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d557600080fd5b506100de610255565b005b3480156100ec57600080fd5b506100de6100fb366004610808565b6102e7565b34801561010c57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100a0565b6100de610139366004610870565b6103ee565b34801561014a57600080fd5b506100de610159366004610808565b6104fc565b34801561016a57600080fd5b506100de6101793660046107e4565b6105d1565b34801561018a57600080fd5b506100a06101993660046107e4565b610701565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b600060405180830381855afa9150503d8060008114610225576040519150601f19603f3d011682016040523d82523d6000602084013e61022a565b606091505b50915091508161023957600080fd5b8080602001905181019061024d9190610964565b949350505050565b60005473ffffffffffffffffffffffffffffffffffffffff1633146102db576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b6102e5600061074d565b565b60005473ffffffffffffffffffffffffffffffffffffffff163314610368576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b600060405180830381600087803b1580156103d257600080fd5b505af11580156103e6573d6000803e3d6000fd5b505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461046f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef2869034906104c59086908690600401610981565b6000604051808303818588803b1580156104de57600080fd5b505af11580156104f2573d6000803e3d6000fd5b5050505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461057d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016103b8565b60005473ffffffffffffffffffffffffffffffffffffffff163314610652576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b73ffffffffffffffffffffffffffffffffffffffff81166106f5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016102d2565b6106fe8161074d565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff811681146106fe57600080fd5b6000602082840312156107f657600080fd5b8135610801816107c2565b9392505050565b6000806040838503121561081b57600080fd5b8235610826816107c2565b91506020830135610836816107c2565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060006060848603121561088557600080fd5b8335610890816107c2565b925060208401356108a0816107c2565b9150604084013567ffffffffffffffff808211156108bd57600080fd5b818601915086601f8301126108d157600080fd5b8135818111156108e3576108e3610841565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561092957610929610841565b8160405282815289602084870101111561094257600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561097657600080fd5b8151610801816107c2565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b818110156109cb578581018301518582016060015282016109af565b818111156109dd576000606083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160600194935050505056fea2646970667358221220131047e01068f5d9fede9201de856c46786e7562ec5dfad2cd5e344ae34f062064736f6c634300080f0033", - "deployedBytecode": "0x60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461012b57806399a88ec41461013e578063f2fde38b1461015e578063f3b7dead1461017e57600080fd5b8063204e1c7a14610080578063715018a6146100c95780637eff275e146100e05780638da5cb5b14610100575b600080fd5b34801561008c57600080fd5b506100a061009b3660046107e4565b61019e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d557600080fd5b506100de610255565b005b3480156100ec57600080fd5b506100de6100fb366004610808565b6102e7565b34801561010c57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100a0565b6100de610139366004610870565b6103ee565b34801561014a57600080fd5b506100de610159366004610808565b6104fc565b34801561016a57600080fd5b506100de6101793660046107e4565b6105d1565b34801561018a57600080fd5b506100a06101993660046107e4565b610701565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b600060405180830381855afa9150503d8060008114610225576040519150601f19603f3d011682016040523d82523d6000602084013e61022a565b606091505b50915091508161023957600080fd5b8080602001905181019061024d9190610964565b949350505050565b60005473ffffffffffffffffffffffffffffffffffffffff1633146102db576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b6102e5600061074d565b565b60005473ffffffffffffffffffffffffffffffffffffffff163314610368576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b600060405180830381600087803b1580156103d257600080fd5b505af11580156103e6573d6000803e3d6000fd5b505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461046f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef2869034906104c59086908690600401610981565b6000604051808303818588803b1580156104de57600080fd5b505af11580156104f2573d6000803e3d6000fd5b5050505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461057d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016103b8565b60005473ffffffffffffffffffffffffffffffffffffffff163314610652576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d2565b73ffffffffffffffffffffffffffffffffffffffff81166106f5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016102d2565b6106fe8161074d565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff811681146106fe57600080fd5b6000602082840312156107f657600080fd5b8135610801816107c2565b9392505050565b6000806040838503121561081b57600080fd5b8235610826816107c2565b91506020830135610836816107c2565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060006060848603121561088557600080fd5b8335610890816107c2565b925060208401356108a0816107c2565b9150604084013567ffffffffffffffff808211156108bd57600080fd5b818601915086601f8301126108d157600080fd5b8135818111156108e3576108e3610841565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561092957610929610841565b8160405282815289602084870101111561094257600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561097657600080fd5b8151610801816107c2565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b818110156109cb578581018301518582016060015282016109af565b818111156109dd576000606083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160600194935050505056fea2646970667358221220131047e01068f5d9fede9201de856c46786e7562ec5dfad2cd5e344ae34f062064736f6c634300080f0033", - "devdoc": { - "details": "This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.", - "kind": "dev", - "methods": { - "changeProxyAdmin(address,address)": { - "details": "Changes the admin of `proxy` to `newAdmin`. Requirements: - This contract must be the current admin of `proxy`." - }, - "getProxyAdmin(address)": { - "details": "Returns the current admin of `proxy`. Requirements: - This contract must be the admin of `proxy`." - }, - "getProxyImplementation(address)": { - "details": "Returns the current implementation of `proxy`. Requirements: - This contract must be the admin of `proxy`." - }, - "owner()": { - "details": "Returns the address of the current owner." - }, - "renounceOwnership()": { - "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." - }, - "transferOwnership(address)": { - "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." - }, - "upgrade(address,address)": { - "details": "Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}. Requirements: - This contract must be the admin of `proxy`." - }, - "upgradeAndCall(address,address,bytes)": { - "details": "Upgrades `proxy` to `implementation` and calls a function on the new implementation. See {TransparentUpgradeableProxy-upgradeToAndCall}. Requirements: - This contract must be the admin of `proxy`." - } - }, - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": {}, - "version": 1 - }, - "storageLayout": { - "storage": [ - { - "astId": 5416, - "contract": "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol:ProxyAdmin", - "label": "_owner", - "offset": 0, - "slot": "0", - "type": "t_address" - } - ], - "types": { - "t_address": { - "encoding": "inplace", - "label": "address", - "numberOfBytes": "20" - } - } - } -} diff --git a/packages/perennial/deployments/kovan/TimelockController.json b/packages/perennial/deployments/kovan/TimelockController.json deleted file mode 100644 index d6bed7095..000000000 --- a/packages/perennial/deployments/kovan/TimelockController.json +++ /dev/null @@ -1,1230 +0,0 @@ -{ - "address": "0xa70eb2DBE380467175d7D793B0875887ABB2D660", - "abi": [ - { - "inputs": [ - { - "internalType": "uint256", - "name": "minDelay", - "type": "uint256" - }, - { - "internalType": "address[]", - "name": "proposers", - "type": "address[]" - }, - { - "internalType": "address[]", - "name": "executors", - "type": "address[]" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "id", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "index", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "CallExecuted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "id", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "index", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "data", - "type": "bytes" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "predecessor", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "delay", - "type": "uint256" - } - ], - "name": "CallScheduled", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "id", - "type": "bytes32" - } - ], - "name": "Cancelled", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "oldDuration", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newDuration", - "type": "uint256" - } - ], - "name": "MinDelayChange", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "previousAdminRole", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "newAdminRole", - "type": "bytes32" - } - ], - "name": "RoleAdminChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "RoleGranted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "RoleRevoked", - "type": "event" - }, - { - "inputs": [], - "name": "CANCELLER_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "DEFAULT_ADMIN_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "EXECUTOR_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "PROPOSER_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "TIMELOCK_ADMIN_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "id", - "type": "bytes32" - } - ], - "name": "cancel", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - }, - { - "internalType": "bytes32", - "name": "predecessor", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - } - ], - "name": "execute", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address[]", - "name": "targets", - "type": "address[]" - }, - { - "internalType": "uint256[]", - "name": "values", - "type": "uint256[]" - }, - { - "internalType": "bytes[]", - "name": "payloads", - "type": "bytes[]" - }, - { - "internalType": "bytes32", - "name": "predecessor", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - } - ], - "name": "executeBatch", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [], - "name": "getMinDelay", - "outputs": [ - { - "internalType": "uint256", - "name": "duration", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - } - ], - "name": "getRoleAdmin", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "id", - "type": "bytes32" - } - ], - "name": "getTimestamp", - "outputs": [ - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "grantRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "hasRole", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - }, - { - "internalType": "bytes32", - "name": "predecessor", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - } - ], - "name": "hashOperation", - "outputs": [ - { - "internalType": "bytes32", - "name": "hash", - "type": "bytes32" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address[]", - "name": "targets", - "type": "address[]" - }, - { - "internalType": "uint256[]", - "name": "values", - "type": "uint256[]" - }, - { - "internalType": "bytes[]", - "name": "payloads", - "type": "bytes[]" - }, - { - "internalType": "bytes32", - "name": "predecessor", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - } - ], - "name": "hashOperationBatch", - "outputs": [ - { - "internalType": "bytes32", - "name": "hash", - "type": "bytes32" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "id", - "type": "bytes32" - } - ], - "name": "isOperation", - "outputs": [ - { - "internalType": "bool", - "name": "pending", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "id", - "type": "bytes32" - } - ], - "name": "isOperationDone", - "outputs": [ - { - "internalType": "bool", - "name": "done", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "id", - "type": "bytes32" - } - ], - "name": "isOperationPending", - "outputs": [ - { - "internalType": "bool", - "name": "pending", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "id", - "type": "bytes32" - } - ], - "name": "isOperationReady", - "outputs": [ - { - "internalType": "bool", - "name": "ready", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "uint256[]", - "name": "", - "type": "uint256[]" - }, - { - "internalType": "uint256[]", - "name": "", - "type": "uint256[]" - }, - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "name": "onERC1155BatchReceived", - "outputs": [ - { - "internalType": "bytes4", - "name": "", - "type": "bytes4" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "name": "onERC1155Received", - "outputs": [ - { - "internalType": "bytes4", - "name": "", - "type": "bytes4" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "name": "onERC721Received", - "outputs": [ - { - "internalType": "bytes4", - "name": "", - "type": "bytes4" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "renounceRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "revokeRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - }, - { - "internalType": "bytes32", - "name": "predecessor", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "delay", - "type": "uint256" - } - ], - "name": "schedule", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address[]", - "name": "targets", - "type": "address[]" - }, - { - "internalType": "uint256[]", - "name": "values", - "type": "uint256[]" - }, - { - "internalType": "bytes[]", - "name": "payloads", - "type": "bytes[]" - }, - { - "internalType": "bytes32", - "name": "predecessor", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "delay", - "type": "uint256" - } - ], - "name": "scheduleBatch", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes4", - "name": "interfaceId", - "type": "bytes4" - } - ], - "name": "supportsInterface", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "newDelay", - "type": "uint256" - } - ], - "name": "updateDelay", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "stateMutability": "payable", - "type": "receive" - } - ], - "transactionHash": "0x5d09ae1862b1fe924cb234e7411e03cf13230f246ff998808f26322d39f6183b", - "receipt": { - "to": null, - "from": "0x66a7fDB96C583c59597de16d8b2B989231415339", - "contractAddress": "0xa70eb2DBE380467175d7D793B0875887ABB2D660", - "transactionIndex": 0, - "gasUsed": "2403523", - "logsBloom": "0x000000050000000008000000000001000a0000000000000000020000000002000000000000000000000000000001000000000000000000000200000010200000000000000000000000000010000000000000100000000000000000000001000000000000020000400000000000000800000000000000000000020000000000000000000000000000400000000000000000000000000000080001000000000400000008000020000000100000000000000000000080000000001000000000004000000000000000004000000000000000000200000000000100000100200020000000000000001000000000000000000000000000000000000000000000000000", - "blockHash": "0x679df1ddd9138ac0e3a0858f8f6aeb420cfd9cac1604fe108a0a1f862832c7e6", - "transactionHash": "0x5d09ae1862b1fe924cb234e7411e03cf13230f246ff998808f26322d39f6183b", - "logs": [ - { - "transactionIndex": 0, - "blockNumber": 33203733, - "transactionHash": "0x5d09ae1862b1fe924cb234e7411e03cf13230f246ff998808f26322d39f6183b", - "address": "0xa70eb2DBE380467175d7D793B0875887ABB2D660", - "topics": [ - "0xbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff", - "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5" - ], - "data": "0x", - "logIndex": 0, - "blockHash": "0x679df1ddd9138ac0e3a0858f8f6aeb420cfd9cac1604fe108a0a1f862832c7e6" - }, - { - "transactionIndex": 0, - "blockNumber": 33203733, - "transactionHash": "0x5d09ae1862b1fe924cb234e7411e03cf13230f246ff998808f26322d39f6183b", - "address": "0xa70eb2DBE380467175d7D793B0875887ABB2D660", - "topics": [ - "0xbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff", - "0xb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5" - ], - "data": "0x", - "logIndex": 1, - "blockHash": "0x679df1ddd9138ac0e3a0858f8f6aeb420cfd9cac1604fe108a0a1f862832c7e6" - }, - { - "transactionIndex": 0, - "blockNumber": 33203733, - "transactionHash": "0x5d09ae1862b1fe924cb234e7411e03cf13230f246ff998808f26322d39f6183b", - "address": "0xa70eb2DBE380467175d7D793B0875887ABB2D660", - "topics": [ - "0xbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff", - "0xd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e63", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5" - ], - "data": "0x", - "logIndex": 2, - "blockHash": "0x679df1ddd9138ac0e3a0858f8f6aeb420cfd9cac1604fe108a0a1f862832c7e6" - }, - { - "transactionIndex": 0, - "blockNumber": 33203733, - "transactionHash": "0x5d09ae1862b1fe924cb234e7411e03cf13230f246ff998808f26322d39f6183b", - "address": "0xa70eb2DBE380467175d7D793B0875887ABB2D660", - "topics": [ - "0xbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff", - "0xfd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5" - ], - "data": "0x", - "logIndex": 3, - "blockHash": "0x679df1ddd9138ac0e3a0858f8f6aeb420cfd9cac1604fe108a0a1f862832c7e6" - }, - { - "transactionIndex": 0, - "blockNumber": 33203733, - "transactionHash": "0x5d09ae1862b1fe924cb234e7411e03cf13230f246ff998808f26322d39f6183b", - "address": "0xa70eb2DBE380467175d7D793B0875887ABB2D660", - "topics": [ - "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d", - "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", - "0x00000000000000000000000066a7fdb96c583c59597de16d8b2b989231415339", - "0x00000000000000000000000066a7fdb96c583c59597de16d8b2b989231415339" - ], - "data": "0x", - "logIndex": 4, - "blockHash": "0x679df1ddd9138ac0e3a0858f8f6aeb420cfd9cac1604fe108a0a1f862832c7e6" - }, - { - "transactionIndex": 0, - "blockNumber": 33203733, - "transactionHash": "0x5d09ae1862b1fe924cb234e7411e03cf13230f246ff998808f26322d39f6183b", - "address": "0xa70eb2DBE380467175d7D793B0875887ABB2D660", - "topics": [ - "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d", - "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", - "0x000000000000000000000000a70eb2dbe380467175d7d793b0875887abb2d660", - "0x00000000000000000000000066a7fdb96c583c59597de16d8b2b989231415339" - ], - "data": "0x", - "logIndex": 5, - "blockHash": "0x679df1ddd9138ac0e3a0858f8f6aeb420cfd9cac1604fe108a0a1f862832c7e6" - }, - { - "transactionIndex": 0, - "blockNumber": 33203733, - "transactionHash": "0x5d09ae1862b1fe924cb234e7411e03cf13230f246ff998808f26322d39f6183b", - "address": "0xa70eb2DBE380467175d7D793B0875887ABB2D660", - "topics": [ - "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d", - "0xb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1", - "0x000000000000000000000000f6c02e15187c9b466e81b3ac72ccf32569eb19ed", - "0x00000000000000000000000066a7fdb96c583c59597de16d8b2b989231415339" - ], - "data": "0x", - "logIndex": 6, - "blockHash": "0x679df1ddd9138ac0e3a0858f8f6aeb420cfd9cac1604fe108a0a1f862832c7e6" - }, - { - "transactionIndex": 0, - "blockNumber": 33203733, - "transactionHash": "0x5d09ae1862b1fe924cb234e7411e03cf13230f246ff998808f26322d39f6183b", - "address": "0xa70eb2DBE380467175d7D793B0875887ABB2D660", - "topics": [ - "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d", - "0xfd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783", - "0x000000000000000000000000f6c02e15187c9b466e81b3ac72ccf32569eb19ed", - "0x00000000000000000000000066a7fdb96c583c59597de16d8b2b989231415339" - ], - "data": "0x", - "logIndex": 7, - "blockHash": "0x679df1ddd9138ac0e3a0858f8f6aeb420cfd9cac1604fe108a0a1f862832c7e6" - }, - { - "transactionIndex": 0, - "blockNumber": 33203733, - "transactionHash": "0x5d09ae1862b1fe924cb234e7411e03cf13230f246ff998808f26322d39f6183b", - "address": "0xa70eb2DBE380467175d7D793B0875887ABB2D660", - "topics": [ - "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d", - "0xd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e63", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x00000000000000000000000066a7fdb96c583c59597de16d8b2b989231415339" - ], - "data": "0x", - "logIndex": 8, - "blockHash": "0x679df1ddd9138ac0e3a0858f8f6aeb420cfd9cac1604fe108a0a1f862832c7e6" - }, - { - "transactionIndex": 0, - "blockNumber": 33203733, - "transactionHash": "0x5d09ae1862b1fe924cb234e7411e03cf13230f246ff998808f26322d39f6183b", - "address": "0xa70eb2DBE380467175d7D793B0875887ABB2D660", - "topics": ["0x11c24f4ead16507c69ac467fbd5e4eed5fb5c699626d2cc6d66421df253886d5"], - "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a300", - "logIndex": 9, - "blockHash": "0x679df1ddd9138ac0e3a0858f8f6aeb420cfd9cac1604fe108a0a1f862832c7e6" - } - ], - "blockNumber": 33203733, - "cumulativeGasUsed": "2403523", - "status": 1, - "byzantium": true - }, - "args": [172800, ["0xf6C02E15187c9b466E81B3aC72cCf32569EB19eD"], ["0x0000000000000000000000000000000000000000"]], - "numDeployments": 1, - "solcInputHash": "dd52f03d8fef7833844e4ba864fd9fba", - "metadata": "{\"compiler\":{\"version\":\"0.8.15+commit.e14f2714\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"minDelay\",\"type\":\"uint256\"},{\"internalType\":\"address[]\",\"name\":\"proposers\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"executors\",\"type\":\"address[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"CallExecuted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"predecessor\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"delay\",\"type\":\"uint256\"}],\"name\":\"CallScheduled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"Cancelled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldDuration\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newDuration\",\"type\":\"uint256\"}],\"name\":\"MinDelayChange\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"CANCELLER_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"EXECUTOR_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"PROPOSER_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"TIMELOCK_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"cancel\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"bytes32\",\"name\":\"predecessor\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"salt\",\"type\":\"bytes32\"}],\"name\":\"execute\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"targets\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"values\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes[]\",\"name\":\"payloads\",\"type\":\"bytes[]\"},{\"internalType\":\"bytes32\",\"name\":\"predecessor\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"salt\",\"type\":\"bytes32\"}],\"name\":\"executeBatch\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMinDelay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"duration\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"getTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"bytes32\",\"name\":\"predecessor\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"salt\",\"type\":\"bytes32\"}],\"name\":\"hashOperation\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"hash\",\"type\":\"bytes32\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"targets\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"values\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes[]\",\"name\":\"payloads\",\"type\":\"bytes[]\"},{\"internalType\":\"bytes32\",\"name\":\"predecessor\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"salt\",\"type\":\"bytes32\"}],\"name\":\"hashOperationBatch\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"hash\",\"type\":\"bytes32\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"isOperation\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"pending\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"isOperationDone\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"done\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"isOperationPending\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"pending\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"isOperationReady\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"ready\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"onERC1155BatchReceived\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"onERC1155Received\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"onERC721Received\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"bytes32\",\"name\":\"predecessor\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"salt\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"delay\",\"type\":\"uint256\"}],\"name\":\"schedule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"targets\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"values\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes[]\",\"name\":\"payloads\",\"type\":\"bytes[]\"},{\"internalType\":\"bytes32\",\"name\":\"predecessor\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"salt\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"delay\",\"type\":\"uint256\"}],\"name\":\"scheduleBatch\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newDelay\",\"type\":\"uint256\"}],\"name\":\"updateDelay\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"Contract module which acts as a timelocked controller. When set as the owner of an `Ownable` smart contract, it enforces a timelock on all `onlyOwner` maintenance operations. This gives time for users of the controlled contract to exit before a potentially dangerous maintenance operation is applied. By default, this contract is self administered, meaning administration tasks have to go through the timelock process. The proposer (resp executor) role is in charge of proposing (resp executing) operations. A common use case is to position this {TimelockController} as the owner of a smart contract, with a multisig or a DAO as the sole proposer. _Available since v3.3._\",\"events\":{\"CallExecuted(bytes32,uint256,address,uint256,bytes)\":{\"details\":\"Emitted when a call is performed as part of operation `id`.\"},\"CallScheduled(bytes32,uint256,address,uint256,bytes,bytes32,uint256)\":{\"details\":\"Emitted when a call is scheduled as part of operation `id`.\"},\"Cancelled(bytes32)\":{\"details\":\"Emitted when operation `id` is cancelled.\"},\"MinDelayChange(uint256,uint256)\":{\"details\":\"Emitted when the minimum delay for future operations is modified.\"}},\"kind\":\"dev\",\"methods\":{\"cancel(bytes32)\":{\"details\":\"Cancel an operation. Requirements: - the caller must have the 'canceller' role.\"},\"constructor\":{\"details\":\"Initializes the contract with a given `minDelay`, and a list of initial proposers and executors. The proposers receive both the proposer and the canceller role (for backward compatibility). The executors receive the executor role. NOTE: At construction, both the deployer and the timelock itself are administrators. This helps further configuration of the timelock by the deployer. After configuration is done, it is recommended that the deployer renounces its admin position and relies on timelocked operations to perform future maintenance.\"},\"execute(address,uint256,bytes,bytes32,bytes32)\":{\"details\":\"Execute an (ready) operation containing a single transaction. Emits a {CallExecuted} event. Requirements: - the caller must have the 'executor' role.\"},\"executeBatch(address[],uint256[],bytes[],bytes32,bytes32)\":{\"details\":\"Execute an (ready) operation containing a batch of transactions. Emits one {CallExecuted} event per transaction in the batch. Requirements: - the caller must have the 'executor' role.\"},\"getMinDelay()\":{\"details\":\"Returns the minimum delay for an operation to become valid. This value can be changed by executing an operation that calls `updateDelay`.\"},\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.\"},\"getTimestamp(bytes32)\":{\"details\":\"Returns the timestamp at with an operation becomes ready (0 for unset operations, 1 for done operations).\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"hashOperation(address,uint256,bytes,bytes32,bytes32)\":{\"details\":\"Returns the identifier of an operation containing a single transaction.\"},\"hashOperationBatch(address[],uint256[],bytes[],bytes32,bytes32)\":{\"details\":\"Returns the identifier of an operation containing a batch of transactions.\"},\"isOperation(bytes32)\":{\"details\":\"Returns whether an id correspond to a registered operation. This includes both Pending, Ready and Done operations.\"},\"isOperationDone(bytes32)\":{\"details\":\"Returns whether an operation is done or not.\"},\"isOperationPending(bytes32)\":{\"details\":\"Returns whether an operation is pending or not.\"},\"isOperationReady(bytes32)\":{\"details\":\"Returns whether an operation is ready or not.\"},\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\":{\"details\":\"See {IERC1155Receiver-onERC1155BatchReceived}.\"},\"onERC1155Received(address,address,uint256,uint256,bytes)\":{\"details\":\"See {IERC1155Receiver-onERC1155Received}.\"},\"onERC721Received(address,address,uint256,bytes)\":{\"details\":\"See {IERC721Receiver-onERC721Received}.\"},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `account`.\"},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role.\"},\"schedule(address,uint256,bytes,bytes32,bytes32,uint256)\":{\"details\":\"Schedule an operation containing a single transaction. Emits a {CallScheduled} event. Requirements: - the caller must have the 'proposer' role.\"},\"scheduleBatch(address[],uint256[],bytes[],bytes32,bytes32,uint256)\":{\"details\":\"Schedule an operation containing a batch of transactions. Emits one {CallScheduled} event per transaction in the batch. Requirements: - the caller must have the 'proposer' role.\"},\"supportsInterface(bytes4)\":{\"details\":\"See {IERC165-supportsInterface}.\"},\"updateDelay(uint256)\":{\"details\":\"Changes the minimum timelock duration for future operations. Emits a {MinDelayChange} event. Requirements: - the caller must be the timelock itself. This can only be achieved by scheduling and later executing an operation where the timelock is the target and the data is the ABI-encoded call to this function.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"@openzeppelin/contracts/governance/TimelockController.sol\":\"TimelockController\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/AccessControl.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (access/AccessControl.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IAccessControl.sol\\\";\\nimport \\\"../utils/Context.sol\\\";\\nimport \\\"../utils/Strings.sol\\\";\\nimport \\\"../utils/introspection/ERC165.sol\\\";\\n\\n/**\\n * @dev Contract module that allows children to implement role-based access\\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\\n * members except through off-chain means by accessing the contract event logs. Some\\n * applications may benefit from on-chain enumerability, for those cases see\\n * {AccessControlEnumerable}.\\n *\\n * Roles are referred to by their `bytes32` identifier. These should be exposed\\n * in the external API and be unique. The best way to achieve this is by\\n * using `public constant` hash digests:\\n *\\n * ```\\n * bytes32 public constant MY_ROLE = keccak256(\\\"MY_ROLE\\\");\\n * ```\\n *\\n * Roles can be used to represent a set of permissions. To restrict access to a\\n * function call, use {hasRole}:\\n *\\n * ```\\n * function foo() public {\\n * require(hasRole(MY_ROLE, msg.sender));\\n * ...\\n * }\\n * ```\\n *\\n * Roles can be granted and revoked dynamically via the {grantRole} and\\n * {revokeRole} functions. Each role has an associated admin role, and only\\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\\n *\\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\\n * that only accounts with this role will be able to grant or revoke other\\n * roles. More complex role relationships can be created by using\\n * {_setRoleAdmin}.\\n *\\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\\n * grant and revoke this role. Extra precautions should be taken to secure\\n * accounts that have been granted it.\\n */\\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\\n struct RoleData {\\n mapping(address => bool) members;\\n bytes32 adminRole;\\n }\\n\\n mapping(bytes32 => RoleData) private _roles;\\n\\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\\n\\n /**\\n * @dev Modifier that checks that an account has a specific role. Reverts\\n * with a standardized message including the required role.\\n *\\n * The format of the revert reason is given by the following regular expression:\\n *\\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\\n *\\n * _Available since v4.1._\\n */\\n modifier onlyRole(bytes32 role) {\\n _checkRole(role);\\n _;\\n }\\n\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\\n }\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\\n return _roles[role].members[account];\\n }\\n\\n /**\\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\\n * Overriding this function changes the behavior of the {onlyRole} modifier.\\n *\\n * Format of the revert message is described in {_checkRole}.\\n *\\n * _Available since v4.6._\\n */\\n function _checkRole(bytes32 role) internal view virtual {\\n _checkRole(role, _msgSender());\\n }\\n\\n /**\\n * @dev Revert with a standard message if `account` is missing `role`.\\n *\\n * The format of the revert reason is given by the following regular expression:\\n *\\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\\n */\\n function _checkRole(bytes32 role, address account) internal view virtual {\\n if (!hasRole(role, account)) {\\n revert(\\n string(\\n abi.encodePacked(\\n \\\"AccessControl: account \\\",\\n Strings.toHexString(uint160(account), 20),\\n \\\" is missing role \\\",\\n Strings.toHexString(uint256(role), 32)\\n )\\n )\\n );\\n }\\n }\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\\n return _roles[role].adminRole;\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n */\\n function renounceRole(bytes32 role, address account) public virtual override {\\n require(account == _msgSender(), \\\"AccessControl: can only renounce roles for self\\\");\\n\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event. Note that unlike {grantRole}, this function doesn't perform any\\n * checks on the calling account.\\n *\\n * [WARNING]\\n * ====\\n * This function should only be called from the constructor when setting\\n * up the initial roles for the system.\\n *\\n * Using this function in any other way is effectively circumventing the admin\\n * system imposed by {AccessControl}.\\n * ====\\n *\\n * NOTE: This function is deprecated in favor of {_grantRole}.\\n */\\n function _setupRole(bytes32 role, address account) internal virtual {\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Sets `adminRole` as ``role``'s admin role.\\n *\\n * Emits a {RoleAdminChanged} event.\\n */\\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\\n bytes32 previousAdminRole = getRoleAdmin(role);\\n _roles[role].adminRole = adminRole;\\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * Internal function without access restriction.\\n */\\n function _grantRole(bytes32 role, address account) internal virtual {\\n if (!hasRole(role, account)) {\\n _roles[role].members[account] = true;\\n emit RoleGranted(role, account, _msgSender());\\n }\\n }\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * Internal function without access restriction.\\n */\\n function _revokeRole(bytes32 role, address account) internal virtual {\\n if (hasRole(role, account)) {\\n _roles[role].members[account] = false;\\n emit RoleRevoked(role, account, _msgSender());\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb4d87ee2ead4bd192b41c128f287d4b7f24b9e0cd740cc9b476881c461286007\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/IAccessControl.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev External interface of AccessControl declared to support ERC165 detection.\\n */\\ninterface IAccessControl {\\n /**\\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\\n *\\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\\n * {RoleAdminChanged} not being emitted signaling this.\\n *\\n * _Available since v3.1._\\n */\\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\\n\\n /**\\n * @dev Emitted when `account` is granted `role`.\\n *\\n * `sender` is the account that originated the contract call, an admin role\\n * bearer except when using {AccessControl-_setupRole}.\\n */\\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Emitted when `account` is revoked `role`.\\n *\\n * `sender` is the account that originated the contract call:\\n * - if using `revokeRole`, it is the admin role bearer\\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\\n */\\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) external view returns (bool);\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function grantRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function revokeRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been granted `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n */\\n function renounceRole(bytes32 role, address account) external;\\n}\\n\",\"keccak256\":\"0x59ce320a585d7e1f163cd70390a0ef2ff9cec832e2aa544293a00692465a7a57\",\"license\":\"MIT\"},\"@openzeppelin/contracts/governance/TimelockController.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (governance/TimelockController.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../access/AccessControl.sol\\\";\\nimport \\\"../token/ERC721/IERC721Receiver.sol\\\";\\nimport \\\"../token/ERC1155/IERC1155Receiver.sol\\\";\\n\\n/**\\n * @dev Contract module which acts as a timelocked controller. When set as the\\n * owner of an `Ownable` smart contract, it enforces a timelock on all\\n * `onlyOwner` maintenance operations. This gives time for users of the\\n * controlled contract to exit before a potentially dangerous maintenance\\n * operation is applied.\\n *\\n * By default, this contract is self administered, meaning administration tasks\\n * have to go through the timelock process. The proposer (resp executor) role\\n * is in charge of proposing (resp executing) operations. A common use case is\\n * to position this {TimelockController} as the owner of a smart contract, with\\n * a multisig or a DAO as the sole proposer.\\n *\\n * _Available since v3.3._\\n */\\ncontract TimelockController is AccessControl, IERC721Receiver, IERC1155Receiver {\\n bytes32 public constant TIMELOCK_ADMIN_ROLE = keccak256(\\\"TIMELOCK_ADMIN_ROLE\\\");\\n bytes32 public constant PROPOSER_ROLE = keccak256(\\\"PROPOSER_ROLE\\\");\\n bytes32 public constant EXECUTOR_ROLE = keccak256(\\\"EXECUTOR_ROLE\\\");\\n bytes32 public constant CANCELLER_ROLE = keccak256(\\\"CANCELLER_ROLE\\\");\\n uint256 internal constant _DONE_TIMESTAMP = uint256(1);\\n\\n mapping(bytes32 => uint256) private _timestamps;\\n uint256 private _minDelay;\\n\\n /**\\n * @dev Emitted when a call is scheduled as part of operation `id`.\\n */\\n event CallScheduled(\\n bytes32 indexed id,\\n uint256 indexed index,\\n address target,\\n uint256 value,\\n bytes data,\\n bytes32 predecessor,\\n uint256 delay\\n );\\n\\n /**\\n * @dev Emitted when a call is performed as part of operation `id`.\\n */\\n event CallExecuted(bytes32 indexed id, uint256 indexed index, address target, uint256 value, bytes data);\\n\\n /**\\n * @dev Emitted when operation `id` is cancelled.\\n */\\n event Cancelled(bytes32 indexed id);\\n\\n /**\\n * @dev Emitted when the minimum delay for future operations is modified.\\n */\\n event MinDelayChange(uint256 oldDuration, uint256 newDuration);\\n\\n /**\\n * @dev Initializes the contract with a given `minDelay`, and a list of\\n * initial proposers and executors. The proposers receive both the\\n * proposer and the canceller role (for backward compatibility). The\\n * executors receive the executor role.\\n *\\n * NOTE: At construction, both the deployer and the timelock itself are\\n * administrators. This helps further configuration of the timelock by the\\n * deployer. After configuration is done, it is recommended that the\\n * deployer renounces its admin position and relies on timelocked\\n * operations to perform future maintenance.\\n */\\n constructor(\\n uint256 minDelay,\\n address[] memory proposers,\\n address[] memory executors\\n ) {\\n _setRoleAdmin(TIMELOCK_ADMIN_ROLE, TIMELOCK_ADMIN_ROLE);\\n _setRoleAdmin(PROPOSER_ROLE, TIMELOCK_ADMIN_ROLE);\\n _setRoleAdmin(EXECUTOR_ROLE, TIMELOCK_ADMIN_ROLE);\\n _setRoleAdmin(CANCELLER_ROLE, TIMELOCK_ADMIN_ROLE);\\n\\n // deployer + self administration\\n _setupRole(TIMELOCK_ADMIN_ROLE, _msgSender());\\n _setupRole(TIMELOCK_ADMIN_ROLE, address(this));\\n\\n // register proposers and cancellers\\n for (uint256 i = 0; i < proposers.length; ++i) {\\n _setupRole(PROPOSER_ROLE, proposers[i]);\\n _setupRole(CANCELLER_ROLE, proposers[i]);\\n }\\n\\n // register executors\\n for (uint256 i = 0; i < executors.length; ++i) {\\n _setupRole(EXECUTOR_ROLE, executors[i]);\\n }\\n\\n _minDelay = minDelay;\\n emit MinDelayChange(0, minDelay);\\n }\\n\\n /**\\n * @dev Modifier to make a function callable only by a certain role. In\\n * addition to checking the sender's role, `address(0)` 's role is also\\n * considered. Granting a role to `address(0)` is equivalent to enabling\\n * this role for everyone.\\n */\\n modifier onlyRoleOrOpenRole(bytes32 role) {\\n if (!hasRole(role, address(0))) {\\n _checkRole(role, _msgSender());\\n }\\n _;\\n }\\n\\n /**\\n * @dev Contract might receive/hold ETH as part of the maintenance process.\\n */\\n receive() external payable {}\\n\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, AccessControl) returns (bool) {\\n return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);\\n }\\n\\n /**\\n * @dev Returns whether an id correspond to a registered operation. This\\n * includes both Pending, Ready and Done operations.\\n */\\n function isOperation(bytes32 id) public view virtual returns (bool pending) {\\n return getTimestamp(id) > 0;\\n }\\n\\n /**\\n * @dev Returns whether an operation is pending or not.\\n */\\n function isOperationPending(bytes32 id) public view virtual returns (bool pending) {\\n return getTimestamp(id) > _DONE_TIMESTAMP;\\n }\\n\\n /**\\n * @dev Returns whether an operation is ready or not.\\n */\\n function isOperationReady(bytes32 id) public view virtual returns (bool ready) {\\n uint256 timestamp = getTimestamp(id);\\n return timestamp > _DONE_TIMESTAMP && timestamp <= block.timestamp;\\n }\\n\\n /**\\n * @dev Returns whether an operation is done or not.\\n */\\n function isOperationDone(bytes32 id) public view virtual returns (bool done) {\\n return getTimestamp(id) == _DONE_TIMESTAMP;\\n }\\n\\n /**\\n * @dev Returns the timestamp at with an operation becomes ready (0 for\\n * unset operations, 1 for done operations).\\n */\\n function getTimestamp(bytes32 id) public view virtual returns (uint256 timestamp) {\\n return _timestamps[id];\\n }\\n\\n /**\\n * @dev Returns the minimum delay for an operation to become valid.\\n *\\n * This value can be changed by executing an operation that calls `updateDelay`.\\n */\\n function getMinDelay() public view virtual returns (uint256 duration) {\\n return _minDelay;\\n }\\n\\n /**\\n * @dev Returns the identifier of an operation containing a single\\n * transaction.\\n */\\n function hashOperation(\\n address target,\\n uint256 value,\\n bytes calldata data,\\n bytes32 predecessor,\\n bytes32 salt\\n ) public pure virtual returns (bytes32 hash) {\\n return keccak256(abi.encode(target, value, data, predecessor, salt));\\n }\\n\\n /**\\n * @dev Returns the identifier of an operation containing a batch of\\n * transactions.\\n */\\n function hashOperationBatch(\\n address[] calldata targets,\\n uint256[] calldata values,\\n bytes[] calldata payloads,\\n bytes32 predecessor,\\n bytes32 salt\\n ) public pure virtual returns (bytes32 hash) {\\n return keccak256(abi.encode(targets, values, payloads, predecessor, salt));\\n }\\n\\n /**\\n * @dev Schedule an operation containing a single transaction.\\n *\\n * Emits a {CallScheduled} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have the 'proposer' role.\\n */\\n function schedule(\\n address target,\\n uint256 value,\\n bytes calldata data,\\n bytes32 predecessor,\\n bytes32 salt,\\n uint256 delay\\n ) public virtual onlyRole(PROPOSER_ROLE) {\\n bytes32 id = hashOperation(target, value, data, predecessor, salt);\\n _schedule(id, delay);\\n emit CallScheduled(id, 0, target, value, data, predecessor, delay);\\n }\\n\\n /**\\n * @dev Schedule an operation containing a batch of transactions.\\n *\\n * Emits one {CallScheduled} event per transaction in the batch.\\n *\\n * Requirements:\\n *\\n * - the caller must have the 'proposer' role.\\n */\\n function scheduleBatch(\\n address[] calldata targets,\\n uint256[] calldata values,\\n bytes[] calldata payloads,\\n bytes32 predecessor,\\n bytes32 salt,\\n uint256 delay\\n ) public virtual onlyRole(PROPOSER_ROLE) {\\n require(targets.length == values.length, \\\"TimelockController: length mismatch\\\");\\n require(targets.length == payloads.length, \\\"TimelockController: length mismatch\\\");\\n\\n bytes32 id = hashOperationBatch(targets, values, payloads, predecessor, salt);\\n _schedule(id, delay);\\n for (uint256 i = 0; i < targets.length; ++i) {\\n emit CallScheduled(id, i, targets[i], values[i], payloads[i], predecessor, delay);\\n }\\n }\\n\\n /**\\n * @dev Schedule an operation that is to becomes valid after a given delay.\\n */\\n function _schedule(bytes32 id, uint256 delay) private {\\n require(!isOperation(id), \\\"TimelockController: operation already scheduled\\\");\\n require(delay >= getMinDelay(), \\\"TimelockController: insufficient delay\\\");\\n _timestamps[id] = block.timestamp + delay;\\n }\\n\\n /**\\n * @dev Cancel an operation.\\n *\\n * Requirements:\\n *\\n * - the caller must have the 'canceller' role.\\n */\\n function cancel(bytes32 id) public virtual onlyRole(CANCELLER_ROLE) {\\n require(isOperationPending(id), \\\"TimelockController: operation cannot be cancelled\\\");\\n delete _timestamps[id];\\n\\n emit Cancelled(id);\\n }\\n\\n /**\\n * @dev Execute an (ready) operation containing a single transaction.\\n *\\n * Emits a {CallExecuted} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have the 'executor' role.\\n */\\n // This function can reenter, but it doesn't pose a risk because _afterCall checks that the proposal is pending,\\n // thus any modifications to the operation during reentrancy should be caught.\\n // slither-disable-next-line reentrancy-eth\\n function execute(\\n address target,\\n uint256 value,\\n bytes calldata data,\\n bytes32 predecessor,\\n bytes32 salt\\n ) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) {\\n bytes32 id = hashOperation(target, value, data, predecessor, salt);\\n _beforeCall(id, predecessor);\\n _call(id, 0, target, value, data);\\n _afterCall(id);\\n }\\n\\n /**\\n * @dev Execute an (ready) operation containing a batch of transactions.\\n *\\n * Emits one {CallExecuted} event per transaction in the batch.\\n *\\n * Requirements:\\n *\\n * - the caller must have the 'executor' role.\\n */\\n function executeBatch(\\n address[] calldata targets,\\n uint256[] calldata values,\\n bytes[] calldata payloads,\\n bytes32 predecessor,\\n bytes32 salt\\n ) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) {\\n require(targets.length == values.length, \\\"TimelockController: length mismatch\\\");\\n require(targets.length == payloads.length, \\\"TimelockController: length mismatch\\\");\\n\\n bytes32 id = hashOperationBatch(targets, values, payloads, predecessor, salt);\\n _beforeCall(id, predecessor);\\n for (uint256 i = 0; i < targets.length; ++i) {\\n _call(id, i, targets[i], values[i], payloads[i]);\\n }\\n _afterCall(id);\\n }\\n\\n /**\\n * @dev Checks before execution of an operation's calls.\\n */\\n function _beforeCall(bytes32 id, bytes32 predecessor) private view {\\n require(isOperationReady(id), \\\"TimelockController: operation is not ready\\\");\\n require(predecessor == bytes32(0) || isOperationDone(predecessor), \\\"TimelockController: missing dependency\\\");\\n }\\n\\n /**\\n * @dev Checks after execution of an operation's calls.\\n */\\n function _afterCall(bytes32 id) private {\\n require(isOperationReady(id), \\\"TimelockController: operation is not ready\\\");\\n _timestamps[id] = _DONE_TIMESTAMP;\\n }\\n\\n /**\\n * @dev Execute an operation's call.\\n *\\n * Emits a {CallExecuted} event.\\n */\\n function _call(\\n bytes32 id,\\n uint256 index,\\n address target,\\n uint256 value,\\n bytes calldata data\\n ) private {\\n (bool success, ) = target.call{value: value}(data);\\n require(success, \\\"TimelockController: underlying transaction reverted\\\");\\n\\n emit CallExecuted(id, index, target, value, data);\\n }\\n\\n /**\\n * @dev Changes the minimum timelock duration for future operations.\\n *\\n * Emits a {MinDelayChange} event.\\n *\\n * Requirements:\\n *\\n * - the caller must be the timelock itself. This can only be achieved by scheduling and later executing\\n * an operation where the timelock is the target and the data is the ABI-encoded call to this function.\\n */\\n function updateDelay(uint256 newDelay) external virtual {\\n require(msg.sender == address(this), \\\"TimelockController: caller must be timelock\\\");\\n emit MinDelayChange(_minDelay, newDelay);\\n _minDelay = newDelay;\\n }\\n\\n /**\\n * @dev See {IERC721Receiver-onERC721Received}.\\n */\\n function onERC721Received(\\n address,\\n address,\\n uint256,\\n bytes memory\\n ) public virtual override returns (bytes4) {\\n return this.onERC721Received.selector;\\n }\\n\\n /**\\n * @dev See {IERC1155Receiver-onERC1155Received}.\\n */\\n function onERC1155Received(\\n address,\\n address,\\n uint256,\\n uint256,\\n bytes memory\\n ) public virtual override returns (bytes4) {\\n return this.onERC1155Received.selector;\\n }\\n\\n /**\\n * @dev See {IERC1155Receiver-onERC1155BatchReceived}.\\n */\\n function onERC1155BatchReceived(\\n address,\\n address,\\n uint256[] memory,\\n uint256[] memory,\\n bytes memory\\n ) public virtual override returns (bytes4) {\\n return this.onERC1155BatchReceived.selector;\\n }\\n}\\n\",\"keccak256\":\"0x7ea1531981766d9a4297f5f2124c7202ec53501f0d692cdcaaf585f6c6cd1977\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165.sol\\\";\\n\\n/**\\n * @dev _Available since v3.1._\\n */\\ninterface IERC1155Receiver is IERC165 {\\n /**\\n * @dev Handles the receipt of a single ERC1155 token type. This function is\\n * called at the end of a `safeTransferFrom` after the balance has been updated.\\n *\\n * NOTE: To accept the transfer, this must return\\n * `bytes4(keccak256(\\\"onERC1155Received(address,address,uint256,uint256,bytes)\\\"))`\\n * (i.e. 0xf23a6e61, or its own function selector).\\n *\\n * @param operator The address which initiated the transfer (i.e. msg.sender)\\n * @param from The address which previously owned the token\\n * @param id The ID of the token being transferred\\n * @param value The amount of tokens being transferred\\n * @param data Additional data with no specified format\\n * @return `bytes4(keccak256(\\\"onERC1155Received(address,address,uint256,uint256,bytes)\\\"))` if transfer is allowed\\n */\\n function onERC1155Received(\\n address operator,\\n address from,\\n uint256 id,\\n uint256 value,\\n bytes calldata data\\n ) external returns (bytes4);\\n\\n /**\\n * @dev Handles the receipt of a multiple ERC1155 token types. This function\\n * is called at the end of a `safeBatchTransferFrom` after the balances have\\n * been updated.\\n *\\n * NOTE: To accept the transfer(s), this must return\\n * `bytes4(keccak256(\\\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\\\"))`\\n * (i.e. 0xbc197c81, or its own function selector).\\n *\\n * @param operator The address which initiated the batch transfer (i.e. msg.sender)\\n * @param from The address which previously owned the token\\n * @param ids An array containing ids of each token being transferred (order and length must match values array)\\n * @param values An array containing amounts of each token being transferred (order and length must match ids array)\\n * @param data Additional data with no specified format\\n * @return `bytes4(keccak256(\\\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\\\"))` if transfer is allowed\\n */\\n function onERC1155BatchReceived(\\n address operator,\\n address from,\\n uint256[] calldata ids,\\n uint256[] calldata values,\\n bytes calldata data\\n ) external returns (bytes4);\\n}\\n\",\"keccak256\":\"0xeb373f1fdc7b755c6a750123a9b9e3a8a02c1470042fd6505d875000a80bde0b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title ERC721 token receiver interface\\n * @dev Interface for any contract that wants to support safeTransfers\\n * from ERC721 asset contracts.\\n */\\ninterface IERC721Receiver {\\n /**\\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\\n * by `operator` from `from`, this function is called.\\n *\\n * It must return its Solidity selector to confirm the token transfer.\\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\\n *\\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\\n */\\n function onERC721Received(\\n address operator,\\n address from,\\n uint256 tokenId,\\n bytes calldata data\\n ) external returns (bytes4);\\n}\\n\",\"keccak256\":\"0xa82b58eca1ee256be466e536706850163d2ec7821945abd6b4778cfb3bee37da\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Strings.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary Strings {\\n bytes16 private constant _HEX_SYMBOLS = \\\"0123456789abcdef\\\";\\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 // Inspired by OraclizeAPI's implementation - MIT licence\\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\\n\\n if (value == 0) {\\n return \\\"0\\\";\\n }\\n uint256 temp = value;\\n uint256 digits;\\n while (temp != 0) {\\n digits++;\\n temp /= 10;\\n }\\n bytes memory buffer = new bytes(digits);\\n while (value != 0) {\\n digits -= 1;\\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\\n value /= 10;\\n }\\n return string(buffer);\\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 if (value == 0) {\\n return \\\"0x00\\\";\\n }\\n uint256 temp = value;\\n uint256 length = 0;\\n while (temp != 0) {\\n length++;\\n temp >>= 8;\\n }\\n return toHexString(value, length);\\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 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_SYMBOLS[value & 0xf];\\n value >>= 4;\\n }\\n require(value == 0, \\\"Strings: hex length insufficient\\\");\\n return string(buffer);\\n }\\n}\\n\",\"keccak256\":\"0x32c202bd28995dd20c4347b7c6467a6d3241c74c8ad3edcbb610cd9205916c45\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/introspection/ERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC165.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC165} interface.\\n *\\n * Contracts that want to implement ERC165 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 *\\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\\n */\\nabstract contract ERC165 is IERC165 {\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n return interfaceId == type(IERC165).interfaceId;\\n }\\n}\\n\",\"keccak256\":\"0xd10975de010d89fd1c78dc5e8a9a7e7f496198085c151648f20cba166b32582b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\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[EIP 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\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x60806040523480156200001157600080fd5b5060405162002b2f38038062002b2f8339810160408190526200003491620003f7565b6200004f60008051602062002aaf833981519152806200021c565b6200007960008051602062002acf83398151915260008051602062002aaf8339815191526200021c565b620000a360008051602062002aef83398151915260008051602062002aaf8339815191526200021c565b620000cd60008051602062002b0f83398151915260008051602062002aaf8339815191526200021c565b620000e860008051602062002aaf8339815191523362000267565b6200010360008051602062002aaf8339815191523062000267565b60005b825181101562000189576200014d60008051602062002acf8339815191528483815181106200013957620001396200046b565b60200260200101516200026760201b60201c565b6200017660008051602062002b0f8339815191528483815181106200013957620001396200046b565b620001818162000481565b905062000106565b5060005b8151811015620001d357620001c060008051602062002aef8339815191528383815181106200013957620001396200046b565b620001cb8162000481565b90506200018d565b5060028390556040805160008152602081018590527f11c24f4ead16507c69ac467fbd5e4eed5fb5c699626d2cc6d66421df253886d5910160405180910390a1505050620004a9565b600082815260208190526040808220600101805490849055905190918391839186917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a4505050565b62000273828262000277565b5050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1662000273576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055620002d33390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b634e487b7160e01b600052604160045260246000fd5b80516001600160a01b03811681146200034557600080fd5b919050565b600082601f8301126200035c57600080fd5b815160206001600160401b03808311156200037b576200037b62000317565b8260051b604051601f19603f83011681018181108482111715620003a357620003a362000317565b604052938452858101830193838101925087851115620003c257600080fd5b83870191505b84821015620003ec57620003dc826200032d565b83529183019190830190620003c8565b979650505050505050565b6000806000606084860312156200040d57600080fd5b835160208501519093506001600160401b03808211156200042d57600080fd5b6200043b878388016200034a565b935060408601519150808211156200045257600080fd5b5062000461868287016200034a565b9150509250925092565b634e487b7160e01b600052603260045260246000fd5b600060018201620004a257634e487b7160e01b600052601160045260246000fd5b5060010190565b6125f680620004b96000396000f3fe6080604052600436106101bb5760003560e01c80638065657f116100ec578063bc197c811161008a578063d547741f11610064578063d547741f146105fd578063e38335e51461061d578063f23a6e6114610630578063f27a0c921461067557600080fd5b8063bc197c811461056b578063c4d252f5146105b0578063d45c4435146105d057600080fd5b806391d14854116100c657806391d14854146104b1578063a217fddf14610502578063b08e51c014610517578063b1c5f4271461054b57600080fd5b80638065657f1461043d5780638f2a0bb01461045d5780638f61f4f51461047d57600080fd5b8063248a9ca31161015957806331d507501161013357806331d50750146103bd57806336568abe146103dd578063584b153e146103fd57806364d623531461041d57600080fd5b8063248a9ca31461033c5780632ab0f5291461036c5780632f2ff15d1461039d57600080fd5b80630d3cf6fc116101955780630d3cf6fc14610260578063134008d31461029457806313bc9f20146102a7578063150b7a02146102c757600080fd5b806301d5062a146101c757806301ffc9a7146101e957806307bd02651461021e57600080fd5b366101c257005b600080fd5b3480156101d357600080fd5b506101e76101e2366004611aae565b61068a565b005b3480156101f557600080fd5b50610209610204366004611b23565b61071f565b60405190151581526020015b60405180910390f35b34801561022a57600080fd5b506102527fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e6381565b604051908152602001610215565b34801561026c57600080fd5b506102527f5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca581565b6101e76102a2366004611b65565b61077b565b3480156102b357600080fd5b506102096102c2366004611bd1565b610836565b3480156102d357600080fd5b5061030b6102e2366004611cf6565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff000000000000000000000000000000000000000000000000000000009091168152602001610215565b34801561034857600080fd5b50610252610357366004611bd1565b60009081526020819052604090206001015490565b34801561037857600080fd5b50610209610387366004611bd1565b6000908152600160208190526040909120541490565b3480156103a957600080fd5b506101e76103b8366004611d5e565b61085c565b3480156103c957600080fd5b506102096103d8366004611bd1565b610886565b3480156103e957600080fd5b506101e76103f8366004611d5e565b61089f565b34801561040957600080fd5b50610209610418366004611bd1565b610957565b34801561042957600080fd5b506101e7610438366004611bd1565b61096d565b34801561044957600080fd5b50610252610458366004611b65565b610a3d565b34801561046957600080fd5b506101e7610478366004611dcf565b610a7c565b34801561048957600080fd5b506102527fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc181565b3480156104bd57600080fd5b506102096104cc366004611d5e565b60009182526020828152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b34801561050e57600080fd5b50610252600081565b34801561052357600080fd5b506102527ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f78381565b34801561055757600080fd5b50610252610566366004611e81565b610cae565b34801561057757600080fd5b5061030b610586366004611faa565b7fbc197c810000000000000000000000000000000000000000000000000000000095945050505050565b3480156105bc57600080fd5b506101e76105cb366004611bd1565b610cf3565b3480156105dc57600080fd5b506102526105eb366004611bd1565b60009081526001602052604090205490565b34801561060957600080fd5b506101e7610618366004611d5e565b610dee565b6101e761062b366004611e81565b610e13565b34801561063c57600080fd5b5061030b61064b366004612054565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b34801561068157600080fd5b50600254610252565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc16106b48161106b565b60006106c4898989898989610a3d565b90506106d08184611078565b6000817f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8b8b8b8b8b8a60405161070c96959493929190612102565b60405180910390a3505050505050505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e00000000000000000000000000000000000000000000000000000000014806107755750610775826111c0565b92915050565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff166107f8576107f88133611257565b6000610808888888888888610a3d565b90506108148185611327565b6108238160008a8a8a8a611464565b61082c816115a9565b5050505050505050565b6000818152600160205260408120546001811180156108555750428111155b9392505050565b6000828152602081905260409020600101546108778161106b565b6108818383611652565b505050565b60008181526001602052604081205481905b1192915050565b73ffffffffffffffffffffffffffffffffffffffff81163314610949576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b6109538282611742565b5050565b6000818152600160208190526040822054610898565b3330146109fc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f54696d656c6f636b436f6e74726f6c6c65723a2063616c6c6572206d7573742060448201527f62652074696d656c6f636b0000000000000000000000000000000000000000006064820152608401610940565b60025460408051918252602082018390527f11c24f4ead16507c69ac467fbd5e4eed5fb5c699626d2cc6d66421df253886d5910160405180910390a1600255565b6000868686868686604051602001610a5a96959493929190612102565b6040516020818303038152906040528051906020012090509695505050505050565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1610aa68161106b565b888714610b35576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f74636800000000000000000000000000000000000000000000000000000000006064820152608401610940565b888514610bc4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f74636800000000000000000000000000000000000000000000000000000000006064820152608401610940565b6000610bd68b8b8b8b8b8b8b8b610cae565b9050610be28184611078565b60005b8a811015610ca05780827f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8e8e85818110610c2257610c2261214d565b9050602002016020810190610c37919061217c565b8d8d86818110610c4957610c4961214d565b905060200201358c8c87818110610c6257610c6261214d565b9050602002810190610c749190612197565b8c8b604051610c8896959493929190612102565b60405180910390a3610c998161222b565b9050610be5565b505050505050505050505050565b60008888888888888888604051602001610ccf989796959493929190612313565b60405160208183030381529060405280519060200120905098975050505050505050565b7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783610d1d8161106b565b610d2682610957565b610db2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20636160448201527f6e6e6f742062652063616e63656c6c65640000000000000000000000000000006064820152608401610940565b6000828152600160205260408082208290555183917fbaa1eb22f2a492ba1a5fea61b8df4d27c6c8b5f3971e63bb58fa14ff72eedb7091a25050565b600082815260208190526040902060010154610e098161106b565b6108818383611742565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff16610e9057610e908133611257565b878614610f1f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f74636800000000000000000000000000000000000000000000000000000000006064820152608401610940565b878414610fae576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f74636800000000000000000000000000000000000000000000000000000000006064820152608401610940565b6000610fc08a8a8a8a8a8a8a8a610cae565b9050610fcc8185611327565b60005b898110156110555761104582828d8d85818110610fee57610fee61214d565b9050602002016020810190611003919061217c565b8c8c868181106110155761101561214d565b905060200201358b8b8781811061102e5761102e61214d565b90506020028101906110409190612197565b611464565b61104e8161222b565b9050610fcf565b5061105f816115a9565b50505050505050505050565b6110758133611257565b50565b61108182610886565b1561110e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20616c60448201527f7265616479207363686564756c656400000000000000000000000000000000006064820152608401610940565b6002548110156111a0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a20696e73756666696369656e7460448201527f2064656c617900000000000000000000000000000000000000000000000000006064820152608401610940565b6111aa81426123e4565b6000928352600160205260409092209190915550565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061077557507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000831614610775565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16610953576112ad8173ffffffffffffffffffffffffffffffffffffffff1660146117f9565b6112b88360206117f9565b6040516020016112c992919061242c565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a0000000000000000000000000000000000000000000000000000000008252610940916004016124ad565b61133082610836565b6113bc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f74207265616479000000000000000000000000000000000000000000006064820152608401610940565b8015806113d85750600081815260016020819052604090912054145b610953576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a206d697373696e67206465706560448201527f6e64656e637900000000000000000000000000000000000000000000000000006064820152608401610940565b60008473ffffffffffffffffffffffffffffffffffffffff1684848460405161148e9291906124fe565b60006040518083038185875af1925050503d80600081146114cb576040519150601f19603f3d011682016040523d82523d6000602084013e6114d0565b606091505b5050905080611561576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603360248201527f54696d656c6f636b436f6e74726f6c6c65723a20756e6465726c79696e67207460448201527f72616e73616374696f6e207265766572746564000000000000000000000000006064820152608401610940565b85877fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b5887878787604051611598949392919061250e565b60405180910390a350505050505050565b6115b281610836565b61163e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f74207265616479000000000000000000000000000000000000000000006064820152608401610940565b600090815260016020819052604090912055565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109535760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556116e43390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16156109535760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6060600061180883600261254e565b6118139060026123e4565b67ffffffffffffffff81111561182b5761182b611bea565b6040519080825280601f01601f191660200182016040528015611855576020820181803683370190505b5090507f30000000000000000000000000000000000000000000000000000000000000008160008151811061188c5761188c61214d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106118ef576118ef61214d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600061192b84600261254e565b6119369060016123e4565b90505b60018111156119d3577f303132333435363738396162636465660000000000000000000000000000000085600f16601081106119775761197761214d565b1a60f81b82828151811061198d5761198d61214d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c936119cc8161258b565b9050611939565b508315610855576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610940565b803573ffffffffffffffffffffffffffffffffffffffff81168114611a6057600080fd5b919050565b60008083601f840112611a7757600080fd5b50813567ffffffffffffffff811115611a8f57600080fd5b602083019150836020828501011115611aa757600080fd5b9250929050565b600080600080600080600060c0888a031215611ac957600080fd5b611ad288611a3c565b965060208801359550604088013567ffffffffffffffff811115611af557600080fd5b611b018a828b01611a65565b989b979a50986060810135976080820135975060a09091013595509350505050565b600060208284031215611b3557600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461085557600080fd5b60008060008060008060a08789031215611b7e57600080fd5b611b8787611a3c565b955060208701359450604087013567ffffffffffffffff811115611baa57600080fd5b611bb689828a01611a65565b979a9699509760608101359660809091013595509350505050565b600060208284031215611be357600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611c6057611c60611bea565b604052919050565b600082601f830112611c7957600080fd5b813567ffffffffffffffff811115611c9357611c93611bea565b611cc460207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611c19565b818152846020838601011115611cd957600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215611d0c57600080fd5b611d1585611a3c565b9350611d2360208601611a3c565b925060408501359150606085013567ffffffffffffffff811115611d4657600080fd5b611d5287828801611c68565b91505092959194509250565b60008060408385031215611d7157600080fd5b82359150611d8160208401611a3c565b90509250929050565b60008083601f840112611d9c57600080fd5b50813567ffffffffffffffff811115611db457600080fd5b6020830191508360208260051b8501011115611aa757600080fd5b600080600080600080600080600060c08a8c031215611ded57600080fd5b893567ffffffffffffffff80821115611e0557600080fd5b611e118d838e01611d8a565b909b50995060208c0135915080821115611e2a57600080fd5b611e368d838e01611d8a565b909950975060408c0135915080821115611e4f57600080fd5b50611e5c8c828d01611d8a565b9a9d999c50979a969997986060880135976080810135975060a0013595509350505050565b60008060008060008060008060a0898b031215611e9d57600080fd5b883567ffffffffffffffff80821115611eb557600080fd5b611ec18c838d01611d8a565b909a50985060208b0135915080821115611eda57600080fd5b611ee68c838d01611d8a565b909850965060408b0135915080821115611eff57600080fd5b50611f0c8b828c01611d8a565b999c989b509699959896976060870135966080013595509350505050565b600082601f830112611f3b57600080fd5b8135602067ffffffffffffffff821115611f5757611f57611bea565b8160051b611f66828201611c19565b9283528481018201928281019087851115611f8057600080fd5b83870192505b84831015611f9f57823582529183019190830190611f86565b979650505050505050565b600080600080600060a08688031215611fc257600080fd5b611fcb86611a3c565b9450611fd960208701611a3c565b9350604086013567ffffffffffffffff80821115611ff657600080fd5b61200289838a01611f2a565b9450606088013591508082111561201857600080fd5b61202489838a01611f2a565b9350608088013591508082111561203a57600080fd5b5061204788828901611c68565b9150509295509295909350565b600080600080600060a0868803121561206c57600080fd5b61207586611a3c565b945061208360208701611a3c565b93506040860135925060608601359150608086013567ffffffffffffffff8111156120ad57600080fd5b61204788828901611c68565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b73ffffffffffffffffffffffffffffffffffffffff8716815285602082015260a06040820152600061213860a0830186886120b9565b60608301949094525060800152949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561218e57600080fd5b61085582611a3c565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126121cc57600080fd5b83018035915067ffffffffffffffff8211156121e757600080fd5b602001915036819003821315611aa757600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361225c5761225c6121fc565b5060010190565b81835260006020808501808196508560051b810191508460005b8781101561230657828403895281357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18836030181126122bc57600080fd5b8701858101903567ffffffffffffffff8111156122d857600080fd5b8036038213156122e757600080fd5b6122f28682846120b9565b9a87019a955050509084019060010161227d565b5091979650505050505050565b60a0808252810188905260008960c08301825b8b8110156123615773ffffffffffffffffffffffffffffffffffffffff61234c84611a3c565b16825260209283019290910190600101612326565b5083810360208501528881527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff89111561239a57600080fd5b8860051b9150818a6020830137818101915050602081016000815260208483030160408501526123cb81888a612263565b6060850196909652505050608001529695505050505050565b600082198211156123f7576123f76121fc565b500190565b60005b838110156124175781810151838201526020016123ff565b83811115612426576000848401525b50505050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516124648160178501602088016123fc565b7f206973206d697373696e6720726f6c652000000000000000000000000000000060179184019182015283516124a18160288401602088016123fc565b01602801949350505050565b60208152600082518060208401526124cc8160408501602087016123fc565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b8183823760009101908152919050565b73ffffffffffffffffffffffffffffffffffffffff851681528360208201526060604082015260006125446060830184866120b9565b9695505050505050565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612586576125866121fc565b500290565b60008161259a5761259a6121fc565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea26469706673582212206c3f14b1a056ea7f0fe0793553971f257bfc9c449371f2593f4b098b3dbe33c964736f6c634300080f00335f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5b09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1d8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e63fd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783", - "deployedBytecode": "0x6080604052600436106101bb5760003560e01c80638065657f116100ec578063bc197c811161008a578063d547741f11610064578063d547741f146105fd578063e38335e51461061d578063f23a6e6114610630578063f27a0c921461067557600080fd5b8063bc197c811461056b578063c4d252f5146105b0578063d45c4435146105d057600080fd5b806391d14854116100c657806391d14854146104b1578063a217fddf14610502578063b08e51c014610517578063b1c5f4271461054b57600080fd5b80638065657f1461043d5780638f2a0bb01461045d5780638f61f4f51461047d57600080fd5b8063248a9ca31161015957806331d507501161013357806331d50750146103bd57806336568abe146103dd578063584b153e146103fd57806364d623531461041d57600080fd5b8063248a9ca31461033c5780632ab0f5291461036c5780632f2ff15d1461039d57600080fd5b80630d3cf6fc116101955780630d3cf6fc14610260578063134008d31461029457806313bc9f20146102a7578063150b7a02146102c757600080fd5b806301d5062a146101c757806301ffc9a7146101e957806307bd02651461021e57600080fd5b366101c257005b600080fd5b3480156101d357600080fd5b506101e76101e2366004611aae565b61068a565b005b3480156101f557600080fd5b50610209610204366004611b23565b61071f565b60405190151581526020015b60405180910390f35b34801561022a57600080fd5b506102527fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e6381565b604051908152602001610215565b34801561026c57600080fd5b506102527f5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca581565b6101e76102a2366004611b65565b61077b565b3480156102b357600080fd5b506102096102c2366004611bd1565b610836565b3480156102d357600080fd5b5061030b6102e2366004611cf6565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff000000000000000000000000000000000000000000000000000000009091168152602001610215565b34801561034857600080fd5b50610252610357366004611bd1565b60009081526020819052604090206001015490565b34801561037857600080fd5b50610209610387366004611bd1565b6000908152600160208190526040909120541490565b3480156103a957600080fd5b506101e76103b8366004611d5e565b61085c565b3480156103c957600080fd5b506102096103d8366004611bd1565b610886565b3480156103e957600080fd5b506101e76103f8366004611d5e565b61089f565b34801561040957600080fd5b50610209610418366004611bd1565b610957565b34801561042957600080fd5b506101e7610438366004611bd1565b61096d565b34801561044957600080fd5b50610252610458366004611b65565b610a3d565b34801561046957600080fd5b506101e7610478366004611dcf565b610a7c565b34801561048957600080fd5b506102527fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc181565b3480156104bd57600080fd5b506102096104cc366004611d5e565b60009182526020828152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b34801561050e57600080fd5b50610252600081565b34801561052357600080fd5b506102527ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f78381565b34801561055757600080fd5b50610252610566366004611e81565b610cae565b34801561057757600080fd5b5061030b610586366004611faa565b7fbc197c810000000000000000000000000000000000000000000000000000000095945050505050565b3480156105bc57600080fd5b506101e76105cb366004611bd1565b610cf3565b3480156105dc57600080fd5b506102526105eb366004611bd1565b60009081526001602052604090205490565b34801561060957600080fd5b506101e7610618366004611d5e565b610dee565b6101e761062b366004611e81565b610e13565b34801561063c57600080fd5b5061030b61064b366004612054565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b34801561068157600080fd5b50600254610252565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc16106b48161106b565b60006106c4898989898989610a3d565b90506106d08184611078565b6000817f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8b8b8b8b8b8a60405161070c96959493929190612102565b60405180910390a3505050505050505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e00000000000000000000000000000000000000000000000000000000014806107755750610775826111c0565b92915050565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff166107f8576107f88133611257565b6000610808888888888888610a3d565b90506108148185611327565b6108238160008a8a8a8a611464565b61082c816115a9565b5050505050505050565b6000818152600160205260408120546001811180156108555750428111155b9392505050565b6000828152602081905260409020600101546108778161106b565b6108818383611652565b505050565b60008181526001602052604081205481905b1192915050565b73ffffffffffffffffffffffffffffffffffffffff81163314610949576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b6109538282611742565b5050565b6000818152600160208190526040822054610898565b3330146109fc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f54696d656c6f636b436f6e74726f6c6c65723a2063616c6c6572206d7573742060448201527f62652074696d656c6f636b0000000000000000000000000000000000000000006064820152608401610940565b60025460408051918252602082018390527f11c24f4ead16507c69ac467fbd5e4eed5fb5c699626d2cc6d66421df253886d5910160405180910390a1600255565b6000868686868686604051602001610a5a96959493929190612102565b6040516020818303038152906040528051906020012090509695505050505050565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1610aa68161106b565b888714610b35576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f74636800000000000000000000000000000000000000000000000000000000006064820152608401610940565b888514610bc4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f74636800000000000000000000000000000000000000000000000000000000006064820152608401610940565b6000610bd68b8b8b8b8b8b8b8b610cae565b9050610be28184611078565b60005b8a811015610ca05780827f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8e8e85818110610c2257610c2261214d565b9050602002016020810190610c37919061217c565b8d8d86818110610c4957610c4961214d565b905060200201358c8c87818110610c6257610c6261214d565b9050602002810190610c749190612197565b8c8b604051610c8896959493929190612102565b60405180910390a3610c998161222b565b9050610be5565b505050505050505050505050565b60008888888888888888604051602001610ccf989796959493929190612313565b60405160208183030381529060405280519060200120905098975050505050505050565b7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783610d1d8161106b565b610d2682610957565b610db2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20636160448201527f6e6e6f742062652063616e63656c6c65640000000000000000000000000000006064820152608401610940565b6000828152600160205260408082208290555183917fbaa1eb22f2a492ba1a5fea61b8df4d27c6c8b5f3971e63bb58fa14ff72eedb7091a25050565b600082815260208190526040902060010154610e098161106b565b6108818383611742565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff16610e9057610e908133611257565b878614610f1f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f74636800000000000000000000000000000000000000000000000000000000006064820152608401610940565b878414610fae576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f74636800000000000000000000000000000000000000000000000000000000006064820152608401610940565b6000610fc08a8a8a8a8a8a8a8a610cae565b9050610fcc8185611327565b60005b898110156110555761104582828d8d85818110610fee57610fee61214d565b9050602002016020810190611003919061217c565b8c8c868181106110155761101561214d565b905060200201358b8b8781811061102e5761102e61214d565b90506020028101906110409190612197565b611464565b61104e8161222b565b9050610fcf565b5061105f816115a9565b50505050505050505050565b6110758133611257565b50565b61108182610886565b1561110e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20616c60448201527f7265616479207363686564756c656400000000000000000000000000000000006064820152608401610940565b6002548110156111a0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a20696e73756666696369656e7460448201527f2064656c617900000000000000000000000000000000000000000000000000006064820152608401610940565b6111aa81426123e4565b6000928352600160205260409092209190915550565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061077557507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000831614610775565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16610953576112ad8173ffffffffffffffffffffffffffffffffffffffff1660146117f9565b6112b88360206117f9565b6040516020016112c992919061242c565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a0000000000000000000000000000000000000000000000000000000008252610940916004016124ad565b61133082610836565b6113bc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f74207265616479000000000000000000000000000000000000000000006064820152608401610940565b8015806113d85750600081815260016020819052604090912054145b610953576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a206d697373696e67206465706560448201527f6e64656e637900000000000000000000000000000000000000000000000000006064820152608401610940565b60008473ffffffffffffffffffffffffffffffffffffffff1684848460405161148e9291906124fe565b60006040518083038185875af1925050503d80600081146114cb576040519150601f19603f3d011682016040523d82523d6000602084013e6114d0565b606091505b5050905080611561576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603360248201527f54696d656c6f636b436f6e74726f6c6c65723a20756e6465726c79696e67207460448201527f72616e73616374696f6e207265766572746564000000000000000000000000006064820152608401610940565b85877fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b5887878787604051611598949392919061250e565b60405180910390a350505050505050565b6115b281610836565b61163e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f74207265616479000000000000000000000000000000000000000000006064820152608401610940565b600090815260016020819052604090912055565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109535760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556116e43390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16156109535760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6060600061180883600261254e565b6118139060026123e4565b67ffffffffffffffff81111561182b5761182b611bea565b6040519080825280601f01601f191660200182016040528015611855576020820181803683370190505b5090507f30000000000000000000000000000000000000000000000000000000000000008160008151811061188c5761188c61214d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106118ef576118ef61214d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600061192b84600261254e565b6119369060016123e4565b90505b60018111156119d3577f303132333435363738396162636465660000000000000000000000000000000085600f16601081106119775761197761214d565b1a60f81b82828151811061198d5761198d61214d565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c936119cc8161258b565b9050611939565b508315610855576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610940565b803573ffffffffffffffffffffffffffffffffffffffff81168114611a6057600080fd5b919050565b60008083601f840112611a7757600080fd5b50813567ffffffffffffffff811115611a8f57600080fd5b602083019150836020828501011115611aa757600080fd5b9250929050565b600080600080600080600060c0888a031215611ac957600080fd5b611ad288611a3c565b965060208801359550604088013567ffffffffffffffff811115611af557600080fd5b611b018a828b01611a65565b989b979a50986060810135976080820135975060a09091013595509350505050565b600060208284031215611b3557600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461085557600080fd5b60008060008060008060a08789031215611b7e57600080fd5b611b8787611a3c565b955060208701359450604087013567ffffffffffffffff811115611baa57600080fd5b611bb689828a01611a65565b979a9699509760608101359660809091013595509350505050565b600060208284031215611be357600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611c6057611c60611bea565b604052919050565b600082601f830112611c7957600080fd5b813567ffffffffffffffff811115611c9357611c93611bea565b611cc460207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611c19565b818152846020838601011115611cd957600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215611d0c57600080fd5b611d1585611a3c565b9350611d2360208601611a3c565b925060408501359150606085013567ffffffffffffffff811115611d4657600080fd5b611d5287828801611c68565b91505092959194509250565b60008060408385031215611d7157600080fd5b82359150611d8160208401611a3c565b90509250929050565b60008083601f840112611d9c57600080fd5b50813567ffffffffffffffff811115611db457600080fd5b6020830191508360208260051b8501011115611aa757600080fd5b600080600080600080600080600060c08a8c031215611ded57600080fd5b893567ffffffffffffffff80821115611e0557600080fd5b611e118d838e01611d8a565b909b50995060208c0135915080821115611e2a57600080fd5b611e368d838e01611d8a565b909950975060408c0135915080821115611e4f57600080fd5b50611e5c8c828d01611d8a565b9a9d999c50979a969997986060880135976080810135975060a0013595509350505050565b60008060008060008060008060a0898b031215611e9d57600080fd5b883567ffffffffffffffff80821115611eb557600080fd5b611ec18c838d01611d8a565b909a50985060208b0135915080821115611eda57600080fd5b611ee68c838d01611d8a565b909850965060408b0135915080821115611eff57600080fd5b50611f0c8b828c01611d8a565b999c989b509699959896976060870135966080013595509350505050565b600082601f830112611f3b57600080fd5b8135602067ffffffffffffffff821115611f5757611f57611bea565b8160051b611f66828201611c19565b9283528481018201928281019087851115611f8057600080fd5b83870192505b84831015611f9f57823582529183019190830190611f86565b979650505050505050565b600080600080600060a08688031215611fc257600080fd5b611fcb86611a3c565b9450611fd960208701611a3c565b9350604086013567ffffffffffffffff80821115611ff657600080fd5b61200289838a01611f2a565b9450606088013591508082111561201857600080fd5b61202489838a01611f2a565b9350608088013591508082111561203a57600080fd5b5061204788828901611c68565b9150509295509295909350565b600080600080600060a0868803121561206c57600080fd5b61207586611a3c565b945061208360208701611a3c565b93506040860135925060608601359150608086013567ffffffffffffffff8111156120ad57600080fd5b61204788828901611c68565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b73ffffffffffffffffffffffffffffffffffffffff8716815285602082015260a06040820152600061213860a0830186886120b9565b60608301949094525060800152949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561218e57600080fd5b61085582611a3c565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126121cc57600080fd5b83018035915067ffffffffffffffff8211156121e757600080fd5b602001915036819003821315611aa757600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361225c5761225c6121fc565b5060010190565b81835260006020808501808196508560051b810191508460005b8781101561230657828403895281357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18836030181126122bc57600080fd5b8701858101903567ffffffffffffffff8111156122d857600080fd5b8036038213156122e757600080fd5b6122f28682846120b9565b9a87019a955050509084019060010161227d565b5091979650505050505050565b60a0808252810188905260008960c08301825b8b8110156123615773ffffffffffffffffffffffffffffffffffffffff61234c84611a3c565b16825260209283019290910190600101612326565b5083810360208501528881527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff89111561239a57600080fd5b8860051b9150818a6020830137818101915050602081016000815260208483030160408501526123cb81888a612263565b6060850196909652505050608001529695505050505050565b600082198211156123f7576123f76121fc565b500190565b60005b838110156124175781810151838201526020016123ff565b83811115612426576000848401525b50505050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516124648160178501602088016123fc565b7f206973206d697373696e6720726f6c652000000000000000000000000000000060179184019182015283516124a18160288401602088016123fc565b01602801949350505050565b60208152600082518060208401526124cc8160408501602087016123fc565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b8183823760009101908152919050565b73ffffffffffffffffffffffffffffffffffffffff851681528360208201526060604082015260006125446060830184866120b9565b9695505050505050565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612586576125866121fc565b500290565b60008161259a5761259a6121fc565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea26469706673582212206c3f14b1a056ea7f0fe0793553971f257bfc9c449371f2593f4b098b3dbe33c964736f6c634300080f0033", - "devdoc": { - "details": "Contract module which acts as a timelocked controller. When set as the owner of an `Ownable` smart contract, it enforces a timelock on all `onlyOwner` maintenance operations. This gives time for users of the controlled contract to exit before a potentially dangerous maintenance operation is applied. By default, this contract is self administered, meaning administration tasks have to go through the timelock process. The proposer (resp executor) role is in charge of proposing (resp executing) operations. A common use case is to position this {TimelockController} as the owner of a smart contract, with a multisig or a DAO as the sole proposer. _Available since v3.3._", - "events": { - "CallExecuted(bytes32,uint256,address,uint256,bytes)": { - "details": "Emitted when a call is performed as part of operation `id`." - }, - "CallScheduled(bytes32,uint256,address,uint256,bytes,bytes32,uint256)": { - "details": "Emitted when a call is scheduled as part of operation `id`." - }, - "Cancelled(bytes32)": { - "details": "Emitted when operation `id` is cancelled." - }, - "MinDelayChange(uint256,uint256)": { - "details": "Emitted when the minimum delay for future operations is modified." - } - }, - "kind": "dev", - "methods": { - "cancel(bytes32)": { - "details": "Cancel an operation. Requirements: - the caller must have the 'canceller' role." - }, - "constructor": { - "details": "Initializes the contract with a given `minDelay`, and a list of initial proposers and executors. The proposers receive both the proposer and the canceller role (for backward compatibility). The executors receive the executor role. NOTE: At construction, both the deployer and the timelock itself are administrators. This helps further configuration of the timelock by the deployer. After configuration is done, it is recommended that the deployer renounces its admin position and relies on timelocked operations to perform future maintenance." - }, - "execute(address,uint256,bytes,bytes32,bytes32)": { - "details": "Execute an (ready) operation containing a single transaction. Emits a {CallExecuted} event. Requirements: - the caller must have the 'executor' role." - }, - "executeBatch(address[],uint256[],bytes[],bytes32,bytes32)": { - "details": "Execute an (ready) operation containing a batch of transactions. Emits one {CallExecuted} event per transaction in the batch. Requirements: - the caller must have the 'executor' role." - }, - "getMinDelay()": { - "details": "Returns the minimum delay for an operation to become valid. This value can be changed by executing an operation that calls `updateDelay`." - }, - "getRoleAdmin(bytes32)": { - "details": "Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}." - }, - "getTimestamp(bytes32)": { - "details": "Returns the timestamp at with an operation becomes ready (0 for unset operations, 1 for done operations)." - }, - "grantRole(bytes32,address)": { - "details": "Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role." - }, - "hasRole(bytes32,address)": { - "details": "Returns `true` if `account` has been granted `role`." - }, - "hashOperation(address,uint256,bytes,bytes32,bytes32)": { - "details": "Returns the identifier of an operation containing a single transaction." - }, - "hashOperationBatch(address[],uint256[],bytes[],bytes32,bytes32)": { - "details": "Returns the identifier of an operation containing a batch of transactions." - }, - "isOperation(bytes32)": { - "details": "Returns whether an id correspond to a registered operation. This includes both Pending, Ready and Done operations." - }, - "isOperationDone(bytes32)": { - "details": "Returns whether an operation is done or not." - }, - "isOperationPending(bytes32)": { - "details": "Returns whether an operation is pending or not." - }, - "isOperationReady(bytes32)": { - "details": "Returns whether an operation is ready or not." - }, - "onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)": { - "details": "See {IERC1155Receiver-onERC1155BatchReceived}." - }, - "onERC1155Received(address,address,uint256,uint256,bytes)": { - "details": "See {IERC1155Receiver-onERC1155Received}." - }, - "onERC721Received(address,address,uint256,bytes)": { - "details": "See {IERC721Receiver-onERC721Received}." - }, - "renounceRole(bytes32,address)": { - "details": "Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `account`." - }, - "revokeRole(bytes32,address)": { - "details": "Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role." - }, - "schedule(address,uint256,bytes,bytes32,bytes32,uint256)": { - "details": "Schedule an operation containing a single transaction. Emits a {CallScheduled} event. Requirements: - the caller must have the 'proposer' role." - }, - "scheduleBatch(address[],uint256[],bytes[],bytes32,bytes32,uint256)": { - "details": "Schedule an operation containing a batch of transactions. Emits one {CallScheduled} event per transaction in the batch. Requirements: - the caller must have the 'proposer' role." - }, - "supportsInterface(bytes4)": { - "details": "See {IERC165-supportsInterface}." - }, - "updateDelay(uint256)": { - "details": "Changes the minimum timelock duration for future operations. Emits a {MinDelayChange} event. Requirements: - the caller must be the timelock itself. This can only be achieved by scheduling and later executing an operation where the timelock is the target and the data is the ABI-encoded call to this function." - } - }, - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": {}, - "version": 1 - }, - "storageLayout": { - "storage": [ - { - "astId": 4890, - "contract": "@openzeppelin/contracts/governance/TimelockController.sol:TimelockController", - "label": "_roles", - "offset": 0, - "slot": "0", - "type": "t_mapping(t_bytes32,t_struct(RoleData)4885_storage)" - }, - { - "astId": 5555, - "contract": "@openzeppelin/contracts/governance/TimelockController.sol:TimelockController", - "label": "_timestamps", - "offset": 0, - "slot": "1", - "type": "t_mapping(t_bytes32,t_uint256)" - }, - { - "astId": 5557, - "contract": "@openzeppelin/contracts/governance/TimelockController.sol:TimelockController", - "label": "_minDelay", - "offset": 0, - "slot": "2", - "type": "t_uint256" - } - ], - "types": { - "t_address": { - "encoding": "inplace", - "label": "address", - "numberOfBytes": "20" - }, - "t_bool": { - "encoding": "inplace", - "label": "bool", - "numberOfBytes": "1" - }, - "t_bytes32": { - "encoding": "inplace", - "label": "bytes32", - "numberOfBytes": "32" - }, - "t_mapping(t_address,t_bool)": { - "encoding": "mapping", - "key": "t_address", - "label": "mapping(address => bool)", - "numberOfBytes": "32", - "value": "t_bool" - }, - "t_mapping(t_bytes32,t_struct(RoleData)4885_storage)": { - "encoding": "mapping", - "key": "t_bytes32", - "label": "mapping(bytes32 => struct AccessControl.RoleData)", - "numberOfBytes": "32", - "value": "t_struct(RoleData)4885_storage" - }, - "t_mapping(t_bytes32,t_uint256)": { - "encoding": "mapping", - "key": "t_bytes32", - "label": "mapping(bytes32 => uint256)", - "numberOfBytes": "32", - "value": "t_uint256" - }, - "t_struct(RoleData)4885_storage": { - "encoding": "inplace", - "label": "struct AccessControl.RoleData", - "members": [ - { - "astId": 4882, - "contract": "@openzeppelin/contracts/governance/TimelockController.sol:TimelockController", - "label": "members", - "offset": 0, - "slot": "0", - "type": "t_mapping(t_address,t_bool)" - }, - { - "astId": 4884, - "contract": "@openzeppelin/contracts/governance/TimelockController.sol:TimelockController", - "label": "adminRole", - "offset": 0, - "slot": "1", - "type": "t_bytes32" - } - ], - "numberOfBytes": "64" - }, - "t_uint256": { - "encoding": "inplace", - "label": "uint256", - "numberOfBytes": "32" - } - } - } -} diff --git a/packages/perennial/deployments/kovan/UpgradeableBeacon.json b/packages/perennial/deployments/kovan/UpgradeableBeacon.json deleted file mode 100644 index 9b2a2e375..000000000 --- a/packages/perennial/deployments/kovan/UpgradeableBeacon.json +++ /dev/null @@ -1,206 +0,0 @@ -{ - "address": "0x1C521Cd674222699520613D599F5e54F272b9972", - "abi": [ - { - "inputs": [ - { - "internalType": "address", - "name": "implementation_", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "implementation", - "type": "address" - } - ], - "name": "Upgraded", - "type": "event" - }, - { - "inputs": [], - "name": "implementation", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newImplementation", - "type": "address" - } - ], - "name": "upgradeTo", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } - ], - "transactionHash": "0x3010d8000807f8b486c1b112defd08769cd6d835093c39d6288985fabee31f03", - "receipt": { - "to": null, - "from": "0x66a7fDB96C583c59597de16d8b2B989231415339", - "contractAddress": "0x1C521Cd674222699520613D599F5e54F272b9972", - "transactionIndex": 1, - "gasUsed": "408807", - "logsBloom": "0x00000000000000000000000000000100000000000000000000800000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000020000000000000000000800000040000000000000000000000000400000000000000000400000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000020000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xa17436a6d7ecf210eba4edda4a13c6cb4d7f5186d4206cff4874b2218ff93521", - "transactionHash": "0x3010d8000807f8b486c1b112defd08769cd6d835093c39d6288985fabee31f03", - "logs": [ - { - "transactionIndex": 1, - "blockNumber": 33203739, - "transactionHash": "0x3010d8000807f8b486c1b112defd08769cd6d835093c39d6288985fabee31f03", - "address": "0x1C521Cd674222699520613D599F5e54F272b9972", - "topics": [ - "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x00000000000000000000000066a7fdb96c583c59597de16d8b2b989231415339" - ], - "data": "0x", - "logIndex": 4, - "blockHash": "0xa17436a6d7ecf210eba4edda4a13c6cb4d7f5186d4206cff4874b2218ff93521" - } - ], - "blockNumber": 33203739, - "cumulativeGasUsed": "550201", - "status": 1, - "byzantium": true - }, - "args": ["0x2C19eac953048801FfE1358D109A1Ac2aF7930fD"], - "numDeployments": 1, - "solcInputHash": "dd52f03d8fef7833844e4ba864fd9fba", - "metadata": "{\"compiler\":{\"version\":\"0.8.15+commit.e14f2714\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their implementation contract, which is where they will delegate all function calls. An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.\",\"events\":{\"Upgraded(address)\":{\"details\":\"Emitted when the implementation returned by the beacon is changed.\"}},\"kind\":\"dev\",\"methods\":{\"constructor\":{\"details\":\"Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the beacon.\"},\"implementation()\":{\"details\":\"Returns the current implementation address.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"upgradeTo(address)\":{\"details\":\"Upgrades the beacon to a new implementation. Emits an {Upgraded} event. Requirements: - msg.sender must be the owner of the contract. - `newImplementation` must be a contract.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol\":\"UpgradeableBeacon\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0x24e0364e503a9bbde94c715d26573a76f14cd2a202d45f96f52134ab806b67b9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/UpgradeableBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IBeacon.sol\\\";\\nimport \\\"../../access/Ownable.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\n\\n/**\\n * @dev This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their\\n * implementation contract, which is where they will delegate all function calls.\\n *\\n * An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.\\n */\\ncontract UpgradeableBeacon is IBeacon, Ownable {\\n address private _implementation;\\n\\n /**\\n * @dev Emitted when the implementation returned by the beacon is changed.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the\\n * beacon.\\n */\\n constructor(address implementation_) {\\n _setImplementation(implementation_);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function implementation() public view virtual override returns (address) {\\n return _implementation;\\n }\\n\\n /**\\n * @dev Upgrades the beacon to a new implementation.\\n *\\n * Emits an {Upgraded} event.\\n *\\n * Requirements:\\n *\\n * - msg.sender must be the owner of the contract.\\n * - `newImplementation` must be a contract.\\n */\\n function upgradeTo(address newImplementation) public virtual onlyOwner {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Sets the implementation contract address for this beacon\\n *\\n * Requirements:\\n *\\n * - `newImplementation` must be a contract.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"UpgradeableBeacon: implementation is not a contract\\\");\\n _implementation = newImplementation;\\n }\\n}\\n\",\"keccak256\":\"0x6ec71aef5659f3f74011169948d2fcda8c6599be5bb38f986380a8737f96cc0f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // 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\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x608060405234801561001057600080fd5b5060405161070c38038061070c83398101604081905261002f91610151565b61003833610047565b61004181610097565b50610181565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6100aa8161014260201b61038d1760201c565b6101205760405162461bcd60e51b815260206004820152603360248201527f5570677261646561626c65426561636f6e3a20696d706c656d656e746174696f60448201527f6e206973206e6f74206120636f6e747261637400000000000000000000000000606482015260840160405180910390fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b03163b151590565b60006020828403121561016357600080fd5b81516001600160a01b038116811461017a57600080fd5b9392505050565b61057c806101906000396000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c8063715018a611610050578063715018a6146100c45780638da5cb5b146100cc578063f2fde38b146100ea57600080fd5b80633659cfe61461006c5780635c60da1b14610081575b600080fd5b61007f61007a366004610509565b6100fd565b005b60015473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61007f6101d0565b60005473ffffffffffffffffffffffffffffffffffffffff1661009b565b61007f6100f8366004610509565b61025d565b60005473ffffffffffffffffffffffffffffffffffffffff163314610183576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b61018c816103a9565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60005473ffffffffffffffffffffffffffffffffffffffff163314610251576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161017a565b61025b6000610494565b565b60005473ffffffffffffffffffffffffffffffffffffffff1633146102de576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161017a565b73ffffffffffffffffffffffffffffffffffffffff8116610381576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161017a565b61038a81610494565b50565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b73ffffffffffffffffffffffffffffffffffffffff81163b61044d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603360248201527f5570677261646561626c65426561636f6e3a20696d706c656d656e746174696f60448201527f6e206973206e6f74206120636f6e747261637400000000000000000000000000606482015260840161017a565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121561051b57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff8116811461053f57600080fd5b939250505056fea2646970667358221220995a0ae0cf04f45364a4a2b63c87f7425d2b95e4f2c42bacf4f6d33339c80e7764736f6c634300080f0033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100675760003560e01c8063715018a611610050578063715018a6146100c45780638da5cb5b146100cc578063f2fde38b146100ea57600080fd5b80633659cfe61461006c5780635c60da1b14610081575b600080fd5b61007f61007a366004610509565b6100fd565b005b60015473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61007f6101d0565b60005473ffffffffffffffffffffffffffffffffffffffff1661009b565b61007f6100f8366004610509565b61025d565b60005473ffffffffffffffffffffffffffffffffffffffff163314610183576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b61018c816103a9565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60005473ffffffffffffffffffffffffffffffffffffffff163314610251576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161017a565b61025b6000610494565b565b60005473ffffffffffffffffffffffffffffffffffffffff1633146102de576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161017a565b73ffffffffffffffffffffffffffffffffffffffff8116610381576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161017a565b61038a81610494565b50565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b73ffffffffffffffffffffffffffffffffffffffff81163b61044d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603360248201527f5570677261646561626c65426561636f6e3a20696d706c656d656e746174696f60448201527f6e206973206e6f74206120636f6e747261637400000000000000000000000000606482015260840161017a565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121561051b57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff8116811461053f57600080fd5b939250505056fea2646970667358221220995a0ae0cf04f45364a4a2b63c87f7425d2b95e4f2c42bacf4f6d33339c80e7764736f6c634300080f0033", - "devdoc": { - "details": "This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their implementation contract, which is where they will delegate all function calls. An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.", - "events": { - "Upgraded(address)": { - "details": "Emitted when the implementation returned by the beacon is changed." - } - }, - "kind": "dev", - "methods": { - "constructor": { - "details": "Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the beacon." - }, - "implementation()": { - "details": "Returns the current implementation address." - }, - "owner()": { - "details": "Returns the address of the current owner." - }, - "renounceOwnership()": { - "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." - }, - "transferOwnership(address)": { - "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." - }, - "upgradeTo(address)": { - "details": "Upgrades the beacon to a new implementation. Emits an {Upgraded} event. Requirements: - msg.sender must be the owner of the contract. - `newImplementation` must be a contract." - } - }, - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": {}, - "version": 1 - }, - "storageLayout": { - "storage": [ - { - "astId": 5416, - "contract": "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol:UpgradeableBeacon", - "label": "_owner", - "offset": 0, - "slot": "0", - "type": "t_address" - }, - { - "astId": 6942, - "contract": "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol:UpgradeableBeacon", - "label": "_implementation", - "offset": 0, - "slot": "1", - "type": "t_address" - } - ], - "types": { - "t_address": { - "encoding": "inplace", - "label": "address", - "numberOfBytes": "20" - } - } - } -} diff --git a/packages/perennial/deployments/kovan/solcInputs/40214df36850e11c061b57b4ce3f83e9.json b/packages/perennial/deployments/kovan/solcInputs/40214df36850e11c061b57b4ce3f83e9.json deleted file mode 100644 index ecbecd14b..000000000 --- a/packages/perennial/deployments/kovan/solcInputs/40214df36850e11c061b57b4ce3f83e9.json +++ /dev/null @@ -1,137 +0,0 @@ -{ - "language": "Solidity", - "sources": { - "contracts/product/Product.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/root/control/unstructured/UInitializable.sol\";\nimport \"@equilibria/root/control/unstructured/UReentrancyGuard.sol\";\nimport \"../controller/UControllerProvider.sol\";\nimport \"./UPayoffProvider.sol\";\nimport \"./UParamProvider.sol\";\nimport \"./types/position/AccountPosition.sol\";\nimport \"./types/accumulator/AccountAccumulator.sol\";\n\n/**\n * @title Product\n * @notice Manages logic and state for a single product market.\n * @dev Cloned by the Controller contract to launch new product markets.\n */\ncontract Product is IProduct, UInitializable, UParamProvider, UPayoffProvider, UReentrancyGuard {\n /// @dev Whether or not the product is closed\n BoolStorage private constant _closed =\n BoolStorage.wrap(keccak256(\"equilibria.perennial.Product.closed\"));\n function closed() public view returns (bool) { return _closed.read(); }\n\n\n /// @dev The name of the product\n string public name;\n\n /// @dev The symbol of the product\n string public symbol;\n\n /// @dev The individual position state for each account\n mapping(address => AccountPosition) private _positions;\n\n /// @dev The global position state for the product\n VersionedPosition private _position;\n\n /// @dev The individual accumulator state for each account\n mapping(address => AccountAccumulator) private _accumulators;\n\n /// @dev The global accumulator state for the product\n VersionedAccumulator private _accumulator;\n\n /**\n * @notice Initializes the contract state\n * @param productInfo_ Product initialization params\n */\n function initialize(ProductInfo calldata productInfo_) external initializer(1) {\n __UControllerProvider__initialize(IController(msg.sender));\n __UPayoffProvider__initialize(productInfo_.oracle, productInfo_.payoffDefinition);\n __UReentrancyGuard__initialize();\n __UParamProvider__initialize(\n productInfo_.maintenance,\n productInfo_.fundingFee,\n productInfo_.makerFee,\n productInfo_.takerFee,\n productInfo_.makerLimit,\n productInfo_.utilizationCurve\n );\n\n name = productInfo_.name;\n symbol = productInfo_.symbol;\n }\n\n /**\n * @notice Surfaces global settlement externally\n */\n function settle() external nonReentrant notPaused {\n _settle();\n }\n\n /**\n * @notice Core global settlement flywheel\n * @dev\n * a) last settle oracle version\n * b) latest pre position oracle version\n * c) current oracle version\n *\n * Settles from a->b then from b->c if either interval is non-zero to account for a change\n * in position quantity at (b).\n *\n * Syncs each to instantaneously after the oracle update.\n */\n function _settle() private returns (IOracleProvider.OracleVersion memory currentOracleVersion) {\n IController _controller = controller();\n\n // Get current oracle version\n currentOracleVersion = _sync();\n\n // Get latest oracle version\n uint256 _latestVersion = latestVersion();\n if (_latestVersion == currentOracleVersion.version) return currentOracleVersion; // short circuit entirely if a == c\n IOracleProvider.OracleVersion memory latestOracleVersion = atVersion(_latestVersion);\n\n // Get settle oracle version\n uint256 _settleVersion = _position.pre.settleVersion(currentOracleVersion.version);\n IOracleProvider.OracleVersion memory settleOracleVersion = _settleVersion == currentOracleVersion.version ?\n currentOracleVersion : // if b == c, don't re-call provider for oracle version\n atVersion(_settleVersion);\n\n // Initiate\n _controller.incentivizer().sync(currentOracleVersion);\n UFixed18 boundedFundingFee = _boundedFundingFee();\n UFixed18 accumulatedFee;\n\n // value a->b\n accumulatedFee = accumulatedFee.add(\n _accumulator.accumulate(boundedFundingFee, _position, latestOracleVersion, settleOracleVersion)\n );\n\n // position a->b\n accumulatedFee = accumulatedFee.add(_position.settle(_latestVersion, settleOracleVersion));\n\n // short-circuit from a->c if b == c\n if (settleOracleVersion.version != currentOracleVersion.version) {\n\n // value b->c\n accumulatedFee = accumulatedFee.add(\n _accumulator.accumulate(boundedFundingFee, _position, settleOracleVersion, currentOracleVersion)\n );\n\n // position b->c (every accumulator version needs a position stamp)\n _position.settle(settleOracleVersion.version, currentOracleVersion);\n }\n\n // settle collateral\n _controller.collateral().settleProduct(accumulatedFee);\n\n emit Settle(settleOracleVersion.version, currentOracleVersion.version);\n }\n\n /**\n * @notice Surfaces account settlement externally\n * @param account Account to settle\n */\n function settleAccount(address account) external nonReentrant notPaused {\n IOracleProvider.OracleVersion memory currentOracleVersion = _settle();\n _settleAccount(account, currentOracleVersion);\n }\n\n /**\n * @notice Core account settlement flywheel\n * @param account Account to settle\n * @dev\n * a) last settle oracle version\n * b) latest pre position oracle version\n * c) current oracle version\n *\n * Settles from a->b then from b->c if either interval is non-zero to account for a change\n * in position quantity at (b).\n *\n * Syncs each to instantaneously after the oracle update.\n */\n function _settleAccount(address account, IOracleProvider.OracleVersion memory currentOracleVersion) private {\n IController _controller = controller();\n\n // Get latest oracle version\n if (latestVersion(account) == currentOracleVersion.version) return; // short circuit entirely if a == c\n\n // Get settle oracle version\n uint256 _settleVersion = _positions[account].pre.settleVersion(currentOracleVersion.version);\n IOracleProvider.OracleVersion memory settleOracleVersion = _settleVersion == currentOracleVersion.version ?\n currentOracleVersion : // if b == c, don't re-call provider for oracle version\n atVersion(_settleVersion);\n\n // initialize\n Fixed18 accumulated;\n\n // sync incentivizer before accumulator\n _controller.incentivizer().syncAccount(account, settleOracleVersion);\n\n // value a->b\n accumulated = accumulated.add(\n _accumulators[account].syncTo(_accumulator, _positions[account], settleOracleVersion.version).sum());\n\n // position a->b\n accumulated = accumulated.sub(Fixed18Lib.from(_positions[account].settle(settleOracleVersion)));\n\n // short-circuit from a->c if b == c\n if (settleOracleVersion.version != currentOracleVersion.version) {\n // sync incentivizer before accumulator\n _controller.incentivizer().syncAccount(account, currentOracleVersion);\n\n // value b->c\n accumulated = accumulated.add(\n _accumulators[account].syncTo(_accumulator, _positions[account], currentOracleVersion.version).sum());\n }\n\n // settle collateral\n _controller.collateral().settleAccount(account, accumulated);\n\n emit AccountSettle(account, settleOracleVersion.version, currentOracleVersion.version);\n }\n\n /**\n * @notice Opens a taker position for `msg.sender`\n * @param amount Amount of the position to open\n */\n function openTake(UFixed18 amount)\n external\n nonReentrant\n notPaused\n notClosed\n settleForAccount(msg.sender)\n takerInvariant\n positionInvariant\n liquidationInvariant\n maintenanceInvariant\n {\n uint256 _latestVersion = latestVersion();\n\n _positions[msg.sender].pre.openTake(_latestVersion, amount);\n _position.pre.openTake(_latestVersion, amount);\n\n emit TakeOpened(msg.sender, _latestVersion, amount);\n }\n\n /**\n * @notice Closes a taker position for `msg.sender`\n * @param amount Amount of the position to close\n */\n function closeTake(UFixed18 amount)\n external\n nonReentrant\n notPaused\n settleForAccount(msg.sender)\n closeInvariant\n liquidationInvariant\n {\n _closeTake(msg.sender, amount);\n }\n\n function _closeTake(address account, UFixed18 amount) private {\n uint256 _latestVersion = latestVersion();\n\n _positions[account].pre.closeTake(_latestVersion, amount);\n _position.pre.closeTake(_latestVersion, amount);\n\n emit TakeClosed(account, _latestVersion, amount);\n }\n\n /**\n * @notice Opens a maker position for `msg.sender`\n * @param amount Amount of the position to open\n */\n function openMake(UFixed18 amount)\n external\n nonReentrant\n notPaused\n notClosed\n settleForAccount(msg.sender)\n nonZeroVersionInvariant\n makerInvariant\n positionInvariant\n liquidationInvariant\n maintenanceInvariant\n {\n uint256 _latestVersion = latestVersion();\n\n _positions[msg.sender].pre.openMake(_latestVersion, amount);\n _position.pre.openMake(_latestVersion, amount);\n\n emit MakeOpened(msg.sender, _latestVersion, amount);\n }\n\n /**\n * @notice Closes a maker position for `msg.sender`\n * @param amount Amount of the position to close\n */\n function closeMake(UFixed18 amount)\n external\n nonReentrant\n notPaused\n settleForAccount(msg.sender)\n takerInvariant\n closeInvariant\n liquidationInvariant\n {\n _closeMake(msg.sender, amount);\n }\n\n function _closeMake(address account, UFixed18 amount) private {\n uint256 _latestVersion = latestVersion();\n\n _positions[account].pre.closeMake(_latestVersion, amount);\n _position.pre.closeMake(_latestVersion, amount);\n\n emit MakeClosed(account, _latestVersion, amount);\n }\n\n /**\n * @notice Closes all open and pending positions, locking for liquidation\n * @dev Only callable by the Collateral contract as part of the liquidation flow\n * @param account Account to close out\n */\n function closeAll(address account) external onlyCollateral notClosed settleForAccount(account) {\n AccountPosition storage accountPosition = _positions[account];\n Position memory p = accountPosition.position.next(_positions[account].pre);\n\n // Close all positions\n _closeMake(account, p.maker);\n _closeTake(account, p.taker);\n\n // Mark liquidation to lock position\n accountPosition.liquidation = true;\n }\n\n /**\n * @notice Returns the maintenance requirement for `account`\n * @param account Account to return for\n * @return The current maintenance requirement\n */\n function maintenance(address account) external view returns (UFixed18) {\n return _positions[account].maintenance();\n }\n\n /**\n * @notice Returns the maintenance requirement for `account` after next settlement\n * @dev Assumes no price change and no funding, used to protect user from over-opening\n * @param account Account to return for\n * @return The next maintenance requirement\n */\n function maintenanceNext(address account) external view returns (UFixed18) {\n return _positions[account].maintenanceNext();\n }\n\n /**\n * @notice Returns whether `account` has a completely zero'd position\n * @param account Account to return for\n * @return The the account is closed\n */\n function isClosed(address account) external view returns (bool) {\n return _positions[account].isClosed();\n }\n\n /**\n * @notice Returns whether `account` is currently locked for an in-progress liquidation\n * @param account Account to return for\n * @return Whether the account is in liquidation\n */\n function isLiquidating(address account) external view returns (bool) {\n return _positions[account].liquidation;\n }\n\n /**\n * @notice Returns `account`'s current position\n * @param account Account to return for\n * @return Current position of the account\n */\n function position(address account) external view returns (Position memory) {\n return _positions[account].position;\n }\n\n /**\n * @notice Returns `account`'s current pending-settlement position\n * @param account Account to return for\n * @return Current pre-position of the account\n */\n function pre(address account) external view returns (PrePosition memory) {\n return _positions[account].pre;\n }\n\n /**\n * @notice Returns the global latest settled oracle version\n * @return Latest settled oracle version of the product\n */\n function latestVersion() public view returns (uint256) {\n return _accumulator.latestVersion;\n }\n\n /**\n * @notice Returns the global position at oracleVersion `oracleVersion`\n * @dev Only valid for the version at which a global settlement occurred\n * @param oracleVersion Oracle version to return for\n * @return Global position at oracle version\n */\n function positionAtVersion(uint256 oracleVersion) public view returns (Position memory) {\n return _position.positionAtVersion(oracleVersion);\n }\n\n /**\n * @notice Returns the current global pending-settlement position\n * @return Global pending-settlement position\n */\n function pre() external view returns (PrePosition memory) {\n return _position.pre;\n }\n\n /**\n * @notice Returns the global accumulator value at oracleVersion `oracleVersion`\n * @dev Only valid for the version at which a global settlement occurred\n * @param oracleVersion Oracle version to return for\n * @return Global accumulator value at oracle version\n */\n function valueAtVersion(uint256 oracleVersion) external view returns (Accumulator memory) {\n return _accumulator.valueAtVersion(oracleVersion);\n }\n\n /**\n * @notice Returns the global accumulator share at oracleVersion `oracleVersion`\n * @dev Only valid for the version at which a global settlement occurred\n * @param oracleVersion Oracle version to return for\n * @return Global accumulator share at oracle version\n */\n function shareAtVersion(uint256 oracleVersion) external view returns (Accumulator memory) {\n return _accumulator.shareAtVersion(oracleVersion);\n }\n\n /**\n * @notice Returns `account`'s latest settled oracle version\n * @param account Account to return for\n * @return Latest settled oracle version of the account\n */\n function latestVersion(address account) public view returns (uint256) {\n return _accumulators[account].latestVersion;\n }\n\n /**\n * @notice Returns The per-second rate based on the provided `position`\n * @dev Handles 0-maker/taker edge cases\n * @param position_ Position to base utilization on\n * @return The per-second rate\n */\n function rate(Position calldata position_) public view returns (Fixed18) {\n UFixed18 utilization = position_.taker.unsafeDiv(position_.maker);\n Fixed18 annualizedRate = utilizationCurve().compute(utilization);\n return annualizedRate.div(Fixed18Lib.from(365 days));\n }\n\n /**\n * @notice Returns the minimum funding fee parameter with a capped range for safety\n * @dev Caps controller.minFundingFee() <= fundingFee() <= 1\n * @return Safe minimum funding fee parameter\n */\n function _boundedFundingFee() private view returns (UFixed18) {\n return fundingFee().max(controller().minFundingFee());\n }\n\n /**\n * @notice Updates product closed state\n * @dev only callable by product owner. Settles the product before flipping the flag\n * @param newClosed new closed value\n */\n function updateClosed(bool newClosed) external onlyProductOwner {\n IOracleProvider.OracleVersion memory oracleVersion = _settle();\n _closed.store(newClosed);\n emit ClosedUpdated(newClosed, oracleVersion.version);\n }\n\n /// @dev Limit total maker for guarded rollouts\n modifier makerInvariant {\n _;\n\n Position memory next = positionAtVersion(latestVersion()).next(_position.pre);\n\n if (next.maker.gt(makerLimit())) revert ProductMakerOverLimitError();\n }\n\n /// @dev Limit maker short exposure to the range 0.0-1.0x of their position. Does not apply when in closeOnly state\n modifier takerInvariant {\n _;\n\n if (closed()) return;\n\n Position memory next = positionAtVersion(latestVersion()).next(_position.pre);\n UFixed18 socializationFactor = next.socializationFactor();\n\n if (socializationFactor.lt(UFixed18Lib.ONE)) revert ProductInsufficientLiquidityError(socializationFactor);\n }\n\n /// @dev Ensure that the user has only taken a maker or taker position, but not both\n modifier positionInvariant {\n _;\n\n if (_positions[msg.sender].isDoubleSided()) revert ProductDoubleSidedError();\n }\n\n /// @dev Ensure that the user hasn't closed more than is open\n modifier closeInvariant {\n _;\n\n if (_positions[msg.sender].isOverClosed()) revert ProductOverClosedError();\n }\n\n /// @dev Ensure that the user will have sufficient margin for maintenance after next settlement\n modifier maintenanceInvariant {\n _;\n\n if (controller().collateral().liquidatableNext(msg.sender, IProduct(this)))\n revert ProductInsufficientCollateralError();\n }\n\n /// @dev Ensure that the user is not currently being liquidated\n modifier liquidationInvariant {\n if (_positions[msg.sender].liquidation) revert ProductInLiquidationError();\n\n _;\n }\n\n /// @dev Helper to fully settle an account's state\n modifier settleForAccount(address account) {\n IOracleProvider.OracleVersion memory _currentVersion = _settle();\n _settleAccount(account, _currentVersion);\n\n _;\n }\n\n /// @dev Ensure we have bootstraped the oracle before creating positions\n modifier nonZeroVersionInvariant {\n if (latestVersion() == 0) revert ProductOracleBootstrappingError();\n\n _;\n }\n\n /// @dev Ensure the product is not closed\n modifier notClosed {\n if (closed()) revert ProductClosedError();\n\n _;\n }\n}\n" - }, - "@equilibria/root/control/unstructured/UInitializable.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"../../storage/UStorage.sol\";\n\n/**\n * @title UInitializable\n * @notice Library to manage the initialization lifecycle of upgradeable contracts\n * @dev `UInitializable` allows the creation of pseudo-constructors for upgradeable contracts. One\n * `initializer` should be declared per top-level contract. Child contracts can use the `onlyInitializer`\n * modifier to tag their internal initialization functions to ensure that they can only be called\n * from a top-level `initializer` or a constructor.\n */\nabstract contract UInitializable {\n error UInitializableZeroVersionError();\n error UInitializableAlreadyInitializedError(uint256 version);\n error UInitializableNotInitializingError();\n\n event Initialized(uint256 version);\n\n /// @dev The initialized flag\n Uint256Storage private constant _version = Uint256Storage.wrap(keccak256(\"equilibria.root.UInitializable.version\"));\n\n /// @dev The initializing flag\n BoolStorage private constant _initializing = BoolStorage.wrap(keccak256(\"equilibria.root.UInitializable.initializing\"));\n\n /// @dev Can only be called once per version, `version` is 1-indexed\n modifier initializer(uint256 version) {\n if (version == 0) revert UInitializableZeroVersionError();\n if (_version.read() >= version) revert UInitializableAlreadyInitializedError(version);\n\n _version.store(version);\n _initializing.store(true);\n\n _;\n\n _initializing.store(false);\n emit Initialized(version);\n }\n\n /// @dev Can only be called from an initializer or constructor\n modifier onlyInitializer() {\n if (!_constructing() && !_initializing.read()) revert UInitializableNotInitializingError();\n _;\n }\n\n /**\n * @notice Returns whether the contract is currently being constructed\n * @dev {Address.isContract} returns false for contracts currently in the process of being constructed\n * @return Whether the contract is currently being constructed\n */\n function _constructing() private view returns (bool) {\n return !Address.isContract(address(this));\n }\n}\n" - }, - "@equilibria/root/control/unstructured/UReentrancyGuard.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"./UInitializable.sol\";\nimport \"../../storage/UStorage.sol\";\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n *\n * NOTE: This contract has been extended from the Open Zeppelin library to include an\n * unstructured storage pattern, so that it can be safely mixed in with upgradeable\n * contracts without affecting their storage patterns through inheritance.\n */\nabstract contract UReentrancyGuard is UInitializable {\n error UReentrancyGuardReentrantCallError();\n\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n /**\n * @dev unstructured storage slot for the reentrancy status\n */\n Uint256Storage private constant _status = Uint256Storage.wrap(keccak256(\"equilibria.root.UReentrancyGuard.status\"));\n\n /**\n * @dev Initializes the contract setting the status to _NOT_ENTERED.\n */\n function __UReentrancyGuard__initialize() internal onlyInitializer {\n _status.store(_NOT_ENTERED);\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and make it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n // On the first call to nonReentrant, _notEntered will be true\n if (_status.read() == _ENTERED) revert UReentrancyGuardReentrantCallError();\n\n // Any calls to nonReentrant after this point will fail\n _status.store(_ENTERED);\n\n _;\n\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status.store(_NOT_ENTERED);\n }\n}\n" - }, - "contracts/controller/UControllerProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/root/control/unstructured/UInitializable.sol\";\nimport \"@equilibria/root/storage/UStorage.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"../interfaces/IController.sol\";\nimport \"../interfaces/IProduct.sol\";\n\n/**\n * @title UControllerProvider\n * @notice Mix-in that manages a controller pointer and associated permissioning modifiers.\n * @dev Uses unstructured storage so that it is safe to mix-in to upgreadable contracts without modifying\n * their storage layout.\n */\nabstract contract UControllerProvider is UInitializable {\n error NotOwnerError(uint256 coordinatorId);\n error NotProductError(IProduct product);\n error NotCollateralError();\n error PausedError();\n error InvalidControllerError();\n\n /// @dev The controller contract address\n AddressStorage private constant _controller = AddressStorage.wrap(keccak256(\"equilibria.perennial.UControllerProvider.controller\"));\n function controller() public view returns (IController) { return IController(_controller.read()); }\n\n /**\n * @notice Initializes the contract state\n * @param controller_ Protocol Controller contract address\n */\n // solhint-disable-next-line func-name-mixedcase\n function __UControllerProvider__initialize(IController controller_) internal onlyInitializer {\n if (!Address.isContract(address(controller_))) revert InvalidControllerError();\n _controller.store(address(controller_));\n }\n\n /// @dev Only allow a valid product contract to call\n modifier onlyProduct {\n if (!controller().isProduct(IProduct(msg.sender))) revert NotProductError(IProduct(msg.sender));\n\n _;\n }\n\n /// @dev Verify that `product` is a valid product contract\n modifier isProduct(IProduct product) {\n if (!controller().isProduct(product)) revert NotProductError(product);\n\n _;\n }\n\n /// @dev Only allow the Collateral contract to call\n modifier onlyCollateral {\n if (msg.sender != address(controller().collateral())) revert NotCollateralError();\n\n _;\n }\n\n /// @dev Only allow the coordinator owner to call\n modifier onlyOwner(uint256 coordinatorId) {\n if (msg.sender != controller().owner(coordinatorId)) revert NotOwnerError(coordinatorId);\n\n _;\n }\n\n /// @dev Only allow if the protocol is currently unpaused\n modifier notPaused() {\n if (controller().paused()) revert PausedError();\n\n _;\n }\n}\n" - }, - "contracts/product/UPayoffProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/control/unstructured/UInitializable.sol\";\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"@equilibria/root/storage/UStorage.sol\";\nimport \"../interfaces/IPayoffProvider.sol\";\nimport \"../interfaces/types/PayoffDefinition.sol\";\n\n/**\n * @title UPayoffProvider\n * @notice Library for manage storing, surfacing, and upgrading a payoff provider.\n * @dev Uses an unstructured storage pattern to store the oracle address and payoff definition which allows this\n provider to be safely used with upgradeable contracts.\n */\nabstract contract UPayoffProvider is IPayoffProvider, UInitializable {\n /// @dev The oracle contract address\n AddressStorage private constant _oracle =\n AddressStorage.wrap(keccak256(\"equilibria.perennial.UPayoffProvider.oracle\"));\n function oracle() public view returns (IOracleProvider) { return IOracleProvider(_oracle.read()); }\n\n /// @dev Payoff definition struct\n PayoffDefinitionStorage private constant _payoffDefinition =\n PayoffDefinitionStorage.wrap(keccak256(\"equilibria.perennial.UPayoffProvider.payoffDefinition\"));\n function payoffDefinition() public view returns (PayoffDefinition memory) { return _payoffDefinition.read(); }\n\n /**\n * @notice Initializes the contract state\n * @param oracle_ Oracle address\n * @param payoffDefinition_ Payoff provider\n */\n // solhint-disable-next-line func-name-mixedcase\n function __UPayoffProvider__initialize(IOracleProvider oracle_, PayoffDefinition calldata payoffDefinition_) internal onlyInitializer {\n if (!Address.isContract(address(oracle_))) revert PayoffProviderInvalidOracle();\n _oracle.store(address(oracle_));\n\n if (!payoffDefinition_.valid()) revert PayoffProviderInvalidPayoffDefinitionError();\n _payoffDefinition.store(payoffDefinition_);\n }\n\n /**\n * @notice Returns the current oracle version transformed by the payoff definition\n * @return Current oracle version transformed by the payoff definition\n */\n function currentVersion() public view returns (IOracleProvider.OracleVersion memory) {\n return _transform(oracle().currentVersion());\n }\n\n /**\n * @notice Returns the oracle version at `oracleVersion` transformed by the payoff definition\n * @param oracleVersion Oracle version to return for\n * @return Oracle version at `oracleVersion` with price transformed by payoff function\n */\n function atVersion(uint256 oracleVersion) public view returns (IOracleProvider.OracleVersion memory) {\n return _transform(oracle().atVersion(oracleVersion));\n }\n\n /**\n * @notice Yook to call sync() on the oracle provider and transform the resulting oracle version\n */\n function _sync() internal returns (IOracleProvider.OracleVersion memory) {\n return _transform(oracle().sync());\n }\n\n /**\n * @notice Returns the transformed oracle version\n * @param oracleVersion Oracle version to transform\n * @return Transformed oracle version\n */\n function _transform(IOracleProvider.OracleVersion memory oracleVersion)\n internal view virtual returns (IOracleProvider.OracleVersion memory) {\n oracleVersion.price = payoffDefinition().transform(oracleVersion.price);\n return oracleVersion;\n }\n}\n" - }, - "contracts/product/UParamProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/control/unstructured/UInitializable.sol\";\nimport \"../controller/UControllerProvider.sol\";\nimport \"../interfaces/IParamProvider.sol\";\nimport \"../interfaces/IProduct.sol\";\n\nabstract contract UParamProvider is IParamProvider, UControllerProvider {\n /**\n * @notice Initializes the contract state\n * @param maintenance_ product maintenance ratio\n * @param fundingFee_ product funding fee\n * @param makerFee_ product maker fee\n * @param takerFee_ product taker fee\n * @param makerLimit_ product maker limit\n * @param utilizationCurve_ utulization curve definition\n */\n // solhint-disable-next-line func-name-mixedcase\n function __UParamProvider__initialize(\n UFixed18 maintenance_,\n UFixed18 fundingFee_,\n UFixed18 makerFee_,\n UFixed18 takerFee_,\n UFixed18 makerLimit_,\n JumpRateUtilizationCurve memory utilizationCurve_\n ) internal onlyInitializer {\n _updateMaintenance(maintenance_);\n _updateFundingFee(fundingFee_);\n _updateMakerFee(makerFee_);\n _updateTakerFee(takerFee_);\n _updateMakerLimit(makerLimit_);\n _updateUtilizationCurve(utilizationCurve_);\n }\n\n /// @dev Only allow the Product's coordinator owner to call\n modifier onlyProductOwner {\n uint256 coordinatorId = controller().coordinatorFor(IProduct(address(this)));\n if (controller().owner(coordinatorId) != msg.sender) revert NotOwnerError(coordinatorId);\n\n _;\n }\n\n /// @dev The maintenance value\n UFixed18Storage private constant _maintenance = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.UParamProvider.maintenance\"));\n function maintenance() public view returns (UFixed18) { return _maintenance.read(); }\n\n /// @dev The funding fee value\n UFixed18Storage private constant _fundingFee = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.UParamProvider.fundingFee\"));\n function fundingFee() public view returns (UFixed18) { return _fundingFee.read(); }\n\n /// @dev The maker fee value\n UFixed18Storage private constant _makerFee = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.UParamProvider.makerFee\"));\n function makerFee() public view returns (UFixed18) { return _makerFee.read(); }\n\n /// @dev The taker fee value\n UFixed18Storage private constant _takerFee = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.UParamProvider.takerFee\"));\n function takerFee() public view returns (UFixed18) { return _takerFee.read(); }\n\n /// @dev The maker limit value\n UFixed18Storage private constant _makerLimit = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.UParamProvider.makerLimit\"));\n function makerLimit() public view returns (UFixed18) { return _makerLimit.read(); }\n\n /// @dev The JumpRateUtilizationCurve params\n JumpRateUtilizationCurveStorage private constant _utilizationCurve =\n JumpRateUtilizationCurveStorage.wrap(keccak256(\"equilibria.perennial.UParamProvider.jumpRateUtilizationCurve\"));\n function utilizationCurve() public view returns (JumpRateUtilizationCurve memory) { return _utilizationCurve.read(); }\n\n /**\n * @notice Updates the maintenance to `newMaintenance`\n * @param newMaintenance new maintenance value\n */\n function _updateMaintenance(UFixed18 newMaintenance) private {\n _maintenance.store(newMaintenance);\n emit MaintenanceUpdated(newMaintenance);\n }\n\n /**\n * @notice Updates the maintenance to `newMaintenance`\n * @dev only callable by product owner\n * @param newMaintenance new maintenance value\n */\n function updateMaintenance(UFixed18 newMaintenance) external onlyProductOwner {\n _updateMaintenance(newMaintenance);\n }\n\n /**\n * @notice Updates the funding fee to `newFundingFee`\n * @param newFundingFee new funding fee value\n */\n function _updateFundingFee(UFixed18 newFundingFee) private {\n if (newFundingFee.gt(UFixed18Lib.ONE)) revert ParamProviderInvalidFundingFee();\n _fundingFee.store(newFundingFee);\n emit FundingFeeUpdated(newFundingFee);\n }\n\n /**\n * @notice Updates the funding fee to `newFundingFee`\n * @dev only callable by product owner\n * @param newFundingFee new funding fee value\n */\n function updateFundingFee(UFixed18 newFundingFee) external onlyProductOwner {\n _updateFundingFee(newFundingFee);\n }\n\n /**\n * @notice Updates the maker fee to `newMakerFee`\n * @param newMakerFee new maker fee value\n */\n function _updateMakerFee(UFixed18 newMakerFee) private {\n if (newMakerFee.gt(UFixed18Lib.ONE)) revert ParamProviderInvalidMakerFee();\n _makerFee.store(newMakerFee);\n emit MakerFeeUpdated(newMakerFee);\n }\n\n /**\n * @notice Updates the maker fee to `newMakerFee`\n * @dev only callable by product owner\n * @param newMakerFee new maker fee value\n */\n function updateMakerFee(UFixed18 newMakerFee) external onlyProductOwner {\n _updateMakerFee(newMakerFee);\n }\n\n /**\n * @notice Updates the taker fee to `newTakerFee`\n * @param newTakerFee new taker fee value\n */\n function _updateTakerFee(UFixed18 newTakerFee) private {\n if (newTakerFee.gt(UFixed18Lib.ONE)) revert ParamProviderInvalidTakerFee();\n _takerFee.store(newTakerFee);\n emit TakerFeeUpdated(newTakerFee);\n }\n\n /**\n * @notice Updates the taker fee to `newTakerFee`\n * @dev only callable by product owner\n * @param newTakerFee new taker fee value\n */\n function updateTakerFee(UFixed18 newTakerFee) external onlyProductOwner {\n _updateTakerFee(newTakerFee);\n }\n\n /**\n * @notice Updates the maker limit to `newMakerLimit`\n * @param newMakerLimit new maker limit value\n */\n function _updateMakerLimit(UFixed18 newMakerLimit) private {\n _makerLimit.store(newMakerLimit);\n emit MakerLimitUpdated(newMakerLimit);\n }\n\n /**\n * @notice Updates the maker limit to `newMakerLimit`\n * @dev only callable by product owner\n * @param newMakerLimit new maker limit value\n */\n function updateMakerLimit(UFixed18 newMakerLimit) external onlyProductOwner {\n _updateMakerLimit(newMakerLimit);\n }\n\n /**\n * @notice Updates the utilization curve to `newUtilizationCurve`\n * @param newUtilizationCurve new utilization curve value\n */\n function _updateUtilizationCurve(JumpRateUtilizationCurve memory newUtilizationCurve) private {\n _utilizationCurve.store(newUtilizationCurve);\n emit JumpRateUtilizationCurveUpdated(\n newUtilizationCurve.minRate.unpack(),\n newUtilizationCurve.maxRate.unpack(),\n newUtilizationCurve.targetRate.unpack(),\n newUtilizationCurve.targetUtilization.unpack()\n );\n }\n\n /**\n * @notice Updates the utilization curve to `newUtilizationCurve`\n * @dev only callable by product owner\n * @param newUtilizationCurve new utilization curve value\n */\n function updateUtilizationCurve(JumpRateUtilizationCurve calldata newUtilizationCurve) external onlyProductOwner {\n _updateUtilizationCurve(newUtilizationCurve);\n }\n}\n" - }, - "contracts/product/types/position/AccountPosition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../../../interfaces/IProduct.sol\";\nimport \"../../../interfaces/types/PrePosition.sol\";\n\n/// @dev AccountPosition type\nstruct AccountPosition {\n /// @dev The current settled position of the account\n Position position;\n\n /// @dev The current position delta pending-settlement\n PrePosition pre;\n\n /// @dev Whether the account is currently locked for liquidation\n bool liquidation;\n}\nusing AccountPositionLib for AccountPosition global;\n\n/**\n * @title AccountPositionLib\n * @notice Library that manages an account-level position.\n */\nlibrary AccountPositionLib {\n /**\n * @notice Settled the account's position to oracle version `toOracleVersion`\n * @param self The struct to operate on\n * @param toOracleVersion The oracle version to accumulate to\n * @return positionFee The fee accrued from opening or closing a new position\n */\n function settle(\n AccountPosition storage self,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal returns (UFixed18 positionFee) {\n bool settled;\n (self.position, positionFee, settled) = self.position.settled(self.pre, toOracleVersion);\n if (settled) {\n delete self.pre;\n self.liquidation = false;\n }\n }\n\n /**\n * @notice Returns the current maintenance requirement for the account\n * @dev Must be called from a valid product to get the proper maintenance value\n * @param self The struct to operate on\n * @return Current maintenance requirement for the account\n */\n function maintenance(AccountPosition storage self) internal view returns (UFixed18) {\n if (self.liquidation) return UFixed18Lib.ZERO;\n return _maintenance(self.position);\n }\n\n /**\n * @notice Returns the maintenance requirement after the next oracle version settlement\n * @dev Includes the current pending-settlement position delta, assumes no price change\n * @param self The struct to operate on\n * @return Next maintenance requirement for the account\n */\n function maintenanceNext(AccountPosition storage self) internal view returns (UFixed18) {\n return _maintenance(self.position.next(self.pre));\n }\n\n /**\n * @notice Returns the maintenance requirement for a given `position`\n * @dev Internal helper\n * @param position The position to compete the maintenance requirement for\n * @return Next maintenance requirement for the account\n */\n function _maintenance(Position memory position) private view returns (UFixed18) {\n IProduct product = IProduct(address(this));\n Fixed18 oraclePrice = product.currentVersion().price;\n UFixed18 notionalMax = Fixed18Lib.from(position.max()).mul(oraclePrice).abs();\n return notionalMax.mul(product.maintenance());\n }\n\n /**\n * @notice Returns whether an account is completely closed, i.e. no position or pre-position\n * @param self The struct to operate on\n * @return Whether the account is closed\n */\n function isClosed(AccountPosition memory self) internal pure returns (bool) {\n return self.pre.isEmpty() && self.position.isEmpty();\n }\n\n /**\n * @notice Returns whether an account has opened position on both sides of the market (maker vs taker)\n * @dev Used to verify the invariant that a single account can only have a position on one side of the\n * market at a time\n * @param self The struct to operate on\n * @return Whether the account is currently doubled sided\n */\n function isDoubleSided(AccountPosition storage self) internal view returns (bool) {\n bool makerEmpty = self.position.maker.isZero() && self.pre.openPosition.maker.isZero() && self.pre.closePosition.maker.isZero();\n bool takerEmpty = self.position.taker.isZero() && self.pre.openPosition.taker.isZero() && self.pre.closePosition.taker.isZero();\n\n return !makerEmpty && !takerEmpty;\n }\n\n /**\n * @notice Returns whether the account's pending-settlement delta closes more position than is open\n * @dev Used to verify the invariant that an account cannot settle into having a negative position\n * @param self The struct to operate on\n * @return Whether the account is currently over closed\n */\n function isOverClosed(AccountPosition storage self) internal view returns (bool) {\n Position memory nextOpen = self.position.add(self.pre.openPosition);\n\n return self.pre.closePosition.maker.gt(nextOpen.maker) || self.pre.closePosition.taker.gt(nextOpen.taker);\n }\n}\n" - }, - "contracts/product/types/accumulator/AccountAccumulator.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../../../interfaces/types/Accumulator.sol\";\nimport \"../position/AccountPosition.sol\";\nimport \"./VersionedAccumulator.sol\";\n\n/// @dev AccountAccumulator type\nstruct AccountAccumulator {\n /// @dev latest version that the account was synced too\n uint256 latestVersion;\n}\nusing AccountAccumulatorLib for AccountAccumulator global;\n\n/**\n * @title AccountAccumulatorLib\n * @notice Library that manages syncing an account-level accumulator.\n */\nlibrary AccountAccumulatorLib {\n /**\n * @notice Syncs the account to oracle version `versionTo`\n * @param self The struct to operate on\n * @param global Pointer to global accumulator\n * @param position Pointer to global position\n * @param versionTo Oracle version to sync account to\n * @return value The value accumulated sync last sync\n */\n function syncTo(\n AccountAccumulator storage self,\n VersionedAccumulator storage global,\n AccountPosition storage position,\n uint256 versionTo\n ) internal returns (Accumulator memory value) {\n Accumulator memory valueAccumulated = global.valueAtVersion(versionTo)\n .sub(global.valueAtVersion(self.latestVersion));\n value = position.position.mul(valueAccumulated);\n self.latestVersion = versionTo;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Address.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // 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\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" - }, - "@equilibria/root/storage/UStorage.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"../number/types/UFixed18.sol\";\n\n/// @dev Stored boolean slot\ntype BoolStorage is bytes32;\nusing BoolStorageLib for BoolStorage global;\n\n/// @dev Stored uint256 slot\ntype Uint256Storage is bytes32;\nusing Uint256StorageLib for Uint256Storage global;\n\n/// @dev Stored int256 slot\ntype Int256Storage is bytes32;\nusing Int256StorageLib for Int256Storage global;\n\n/// @dev Stored address slot\ntype AddressStorage is bytes32;\nusing AddressStorageLib for AddressStorage global;\n\n/// @dev Stored bytes32 slot\ntype Bytes32Storage is bytes32;\nusing Bytes32StorageLib for Bytes32Storage global;\n\n/**\n * @title BoolStorageLib\n * @notice Library to manage storage and retrival of a boolean at a fixed storage slot\n */\nlibrary BoolStorageLib {\n /**\n * @notice Retrieves the stored value\n * @param self Storage slot\n * @return value Stored bool value\n */\n function read(BoolStorage self) internal view returns (bool value) {\n assembly {\n value := sload(self)\n }\n }\n\n /**\n * @notice Stores the value at the specific slot\n * @param self Storage slot\n * @param value boolean value to store\n */\n function store(BoolStorage self, bool value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n\n/**\n * @title Uint256StorageLib\n * @notice Library to manage storage and retrival of an uint256 at a fixed storage slot\n */\nlibrary Uint256StorageLib {\n /**\n * @notice Retrieves the stored value\n * @param self Storage slot\n * @return value Stored uint256 value\n */\n function read(Uint256Storage self) internal view returns (uint256 value) {\n assembly {\n value := sload(self)\n }\n }\n\n /**\n * @notice Stores the value at the specific slot\n * @param self Storage slot\n * @param value uint256 value to store\n */\n function store(Uint256Storage self, uint256 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n\n/**\n * @title Int256StorageLib\n * @notice Library to manage storage and retrival of an int256 at a fixed storage slot\n */\nlibrary Int256StorageLib {\n /**\n * @notice Retrieves the stored value\n * @param self Storage slot\n * @return value Stored int256 value\n */\n function read(Int256Storage self) internal view returns (int256 value) {\n assembly {\n value := sload(self)\n }\n }\n\n /**\n * @notice Stores the value at the specific slot\n * @param self Storage slot\n * @param value int256 value to store\n */\n function store(Int256Storage self, int256 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n\n/**\n * @title AddressStorageLib\n * @notice Library to manage storage and retrival of an address at a fixed storage slot\n */\nlibrary AddressStorageLib {\n /**\n * @notice Retrieves the stored value\n * @param self Storage slot\n * @return value Stored address value\n */\n function read(AddressStorage self) internal view returns (address value) {\n assembly {\n value := sload(self)\n }\n }\n\n /**\n * @notice Stores the value at the specific slot\n * @param self Storage slot\n * @param value address value to store\n */\n function store(AddressStorage self, address value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n\n/**\n * @title Bytes32StorageLib\n * @notice Library to manage storage and retrival of a bytes32 at a fixed storage slot\n */\nlibrary Bytes32StorageLib {\n /**\n * @notice Retrieves the stored value\n * @param self Storage slot\n * @return value Stored bytes32 value\n */\n function read(Bytes32Storage self) internal view returns (bytes32 value) {\n assembly {\n value := sload(self)\n }\n }\n\n /**\n * @notice Stores the value at the specific slot\n * @param self Storage slot\n * @param value bytes32 value to store\n */\n function store(Bytes32Storage self, bytes32 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "@equilibria/root/number/types/UFixed18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"./Fixed18.sol\";\nimport \"./PackedUFixed18.sol\";\n\n/// @dev UFixed18 type\ntype UFixed18 is uint256;\nusing UFixed18Lib for UFixed18 global;\ntype UFixed18Storage is bytes32;\nusing UFixed18StorageLib for UFixed18Storage global;\n\n/**\n * @title UFixed18Lib\n * @notice Library for the unsigned fixed-decimal type.\n */\nlibrary UFixed18Lib {\n error UFixed18UnderflowError(int256 value);\n error UFixed18PackingOverflowError(uint256 value);\n\n uint256 private constant BASE = 1e18;\n UFixed18 public constant ZERO = UFixed18.wrap(0);\n UFixed18 public constant ONE = UFixed18.wrap(BASE);\n UFixed18 public constant MAX = UFixed18.wrap(type(uint256).max);\n\n /**\n * @notice Creates a unsigned fixed-decimal from a signed fixed-decimal\n * @param a Signed fixed-decimal\n * @return New unsigned fixed-decimal\n */\n function from(Fixed18 a) internal pure returns (UFixed18) {\n int256 value = Fixed18.unwrap(a);\n if (value < 0) revert UFixed18UnderflowError(value);\n return UFixed18.wrap(uint256(value));\n }\n\n /**\n * @notice Creates a unsigned fixed-decimal from a unsigned integer\n * @param a Unsigned number\n * @return New unsigned fixed-decimal\n */\n function from(uint256 a) internal pure returns (UFixed18) {\n return UFixed18.wrap(a * BASE);\n }\n\n /**\n * @notice Creates a packed unsigned fixed-decimal from an unsigned fixed-decimal\n * @param a unsigned fixed-decimal\n * @return New packed unsigned fixed-decimal\n */\n function pack(UFixed18 a) internal pure returns (PackedUFixed18) {\n uint256 value = UFixed18.unwrap(a);\n if (value > type(uint128).max) revert UFixed18PackingOverflowError(value);\n return PackedUFixed18.wrap(uint128(value));\n }\n\n /**\n * @notice Returns whether the unsigned fixed-decimal is equal to zero.\n * @param a Unsigned fixed-decimal\n * @return Whether the unsigned fixed-decimal is zero.\n */\n function isZero(UFixed18 a) internal pure returns (bool) {\n return UFixed18.unwrap(a) == 0;\n }\n\n /**\n * @notice Adds two unsigned fixed-decimals `a` and `b` together\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Resulting summed unsigned fixed-decimal\n */\n function add(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) + UFixed18.unwrap(b));\n }\n\n /**\n * @notice Subtracts unsigned fixed-decimal `b` from `a`\n * @param a Unsigned fixed-decimal to subtract from\n * @param b Unsigned fixed-decimal to subtract\n * @return Resulting subtracted unsigned fixed-decimal\n */\n function sub(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) - UFixed18.unwrap(b));\n }\n\n /**\n * @notice Multiplies two unsigned fixed-decimals `a` and `b` together\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Resulting multiplied unsigned fixed-decimal\n */\n function mul(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / BASE);\n }\n\n /**\n * @notice Divides unsigned fixed-decimal `a` by `b`\n * @param a Unsigned fixed-decimal to divide\n * @param b Unsigned fixed-decimal to divide by\n * @return Resulting divided unsigned fixed-decimal\n */\n function div(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) * BASE / UFixed18.unwrap(b));\n }\n\n /**\n * @notice Divides unsigned fixed-decimal `a` by `b`\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0` and `MAX` for `n/0`.\n * @param a Unsigned fixed-decimal to divide\n * @param b Unsigned fixed-decimal to divide by\n * @return Resulting divided unsigned fixed-decimal\n */\n function unsafeDiv(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n if (isZero(b)) {\n return isZero(a) ? ONE : MAX;\n } else {\n return div(a, b);\n }\n }\n\n /**\n * @notice Computes a * b / c without loss of precision due to BASE conversion\n * @param a First unsigned fixed-decimal\n * @param b Unsigned number to multiply by\n * @param c Unsigned number to divide by\n * @return Resulting computation\n */\n function muldiv(UFixed18 a, uint256 b, uint256 c) internal pure returns (UFixed18) {\n return muldiv(a, UFixed18.wrap(b), UFixed18.wrap(c));\n }\n\n /**\n * @notice Computes a * b / c without loss of precision due to BASE conversion\n * @param a First unsigned fixed-decimal\n * @param b Unsigned fixed-decimal to multiply by\n * @param c Unsigned fixed-decimal to divide by\n * @return Resulting computation\n */\n function muldiv(UFixed18 a, UFixed18 b, UFixed18 c) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / UFixed18.unwrap(c));\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is equal to `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is equal to `b`\n */\n function eq(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return compare(a, b) == 1;\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is greater than `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is greater than `b`\n */\n function gt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return compare(a, b) == 2;\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is less than `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is less than `b`\n */\n function lt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return compare(a, b) == 0;\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is greater than or equal to `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is greater than or equal to `b`\n */\n function gte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return gt(a, b) || eq(a, b);\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is less than or equal to `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is less than or equal to `b`\n */\n function lte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return lt(a, b) || eq(a, b);\n }\n\n /**\n * @notice Compares the unsigned fixed-decimals `a` and `b`\n * @dev Returns: 2 for greater than\n * 1 for equal to\n * 0 for less than\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Compare result of `a` and `b`\n */\n function compare(UFixed18 a, UFixed18 b) internal pure returns (uint256) {\n (uint256 au, uint256 bu) = (UFixed18.unwrap(a), UFixed18.unwrap(b));\n if (au > bu) return 2;\n if (au < bu) return 0;\n return 1;\n }\n\n /**\n * @notice Returns a unsigned fixed-decimal representing the ratio of `a` over `b`\n * @param a First unsigned number\n * @param b Second unsigned number\n * @return Ratio of `a` over `b`\n */\n function ratio(uint256 a, uint256 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(a * BASE / b);\n }\n\n /**\n * @notice Returns the minimum of unsigned fixed-decimals `a` and `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Minimum of `a` and `b`\n */\n function min(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(Math.min(UFixed18.unwrap(a), UFixed18.unwrap(b)));\n }\n\n /**\n * @notice Returns the maximum of unsigned fixed-decimals `a` and `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Maximum of `a` and `b`\n */\n function max(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(Math.max(UFixed18.unwrap(a), UFixed18.unwrap(b)));\n }\n\n /**\n * @notice Converts the unsigned fixed-decimal into an integer, truncating any decimal portion\n * @param a Unsigned fixed-decimal\n * @return Truncated unsigned number\n */\n function truncate(UFixed18 a) internal pure returns (uint256) {\n return UFixed18.unwrap(a) / BASE;\n }\n}\n\nlibrary UFixed18StorageLib {\n function read(UFixed18Storage self) internal view returns (UFixed18 value) {\n assembly {\n value := sload(self)\n }\n }\n\n function store(UFixed18Storage self, UFixed18 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return 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 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 up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a / b + (a % b == 0 ? 0 : 1);\n }\n}\n" - }, - "@equilibria/root/number/types/Fixed18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/SignedMath.sol\";\nimport \"./UFixed18.sol\";\nimport \"./PackedFixed18.sol\";\n\n/// @dev Fixed18 type\ntype Fixed18 is int256;\nusing Fixed18Lib for Fixed18 global;\ntype Fixed18Storage is bytes32;\nusing Fixed18StorageLib for Fixed18Storage global;\n\n/**\n * @title Fixed18Lib\n * @notice Library for the signed fixed-decimal type.\n */\nlibrary Fixed18Lib {\n error Fixed18OverflowError(uint256 value);\n error Fixed18PackingOverflowError(int256 value);\n error Fixed18PackingUnderflowError(int256 value);\n\n int256 private constant BASE = 1e18;\n Fixed18 public constant ZERO = Fixed18.wrap(0);\n Fixed18 public constant ONE = Fixed18.wrap(BASE);\n Fixed18 public constant NEG_ONE = Fixed18.wrap(-1 * BASE);\n Fixed18 public constant MAX = Fixed18.wrap(type(int256).max);\n Fixed18 public constant MIN = Fixed18.wrap(type(int256).min);\n\n /**\n * @notice Creates a signed fixed-decimal from an unsigned fixed-decimal\n * @param a Unsigned fixed-decimal\n * @return New signed fixed-decimal\n */\n function from(UFixed18 a) internal pure returns (Fixed18) {\n uint256 value = UFixed18.unwrap(a);\n if (value > uint256(type(int256).max)) revert Fixed18OverflowError(value);\n return Fixed18.wrap(int256(value));\n }\n\n /**\n * @notice Creates a signed fixed-decimal from a sign and an unsigned fixed-decimal\n * @param s Sign\n * @param m Unsigned fixed-decimal magnitude\n * @return New signed fixed-decimal\n */\n function from(int256 s, UFixed18 m) internal pure returns (Fixed18) {\n if (s > 0) return from(m);\n if (s < 0) return Fixed18.wrap(-1 * Fixed18.unwrap(from(m)));\n return ZERO;\n }\n\n /**\n * @notice Creates a signed fixed-decimal from a signed integer\n * @param a Signed number\n * @return New signed fixed-decimal\n */\n function from(int256 a) internal pure returns (Fixed18) {\n return Fixed18.wrap(a * BASE);\n }\n\n /**\n * @notice Creates a packed signed fixed-decimal from an signed fixed-decimal\n * @param a signed fixed-decimal\n * @return New packed signed fixed-decimal\n */\n function pack(Fixed18 a) internal pure returns (PackedFixed18) {\n int256 value = Fixed18.unwrap(a);\n if (value > type(int128).max) revert Fixed18PackingOverflowError(value);\n if (value < type(int128).min) revert Fixed18PackingUnderflowError(value);\n return PackedFixed18.wrap(int128(value));\n }\n\n /**\n * @notice Returns whether the signed fixed-decimal is equal to zero.\n * @param a Signed fixed-decimal\n * @return Whether the signed fixed-decimal is zero.\n */\n function isZero(Fixed18 a) internal pure returns (bool) {\n return Fixed18.unwrap(a) == 0;\n }\n\n /**\n * @notice Adds two signed fixed-decimals `a` and `b` together\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Resulting summed signed fixed-decimal\n */\n function add(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) + Fixed18.unwrap(b));\n }\n\n /**\n * @notice Subtracts signed fixed-decimal `b` from `a`\n * @param a Signed fixed-decimal to subtract from\n * @param b Signed fixed-decimal to subtract\n * @return Resulting subtracted signed fixed-decimal\n */\n function sub(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) - Fixed18.unwrap(b));\n }\n\n /**\n * @notice Multiplies two signed fixed-decimals `a` and `b` together\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Resulting multiplied signed fixed-decimal\n */\n function mul(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / BASE);\n }\n\n /**\n * @notice Divides signed fixed-decimal `a` by `b`\n * @param a Signed fixed-decimal to divide\n * @param b Signed fixed-decimal to divide by\n * @return Resulting divided signed fixed-decimal\n */\n function div(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) * BASE / Fixed18.unwrap(b));\n }\n\n /**\n * @notice Divides unsigned fixed-decimal `a` by `b`\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0`, `MAX` for `n/0`, and `MIN` for `-n/0`.\n * @param a Unsigned fixed-decimal to divide\n * @param b Unsigned fixed-decimal to divide by\n * @return Resulting divided unsigned fixed-decimal\n */\n function unsafeDiv(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n if (isZero(b)) {\n if (gt(a, ZERO)) return MAX;\n if (lt(a, ZERO)) return MIN;\n return ONE;\n } else {\n return div(a, b);\n }\n }\n\n /**\n * @notice Computes a * b / c without loss of precision due to BASE conversion\n * @param a First signed fixed-decimal\n * @param b Signed number to multiply by\n * @param c Signed number to divide by\n * @return Resulting computation\n */\n function muldiv(Fixed18 a, int256 b, int256 c) internal pure returns (Fixed18) {\n return muldiv(a, Fixed18.wrap(b), Fixed18.wrap(c));\n }\n\n /**\n * @notice Computes a * b / c without loss of precision due to BASE conversion\n * @param a First signed fixed-decimal\n * @param b Signed fixed-decimal to multiply by\n * @param c Signed fixed-decimal to divide by\n * @return Resulting computation\n */\n function muldiv(Fixed18 a, Fixed18 b, Fixed18 c) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / Fixed18.unwrap(c));\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is equal to `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is equal to `b`\n */\n function eq(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return compare(a, b) == 1;\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is greater than `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is greater than `b`\n */\n function gt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return compare(a, b) == 2;\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is less than `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is less than `b`\n */\n function lt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return compare(a, b) == 0;\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is greater than or equal to `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is greater than or equal to `b`\n */\n function gte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return gt(a, b) || eq(a, b);\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is less than or equal to `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is less than or equal to `b`\n */\n function lte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return lt(a, b) || eq(a, b);\n }\n\n /**\n * @notice Compares the signed fixed-decimals `a` and `b`\n * @dev Returns: 2 for greater than\n * 1 for equal to\n * 0 for less than\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Compare result of `a` and `b`\n */\n function compare(Fixed18 a, Fixed18 b) internal pure returns (uint256) {\n (int256 au, int256 bu) = (Fixed18.unwrap(a), Fixed18.unwrap(b));\n if (au > bu) return 2;\n if (au < bu) return 0;\n return 1;\n }\n\n /**\n * @notice Returns a signed fixed-decimal representing the ratio of `a` over `b`\n * @param a First signed number\n * @param b Second signed number\n * @return Ratio of `a` over `b`\n */\n function ratio(int256 a, int256 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(a * BASE / b);\n }\n\n /**\n * @notice Returns the minimum of signed fixed-decimals `a` and `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Minimum of `a` and `b`\n */\n function min(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(SignedMath.min(Fixed18.unwrap(a), Fixed18.unwrap(b)));\n }\n\n /**\n * @notice Returns the maximum of signed fixed-decimals `a` and `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Maximum of `a` and `b`\n */\n function max(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(SignedMath.max(Fixed18.unwrap(a), Fixed18.unwrap(b)));\n }\n\n /**\n * @notice Converts the signed fixed-decimal into an integer, truncating any decimal portion\n * @param a Signed fixed-decimal\n * @return Truncated signed number\n */\n function truncate(Fixed18 a) internal pure returns (int256) {\n return Fixed18.unwrap(a) / BASE;\n }\n\n /**\n * @notice Returns the sign of the signed fixed-decimal\n * @dev Returns: -1 for negative\n * 0 for zero\n * 1 for positive\n * @param a Signed fixed-decimal\n * @return Sign of the signed fixed-decimal\n */\n function sign(Fixed18 a) internal pure returns (int256) {\n if (Fixed18.unwrap(a) > 0) return 1;\n if (Fixed18.unwrap(a) < 0) return -1;\n return 0;\n }\n\n /**\n * @notice Returns the absolute value of the signed fixed-decimal\n * @param a Signed fixed-decimal\n * @return Absolute value of the signed fixed-decimal\n */\n function abs(Fixed18 a) internal pure returns (UFixed18) {\n return UFixed18.wrap(SignedMath.abs(Fixed18.unwrap(a)));\n }\n}\n\nlibrary Fixed18StorageLib {\n function read(Fixed18Storage self) internal view returns (Fixed18 value) {\n assembly {\n value := sload(self)\n }\n }\n\n function store(Fixed18Storage self, Fixed18 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "@equilibria/root/number/types/PackedUFixed18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"./UFixed18.sol\";\n\n/// @dev PackedUFixed18 type\ntype PackedUFixed18 is uint128;\nusing PackedUFixed18Lib for PackedUFixed18 global;\n\n/**\n * @title PackedUFixed18Lib\n * @dev A packed version of the UFixed18 which takes up half the storage space (two PackedUFixed18 can be packed\n * into a single slot). Only valid within the range 0 <= x <= 3.4028237e+20.\n * @notice Library for the packed unsigned fixed-decimal type.\n */\nlibrary PackedUFixed18Lib {\n PackedUFixed18 public constant MAX = PackedUFixed18.wrap(type(uint128).max);\n\n /**\n * @notice Creates an unpacked unsigned fixed-decimal from a packed unsigned fixed-decimal\n * @param self packed unsigned fixed-decimal\n * @return New unpacked unsigned fixed-decimal\n */\n function unpack(PackedUFixed18 self) internal pure returns (UFixed18) {\n return UFixed18.wrap(uint256(PackedUFixed18.unwrap(self)));\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/SignedMath.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n /**\n * @dev Returns the largest of two signed numbers.\n */\n function max(int256 a, int256 b) internal pure returns (int256) {\n return 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 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 // must be unchecked in order to support `n = type(int256).min`\n return uint256(n >= 0 ? n : -n);\n }\n }\n}\n" - }, - "@equilibria/root/number/types/PackedFixed18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"./Fixed18.sol\";\n\n/// @dev PackedFixed18 type\ntype PackedFixed18 is int128;\nusing PackedFixed18Lib for PackedFixed18 global;\n\n/**\n * @title PackedFixed18Lib\n * @dev A packed version of the Fixed18 which takes up half the storage space (two PackedFixed18 can be packed\n * into a single slot). Only valid within the range -1.7014118e+20 <= x <= 1.7014118e+20.\n * @notice Library for the packed signed fixed-decimal type.\n */\nlibrary PackedFixed18Lib {\n PackedFixed18 public constant MAX = PackedFixed18.wrap(type(int128).max);\n PackedFixed18 public constant MIN = PackedFixed18.wrap(type(int128).min);\n\n /**\n * @notice Creates an unpacked signed fixed-decimal from a packed signed fixed-decimal\n * @param self packed signed fixed-decimal\n * @return New unpacked signed fixed-decimal\n */\n function unpack(PackedFixed18 self) internal pure returns (Fixed18) {\n return Fixed18.wrap(int256(PackedFixed18.unwrap(self)));\n }\n}\n" - }, - "contracts/interfaces/IController.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\";\nimport \"./ICollateral.sol\";\nimport \"./IIncentivizer.sol\";\nimport \"./IProduct.sol\";\nimport \"./types/PayoffDefinition.sol\";\n\ninterface IController {\n /// @dev Coordinator of a one or many products\n struct Coordinator {\n /// @dev Pending owner of the product, can accept ownership\n address pendingOwner;\n\n /// @dev Owner of the product, allowed to update select parameters\n address owner;\n\n /// @dev Treasury of the product, collects fees\n address treasury;\n }\n\n event CollateralUpdated(ICollateral newCollateral);\n event IncentivizerUpdated(IIncentivizer newIncentivizer);\n event ProductBeaconUpdated(IBeacon newProductBeacon);\n event ProtocolFeeUpdated(UFixed18 newProtocolFee);\n event MinFundingFeeUpdated(UFixed18 newMinFundingFee);\n event LiquidationFeeUpdated(UFixed18 newLiquidationFee);\n event IncentivizationFeeUpdated(UFixed18 newIncentivizationFee);\n event MinCollateralUpdated(UFixed18 newMinCollateral);\n event ProgramsPerProductUpdated(uint256 newProgramsPerProduct);\n event PauserUpdated(address newPauser);\n event PausedUpdated(bool newPaused);\n event CoordinatorPendingOwnerUpdated(uint256 indexed coordinatorId, address newPendingOwner);\n event CoordinatorOwnerUpdated(uint256 indexed coordinatorId, address newOwner);\n event CoordinatorTreasuryUpdated(uint256 indexed coordinatorId, address newTreasury);\n event CoordinatorCreated(uint256 indexed coordinatorId, address owner);\n event ProductCreated(IProduct indexed product, IProduct.ProductInfo productInfo);\n\n error ControllerNoZeroCoordinatorError();\n error ControllerNotPauserError();\n error ControllerNotOwnerError(uint256 controllerId);\n error ControllerNotPendingOwnerError(uint256 controllerId);\n error ControllerInvalidProtocolFeeError();\n error ControllerInvalidMinFundingFeeError();\n error ControllerInvalidLiquidationFeeError();\n error ControllerInvalidIncentivizationFeeError();\n error ControllerNotContractAddressError();\n\n function collateral() external view returns (ICollateral);\n function incentivizer() external view returns (IIncentivizer);\n function productBeacon() external view returns (IBeacon);\n function coordinators(uint256 collateralId) external view returns (Coordinator memory);\n function coordinatorFor(IProduct product) external view returns (uint256);\n function protocolFee() external view returns (UFixed18);\n function minFundingFee() external view returns (UFixed18);\n function liquidationFee() external view returns (UFixed18);\n function incentivizationFee() external view returns (UFixed18);\n function minCollateral() external view returns (UFixed18);\n function programsPerProduct() external view returns (uint256);\n function pauser() external view returns (address);\n function paused() external view returns (bool);\n function initialize(ICollateral collateral_, IIncentivizer incentivizer_, IBeacon productBeacon_) external;\n function createCoordinator() external returns (uint256);\n function updateCoordinatorPendingOwner(uint256 coordinatorId, address newPendingOwner) external;\n function acceptCoordinatorOwner(uint256 coordinatorId) external;\n function updateCoordinatorTreasury(uint256 coordinatorId, address newTreasury) external;\n function createProduct(uint256 coordinatorId, IProduct.ProductInfo calldata productInfo) external returns (IProduct);\n function updateCollateral(ICollateral newCollateral) external;\n function updateIncentivizer(IIncentivizer newIncentivizer) external;\n function updateProductBeacon(IBeacon newProductBeacon) external;\n function updateProtocolFee(UFixed18 newProtocolFee) external;\n function updateMinFundingFee(UFixed18 newMinFundingFee) external;\n function updateLiquidationFee(UFixed18 newLiquidationFee) external;\n function updateIncentivizationFee(UFixed18 newIncentivizationFee) external;\n function updateMinCollateral(UFixed18 newMinCollateral) external;\n function updateProgramsPerProduct(uint256 newProductsPerProduct) external;\n function updatePauser(address newPauser) external;\n function updatePaused(bool newPaused) external;\n function isProduct(IProduct product) external view returns (bool);\n function owner() external view returns (address);\n function owner(uint256 coordinatorId) external view returns (address);\n function owner(IProduct product) external view returns (address);\n function treasury() external view returns (address);\n function treasury(uint256 coordinatorId) external view returns (address);\n function treasury(IProduct product) external view returns (address);\n}\n" - }, - "contracts/interfaces/IProduct.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\";\nimport \"./IPayoffProvider.sol\";\nimport \"./IParamProvider.sol\";\nimport \"./types/PayoffDefinition.sol\";\nimport \"./types/Position.sol\";\nimport \"./types/PrePosition.sol\";\nimport \"./types/Accumulator.sol\";\n\ninterface IProduct is IPayoffProvider, IParamProvider {\n /// @dev Product Creation parameters\n struct ProductInfo {\n /// @dev name of the product\n string name;\n\n /// @dev symbol of the product\n string symbol;\n\n /// @dev product payoff definition\n PayoffDefinition payoffDefinition;\n\n /// @dev oracle address\n IOracleProvider oracle;\n\n /// @dev product maintenance ratio\n UFixed18 maintenance;\n\n /// @dev product funding fee\n UFixed18 fundingFee;\n\n /// @dev product maker fee\n UFixed18 makerFee;\n\n /// @dev product taker fee\n UFixed18 takerFee;\n\n /// @dev product maker limit\n UFixed18 makerLimit;\n\n /// @dev utulization curve definition\n JumpRateUtilizationCurve utilizationCurve;\n }\n\n event Settle(uint256 preVersion, uint256 toVersion);\n event AccountSettle(address indexed account, uint256 preVersion, uint256 toVersion);\n event MakeOpened(address indexed account, uint256 version, UFixed18 amount);\n event TakeOpened(address indexed account, uint256 version, UFixed18 amount);\n event MakeClosed(address indexed account, uint256 version, UFixed18 amount);\n event TakeClosed(address indexed account, uint256 version, UFixed18 amount);\n event ClosedUpdated(bool indexed newClosed, uint256 version);\n\n error ProductInsufficientLiquidityError(UFixed18 socializationFactor);\n error ProductDoubleSidedError();\n error ProductOverClosedError();\n error ProductInsufficientCollateralError();\n error ProductInLiquidationError();\n error ProductMakerOverLimitError();\n error ProductOracleBootstrappingError();\n error ProductNotOwnerError();\n error ProductInvalidOracle();\n error ProductClosedError();\n\n function name() external view returns (string memory);\n function symbol() external view returns (string memory);\n function initialize(ProductInfo calldata productInfo_) external;\n function settle() external;\n function settleAccount(address account) external;\n function openTake(UFixed18 amount) external;\n function closeTake(UFixed18 amount) external;\n function openMake(UFixed18 amount) external;\n function closeMake(UFixed18 amount) external;\n function closeAll(address account) external;\n function maintenance(address account) external view returns (UFixed18);\n function maintenanceNext(address account) external view returns (UFixed18);\n function isClosed(address account) external view returns (bool);\n function isLiquidating(address account) external view returns (bool);\n function position(address account) external view returns (Position memory);\n function pre(address account) external view returns (PrePosition memory);\n function latestVersion() external view returns (uint256);\n function positionAtVersion(uint256 oracleVersion) external view returns (Position memory);\n function pre() external view returns (PrePosition memory);\n function valueAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\n function shareAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\n function latestVersion(address account) external view returns (uint256);\n function rate(Position memory position) external view returns (Fixed18);\n function closed() external view returns (bool);\n function updateClosed(bool newClosed) external;\n}\n" - }, - "@openzeppelin/contracts/proxy/beacon/IBeacon.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n" - }, - "contracts/interfaces/ICollateral.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/root/number/types/Fixed18.sol\";\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"./IController.sol\";\nimport \"./IProduct.sol\";\n\ninterface ICollateral {\n event Deposit(address indexed user, IProduct indexed product, UFixed18 amount);\n event Withdrawal(address indexed user, IProduct indexed product, UFixed18 amount);\n event AccountSettle(IProduct indexed product, address indexed account, Fixed18 amount, UFixed18 newShortfall);\n event ProductSettle(IProduct indexed product, UFixed18 protocolFee, UFixed18 productFee);\n event Liquidation(address indexed user, IProduct indexed product, address liquidator, UFixed18 fee);\n event ShortfallResolution(IProduct indexed product, UFixed18 amount);\n event FeeClaim(address indexed account, UFixed18 amount);\n\n error CollateralCantLiquidate(UFixed18 totalMaintenance, UFixed18 totalCollateral);\n error CollateralInsufficientCollateralError();\n error CollateralUnderLimitError();\n error CollateralZeroAddressError();\n\n function token() external view returns (Token18);\n function fees(address account) external view returns (UFixed18);\n function initialize(IController controller_) external;\n function depositTo(address account, IProduct product, UFixed18 amount) external;\n function withdrawTo(address account, IProduct product, UFixed18 amount) external;\n function liquidate(address account, IProduct product) external;\n function settleAccount(address account, Fixed18 amount) external;\n function settleProduct(UFixed18 amount) external;\n function collateral(address account, IProduct product) external view returns (UFixed18);\n function collateral(IProduct product) external view returns (UFixed18);\n function shortfall(IProduct product) external view returns (UFixed18);\n function liquidatable(address account, IProduct product) external view returns (bool);\n function liquidatableNext(address account, IProduct product) external view returns (bool);\n function resolveShortfall(IProduct product, UFixed18 amount) external;\n function claimFee() external;\n}\n" - }, - "contracts/interfaces/IIncentivizer.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"./types/ProgramInfo.sol\";\nimport \"./IController.sol\";\nimport \"./IProduct.sol\";\n\ninterface IIncentivizer {\n event ProgramCreated(IProduct indexed product, uint256 indexed programId, ProgramInfo programInfo, UFixed18 programFeeAmount);\n event ProgramStarted(IProduct indexed product, uint256 indexed programId, uint256 version);\n event ProgramComplete(IProduct indexed product, uint256 indexed programId, uint256 version);\n event Claim(IProduct indexed product, address indexed account, uint256 indexed programId, UFixed18 amount);\n event FeeClaim(Token18 indexed token, UFixed18 amount);\n\n error IncentivizerNotAllowedError(IProduct product);\n error IncentivizerTooManyProgramsError();\n error IncentivizerNotProgramOwnerError(IProduct product, uint256 programId);\n error IncentivizerInvalidProgramError(IProduct product, uint256 programId);\n error IncentivizerBatchClaimArgumentMismatchError();\n\n function programInfos(IProduct product, uint256 programId) external view returns (ProgramInfo memory);\n function fees(Token18 token) external view returns (UFixed18);\n function initialize(IController controller_) external;\n function create(IProduct product, ProgramInfo calldata info) external returns (uint256);\n function complete(IProduct product, uint256 programId) external;\n function sync(IOracleProvider.OracleVersion memory currentOracleVersion) external;\n function syncAccount(address account, IOracleProvider.OracleVersion memory currentOracleVersion) external;\n function claim(IProduct product, uint256[] calldata programIds) external;\n function claim(IProduct[] calldata products, uint256[][] calldata programIds) external;\n function claimFee(Token18[] calldata tokens) external;\n function active(IProduct product) external view returns (uint256);\n function count(IProduct product) external view returns (uint256);\n function unclaimed(IProduct product, address account, uint256 programId) external view returns (UFixed18);\n function available(IProduct product, uint256 programId) external view returns (UFixed18);\n function versionStarted(IProduct product, uint256 programId) external view returns (uint256);\n function versionComplete(IProduct product, uint256 programId) external view returns (uint256);\n function owner(IProduct product, uint256 programId) external view returns (address);\n function treasury(IProduct product, uint256 programId) external view returns (address);\n}\n" - }, - "contracts/interfaces/types/PayoffDefinition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"../../interfaces/IContractPayoffProvider.sol\";\n\n/// @dev PayoffDefinition tyoe\nstruct PayoffDefinition {\n PayoffDefinitionLib.PayoffType payoffType;\n PayoffDefinitionLib.PayoffDirection payoffDirection;\n bytes30 data;\n}\nusing PayoffDefinitionLib for PayoffDefinition global;\ntype PayoffDefinitionStorage is bytes32;\nusing PayoffDefinitionStorageLib for PayoffDefinitionStorage global;\n\n/**\n * @title PayoffDefinitionLib\n * @dev Library that surfaces logic for PayoffDefinition type functionality\n * @notice Library for the PayoffDefinition type. Performs validity and price transformation\n based on the payoff definition type.\n */\nlibrary PayoffDefinitionLib {\n using Address for address;\n\n error PayoffDefinitionUnsupportedTransform(PayoffType payoffType, PayoffDirection payoffDirection);\n error PayoffDefinitionNotContract(PayoffType payoffType, bytes30 data);\n\n /// @dev Payoff function type enum\n enum PayoffType { PASSTHROUGH, CONTRACT }\n enum PayoffDirection { LONG, SHORT }\n\n /**\n * @notice Checks validity of the payoff definition\n * @param self a payoff definition\n * @return Whether the payoff definition is valid for it's given type\n */\n function valid(PayoffDefinition memory self) internal view returns (bool) {\n if (self.payoffType == PayoffType.CONTRACT) return address(_providerContract(self)).isContract();\n\n // All other payoff types should have no data\n return uint(bytes32(self.data)) == 0;\n }\n\n /**\n * @notice Transforms a price based on the payoff definition\n * @param self a payoff definition\n * @param price raw oracle price\n * @return Price transformed by the payoff definition function\n */\n function transform(\n PayoffDefinition memory self,\n Fixed18 price\n ) internal view returns (Fixed18) {\n PayoffType payoffType = self.payoffType;\n PayoffDirection payoffDirection = self.payoffDirection;\n Fixed18 transformedPrice;\n\n // First get the price depending on the type\n if (payoffType == PayoffType.PASSTHROUGH) transformedPrice = price;\n else if (payoffType == PayoffType.CONTRACT) transformedPrice = _payoffFromContract(self, price);\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\n\n // Then transform it depending on the direction flag\n if (self.payoffDirection == PayoffDirection.LONG) return transformedPrice;\n else if (self.payoffDirection == PayoffDirection.SHORT) return transformedPrice.mul(Fixed18Lib.NEG_ONE);\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\n }\n\n /**\n * @notice Parses the data field into an address\n * @dev Reverts if payoffType is not CONTRACT\n * @param self a payoff definition\n * @return IContractPayoffProvider address\n */\n function _providerContract(\n PayoffDefinition memory self\n ) private pure returns (IContractPayoffProvider) {\n if (self.payoffType != PayoffType.CONTRACT) revert PayoffDefinitionNotContract(self.payoffType, self.data);\n // Shift to pull the last 20 bytes, then cast to an address\n return IContractPayoffProvider(address(bytes20(self.data << 80)));\n }\n\n /**\n * @notice Performs a price transformation by calling the underlying payoff contract\n * @param self a payoff definition\n * @param price raw oracle price\n * @return Price transformed by the payoff definition function on the contract\n */\n function _payoffFromContract(\n PayoffDefinition memory self,\n Fixed18 price\n ) private view returns (Fixed18) {\n bytes memory ret = address(_providerContract(self)).functionStaticCall(\n abi.encodeCall(IContractPayoffProvider.payoff, price)\n );\n return Fixed18.wrap(abi.decode(ret, (int256)));\n }\n}\n\n/**\n * @title PayoffDefinitionStorageLib\n * @notice Library that surfaces storage read and writes for the PayoffDefinition type\n */\nlibrary PayoffDefinitionStorageLib {\n function read(PayoffDefinitionStorage self) internal view returns (PayoffDefinition memory) {\n return _storagePointer(self);\n }\n\n function store(PayoffDefinitionStorage self, PayoffDefinition memory value) internal {\n PayoffDefinition storage storagePointer = _storagePointer(self);\n\n storagePointer.payoffType = value.payoffType;\n storagePointer.payoffDirection = value.payoffDirection;\n storagePointer.data = value.data;\n }\n\n function _storagePointer(\n PayoffDefinitionStorage self\n ) private pure returns (PayoffDefinition storage pointer) {\n assembly { pointer.slot := self }\n }\n}\n" - }, - "@equilibria/root/token/types/Token18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"../../number/types/UFixed18.sol\";\n\n/// @dev Token18\ntype Token18 is address;\nusing Token18Lib for Token18 global;\ntype Token18Storage is bytes32;\nusing Token18StorageLib for Token18Storage global;\n\n/**\n * @title Token18Lib\n * @notice Library to manage 18-decimal ERC20s that is compliant with the fixed-decimal types.\n * @dev Maintains significant gas savings over other Token implementations since no conversion take place\n */\nlibrary Token18Lib {\n using SafeERC20 for IERC20;\n\n Token18 public constant ZERO = Token18.wrap(address(0));\n\n /**\n * @notice Returns whether a token is the zero address\n * @param self Token to check for\n * @return Whether the token is the zero address\n */\n function isZero(Token18 self) internal pure returns (bool) {\n return Token18.unwrap(self) == Token18.unwrap(ZERO);\n }\n\n /**\n * @notice Returns whether the two tokens are equal\n * @param a First token to compare\n * @param b Second token to compare\n * @return Whether the two tokens are equal\n */\n function eq(Token18 a, Token18 b) internal pure returns (bool) {\n return Token18.unwrap(a) == Token18.unwrap(b);\n }\n\n /**\n * @notice Approves `grantee` to spend infinite tokens from the caller\n * @param self Token to transfer\n * @param grantee Address to allow spending\n */\n function approve(Token18 self, address grantee) internal {\n IERC20(Token18.unwrap(self)).safeApprove(grantee, type(uint256).max);\n }\n\n /**\n * @notice Approves `grantee` to spend `amount` tokens from the caller\n * @dev There are important race conditions to be aware of when using this function\n with values other than 0. This will revert if moving from non-zero to non-zero amounts\n See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/a55b7d13722e7ce850b626da2313f3e66ca1d101/contracts/token/ERC20/IERC20.sol#L57\n * @param self Token to transfer\n * @param grantee Address to allow spending\n * @param amount Amount of tokens to approve to spend\n */\n function approve(Token18 self, address grantee, UFixed18 amount) internal {\n IERC20(Token18.unwrap(self)).safeApprove(grantee, UFixed18.unwrap(amount));\n }\n\n /**\n * @notice Transfers all held tokens from the caller to the `recipient`\n * @param self Token to transfer\n * @param recipient Address to receive the tokens\n */\n function push(Token18 self, address recipient) internal {\n push(self, recipient, balanceOf(self, address(this)));\n }\n\n /**\n * @notice Transfers `amount` tokens from the caller to the `recipient`\n * @param self Token to transfer\n * @param recipient Address to transfer tokens to\n * @param amount Amount of tokens to transfer\n */\n function push(Token18 self, address recipient, UFixed18 amount) internal {\n IERC20(Token18.unwrap(self)).safeTransfer(recipient, UFixed18.unwrap(amount));\n }\n\n /**\n * @notice Transfers `amount` tokens from the `benefactor` to the caller\n * @dev Reverts if trying to pull Ether\n * @param self Token to transfer\n * @param benefactor Address to transfer tokens from\n * @param amount Amount of tokens to transfer\n */\n function pull(Token18 self, address benefactor, UFixed18 amount) internal {\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, address(this), UFixed18.unwrap(amount));\n }\n\n /**\n * @notice Transfers `amount` tokens from the `benefactor` to `recipient`\n * @dev Reverts if trying to pull Ether\n * @param self Token to transfer\n * @param benefactor Address to transfer tokens from\n * @param recipient Address to transfer tokens to\n * @param amount Amount of tokens to transfer\n */\n function pullTo(Token18 self, address benefactor, address recipient, UFixed18 amount) internal {\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, recipient, UFixed18.unwrap(amount));\n }\n\n /**\n * @notice Returns the name of the token\n * @param self Token to check for\n * @return Token name\n */\n function name(Token18 self) internal view returns (string memory) {\n return IERC20Metadata(Token18.unwrap(self)).name();\n }\n\n /**\n * @notice Returns the symbol of the token\n * @param self Token to check for\n * @return Token symbol\n */\n function symbol(Token18 self) internal view returns (string memory) {\n return IERC20Metadata(Token18.unwrap(self)).symbol();\n }\n\n /**\n * @notice Returns the `self` token balance of the caller\n * @param self Token to check for\n * @return Token balance of the caller\n */\n function balanceOf(Token18 self) internal view returns (UFixed18) {\n return balanceOf(self, address(this));\n }\n\n /**\n * @notice Returns the `self` token balance of `account`\n * @param self Token to check for\n * @param account Account to check\n * @return Token balance of the account\n */\n function balanceOf(Token18 self, address account) internal view returns (UFixed18) {\n return UFixed18.wrap(IERC20(Token18.unwrap(self)).balanceOf(account));\n }\n}\n\nlibrary Token18StorageLib {\n function read(Token18Storage self) internal view returns (Token18 value) {\n assembly {\n value := sload(self)\n }\n }\n\n function store(Token18Storage self, Token18 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/IERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\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 amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` 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(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\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" - }, - "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 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 using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\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 function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" - }, - "@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/Fixed18.sol\";\n\ninterface IOracleProvider {\n /// @dev A singular oracle version with its corresponding data\n struct OracleVersion {\n /// @dev The iterative version\n uint256 version;\n\n /// @dev the timestamp of the oracle update\n uint256 timestamp;\n\n /// @dev The oracle price of the corresponding version\n Fixed18 price;\n }\n\n function sync() external returns (OracleVersion memory);\n function currentVersion() external view returns (OracleVersion memory);\n function atVersion(uint256 oracleVersion) external view returns (OracleVersion memory);\n}\n" - }, - "contracts/interfaces/types/ProgramInfo.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"../IProduct.sol\";\nimport \"./Position.sol\";\nimport \"./Accumulator.sol\";\n\n/// @dev ProgramInfo type\nstruct ProgramInfo {\n /// @dev Coordinator for this program\n uint256 coordinatorId;\n\n /// @dev Amount of total maker and taker rewards\n Position amount;\n\n /// @dev start timestamp of the program\n uint256 start;\n\n /// @dev duration of the program (in seconds)\n uint256 duration;\n\n /**\n * @dev Reward ERC20 token contract\n * @notice Perennial does not support non-standard ERC20s as reward tokens for incentive programs, including,\n but not limited to: fee on transfer and rebase tokens. Using such a non-standard token will likely\n result in loss of funds.\n */\n Token18 token;\n}\nusing ProgramInfoLib for ProgramInfo global;\n\n/**\n * @title ProgramInfoLib\n * @notice Library that snapshots the static information for a single program.\n * @dev This information does not change during the operation of a program.\n */\nlibrary ProgramInfoLib {\n uint256 private constant MIN_DURATION = 1 days;\n uint256 private constant MAX_DURATION = 2 * 365 days;\n\n error ProgramInvalidStartError();\n error ProgramInvalidDurationError();\n\n /**\n * @notice Validates and creates a new Program\n * @dev Reverts for invalid programInfos\n * @param programInfo Un-sanitized static program information\n */\n function validate(ProgramInfo memory programInfo) internal view {\n if (isStarted(programInfo, block.timestamp)) revert ProgramInvalidStartError();\n if (programInfo.duration < MIN_DURATION || programInfo.duration > MAX_DURATION) revert ProgramInvalidDurationError();\n }\n\n /**\n * @notice Computes a new program info with the fee taken out of the amount\n * @param programInfo Original program info\n * @param incentivizationFee The incentivization fee\n * @return New program info\n * @return Fee amount\n */\n function deductFee(ProgramInfo memory programInfo, UFixed18 incentivizationFee)\n internal pure returns (ProgramInfo memory, UFixed18) {\n Position memory newProgramAmount = programInfo.amount.mul(UFixed18Lib.ONE.sub(incentivizationFee));\n UFixed18 programFeeAmount = programInfo.amount.sub(newProgramAmount).sum();\n programInfo.amount = newProgramAmount;\n return (programInfo, programFeeAmount);\n }\n\n /**\n * @notice Returns the maker and taker amounts per position share\n * @param self The ProgramInfo to operate on\n * @return programFee Amounts per share\n */\n function amountPerShare(ProgramInfo memory self) internal pure returns (Accumulator memory) {\n return self.amount.div(self.duration);\n }\n\n /**\n * @notice Returns whether the program has started by timestamp `timestamp`\n * @param self The ProgramInfo to operate on\n * @param timestamp Timestamp to check for\n * @return Whether the program has started\n */\n function isStarted(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\n return timestamp >= self.start;\n }\n\n /**\n * @notice Returns whether the program is completed by timestamp `timestamp`\n * @param self The ProgramInfo to operate on\n * @param timestamp Timestamp to check for\n * @return Whether the program is completed\n */\n function isComplete(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\n return timestamp >= (self.start + self.duration);\n }\n}\n" - }, - "contracts/interfaces/types/Position.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"../IProduct.sol\";\nimport \"./Accumulator.sol\";\nimport \"./PrePosition.sol\";\nimport \"./PackedPosition.sol\";\n\n/// @dev Position type\nstruct Position {\n /// @dev Quantity of the maker position\n UFixed18 maker;\n /// @dev Quantity of the taker position\n UFixed18 taker;\n}\nusing PositionLib for Position global;\n\n/**\n * @title PositionLib\n * @notice Library that surfaces math and settlement computations for the Position type.\n * @dev Positions track the current quantity of the account's maker and taker positions respectively\n * denominated as a unit of the product's payoff function.\n */\nlibrary PositionLib {\n /**\n * @notice Creates a packed position from an position\n * @param self A position\n * @return New packed position\n */\n function pack(Position memory self) internal pure returns (PackedPosition memory) {\n return PackedPosition({maker: self.maker.pack(), taker: self.taker.pack()});\n }\n\n /**\n * @notice Returns whether the position is fully empty\n * @param self A position\n * @return Whether the position is empty\n */\n function isEmpty(Position memory self) internal pure returns (bool) {\n return self.maker.isZero() && self.taker.isZero();\n }\n\n /**\n * @notice Adds position `a` and `b` together, returning the result\n * @param a The first position to sum\n * @param b The second position to sum\n * @return Resulting summed position\n */\n function add(Position memory a, Position memory b) internal pure returns (Position memory) {\n return Position({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\n }\n\n /**\n * @notice Subtracts position `b` from `a`, returning the result\n * @param a The position to subtract from\n * @param b The position to subtract\n * @return Resulting subtracted position\n */\n function sub(Position memory a, Position memory b) internal pure returns (Position memory) {\n return Position({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\n }\n\n /**\n * @notice Multiplies position `self` by accumulator `accumulator` and returns the resulting accumulator\n * @param self The Position to operate on\n * @param accumulator The accumulator to multiply by\n * @return Resulting multiplied accumulator\n */\n function mul(Position memory self, Accumulator memory accumulator) internal pure returns (Accumulator memory) {\n return Accumulator({\n maker: Fixed18Lib.from(self.maker).mul(accumulator.maker),\n taker: Fixed18Lib.from(self.taker).mul(accumulator.taker)\n });\n }\n\n /**\n * @notice Scales position `self` by fixed-decimal `scale` and returns the resulting position\n * @param self The Position to operate on\n * @param scale The Fixed-decimal to scale by\n * @return Resulting scaled position\n */\n function mul(Position memory self, UFixed18 scale) internal pure returns (Position memory) {\n return Position({maker: self.maker.mul(scale), taker: self.taker.mul(scale)});\n }\n\n /**\n * @notice Divides position `self` by `b` and returns the resulting accumulator\n * @param self The Position to operate on\n * @param b The number to divide by\n * @return Resulting divided accumulator\n */\n function div(Position memory self, uint256 b) internal pure returns (Accumulator memory) {\n return Accumulator({\n maker: Fixed18Lib.from(self.maker).div(Fixed18Lib.from(UFixed18Lib.from(b))),\n taker: Fixed18Lib.from(self.taker).div(Fixed18Lib.from(UFixed18Lib.from(b)))\n });\n }\n\n /**\n * @notice Returns the maximum of `self`'s maker and taker values\n * @param self The struct to operate on\n * @return Resulting maximum value\n */\n function max(Position memory self) internal pure returns (UFixed18) {\n return UFixed18Lib.max(self.maker, self.taker);\n }\n\n /**\n * @notice Sums the maker and taker together from a single position\n * @param self The struct to operate on\n * @return The sum of its maker and taker\n */\n function sum(Position memory self) internal pure returns (UFixed18) {\n return self.maker.add(self.taker);\n }\n\n /**\n * @notice Computes the next position after the pending-settlement position delta is included\n * @param self The current Position\n * @param pre The pending-settlement position delta\n * @return Next Position\n */\n function next(Position memory self, PrePosition memory pre) internal pure returns (Position memory) {\n return sub(add(self, pre.openPosition), pre.closePosition);\n }\n\n /**\n * @notice Returns the settled position at oracle version `toOracleVersion`\n * @dev Checks if a new position is ready to be settled based on the provided `toOracleVersion`\n * and `pre` and returns accordingly\n * @param self The current Position\n * @param pre The pending-settlement position delta\n * @param toOracleVersion The oracle version to settle to\n * @return Settled position at oracle version\n * @return Fee accrued from opening or closing the position\n * @return Whether a new position was settled\n */\n function settled(\n Position memory self,\n PrePosition memory pre,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal view returns (Position memory, UFixed18, bool) {\n return pre.canSettle(toOracleVersion) ? (next(self, pre), pre.computeFee(toOracleVersion), true) : (self, UFixed18Lib.ZERO, false);\n }\n\n /**\n * @notice Returns the socialization factor for the current position\n * @dev Socialization account for the case where `taker` > `maker` temporarily due to a liquidation\n * on the maker side. This dampens the taker's exposure pro-rata to ensure that the maker side\n * is never exposed over 1 x short.\n * @param self The Position to operate on\n * @return Socialization factor\n */\n function socializationFactor(Position memory self) internal pure returns (UFixed18) {\n return self.taker.isZero() ? UFixed18Lib.ONE : UFixed18Lib.min(UFixed18Lib.ONE, self.maker.div(self.taker));\n }\n}\n" - }, - "contracts/interfaces/types/Accumulator.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/Fixed18.sol\";\nimport \"./PackedAccumulator.sol\";\n\n/// @dev Accumulator type\nstruct Accumulator {\n /// @dev maker accumulator per share\n Fixed18 maker;\n /// @dev taker accumulator per share\n Fixed18 taker;\n}\nusing AccumulatorLib for Accumulator global;\n\n/**\n * @title AccountAccumulatorLib\n * @notice Library that surfaces math operations for the Accumulator type.\n * @dev Accumulators track the cumulative change in position value over time for the maker and taker positions\n * respectively. Account-level accumulators can then use two of these values `a` and `a'` to compute the\n * change in position value since last sync. This change in value is then used to compute P&L and fees.\n */\nlibrary AccumulatorLib {\n /**\n * @notice Creates a packed accumulator from an accumulator\n * @param self an accumulator\n * @return New packed accumulator\n */\n function pack(Accumulator memory self) internal pure returns (PackedAccumulator memory) {\n return PackedAccumulator({maker: self.maker.pack(), taker: self.taker.pack()});\n }\n\n /**\n * @notice Adds two accumulators together\n * @param a The first accumulator to sum\n * @param b The second accumulator to sum\n * @return The resulting summed accumulator\n */\n function add(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\n return Accumulator({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\n }\n\n /**\n * @notice Subtracts accumulator `b` from `a`\n * @param a The accumulator to subtract from\n * @param b The accumulator to subtract\n * @return The resulting subtracted accumulator\n */\n function sub(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\n return Accumulator({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\n }\n\n /**\n * @notice Multiplies two accumulators together\n * @param a The first accumulator to multiply\n * @param b The second accumulator to multiply\n * @return The resulting multiplied accumulator\n */\n function mul(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\n return Accumulator({maker: a.maker.mul(b.maker), taker: a.taker.mul(b.taker)});\n }\n\n /**\n * @notice Sums the maker and taker together from a single accumulator\n * @param self The struct to operate on\n * @return The sum of its maker and taker\n */\n function sum(Accumulator memory self) internal pure returns (Fixed18) {\n return self.maker.add(self.taker);\n }\n}\n" - }, - "@equilibria/root/curve/types/JumpRateUtilizationCurve.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"../CurveMath.sol\";\nimport \"../../number/types/PackedUFixed18.sol\";\nimport \"../../number/types/PackedFixed18.sol\";\n\n/// @dev JumpRateUtilizationCurve type\nstruct JumpRateUtilizationCurve {\n PackedFixed18 minRate;\n PackedFixed18 maxRate;\n PackedFixed18 targetRate;\n PackedUFixed18 targetUtilization;\n}\nusing JumpRateUtilizationCurveLib for JumpRateUtilizationCurve global;\ntype JumpRateUtilizationCurveStorage is bytes32;\nusing JumpRateUtilizationCurveStorageLib for JumpRateUtilizationCurveStorage global;\n\n/**\n * @title JumpRateUtilizationCurveLib\n * @notice Library for the Jump Rate utilization curve type\n */\nlibrary JumpRateUtilizationCurveLib {\n /**\n * @notice Computes the corresponding rate for a utilization ratio\n * @param utilization The utilization ratio\n * @return The corresponding rate\n */\n function compute(JumpRateUtilizationCurve memory self, UFixed18 utilization) internal pure returns (Fixed18) {\n UFixed18 targetUtilization = self.targetUtilization.unpack();\n if (utilization.lt(targetUtilization)) {\n return CurveMath.linearInterpolation(\n UFixed18Lib.ZERO,\n self.minRate.unpack(),\n targetUtilization,\n self.targetRate.unpack(),\n utilization\n );\n }\n if (utilization.lt(UFixed18Lib.ONE)) {\n return CurveMath.linearInterpolation(\n targetUtilization,\n self.targetRate.unpack(),\n UFixed18Lib.ONE,\n self.maxRate.unpack(),\n utilization\n );\n }\n return self.maxRate.unpack();\n }\n}\n\nlibrary JumpRateUtilizationCurveStorageLib {\n function read(JumpRateUtilizationCurveStorage self) internal view returns (JumpRateUtilizationCurve memory) {\n return _storagePointer(self);\n }\n\n function store(JumpRateUtilizationCurveStorage self, JumpRateUtilizationCurve memory value) internal {\n JumpRateUtilizationCurve storage storagePointer = _storagePointer(self);\n\n storagePointer.minRate = value.minRate;\n storagePointer.maxRate = value.maxRate;\n storagePointer.targetRate = value.targetRate;\n storagePointer.targetUtilization = value.targetUtilization;\n }\n\n function _storagePointer(JumpRateUtilizationCurveStorage self)\n private pure returns (JumpRateUtilizationCurve storage pointer) {\n assembly { pointer.slot := self }\n }\n}" - }, - "contracts/interfaces/IPayoffProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/Fixed18.sol\";\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"./types/PayoffDefinition.sol\";\n\ninterface IPayoffProvider {\n error PayoffProviderInvalidOracle();\n error PayoffProviderInvalidPayoffDefinitionError();\n\n function oracle() external view returns (IOracleProvider);\n function payoffDefinition() external view returns (PayoffDefinition memory);\n function currentVersion() external view returns (IOracleProvider.OracleVersion memory);\n function atVersion(uint256 oracleVersion) external view returns (IOracleProvider.OracleVersion memory);\n}\n" - }, - "contracts/interfaces/IParamProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\";\n\ninterface IParamProvider {\n event MaintenanceUpdated(UFixed18 newMaintenance);\n event FundingFeeUpdated(UFixed18 newFundingFee);\n event MakerFeeUpdated(UFixed18 newMakerFee);\n event TakerFeeUpdated(UFixed18 newTakerFee);\n event MakerLimitUpdated(UFixed18 newMakerLimit);\n event JumpRateUtilizationCurveUpdated(\n Fixed18 minRate,\n Fixed18 maxRate,\n Fixed18 targetRate,\n UFixed18 targetUtilization\n );\n\n error ParamProviderInvalidMakerFee();\n error ParamProviderInvalidTakerFee();\n error ParamProviderInvalidFundingFee();\n \n function maintenance() external view returns (UFixed18);\n function updateMaintenance(UFixed18 newMaintenance) external;\n function fundingFee() external view returns (UFixed18);\n function updateFundingFee(UFixed18 newFundingFee) external;\n function makerFee() external view returns (UFixed18);\n function updateMakerFee(UFixed18 newMakerFee) external;\n function takerFee() external view returns (UFixed18);\n function updateTakerFee(UFixed18 newTakerFee) external;\n function makerLimit() external view returns (UFixed18);\n function updateMakerLimit(UFixed18 newMakerLimit) external;\n function utilizationCurve() external view returns (JumpRateUtilizationCurve memory);\n function updateUtilizationCurve(JumpRateUtilizationCurve memory newUtilizationCurve) external;\n}\n" - }, - "contracts/interfaces/types/PrePosition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"./Position.sol\";\nimport \"../IProduct.sol\";\n\n/// @dev PrePosition type\nstruct PrePosition {\n /// @dev Oracle version at which the new position delta was recorded\n uint256 oracleVersion;\n\n /// @dev Size of position to open at oracle version\n Position openPosition;\n\n /// @dev Size of position to close at oracle version\n Position closePosition;\n}\nusing PrePositionLib for PrePosition global;\n\n/**\n * @title PrePositionLib\n * @notice Library that manages a pre-settlement position delta.\n * @dev PrePositions track the currently awaiting-settlement deltas to a settled Position. These are\n * Primarily necessary to introduce lag into the settlement system such that oracle lag cannot be\n * gamed to a user's advantage. When a user opens or closes a new position, it sits as a PrePosition\n * for one oracle version until it's settle into the Position, making it then effective. PrePositions\n * are automatically settled at the correct oracle version even if a flywheel call doesn't happen until\n * several version into the future by using the historical version lookups in the corresponding \"Versioned\"\n * global state types.\n */\nlibrary PrePositionLib {\n /**\n * @notice Returns whether there is no pending-settlement position delta\n * @dev Can be \"empty\" even with a non-zero oracleVersion if a position is opened and\n * closed in the same version netting out to a zero position delta\n * @param self The struct to operate on\n * @return Whether the pending-settlement position delta is empty\n */\n function isEmpty(PrePosition memory self) internal pure returns (bool) {\n return self.openPosition.isEmpty() && self.closePosition.isEmpty();\n }\n\n /**\n * @notice Increments the maker side of the open position delta\n * @dev Nets out open and close deltas to minimize the size of each\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @param amount The position amount to open\n */\n function openMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\n self.openPosition.maker = self.openPosition.maker.add(amount);\n self.oracleVersion = currentVersion;\n _netMake(self);\n }\n\n /**\n * @notice Increments the maker side of the close position delta\n * @dev Nets out open and close deltas to minimize the size of each\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @param amount The maker position amount to close\n */\n function closeMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\n self.closePosition.maker = self.closePosition.maker.add(amount);\n self.oracleVersion = currentVersion;\n _netMake(self);\n }\n\n /**\n * @notice Increments the taker side of the open position delta\n * @dev Nets out open and close deltas to minimize the size of each\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @param amount The taker position amount to open\n */\n function openTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\n self.openPosition.taker = self.openPosition.taker.add(amount);\n self.oracleVersion = currentVersion;\n _netTake(self);\n }\n\n /**\n * @notice Increments the taker side of the close position delta\n * @dev Nets out open and close deltas to minimize the size of each\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @param amount The taker position amount to close\n */\n function closeTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\n self.closePosition.taker = self.closePosition.taker.add(amount);\n self.oracleVersion = currentVersion;\n _netTake(self);\n }\n\n /**\n * @notice Nets out the open and close on the maker side of the position delta\n * @param self The struct to operate on\n */\n function _netMake(PrePosition storage self) private {\n if (self.openPosition.maker.gt(self.closePosition.maker)) {\n self.openPosition.maker = self.openPosition.maker.sub(self.closePosition.maker);\n self.closePosition.maker = UFixed18Lib.ZERO;\n } else {\n self.closePosition.maker = self.closePosition.maker.sub(self.openPosition.maker);\n self.openPosition.maker = UFixed18Lib.ZERO;\n }\n }\n\n /**\n * @notice Nets out the open and close on the taker side of the position delta\n * @param self The struct to operate on\n */\n function _netTake(PrePosition storage self) private {\n if (self.openPosition.taker.gt(self.closePosition.taker)) {\n self.openPosition.taker = self.openPosition.taker.sub(self.closePosition.taker);\n self.closePosition.taker = UFixed18Lib.ZERO;\n } else {\n self.closePosition.taker = self.closePosition.taker.sub(self.openPosition.taker);\n self.openPosition.taker = UFixed18Lib.ZERO;\n }\n }\n\n /**\n * @notice Returns whether the the pending position delta can be settled at version `toOracleVersion`\n * @dev Pending-settlement positions deltas can be settled (1) oracle version after they are recorded\n * @param self The struct to operate on\n * @param toOracleVersion The potential oracle version to settle\n * @return Whether the position delta can be settled\n */\n function canSettle(\n PrePosition memory self,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal pure returns (bool) {\n return !isEmpty(self) && toOracleVersion.version > self.oracleVersion;\n }\n\n /**\n * @notice Computes the fee incurred for opening or closing the pending-settlement position\n * @dev Must be called from a valid product to get the proper fee amounts\n * @param self The struct to operate on\n * @param toOracleVersion The oracle version at which settlement takes place\n * @return positionFee The maker / taker fee incurred\n */\n function computeFee(\n PrePosition memory self,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal view returns (UFixed18) {\n Position memory positionDelta = self.openPosition.add(self.closePosition);\n\n (UFixed18 makerNotional, UFixed18 takerNotional) = (\n Fixed18Lib.from(positionDelta.maker).mul(toOracleVersion.price).abs(),\n Fixed18Lib.from(positionDelta.taker).mul(toOracleVersion.price).abs()\n );\n\n IProduct product = IProduct(address(this));\n return makerNotional.mul(product.makerFee()).add(takerNotional.mul(product.takerFee()));\n }\n\n /**\n * @notice Computes the next oracle version to settle\n * @dev - If there is no pending-settlement position delta, returns the current oracle version\n * - Otherwise returns the oracle version at which the pending-settlement position delta can be first settled\n *\n * Corresponds to point (b) in the Position settlement flow\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @return Next oracle version to settle\n */\n function settleVersion(PrePosition storage self, uint256 currentVersion) internal view returns (uint256) {\n uint256 _oracleVersion = self.oracleVersion;\n return _oracleVersion == 0 ? currentVersion : _oracleVersion + 1;\n }\n}\n" - }, - "@equilibria/root/curve/CurveMath.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"../number/types/UFixed18.sol\";\nimport \"../number/types/Fixed18.sol\";\n\n/**\n * @title CurveMath\n * @notice Library for managing math operations for utilization curves.\n */\nlibrary CurveMath {\n error CurveMathOutOfBoundsError();\n\n /**\n * @notice Computes a linear interpolation between two points\n * @param startX First point's x-coordinate\n * @param startY First point's y-coordinate\n * @param endX Second point's x-coordinate\n * @param endY Second point's y-coordinate\n * @param targetX x-coordinate to interpolate\n * @return y-coordinate for `targetX` along the line from (`startX`, `startY`) -> (`endX`, `endY`)\n */\n function linearInterpolation(\n UFixed18 startX,\n Fixed18 startY,\n UFixed18 endX,\n Fixed18 endY,\n UFixed18 targetX\n ) internal pure returns (Fixed18) {\n if (targetX.lt(startX) || targetX.gt(endX)) revert CurveMathOutOfBoundsError();\n\n UFixed18 xRange = endX.sub(startX);\n Fixed18 yRange = endY.sub(startY);\n UFixed18 xRatio = targetX.sub(startX).div(xRange);\n return yRange.mul(Fixed18Lib.from(xRatio)).add(startY);\n }\n}\n" - }, - "contracts/interfaces/IContractPayoffProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/Fixed18.sol\";\n\ninterface IContractPayoffProvider {\n function payoff(Fixed18 price) external view returns (Fixed18 payoff);\n}\n" - }, - "contracts/interfaces/types/PackedPosition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/PackedUFixed18.sol\";\nimport \"./Position.sol\";\n\n/// @dev PackedPosition type\nstruct PackedPosition {\n /// @dev Quantity of the maker position\n PackedUFixed18 maker;\n /// @dev Quantity of the taker position\n PackedUFixed18 taker;\n}\nusing PackedPositionLib for PackedPosition global;\n\n/**\n * @title PackedPositionLib\n * @dev A packed version of the Position which takes up a single storage slot using `PackedFixed18` values.\n * @notice Library for the packed Position type.\n */\nlibrary PackedPositionLib {\n /**\n * @notice Creates an position from a packed position\n * @param self packed position\n * @return New position\n */\n function unpack(PackedPosition memory self) internal pure returns (Position memory) {\n return Position({maker: self.maker.unpack(), taker: self.taker.unpack()});\n }\n}\n" - }, - "contracts/interfaces/types/PackedAccumulator.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/PackedFixed18.sol\";\nimport \"./Accumulator.sol\";\n\n/// @dev PackedAccumulator type\nstruct PackedAccumulator {\n /// @dev maker accumulator per share\n PackedFixed18 maker;\n /// @dev taker accumulator per share\n PackedFixed18 taker;\n}\nusing PackedAccumulatorLib for PackedAccumulator global;\n\n/**\n * @title PackedAccumulatorLib\n * @dev A packed version of the Accumulator which takes up a single storage slot using `PackedFixed18` values.\n * @notice Library for the packed Accumulator type.\n */\nlibrary PackedAccumulatorLib {\n /**\n * @notice Creates an accumulator from a packed accumulator\n * @param self packed accumulator\n * @return New accumulator\n */\n function unpack(PackedAccumulator memory self) internal pure returns (Accumulator memory) {\n return Accumulator({maker: self.maker.unpack(), taker: self.taker.unpack()});\n }\n}\n" - }, - "contracts/product/types/accumulator/VersionedAccumulator.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../../../interfaces/IProduct.sol\";\nimport \"../../../interfaces/types/Accumulator.sol\";\nimport \"../position/VersionedPosition.sol\";\n\n/// @dev VersionedAccumulator type\nstruct VersionedAccumulator {\n /// @dev Latest synced oracle version\n uint256 latestVersion;\n\n /// @dev Mapping of accumulator value at each settled oracle version\n mapping(uint256 => PackedAccumulator) _valueAtVersion;\n\n /// @dev Mapping of accumulator share at each settled oracle version\n mapping(uint256 => PackedAccumulator) _shareAtVersion;\n}\nusing VersionedAccumulatorLib for VersionedAccumulator global;\n\n/**\n * @title VersionedAccumulatorLib\n * @notice Library that manages global versioned accumulator state.\n * @dev Manages two accumulators: value and share. The value accumulator measures the change in position value\n * over time. The share accumulator measures the change in liquidity ownership over time (for tracking\n * incentivization rewards).\n *\n * Both accumulators are stamped for historical lookup anytime there is a global settlement, which services\n * the delayed-position accounting. It is not guaranteed that every version will have a value stamped, but\n * only versions when a settlement occurred are needed for this historical computation.\n */\nlibrary VersionedAccumulatorLib {\n /**\n * @notice Returns the stamped value accumulator at `oracleVersion`\n * @param self The struct to operate on\n * @param oracleVersion The oracle version to retrieve the value at\n * @return The stamped value accumulator at the requested version\n */\n function valueAtVersion(VersionedAccumulator storage self, uint256 oracleVersion) internal view returns (Accumulator memory) {\n return self._valueAtVersion[oracleVersion].unpack();\n }\n\n /**\n * @notice Returns the stamped share accumulator at `oracleVersion`\n * @param self The struct to operate on\n * @param oracleVersion The oracle version to retrieve the share at\n * @return The stamped share accumulator at the requested version\n */\n function shareAtVersion(VersionedAccumulator storage self, uint256 oracleVersion) internal view returns (Accumulator memory) {\n return self._shareAtVersion[oracleVersion].unpack();\n }\n\n /**\n * @notice Globally accumulates all value (position + funding) and share since last oracle update\n * @param self The struct to operate on\n * @param fundingFee The funding fee rate for the product\n * @param position Pointer to global position\n * @param latestOracleVersion The oracle version to accumulate from\n * @param toOracleVersion The oracle version to accumulate to\n * @return accumulatedFee The total fee accrued from accumulation\n */\n function accumulate(\n VersionedAccumulator storage self,\n UFixed18 fundingFee,\n VersionedPosition storage position,\n IOracleProvider.OracleVersion memory latestOracleVersion,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal returns (UFixed18 accumulatedFee) {\n Position memory latestPosition = position.positionAtVersion(latestOracleVersion.version);\n\n // accumulate funding\n Accumulator memory accumulatedPosition;\n (accumulatedPosition, accumulatedFee) =\n _accumulateFunding(fundingFee, latestPosition, latestOracleVersion, toOracleVersion);\n\n // accumulate position\n accumulatedPosition = accumulatedPosition.add(\n _accumulatePosition(latestPosition, latestOracleVersion, toOracleVersion));\n\n // accumulate share\n Accumulator memory accumulatedShare =\n _accumulateShare(latestPosition, latestOracleVersion, toOracleVersion);\n\n // save update\n self._valueAtVersion[toOracleVersion.version] = valueAtVersion(self, latestOracleVersion.version)\n .add(accumulatedPosition)\n .pack();\n self._shareAtVersion[toOracleVersion.version] = shareAtVersion(self, latestOracleVersion.version)\n .add(accumulatedShare)\n .pack();\n self.latestVersion = toOracleVersion.version;\n }\n\n /**\n * @notice Globally accumulates all funding since last oracle update\n * @dev If an oracle version is skipped due to no pre positions, funding will continue to be\n * pegged to the price of the last snapshotted oracleVersion until a new one is accumulated.\n * This is an acceptable approximation.\n * @param fundingFee The funding fee rate for the product\n * @param latestPosition The latest global position\n * @param latestOracleVersion The oracle version to accumulate from\n * @param toOracleVersion The oracle version to accumulate to\n * @return accumulatedFunding The total amount accumulated from funding\n * @return accumulatedFee The total fee accrued from funding accumulation\n */\n function _accumulateFunding(\n UFixed18 fundingFee,\n Position memory latestPosition,\n IOracleProvider.OracleVersion memory latestOracleVersion,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) private view returns (Accumulator memory accumulatedFunding, UFixed18 accumulatedFee) {\n if (_product().closed()) return (Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO), UFixed18Lib.ZERO);\n if (latestPosition.taker.isZero()) return (Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO), UFixed18Lib.ZERO);\n if (latestPosition.maker.isZero()) return (Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO), UFixed18Lib.ZERO);\n\n uint256 elapsed = toOracleVersion.timestamp - latestOracleVersion.timestamp;\n\n UFixed18 takerNotional = Fixed18Lib.from(latestPosition.taker).mul(latestOracleVersion.price).abs();\n UFixed18 socializedNotional = takerNotional.mul(latestPosition.socializationFactor());\n\n Fixed18 rateAccumulated = _product().rate(latestPosition)\n .mul(Fixed18Lib.from(UFixed18Lib.from(elapsed)));\n Fixed18 fundingAccumulated = rateAccumulated.mul(Fixed18Lib.from(socializedNotional));\n accumulatedFee = fundingAccumulated.abs().mul(fundingFee);\n\n Fixed18 fundingAccumulatedWithoutFee = Fixed18Lib.from(\n fundingAccumulated.sign(),\n fundingAccumulated.abs().sub(accumulatedFee)\n );\n\n bool makerPaysFunding = fundingAccumulated.sign() < 0;\n accumulatedFunding.maker = (makerPaysFunding ? fundingAccumulated : fundingAccumulatedWithoutFee)\n .div(Fixed18Lib.from(latestPosition.maker));\n accumulatedFunding.taker = (makerPaysFunding ? fundingAccumulatedWithoutFee : fundingAccumulated)\n .div(Fixed18Lib.from(latestPosition.taker)).mul(Fixed18Lib.NEG_ONE);\n }\n\n /**\n * @notice Globally accumulates position PNL since last oracle update\n * @param latestPosition The latest global position\n * @param latestOracleVersion The oracle version to accumulate from\n * @param toOracleVersion The oracle version to accumulate to\n * @return accumulatedPosition The total amount accumulated from position PNL\n */\n function _accumulatePosition(\n Position memory latestPosition,\n IOracleProvider.OracleVersion memory latestOracleVersion,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) private view returns (Accumulator memory accumulatedPosition) {\n if (_product().closed()) return Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO);\n if (latestPosition.taker.isZero()) return Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO);\n if (latestPosition.maker.isZero()) return Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO);\n\n Fixed18 oracleDelta = toOracleVersion.price.sub(latestOracleVersion.price);\n Fixed18 totalTakerDelta = oracleDelta.mul(Fixed18Lib.from(latestPosition.taker));\n Fixed18 socializedTakerDelta = totalTakerDelta.mul(Fixed18Lib.from(latestPosition.socializationFactor()));\n\n accumulatedPosition.maker = socializedTakerDelta.div(Fixed18Lib.from(latestPosition.maker)).mul(Fixed18Lib.NEG_ONE);\n accumulatedPosition.taker = socializedTakerDelta.div(Fixed18Lib.from(latestPosition.taker));\n }\n\n /**\n * @notice Globally accumulates position's share of the total market since last oracle update\n * @dev This is used to compute incentivization rewards based on market participation\n * @param latestPosition The latest global position\n * @param latestOracleVersion The oracle version to accumulate from\n * @param toOracleVersion The oracle version to accumulate to\n * @return accumulatedShare The total share amount accumulated per position\n */\n function _accumulateShare(\n Position memory latestPosition,\n IOracleProvider.OracleVersion memory latestOracleVersion,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) private pure returns (Accumulator memory accumulatedShare) {\n uint256 elapsed = toOracleVersion.timestamp - latestOracleVersion.timestamp;\n\n accumulatedShare.maker = latestPosition.maker.isZero() ?\n Fixed18Lib.ZERO :\n Fixed18Lib.from(UFixed18Lib.from(elapsed).div(latestPosition.maker));\n accumulatedShare.taker = latestPosition.taker.isZero() ?\n Fixed18Lib.ZERO :\n Fixed18Lib.from(UFixed18Lib.from(elapsed).div(latestPosition.taker));\n }\n\n function _product() private view returns (IProduct) {\n return IProduct(address(this));\n }\n}\n" - }, - "contracts/product/types/position/VersionedPosition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../../../interfaces/types/PrePosition.sol\";\nimport \"../../../interfaces/types/PackedPosition.sol\";\n\n//// @dev VersionedPosition type\nstruct VersionedPosition {\n /// @dev Mapping of global position at each version\n mapping(uint256 => PackedPosition) _positionAtVersion;\n\n /// @dev Current global pending-settlement position delta\n PrePosition pre;\n}\nusing VersionedPositionLib for VersionedPosition global;\n\n/**\n * @title VersionedPositionLib\n * @notice Library that manages global position state.\n * @dev Global position state is used to compute utilization rate and socialization, and to account for and\n * distribute fees globally.\n *\n * Positions are stamped for historical lookup anytime there is a global settlement, which services\n * the delayed-position accounting. It is not guaranteed that every version will have a value stamped, but\n * only versions when a settlement occurred are needed for this historical computation.\n */\nlibrary VersionedPositionLib {\n /**\n * @notice Returns the current global position\n * @return Current global position\n */\n function positionAtVersion(VersionedPosition storage self, uint256 oracleVersion) internal view returns (Position memory) {\n return self._positionAtVersion[oracleVersion].unpack();\n }\n\n /**\n * @notice Settled the global position to oracle version `toOracleVersion`\n * @param self The struct to operate on\n * @param latestVersion The latest settled oracle version\n * @param toOracleVersion The oracle version to settle to\n * @return positionFee The fee accrued from opening or closing a new position\n */\n function settle(\n VersionedPosition storage self,\n uint256 latestVersion,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal returns (UFixed18) {\n (Position memory newPosition, UFixed18 positionFee, bool settled) =\n positionAtVersion(self, latestVersion).settled(self.pre, toOracleVersion);\n\n self._positionAtVersion[toOracleVersion.version] = newPosition.pack();\n if (settled) delete self.pre;\n\n return positionFee;\n }\n}\n" - } - }, - "settings": { - "optimizer": { - "enabled": true, - "runs": 5800 - }, - "outputSelection": { - "*": { - "*": ["abi", "evm.bytecode", "evm.deployedBytecode", "evm.methodIdentifiers", "metadata"], - "": ["ast"] - } - } - } -} diff --git a/packages/perennial/deployments/kovan/solcInputs/9ec7860e75dc1d06fa99c459c5b65009.json b/packages/perennial/deployments/kovan/solcInputs/9ec7860e75dc1d06fa99c459c5b65009.json deleted file mode 100644 index 4133d5945..000000000 --- a/packages/perennial/deployments/kovan/solcInputs/9ec7860e75dc1d06fa99c459c5b65009.json +++ /dev/null @@ -1,123 +0,0 @@ -{ - "language": "Solidity", - "sources": { - "contracts/lens/PerennialLens.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../interfaces/IPerennialLens.sol\";\n\n/**\n * @title Lens contract to conveniently pull protocol data\n * @notice All functions should be called using `callStatic`\n */\ncontract PerennialLens is IPerennialLens {\n /**\n * @notice Protocol controller\n * @return Protocol controller\n */\n IController public immutable controller;\n\n /// @param _controller Protocol controller address\n constructor(IController _controller) {\n controller = _controller;\n }\n\n /**\n * @notice Returns the name of the provided `product`\n * @param product Product address\n * @return Name of the product\n */\n function name(IProduct product) external view returns (string memory) {\n return product.name();\n }\n\n /**\n * @notice Returns the symbol of the provided `product`\n * @param product Product address\n * @return Symbol of the product\n */\n function symbol(IProduct product) external view returns (string memory) {\n return product.symbol();\n }\n\n /**\n * @notice Protocol collateral address\n * @return Protocol collateral address\n */\n function collateral() public view returns (ICollateral) {\n return controller.collateral();\n }\n\n /**\n * @notice User collateral amount for product after settle\n * @param account Account address\n * @param product Product address\n * @return User deposited collateral for product\n */\n function collateral(address account, IProduct product) external settleAccount(account, product) returns (UFixed18) {\n return collateral().collateral(account, product);\n }\n\n /**\n * @notice Product total collateral amount after settle\n * @param product Product address\n * @return Total collateral for product\n */\n function collateral(IProduct product) external settle(product) returns (UFixed18) {\n return collateral().collateral(product);\n }\n\n /**\n * @notice Product total shortfall amount after settle\n * @param product Product address\n * @return Total shortfall for product\n */\n function shortfall(IProduct product) external settle(product) returns (UFixed18) {\n return collateral().shortfall(product);\n }\n\n /**\n * @notice User maintenance amount for product after settle\n * @param account Account address\n * @param product Product address\n * @return Maximum of user maintenance, and maintenanceNext\n */\n function maintenance(address account, IProduct product)\n external\n settleAccount(account, product)\n returns (UFixed18)\n {\n return UFixed18Lib.max(product.maintenance(account), product.maintenanceNext(account));\n }\n\n /**\n * @notice User liquidatble status for product after settle\n * @param account Account address\n * @param product Product address\n * @return Whether or not the user's position eligible to be liquidated\n */\n function liquidatable(address account, IProduct product) external settleAccount(account, product) returns (bool) {\n return collateral().liquidatable(account, product);\n }\n\n /**\n * @notice User pre position for product after settle\n * @param account Account address\n * @param product Product address\n * @return User pre-position\n */\n function pre(address account, IProduct product)\n external\n settleAccount(account, product)\n returns (PrePosition memory)\n {\n return product.pre(account);\n }\n\n /**\n * @notice Product pre position after settle\n * @param product Product address\n * @return Product pre-position\n */\n function pre(IProduct product) external settle(product) returns (PrePosition memory) {\n return product.pre();\n }\n\n /**\n * @notice User position for product after settle\n * @param account Account address\n * @param product Product address\n * @return User position\n */\n function position(address account, IProduct product)\n external\n settleAccount(account, product)\n returns (Position memory)\n {\n return product.position(account);\n }\n\n /**\n * @notice Product position after settle\n * @param product Product address\n * @return product position\n */\n function position(IProduct product) external settle(product) returns (Position memory) {\n return _latestPosition(product);\n }\n\n /**\n * @notice User pre-position and position for product after settle\n * @param account Account address\n * @param product Product address\n * @return User pre-position\n * @return User position\n */\n function userPosition(address account, IProduct product)\n external\n settleAccount(account, product)\n returns (PrePosition memory, Position memory)\n {\n return (product.pre(account), product.position(account));\n }\n\n /**\n * @notice Product pre-position and position after settle\n * @param product Product address\n * @return Product pre-position\n * @return Product position\n */\n function globalPosition(IProduct product) external settle(product) returns (PrePosition memory, Position memory) {\n return (product.pre(), _latestPosition(product));\n }\n\n /**\n * @notice Current price of product after settle\n * @param product Product address\n * @return Product latest price\n */\n function price(IProduct product) external settle(product) returns (Fixed18) {\n return _latestVersion(product).price;\n }\n\n /**\n * @notice Current price of product at specified version after settle\n * @param product Product address\n * @param version Oracle version\n * @return Product price at specified version\n */\n function priceAtVersion(IProduct product, uint version) external settle(product) returns (Fixed18) {\n return product.atVersion(version).price;\n }\n\n /**\n * @notice Fees accumulated by product and protocol treasuries after settle\n * @param product Product address\n * @return protocolFees fees accrued by the protocol\n * @return productFees fees accrued by the product owner\n */\n function fees(IProduct product) external settle(product) returns (UFixed18 protocolFees, UFixed18 productFees) {\n address protocolTreasury = controller.treasury();\n address productTreasury = controller.treasury(product);\n\n protocolFees = collateral().fees(protocolTreasury);\n productFees = collateral().fees(productTreasury);\n }\n\n /**\n * @notice Fees accumulated by treasury after settle\n * @param account Account address\n * @param products Product addresses\n * @return sum of all fees accrued by the account\n */\n function fees(address account, IProduct[] memory products) external returns (UFixed18) {\n for (uint256 i = 0; i < products.length; i++) {\n products[i].settle();\n }\n\n return collateral().fees(account);\n }\n\n /**\n * @notice User's open interest in product after settle\n * @param account Account address\n * @param product Product address\n * @return User's maker or taker position multiplied by latest price after settle\n */\n function openInterest(address account, IProduct product)\n external\n settleAccount(account, product)\n returns (Position memory)\n {\n return product.position(account).mul(_latestVersion(product).price.abs());\n }\n\n /**\n * @notice Product total open interest after settle\n * @param product Product address\n * @return Product maker and taker position multiplied by latest price after settle\n */\n function openInterest(IProduct product) external settle(product) returns (Position memory) {\n return _latestPosition(product).mul(_latestVersion(product).price.abs());\n }\n\n /**\n * @notice Product funding rate after settle\n * @param product Product address\n * @return Product current funding rate\n */\n function rate(IProduct product) external settle(product) returns (Fixed18) {\n Position memory position_ = _latestPosition(product);\n return product.rate(position_);\n }\n\n /**\n * @notice Product funding extrapolated to a daily rate after settle\n * @param product Product address\n * @return Product current funding extrapolated to a daily rate\n */\n function dailyRate(IProduct product) external settle(product) returns (Fixed18) {\n Position memory position_ = _latestPosition(product);\n return product.rate(position_).mul(Fixed18Lib.from(60 * 60 * 24));\n }\n\n /**\n * @notice User's maintenance required for position size in product after settle\n * @param account Account address\n * @param product Product address\n * @param positionSize size of position for maintenance calculation\n * @return Maintenance required for position in product\n */\n function maintenanceRequired(\n address account,\n IProduct product,\n UFixed18 positionSize\n ) external settleAccount(account, product) returns (UFixed18) {\n UFixed18 notional = positionSize.mul(_latestVersion(product).price.abs());\n return notional.mul(product.maintenance());\n }\n\n /**\n * @notice User's unclaimed rewards for all programs for product after settle\n * @param account Account address\n * @param product Product address\n * @return tokens Token addresses of unclaimed incentive rewards for given product\n * @return amounts Token amounts of unclaimed incentive rewards for given product\n */\n function unclaimedIncentiveRewards(address account, IProduct product)\n external\n settleAccount(account, product)\n returns (Token18[] memory tokens, UFixed18[] memory amounts)\n {\n IIncentivizer incentivizer = controller.incentivizer();\n\n uint256 programsLength = incentivizer.count(product);\n tokens = new Token18[](programsLength);\n amounts = new UFixed18[](programsLength);\n for (uint256 i = 0; i < programsLength; i++) {\n ProgramInfo memory programInfo = incentivizer.programInfos(product, i);\n tokens[i] = programInfo.token;\n amounts[i] = incentivizer.unclaimed(product, account, i);\n }\n }\n\n /**\n * @notice User's unclaimed rewards for provided programs for product after settle\n * @param account Account address\n * @param product Product address\n * @param programIds Program IDs to query\n * @return tokens Token addresses of unclaimed incentive rewards for given program IDs\n * @return amounts Token amounts of unclaimed incentive rewards for given program IDs\n */\n function unclaimedIncentiveRewards(\n address account,\n IProduct product,\n uint256[] calldata programIds\n ) external settleAccount(account, product) returns (Token18[] memory tokens, UFixed18[] memory amounts) {\n IIncentivizer incentivizer = controller.incentivizer();\n tokens = new Token18[](programIds.length);\n amounts = new UFixed18[](programIds.length);\n for (uint256 i = 0; i < programIds.length; i++) {\n ProgramInfo memory programInfo = incentivizer.programInfos(product, programIds[i]);\n tokens[i] = programInfo.token;\n amounts[i] = incentivizer.unclaimed(product, account, programIds[i]);\n }\n }\n\n // TODO: all data for Product, all data for User, batching\n\n /**\n * @notice Returns the Product's latest position\n * @dev Private function, does not call settle itself\n * @param product Product address\n * @return Latest position for the product\n */\n function _latestPosition(IProduct product) private view returns (Position memory) {\n return product.positionAtVersion(product.latestVersion());\n }\n\n /**\n * @notice Returns the Product's latest version\n * @dev Private function, does not call settle itself\n * @param product Product address\n * @return Latest version for the product\n */\n function _latestVersion(IProduct product) private view returns (IOracleProvider.OracleVersion memory) {\n return product.currentVersion();\n }\n\n /// @dev Settles the product\n modifier settle(IProduct product) {\n product.settle();\n _;\n }\n\n /// @dev Settles the product. product.settleAccount also settles the product\n modifier settleAccount(address account, IProduct product) {\n product.settleAccount(account);\n _;\n }\n}\n" - }, - "contracts/interfaces/IPerennialLens.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"./IProduct.sol\";\nimport \"./ICollateral.sol\";\nimport \"./IController.sol\";\n\ninterface IPerennialLens {\n function controller() external view returns (IController);\n function name(IProduct product) external view returns (string memory);\n function symbol(IProduct product) external view returns (string memory);\n function collateral() external view returns (ICollateral);\n function collateral(address account, IProduct product) external returns (UFixed18);\n function collateral(IProduct product) external returns (UFixed18);\n function shortfall(IProduct product) external returns (UFixed18);\n function maintenance(address account, IProduct product) external returns (UFixed18);\n function liquidatable(address account, IProduct product) external returns (bool);\n function pre(address account, IProduct product) external returns (PrePosition memory);\n function pre(IProduct product) external returns (PrePosition memory);\n function position(address account, IProduct product) external returns (Position memory);\n function position(IProduct product) external returns (Position memory);\n function userPosition(address account, IProduct product) external returns (PrePosition memory, Position memory);\n function globalPosition(IProduct product) external returns (PrePosition memory, Position memory);\n function price(IProduct product) external returns (Fixed18);\n function fees(IProduct product) external returns (UFixed18 protocolFees, UFixed18 productFees);\n function fees(address account, IProduct[] memory products) external returns (UFixed18);\n function openInterest(address account, IProduct product) external returns (Position memory);\n function openInterest(IProduct product) external returns (Position memory);\n function rate(IProduct product) external returns (Fixed18);\n function dailyRate(IProduct product) external returns (Fixed18);\n function maintenanceRequired(\n address account,\n IProduct product,\n UFixed18 positionSize\n ) external returns (UFixed18);\n function unclaimedIncentiveRewards(address account, IProduct product)\n external\n returns (Token18[] memory tokens, UFixed18[] memory amounts);\n function unclaimedIncentiveRewards(\n address account,\n IProduct product,\n uint256[] calldata programIds\n ) external returns (Token18[] memory tokens, UFixed18[] memory amounts);\n}\n" - }, - "@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/Fixed18.sol\";\n\ninterface IOracleProvider {\n /// @dev A singular oracle version with its corresponding data\n struct OracleVersion {\n /// @dev The iterative version\n uint256 version;\n\n /// @dev the timestamp of the oracle update\n uint256 timestamp;\n\n /// @dev The oracle price of the corresponding version\n Fixed18 price;\n }\n\n function sync() external returns (OracleVersion memory);\n function currentVersion() external view returns (OracleVersion memory);\n function atVersion(uint256 oracleVersion) external view returns (OracleVersion memory);\n}\n" - }, - "contracts/interfaces/IProduct.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\";\nimport \"./IPayoffProvider.sol\";\nimport \"./IParamProvider.sol\";\nimport \"./types/PayoffDefinition.sol\";\nimport \"./types/Position.sol\";\nimport \"./types/PrePosition.sol\";\nimport \"./types/Accumulator.sol\";\n\ninterface IProduct is IPayoffProvider, IParamProvider {\n /// @dev Product Creation parameters\n struct ProductInfo {\n /// @dev name of the product\n string name;\n\n /// @dev symbol of the product\n string symbol;\n\n /// @dev product payoff definition\n PayoffDefinition payoffDefinition;\n\n /// @dev oracle address\n IOracleProvider oracle;\n\n /// @dev product maintenance ratio\n UFixed18 maintenance;\n\n /// @dev product funding fee\n UFixed18 fundingFee;\n\n /// @dev product maker fee\n UFixed18 makerFee;\n\n /// @dev product taker fee\n UFixed18 takerFee;\n\n /// @dev product maker limit\n UFixed18 makerLimit;\n\n /// @dev utulization curve definition\n JumpRateUtilizationCurve utilizationCurve;\n }\n\n event Settle(uint256 preVersion, uint256 toVersion);\n event AccountSettle(address indexed account, uint256 preVersion, uint256 toVersion);\n event MakeOpened(address indexed account, uint256 version, UFixed18 amount);\n event TakeOpened(address indexed account, uint256 version, UFixed18 amount);\n event MakeClosed(address indexed account, uint256 version, UFixed18 amount);\n event TakeClosed(address indexed account, uint256 version, UFixed18 amount);\n event ClosedUpdated(bool indexed newClosed, uint256 version);\n\n error ProductInsufficientLiquidityError(UFixed18 socializationFactor);\n error ProductDoubleSidedError();\n error ProductOverClosedError();\n error ProductInsufficientCollateralError();\n error ProductInLiquidationError();\n error ProductMakerOverLimitError();\n error ProductOracleBootstrappingError();\n error ProductNotOwnerError();\n error ProductInvalidOracle();\n error ProductClosedError();\n\n function name() external view returns (string memory);\n function symbol() external view returns (string memory);\n function initialize(ProductInfo calldata productInfo_) external;\n function settle() external;\n function settleAccount(address account) external;\n function openTake(UFixed18 amount) external;\n function closeTake(UFixed18 amount) external;\n function openMake(UFixed18 amount) external;\n function closeMake(UFixed18 amount) external;\n function closeAll(address account) external;\n function maintenance(address account) external view returns (UFixed18);\n function maintenanceNext(address account) external view returns (UFixed18);\n function isClosed(address account) external view returns (bool);\n function isLiquidating(address account) external view returns (bool);\n function position(address account) external view returns (Position memory);\n function pre(address account) external view returns (PrePosition memory);\n function latestVersion() external view returns (uint256);\n function positionAtVersion(uint256 oracleVersion) external view returns (Position memory);\n function pre() external view returns (PrePosition memory);\n function valueAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\n function shareAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\n function latestVersion(address account) external view returns (uint256);\n function rate(Position memory position) external view returns (Fixed18);\n function closed() external view returns (bool);\n function updateClosed(bool newClosed) external;\n}\n" - }, - "contracts/interfaces/ICollateral.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/root/number/types/Fixed18.sol\";\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"./IController.sol\";\nimport \"./IProduct.sol\";\n\ninterface ICollateral {\n event Deposit(address indexed user, IProduct indexed product, UFixed18 amount);\n event Withdrawal(address indexed user, IProduct indexed product, UFixed18 amount);\n event AccountSettle(IProduct indexed product, address indexed account, Fixed18 amount, UFixed18 newShortfall);\n event ProductSettle(IProduct indexed product, UFixed18 protocolFee, UFixed18 productFee);\n event Liquidation(address indexed user, IProduct indexed product, address liquidator, UFixed18 fee);\n event ShortfallResolution(IProduct indexed product, UFixed18 amount);\n event FeeClaim(address indexed account, UFixed18 amount);\n\n error CollateralCantLiquidate(UFixed18 totalMaintenance, UFixed18 totalCollateral);\n error CollateralInsufficientCollateralError();\n error CollateralUnderLimitError();\n error CollateralZeroAddressError();\n\n function token() external view returns (Token18);\n function fees(address account) external view returns (UFixed18);\n function initialize(IController controller_) external;\n function depositTo(address account, IProduct product, UFixed18 amount) external;\n function withdrawTo(address account, IProduct product, UFixed18 amount) external;\n function liquidate(address account, IProduct product) external;\n function settleAccount(address account, Fixed18 amount) external;\n function settleProduct(UFixed18 amount) external;\n function collateral(address account, IProduct product) external view returns (UFixed18);\n function collateral(IProduct product) external view returns (UFixed18);\n function shortfall(IProduct product) external view returns (UFixed18);\n function liquidatable(address account, IProduct product) external view returns (bool);\n function liquidatableNext(address account, IProduct product) external view returns (bool);\n function resolveShortfall(IProduct product, UFixed18 amount) external;\n function claimFee() external;\n}\n" - }, - "contracts/interfaces/IController.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\";\nimport \"./ICollateral.sol\";\nimport \"./IIncentivizer.sol\";\nimport \"./IProduct.sol\";\nimport \"./types/PayoffDefinition.sol\";\n\ninterface IController {\n /// @dev Coordinator of a one or many products\n struct Coordinator {\n /// @dev Pending owner of the product, can accept ownership\n address pendingOwner;\n\n /// @dev Owner of the product, allowed to update select parameters\n address owner;\n\n /// @dev Treasury of the product, collects fees\n address treasury;\n }\n\n event CollateralUpdated(ICollateral newCollateral);\n event IncentivizerUpdated(IIncentivizer newIncentivizer);\n event ProductBeaconUpdated(IBeacon newProductBeacon);\n event ProtocolFeeUpdated(UFixed18 newProtocolFee);\n event MinFundingFeeUpdated(UFixed18 newMinFundingFee);\n event LiquidationFeeUpdated(UFixed18 newLiquidationFee);\n event IncentivizationFeeUpdated(UFixed18 newIncentivizationFee);\n event MinCollateralUpdated(UFixed18 newMinCollateral);\n event ProgramsPerProductUpdated(uint256 newProgramsPerProduct);\n event PauserUpdated(address newPauser);\n event PausedUpdated(bool newPaused);\n event CoordinatorPendingOwnerUpdated(uint256 indexed coordinatorId, address newPendingOwner);\n event CoordinatorOwnerUpdated(uint256 indexed coordinatorId, address newOwner);\n event CoordinatorTreasuryUpdated(uint256 indexed coordinatorId, address newTreasury);\n event CoordinatorCreated(uint256 indexed coordinatorId, address owner);\n event ProductCreated(IProduct indexed product, IProduct.ProductInfo productInfo);\n\n error ControllerNoZeroCoordinatorError();\n error ControllerNotPauserError();\n error ControllerNotOwnerError(uint256 controllerId);\n error ControllerNotPendingOwnerError(uint256 controllerId);\n error ControllerInvalidProtocolFeeError();\n error ControllerInvalidMinFundingFeeError();\n error ControllerInvalidLiquidationFeeError();\n error ControllerInvalidIncentivizationFeeError();\n error ControllerNotContractAddressError();\n\n function collateral() external view returns (ICollateral);\n function incentivizer() external view returns (IIncentivizer);\n function productBeacon() external view returns (IBeacon);\n function coordinators(uint256 collateralId) external view returns (Coordinator memory);\n function coordinatorFor(IProduct product) external view returns (uint256);\n function protocolFee() external view returns (UFixed18);\n function minFundingFee() external view returns (UFixed18);\n function liquidationFee() external view returns (UFixed18);\n function incentivizationFee() external view returns (UFixed18);\n function minCollateral() external view returns (UFixed18);\n function programsPerProduct() external view returns (uint256);\n function pauser() external view returns (address);\n function paused() external view returns (bool);\n function initialize(ICollateral collateral_, IIncentivizer incentivizer_, IBeacon productBeacon_) external;\n function createCoordinator() external returns (uint256);\n function updateCoordinatorPendingOwner(uint256 coordinatorId, address newPendingOwner) external;\n function acceptCoordinatorOwner(uint256 coordinatorId) external;\n function updateCoordinatorTreasury(uint256 coordinatorId, address newTreasury) external;\n function createProduct(uint256 coordinatorId, IProduct.ProductInfo calldata productInfo) external returns (IProduct);\n function updateCollateral(ICollateral newCollateral) external;\n function updateIncentivizer(IIncentivizer newIncentivizer) external;\n function updateProductBeacon(IBeacon newProductBeacon) external;\n function updateProtocolFee(UFixed18 newProtocolFee) external;\n function updateMinFundingFee(UFixed18 newMinFundingFee) external;\n function updateLiquidationFee(UFixed18 newLiquidationFee) external;\n function updateIncentivizationFee(UFixed18 newIncentivizationFee) external;\n function updateMinCollateral(UFixed18 newMinCollateral) external;\n function updateProgramsPerProduct(uint256 newProductsPerProduct) external;\n function updatePauser(address newPauser) external;\n function updatePaused(bool newPaused) external;\n function isProduct(IProduct product) external view returns (bool);\n function owner() external view returns (address);\n function owner(uint256 coordinatorId) external view returns (address);\n function owner(IProduct product) external view returns (address);\n function treasury() external view returns (address);\n function treasury(uint256 coordinatorId) external view returns (address);\n function treasury(IProduct product) external view returns (address);\n}\n" - }, - "@equilibria/root/number/types/Fixed18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/SignedMath.sol\";\nimport \"./UFixed18.sol\";\nimport \"./PackedFixed18.sol\";\n\n/// @dev Fixed18 type\ntype Fixed18 is int256;\nusing Fixed18Lib for Fixed18 global;\ntype Fixed18Storage is bytes32;\nusing Fixed18StorageLib for Fixed18Storage global;\n\n/**\n * @title Fixed18Lib\n * @notice Library for the signed fixed-decimal type.\n */\nlibrary Fixed18Lib {\n error Fixed18OverflowError(uint256 value);\n error Fixed18PackingOverflowError(int256 value);\n error Fixed18PackingUnderflowError(int256 value);\n\n int256 private constant BASE = 1e18;\n Fixed18 public constant ZERO = Fixed18.wrap(0);\n Fixed18 public constant ONE = Fixed18.wrap(BASE);\n Fixed18 public constant NEG_ONE = Fixed18.wrap(-1 * BASE);\n Fixed18 public constant MAX = Fixed18.wrap(type(int256).max);\n Fixed18 public constant MIN = Fixed18.wrap(type(int256).min);\n\n /**\n * @notice Creates a signed fixed-decimal from an unsigned fixed-decimal\n * @param a Unsigned fixed-decimal\n * @return New signed fixed-decimal\n */\n function from(UFixed18 a) internal pure returns (Fixed18) {\n uint256 value = UFixed18.unwrap(a);\n if (value > uint256(type(int256).max)) revert Fixed18OverflowError(value);\n return Fixed18.wrap(int256(value));\n }\n\n /**\n * @notice Creates a signed fixed-decimal from a sign and an unsigned fixed-decimal\n * @param s Sign\n * @param m Unsigned fixed-decimal magnitude\n * @return New signed fixed-decimal\n */\n function from(int256 s, UFixed18 m) internal pure returns (Fixed18) {\n if (s > 0) return from(m);\n if (s < 0) return Fixed18.wrap(-1 * Fixed18.unwrap(from(m)));\n return ZERO;\n }\n\n /**\n * @notice Creates a signed fixed-decimal from a signed integer\n * @param a Signed number\n * @return New signed fixed-decimal\n */\n function from(int256 a) internal pure returns (Fixed18) {\n return Fixed18.wrap(a * BASE);\n }\n\n /**\n * @notice Creates a packed signed fixed-decimal from an signed fixed-decimal\n * @param a signed fixed-decimal\n * @return New packed signed fixed-decimal\n */\n function pack(Fixed18 a) internal pure returns (PackedFixed18) {\n int256 value = Fixed18.unwrap(a);\n if (value > type(int128).max) revert Fixed18PackingOverflowError(value);\n if (value < type(int128).min) revert Fixed18PackingUnderflowError(value);\n return PackedFixed18.wrap(int128(value));\n }\n\n /**\n * @notice Returns whether the signed fixed-decimal is equal to zero.\n * @param a Signed fixed-decimal\n * @return Whether the signed fixed-decimal is zero.\n */\n function isZero(Fixed18 a) internal pure returns (bool) {\n return Fixed18.unwrap(a) == 0;\n }\n\n /**\n * @notice Adds two signed fixed-decimals `a` and `b` together\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Resulting summed signed fixed-decimal\n */\n function add(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) + Fixed18.unwrap(b));\n }\n\n /**\n * @notice Subtracts signed fixed-decimal `b` from `a`\n * @param a Signed fixed-decimal to subtract from\n * @param b Signed fixed-decimal to subtract\n * @return Resulting subtracted signed fixed-decimal\n */\n function sub(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) - Fixed18.unwrap(b));\n }\n\n /**\n * @notice Multiplies two signed fixed-decimals `a` and `b` together\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Resulting multiplied signed fixed-decimal\n */\n function mul(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / BASE);\n }\n\n /**\n * @notice Divides signed fixed-decimal `a` by `b`\n * @param a Signed fixed-decimal to divide\n * @param b Signed fixed-decimal to divide by\n * @return Resulting divided signed fixed-decimal\n */\n function div(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) * BASE / Fixed18.unwrap(b));\n }\n\n /**\n * @notice Divides unsigned fixed-decimal `a` by `b`\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0`, `MAX` for `n/0`, and `MIN` for `-n/0`.\n * @param a Unsigned fixed-decimal to divide\n * @param b Unsigned fixed-decimal to divide by\n * @return Resulting divided unsigned fixed-decimal\n */\n function unsafeDiv(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n if (isZero(b)) {\n if (gt(a, ZERO)) return MAX;\n if (lt(a, ZERO)) return MIN;\n return ONE;\n } else {\n return div(a, b);\n }\n }\n\n /**\n * @notice Computes a * b / c without loss of precision due to BASE conversion\n * @param a First signed fixed-decimal\n * @param b Signed number to multiply by\n * @param c Signed number to divide by\n * @return Resulting computation\n */\n function muldiv(Fixed18 a, int256 b, int256 c) internal pure returns (Fixed18) {\n return muldiv(a, Fixed18.wrap(b), Fixed18.wrap(c));\n }\n\n /**\n * @notice Computes a * b / c without loss of precision due to BASE conversion\n * @param a First signed fixed-decimal\n * @param b Signed fixed-decimal to multiply by\n * @param c Signed fixed-decimal to divide by\n * @return Resulting computation\n */\n function muldiv(Fixed18 a, Fixed18 b, Fixed18 c) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / Fixed18.unwrap(c));\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is equal to `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is equal to `b`\n */\n function eq(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return compare(a, b) == 1;\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is greater than `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is greater than `b`\n */\n function gt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return compare(a, b) == 2;\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is less than `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is less than `b`\n */\n function lt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return compare(a, b) == 0;\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is greater than or equal to `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is greater than or equal to `b`\n */\n function gte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return gt(a, b) || eq(a, b);\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is less than or equal to `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is less than or equal to `b`\n */\n function lte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return lt(a, b) || eq(a, b);\n }\n\n /**\n * @notice Compares the signed fixed-decimals `a` and `b`\n * @dev Returns: 2 for greater than\n * 1 for equal to\n * 0 for less than\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Compare result of `a` and `b`\n */\n function compare(Fixed18 a, Fixed18 b) internal pure returns (uint256) {\n (int256 au, int256 bu) = (Fixed18.unwrap(a), Fixed18.unwrap(b));\n if (au > bu) return 2;\n if (au < bu) return 0;\n return 1;\n }\n\n /**\n * @notice Returns a signed fixed-decimal representing the ratio of `a` over `b`\n * @param a First signed number\n * @param b Second signed number\n * @return Ratio of `a` over `b`\n */\n function ratio(int256 a, int256 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(a * BASE / b);\n }\n\n /**\n * @notice Returns the minimum of signed fixed-decimals `a` and `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Minimum of `a` and `b`\n */\n function min(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(SignedMath.min(Fixed18.unwrap(a), Fixed18.unwrap(b)));\n }\n\n /**\n * @notice Returns the maximum of signed fixed-decimals `a` and `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Maximum of `a` and `b`\n */\n function max(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(SignedMath.max(Fixed18.unwrap(a), Fixed18.unwrap(b)));\n }\n\n /**\n * @notice Converts the signed fixed-decimal into an integer, truncating any decimal portion\n * @param a Signed fixed-decimal\n * @return Truncated signed number\n */\n function truncate(Fixed18 a) internal pure returns (int256) {\n return Fixed18.unwrap(a) / BASE;\n }\n\n /**\n * @notice Returns the sign of the signed fixed-decimal\n * @dev Returns: -1 for negative\n * 0 for zero\n * 1 for positive\n * @param a Signed fixed-decimal\n * @return Sign of the signed fixed-decimal\n */\n function sign(Fixed18 a) internal pure returns (int256) {\n if (Fixed18.unwrap(a) > 0) return 1;\n if (Fixed18.unwrap(a) < 0) return -1;\n return 0;\n }\n\n /**\n * @notice Returns the absolute value of the signed fixed-decimal\n * @param a Signed fixed-decimal\n * @return Absolute value of the signed fixed-decimal\n */\n function abs(Fixed18 a) internal pure returns (UFixed18) {\n return UFixed18.wrap(SignedMath.abs(Fixed18.unwrap(a)));\n }\n}\n\nlibrary Fixed18StorageLib {\n function read(Fixed18Storage self) internal view returns (Fixed18 value) {\n assembly {\n value := sload(self)\n }\n }\n\n function store(Fixed18Storage self, Fixed18 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/SignedMath.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n /**\n * @dev Returns the largest of two signed numbers.\n */\n function max(int256 a, int256 b) internal pure returns (int256) {\n return 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 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 // must be unchecked in order to support `n = type(int256).min`\n return uint256(n >= 0 ? n : -n);\n }\n }\n}\n" - }, - "@equilibria/root/number/types/UFixed18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"./Fixed18.sol\";\nimport \"./PackedUFixed18.sol\";\n\n/// @dev UFixed18 type\ntype UFixed18 is uint256;\nusing UFixed18Lib for UFixed18 global;\ntype UFixed18Storage is bytes32;\nusing UFixed18StorageLib for UFixed18Storage global;\n\n/**\n * @title UFixed18Lib\n * @notice Library for the unsigned fixed-decimal type.\n */\nlibrary UFixed18Lib {\n error UFixed18UnderflowError(int256 value);\n error UFixed18PackingOverflowError(uint256 value);\n\n uint256 private constant BASE = 1e18;\n UFixed18 public constant ZERO = UFixed18.wrap(0);\n UFixed18 public constant ONE = UFixed18.wrap(BASE);\n UFixed18 public constant MAX = UFixed18.wrap(type(uint256).max);\n\n /**\n * @notice Creates a unsigned fixed-decimal from a signed fixed-decimal\n * @param a Signed fixed-decimal\n * @return New unsigned fixed-decimal\n */\n function from(Fixed18 a) internal pure returns (UFixed18) {\n int256 value = Fixed18.unwrap(a);\n if (value < 0) revert UFixed18UnderflowError(value);\n return UFixed18.wrap(uint256(value));\n }\n\n /**\n * @notice Creates a unsigned fixed-decimal from a unsigned integer\n * @param a Unsigned number\n * @return New unsigned fixed-decimal\n */\n function from(uint256 a) internal pure returns (UFixed18) {\n return UFixed18.wrap(a * BASE);\n }\n\n /**\n * @notice Creates a packed unsigned fixed-decimal from an unsigned fixed-decimal\n * @param a unsigned fixed-decimal\n * @return New packed unsigned fixed-decimal\n */\n function pack(UFixed18 a) internal pure returns (PackedUFixed18) {\n uint256 value = UFixed18.unwrap(a);\n if (value > type(uint128).max) revert UFixed18PackingOverflowError(value);\n return PackedUFixed18.wrap(uint128(value));\n }\n\n /**\n * @notice Returns whether the unsigned fixed-decimal is equal to zero.\n * @param a Unsigned fixed-decimal\n * @return Whether the unsigned fixed-decimal is zero.\n */\n function isZero(UFixed18 a) internal pure returns (bool) {\n return UFixed18.unwrap(a) == 0;\n }\n\n /**\n * @notice Adds two unsigned fixed-decimals `a` and `b` together\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Resulting summed unsigned fixed-decimal\n */\n function add(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) + UFixed18.unwrap(b));\n }\n\n /**\n * @notice Subtracts unsigned fixed-decimal `b` from `a`\n * @param a Unsigned fixed-decimal to subtract from\n * @param b Unsigned fixed-decimal to subtract\n * @return Resulting subtracted unsigned fixed-decimal\n */\n function sub(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) - UFixed18.unwrap(b));\n }\n\n /**\n * @notice Multiplies two unsigned fixed-decimals `a` and `b` together\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Resulting multiplied unsigned fixed-decimal\n */\n function mul(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / BASE);\n }\n\n /**\n * @notice Divides unsigned fixed-decimal `a` by `b`\n * @param a Unsigned fixed-decimal to divide\n * @param b Unsigned fixed-decimal to divide by\n * @return Resulting divided unsigned fixed-decimal\n */\n function div(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) * BASE / UFixed18.unwrap(b));\n }\n\n /**\n * @notice Divides unsigned fixed-decimal `a` by `b`\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0` and `MAX` for `n/0`.\n * @param a Unsigned fixed-decimal to divide\n * @param b Unsigned fixed-decimal to divide by\n * @return Resulting divided unsigned fixed-decimal\n */\n function unsafeDiv(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n if (isZero(b)) {\n return isZero(a) ? ONE : MAX;\n } else {\n return div(a, b);\n }\n }\n\n /**\n * @notice Computes a * b / c without loss of precision due to BASE conversion\n * @param a First unsigned fixed-decimal\n * @param b Unsigned number to multiply by\n * @param c Unsigned number to divide by\n * @return Resulting computation\n */\n function muldiv(UFixed18 a, uint256 b, uint256 c) internal pure returns (UFixed18) {\n return muldiv(a, UFixed18.wrap(b), UFixed18.wrap(c));\n }\n\n /**\n * @notice Computes a * b / c without loss of precision due to BASE conversion\n * @param a First unsigned fixed-decimal\n * @param b Unsigned fixed-decimal to multiply by\n * @param c Unsigned fixed-decimal to divide by\n * @return Resulting computation\n */\n function muldiv(UFixed18 a, UFixed18 b, UFixed18 c) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / UFixed18.unwrap(c));\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is equal to `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is equal to `b`\n */\n function eq(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return compare(a, b) == 1;\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is greater than `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is greater than `b`\n */\n function gt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return compare(a, b) == 2;\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is less than `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is less than `b`\n */\n function lt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return compare(a, b) == 0;\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is greater than or equal to `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is greater than or equal to `b`\n */\n function gte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return gt(a, b) || eq(a, b);\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is less than or equal to `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is less than or equal to `b`\n */\n function lte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return lt(a, b) || eq(a, b);\n }\n\n /**\n * @notice Compares the unsigned fixed-decimals `a` and `b`\n * @dev Returns: 2 for greater than\n * 1 for equal to\n * 0 for less than\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Compare result of `a` and `b`\n */\n function compare(UFixed18 a, UFixed18 b) internal pure returns (uint256) {\n (uint256 au, uint256 bu) = (UFixed18.unwrap(a), UFixed18.unwrap(b));\n if (au > bu) return 2;\n if (au < bu) return 0;\n return 1;\n }\n\n /**\n * @notice Returns a unsigned fixed-decimal representing the ratio of `a` over `b`\n * @param a First unsigned number\n * @param b Second unsigned number\n * @return Ratio of `a` over `b`\n */\n function ratio(uint256 a, uint256 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(a * BASE / b);\n }\n\n /**\n * @notice Returns the minimum of unsigned fixed-decimals `a` and `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Minimum of `a` and `b`\n */\n function min(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(Math.min(UFixed18.unwrap(a), UFixed18.unwrap(b)));\n }\n\n /**\n * @notice Returns the maximum of unsigned fixed-decimals `a` and `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Maximum of `a` and `b`\n */\n function max(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(Math.max(UFixed18.unwrap(a), UFixed18.unwrap(b)));\n }\n\n /**\n * @notice Converts the unsigned fixed-decimal into an integer, truncating any decimal portion\n * @param a Unsigned fixed-decimal\n * @return Truncated unsigned number\n */\n function truncate(UFixed18 a) internal pure returns (uint256) {\n return UFixed18.unwrap(a) / BASE;\n }\n}\n\nlibrary UFixed18StorageLib {\n function read(UFixed18Storage self) internal view returns (UFixed18 value) {\n assembly {\n value := sload(self)\n }\n }\n\n function store(UFixed18Storage self, UFixed18 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "@equilibria/root/number/types/PackedFixed18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"./Fixed18.sol\";\n\n/// @dev PackedFixed18 type\ntype PackedFixed18 is int128;\nusing PackedFixed18Lib for PackedFixed18 global;\n\n/**\n * @title PackedFixed18Lib\n * @dev A packed version of the Fixed18 which takes up half the storage space (two PackedFixed18 can be packed\n * into a single slot). Only valid within the range -1.7014118e+20 <= x <= 1.7014118e+20.\n * @notice Library for the packed signed fixed-decimal type.\n */\nlibrary PackedFixed18Lib {\n PackedFixed18 public constant MAX = PackedFixed18.wrap(type(int128).max);\n PackedFixed18 public constant MIN = PackedFixed18.wrap(type(int128).min);\n\n /**\n * @notice Creates an unpacked signed fixed-decimal from a packed signed fixed-decimal\n * @param self packed signed fixed-decimal\n * @return New unpacked signed fixed-decimal\n */\n function unpack(PackedFixed18 self) internal pure returns (Fixed18) {\n return Fixed18.wrap(int256(PackedFixed18.unwrap(self)));\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return 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 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 up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a / b + (a % b == 0 ? 0 : 1);\n }\n}\n" - }, - "@equilibria/root/number/types/PackedUFixed18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"./UFixed18.sol\";\n\n/// @dev PackedUFixed18 type\ntype PackedUFixed18 is uint128;\nusing PackedUFixed18Lib for PackedUFixed18 global;\n\n/**\n * @title PackedUFixed18Lib\n * @dev A packed version of the UFixed18 which takes up half the storage space (two PackedUFixed18 can be packed\n * into a single slot). Only valid within the range 0 <= x <= 3.4028237e+20.\n * @notice Library for the packed unsigned fixed-decimal type.\n */\nlibrary PackedUFixed18Lib {\n PackedUFixed18 public constant MAX = PackedUFixed18.wrap(type(uint128).max);\n\n /**\n * @notice Creates an unpacked unsigned fixed-decimal from a packed unsigned fixed-decimal\n * @param self packed unsigned fixed-decimal\n * @return New unpacked unsigned fixed-decimal\n */\n function unpack(PackedUFixed18 self) internal pure returns (UFixed18) {\n return UFixed18.wrap(uint256(PackedUFixed18.unwrap(self)));\n }\n}\n" - }, - "@equilibria/root/curve/types/JumpRateUtilizationCurve.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"../CurveMath.sol\";\nimport \"../../number/types/PackedUFixed18.sol\";\nimport \"../../number/types/PackedFixed18.sol\";\n\n/// @dev JumpRateUtilizationCurve type\nstruct JumpRateUtilizationCurve {\n PackedFixed18 minRate;\n PackedFixed18 maxRate;\n PackedFixed18 targetRate;\n PackedUFixed18 targetUtilization;\n}\nusing JumpRateUtilizationCurveLib for JumpRateUtilizationCurve global;\ntype JumpRateUtilizationCurveStorage is bytes32;\nusing JumpRateUtilizationCurveStorageLib for JumpRateUtilizationCurveStorage global;\n\n/**\n * @title JumpRateUtilizationCurveLib\n * @notice Library for the Jump Rate utilization curve type\n */\nlibrary JumpRateUtilizationCurveLib {\n /**\n * @notice Computes the corresponding rate for a utilization ratio\n * @param utilization The utilization ratio\n * @return The corresponding rate\n */\n function compute(JumpRateUtilizationCurve memory self, UFixed18 utilization) internal pure returns (Fixed18) {\n UFixed18 targetUtilization = self.targetUtilization.unpack();\n if (utilization.lt(targetUtilization)) {\n return CurveMath.linearInterpolation(\n UFixed18Lib.ZERO,\n self.minRate.unpack(),\n targetUtilization,\n self.targetRate.unpack(),\n utilization\n );\n }\n if (utilization.lt(UFixed18Lib.ONE)) {\n return CurveMath.linearInterpolation(\n targetUtilization,\n self.targetRate.unpack(),\n UFixed18Lib.ONE,\n self.maxRate.unpack(),\n utilization\n );\n }\n return self.maxRate.unpack();\n }\n}\n\nlibrary JumpRateUtilizationCurveStorageLib {\n function read(JumpRateUtilizationCurveStorage self) internal view returns (JumpRateUtilizationCurve memory) {\n return _storagePointer(self);\n }\n\n function store(JumpRateUtilizationCurveStorage self, JumpRateUtilizationCurve memory value) internal {\n JumpRateUtilizationCurve storage storagePointer = _storagePointer(self);\n\n storagePointer.minRate = value.minRate;\n storagePointer.maxRate = value.maxRate;\n storagePointer.targetRate = value.targetRate;\n storagePointer.targetUtilization = value.targetUtilization;\n }\n\n function _storagePointer(JumpRateUtilizationCurveStorage self)\n private pure returns (JumpRateUtilizationCurve storage pointer) {\n assembly { pointer.slot := self }\n }\n}" - }, - "contracts/interfaces/IPayoffProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/Fixed18.sol\";\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"./types/PayoffDefinition.sol\";\n\ninterface IPayoffProvider {\n error PayoffProviderInvalidOracle();\n error PayoffProviderInvalidPayoffDefinitionError();\n\n function oracle() external view returns (IOracleProvider);\n function payoffDefinition() external view returns (PayoffDefinition memory);\n function currentVersion() external view returns (IOracleProvider.OracleVersion memory);\n function atVersion(uint256 oracleVersion) external view returns (IOracleProvider.OracleVersion memory);\n}\n" - }, - "contracts/interfaces/IParamProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\";\n\ninterface IParamProvider {\n event MaintenanceUpdated(UFixed18 newMaintenance);\n event FundingFeeUpdated(UFixed18 newFundingFee);\n event MakerFeeUpdated(UFixed18 newMakerFee);\n event TakerFeeUpdated(UFixed18 newTakerFee);\n event MakerLimitUpdated(UFixed18 newMakerLimit);\n event JumpRateUtilizationCurveUpdated(\n Fixed18 minRate,\n Fixed18 maxRate,\n Fixed18 targetRate,\n UFixed18 targetUtilization\n );\n\n error ParamProviderInvalidMakerFee();\n error ParamProviderInvalidTakerFee();\n error ParamProviderInvalidFundingFee();\n \n function maintenance() external view returns (UFixed18);\n function updateMaintenance(UFixed18 newMaintenance) external;\n function fundingFee() external view returns (UFixed18);\n function updateFundingFee(UFixed18 newFundingFee) external;\n function makerFee() external view returns (UFixed18);\n function updateMakerFee(UFixed18 newMakerFee) external;\n function takerFee() external view returns (UFixed18);\n function updateTakerFee(UFixed18 newTakerFee) external;\n function makerLimit() external view returns (UFixed18);\n function updateMakerLimit(UFixed18 newMakerLimit) external;\n function utilizationCurve() external view returns (JumpRateUtilizationCurve memory);\n function updateUtilizationCurve(JumpRateUtilizationCurve memory newUtilizationCurve) external;\n}\n" - }, - "contracts/interfaces/types/PayoffDefinition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"../../interfaces/IContractPayoffProvider.sol\";\n\n/// @dev PayoffDefinition tyoe\nstruct PayoffDefinition {\n PayoffDefinitionLib.PayoffType payoffType;\n PayoffDefinitionLib.PayoffDirection payoffDirection;\n bytes30 data;\n}\nusing PayoffDefinitionLib for PayoffDefinition global;\ntype PayoffDefinitionStorage is bytes32;\nusing PayoffDefinitionStorageLib for PayoffDefinitionStorage global;\n\n/**\n * @title PayoffDefinitionLib\n * @dev Library that surfaces logic for PayoffDefinition type functionality\n * @notice Library for the PayoffDefinition type. Performs validity and price transformation\n based on the payoff definition type.\n */\nlibrary PayoffDefinitionLib {\n using Address for address;\n\n error PayoffDefinitionUnsupportedTransform(PayoffType payoffType, PayoffDirection payoffDirection);\n error PayoffDefinitionNotContract(PayoffType payoffType, bytes30 data);\n\n /// @dev Payoff function type enum\n enum PayoffType { PASSTHROUGH, CONTRACT }\n enum PayoffDirection { LONG, SHORT }\n\n /**\n * @notice Checks validity of the payoff definition\n * @param self a payoff definition\n * @return Whether the payoff definition is valid for it's given type\n */\n function valid(PayoffDefinition memory self) internal view returns (bool) {\n if (self.payoffType == PayoffType.CONTRACT) return address(_providerContract(self)).isContract();\n\n // All other payoff types should have no data\n return uint(bytes32(self.data)) == 0;\n }\n\n /**\n * @notice Transforms a price based on the payoff definition\n * @param self a payoff definition\n * @param price raw oracle price\n * @return Price transformed by the payoff definition function\n */\n function transform(\n PayoffDefinition memory self,\n Fixed18 price\n ) internal view returns (Fixed18) {\n PayoffType payoffType = self.payoffType;\n PayoffDirection payoffDirection = self.payoffDirection;\n Fixed18 transformedPrice;\n\n // First get the price depending on the type\n if (payoffType == PayoffType.PASSTHROUGH) transformedPrice = price;\n else if (payoffType == PayoffType.CONTRACT) transformedPrice = _payoffFromContract(self, price);\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\n\n // Then transform it depending on the direction flag\n if (self.payoffDirection == PayoffDirection.LONG) return transformedPrice;\n else if (self.payoffDirection == PayoffDirection.SHORT) return transformedPrice.mul(Fixed18Lib.NEG_ONE);\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\n }\n\n /**\n * @notice Parses the data field into an address\n * @dev Reverts if payoffType is not CONTRACT\n * @param self a payoff definition\n * @return IContractPayoffProvider address\n */\n function _providerContract(\n PayoffDefinition memory self\n ) private pure returns (IContractPayoffProvider) {\n if (self.payoffType != PayoffType.CONTRACT) revert PayoffDefinitionNotContract(self.payoffType, self.data);\n // Shift to pull the last 20 bytes, then cast to an address\n return IContractPayoffProvider(address(bytes20(self.data << 80)));\n }\n\n /**\n * @notice Performs a price transformation by calling the underlying payoff contract\n * @param self a payoff definition\n * @param price raw oracle price\n * @return Price transformed by the payoff definition function on the contract\n */\n function _payoffFromContract(\n PayoffDefinition memory self,\n Fixed18 price\n ) private view returns (Fixed18) {\n bytes memory ret = address(_providerContract(self)).functionStaticCall(\n abi.encodeCall(IContractPayoffProvider.payoff, price)\n );\n return Fixed18.wrap(abi.decode(ret, (int256)));\n }\n}\n\n/**\n * @title PayoffDefinitionStorageLib\n * @notice Library that surfaces storage read and writes for the PayoffDefinition type\n */\nlibrary PayoffDefinitionStorageLib {\n function read(PayoffDefinitionStorage self) internal view returns (PayoffDefinition memory) {\n return _storagePointer(self);\n }\n\n function store(PayoffDefinitionStorage self, PayoffDefinition memory value) internal {\n PayoffDefinition storage storagePointer = _storagePointer(self);\n\n storagePointer.payoffType = value.payoffType;\n storagePointer.payoffDirection = value.payoffDirection;\n storagePointer.data = value.data;\n }\n\n function _storagePointer(\n PayoffDefinitionStorage self\n ) private pure returns (PayoffDefinition storage pointer) {\n assembly { pointer.slot := self }\n }\n}\n" - }, - "contracts/interfaces/types/Position.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"../IProduct.sol\";\nimport \"./Accumulator.sol\";\nimport \"./PrePosition.sol\";\nimport \"./PackedPosition.sol\";\n\n/// @dev Position type\nstruct Position {\n /// @dev Quantity of the maker position\n UFixed18 maker;\n /// @dev Quantity of the taker position\n UFixed18 taker;\n}\nusing PositionLib for Position global;\n\n/**\n * @title PositionLib\n * @notice Library that surfaces math and settlement computations for the Position type.\n * @dev Positions track the current quantity of the account's maker and taker positions respectively\n * denominated as a unit of the product's payoff function.\n */\nlibrary PositionLib {\n /**\n * @notice Creates a packed position from an position\n * @param self A position\n * @return New packed position\n */\n function pack(Position memory self) internal pure returns (PackedPosition memory) {\n return PackedPosition({maker: self.maker.pack(), taker: self.taker.pack()});\n }\n\n /**\n * @notice Returns whether the position is fully empty\n * @param self A position\n * @return Whether the position is empty\n */\n function isEmpty(Position memory self) internal pure returns (bool) {\n return self.maker.isZero() && self.taker.isZero();\n }\n\n /**\n * @notice Adds position `a` and `b` together, returning the result\n * @param a The first position to sum\n * @param b The second position to sum\n * @return Resulting summed position\n */\n function add(Position memory a, Position memory b) internal pure returns (Position memory) {\n return Position({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\n }\n\n /**\n * @notice Subtracts position `b` from `a`, returning the result\n * @param a The position to subtract from\n * @param b The position to subtract\n * @return Resulting subtracted position\n */\n function sub(Position memory a, Position memory b) internal pure returns (Position memory) {\n return Position({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\n }\n\n /**\n * @notice Multiplies position `self` by accumulator `accumulator` and returns the resulting accumulator\n * @param self The Position to operate on\n * @param accumulator The accumulator to multiply by\n * @return Resulting multiplied accumulator\n */\n function mul(Position memory self, Accumulator memory accumulator) internal pure returns (Accumulator memory) {\n return Accumulator({\n maker: Fixed18Lib.from(self.maker).mul(accumulator.maker),\n taker: Fixed18Lib.from(self.taker).mul(accumulator.taker)\n });\n }\n\n /**\n * @notice Scales position `self` by fixed-decimal `scale` and returns the resulting position\n * @param self The Position to operate on\n * @param scale The Fixed-decimal to scale by\n * @return Resulting scaled position\n */\n function mul(Position memory self, UFixed18 scale) internal pure returns (Position memory) {\n return Position({maker: self.maker.mul(scale), taker: self.taker.mul(scale)});\n }\n\n /**\n * @notice Divides position `self` by `b` and returns the resulting accumulator\n * @param self The Position to operate on\n * @param b The number to divide by\n * @return Resulting divided accumulator\n */\n function div(Position memory self, uint256 b) internal pure returns (Accumulator memory) {\n return Accumulator({\n maker: Fixed18Lib.from(self.maker).div(Fixed18Lib.from(UFixed18Lib.from(b))),\n taker: Fixed18Lib.from(self.taker).div(Fixed18Lib.from(UFixed18Lib.from(b)))\n });\n }\n\n /**\n * @notice Returns the maximum of `self`'s maker and taker values\n * @param self The struct to operate on\n * @return Resulting maximum value\n */\n function max(Position memory self) internal pure returns (UFixed18) {\n return UFixed18Lib.max(self.maker, self.taker);\n }\n\n /**\n * @notice Sums the maker and taker together from a single position\n * @param self The struct to operate on\n * @return The sum of its maker and taker\n */\n function sum(Position memory self) internal pure returns (UFixed18) {\n return self.maker.add(self.taker);\n }\n\n /**\n * @notice Computes the next position after the pending-settlement position delta is included\n * @param self The current Position\n * @param pre The pending-settlement position delta\n * @return Next Position\n */\n function next(Position memory self, PrePosition memory pre) internal pure returns (Position memory) {\n return sub(add(self, pre.openPosition), pre.closePosition);\n }\n\n /**\n * @notice Returns the settled position at oracle version `toOracleVersion`\n * @dev Checks if a new position is ready to be settled based on the provided `toOracleVersion`\n * and `pre` and returns accordingly\n * @param self The current Position\n * @param pre The pending-settlement position delta\n * @param toOracleVersion The oracle version to settle to\n * @return Settled position at oracle version\n * @return Fee accrued from opening or closing the position\n * @return Whether a new position was settled\n */\n function settled(\n Position memory self,\n PrePosition memory pre,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal view returns (Position memory, UFixed18, bool) {\n return pre.canSettle(toOracleVersion) ? (next(self, pre), pre.computeFee(toOracleVersion), true) : (self, UFixed18Lib.ZERO, false);\n }\n\n /**\n * @notice Returns the socialization factor for the current position\n * @dev Socialization account for the case where `taker` > `maker` temporarily due to a liquidation\n * on the maker side. This dampens the taker's exposure pro-rata to ensure that the maker side\n * is never exposed over 1 x short.\n * @param self The Position to operate on\n * @return Socialization factor\n */\n function socializationFactor(Position memory self) internal pure returns (UFixed18) {\n return self.taker.isZero() ? UFixed18Lib.ONE : UFixed18Lib.min(UFixed18Lib.ONE, self.maker.div(self.taker));\n }\n}\n" - }, - "contracts/interfaces/types/PrePosition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"./Position.sol\";\nimport \"../IProduct.sol\";\n\n/// @dev PrePosition type\nstruct PrePosition {\n /// @dev Oracle version at which the new position delta was recorded\n uint256 oracleVersion;\n\n /// @dev Size of position to open at oracle version\n Position openPosition;\n\n /// @dev Size of position to close at oracle version\n Position closePosition;\n}\nusing PrePositionLib for PrePosition global;\n\n/**\n * @title PrePositionLib\n * @notice Library that manages a pre-settlement position delta.\n * @dev PrePositions track the currently awaiting-settlement deltas to a settled Position. These are\n * Primarily necessary to introduce lag into the settlement system such that oracle lag cannot be\n * gamed to a user's advantage. When a user opens or closes a new position, it sits as a PrePosition\n * for one oracle version until it's settle into the Position, making it then effective. PrePositions\n * are automatically settled at the correct oracle version even if a flywheel call doesn't happen until\n * several version into the future by using the historical version lookups in the corresponding \"Versioned\"\n * global state types.\n */\nlibrary PrePositionLib {\n /**\n * @notice Returns whether there is no pending-settlement position delta\n * @dev Can be \"empty\" even with a non-zero oracleVersion if a position is opened and\n * closed in the same version netting out to a zero position delta\n * @param self The struct to operate on\n * @return Whether the pending-settlement position delta is empty\n */\n function isEmpty(PrePosition memory self) internal pure returns (bool) {\n return self.openPosition.isEmpty() && self.closePosition.isEmpty();\n }\n\n /**\n * @notice Increments the maker side of the open position delta\n * @dev Nets out open and close deltas to minimize the size of each\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @param amount The position amount to open\n */\n function openMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\n self.openPosition.maker = self.openPosition.maker.add(amount);\n self.oracleVersion = currentVersion;\n _netMake(self);\n }\n\n /**\n * @notice Increments the maker side of the close position delta\n * @dev Nets out open and close deltas to minimize the size of each\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @param amount The maker position amount to close\n */\n function closeMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\n self.closePosition.maker = self.closePosition.maker.add(amount);\n self.oracleVersion = currentVersion;\n _netMake(self);\n }\n\n /**\n * @notice Increments the taker side of the open position delta\n * @dev Nets out open and close deltas to minimize the size of each\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @param amount The taker position amount to open\n */\n function openTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\n self.openPosition.taker = self.openPosition.taker.add(amount);\n self.oracleVersion = currentVersion;\n _netTake(self);\n }\n\n /**\n * @notice Increments the taker side of the close position delta\n * @dev Nets out open and close deltas to minimize the size of each\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @param amount The taker position amount to close\n */\n function closeTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\n self.closePosition.taker = self.closePosition.taker.add(amount);\n self.oracleVersion = currentVersion;\n _netTake(self);\n }\n\n /**\n * @notice Nets out the open and close on the maker side of the position delta\n * @param self The struct to operate on\n */\n function _netMake(PrePosition storage self) private {\n if (self.openPosition.maker.gt(self.closePosition.maker)) {\n self.openPosition.maker = self.openPosition.maker.sub(self.closePosition.maker);\n self.closePosition.maker = UFixed18Lib.ZERO;\n } else {\n self.closePosition.maker = self.closePosition.maker.sub(self.openPosition.maker);\n self.openPosition.maker = UFixed18Lib.ZERO;\n }\n }\n\n /**\n * @notice Nets out the open and close on the taker side of the position delta\n * @param self The struct to operate on\n */\n function _netTake(PrePosition storage self) private {\n if (self.openPosition.taker.gt(self.closePosition.taker)) {\n self.openPosition.taker = self.openPosition.taker.sub(self.closePosition.taker);\n self.closePosition.taker = UFixed18Lib.ZERO;\n } else {\n self.closePosition.taker = self.closePosition.taker.sub(self.openPosition.taker);\n self.openPosition.taker = UFixed18Lib.ZERO;\n }\n }\n\n /**\n * @notice Returns whether the the pending position delta can be settled at version `toOracleVersion`\n * @dev Pending-settlement positions deltas can be settled (1) oracle version after they are recorded\n * @param self The struct to operate on\n * @param toOracleVersion The potential oracle version to settle\n * @return Whether the position delta can be settled\n */\n function canSettle(\n PrePosition memory self,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal pure returns (bool) {\n return !isEmpty(self) && toOracleVersion.version > self.oracleVersion;\n }\n\n /**\n * @notice Computes the fee incurred for opening or closing the pending-settlement position\n * @dev Must be called from a valid product to get the proper fee amounts\n * @param self The struct to operate on\n * @param toOracleVersion The oracle version at which settlement takes place\n * @return positionFee The maker / taker fee incurred\n */\n function computeFee(\n PrePosition memory self,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal view returns (UFixed18) {\n Position memory positionDelta = self.openPosition.add(self.closePosition);\n\n (UFixed18 makerNotional, UFixed18 takerNotional) = (\n Fixed18Lib.from(positionDelta.maker).mul(toOracleVersion.price).abs(),\n Fixed18Lib.from(positionDelta.taker).mul(toOracleVersion.price).abs()\n );\n\n IProduct product = IProduct(address(this));\n return makerNotional.mul(product.makerFee()).add(takerNotional.mul(product.takerFee()));\n }\n\n /**\n * @notice Computes the next oracle version to settle\n * @dev - If there is no pending-settlement position delta, returns the current oracle version\n * - Otherwise returns the oracle version at which the pending-settlement position delta can be first settled\n *\n * Corresponds to point (b) in the Position settlement flow\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @return Next oracle version to settle\n */\n function settleVersion(PrePosition storage self, uint256 currentVersion) internal view returns (uint256) {\n uint256 _oracleVersion = self.oracleVersion;\n return _oracleVersion == 0 ? currentVersion : _oracleVersion + 1;\n }\n}\n" - }, - "contracts/interfaces/types/Accumulator.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/Fixed18.sol\";\nimport \"./PackedAccumulator.sol\";\n\n/// @dev Accumulator type\nstruct Accumulator {\n /// @dev maker accumulator per share\n Fixed18 maker;\n /// @dev taker accumulator per share\n Fixed18 taker;\n}\nusing AccumulatorLib for Accumulator global;\n\n/**\n * @title AccountAccumulatorLib\n * @notice Library that surfaces math operations for the Accumulator type.\n * @dev Accumulators track the cumulative change in position value over time for the maker and taker positions\n * respectively. Account-level accumulators can then use two of these values `a` and `a'` to compute the\n * change in position value since last sync. This change in value is then used to compute P&L and fees.\n */\nlibrary AccumulatorLib {\n /**\n * @notice Creates a packed accumulator from an accumulator\n * @param self an accumulator\n * @return New packed accumulator\n */\n function pack(Accumulator memory self) internal pure returns (PackedAccumulator memory) {\n return PackedAccumulator({maker: self.maker.pack(), taker: self.taker.pack()});\n }\n\n /**\n * @notice Adds two accumulators together\n * @param a The first accumulator to sum\n * @param b The second accumulator to sum\n * @return The resulting summed accumulator\n */\n function add(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\n return Accumulator({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\n }\n\n /**\n * @notice Subtracts accumulator `b` from `a`\n * @param a The accumulator to subtract from\n * @param b The accumulator to subtract\n * @return The resulting subtracted accumulator\n */\n function sub(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\n return Accumulator({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\n }\n\n /**\n * @notice Multiplies two accumulators together\n * @param a The first accumulator to multiply\n * @param b The second accumulator to multiply\n * @return The resulting multiplied accumulator\n */\n function mul(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\n return Accumulator({maker: a.maker.mul(b.maker), taker: a.taker.mul(b.taker)});\n }\n\n /**\n * @notice Sums the maker and taker together from a single accumulator\n * @param self The struct to operate on\n * @return The sum of its maker and taker\n */\n function sum(Accumulator memory self) internal pure returns (Fixed18) {\n return self.maker.add(self.taker);\n }\n}\n" - }, - "@equilibria/root/curve/CurveMath.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"../number/types/UFixed18.sol\";\nimport \"../number/types/Fixed18.sol\";\n\n/**\n * @title CurveMath\n * @notice Library for managing math operations for utilization curves.\n */\nlibrary CurveMath {\n error CurveMathOutOfBoundsError();\n\n /**\n * @notice Computes a linear interpolation between two points\n * @param startX First point's x-coordinate\n * @param startY First point's y-coordinate\n * @param endX Second point's x-coordinate\n * @param endY Second point's y-coordinate\n * @param targetX x-coordinate to interpolate\n * @return y-coordinate for `targetX` along the line from (`startX`, `startY`) -> (`endX`, `endY`)\n */\n function linearInterpolation(\n UFixed18 startX,\n Fixed18 startY,\n UFixed18 endX,\n Fixed18 endY,\n UFixed18 targetX\n ) internal pure returns (Fixed18) {\n if (targetX.lt(startX) || targetX.gt(endX)) revert CurveMathOutOfBoundsError();\n\n UFixed18 xRange = endX.sub(startX);\n Fixed18 yRange = endY.sub(startY);\n UFixed18 xRatio = targetX.sub(startX).div(xRange);\n return yRange.mul(Fixed18Lib.from(xRatio)).add(startY);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Address.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // 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\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" - }, - "contracts/interfaces/IContractPayoffProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/Fixed18.sol\";\n\ninterface IContractPayoffProvider {\n function payoff(Fixed18 price) external view returns (Fixed18 payoff);\n}\n" - }, - "contracts/interfaces/types/PackedPosition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/PackedUFixed18.sol\";\nimport \"./Position.sol\";\n\n/// @dev PackedPosition type\nstruct PackedPosition {\n /// @dev Quantity of the maker position\n PackedUFixed18 maker;\n /// @dev Quantity of the taker position\n PackedUFixed18 taker;\n}\nusing PackedPositionLib for PackedPosition global;\n\n/**\n * @title PackedPositionLib\n * @dev A packed version of the Position which takes up a single storage slot using `PackedFixed18` values.\n * @notice Library for the packed Position type.\n */\nlibrary PackedPositionLib {\n /**\n * @notice Creates an position from a packed position\n * @param self packed position\n * @return New position\n */\n function unpack(PackedPosition memory self) internal pure returns (Position memory) {\n return Position({maker: self.maker.unpack(), taker: self.taker.unpack()});\n }\n}\n" - }, - "contracts/interfaces/types/PackedAccumulator.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/PackedFixed18.sol\";\nimport \"./Accumulator.sol\";\n\n/// @dev PackedAccumulator type\nstruct PackedAccumulator {\n /// @dev maker accumulator per share\n PackedFixed18 maker;\n /// @dev taker accumulator per share\n PackedFixed18 taker;\n}\nusing PackedAccumulatorLib for PackedAccumulator global;\n\n/**\n * @title PackedAccumulatorLib\n * @dev A packed version of the Accumulator which takes up a single storage slot using `PackedFixed18` values.\n * @notice Library for the packed Accumulator type.\n */\nlibrary PackedAccumulatorLib {\n /**\n * @notice Creates an accumulator from a packed accumulator\n * @param self packed accumulator\n * @return New accumulator\n */\n function unpack(PackedAccumulator memory self) internal pure returns (Accumulator memory) {\n return Accumulator({maker: self.maker.unpack(), taker: self.taker.unpack()});\n }\n}\n" - }, - "@equilibria/root/token/types/Token18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"../../number/types/UFixed18.sol\";\n\n/// @dev Token18\ntype Token18 is address;\nusing Token18Lib for Token18 global;\ntype Token18Storage is bytes32;\nusing Token18StorageLib for Token18Storage global;\n\n/**\n * @title Token18Lib\n * @notice Library to manage 18-decimal ERC20s that is compliant with the fixed-decimal types.\n * @dev Maintains significant gas savings over other Token implementations since no conversion take place\n */\nlibrary Token18Lib {\n using SafeERC20 for IERC20;\n\n Token18 public constant ZERO = Token18.wrap(address(0));\n\n /**\n * @notice Returns whether a token is the zero address\n * @param self Token to check for\n * @return Whether the token is the zero address\n */\n function isZero(Token18 self) internal pure returns (bool) {\n return Token18.unwrap(self) == Token18.unwrap(ZERO);\n }\n\n /**\n * @notice Returns whether the two tokens are equal\n * @param a First token to compare\n * @param b Second token to compare\n * @return Whether the two tokens are equal\n */\n function eq(Token18 a, Token18 b) internal pure returns (bool) {\n return Token18.unwrap(a) == Token18.unwrap(b);\n }\n\n /**\n * @notice Approves `grantee` to spend infinite tokens from the caller\n * @param self Token to transfer\n * @param grantee Address to allow spending\n */\n function approve(Token18 self, address grantee) internal {\n IERC20(Token18.unwrap(self)).safeApprove(grantee, type(uint256).max);\n }\n\n /**\n * @notice Approves `grantee` to spend `amount` tokens from the caller\n * @dev There are important race conditions to be aware of when using this function\n with values other than 0. This will revert if moving from non-zero to non-zero amounts\n See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/a55b7d13722e7ce850b626da2313f3e66ca1d101/contracts/token/ERC20/IERC20.sol#L57\n * @param self Token to transfer\n * @param grantee Address to allow spending\n * @param amount Amount of tokens to approve to spend\n */\n function approve(Token18 self, address grantee, UFixed18 amount) internal {\n IERC20(Token18.unwrap(self)).safeApprove(grantee, UFixed18.unwrap(amount));\n }\n\n /**\n * @notice Transfers all held tokens from the caller to the `recipient`\n * @param self Token to transfer\n * @param recipient Address to receive the tokens\n */\n function push(Token18 self, address recipient) internal {\n push(self, recipient, balanceOf(self, address(this)));\n }\n\n /**\n * @notice Transfers `amount` tokens from the caller to the `recipient`\n * @param self Token to transfer\n * @param recipient Address to transfer tokens to\n * @param amount Amount of tokens to transfer\n */\n function push(Token18 self, address recipient, UFixed18 amount) internal {\n IERC20(Token18.unwrap(self)).safeTransfer(recipient, UFixed18.unwrap(amount));\n }\n\n /**\n * @notice Transfers `amount` tokens from the `benefactor` to the caller\n * @dev Reverts if trying to pull Ether\n * @param self Token to transfer\n * @param benefactor Address to transfer tokens from\n * @param amount Amount of tokens to transfer\n */\n function pull(Token18 self, address benefactor, UFixed18 amount) internal {\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, address(this), UFixed18.unwrap(amount));\n }\n\n /**\n * @notice Transfers `amount` tokens from the `benefactor` to `recipient`\n * @dev Reverts if trying to pull Ether\n * @param self Token to transfer\n * @param benefactor Address to transfer tokens from\n * @param recipient Address to transfer tokens to\n * @param amount Amount of tokens to transfer\n */\n function pullTo(Token18 self, address benefactor, address recipient, UFixed18 amount) internal {\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, recipient, UFixed18.unwrap(amount));\n }\n\n /**\n * @notice Returns the name of the token\n * @param self Token to check for\n * @return Token name\n */\n function name(Token18 self) internal view returns (string memory) {\n return IERC20Metadata(Token18.unwrap(self)).name();\n }\n\n /**\n * @notice Returns the symbol of the token\n * @param self Token to check for\n * @return Token symbol\n */\n function symbol(Token18 self) internal view returns (string memory) {\n return IERC20Metadata(Token18.unwrap(self)).symbol();\n }\n\n /**\n * @notice Returns the `self` token balance of the caller\n * @param self Token to check for\n * @return Token balance of the caller\n */\n function balanceOf(Token18 self) internal view returns (UFixed18) {\n return balanceOf(self, address(this));\n }\n\n /**\n * @notice Returns the `self` token balance of `account`\n * @param self Token to check for\n * @param account Account to check\n * @return Token balance of the account\n */\n function balanceOf(Token18 self, address account) internal view returns (UFixed18) {\n return UFixed18.wrap(IERC20(Token18.unwrap(self)).balanceOf(account));\n }\n}\n\nlibrary Token18StorageLib {\n function read(Token18Storage self) internal view returns (Token18 value) {\n assembly {\n value := sload(self)\n }\n }\n\n function store(Token18Storage self, Token18 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/IERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\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 amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` 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(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\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" - }, - "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 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 using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\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 function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" - }, - "@openzeppelin/contracts/proxy/beacon/IBeacon.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n" - }, - "contracts/interfaces/IIncentivizer.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"./types/ProgramInfo.sol\";\nimport \"./IController.sol\";\nimport \"./IProduct.sol\";\n\ninterface IIncentivizer {\n event ProgramCreated(IProduct indexed product, uint256 indexed programId, ProgramInfo programInfo, UFixed18 programFeeAmount);\n event ProgramStarted(IProduct indexed product, uint256 indexed programId, uint256 version);\n event ProgramComplete(IProduct indexed product, uint256 indexed programId, uint256 version);\n event Claim(IProduct indexed product, address indexed account, uint256 indexed programId, UFixed18 amount);\n event FeeClaim(Token18 indexed token, UFixed18 amount);\n\n error IncentivizerNotAllowedError(IProduct product);\n error IncentivizerTooManyProgramsError();\n error IncentivizerNotProgramOwnerError(IProduct product, uint256 programId);\n error IncentivizerInvalidProgramError(IProduct product, uint256 programId);\n error IncentivizerBatchClaimArgumentMismatchError();\n\n function programInfos(IProduct product, uint256 programId) external view returns (ProgramInfo memory);\n function fees(Token18 token) external view returns (UFixed18);\n function initialize(IController controller_) external;\n function create(IProduct product, ProgramInfo calldata info) external returns (uint256);\n function complete(IProduct product, uint256 programId) external;\n function sync(IOracleProvider.OracleVersion memory currentOracleVersion) external;\n function syncAccount(address account, IOracleProvider.OracleVersion memory currentOracleVersion) external;\n function claim(IProduct product, uint256[] calldata programIds) external;\n function claim(IProduct[] calldata products, uint256[][] calldata programIds) external;\n function claimFee(Token18[] calldata tokens) external;\n function active(IProduct product) external view returns (uint256);\n function count(IProduct product) external view returns (uint256);\n function unclaimed(IProduct product, address account, uint256 programId) external view returns (UFixed18);\n function available(IProduct product, uint256 programId) external view returns (UFixed18);\n function versionStarted(IProduct product, uint256 programId) external view returns (uint256);\n function versionComplete(IProduct product, uint256 programId) external view returns (uint256);\n function owner(IProduct product, uint256 programId) external view returns (address);\n function treasury(IProduct product, uint256 programId) external view returns (address);\n}\n" - }, - "contracts/interfaces/types/ProgramInfo.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"../IProduct.sol\";\nimport \"./Position.sol\";\nimport \"./Accumulator.sol\";\n\n/// @dev ProgramInfo type\nstruct ProgramInfo {\n /// @dev Coordinator for this program\n uint256 coordinatorId;\n\n /// @dev Amount of total maker and taker rewards\n Position amount;\n\n /// @dev start timestamp of the program\n uint256 start;\n\n /// @dev duration of the program (in seconds)\n uint256 duration;\n\n /**\n * @dev Reward ERC20 token contract\n * @notice Perennial does not support non-standard ERC20s as reward tokens for incentive programs, including,\n but not limited to: fee on transfer and rebase tokens. Using such a non-standard token will likely\n result in loss of funds.\n */\n Token18 token;\n}\nusing ProgramInfoLib for ProgramInfo global;\n\n/**\n * @title ProgramInfoLib\n * @notice Library that snapshots the static information for a single program.\n * @dev This information does not change during the operation of a program.\n */\nlibrary ProgramInfoLib {\n uint256 private constant MIN_DURATION = 1 days;\n uint256 private constant MAX_DURATION = 2 * 365 days;\n\n error ProgramInvalidStartError();\n error ProgramInvalidDurationError();\n\n /**\n * @notice Validates and creates a new Program\n * @dev Reverts for invalid programInfos\n * @param programInfo Un-sanitized static program information\n */\n function validate(ProgramInfo memory programInfo) internal view {\n if (isStarted(programInfo, block.timestamp)) revert ProgramInvalidStartError();\n if (programInfo.duration < MIN_DURATION || programInfo.duration > MAX_DURATION) revert ProgramInvalidDurationError();\n }\n\n /**\n * @notice Computes a new program info with the fee taken out of the amount\n * @param programInfo Original program info\n * @param incentivizationFee The incentivization fee\n * @return New program info\n * @return Fee amount\n */\n function deductFee(ProgramInfo memory programInfo, UFixed18 incentivizationFee)\n internal pure returns (ProgramInfo memory, UFixed18) {\n Position memory newProgramAmount = programInfo.amount.mul(UFixed18Lib.ONE.sub(incentivizationFee));\n UFixed18 programFeeAmount = programInfo.amount.sub(newProgramAmount).sum();\n programInfo.amount = newProgramAmount;\n return (programInfo, programFeeAmount);\n }\n\n /**\n * @notice Returns the maker and taker amounts per position share\n * @param self The ProgramInfo to operate on\n * @return programFee Amounts per share\n */\n function amountPerShare(ProgramInfo memory self) internal pure returns (Accumulator memory) {\n return self.amount.div(self.duration);\n }\n\n /**\n * @notice Returns whether the program has started by timestamp `timestamp`\n * @param self The ProgramInfo to operate on\n * @param timestamp Timestamp to check for\n * @return Whether the program has started\n */\n function isStarted(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\n return timestamp >= self.start;\n }\n\n /**\n * @notice Returns whether the program is completed by timestamp `timestamp`\n * @param self The ProgramInfo to operate on\n * @param timestamp Timestamp to check for\n * @return Whether the program is completed\n */\n function isComplete(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\n return timestamp >= (self.start + self.duration);\n }\n}\n" - } - }, - "settings": { - "optimizer": { - "enabled": false, - "runs": 1000000 - }, - "outputSelection": { - "*": { - "*": [ - "storageLayout", - "abi", - "evm.bytecode", - "evm.deployedBytecode", - "evm.methodIdentifiers", - "metadata", - "devdoc", - "userdoc", - "evm.gasEstimates" - ], - "": ["ast"] - } - }, - "metadata": { - "useLiteralContent": true - } - } -} diff --git a/packages/perennial/deployments/kovan/solcInputs/dd0d601ac153d6a2cb60f335fa990f18.json b/packages/perennial/deployments/kovan/solcInputs/dd0d601ac153d6a2cb60f335fa990f18.json deleted file mode 100644 index 00a283dc6..000000000 --- a/packages/perennial/deployments/kovan/solcInputs/dd0d601ac153d6a2cb60f335fa990f18.json +++ /dev/null @@ -1,354 +0,0 @@ -{ - "language": "Solidity", - "sources": { - "contracts/collateral/Collateral.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/root/control/unstructured/UInitializable.sol\";\nimport \"@equilibria/root/control/unstructured/UReentrancyGuard.sol\";\nimport \"../interfaces/ICollateral.sol\";\nimport \"./types/OptimisticLedger.sol\";\nimport \"../controller/UControllerProvider.sol\";\n\n/**\n * @title Collateral\n * @notice Manages logic and state for all collateral accounts in the protocol.\n */\ncontract Collateral is ICollateral, UInitializable, UControllerProvider, UReentrancyGuard {\n /// @dev ERC20 stablecoin for collateral\n Token18 public immutable token;\n\n /// @dev Per product collateral state\n mapping(IProduct => OptimisticLedger) private _products;\n\n /// @dev Protocol and product fees collected, but not yet claimed\n mapping(address => UFixed18) public fees;\n\n /**\n * @notice Initializes the immutable contract state\n * @dev Called at implementation instantiate and constant for that implementation.\n * @param token_ Collateral ERC20 stablecoin address\n */\n constructor(Token18 token_) {\n token = token_;\n }\n\n /**\n * @notice Initializes the contract state\n * @dev Must be called atomically as part of the upgradeable proxy deployment to\n * avoid front-running\n * @param controller_ Factory contract address\n */\n function initialize(IController controller_) external initializer(1) {\n __UControllerProvider__initialize(controller_);\n __UReentrancyGuard__initialize();\n }\n\n /**\n * @notice Deposits `amount` collateral from `msg.sender` to `account`'s `product`\n * account\n * @param account Account to deposit the collateral for\n * @param product Product to credit the collateral to\n * @param amount Amount of collateral to deposit\n */\n function depositTo(address account, IProduct product, UFixed18 amount)\n external\n nonReentrant\n notPaused\n notZeroAddress(account)\n isProduct(product)\n collateralInvariant(account, product)\n {\n _products[product].creditAccount(account, amount);\n token.pull(msg.sender, amount);\n\n emit Deposit(account, product, amount);\n }\n\n /**\n * @notice Withdraws `amount` collateral from `msg.sender`'s `product` account\n * and sends it to `account`\n * @param account Account to withdraw the collateral to\n * @param product Product to withdraw the collateral from\n * @param amount Amount of collateral to withdraw\n */\n function withdrawTo(address account, IProduct product, UFixed18 amount)\n external\n nonReentrant\n notPaused\n notZeroAddress(account)\n isProduct(product)\n settleForAccount(msg.sender, product)\n collateralInvariant(msg.sender, product)\n maintenanceInvariant(msg.sender, product)\n {\n amount = amount.eq(UFixed18Lib.MAX) ? collateral(msg.sender, product) : amount;\n _products[product].debitAccount(msg.sender, amount);\n token.push(account, amount);\n\n emit Withdrawal(msg.sender, product, amount);\n }\n\n /**\n * @notice Liquidates `account`'s `product` collateral account\n * @dev Account must be under-collateralized, fee returned immediately to `msg.sender`\n * @param account Account to liquidate\n * @param product Product to liquidate for\n */\n function liquidate(address account, IProduct product)\n external\n nonReentrant\n notPaused\n isProduct(product)\n settleForAccount(account, product)\n {\n UFixed18 totalMaintenance = product.maintenance(account);\n UFixed18 totalCollateral = collateral(account, product);\n\n if (!totalMaintenance.gt(totalCollateral))\n revert CollateralCantLiquidate(totalMaintenance, totalCollateral);\n\n product.closeAll(account);\n\n // claim fee\n UFixed18 liquidationFee = controller().liquidationFee();\n UFixed18 fee = UFixed18Lib.min(totalCollateral, totalMaintenance.mul(liquidationFee));\n\n _products[product].debitAccount(account, fee);\n token.push(msg.sender, fee);\n\n emit Liquidation(account, product, msg.sender, fee);\n }\n\n /**\n * @notice Credits `amount` to `account`'s collateral account\n * @dev Callable only by the corresponding product as part of the settlement flywheel.\n * Moves collateral within a product, any collateral leaving the product due to\n * fees has already been accounted for in the settleProduct flywheel.\n * Debits in excess of the account balance get recorded as shortfall, and can be\n * resolved by the product owner as needed.\n * @param account Account to credit\n * @param amount Amount to credit the account (can be negative)\n */\n function settleAccount(address account, Fixed18 amount) external onlyProduct {\n IProduct product = IProduct(msg.sender);\n\n UFixed18 newShortfall = _products[product].settleAccount(account, amount);\n\n emit AccountSettle(product, account, amount, newShortfall);\n }\n\n /**\n * @notice Debits `amount` from product's total collateral account\n * @dev Callable only by the corresponding product as part of the settlement flywheel\n * Removes collateral from the product as fees.\n * @param amount Amount to debit from the account\n */\n function settleProduct(UFixed18 amount) external onlyProduct {\n (IProduct product, IController controller) = (IProduct(msg.sender), controller());\n\n address protocolTreasury = controller.treasury();\n address productTreasury = controller.treasury(product);\n\n UFixed18 protocolFee = amount.mul(controller.protocolFee());\n UFixed18 productFee = amount.sub(protocolFee);\n\n _products[product].debit(amount);\n fees[protocolTreasury] = fees[protocolTreasury].add(protocolFee);\n fees[productTreasury] = fees[productTreasury].add(productFee);\n\n emit ProductSettle(product, protocolFee, productFee);\n }\n\n /**\n * @notice Returns the balance of `account`'s `product` collateral account\n * @param account Account to return for\n * @param product Product to return for\n * @return The balance of the collateral account\n */\n function collateral(address account, IProduct product) public view returns (UFixed18) {\n return _products[product].balances[account];\n }\n\n /**\n * @notice Returns the total balance of `product`'s collateral\n * @param product Product to return for\n * @return The total balance of collateral in the product\n */\n function collateral(IProduct product) external view returns (UFixed18) {\n return _products[product].total;\n }\n\n /**\n * @notice Returns the current shortfall of `product`'s collateral\n * @param product Product to return for\n * @return The current shortfall of the product\n */\n function shortfall(IProduct product) external view returns (UFixed18) {\n return _products[product].shortfall;\n }\n\n /**\n * @notice Returns whether `account`'s `product` collateral account can be liquidated\n * @param account Account to return for\n * @param product Product to return for\n * @return Whether the account can be liquidated\n */\n function liquidatable(address account, IProduct product) external view returns (bool) {\n return product.maintenance(account).gt(collateral(account, product));\n }\n\n /**\n * @notice Returns whether `account`'s `product` collateral account can be liquidated\n * after the next oracle version settlement\n * @dev Takes into account the current pre-position on the account\n * @param account Account to return for\n * @param product Product to return for\n * @return Whether the account can be liquidated\n */\n function liquidatableNext(address account, IProduct product) external view returns (bool) {\n return product.maintenanceNext(account).gt(collateral(account, product));\n }\n\n /**\n * @notice Injects additional collateral into a product to resolve shortfall\n * @dev Shortfall is a measure of settled insolvency in the market\n * This hook can be used by the product owner or an insurance fund to re-capitalize an insolvent market\n * @param product Product to resolve shortfall for\n * @param amount Amount of shortfall to resolve\n */\n function resolveShortfall(IProduct product, UFixed18 amount) external isProduct(product) notPaused {\n _products[product].resolve(amount);\n token.pull(msg.sender, amount);\n\n emit ShortfallResolution(product, amount);\n }\n\n /**\n * @notice Claims all of `msg.sender`'s fees\n */\n function claimFee() external notPaused {\n UFixed18 amount = fees[msg.sender];\n\n fees[msg.sender] = UFixed18Lib.ZERO;\n token.push(msg.sender, amount);\n\n emit FeeClaim(msg.sender, amount);\n }\n\n /// @dev Ensure that the address is non-zero\n modifier notZeroAddress(address account) {\n if (account == address(0)) revert CollateralZeroAddressError();\n\n _;\n }\n\n /// @dev Ensure that the user has sufficient margin for both current and next maintenance\n modifier maintenanceInvariant(address account, IProduct product) {\n _;\n\n UFixed18 maintenance = product.maintenance(account);\n UFixed18 maintenanceNext = product.maintenanceNext(account);\n\n if (UFixed18Lib.max(maintenance, maintenanceNext).gt(collateral(account, product)))\n revert CollateralInsufficientCollateralError();\n }\n\n /// @dev Ensure that the account is either empty or above the collateral minimum\n modifier collateralInvariant(address account, IProduct product) {\n _;\n\n UFixed18 accountCollateral = collateral(account, product);\n if (!accountCollateral.isZero() && accountCollateral.lt(controller().minCollateral()))\n revert CollateralUnderLimitError();\n }\n\n /// @dev Helper to fully settle an account's state\n modifier settleForAccount(address account, IProduct product) {\n product.settleAccount(account);\n\n _;\n }\n}\n" - }, - "@equilibria/root/control/unstructured/UInitializable.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"../../storage/UStorage.sol\";\n\n/**\n * @title UInitializable\n * @notice Library to manage the initialization lifecycle of upgradeable contracts\n * @dev `UInitializable` allows the creation of pseudo-constructors for upgradeable contracts. One\n * `initializer` should be declared per top-level contract. Child contracts can use the `onlyInitializer`\n * modifier to tag their internal initialization functions to ensure that they can only be called\n * from a top-level `initializer` or a constructor.\n */\nabstract contract UInitializable {\n error UInitializableZeroVersionError();\n error UInitializableAlreadyInitializedError(uint256 version);\n error UInitializableNotInitializingError();\n\n event Initialized(uint256 version);\n\n /// @dev The initialized flag\n Uint256Storage private constant _version = Uint256Storage.wrap(keccak256(\"equilibria.root.UInitializable.version\"));\n\n /// @dev The initializing flag\n BoolStorage private constant _initializing = BoolStorage.wrap(keccak256(\"equilibria.root.UInitializable.initializing\"));\n\n /// @dev Can only be called once per version, `version` is 1-indexed\n modifier initializer(uint256 version) {\n if (version == 0) revert UInitializableZeroVersionError();\n if (_version.read() >= version) revert UInitializableAlreadyInitializedError(version);\n\n _version.store(version);\n _initializing.store(true);\n\n _;\n\n _initializing.store(false);\n emit Initialized(version);\n }\n\n /// @dev Can only be called from an initializer or constructor\n modifier onlyInitializer() {\n if (!_constructing() && !_initializing.read()) revert UInitializableNotInitializingError();\n _;\n }\n\n /**\n * @notice Returns whether the contract is currently being constructed\n * @dev {Address.isContract} returns false for contracts currently in the process of being constructed\n * @return Whether the contract is currently being constructed\n */\n function _constructing() private view returns (bool) {\n return !Address.isContract(address(this));\n }\n}\n" - }, - "@equilibria/root/control/unstructured/UReentrancyGuard.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"./UInitializable.sol\";\nimport \"../../storage/UStorage.sol\";\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n *\n * NOTE: This contract has been extended from the Open Zeppelin library to include an\n * unstructured storage pattern, so that it can be safely mixed in with upgradeable\n * contracts without affecting their storage patterns through inheritance.\n */\nabstract contract UReentrancyGuard is UInitializable {\n error UReentrancyGuardReentrantCallError();\n\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n /**\n * @dev unstructured storage slot for the reentrancy status\n */\n Uint256Storage private constant _status = Uint256Storage.wrap(keccak256(\"equilibria.root.UReentrancyGuard.status\"));\n\n /**\n * @dev Initializes the contract setting the status to _NOT_ENTERED.\n */\n function __UReentrancyGuard__initialize() internal onlyInitializer {\n _status.store(_NOT_ENTERED);\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and make it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n // On the first call to nonReentrant, _notEntered will be true\n if (_status.read() == _ENTERED) revert UReentrancyGuardReentrantCallError();\n\n // Any calls to nonReentrant after this point will fail\n _status.store(_ENTERED);\n\n _;\n\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status.store(_NOT_ENTERED);\n }\n}\n" - }, - "contracts/interfaces/ICollateral.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/root/number/types/Fixed18.sol\";\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"./IController.sol\";\nimport \"./IProduct.sol\";\n\ninterface ICollateral {\n event Deposit(address indexed user, IProduct indexed product, UFixed18 amount);\n event Withdrawal(address indexed user, IProduct indexed product, UFixed18 amount);\n event AccountSettle(IProduct indexed product, address indexed account, Fixed18 amount, UFixed18 newShortfall);\n event ProductSettle(IProduct indexed product, UFixed18 protocolFee, UFixed18 productFee);\n event Liquidation(address indexed user, IProduct indexed product, address liquidator, UFixed18 fee);\n event ShortfallResolution(IProduct indexed product, UFixed18 amount);\n event FeeClaim(address indexed account, UFixed18 amount);\n\n error CollateralCantLiquidate(UFixed18 totalMaintenance, UFixed18 totalCollateral);\n error CollateralInsufficientCollateralError();\n error CollateralUnderLimitError();\n error CollateralZeroAddressError();\n\n function token() external view returns (Token18);\n function fees(address account) external view returns (UFixed18);\n function initialize(IController controller_) external;\n function depositTo(address account, IProduct product, UFixed18 amount) external;\n function withdrawTo(address account, IProduct product, UFixed18 amount) external;\n function liquidate(address account, IProduct product) external;\n function settleAccount(address account, Fixed18 amount) external;\n function settleProduct(UFixed18 amount) external;\n function collateral(address account, IProduct product) external view returns (UFixed18);\n function collateral(IProduct product) external view returns (UFixed18);\n function shortfall(IProduct product) external view returns (UFixed18);\n function liquidatable(address account, IProduct product) external view returns (bool);\n function liquidatableNext(address account, IProduct product) external view returns (bool);\n function resolveShortfall(IProduct product, UFixed18 amount) external;\n function claimFee() external;\n}\n" - }, - "contracts/collateral/types/OptimisticLedger.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\n\n/// @dev OptimisticLedger type\nstruct OptimisticLedger {\n /// @dev Individual account collateral balances\n mapping(address => UFixed18) balances;\n\n /// @dev Total ledger collateral balance\n UFixed18 total;\n\n /// @dev Total ledger collateral shortfall\n UFixed18 shortfall;\n}\nusing OptimisticLedgerLib for OptimisticLedger global;\n\n/**\n * @title OptimisticLedgerLib\n * @notice Library that manages a global vs account ledger where the global ledger is settled separately,\n * and ahead of, the user-level accounts.\n * @dev Ensures that no more collateral leaves the ledger than goes it, while allowing user-level accounts\n * to settle as a follow up step. Overdrafts on the user-level are accounted as \"shortall\". Shortfall\n * in the system is the quantity of insolvency that can be optionally resolved by the ledger owner.\n * Until the shortfall is resolved, collateral may be withdrawn from the ledger on a FCFS basis. However\n * once the ledger total has been depleted, users will not be able to withdraw even if they have non-zero\n * user level balances until the shortfall is resolved, recapitalizing the ledger.\n */\nlibrary OptimisticLedgerLib {\n /**\n * @notice Credits `account` with `amount` collateral\n * @param self The struct to operate on\n * @param account Account to credit collateral to\n * @param amount Amount of collateral to credit\n */\n function creditAccount(OptimisticLedger storage self, address account, UFixed18 amount) internal {\n self.balances[account] = self.balances[account].add(amount);\n self.total = self.total.add(amount);\n }\n\n /**\n * @notice Debits `account` `amount` collateral\n * @param self The struct to operate on\n * @param account Account to debit collateral from\n * @param amount Amount of collateral to debit\n */\n function debitAccount(OptimisticLedger storage self, address account, UFixed18 amount) internal {\n self.balances[account] = self.balances[account].sub(amount);\n self.total = self.total.sub(amount);\n }\n\n /**\n * @notice Credits `account` with `amount` collateral\n * @dev Funds come from inside the product, not totals are updated\n * Shortfall is created if more funds are debited from an account than exist\n * @param self The struct to operate on\n * @param account Account to credit collateral to\n * @param amount Amount of collateral to credit\n * @return newShortfall Any new shortfall incurred during this settlement\n */\n function settleAccount(OptimisticLedger storage self, address account, Fixed18 amount)\n internal returns (UFixed18 newShortfall) {\n Fixed18 newBalance = Fixed18Lib.from(self.balances[account]).add(amount);\n\n if (newBalance.sign() == -1) {\n newShortfall = newBalance.abs();\n newBalance = Fixed18Lib.ZERO;\n }\n\n self.balances[account] = newBalance.abs();\n self.shortfall = self.shortfall.add(newShortfall);\n }\n\n /**\n * @notice Debits ledger globally `amount` collateral\n * @dev Removes balance from total that is accounted for elsewhere (e.g. product-level accumulators)\n * @param self The struct to operate on\n * @param amount Amount of collateral to debit\n */\n function debit(OptimisticLedger storage self, UFixed18 amount) internal {\n self.total = self.total.sub(amount);\n }\n\n /**\n * @notice Reduces the amount of collateral shortfall in the ledger\n * @param self The struct to operate on\n * @param amount Amount of shortfall to resolve\n */\n function resolve(OptimisticLedger storage self, UFixed18 amount) internal {\n self.shortfall = self.shortfall.sub(amount);\n self.total = self.total.add(amount);\n }\n}\n" - }, - "contracts/controller/UControllerProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/root/control/unstructured/UInitializable.sol\";\nimport \"@equilibria/root/storage/UStorage.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"../interfaces/IController.sol\";\nimport \"../interfaces/IProduct.sol\";\n\n/**\n * @title UControllerProvider\n * @notice Mix-in that manages a controller pointer and associated permissioning modifiers.\n * @dev Uses unstructured storage so that it is safe to mix-in to upgreadable contracts without modifying\n * their storage layout.\n */\nabstract contract UControllerProvider is UInitializable {\n error NotOwnerError(uint256 coordinatorId);\n error NotProductError(IProduct product);\n error NotCollateralError();\n error PausedError();\n error InvalidControllerError();\n\n /// @dev The controller contract address\n AddressStorage private constant _controller = AddressStorage.wrap(keccak256(\"equilibria.perennial.UControllerProvider.controller\"));\n function controller() public view returns (IController) { return IController(_controller.read()); }\n\n /**\n * @notice Initializes the contract state\n * @param controller_ Protocol Controller contract address\n */\n // solhint-disable-next-line func-name-mixedcase\n function __UControllerProvider__initialize(IController controller_) internal onlyInitializer {\n if (!Address.isContract(address(controller_))) revert InvalidControllerError();\n _controller.store(address(controller_));\n }\n\n /// @dev Only allow a valid product contract to call\n modifier onlyProduct {\n if (!controller().isProduct(IProduct(msg.sender))) revert NotProductError(IProduct(msg.sender));\n\n _;\n }\n\n /// @dev Verify that `product` is a valid product contract\n modifier isProduct(IProduct product) {\n if (!controller().isProduct(product)) revert NotProductError(product);\n\n _;\n }\n\n /// @dev Only allow the Collateral contract to call\n modifier onlyCollateral {\n if (msg.sender != address(controller().collateral())) revert NotCollateralError();\n\n _;\n }\n\n /// @dev Only allow the coordinator owner to call\n modifier onlyOwner(uint256 coordinatorId) {\n if (msg.sender != controller().owner(coordinatorId)) revert NotOwnerError(coordinatorId);\n\n _;\n }\n\n /// @dev Only allow if the protocol is currently unpaused\n modifier notPaused() {\n if (controller().paused()) revert PausedError();\n\n _;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Address.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // 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\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" - }, - "@equilibria/root/storage/UStorage.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"../number/types/UFixed18.sol\";\n\n/// @dev Stored boolean slot\ntype BoolStorage is bytes32;\nusing BoolStorageLib for BoolStorage global;\n\n/// @dev Stored uint256 slot\ntype Uint256Storage is bytes32;\nusing Uint256StorageLib for Uint256Storage global;\n\n/// @dev Stored int256 slot\ntype Int256Storage is bytes32;\nusing Int256StorageLib for Int256Storage global;\n\n/// @dev Stored address slot\ntype AddressStorage is bytes32;\nusing AddressStorageLib for AddressStorage global;\n\n/// @dev Stored bytes32 slot\ntype Bytes32Storage is bytes32;\nusing Bytes32StorageLib for Bytes32Storage global;\n\n/**\n * @title BoolStorageLib\n * @notice Library to manage storage and retrival of a boolean at a fixed storage slot\n */\nlibrary BoolStorageLib {\n /**\n * @notice Retrieves the stored value\n * @param self Storage slot\n * @return value Stored bool value\n */\n function read(BoolStorage self) internal view returns (bool value) {\n assembly {\n value := sload(self)\n }\n }\n\n /**\n * @notice Stores the value at the specific slot\n * @param self Storage slot\n * @param value boolean value to store\n */\n function store(BoolStorage self, bool value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n\n/**\n * @title Uint256StorageLib\n * @notice Library to manage storage and retrival of an uint256 at a fixed storage slot\n */\nlibrary Uint256StorageLib {\n /**\n * @notice Retrieves the stored value\n * @param self Storage slot\n * @return value Stored uint256 value\n */\n function read(Uint256Storage self) internal view returns (uint256 value) {\n assembly {\n value := sload(self)\n }\n }\n\n /**\n * @notice Stores the value at the specific slot\n * @param self Storage slot\n * @param value uint256 value to store\n */\n function store(Uint256Storage self, uint256 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n\n/**\n * @title Int256StorageLib\n * @notice Library to manage storage and retrival of an int256 at a fixed storage slot\n */\nlibrary Int256StorageLib {\n /**\n * @notice Retrieves the stored value\n * @param self Storage slot\n * @return value Stored int256 value\n */\n function read(Int256Storage self) internal view returns (int256 value) {\n assembly {\n value := sload(self)\n }\n }\n\n /**\n * @notice Stores the value at the specific slot\n * @param self Storage slot\n * @param value int256 value to store\n */\n function store(Int256Storage self, int256 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n\n/**\n * @title AddressStorageLib\n * @notice Library to manage storage and retrival of an address at a fixed storage slot\n */\nlibrary AddressStorageLib {\n /**\n * @notice Retrieves the stored value\n * @param self Storage slot\n * @return value Stored address value\n */\n function read(AddressStorage self) internal view returns (address value) {\n assembly {\n value := sload(self)\n }\n }\n\n /**\n * @notice Stores the value at the specific slot\n * @param self Storage slot\n * @param value address value to store\n */\n function store(AddressStorage self, address value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n\n/**\n * @title Bytes32StorageLib\n * @notice Library to manage storage and retrival of a bytes32 at a fixed storage slot\n */\nlibrary Bytes32StorageLib {\n /**\n * @notice Retrieves the stored value\n * @param self Storage slot\n * @return value Stored bytes32 value\n */\n function read(Bytes32Storage self) internal view returns (bytes32 value) {\n assembly {\n value := sload(self)\n }\n }\n\n /**\n * @notice Stores the value at the specific slot\n * @param self Storage slot\n * @param value bytes32 value to store\n */\n function store(Bytes32Storage self, bytes32 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "@equilibria/root/number/types/UFixed18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"./Fixed18.sol\";\nimport \"./PackedUFixed18.sol\";\n\n/// @dev UFixed18 type\ntype UFixed18 is uint256;\nusing UFixed18Lib for UFixed18 global;\ntype UFixed18Storage is bytes32;\nusing UFixed18StorageLib for UFixed18Storage global;\n\n/**\n * @title UFixed18Lib\n * @notice Library for the unsigned fixed-decimal type.\n */\nlibrary UFixed18Lib {\n error UFixed18UnderflowError(int256 value);\n error UFixed18PackingOverflowError(uint256 value);\n\n uint256 private constant BASE = 1e18;\n UFixed18 public constant ZERO = UFixed18.wrap(0);\n UFixed18 public constant ONE = UFixed18.wrap(BASE);\n UFixed18 public constant MAX = UFixed18.wrap(type(uint256).max);\n\n /**\n * @notice Creates a unsigned fixed-decimal from a signed fixed-decimal\n * @param a Signed fixed-decimal\n * @return New unsigned fixed-decimal\n */\n function from(Fixed18 a) internal pure returns (UFixed18) {\n int256 value = Fixed18.unwrap(a);\n if (value < 0) revert UFixed18UnderflowError(value);\n return UFixed18.wrap(uint256(value));\n }\n\n /**\n * @notice Creates a unsigned fixed-decimal from a unsigned integer\n * @param a Unsigned number\n * @return New unsigned fixed-decimal\n */\n function from(uint256 a) internal pure returns (UFixed18) {\n return UFixed18.wrap(a * BASE);\n }\n\n /**\n * @notice Creates a packed unsigned fixed-decimal from an unsigned fixed-decimal\n * @param a unsigned fixed-decimal\n * @return New packed unsigned fixed-decimal\n */\n function pack(UFixed18 a) internal pure returns (PackedUFixed18) {\n uint256 value = UFixed18.unwrap(a);\n if (value > type(uint128).max) revert UFixed18PackingOverflowError(value);\n return PackedUFixed18.wrap(uint128(value));\n }\n\n /**\n * @notice Returns whether the unsigned fixed-decimal is equal to zero.\n * @param a Unsigned fixed-decimal\n * @return Whether the unsigned fixed-decimal is zero.\n */\n function isZero(UFixed18 a) internal pure returns (bool) {\n return UFixed18.unwrap(a) == 0;\n }\n\n /**\n * @notice Adds two unsigned fixed-decimals `a` and `b` together\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Resulting summed unsigned fixed-decimal\n */\n function add(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) + UFixed18.unwrap(b));\n }\n\n /**\n * @notice Subtracts unsigned fixed-decimal `b` from `a`\n * @param a Unsigned fixed-decimal to subtract from\n * @param b Unsigned fixed-decimal to subtract\n * @return Resulting subtracted unsigned fixed-decimal\n */\n function sub(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) - UFixed18.unwrap(b));\n }\n\n /**\n * @notice Multiplies two unsigned fixed-decimals `a` and `b` together\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Resulting multiplied unsigned fixed-decimal\n */\n function mul(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / BASE);\n }\n\n /**\n * @notice Divides unsigned fixed-decimal `a` by `b`\n * @param a Unsigned fixed-decimal to divide\n * @param b Unsigned fixed-decimal to divide by\n * @return Resulting divided unsigned fixed-decimal\n */\n function div(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) * BASE / UFixed18.unwrap(b));\n }\n\n /**\n * @notice Divides unsigned fixed-decimal `a` by `b`\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0` and `MAX` for `n/0`.\n * @param a Unsigned fixed-decimal to divide\n * @param b Unsigned fixed-decimal to divide by\n * @return Resulting divided unsigned fixed-decimal\n */\n function unsafeDiv(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n if (isZero(b)) {\n return isZero(a) ? ONE : MAX;\n } else {\n return div(a, b);\n }\n }\n\n /**\n * @notice Computes a * b / c without loss of precision due to BASE conversion\n * @param a First unsigned fixed-decimal\n * @param b Unsigned number to multiply by\n * @param c Unsigned number to divide by\n * @return Resulting computation\n */\n function muldiv(UFixed18 a, uint256 b, uint256 c) internal pure returns (UFixed18) {\n return muldiv(a, UFixed18.wrap(b), UFixed18.wrap(c));\n }\n\n /**\n * @notice Computes a * b / c without loss of precision due to BASE conversion\n * @param a First unsigned fixed-decimal\n * @param b Unsigned fixed-decimal to multiply by\n * @param c Unsigned fixed-decimal to divide by\n * @return Resulting computation\n */\n function muldiv(UFixed18 a, UFixed18 b, UFixed18 c) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / UFixed18.unwrap(c));\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is equal to `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is equal to `b`\n */\n function eq(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return compare(a, b) == 1;\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is greater than `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is greater than `b`\n */\n function gt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return compare(a, b) == 2;\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is less than `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is less than `b`\n */\n function lt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return compare(a, b) == 0;\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is greater than or equal to `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is greater than or equal to `b`\n */\n function gte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return gt(a, b) || eq(a, b);\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is less than or equal to `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is less than or equal to `b`\n */\n function lte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return lt(a, b) || eq(a, b);\n }\n\n /**\n * @notice Compares the unsigned fixed-decimals `a` and `b`\n * @dev Returns: 2 for greater than\n * 1 for equal to\n * 0 for less than\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Compare result of `a` and `b`\n */\n function compare(UFixed18 a, UFixed18 b) internal pure returns (uint256) {\n (uint256 au, uint256 bu) = (UFixed18.unwrap(a), UFixed18.unwrap(b));\n if (au > bu) return 2;\n if (au < bu) return 0;\n return 1;\n }\n\n /**\n * @notice Returns a unsigned fixed-decimal representing the ratio of `a` over `b`\n * @param a First unsigned number\n * @param b Second unsigned number\n * @return Ratio of `a` over `b`\n */\n function ratio(uint256 a, uint256 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(a * BASE / b);\n }\n\n /**\n * @notice Returns the minimum of unsigned fixed-decimals `a` and `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Minimum of `a` and `b`\n */\n function min(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(Math.min(UFixed18.unwrap(a), UFixed18.unwrap(b)));\n }\n\n /**\n * @notice Returns the maximum of unsigned fixed-decimals `a` and `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Maximum of `a` and `b`\n */\n function max(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(Math.max(UFixed18.unwrap(a), UFixed18.unwrap(b)));\n }\n\n /**\n * @notice Converts the unsigned fixed-decimal into an integer, truncating any decimal portion\n * @param a Unsigned fixed-decimal\n * @return Truncated unsigned number\n */\n function truncate(UFixed18 a) internal pure returns (uint256) {\n return UFixed18.unwrap(a) / BASE;\n }\n}\n\nlibrary UFixed18StorageLib {\n function read(UFixed18Storage self) internal view returns (UFixed18 value) {\n assembly {\n value := sload(self)\n }\n }\n\n function store(UFixed18Storage self, UFixed18 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return 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 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 up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a / b + (a % b == 0 ? 0 : 1);\n }\n}\n" - }, - "@equilibria/root/number/types/Fixed18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/SignedMath.sol\";\nimport \"./UFixed18.sol\";\nimport \"./PackedFixed18.sol\";\n\n/// @dev Fixed18 type\ntype Fixed18 is int256;\nusing Fixed18Lib for Fixed18 global;\ntype Fixed18Storage is bytes32;\nusing Fixed18StorageLib for Fixed18Storage global;\n\n/**\n * @title Fixed18Lib\n * @notice Library for the signed fixed-decimal type.\n */\nlibrary Fixed18Lib {\n error Fixed18OverflowError(uint256 value);\n error Fixed18PackingOverflowError(int256 value);\n error Fixed18PackingUnderflowError(int256 value);\n\n int256 private constant BASE = 1e18;\n Fixed18 public constant ZERO = Fixed18.wrap(0);\n Fixed18 public constant ONE = Fixed18.wrap(BASE);\n Fixed18 public constant NEG_ONE = Fixed18.wrap(-1 * BASE);\n Fixed18 public constant MAX = Fixed18.wrap(type(int256).max);\n Fixed18 public constant MIN = Fixed18.wrap(type(int256).min);\n\n /**\n * @notice Creates a signed fixed-decimal from an unsigned fixed-decimal\n * @param a Unsigned fixed-decimal\n * @return New signed fixed-decimal\n */\n function from(UFixed18 a) internal pure returns (Fixed18) {\n uint256 value = UFixed18.unwrap(a);\n if (value > uint256(type(int256).max)) revert Fixed18OverflowError(value);\n return Fixed18.wrap(int256(value));\n }\n\n /**\n * @notice Creates a signed fixed-decimal from a sign and an unsigned fixed-decimal\n * @param s Sign\n * @param m Unsigned fixed-decimal magnitude\n * @return New signed fixed-decimal\n */\n function from(int256 s, UFixed18 m) internal pure returns (Fixed18) {\n if (s > 0) return from(m);\n if (s < 0) return Fixed18.wrap(-1 * Fixed18.unwrap(from(m)));\n return ZERO;\n }\n\n /**\n * @notice Creates a signed fixed-decimal from a signed integer\n * @param a Signed number\n * @return New signed fixed-decimal\n */\n function from(int256 a) internal pure returns (Fixed18) {\n return Fixed18.wrap(a * BASE);\n }\n\n /**\n * @notice Creates a packed signed fixed-decimal from an signed fixed-decimal\n * @param a signed fixed-decimal\n * @return New packed signed fixed-decimal\n */\n function pack(Fixed18 a) internal pure returns (PackedFixed18) {\n int256 value = Fixed18.unwrap(a);\n if (value > type(int128).max) revert Fixed18PackingOverflowError(value);\n if (value < type(int128).min) revert Fixed18PackingUnderflowError(value);\n return PackedFixed18.wrap(int128(value));\n }\n\n /**\n * @notice Returns whether the signed fixed-decimal is equal to zero.\n * @param a Signed fixed-decimal\n * @return Whether the signed fixed-decimal is zero.\n */\n function isZero(Fixed18 a) internal pure returns (bool) {\n return Fixed18.unwrap(a) == 0;\n }\n\n /**\n * @notice Adds two signed fixed-decimals `a` and `b` together\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Resulting summed signed fixed-decimal\n */\n function add(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) + Fixed18.unwrap(b));\n }\n\n /**\n * @notice Subtracts signed fixed-decimal `b` from `a`\n * @param a Signed fixed-decimal to subtract from\n * @param b Signed fixed-decimal to subtract\n * @return Resulting subtracted signed fixed-decimal\n */\n function sub(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) - Fixed18.unwrap(b));\n }\n\n /**\n * @notice Multiplies two signed fixed-decimals `a` and `b` together\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Resulting multiplied signed fixed-decimal\n */\n function mul(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / BASE);\n }\n\n /**\n * @notice Divides signed fixed-decimal `a` by `b`\n * @param a Signed fixed-decimal to divide\n * @param b Signed fixed-decimal to divide by\n * @return Resulting divided signed fixed-decimal\n */\n function div(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) * BASE / Fixed18.unwrap(b));\n }\n\n /**\n * @notice Divides unsigned fixed-decimal `a` by `b`\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0`, `MAX` for `n/0`, and `MIN` for `-n/0`.\n * @param a Unsigned fixed-decimal to divide\n * @param b Unsigned fixed-decimal to divide by\n * @return Resulting divided unsigned fixed-decimal\n */\n function unsafeDiv(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n if (isZero(b)) {\n if (gt(a, ZERO)) return MAX;\n if (lt(a, ZERO)) return MIN;\n return ONE;\n } else {\n return div(a, b);\n }\n }\n\n /**\n * @notice Computes a * b / c without loss of precision due to BASE conversion\n * @param a First signed fixed-decimal\n * @param b Signed number to multiply by\n * @param c Signed number to divide by\n * @return Resulting computation\n */\n function muldiv(Fixed18 a, int256 b, int256 c) internal pure returns (Fixed18) {\n return muldiv(a, Fixed18.wrap(b), Fixed18.wrap(c));\n }\n\n /**\n * @notice Computes a * b / c without loss of precision due to BASE conversion\n * @param a First signed fixed-decimal\n * @param b Signed fixed-decimal to multiply by\n * @param c Signed fixed-decimal to divide by\n * @return Resulting computation\n */\n function muldiv(Fixed18 a, Fixed18 b, Fixed18 c) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / Fixed18.unwrap(c));\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is equal to `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is equal to `b`\n */\n function eq(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return compare(a, b) == 1;\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is greater than `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is greater than `b`\n */\n function gt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return compare(a, b) == 2;\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is less than `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is less than `b`\n */\n function lt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return compare(a, b) == 0;\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is greater than or equal to `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is greater than or equal to `b`\n */\n function gte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return gt(a, b) || eq(a, b);\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is less than or equal to `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is less than or equal to `b`\n */\n function lte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return lt(a, b) || eq(a, b);\n }\n\n /**\n * @notice Compares the signed fixed-decimals `a` and `b`\n * @dev Returns: 2 for greater than\n * 1 for equal to\n * 0 for less than\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Compare result of `a` and `b`\n */\n function compare(Fixed18 a, Fixed18 b) internal pure returns (uint256) {\n (int256 au, int256 bu) = (Fixed18.unwrap(a), Fixed18.unwrap(b));\n if (au > bu) return 2;\n if (au < bu) return 0;\n return 1;\n }\n\n /**\n * @notice Returns a signed fixed-decimal representing the ratio of `a` over `b`\n * @param a First signed number\n * @param b Second signed number\n * @return Ratio of `a` over `b`\n */\n function ratio(int256 a, int256 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(a * BASE / b);\n }\n\n /**\n * @notice Returns the minimum of signed fixed-decimals `a` and `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Minimum of `a` and `b`\n */\n function min(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(SignedMath.min(Fixed18.unwrap(a), Fixed18.unwrap(b)));\n }\n\n /**\n * @notice Returns the maximum of signed fixed-decimals `a` and `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Maximum of `a` and `b`\n */\n function max(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(SignedMath.max(Fixed18.unwrap(a), Fixed18.unwrap(b)));\n }\n\n /**\n * @notice Converts the signed fixed-decimal into an integer, truncating any decimal portion\n * @param a Signed fixed-decimal\n * @return Truncated signed number\n */\n function truncate(Fixed18 a) internal pure returns (int256) {\n return Fixed18.unwrap(a) / BASE;\n }\n\n /**\n * @notice Returns the sign of the signed fixed-decimal\n * @dev Returns: -1 for negative\n * 0 for zero\n * 1 for positive\n * @param a Signed fixed-decimal\n * @return Sign of the signed fixed-decimal\n */\n function sign(Fixed18 a) internal pure returns (int256) {\n if (Fixed18.unwrap(a) > 0) return 1;\n if (Fixed18.unwrap(a) < 0) return -1;\n return 0;\n }\n\n /**\n * @notice Returns the absolute value of the signed fixed-decimal\n * @param a Signed fixed-decimal\n * @return Absolute value of the signed fixed-decimal\n */\n function abs(Fixed18 a) internal pure returns (UFixed18) {\n return UFixed18.wrap(SignedMath.abs(Fixed18.unwrap(a)));\n }\n}\n\nlibrary Fixed18StorageLib {\n function read(Fixed18Storage self) internal view returns (Fixed18 value) {\n assembly {\n value := sload(self)\n }\n }\n\n function store(Fixed18Storage self, Fixed18 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "@equilibria/root/number/types/PackedUFixed18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"./UFixed18.sol\";\n\n/// @dev PackedUFixed18 type\ntype PackedUFixed18 is uint128;\nusing PackedUFixed18Lib for PackedUFixed18 global;\n\n/**\n * @title PackedUFixed18Lib\n * @dev A packed version of the UFixed18 which takes up half the storage space (two PackedUFixed18 can be packed\n * into a single slot). Only valid within the range 0 <= x <= 3.4028237e+20.\n * @notice Library for the packed unsigned fixed-decimal type.\n */\nlibrary PackedUFixed18Lib {\n PackedUFixed18 public constant MAX = PackedUFixed18.wrap(type(uint128).max);\n\n /**\n * @notice Creates an unpacked unsigned fixed-decimal from a packed unsigned fixed-decimal\n * @param self packed unsigned fixed-decimal\n * @return New unpacked unsigned fixed-decimal\n */\n function unpack(PackedUFixed18 self) internal pure returns (UFixed18) {\n return UFixed18.wrap(uint256(PackedUFixed18.unwrap(self)));\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/SignedMath.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n /**\n * @dev Returns the largest of two signed numbers.\n */\n function max(int256 a, int256 b) internal pure returns (int256) {\n return 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 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 // must be unchecked in order to support `n = type(int256).min`\n return uint256(n >= 0 ? n : -n);\n }\n }\n}\n" - }, - "@equilibria/root/number/types/PackedFixed18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"./Fixed18.sol\";\n\n/// @dev PackedFixed18 type\ntype PackedFixed18 is int128;\nusing PackedFixed18Lib for PackedFixed18 global;\n\n/**\n * @title PackedFixed18Lib\n * @dev A packed version of the Fixed18 which takes up half the storage space (two PackedFixed18 can be packed\n * into a single slot). Only valid within the range -1.7014118e+20 <= x <= 1.7014118e+20.\n * @notice Library for the packed signed fixed-decimal type.\n */\nlibrary PackedFixed18Lib {\n PackedFixed18 public constant MAX = PackedFixed18.wrap(type(int128).max);\n PackedFixed18 public constant MIN = PackedFixed18.wrap(type(int128).min);\n\n /**\n * @notice Creates an unpacked signed fixed-decimal from a packed signed fixed-decimal\n * @param self packed signed fixed-decimal\n * @return New unpacked signed fixed-decimal\n */\n function unpack(PackedFixed18 self) internal pure returns (Fixed18) {\n return Fixed18.wrap(int256(PackedFixed18.unwrap(self)));\n }\n}\n" - }, - "@equilibria/root/token/types/Token18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"../../number/types/UFixed18.sol\";\n\n/// @dev Token18\ntype Token18 is address;\nusing Token18Lib for Token18 global;\ntype Token18Storage is bytes32;\nusing Token18StorageLib for Token18Storage global;\n\n/**\n * @title Token18Lib\n * @notice Library to manage 18-decimal ERC20s that is compliant with the fixed-decimal types.\n * @dev Maintains significant gas savings over other Token implementations since no conversion take place\n */\nlibrary Token18Lib {\n using SafeERC20 for IERC20;\n\n Token18 public constant ZERO = Token18.wrap(address(0));\n\n /**\n * @notice Returns whether a token is the zero address\n * @param self Token to check for\n * @return Whether the token is the zero address\n */\n function isZero(Token18 self) internal pure returns (bool) {\n return Token18.unwrap(self) == Token18.unwrap(ZERO);\n }\n\n /**\n * @notice Returns whether the two tokens are equal\n * @param a First token to compare\n * @param b Second token to compare\n * @return Whether the two tokens are equal\n */\n function eq(Token18 a, Token18 b) internal pure returns (bool) {\n return Token18.unwrap(a) == Token18.unwrap(b);\n }\n\n /**\n * @notice Approves `grantee` to spend infinite tokens from the caller\n * @param self Token to transfer\n * @param grantee Address to allow spending\n */\n function approve(Token18 self, address grantee) internal {\n IERC20(Token18.unwrap(self)).safeApprove(grantee, type(uint256).max);\n }\n\n /**\n * @notice Approves `grantee` to spend `amount` tokens from the caller\n * @dev There are important race conditions to be aware of when using this function\n with values other than 0. This will revert if moving from non-zero to non-zero amounts\n See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/a55b7d13722e7ce850b626da2313f3e66ca1d101/contracts/token/ERC20/IERC20.sol#L57\n * @param self Token to transfer\n * @param grantee Address to allow spending\n * @param amount Amount of tokens to approve to spend\n */\n function approve(Token18 self, address grantee, UFixed18 amount) internal {\n IERC20(Token18.unwrap(self)).safeApprove(grantee, UFixed18.unwrap(amount));\n }\n\n /**\n * @notice Transfers all held tokens from the caller to the `recipient`\n * @param self Token to transfer\n * @param recipient Address to receive the tokens\n */\n function push(Token18 self, address recipient) internal {\n push(self, recipient, balanceOf(self, address(this)));\n }\n\n /**\n * @notice Transfers `amount` tokens from the caller to the `recipient`\n * @param self Token to transfer\n * @param recipient Address to transfer tokens to\n * @param amount Amount of tokens to transfer\n */\n function push(Token18 self, address recipient, UFixed18 amount) internal {\n IERC20(Token18.unwrap(self)).safeTransfer(recipient, UFixed18.unwrap(amount));\n }\n\n /**\n * @notice Transfers `amount` tokens from the `benefactor` to the caller\n * @dev Reverts if trying to pull Ether\n * @param self Token to transfer\n * @param benefactor Address to transfer tokens from\n * @param amount Amount of tokens to transfer\n */\n function pull(Token18 self, address benefactor, UFixed18 amount) internal {\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, address(this), UFixed18.unwrap(amount));\n }\n\n /**\n * @notice Transfers `amount` tokens from the `benefactor` to `recipient`\n * @dev Reverts if trying to pull Ether\n * @param self Token to transfer\n * @param benefactor Address to transfer tokens from\n * @param recipient Address to transfer tokens to\n * @param amount Amount of tokens to transfer\n */\n function pullTo(Token18 self, address benefactor, address recipient, UFixed18 amount) internal {\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, recipient, UFixed18.unwrap(amount));\n }\n\n /**\n * @notice Returns the name of the token\n * @param self Token to check for\n * @return Token name\n */\n function name(Token18 self) internal view returns (string memory) {\n return IERC20Metadata(Token18.unwrap(self)).name();\n }\n\n /**\n * @notice Returns the symbol of the token\n * @param self Token to check for\n * @return Token symbol\n */\n function symbol(Token18 self) internal view returns (string memory) {\n return IERC20Metadata(Token18.unwrap(self)).symbol();\n }\n\n /**\n * @notice Returns the `self` token balance of the caller\n * @param self Token to check for\n * @return Token balance of the caller\n */\n function balanceOf(Token18 self) internal view returns (UFixed18) {\n return balanceOf(self, address(this));\n }\n\n /**\n * @notice Returns the `self` token balance of `account`\n * @param self Token to check for\n * @param account Account to check\n * @return Token balance of the account\n */\n function balanceOf(Token18 self, address account) internal view returns (UFixed18) {\n return UFixed18.wrap(IERC20(Token18.unwrap(self)).balanceOf(account));\n }\n}\n\nlibrary Token18StorageLib {\n function read(Token18Storage self) internal view returns (Token18 value) {\n assembly {\n value := sload(self)\n }\n }\n\n function store(Token18Storage self, Token18 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "contracts/interfaces/IController.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\";\nimport \"./ICollateral.sol\";\nimport \"./IIncentivizer.sol\";\nimport \"./IProduct.sol\";\nimport \"./types/PayoffDefinition.sol\";\n\ninterface IController {\n /// @dev Coordinator of a one or many products\n struct Coordinator {\n /// @dev Pending owner of the product, can accept ownership\n address pendingOwner;\n\n /// @dev Owner of the product, allowed to update select parameters\n address owner;\n\n /// @dev Treasury of the product, collects fees\n address treasury;\n }\n\n event CollateralUpdated(ICollateral newCollateral);\n event IncentivizerUpdated(IIncentivizer newIncentivizer);\n event ProductBeaconUpdated(IBeacon newProductBeacon);\n event ProtocolFeeUpdated(UFixed18 newProtocolFee);\n event MinFundingFeeUpdated(UFixed18 newMinFundingFee);\n event LiquidationFeeUpdated(UFixed18 newLiquidationFee);\n event IncentivizationFeeUpdated(UFixed18 newIncentivizationFee);\n event MinCollateralUpdated(UFixed18 newMinCollateral);\n event ProgramsPerProductUpdated(uint256 newProgramsPerProduct);\n event PauserUpdated(address newPauser);\n event PausedUpdated(bool newPaused);\n event CoordinatorPendingOwnerUpdated(uint256 indexed coordinatorId, address newPendingOwner);\n event CoordinatorOwnerUpdated(uint256 indexed coordinatorId, address newOwner);\n event CoordinatorTreasuryUpdated(uint256 indexed coordinatorId, address newTreasury);\n event CoordinatorCreated(uint256 indexed coordinatorId, address owner);\n event ProductCreated(IProduct indexed product, IProduct.ProductInfo productInfo);\n\n error ControllerNoZeroCoordinatorError();\n error ControllerNotPauserError();\n error ControllerNotOwnerError(uint256 controllerId);\n error ControllerNotPendingOwnerError(uint256 controllerId);\n error ControllerInvalidProtocolFeeError();\n error ControllerInvalidMinFundingFeeError();\n error ControllerInvalidLiquidationFeeError();\n error ControllerInvalidIncentivizationFeeError();\n error ControllerNotContractAddressError();\n\n function collateral() external view returns (ICollateral);\n function incentivizer() external view returns (IIncentivizer);\n function productBeacon() external view returns (IBeacon);\n function coordinators(uint256 collateralId) external view returns (Coordinator memory);\n function coordinatorFor(IProduct product) external view returns (uint256);\n function protocolFee() external view returns (UFixed18);\n function minFundingFee() external view returns (UFixed18);\n function liquidationFee() external view returns (UFixed18);\n function incentivizationFee() external view returns (UFixed18);\n function minCollateral() external view returns (UFixed18);\n function programsPerProduct() external view returns (uint256);\n function pauser() external view returns (address);\n function paused() external view returns (bool);\n function initialize(ICollateral collateral_, IIncentivizer incentivizer_, IBeacon productBeacon_) external;\n function createCoordinator() external returns (uint256);\n function updateCoordinatorPendingOwner(uint256 coordinatorId, address newPendingOwner) external;\n function acceptCoordinatorOwner(uint256 coordinatorId) external;\n function updateCoordinatorTreasury(uint256 coordinatorId, address newTreasury) external;\n function createProduct(uint256 coordinatorId, IProduct.ProductInfo calldata productInfo) external returns (IProduct);\n function updateCollateral(ICollateral newCollateral) external;\n function updateIncentivizer(IIncentivizer newIncentivizer) external;\n function updateProductBeacon(IBeacon newProductBeacon) external;\n function updateProtocolFee(UFixed18 newProtocolFee) external;\n function updateMinFundingFee(UFixed18 newMinFundingFee) external;\n function updateLiquidationFee(UFixed18 newLiquidationFee) external;\n function updateIncentivizationFee(UFixed18 newIncentivizationFee) external;\n function updateMinCollateral(UFixed18 newMinCollateral) external;\n function updateProgramsPerProduct(uint256 newProductsPerProduct) external;\n function updatePauser(address newPauser) external;\n function updatePaused(bool newPaused) external;\n function isProduct(IProduct product) external view returns (bool);\n function owner() external view returns (address);\n function owner(uint256 coordinatorId) external view returns (address);\n function owner(IProduct product) external view returns (address);\n function treasury() external view returns (address);\n function treasury(uint256 coordinatorId) external view returns (address);\n function treasury(IProduct product) external view returns (address);\n}\n" - }, - "contracts/interfaces/IProduct.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\";\nimport \"./IPayoffProvider.sol\";\nimport \"./IParamProvider.sol\";\nimport \"./types/PayoffDefinition.sol\";\nimport \"./types/Position.sol\";\nimport \"./types/PrePosition.sol\";\nimport \"./types/Accumulator.sol\";\n\ninterface IProduct is IPayoffProvider, IParamProvider {\n /// @dev Product Creation parameters\n struct ProductInfo {\n /// @dev name of the product\n string name;\n\n /// @dev symbol of the product\n string symbol;\n\n /// @dev product payoff definition\n PayoffDefinition payoffDefinition;\n\n /// @dev oracle address\n IOracleProvider oracle;\n\n /// @dev product maintenance ratio\n UFixed18 maintenance;\n\n /// @dev product funding fee\n UFixed18 fundingFee;\n\n /// @dev product maker fee\n UFixed18 makerFee;\n\n /// @dev product taker fee\n UFixed18 takerFee;\n\n /// @dev product maker limit\n UFixed18 makerLimit;\n\n /// @dev utulization curve definition\n JumpRateUtilizationCurve utilizationCurve;\n }\n\n event Settle(uint256 preVersion, uint256 toVersion);\n event AccountSettle(address indexed account, uint256 preVersion, uint256 toVersion);\n event MakeOpened(address indexed account, uint256 version, UFixed18 amount);\n event TakeOpened(address indexed account, uint256 version, UFixed18 amount);\n event MakeClosed(address indexed account, uint256 version, UFixed18 amount);\n event TakeClosed(address indexed account, uint256 version, UFixed18 amount);\n event ClosedUpdated(bool indexed newClosed, uint256 version);\n\n error ProductInsufficientLiquidityError(UFixed18 socializationFactor);\n error ProductDoubleSidedError();\n error ProductOverClosedError();\n error ProductInsufficientCollateralError();\n error ProductInLiquidationError();\n error ProductMakerOverLimitError();\n error ProductOracleBootstrappingError();\n error ProductNotOwnerError();\n error ProductInvalidOracle();\n error ProductClosedError();\n\n function name() external view returns (string memory);\n function symbol() external view returns (string memory);\n function initialize(ProductInfo calldata productInfo_) external;\n function settle() external;\n function settleAccount(address account) external;\n function openTake(UFixed18 amount) external;\n function closeTake(UFixed18 amount) external;\n function openMake(UFixed18 amount) external;\n function closeMake(UFixed18 amount) external;\n function closeAll(address account) external;\n function maintenance(address account) external view returns (UFixed18);\n function maintenanceNext(address account) external view returns (UFixed18);\n function isClosed(address account) external view returns (bool);\n function isLiquidating(address account) external view returns (bool);\n function position(address account) external view returns (Position memory);\n function pre(address account) external view returns (PrePosition memory);\n function latestVersion() external view returns (uint256);\n function positionAtVersion(uint256 oracleVersion) external view returns (Position memory);\n function pre() external view returns (PrePosition memory);\n function valueAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\n function shareAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\n function latestVersion(address account) external view returns (uint256);\n function rate(Position memory position) external view returns (Fixed18);\n function closed() external view returns (bool);\n function updateClosed(bool newClosed) external;\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/IERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\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 amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` 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(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\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" - }, - "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 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 using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\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 function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" - }, - "@openzeppelin/contracts/proxy/beacon/IBeacon.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n" - }, - "contracts/interfaces/IIncentivizer.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"./types/ProgramInfo.sol\";\nimport \"./IController.sol\";\nimport \"./IProduct.sol\";\n\ninterface IIncentivizer {\n event ProgramCreated(IProduct indexed product, uint256 indexed programId, ProgramInfo programInfo, UFixed18 programFeeAmount);\n event ProgramStarted(IProduct indexed product, uint256 indexed programId, uint256 version);\n event ProgramComplete(IProduct indexed product, uint256 indexed programId, uint256 version);\n event Claim(IProduct indexed product, address indexed account, uint256 indexed programId, UFixed18 amount);\n event FeeClaim(Token18 indexed token, UFixed18 amount);\n\n error IncentivizerNotAllowedError(IProduct product);\n error IncentivizerTooManyProgramsError();\n error IncentivizerNotProgramOwnerError(IProduct product, uint256 programId);\n error IncentivizerInvalidProgramError(IProduct product, uint256 programId);\n error IncentivizerBatchClaimArgumentMismatchError();\n\n function programInfos(IProduct product, uint256 programId) external view returns (ProgramInfo memory);\n function fees(Token18 token) external view returns (UFixed18);\n function initialize(IController controller_) external;\n function create(IProduct product, ProgramInfo calldata info) external returns (uint256);\n function complete(IProduct product, uint256 programId) external;\n function sync(IOracleProvider.OracleVersion memory currentOracleVersion) external;\n function syncAccount(address account, IOracleProvider.OracleVersion memory currentOracleVersion) external;\n function claim(IProduct product, uint256[] calldata programIds) external;\n function claim(IProduct[] calldata products, uint256[][] calldata programIds) external;\n function claimFee(Token18[] calldata tokens) external;\n function active(IProduct product) external view returns (uint256);\n function count(IProduct product) external view returns (uint256);\n function unclaimed(IProduct product, address account, uint256 programId) external view returns (UFixed18);\n function available(IProduct product, uint256 programId) external view returns (UFixed18);\n function versionStarted(IProduct product, uint256 programId) external view returns (uint256);\n function versionComplete(IProduct product, uint256 programId) external view returns (uint256);\n function owner(IProduct product, uint256 programId) external view returns (address);\n function treasury(IProduct product, uint256 programId) external view returns (address);\n}\n" - }, - "contracts/interfaces/types/PayoffDefinition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"../../interfaces/IContractPayoffProvider.sol\";\n\n/// @dev PayoffDefinition tyoe\nstruct PayoffDefinition {\n PayoffDefinitionLib.PayoffType payoffType;\n PayoffDefinitionLib.PayoffDirection payoffDirection;\n bytes30 data;\n}\nusing PayoffDefinitionLib for PayoffDefinition global;\ntype PayoffDefinitionStorage is bytes32;\nusing PayoffDefinitionStorageLib for PayoffDefinitionStorage global;\n\n/**\n * @title PayoffDefinitionLib\n * @dev Library that surfaces logic for PayoffDefinition type functionality\n * @notice Library for the PayoffDefinition type. Performs validity and price transformation\n based on the payoff definition type.\n */\nlibrary PayoffDefinitionLib {\n using Address for address;\n\n error PayoffDefinitionUnsupportedTransform(PayoffType payoffType, PayoffDirection payoffDirection);\n error PayoffDefinitionNotContract(PayoffType payoffType, bytes30 data);\n\n /// @dev Payoff function type enum\n enum PayoffType { PASSTHROUGH, CONTRACT }\n enum PayoffDirection { LONG, SHORT }\n\n /**\n * @notice Checks validity of the payoff definition\n * @param self a payoff definition\n * @return Whether the payoff definition is valid for it's given type\n */\n function valid(PayoffDefinition memory self) internal view returns (bool) {\n if (self.payoffType == PayoffType.CONTRACT) return address(_providerContract(self)).isContract();\n\n // All other payoff types should have no data\n return uint(bytes32(self.data)) == 0;\n }\n\n /**\n * @notice Transforms a price based on the payoff definition\n * @param self a payoff definition\n * @param price raw oracle price\n * @return Price transformed by the payoff definition function\n */\n function transform(\n PayoffDefinition memory self,\n Fixed18 price\n ) internal view returns (Fixed18) {\n PayoffType payoffType = self.payoffType;\n PayoffDirection payoffDirection = self.payoffDirection;\n Fixed18 transformedPrice;\n\n // First get the price depending on the type\n if (payoffType == PayoffType.PASSTHROUGH) transformedPrice = price;\n else if (payoffType == PayoffType.CONTRACT) transformedPrice = _payoffFromContract(self, price);\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\n\n // Then transform it depending on the direction flag\n if (self.payoffDirection == PayoffDirection.LONG) return transformedPrice;\n else if (self.payoffDirection == PayoffDirection.SHORT) return transformedPrice.mul(Fixed18Lib.NEG_ONE);\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\n }\n\n /**\n * @notice Parses the data field into an address\n * @dev Reverts if payoffType is not CONTRACT\n * @param self a payoff definition\n * @return IContractPayoffProvider address\n */\n function _providerContract(\n PayoffDefinition memory self\n ) private pure returns (IContractPayoffProvider) {\n if (self.payoffType != PayoffType.CONTRACT) revert PayoffDefinitionNotContract(self.payoffType, self.data);\n // Shift to pull the last 20 bytes, then cast to an address\n return IContractPayoffProvider(address(bytes20(self.data << 80)));\n }\n\n /**\n * @notice Performs a price transformation by calling the underlying payoff contract\n * @param self a payoff definition\n * @param price raw oracle price\n * @return Price transformed by the payoff definition function on the contract\n */\n function _payoffFromContract(\n PayoffDefinition memory self,\n Fixed18 price\n ) private view returns (Fixed18) {\n bytes memory ret = address(_providerContract(self)).functionStaticCall(\n abi.encodeCall(IContractPayoffProvider.payoff, price)\n );\n return Fixed18.wrap(abi.decode(ret, (int256)));\n }\n}\n\n/**\n * @title PayoffDefinitionStorageLib\n * @notice Library that surfaces storage read and writes for the PayoffDefinition type\n */\nlibrary PayoffDefinitionStorageLib {\n function read(PayoffDefinitionStorage self) internal view returns (PayoffDefinition memory) {\n return _storagePointer(self);\n }\n\n function store(PayoffDefinitionStorage self, PayoffDefinition memory value) internal {\n PayoffDefinition storage storagePointer = _storagePointer(self);\n\n storagePointer.payoffType = value.payoffType;\n storagePointer.payoffDirection = value.payoffDirection;\n storagePointer.data = value.data;\n }\n\n function _storagePointer(\n PayoffDefinitionStorage self\n ) private pure returns (PayoffDefinition storage pointer) {\n assembly { pointer.slot := self }\n }\n}\n" - }, - "@equilibria/root/curve/types/JumpRateUtilizationCurve.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"../CurveMath.sol\";\nimport \"../../number/types/PackedUFixed18.sol\";\nimport \"../../number/types/PackedFixed18.sol\";\n\n/// @dev JumpRateUtilizationCurve type\nstruct JumpRateUtilizationCurve {\n PackedFixed18 minRate;\n PackedFixed18 maxRate;\n PackedFixed18 targetRate;\n PackedUFixed18 targetUtilization;\n}\nusing JumpRateUtilizationCurveLib for JumpRateUtilizationCurve global;\ntype JumpRateUtilizationCurveStorage is bytes32;\nusing JumpRateUtilizationCurveStorageLib for JumpRateUtilizationCurveStorage global;\n\n/**\n * @title JumpRateUtilizationCurveLib\n * @notice Library for the Jump Rate utilization curve type\n */\nlibrary JumpRateUtilizationCurveLib {\n /**\n * @notice Computes the corresponding rate for a utilization ratio\n * @param utilization The utilization ratio\n * @return The corresponding rate\n */\n function compute(JumpRateUtilizationCurve memory self, UFixed18 utilization) internal pure returns (Fixed18) {\n UFixed18 targetUtilization = self.targetUtilization.unpack();\n if (utilization.lt(targetUtilization)) {\n return CurveMath.linearInterpolation(\n UFixed18Lib.ZERO,\n self.minRate.unpack(),\n targetUtilization,\n self.targetRate.unpack(),\n utilization\n );\n }\n if (utilization.lt(UFixed18Lib.ONE)) {\n return CurveMath.linearInterpolation(\n targetUtilization,\n self.targetRate.unpack(),\n UFixed18Lib.ONE,\n self.maxRate.unpack(),\n utilization\n );\n }\n return self.maxRate.unpack();\n }\n}\n\nlibrary JumpRateUtilizationCurveStorageLib {\n function read(JumpRateUtilizationCurveStorage self) internal view returns (JumpRateUtilizationCurve memory) {\n return _storagePointer(self);\n }\n\n function store(JumpRateUtilizationCurveStorage self, JumpRateUtilizationCurve memory value) internal {\n JumpRateUtilizationCurve storage storagePointer = _storagePointer(self);\n\n storagePointer.minRate = value.minRate;\n storagePointer.maxRate = value.maxRate;\n storagePointer.targetRate = value.targetRate;\n storagePointer.targetUtilization = value.targetUtilization;\n }\n\n function _storagePointer(JumpRateUtilizationCurveStorage self)\n private pure returns (JumpRateUtilizationCurve storage pointer) {\n assembly { pointer.slot := self }\n }\n}" - }, - "contracts/interfaces/IPayoffProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/Fixed18.sol\";\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"./types/PayoffDefinition.sol\";\n\ninterface IPayoffProvider {\n error PayoffProviderInvalidOracle();\n error PayoffProviderInvalidPayoffDefinitionError();\n\n function oracle() external view returns (IOracleProvider);\n function payoffDefinition() external view returns (PayoffDefinition memory);\n function currentVersion() external view returns (IOracleProvider.OracleVersion memory);\n function atVersion(uint256 oracleVersion) external view returns (IOracleProvider.OracleVersion memory);\n}\n" - }, - "contracts/interfaces/IParamProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\";\n\ninterface IParamProvider {\n event MaintenanceUpdated(UFixed18 newMaintenance);\n event FundingFeeUpdated(UFixed18 newFundingFee);\n event MakerFeeUpdated(UFixed18 newMakerFee);\n event TakerFeeUpdated(UFixed18 newTakerFee);\n event MakerLimitUpdated(UFixed18 newMakerLimit);\n event JumpRateUtilizationCurveUpdated(\n Fixed18 minRate,\n Fixed18 maxRate,\n Fixed18 targetRate,\n UFixed18 targetUtilization\n );\n\n error ParamProviderInvalidMakerFee();\n error ParamProviderInvalidTakerFee();\n error ParamProviderInvalidFundingFee();\n \n function maintenance() external view returns (UFixed18);\n function updateMaintenance(UFixed18 newMaintenance) external;\n function fundingFee() external view returns (UFixed18);\n function updateFundingFee(UFixed18 newFundingFee) external;\n function makerFee() external view returns (UFixed18);\n function updateMakerFee(UFixed18 newMakerFee) external;\n function takerFee() external view returns (UFixed18);\n function updateTakerFee(UFixed18 newTakerFee) external;\n function makerLimit() external view returns (UFixed18);\n function updateMakerLimit(UFixed18 newMakerLimit) external;\n function utilizationCurve() external view returns (JumpRateUtilizationCurve memory);\n function updateUtilizationCurve(JumpRateUtilizationCurve memory newUtilizationCurve) external;\n}\n" - }, - "contracts/interfaces/types/Position.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"../IProduct.sol\";\nimport \"./Accumulator.sol\";\nimport \"./PrePosition.sol\";\nimport \"./PackedPosition.sol\";\n\n/// @dev Position type\nstruct Position {\n /// @dev Quantity of the maker position\n UFixed18 maker;\n /// @dev Quantity of the taker position\n UFixed18 taker;\n}\nusing PositionLib for Position global;\n\n/**\n * @title PositionLib\n * @notice Library that surfaces math and settlement computations for the Position type.\n * @dev Positions track the current quantity of the account's maker and taker positions respectively\n * denominated as a unit of the product's payoff function.\n */\nlibrary PositionLib {\n /**\n * @notice Creates a packed position from an position\n * @param self A position\n * @return New packed position\n */\n function pack(Position memory self) internal pure returns (PackedPosition memory) {\n return PackedPosition({maker: self.maker.pack(), taker: self.taker.pack()});\n }\n\n /**\n * @notice Returns whether the position is fully empty\n * @param self A position\n * @return Whether the position is empty\n */\n function isEmpty(Position memory self) internal pure returns (bool) {\n return self.maker.isZero() && self.taker.isZero();\n }\n\n /**\n * @notice Adds position `a` and `b` together, returning the result\n * @param a The first position to sum\n * @param b The second position to sum\n * @return Resulting summed position\n */\n function add(Position memory a, Position memory b) internal pure returns (Position memory) {\n return Position({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\n }\n\n /**\n * @notice Subtracts position `b` from `a`, returning the result\n * @param a The position to subtract from\n * @param b The position to subtract\n * @return Resulting subtracted position\n */\n function sub(Position memory a, Position memory b) internal pure returns (Position memory) {\n return Position({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\n }\n\n /**\n * @notice Multiplies position `self` by accumulator `accumulator` and returns the resulting accumulator\n * @param self The Position to operate on\n * @param accumulator The accumulator to multiply by\n * @return Resulting multiplied accumulator\n */\n function mul(Position memory self, Accumulator memory accumulator) internal pure returns (Accumulator memory) {\n return Accumulator({\n maker: Fixed18Lib.from(self.maker).mul(accumulator.maker),\n taker: Fixed18Lib.from(self.taker).mul(accumulator.taker)\n });\n }\n\n /**\n * @notice Scales position `self` by fixed-decimal `scale` and returns the resulting position\n * @param self The Position to operate on\n * @param scale The Fixed-decimal to scale by\n * @return Resulting scaled position\n */\n function mul(Position memory self, UFixed18 scale) internal pure returns (Position memory) {\n return Position({maker: self.maker.mul(scale), taker: self.taker.mul(scale)});\n }\n\n /**\n * @notice Divides position `self` by `b` and returns the resulting accumulator\n * @param self The Position to operate on\n * @param b The number to divide by\n * @return Resulting divided accumulator\n */\n function div(Position memory self, uint256 b) internal pure returns (Accumulator memory) {\n return Accumulator({\n maker: Fixed18Lib.from(self.maker).div(Fixed18Lib.from(UFixed18Lib.from(b))),\n taker: Fixed18Lib.from(self.taker).div(Fixed18Lib.from(UFixed18Lib.from(b)))\n });\n }\n\n /**\n * @notice Returns the maximum of `self`'s maker and taker values\n * @param self The struct to operate on\n * @return Resulting maximum value\n */\n function max(Position memory self) internal pure returns (UFixed18) {\n return UFixed18Lib.max(self.maker, self.taker);\n }\n\n /**\n * @notice Sums the maker and taker together from a single position\n * @param self The struct to operate on\n * @return The sum of its maker and taker\n */\n function sum(Position memory self) internal pure returns (UFixed18) {\n return self.maker.add(self.taker);\n }\n\n /**\n * @notice Computes the next position after the pending-settlement position delta is included\n * @param self The current Position\n * @param pre The pending-settlement position delta\n * @return Next Position\n */\n function next(Position memory self, PrePosition memory pre) internal pure returns (Position memory) {\n return sub(add(self, pre.openPosition), pre.closePosition);\n }\n\n /**\n * @notice Returns the settled position at oracle version `toOracleVersion`\n * @dev Checks if a new position is ready to be settled based on the provided `toOracleVersion`\n * and `pre` and returns accordingly\n * @param self The current Position\n * @param pre The pending-settlement position delta\n * @param toOracleVersion The oracle version to settle to\n * @return Settled position at oracle version\n * @return Fee accrued from opening or closing the position\n * @return Whether a new position was settled\n */\n function settled(\n Position memory self,\n PrePosition memory pre,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal view returns (Position memory, UFixed18, bool) {\n return pre.canSettle(toOracleVersion) ? (next(self, pre), pre.computeFee(toOracleVersion), true) : (self, UFixed18Lib.ZERO, false);\n }\n\n /**\n * @notice Returns the socialization factor for the current position\n * @dev Socialization account for the case where `taker` > `maker` temporarily due to a liquidation\n * on the maker side. This dampens the taker's exposure pro-rata to ensure that the maker side\n * is never exposed over 1 x short.\n * @param self The Position to operate on\n * @return Socialization factor\n */\n function socializationFactor(Position memory self) internal pure returns (UFixed18) {\n return self.taker.isZero() ? UFixed18Lib.ONE : UFixed18Lib.min(UFixed18Lib.ONE, self.maker.div(self.taker));\n }\n}\n" - }, - "contracts/interfaces/types/PrePosition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"./Position.sol\";\nimport \"../IProduct.sol\";\n\n/// @dev PrePosition type\nstruct PrePosition {\n /// @dev Oracle version at which the new position delta was recorded\n uint256 oracleVersion;\n\n /// @dev Size of position to open at oracle version\n Position openPosition;\n\n /// @dev Size of position to close at oracle version\n Position closePosition;\n}\nusing PrePositionLib for PrePosition global;\n\n/**\n * @title PrePositionLib\n * @notice Library that manages a pre-settlement position delta.\n * @dev PrePositions track the currently awaiting-settlement deltas to a settled Position. These are\n * Primarily necessary to introduce lag into the settlement system such that oracle lag cannot be\n * gamed to a user's advantage. When a user opens or closes a new position, it sits as a PrePosition\n * for one oracle version until it's settle into the Position, making it then effective. PrePositions\n * are automatically settled at the correct oracle version even if a flywheel call doesn't happen until\n * several version into the future by using the historical version lookups in the corresponding \"Versioned\"\n * global state types.\n */\nlibrary PrePositionLib {\n /**\n * @notice Returns whether there is no pending-settlement position delta\n * @dev Can be \"empty\" even with a non-zero oracleVersion if a position is opened and\n * closed in the same version netting out to a zero position delta\n * @param self The struct to operate on\n * @return Whether the pending-settlement position delta is empty\n */\n function isEmpty(PrePosition memory self) internal pure returns (bool) {\n return self.openPosition.isEmpty() && self.closePosition.isEmpty();\n }\n\n /**\n * @notice Increments the maker side of the open position delta\n * @dev Nets out open and close deltas to minimize the size of each\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @param amount The position amount to open\n */\n function openMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\n self.openPosition.maker = self.openPosition.maker.add(amount);\n self.oracleVersion = currentVersion;\n _netMake(self);\n }\n\n /**\n * @notice Increments the maker side of the close position delta\n * @dev Nets out open and close deltas to minimize the size of each\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @param amount The maker position amount to close\n */\n function closeMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\n self.closePosition.maker = self.closePosition.maker.add(amount);\n self.oracleVersion = currentVersion;\n _netMake(self);\n }\n\n /**\n * @notice Increments the taker side of the open position delta\n * @dev Nets out open and close deltas to minimize the size of each\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @param amount The taker position amount to open\n */\n function openTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\n self.openPosition.taker = self.openPosition.taker.add(amount);\n self.oracleVersion = currentVersion;\n _netTake(self);\n }\n\n /**\n * @notice Increments the taker side of the close position delta\n * @dev Nets out open and close deltas to minimize the size of each\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @param amount The taker position amount to close\n */\n function closeTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\n self.closePosition.taker = self.closePosition.taker.add(amount);\n self.oracleVersion = currentVersion;\n _netTake(self);\n }\n\n /**\n * @notice Nets out the open and close on the maker side of the position delta\n * @param self The struct to operate on\n */\n function _netMake(PrePosition storage self) private {\n if (self.openPosition.maker.gt(self.closePosition.maker)) {\n self.openPosition.maker = self.openPosition.maker.sub(self.closePosition.maker);\n self.closePosition.maker = UFixed18Lib.ZERO;\n } else {\n self.closePosition.maker = self.closePosition.maker.sub(self.openPosition.maker);\n self.openPosition.maker = UFixed18Lib.ZERO;\n }\n }\n\n /**\n * @notice Nets out the open and close on the taker side of the position delta\n * @param self The struct to operate on\n */\n function _netTake(PrePosition storage self) private {\n if (self.openPosition.taker.gt(self.closePosition.taker)) {\n self.openPosition.taker = self.openPosition.taker.sub(self.closePosition.taker);\n self.closePosition.taker = UFixed18Lib.ZERO;\n } else {\n self.closePosition.taker = self.closePosition.taker.sub(self.openPosition.taker);\n self.openPosition.taker = UFixed18Lib.ZERO;\n }\n }\n\n /**\n * @notice Returns whether the the pending position delta can be settled at version `toOracleVersion`\n * @dev Pending-settlement positions deltas can be settled (1) oracle version after they are recorded\n * @param self The struct to operate on\n * @param toOracleVersion The potential oracle version to settle\n * @return Whether the position delta can be settled\n */\n function canSettle(\n PrePosition memory self,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal pure returns (bool) {\n return !isEmpty(self) && toOracleVersion.version > self.oracleVersion;\n }\n\n /**\n * @notice Computes the fee incurred for opening or closing the pending-settlement position\n * @dev Must be called from a valid product to get the proper fee amounts\n * @param self The struct to operate on\n * @param toOracleVersion The oracle version at which settlement takes place\n * @return positionFee The maker / taker fee incurred\n */\n function computeFee(\n PrePosition memory self,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal view returns (UFixed18) {\n Position memory positionDelta = self.openPosition.add(self.closePosition);\n\n (UFixed18 makerNotional, UFixed18 takerNotional) = (\n Fixed18Lib.from(positionDelta.maker).mul(toOracleVersion.price).abs(),\n Fixed18Lib.from(positionDelta.taker).mul(toOracleVersion.price).abs()\n );\n\n IProduct product = IProduct(address(this));\n return makerNotional.mul(product.makerFee()).add(takerNotional.mul(product.takerFee()));\n }\n\n /**\n * @notice Computes the next oracle version to settle\n * @dev - If there is no pending-settlement position delta, returns the current oracle version\n * - Otherwise returns the oracle version at which the pending-settlement position delta can be first settled\n *\n * Corresponds to point (b) in the Position settlement flow\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @return Next oracle version to settle\n */\n function settleVersion(PrePosition storage self, uint256 currentVersion) internal view returns (uint256) {\n uint256 _oracleVersion = self.oracleVersion;\n return _oracleVersion == 0 ? currentVersion : _oracleVersion + 1;\n }\n}\n" - }, - "contracts/interfaces/types/Accumulator.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/Fixed18.sol\";\nimport \"./PackedAccumulator.sol\";\n\n/// @dev Accumulator type\nstruct Accumulator {\n /// @dev maker accumulator per share\n Fixed18 maker;\n /// @dev taker accumulator per share\n Fixed18 taker;\n}\nusing AccumulatorLib for Accumulator global;\n\n/**\n * @title AccountAccumulatorLib\n * @notice Library that surfaces math operations for the Accumulator type.\n * @dev Accumulators track the cumulative change in position value over time for the maker and taker positions\n * respectively. Account-level accumulators can then use two of these values `a` and `a'` to compute the\n * change in position value since last sync. This change in value is then used to compute P&L and fees.\n */\nlibrary AccumulatorLib {\n /**\n * @notice Creates a packed accumulator from an accumulator\n * @param self an accumulator\n * @return New packed accumulator\n */\n function pack(Accumulator memory self) internal pure returns (PackedAccumulator memory) {\n return PackedAccumulator({maker: self.maker.pack(), taker: self.taker.pack()});\n }\n\n /**\n * @notice Adds two accumulators together\n * @param a The first accumulator to sum\n * @param b The second accumulator to sum\n * @return The resulting summed accumulator\n */\n function add(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\n return Accumulator({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\n }\n\n /**\n * @notice Subtracts accumulator `b` from `a`\n * @param a The accumulator to subtract from\n * @param b The accumulator to subtract\n * @return The resulting subtracted accumulator\n */\n function sub(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\n return Accumulator({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\n }\n\n /**\n * @notice Multiplies two accumulators together\n * @param a The first accumulator to multiply\n * @param b The second accumulator to multiply\n * @return The resulting multiplied accumulator\n */\n function mul(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\n return Accumulator({maker: a.maker.mul(b.maker), taker: a.taker.mul(b.taker)});\n }\n\n /**\n * @notice Sums the maker and taker together from a single accumulator\n * @param self The struct to operate on\n * @return The sum of its maker and taker\n */\n function sum(Accumulator memory self) internal pure returns (Fixed18) {\n return self.maker.add(self.taker);\n }\n}\n" - }, - "@equilibria/root/curve/CurveMath.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"../number/types/UFixed18.sol\";\nimport \"../number/types/Fixed18.sol\";\n\n/**\n * @title CurveMath\n * @notice Library for managing math operations for utilization curves.\n */\nlibrary CurveMath {\n error CurveMathOutOfBoundsError();\n\n /**\n * @notice Computes a linear interpolation between two points\n * @param startX First point's x-coordinate\n * @param startY First point's y-coordinate\n * @param endX Second point's x-coordinate\n * @param endY Second point's y-coordinate\n * @param targetX x-coordinate to interpolate\n * @return y-coordinate for `targetX` along the line from (`startX`, `startY`) -> (`endX`, `endY`)\n */\n function linearInterpolation(\n UFixed18 startX,\n Fixed18 startY,\n UFixed18 endX,\n Fixed18 endY,\n UFixed18 targetX\n ) internal pure returns (Fixed18) {\n if (targetX.lt(startX) || targetX.gt(endX)) revert CurveMathOutOfBoundsError();\n\n UFixed18 xRange = endX.sub(startX);\n Fixed18 yRange = endY.sub(startY);\n UFixed18 xRatio = targetX.sub(startX).div(xRange);\n return yRange.mul(Fixed18Lib.from(xRatio)).add(startY);\n }\n}\n" - }, - "@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/Fixed18.sol\";\n\ninterface IOracleProvider {\n /// @dev A singular oracle version with its corresponding data\n struct OracleVersion {\n /// @dev The iterative version\n uint256 version;\n\n /// @dev the timestamp of the oracle update\n uint256 timestamp;\n\n /// @dev The oracle price of the corresponding version\n Fixed18 price;\n }\n\n function sync() external returns (OracleVersion memory);\n function currentVersion() external view returns (OracleVersion memory);\n function atVersion(uint256 oracleVersion) external view returns (OracleVersion memory);\n}\n" - }, - "contracts/interfaces/IContractPayoffProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/Fixed18.sol\";\n\ninterface IContractPayoffProvider {\n function payoff(Fixed18 price) external view returns (Fixed18 payoff);\n}\n" - }, - "contracts/interfaces/types/PackedPosition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/PackedUFixed18.sol\";\nimport \"./Position.sol\";\n\n/// @dev PackedPosition type\nstruct PackedPosition {\n /// @dev Quantity of the maker position\n PackedUFixed18 maker;\n /// @dev Quantity of the taker position\n PackedUFixed18 taker;\n}\nusing PackedPositionLib for PackedPosition global;\n\n/**\n * @title PackedPositionLib\n * @dev A packed version of the Position which takes up a single storage slot using `PackedFixed18` values.\n * @notice Library for the packed Position type.\n */\nlibrary PackedPositionLib {\n /**\n * @notice Creates an position from a packed position\n * @param self packed position\n * @return New position\n */\n function unpack(PackedPosition memory self) internal pure returns (Position memory) {\n return Position({maker: self.maker.unpack(), taker: self.taker.unpack()});\n }\n}\n" - }, - "contracts/interfaces/types/PackedAccumulator.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/PackedFixed18.sol\";\nimport \"./Accumulator.sol\";\n\n/// @dev PackedAccumulator type\nstruct PackedAccumulator {\n /// @dev maker accumulator per share\n PackedFixed18 maker;\n /// @dev taker accumulator per share\n PackedFixed18 taker;\n}\nusing PackedAccumulatorLib for PackedAccumulator global;\n\n/**\n * @title PackedAccumulatorLib\n * @dev A packed version of the Accumulator which takes up a single storage slot using `PackedFixed18` values.\n * @notice Library for the packed Accumulator type.\n */\nlibrary PackedAccumulatorLib {\n /**\n * @notice Creates an accumulator from a packed accumulator\n * @param self packed accumulator\n * @return New accumulator\n */\n function unpack(PackedAccumulator memory self) internal pure returns (Accumulator memory) {\n return Accumulator({maker: self.maker.unpack(), taker: self.taker.unpack()});\n }\n}\n" - }, - "contracts/interfaces/types/ProgramInfo.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"../IProduct.sol\";\nimport \"./Position.sol\";\nimport \"./Accumulator.sol\";\n\n/// @dev ProgramInfo type\nstruct ProgramInfo {\n /// @dev Coordinator for this program\n uint256 coordinatorId;\n\n /// @dev Amount of total maker and taker rewards\n Position amount;\n\n /// @dev start timestamp of the program\n uint256 start;\n\n /// @dev duration of the program (in seconds)\n uint256 duration;\n\n /**\n * @dev Reward ERC20 token contract\n * @notice Perennial does not support non-standard ERC20s as reward tokens for incentive programs, including,\n but not limited to: fee on transfer and rebase tokens. Using such a non-standard token will likely\n result in loss of funds.\n */\n Token18 token;\n}\nusing ProgramInfoLib for ProgramInfo global;\n\n/**\n * @title ProgramInfoLib\n * @notice Library that snapshots the static information for a single program.\n * @dev This information does not change during the operation of a program.\n */\nlibrary ProgramInfoLib {\n uint256 private constant MIN_DURATION = 1 days;\n uint256 private constant MAX_DURATION = 2 * 365 days;\n\n error ProgramInvalidStartError();\n error ProgramInvalidDurationError();\n\n /**\n * @notice Validates and creates a new Program\n * @dev Reverts for invalid programInfos\n * @param programInfo Un-sanitized static program information\n */\n function validate(ProgramInfo memory programInfo) internal view {\n if (isStarted(programInfo, block.timestamp)) revert ProgramInvalidStartError();\n if (programInfo.duration < MIN_DURATION || programInfo.duration > MAX_DURATION) revert ProgramInvalidDurationError();\n }\n\n /**\n * @notice Computes a new program info with the fee taken out of the amount\n * @param programInfo Original program info\n * @param incentivizationFee The incentivization fee\n * @return New program info\n * @return Fee amount\n */\n function deductFee(ProgramInfo memory programInfo, UFixed18 incentivizationFee)\n internal pure returns (ProgramInfo memory, UFixed18) {\n Position memory newProgramAmount = programInfo.amount.mul(UFixed18Lib.ONE.sub(incentivizationFee));\n UFixed18 programFeeAmount = programInfo.amount.sub(newProgramAmount).sum();\n programInfo.amount = newProgramAmount;\n return (programInfo, programFeeAmount);\n }\n\n /**\n * @notice Returns the maker and taker amounts per position share\n * @param self The ProgramInfo to operate on\n * @return programFee Amounts per share\n */\n function amountPerShare(ProgramInfo memory self) internal pure returns (Accumulator memory) {\n return self.amount.div(self.duration);\n }\n\n /**\n * @notice Returns whether the program has started by timestamp `timestamp`\n * @param self The ProgramInfo to operate on\n * @param timestamp Timestamp to check for\n * @return Whether the program has started\n */\n function isStarted(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\n return timestamp >= self.start;\n }\n\n /**\n * @notice Returns whether the program is completed by timestamp `timestamp`\n * @param self The ProgramInfo to operate on\n * @param timestamp Timestamp to check for\n * @return Whether the program is completed\n */\n function isComplete(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\n return timestamp >= (self.start + self.duration);\n }\n}\n" - }, - "contracts/product/UParamProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/control/unstructured/UInitializable.sol\";\nimport \"../controller/UControllerProvider.sol\";\nimport \"../interfaces/IParamProvider.sol\";\nimport \"../interfaces/IProduct.sol\";\n\nabstract contract UParamProvider is IParamProvider, UControllerProvider {\n /**\n * @notice Initializes the contract state\n * @param maintenance_ product maintenance ratio\n * @param fundingFee_ product funding fee\n * @param makerFee_ product maker fee\n * @param takerFee_ product taker fee\n * @param makerLimit_ product maker limit\n * @param utilizationCurve_ utulization curve definition\n */\n // solhint-disable-next-line func-name-mixedcase\n function __UParamProvider__initialize(\n UFixed18 maintenance_,\n UFixed18 fundingFee_,\n UFixed18 makerFee_,\n UFixed18 takerFee_,\n UFixed18 makerLimit_,\n JumpRateUtilizationCurve memory utilizationCurve_\n ) internal onlyInitializer {\n _updateMaintenance(maintenance_);\n _updateFundingFee(fundingFee_);\n _updateMakerFee(makerFee_);\n _updateTakerFee(takerFee_);\n _updateMakerLimit(makerLimit_);\n _updateUtilizationCurve(utilizationCurve_);\n }\n\n /// @dev Only allow the Product's coordinator owner to call\n modifier onlyProductOwner {\n uint256 coordinatorId = controller().coordinatorFor(IProduct(address(this)));\n if (controller().owner(coordinatorId) != msg.sender) revert NotOwnerError(coordinatorId);\n\n _;\n }\n\n /// @dev The maintenance value\n UFixed18Storage private constant _maintenance = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.UParamProvider.maintenance\"));\n function maintenance() public view returns (UFixed18) { return _maintenance.read(); }\n\n /// @dev The funding fee value\n UFixed18Storage private constant _fundingFee = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.UParamProvider.fundingFee\"));\n function fundingFee() public view returns (UFixed18) { return _fundingFee.read(); }\n\n /// @dev The maker fee value\n UFixed18Storage private constant _makerFee = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.UParamProvider.makerFee\"));\n function makerFee() public view returns (UFixed18) { return _makerFee.read(); }\n\n /// @dev The taker fee value\n UFixed18Storage private constant _takerFee = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.UParamProvider.takerFee\"));\n function takerFee() public view returns (UFixed18) { return _takerFee.read(); }\n\n /// @dev The maker limit value\n UFixed18Storage private constant _makerLimit = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.UParamProvider.makerLimit\"));\n function makerLimit() public view returns (UFixed18) { return _makerLimit.read(); }\n\n /// @dev The JumpRateUtilizationCurve params\n JumpRateUtilizationCurveStorage private constant _utilizationCurve =\n JumpRateUtilizationCurveStorage.wrap(keccak256(\"equilibria.perennial.UParamProvider.jumpRateUtilizationCurve\"));\n function utilizationCurve() public view returns (JumpRateUtilizationCurve memory) { return _utilizationCurve.read(); }\n\n /**\n * @notice Updates the maintenance to `newMaintenance`\n * @param newMaintenance new maintenance value\n */\n function _updateMaintenance(UFixed18 newMaintenance) private {\n _maintenance.store(newMaintenance);\n emit MaintenanceUpdated(newMaintenance);\n }\n\n /**\n * @notice Updates the maintenance to `newMaintenance`\n * @dev only callable by product owner\n * @param newMaintenance new maintenance value\n */\n function updateMaintenance(UFixed18 newMaintenance) external onlyProductOwner {\n _updateMaintenance(newMaintenance);\n }\n\n /**\n * @notice Updates the funding fee to `newFundingFee`\n * @param newFundingFee new funding fee value\n */\n function _updateFundingFee(UFixed18 newFundingFee) private {\n if (newFundingFee.gt(UFixed18Lib.ONE)) revert ParamProviderInvalidFundingFee();\n _fundingFee.store(newFundingFee);\n emit FundingFeeUpdated(newFundingFee);\n }\n\n /**\n * @notice Updates the funding fee to `newFundingFee`\n * @dev only callable by product owner\n * @param newFundingFee new funding fee value\n */\n function updateFundingFee(UFixed18 newFundingFee) external onlyProductOwner {\n _updateFundingFee(newFundingFee);\n }\n\n /**\n * @notice Updates the maker fee to `newMakerFee`\n * @param newMakerFee new maker fee value\n */\n function _updateMakerFee(UFixed18 newMakerFee) private {\n if (newMakerFee.gt(UFixed18Lib.ONE)) revert ParamProviderInvalidMakerFee();\n _makerFee.store(newMakerFee);\n emit MakerFeeUpdated(newMakerFee);\n }\n\n /**\n * @notice Updates the maker fee to `newMakerFee`\n * @dev only callable by product owner\n * @param newMakerFee new maker fee value\n */\n function updateMakerFee(UFixed18 newMakerFee) external onlyProductOwner {\n _updateMakerFee(newMakerFee);\n }\n\n /**\n * @notice Updates the taker fee to `newTakerFee`\n * @param newTakerFee new taker fee value\n */\n function _updateTakerFee(UFixed18 newTakerFee) private {\n if (newTakerFee.gt(UFixed18Lib.ONE)) revert ParamProviderInvalidTakerFee();\n _takerFee.store(newTakerFee);\n emit TakerFeeUpdated(newTakerFee);\n }\n\n /**\n * @notice Updates the taker fee to `newTakerFee`\n * @dev only callable by product owner\n * @param newTakerFee new taker fee value\n */\n function updateTakerFee(UFixed18 newTakerFee) external onlyProductOwner {\n _updateTakerFee(newTakerFee);\n }\n\n /**\n * @notice Updates the maker limit to `newMakerLimit`\n * @param newMakerLimit new maker limit value\n */\n function _updateMakerLimit(UFixed18 newMakerLimit) private {\n _makerLimit.store(newMakerLimit);\n emit MakerLimitUpdated(newMakerLimit);\n }\n\n /**\n * @notice Updates the maker limit to `newMakerLimit`\n * @dev only callable by product owner\n * @param newMakerLimit new maker limit value\n */\n function updateMakerLimit(UFixed18 newMakerLimit) external onlyProductOwner {\n _updateMakerLimit(newMakerLimit);\n }\n\n /**\n * @notice Updates the utilization curve to `newUtilizationCurve`\n * @param newUtilizationCurve new utilization curve value\n */\n function _updateUtilizationCurve(JumpRateUtilizationCurve memory newUtilizationCurve) private {\n _utilizationCurve.store(newUtilizationCurve);\n emit JumpRateUtilizationCurveUpdated(\n newUtilizationCurve.minRate.unpack(),\n newUtilizationCurve.maxRate.unpack(),\n newUtilizationCurve.targetRate.unpack(),\n newUtilizationCurve.targetUtilization.unpack()\n );\n }\n\n /**\n * @notice Updates the utilization curve to `newUtilizationCurve`\n * @dev only callable by product owner\n * @param newUtilizationCurve new utilization curve value\n */\n function updateUtilizationCurve(JumpRateUtilizationCurve calldata newUtilizationCurve) external onlyProductOwner {\n _updateUtilizationCurve(newUtilizationCurve);\n }\n}\n" - }, - "contracts/product/types/accumulator/VersionedAccumulator.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../../../interfaces/IProduct.sol\";\nimport \"../../../interfaces/types/Accumulator.sol\";\nimport \"../position/VersionedPosition.sol\";\n\n/// @dev VersionedAccumulator type\nstruct VersionedAccumulator {\n /// @dev Latest synced oracle version\n uint256 latestVersion;\n\n /// @dev Mapping of accumulator value at each settled oracle version\n mapping(uint256 => PackedAccumulator) _valueAtVersion;\n\n /// @dev Mapping of accumulator share at each settled oracle version\n mapping(uint256 => PackedAccumulator) _shareAtVersion;\n}\nusing VersionedAccumulatorLib for VersionedAccumulator global;\n\n/**\n * @title VersionedAccumulatorLib\n * @notice Library that manages global versioned accumulator state.\n * @dev Manages two accumulators: value and share. The value accumulator measures the change in position value\n * over time. The share accumulator measures the change in liquidity ownership over time (for tracking\n * incentivization rewards).\n *\n * Both accumulators are stamped for historical lookup anytime there is a global settlement, which services\n * the delayed-position accounting. It is not guaranteed that every version will have a value stamped, but\n * only versions when a settlement occurred are needed for this historical computation.\n */\nlibrary VersionedAccumulatorLib {\n /**\n * @notice Returns the stamped value accumulator at `oracleVersion`\n * @param self The struct to operate on\n * @param oracleVersion The oracle version to retrieve the value at\n * @return The stamped value accumulator at the requested version\n */\n function valueAtVersion(VersionedAccumulator storage self, uint256 oracleVersion) internal view returns (Accumulator memory) {\n return self._valueAtVersion[oracleVersion].unpack();\n }\n\n /**\n * @notice Returns the stamped share accumulator at `oracleVersion`\n * @param self The struct to operate on\n * @param oracleVersion The oracle version to retrieve the share at\n * @return The stamped share accumulator at the requested version\n */\n function shareAtVersion(VersionedAccumulator storage self, uint256 oracleVersion) internal view returns (Accumulator memory) {\n return self._shareAtVersion[oracleVersion].unpack();\n }\n\n /**\n * @notice Globally accumulates all value (position + funding) and share since last oracle update\n * @param self The struct to operate on\n * @param fundingFee The funding fee rate for the product\n * @param position Pointer to global position\n * @param latestOracleVersion The oracle version to accumulate from\n * @param toOracleVersion The oracle version to accumulate to\n * @return accumulatedFee The total fee accrued from accumulation\n */\n function accumulate(\n VersionedAccumulator storage self,\n UFixed18 fundingFee,\n VersionedPosition storage position,\n IOracleProvider.OracleVersion memory latestOracleVersion,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal returns (UFixed18 accumulatedFee) {\n Position memory latestPosition = position.positionAtVersion(latestOracleVersion.version);\n\n // accumulate funding\n Accumulator memory accumulatedPosition;\n (accumulatedPosition, accumulatedFee) =\n _accumulateFunding(fundingFee, latestPosition, latestOracleVersion, toOracleVersion);\n\n // accumulate position\n accumulatedPosition = accumulatedPosition.add(\n _accumulatePosition(latestPosition, latestOracleVersion, toOracleVersion));\n\n // accumulate share\n Accumulator memory accumulatedShare =\n _accumulateShare(latestPosition, latestOracleVersion, toOracleVersion);\n\n // save update\n self._valueAtVersion[toOracleVersion.version] = valueAtVersion(self, latestOracleVersion.version)\n .add(accumulatedPosition)\n .pack();\n self._shareAtVersion[toOracleVersion.version] = shareAtVersion(self, latestOracleVersion.version)\n .add(accumulatedShare)\n .pack();\n self.latestVersion = toOracleVersion.version;\n }\n\n /**\n * @notice Globally accumulates all funding since last oracle update\n * @dev If an oracle version is skipped due to no pre positions, funding will continue to be\n * pegged to the price of the last snapshotted oracleVersion until a new one is accumulated.\n * This is an acceptable approximation.\n * @param fundingFee The funding fee rate for the product\n * @param latestPosition The latest global position\n * @param latestOracleVersion The oracle version to accumulate from\n * @param toOracleVersion The oracle version to accumulate to\n * @return accumulatedFunding The total amount accumulated from funding\n * @return accumulatedFee The total fee accrued from funding accumulation\n */\n function _accumulateFunding(\n UFixed18 fundingFee,\n Position memory latestPosition,\n IOracleProvider.OracleVersion memory latestOracleVersion,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) private view returns (Accumulator memory accumulatedFunding, UFixed18 accumulatedFee) {\n if (_product().closed()) return (Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO), UFixed18Lib.ZERO);\n if (latestPosition.taker.isZero()) return (Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO), UFixed18Lib.ZERO);\n if (latestPosition.maker.isZero()) return (Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO), UFixed18Lib.ZERO);\n\n uint256 elapsed = toOracleVersion.timestamp - latestOracleVersion.timestamp;\n\n UFixed18 takerNotional = Fixed18Lib.from(latestPosition.taker).mul(latestOracleVersion.price).abs();\n UFixed18 socializedNotional = takerNotional.mul(latestPosition.socializationFactor());\n\n Fixed18 rateAccumulated = _product().rate(latestPosition)\n .mul(Fixed18Lib.from(UFixed18Lib.from(elapsed)));\n Fixed18 fundingAccumulated = rateAccumulated.mul(Fixed18Lib.from(socializedNotional));\n accumulatedFee = fundingAccumulated.abs().mul(fundingFee);\n\n Fixed18 fundingAccumulatedWithoutFee = Fixed18Lib.from(\n fundingAccumulated.sign(),\n fundingAccumulated.abs().sub(accumulatedFee)\n );\n\n bool makerPaysFunding = fundingAccumulated.sign() < 0;\n accumulatedFunding.maker = (makerPaysFunding ? fundingAccumulated : fundingAccumulatedWithoutFee)\n .div(Fixed18Lib.from(latestPosition.maker));\n accumulatedFunding.taker = (makerPaysFunding ? fundingAccumulatedWithoutFee : fundingAccumulated)\n .div(Fixed18Lib.from(latestPosition.taker)).mul(Fixed18Lib.NEG_ONE);\n }\n\n /**\n * @notice Globally accumulates position PNL since last oracle update\n * @param latestPosition The latest global position\n * @param latestOracleVersion The oracle version to accumulate from\n * @param toOracleVersion The oracle version to accumulate to\n * @return accumulatedPosition The total amount accumulated from position PNL\n */\n function _accumulatePosition(\n Position memory latestPosition,\n IOracleProvider.OracleVersion memory latestOracleVersion,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) private view returns (Accumulator memory accumulatedPosition) {\n if (_product().closed()) return Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO);\n if (latestPosition.taker.isZero()) return Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO);\n if (latestPosition.maker.isZero()) return Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO);\n\n Fixed18 oracleDelta = toOracleVersion.price.sub(latestOracleVersion.price);\n Fixed18 totalTakerDelta = oracleDelta.mul(Fixed18Lib.from(latestPosition.taker));\n Fixed18 socializedTakerDelta = totalTakerDelta.mul(Fixed18Lib.from(latestPosition.socializationFactor()));\n\n accumulatedPosition.maker = socializedTakerDelta.div(Fixed18Lib.from(latestPosition.maker)).mul(Fixed18Lib.NEG_ONE);\n accumulatedPosition.taker = socializedTakerDelta.div(Fixed18Lib.from(latestPosition.taker));\n }\n\n /**\n * @notice Globally accumulates position's share of the total market since last oracle update\n * @dev This is used to compute incentivization rewards based on market participation\n * @param latestPosition The latest global position\n * @param latestOracleVersion The oracle version to accumulate from\n * @param toOracleVersion The oracle version to accumulate to\n * @return accumulatedShare The total share amount accumulated per position\n */\n function _accumulateShare(\n Position memory latestPosition,\n IOracleProvider.OracleVersion memory latestOracleVersion,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) private pure returns (Accumulator memory accumulatedShare) {\n uint256 elapsed = toOracleVersion.timestamp - latestOracleVersion.timestamp;\n\n accumulatedShare.maker = latestPosition.maker.isZero() ?\n Fixed18Lib.ZERO :\n Fixed18Lib.from(UFixed18Lib.from(elapsed).div(latestPosition.maker));\n accumulatedShare.taker = latestPosition.taker.isZero() ?\n Fixed18Lib.ZERO :\n Fixed18Lib.from(UFixed18Lib.from(elapsed).div(latestPosition.taker));\n }\n\n function _product() private view returns (IProduct) {\n return IProduct(address(this));\n }\n}\n" - }, - "contracts/product/types/position/VersionedPosition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../../../interfaces/types/PrePosition.sol\";\nimport \"../../../interfaces/types/PackedPosition.sol\";\n\n//// @dev VersionedPosition type\nstruct VersionedPosition {\n /// @dev Mapping of global position at each version\n mapping(uint256 => PackedPosition) _positionAtVersion;\n\n /// @dev Current global pending-settlement position delta\n PrePosition pre;\n}\nusing VersionedPositionLib for VersionedPosition global;\n\n/**\n * @title VersionedPositionLib\n * @notice Library that manages global position state.\n * @dev Global position state is used to compute utilization rate and socialization, and to account for and\n * distribute fees globally.\n *\n * Positions are stamped for historical lookup anytime there is a global settlement, which services\n * the delayed-position accounting. It is not guaranteed that every version will have a value stamped, but\n * only versions when a settlement occurred are needed for this historical computation.\n */\nlibrary VersionedPositionLib {\n /**\n * @notice Returns the current global position\n * @return Current global position\n */\n function positionAtVersion(VersionedPosition storage self, uint256 oracleVersion) internal view returns (Position memory) {\n return self._positionAtVersion[oracleVersion].unpack();\n }\n\n /**\n * @notice Settled the global position to oracle version `toOracleVersion`\n * @param self The struct to operate on\n * @param latestVersion The latest settled oracle version\n * @param toOracleVersion The oracle version to settle to\n * @return positionFee The fee accrued from opening or closing a new position\n */\n function settle(\n VersionedPosition storage self,\n uint256 latestVersion,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal returns (UFixed18) {\n (Position memory newPosition, UFixed18 positionFee, bool settled) =\n positionAtVersion(self, latestVersion).settled(self.pre, toOracleVersion);\n\n self._positionAtVersion[toOracleVersion.version] = newPosition.pack();\n if (settled) delete self.pre;\n\n return positionFee;\n }\n}\n" - }, - "contracts/test/TestnetProductProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\";\nimport \"../interfaces/IContractPayoffProvider.sol\";\n\ncontract TestnetContractPayoffProvider is IContractPayoffProvider {\n function payoff(Fixed18 price) public pure returns (Fixed18) {\n return price.mul(price);\n }\n}\n" - }, - "contracts/product/types/accumulator/AccountAccumulator.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../../../interfaces/types/Accumulator.sol\";\nimport \"../position/AccountPosition.sol\";\nimport \"./VersionedAccumulator.sol\";\n\n/// @dev AccountAccumulator type\nstruct AccountAccumulator {\n /// @dev latest version that the account was synced too\n uint256 latestVersion;\n}\nusing AccountAccumulatorLib for AccountAccumulator global;\n\n/**\n * @title AccountAccumulatorLib\n * @notice Library that manages syncing an account-level accumulator.\n */\nlibrary AccountAccumulatorLib {\n /**\n * @notice Syncs the account to oracle version `versionTo`\n * @param self The struct to operate on\n * @param global Pointer to global accumulator\n * @param position Pointer to global position\n * @param versionTo Oracle version to sync account to\n * @return value The value accumulated sync last sync\n */\n function syncTo(\n AccountAccumulator storage self,\n VersionedAccumulator storage global,\n AccountPosition storage position,\n uint256 versionTo\n ) internal returns (Accumulator memory value) {\n Accumulator memory valueAccumulated = global.valueAtVersion(versionTo)\n .sub(global.valueAtVersion(self.latestVersion));\n value = position.position.mul(valueAccumulated);\n self.latestVersion = versionTo;\n }\n}\n" - }, - "contracts/product/types/position/AccountPosition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../../../interfaces/IProduct.sol\";\nimport \"../../../interfaces/types/PrePosition.sol\";\n\n/// @dev AccountPosition type\nstruct AccountPosition {\n /// @dev The current settled position of the account\n Position position;\n\n /// @dev The current position delta pending-settlement\n PrePosition pre;\n\n /// @dev Whether the account is currently locked for liquidation\n bool liquidation;\n}\nusing AccountPositionLib for AccountPosition global;\n\n/**\n * @title AccountPositionLib\n * @notice Library that manages an account-level position.\n */\nlibrary AccountPositionLib {\n /**\n * @notice Settled the account's position to oracle version `toOracleVersion`\n * @param self The struct to operate on\n * @param toOracleVersion The oracle version to accumulate to\n * @return positionFee The fee accrued from opening or closing a new position\n */\n function settle(\n AccountPosition storage self,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal returns (UFixed18 positionFee) {\n bool settled;\n (self.position, positionFee, settled) = self.position.settled(self.pre, toOracleVersion);\n if (settled) {\n delete self.pre;\n self.liquidation = false;\n }\n }\n\n /**\n * @notice Returns the current maintenance requirement for the account\n * @dev Must be called from a valid product to get the proper maintenance value\n * @param self The struct to operate on\n * @return Current maintenance requirement for the account\n */\n function maintenance(AccountPosition storage self) internal view returns (UFixed18) {\n if (self.liquidation) return UFixed18Lib.ZERO;\n return _maintenance(self.position);\n }\n\n /**\n * @notice Returns the maintenance requirement after the next oracle version settlement\n * @dev Includes the current pending-settlement position delta, assumes no price change\n * @param self The struct to operate on\n * @return Next maintenance requirement for the account\n */\n function maintenanceNext(AccountPosition storage self) internal view returns (UFixed18) {\n return _maintenance(self.position.next(self.pre));\n }\n\n /**\n * @notice Returns the maintenance requirement for a given `position`\n * @dev Internal helper\n * @param position The position to compete the maintenance requirement for\n * @return Next maintenance requirement for the account\n */\n function _maintenance(Position memory position) private view returns (UFixed18) {\n IProduct product = IProduct(address(this));\n Fixed18 oraclePrice = product.currentVersion().price;\n UFixed18 notionalMax = Fixed18Lib.from(position.max()).mul(oraclePrice).abs();\n return notionalMax.mul(product.maintenance());\n }\n\n /**\n * @notice Returns whether an account is completely closed, i.e. no position or pre-position\n * @param self The struct to operate on\n * @return Whether the account is closed\n */\n function isClosed(AccountPosition memory self) internal pure returns (bool) {\n return self.pre.isEmpty() && self.position.isEmpty();\n }\n\n /**\n * @notice Returns whether an account has opened position on both sides of the market (maker vs taker)\n * @dev Used to verify the invariant that a single account can only have a position on one side of the\n * market at a time\n * @param self The struct to operate on\n * @return Whether the account is currently doubled sided\n */\n function isDoubleSided(AccountPosition storage self) internal view returns (bool) {\n bool makerEmpty = self.position.maker.isZero() && self.pre.openPosition.maker.isZero() && self.pre.closePosition.maker.isZero();\n bool takerEmpty = self.position.taker.isZero() && self.pre.openPosition.taker.isZero() && self.pre.closePosition.taker.isZero();\n\n return !makerEmpty && !takerEmpty;\n }\n\n /**\n * @notice Returns whether the account's pending-settlement delta closes more position than is open\n * @dev Used to verify the invariant that an account cannot settle into having a negative position\n * @param self The struct to operate on\n * @return Whether the account is currently over closed\n */\n function isOverClosed(AccountPosition storage self) internal view returns (bool) {\n Position memory nextOpen = self.position.add(self.pre.openPosition);\n\n return self.pre.closePosition.maker.gt(nextOpen.maker) || self.pre.closePosition.taker.gt(nextOpen.taker);\n }\n}\n" - }, - "contracts/product/UPayoffProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/control/unstructured/UInitializable.sol\";\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"@equilibria/root/storage/UStorage.sol\";\nimport \"../interfaces/IPayoffProvider.sol\";\nimport \"../interfaces/types/PayoffDefinition.sol\";\n\n/**\n * @title UPayoffProvider\n * @notice Library for manage storing, surfacing, and upgrading a payoff provider.\n * @dev Uses an unstructured storage pattern to store the oracle address and payoff definition which allows this\n provider to be safely used with upgradeable contracts.\n */\nabstract contract UPayoffProvider is IPayoffProvider, UInitializable {\n /// @dev The oracle contract address\n AddressStorage private constant _oracle =\n AddressStorage.wrap(keccak256(\"equilibria.perennial.UPayoffProvider.oracle\"));\n function oracle() public view returns (IOracleProvider) { return IOracleProvider(_oracle.read()); }\n\n /// @dev Payoff definition struct\n PayoffDefinitionStorage private constant _payoffDefinition =\n PayoffDefinitionStorage.wrap(keccak256(\"equilibria.perennial.UPayoffProvider.payoffDefinition\"));\n function payoffDefinition() public view returns (PayoffDefinition memory) { return _payoffDefinition.read(); }\n\n /**\n * @notice Initializes the contract state\n * @param oracle_ Oracle address\n * @param payoffDefinition_ Payoff provider\n */\n // solhint-disable-next-line func-name-mixedcase\n function __UPayoffProvider__initialize(IOracleProvider oracle_, PayoffDefinition calldata payoffDefinition_) internal onlyInitializer {\n if (!Address.isContract(address(oracle_))) revert PayoffProviderInvalidOracle();\n _oracle.store(address(oracle_));\n\n if (!payoffDefinition_.valid()) revert PayoffProviderInvalidPayoffDefinitionError();\n _payoffDefinition.store(payoffDefinition_);\n }\n\n /**\n * @notice Returns the current oracle version transformed by the payoff definition\n * @return Current oracle version transformed by the payoff definition\n */\n function currentVersion() public view returns (IOracleProvider.OracleVersion memory) {\n return _transform(oracle().currentVersion());\n }\n\n /**\n * @notice Returns the oracle version at `oracleVersion` transformed by the payoff definition\n * @param oracleVersion Oracle version to return for\n * @return Oracle version at `oracleVersion` with price transformed by payoff function\n */\n function atVersion(uint256 oracleVersion) public view returns (IOracleProvider.OracleVersion memory) {\n return _transform(oracle().atVersion(oracleVersion));\n }\n\n /**\n * @notice Yook to call sync() on the oracle provider and transform the resulting oracle version\n */\n function _sync() internal returns (IOracleProvider.OracleVersion memory) {\n return _transform(oracle().sync());\n }\n\n /**\n * @notice Returns the transformed oracle version\n * @param oracleVersion Oracle version to transform\n * @return Transformed oracle version\n */\n function _transform(IOracleProvider.OracleVersion memory oracleVersion)\n internal view virtual returns (IOracleProvider.OracleVersion memory) {\n oracleVersion.price = payoffDefinition().transform(oracleVersion.price);\n return oracleVersion;\n }\n}\n" - }, - "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/UpgradeableBeacon.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IBeacon.sol\";\nimport \"../../access/Ownable.sol\";\nimport \"../../utils/Address.sol\";\n\n/**\n * @dev This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their\n * implementation contract, which is where they will delegate all function calls.\n *\n * An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.\n */\ncontract UpgradeableBeacon is IBeacon, Ownable {\n address private _implementation;\n\n /**\n * @dev Emitted when the implementation returned by the beacon is changed.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the\n * beacon.\n */\n constructor(address implementation_) {\n _setImplementation(implementation_);\n }\n\n /**\n * @dev Returns the current implementation address.\n */\n function implementation() public view virtual override returns (address) {\n return _implementation;\n }\n\n /**\n * @dev Upgrades the beacon to a new implementation.\n *\n * Emits an {Upgraded} event.\n *\n * Requirements:\n *\n * - msg.sender must be the owner of the contract.\n * - `newImplementation` must be a contract.\n */\n function upgradeTo(address newImplementation) public virtual onlyOwner {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Sets the implementation contract address for this beacon\n *\n * Requirements:\n *\n * - `newImplementation` must be a contract.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"UpgradeableBeacon: implementation is not a contract\");\n _implementation = newImplementation;\n }\n}\n" - }, - "@openzeppelin/contracts/access/Ownable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n _;\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Context.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n" - }, - "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/ProxyAdmin.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./TransparentUpgradeableProxy.sol\";\nimport \"../../access/Ownable.sol\";\n\n/**\n * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an\n * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.\n */\ncontract ProxyAdmin is Ownable {\n /**\n * @dev Returns the current implementation of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"implementation()\")) == 0x5c60da1b\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"5c60da1b\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Returns the current admin of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"admin()\")) == 0xf851a440\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"f851a440\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Changes the admin of `proxy` to `newAdmin`.\n *\n * Requirements:\n *\n * - This contract must be the current admin of `proxy`.\n */\n function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {\n proxy.changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {\n proxy.upgradeTo(implementation);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See\n * {TransparentUpgradeableProxy-upgradeToAndCall}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgradeAndCall(\n TransparentUpgradeableProxy proxy,\n address implementation,\n bytes memory data\n ) public payable virtual onlyOwner {\n proxy.upgradeToAndCall{value: msg.value}(implementation, data);\n }\n}\n" - }, - "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC1967/ERC1967Proxy.sol\";\n\n/**\n * @dev This contract implements a proxy that is upgradeable by an admin.\n *\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\n * clashing], which can potentially be used in an attack, this contract uses the\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\n * things that go hand in hand:\n *\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\n * that call matches one of the admin functions exposed by the proxy itself.\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\n * \"admin cannot fallback to proxy target\".\n *\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\n * to sudden errors when trying to call a function from the proxy implementation.\n *\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\n */\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\n /**\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\n */\n constructor(\n address _logic,\n address admin_,\n bytes memory _data\n ) payable ERC1967Proxy(_logic, _data) {\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.admin\")) - 1));\n _changeAdmin(admin_);\n }\n\n /**\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\n */\n modifier ifAdmin() {\n if (msg.sender == _getAdmin()) {\n _;\n } else {\n _fallback();\n }\n }\n\n /**\n * @dev Returns the current admin.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\n */\n function admin() external ifAdmin returns (address admin_) {\n admin_ = _getAdmin();\n }\n\n /**\n * @dev Returns the current implementation.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\n */\n function implementation() external ifAdmin returns (address implementation_) {\n implementation_ = _implementation();\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\n */\n function changeAdmin(address newAdmin) external virtual ifAdmin {\n _changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\n */\n function upgradeTo(address newImplementation) external ifAdmin {\n _upgradeToAndCall(newImplementation, bytes(\"\"), false);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\n * proxied contract.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\n */\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\n _upgradeToAndCall(newImplementation, data, true);\n }\n\n /**\n * @dev Returns the current admin.\n */\n function _admin() internal view virtual returns (address) {\n return _getAdmin();\n }\n\n /**\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\n */\n function _beforeFallback() internal virtual override {\n require(msg.sender != _getAdmin(), \"TransparentUpgradeableProxy: admin cannot fallback to proxy target\");\n super._beforeFallback();\n }\n}\n" - }, - "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Proxy.sol\";\nimport \"./ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\n * implementation address that can be changed. This address is stored in storage in the location specified by\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\n * implementation behind the proxy.\n */\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\n /**\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\n *\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\n */\n constructor(address _logic, bytes memory _data) payable {\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.implementation\")) - 1));\n _upgradeToAndCall(_logic, _data, false);\n }\n\n /**\n * @dev Returns the current implementation address.\n */\n function _implementation() internal view virtual override returns (address impl) {\n return ERC1967Upgrade._getImplementation();\n }\n}\n" - }, - "@openzeppelin/contracts/proxy/Proxy.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n /**\n * @dev Delegates the current call to `implementation`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _delegate(address implementation) internal virtual {\n assembly {\n // Copy msg.data. We take full control of memory in this inline assembly\n // block because it will not return to Solidity code. We overwrite the\n // Solidity scratch pad at memory position 0.\n calldatacopy(0, 0, calldatasize())\n\n // Call the implementation.\n // out and outsize are 0 because we don't know the size yet.\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n // Copy the returned data.\n returndatacopy(0, 0, returndatasize())\n\n switch result\n // delegatecall returns 0 on error.\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n /**\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\n * and {_fallback} should delegate.\n */\n function _implementation() internal view virtual returns (address);\n\n /**\n * @dev Delegates the current call to the address returned by `_implementation()`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _fallback() internal virtual {\n _beforeFallback();\n _delegate(_implementation());\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n * function in the contract matches the call data.\n */\n fallback() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\n * is empty.\n */\n receive() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\n * call, or as part of the Solidity `fallback` or `receive` functions.\n *\n * If overridden should call `super._beforeFallback()`.\n */\n function _beforeFallback() internal virtual {}\n}\n" - }, - "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeacon.sol\";\nimport \"../../interfaces/draft-IERC1822.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/StorageSlot.sol\";\n\n/**\n * @dev This abstract contract provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\n *\n * _Available since v4.1._\n *\n * @custom:oz-upgrades-unsafe-allow delegatecall\n */\nabstract contract ERC1967Upgrade {\n // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\n\n /**\n * @dev Storage slot with the address of the current implementation.\n * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @dev Emitted when the implementation is upgraded.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Returns the current implementation address.\n */\n function _getImplementation() internal view returns (address) {\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 implementation slot.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n }\n\n /**\n * @dev Perform implementation upgrade\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeTo(address newImplementation) internal {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Perform implementation upgrade with additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCall(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n _upgradeTo(newImplementation);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(newImplementation, data);\n }\n }\n\n /**\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCallUUPS(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n // Upgrades from old implementations will perform a rollback test. This test requires the new\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\n // this special case will break upgrade paths from old UUPS implementation to new ones.\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\n _setImplementation(newImplementation);\n } else {\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n require(slot == _IMPLEMENTATION_SLOT, \"ERC1967Upgrade: unsupported proxiableUUID\");\n } catch {\n revert(\"ERC1967Upgrade: new implementation is not UUPS\");\n }\n _upgradeToAndCall(newImplementation, data, forceCall);\n }\n }\n\n /**\n * @dev Storage slot with the admin of the contract.\n * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n /**\n * @dev Emitted when the admin account has changed.\n */\n event AdminChanged(address previousAdmin, address newAdmin);\n\n /**\n * @dev Returns the current admin.\n */\n function _getAdmin() internal view returns (address) {\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 admin slot.\n */\n function _setAdmin(address newAdmin) private {\n require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n */\n function _changeAdmin(address newAdmin) internal {\n emit AdminChanged(_getAdmin(), newAdmin);\n _setAdmin(newAdmin);\n }\n\n /**\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n */\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n /**\n * @dev Emitted when the beacon is upgraded.\n */\n event BeaconUpgraded(address indexed beacon);\n\n /**\n * @dev Returns the current beacon.\n */\n function _getBeacon() internal view returns (address) {\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\n }\n\n /**\n * @dev Stores a new beacon in the EIP1967 beacon slot.\n */\n function _setBeacon(address newBeacon) private {\n require(Address.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n require(\n Address.isContract(IBeacon(newBeacon).implementation()),\n \"ERC1967: beacon implementation is not a contract\"\n );\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n }\n\n /**\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n *\n * Emits a {BeaconUpgraded} event.\n */\n function _upgradeBeaconToAndCall(\n address newBeacon,\n bytes memory data,\n bool forceCall\n ) internal {\n _setBeacon(newBeacon);\n emit BeaconUpgraded(newBeacon);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/interfaces/draft-IERC1822.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822Proxiable {\n /**\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n * address.\n *\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n * function revert if invoked through a proxy.\n */\n function proxiableUUID() external view returns (bytes32);\n}\n" - }, - "@openzeppelin/contracts/utils/StorageSlot.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\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 ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\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(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\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 /**\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 {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n assembly {\n r.slot := slot\n }\n }\n}\n" - }, - "contracts/hardhat-dependency-compiler/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol';\n" - }, - "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/BeaconProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IBeacon.sol\";\nimport \"../Proxy.sol\";\nimport \"../ERC1967/ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements a proxy that gets the implementation address for each call from a {UpgradeableBeacon}.\n *\n * The beacon address is stored in storage slot `uint256(keccak256('eip1967.proxy.beacon')) - 1`, so that it doesn't\n * conflict with the storage layout of the implementation behind the proxy.\n *\n * _Available since v3.4._\n */\ncontract BeaconProxy is Proxy, ERC1967Upgrade {\n /**\n * @dev Initializes the proxy with `beacon`.\n *\n * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This\n * will typically be an encoded function call, and allows initializating the storage of the proxy like a Solidity\n * constructor.\n *\n * Requirements:\n *\n * - `beacon` must be a contract with the interface {IBeacon}.\n */\n constructor(address beacon, bytes memory data) payable {\n assert(_BEACON_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.beacon\")) - 1));\n _upgradeBeaconToAndCall(beacon, data, false);\n }\n\n /**\n * @dev Returns the current beacon address.\n */\n function _beacon() internal view virtual returns (address) {\n return _getBeacon();\n }\n\n /**\n * @dev Returns the current implementation address of the associated beacon.\n */\n function _implementation() internal view virtual override returns (address) {\n return IBeacon(_getBeacon()).implementation();\n }\n\n /**\n * @dev Changes the proxy to use a new beacon. Deprecated: see {_upgradeBeaconToAndCall}.\n *\n * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon.\n *\n * Requirements:\n *\n * - `beacon` must be a contract.\n * - The implementation returned by `beacon` must be a contract.\n */\n function _setBeacon(address beacon, bytes memory data) internal virtual {\n _upgradeBeaconToAndCall(beacon, data, false);\n }\n}\n" - }, - "contracts/controller/Controller.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/root/control/unstructured/UInitializable.sol\";\nimport \"@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol\";\nimport \"../interfaces/IController.sol\";\nimport \"../interfaces/ICollateral.sol\";\nimport \"../interfaces/IIncentivizer.sol\";\nimport \"../interfaces/IProduct.sol\";\n\n/**\n * @title Controller\n * @notice Manages creating new products and global protocol parameters.\n */\ncontract Controller is IController, UInitializable {\n /// @dev Collateral contract address for the protocol\n AddressStorage private constant _collateral = AddressStorage.wrap(keccak256(\"equilibria.perennial.Controller.collateral\"));\n function collateral() public view returns (ICollateral) { return ICollateral(_collateral.read()); }\n\n /// @dev Incentivizer contract address for the protocol\n AddressStorage private constant _incentivizer = AddressStorage.wrap(keccak256(\"equilibria.perennial.Controller.incentivizer\"));\n function incentivizer() public view returns (IIncentivizer) { return IIncentivizer(_incentivizer.read()); }\n\n /// @dev Product implementation beacon address for the protocol\n AddressStorage private constant _productBeacon = AddressStorage.wrap(keccak256(\"equilibria.perennial.Controller.productBeacon\"));\n function productBeacon() public view returns (IBeacon) { return IBeacon(_productBeacon.read()); }\n\n /// @dev Percent of collected fees that go to the protocol treasury vs the product treasury\n UFixed18Storage private constant _protocolFee = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.Controller.protocolFee\"));\n function protocolFee() public view returns (UFixed18) { return _protocolFee.read(); }\n\n /// @dev Minimum allowable funding fee for a product\n UFixed18Storage private constant _minFundingFee = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.Controller.minFundingFee\"));\n function minFundingFee() public view returns (UFixed18) { return _minFundingFee.read(); }\n\n /// @dev Fee on maintenance for liquidation\n UFixed18Storage private constant _liquidationFee = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.Controller.liquidationFee\"));\n function liquidationFee() public view returns (UFixed18) { return _liquidationFee.read(); }\n\n /// @dev Fee on incentivization programs\n UFixed18Storage private constant _incentivizationFee = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.Controller.incentivizationFee\"));\n function incentivizationFee() public view returns (UFixed18) { return _incentivizationFee.read(); }\n\n /// @dev Minimum allowable collateral amount per user account\n UFixed18Storage private constant _minCollateral = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.Controller.minCollateral\"));\n function minCollateral() public view returns (UFixed18) { return _minCollateral.read(); }\n\n /// @dev Maximum incentivization programs per product allowed\n Uint256Storage private constant _programsPerProduct = Uint256Storage.wrap(keccak256(\"equilibria.perennial.Controller.programsPerProduct\"));\n function programsPerProduct() public view returns (uint256) { return _programsPerProduct.read(); }\n\n /// @dev Protocol pauser address. address(0) defaults to owner(0)\n AddressStorage private constant _pauser = AddressStorage.wrap(keccak256(\"equilibria.perennial.Controller.pauser\"));\n function pauser() public view returns (address) {\n address pauser_ = _pauser.read();\n return pauser_ == address(0) ? owner() : pauser_;\n }\n\n /// @dev The paused status of the protocol\n BoolStorage private constant _paused = BoolStorage.wrap(keccak256(\"equilibria.perennial.Controller.paused\"));\n function paused() public view returns (bool) { return _paused.read(); }\n\n /// @dev List of product coordinators\n Coordinator[] private _coordinators;\n\n /// @dev Mapping of the coordinator for each product\n mapping(IProduct => uint256) public coordinatorFor;\n\n /**\n * @notice Initializes the contract state\n * @dev Must be called atomically as part of the upgradeable proxy deployment to\n * avoid front-running\n * @param collateral_ Collateral contract address\n * @param incentivizer_ Incentivizer contract address\n * @param productBeacon_ Product implementation beacon address\n */\n function initialize(\n ICollateral collateral_,\n IIncentivizer incentivizer_,\n IBeacon productBeacon_\n ) external initializer(1) {\n _createCoordinator();\n\n updateCollateral(collateral_);\n updateIncentivizer(incentivizer_);\n updateProductBeacon(productBeacon_);\n }\n\n /**\n * @notice Creates a new coordinator with `msg.sender` as the owner\n * @dev Can only be called by the protocol owner\n * @return New coordinator ID\n */\n function createCoordinator() external returns (uint256) {\n return _createCoordinator();\n }\n\n /**\n * @notice Creates a new coordinator with `msg.sender` as the owner\n * @dev `treasury` and `pauser` initialize as the 0-address, defaulting to the `owner`\n * @return New coordinator ID\n */\n function _createCoordinator() private returns (uint256) {\n uint256 coordinatorId = _coordinators.length;\n\n _coordinators.push(Coordinator({\n pendingOwner: address(0),\n owner: msg.sender,\n treasury: address(0)\n }));\n\n emit CoordinatorCreated(coordinatorId, msg.sender);\n\n return coordinatorId;\n }\n\n /**\n * @notice Updates the pending owner of an existing coordinator\n * @dev Must be called by the coordinator's current owner\n * @param coordinatorId Coordinator to update\n * @param newPendingOwner New pending owner address\n */\n function updateCoordinatorPendingOwner(uint256 coordinatorId, address newPendingOwner) external onlyOwner(coordinatorId) {\n _coordinators[coordinatorId].pendingOwner = newPendingOwner;\n emit CoordinatorPendingOwnerUpdated(coordinatorId, newPendingOwner);\n }\n\n /**\n * @notice Accepts ownership over an existing coordinator\n * @dev Must be called by the coordinator's pending owner\n * @param coordinatorId Coordinator to update\n */\n function acceptCoordinatorOwner(uint256 coordinatorId) external {\n Coordinator storage coordinator = _coordinators[coordinatorId];\n address newPendingOwner = coordinator.pendingOwner;\n\n if (msg.sender != newPendingOwner) revert ControllerNotPendingOwnerError(coordinatorId);\n\n coordinator.pendingOwner = address(0);\n coordinator.owner = newPendingOwner;\n emit CoordinatorOwnerUpdated(coordinatorId, newPendingOwner);\n }\n\n /**\n * @notice Updates the treasury of an existing coordinator\n * @dev Must be called by the coordinator's current owner. Defaults to the coordinator `owner` if set to address(0)\n * @param coordinatorId Coordinator to update\n * @param newTreasury New treasury address\n */\n function updateCoordinatorTreasury(uint256 coordinatorId, address newTreasury) external onlyOwner(coordinatorId) {\n _coordinators[coordinatorId].treasury = newTreasury;\n emit CoordinatorTreasuryUpdated(coordinatorId, newTreasury);\n }\n\n /**\n * @notice Creates a new product market with `provider`\n * @dev Can only be called by the coordinator owner\n * @param coordinatorId Coordinator that will own the product\n * @param productInfo Product params used to initialize the product\n * @return New product contract address\n */\n function createProduct(uint256 coordinatorId, IProduct.ProductInfo calldata productInfo)\n external onlyOwner(coordinatorId) returns (IProduct) {\n if (coordinatorId == 0) revert ControllerNoZeroCoordinatorError();\n\n BeaconProxy newProductProxy = new BeaconProxy(address(productBeacon()), abi.encodeCall(IProduct.initialize, productInfo));\n IProduct newProduct = IProduct(address(newProductProxy));\n coordinatorFor[newProduct] = coordinatorId;\n emit ProductCreated(newProduct, productInfo);\n\n return newProduct;\n }\n\n /**\n * @notice Updates the Collateral contract address\n * @param newCollateral New Collateral contract address\n */\n function updateCollateral(ICollateral newCollateral) public onlyOwner(0) {\n if (!Address.isContract(address(newCollateral))) revert ControllerNotContractAddressError();\n _collateral.store(address(newCollateral));\n emit CollateralUpdated(newCollateral);\n }\n\n /**\n * @notice Updates the Incentivizer contract address\n * @param newIncentivizer New Incentivizer contract address\n */\n function updateIncentivizer(IIncentivizer newIncentivizer) public onlyOwner(0) {\n if (!Address.isContract(address(newIncentivizer))) revert ControllerNotContractAddressError();\n _incentivizer.store(address(newIncentivizer));\n emit IncentivizerUpdated(newIncentivizer);\n }\n\n /**\n * @notice Updates the Product implementation beacon address\n * @param newProductBeacon New Product implementation beacon address\n */\n function updateProductBeacon(IBeacon newProductBeacon) public onlyOwner(0) {\n if (!Address.isContract(address(newProductBeacon))) revert ControllerNotContractAddressError();\n _productBeacon.store(address(newProductBeacon));\n emit ProductBeaconUpdated(newProductBeacon);\n }\n\n /**\n * @notice Updates the protocol-product fee split\n * @param newProtocolFee New protocol-product fee split\n */\n function updateProtocolFee(UFixed18 newProtocolFee) public onlyOwner(0) {\n if (newProtocolFee.gt(UFixed18Lib.ONE)) revert ControllerInvalidProtocolFeeError();\n\n _protocolFee.store(newProtocolFee);\n emit ProtocolFeeUpdated(newProtocolFee);\n }\n\n /**\n * @notice Updates the minimum allowed funding fee\n * @param newMinFundingFee New minimum allowed funding fee\n */\n function updateMinFundingFee(UFixed18 newMinFundingFee) public onlyOwner(0) {\n if (newMinFundingFee.gt(UFixed18Lib.ONE)) revert ControllerInvalidMinFundingFeeError();\n\n _minFundingFee.store(newMinFundingFee);\n emit MinFundingFeeUpdated(newMinFundingFee);\n }\n\n /**\n * @notice Updates the liquidation fee\n * @param newLiquidationFee New liquidation fee\n */\n function updateLiquidationFee(UFixed18 newLiquidationFee) public onlyOwner(0) {\n if (newLiquidationFee.gt(UFixed18Lib.ONE)) revert ControllerInvalidLiquidationFeeError();\n\n _liquidationFee.store(newLiquidationFee);\n emit LiquidationFeeUpdated(newLiquidationFee);\n }\n\n /**\n * @notice Updates the incentivization fee\n * @param newIncentivizationFee New incentivization fee\n */\n function updateIncentivizationFee(UFixed18 newIncentivizationFee) public onlyOwner(0) {\n if (newIncentivizationFee.gt(UFixed18Lib.ONE)) revert ControllerInvalidIncentivizationFeeError();\n\n _incentivizationFee.store(newIncentivizationFee);\n emit IncentivizationFeeUpdated(newIncentivizationFee);\n }\n\n /**\n * @notice Updates the minimum allowed collateral amount per user account\n * @param newMinCollateral New minimum allowed collateral amount\n */\n function updateMinCollateral(UFixed18 newMinCollateral) public onlyOwner(0) {\n _minCollateral.store(newMinCollateral);\n emit MinCollateralUpdated(newMinCollateral);\n }\n\n /**\n * @notice Updates the maximum incentivization programs per product allowed\n * @param newProgramsPerProduct New maximum incentivization programs per product allowed\n */\n function updateProgramsPerProduct(uint256 newProgramsPerProduct) public onlyOwner(0) {\n _programsPerProduct.store(newProgramsPerProduct);\n emit ProgramsPerProductUpdated(newProgramsPerProduct);\n }\n\n /**\n * @notice Updates the protocol pauser address. Zero address defaults to owner(0)\n * @param newPauser New protocol pauser address\n */\n function updatePauser(address newPauser) public onlyOwner(0) {\n _pauser.store(newPauser);\n emit PauserUpdated(newPauser);\n }\n\n /**\n * @notice Updates the protocol paused state\n * @param newPaused New protocol paused state\n */\n function updatePaused(bool newPaused) public onlyPauser {\n _paused.store(newPaused);\n emit PausedUpdated(newPaused);\n }\n\n /**\n * @notice Returns whether a contract is a product\n * @param product Contract address to check\n * @return Whether a contract is a product\n */\n function isProduct(IProduct product) external view returns (bool) {\n return coordinatorFor[product] != 0;\n }\n\n /**\n * @notice Returns coordinator state for coordinator `coordinatorId`\n * @param coordinatorId Coordinator to return for\n * @return Coordinator state\n */\n function coordinators(uint256 coordinatorId) external view returns (Coordinator memory) {\n return _coordinators[coordinatorId];\n }\n\n /**\n * @notice Returns the pending owner of the protocol\n * @return Owner of the protocol\n */\n function pendingOwner() public view returns (address) {\n return pendingOwner(0);\n }\n\n /**\n * @notice Returns the pending owner of the coordinator `coordinatorId`\n * @param coordinatorId Coordinator to return for\n * @return Pending owner of the coordinator\n */\n function pendingOwner(uint256 coordinatorId) public view returns (address) {\n return _coordinators[coordinatorId].pendingOwner;\n }\n\n /**\n * @notice Returns the owner of the protocol\n * @return Owner of the protocol\n */\n function owner() public view returns (address) {\n return owner(0);\n }\n\n /**\n * @notice Returns the owner of the coordinator `coordinatorId`\n * @param coordinatorId Coordinator to return for\n * @return Owner of the coordinator\n */\n function owner(uint256 coordinatorId) public view returns (address) {\n return _coordinators[coordinatorId].owner;\n }\n\n /**\n * @notice Returns the owner of the product `product`\n * @param product Product to return for\n * @return Owner of the product\n */\n function owner(IProduct product) external view returns (address) {\n return owner(coordinatorFor[product]);\n }\n\n /**\n * @notice Returns the treasury of the protocol\n * @dev Defaults to the `owner` when `treasury` is unset\n * @return Treasury of the protocol\n */\n function treasury() external view returns (address) {\n return treasury(0);\n }\n\n /**\n * @notice Returns the treasury of the coordinator `coordinatorId`\n * @dev Defaults to the `owner` when `treasury` is unset\n * @param coordinatorId Coordinator to return for\n * @return Treasury of the coordinator\n */\n function treasury(uint256 coordinatorId) public view returns (address) {\n address _treasury = _coordinators[coordinatorId].treasury;\n return _treasury == address(0) ? owner(coordinatorId) : _treasury;\n }\n\n /**\n * @notice Returns the treasury of the product `product`\n * @dev Defaults to the `owner` when `treasury` is unset\n * @param product Product to return for\n * @return Treasury of the product\n */\n function treasury(IProduct product) external view returns (address) {\n return treasury(coordinatorFor[product]);\n }\n\n /// @dev Only allow owner of `coordinatorId` to call\n modifier onlyOwner(uint256 coordinatorId) {\n if (msg.sender != owner(coordinatorId)) revert ControllerNotOwnerError(coordinatorId);\n\n _;\n }\n\n /// @dev Only allow the pauser to call\n modifier onlyPauser {\n if (msg.sender != pauser()) revert ControllerNotPauserError();\n\n _;\n }\n}\n" - }, - "contracts/incentivizer/Incentivizer.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/root/control/unstructured/UInitializable.sol\";\nimport \"@equilibria/root/control/unstructured/UReentrancyGuard.sol\";\nimport \"../interfaces/IIncentivizer.sol\";\nimport \"../interfaces/IController.sol\";\nimport \"../controller/UControllerProvider.sol\";\nimport \"./types/ProductManager.sol\";\n\n/**\n * @title Incentivizer\n * @notice Manages logic and state for all incentive programs in the protocol.\n */\ncontract Incentivizer is IIncentivizer, UInitializable, UControllerProvider, UReentrancyGuard {\n /// @dev Product management state\n mapping(IProduct => ProductManager) private _products;\n\n /// @dev Fees that have been collected, but remain unclaimed\n mapping(Token18 => UFixed18) public fees;\n\n /**\n * @notice Initializes the contract state\n * @dev Must be called atomically as part of the upgradeable proxy deployment to\n * avoid front-running\n * @param controller_ Factory contract address\n */\n function initialize(IController controller_) external initializer(1) {\n __UControllerProvider__initialize(controller_);\n __UReentrancyGuard__initialize();\n }\n\n /**\n * @notice Creates a new incentive program\n * @dev Must be called as the product or protocol owner\n * @param product The product to create the new program on\n * @param programInfo Parameters for the new program\n * @return programId New program's ID\n */\n function create(IProduct product, ProgramInfo calldata programInfo)\n external\n nonReentrant\n isProduct(product)\n notPaused\n onlyOwner(programInfo.coordinatorId)\n returns (uint256 programId) {\n IController _controller = controller();\n\n // Validate\n if (programInfo.coordinatorId != 0 && programInfo.coordinatorId != _controller.coordinatorFor(product))\n revert IncentivizerNotAllowedError(product);\n if (active(product) >= _controller.programsPerProduct())\n revert IncentivizerTooManyProgramsError();\n ProgramInfoLib.validate(programInfo);\n\n // Take fee\n (ProgramInfo memory newProgramInfo, UFixed18 programFeeAmount) = ProgramInfoLib.deductFee(programInfo, _controller.incentivizationFee());\n fees[newProgramInfo.token] = fees[newProgramInfo.token].add(programFeeAmount);\n\n // Register program\n programId = _products[product].register(newProgramInfo);\n\n // Charge creator\n newProgramInfo.token.pull(msg.sender, programInfo.amount.sum());\n\n emit ProgramCreated(\n product,\n programId,\n newProgramInfo,\n programFeeAmount\n );\n }\n\n /**\n * @notice Completes an in-progress program early\n * @dev Must be called as the program owner\n * @param product Product that the program is running on\n * @param programId Program to complete early\n */\n function complete(IProduct product, uint256 programId)\n external\n nonReentrant\n isProgram(product, programId)\n notPaused\n onlyProgramOwner(product, programId)\n {\n ProductManagerLib.SyncResult memory syncResult = _products[product].complete(product, programId);\n _handleSyncResult(product, syncResult);\n }\n\n /**\n * @notice Starts and completes programs as they become available\n * @dev Called every settle() from each product\n * @param currentOracleVersion The preloaded current oracle version\n */\n function sync(IOracleProvider.OracleVersion memory currentOracleVersion) external onlyProduct {\n IProduct product = IProduct(msg.sender);\n\n ProductManagerLib.SyncResult[] memory syncResults = _products[product].sync(product, currentOracleVersion);\n for (uint256 i = 0; i < syncResults.length; i++) {\n _handleSyncResult(product, syncResults[i]);\n }\n }\n\n /**\n * @notice Handles refunding and event emitting on program start and completion\n * @param product Product that the program is running on\n * @param syncResult The data from the sync event to handle\n */\n function _handleSyncResult(IProduct product, ProductManagerLib.SyncResult memory syncResult) private {\n uint256 programId = syncResult.programId;\n if (!syncResult.refundAmount.isZero())\n _products[product].token(programId).push(treasury(product, programId), syncResult.refundAmount);\n if (syncResult.versionStarted != 0)\n emit ProgramStarted(product, programId, syncResult.versionStarted);\n if (syncResult.versionComplete != 0)\n emit ProgramComplete(product, programId, syncResult.versionComplete);\n }\n\n /**\n * @notice Settles unsettled balance for `account`\n * @dev Called immediately proceeding a position update in the corresponding product\n * @param account Account to sync\n * @param currentOracleVersion The preloaded current oracle version\n */\n function syncAccount(\n address account,\n IOracleProvider.OracleVersion memory currentOracleVersion\n ) external onlyProduct {\n IProduct product = IProduct(msg.sender);\n _products[product].syncAccount(product, account, currentOracleVersion);\n }\n\n /**\n * @notice Claims all of `msg.sender`'s rewards for `product` programs\n * @param product Product to claim rewards for\n * @param programIds Programs to claim rewards for\n */\n function claim(IProduct product, uint256[] calldata programIds)\n external\n nonReentrant\n {\n _claimProduct(product, programIds);\n }\n\n /**\n * @notice Claims all of `msg.sender`'s rewards for a specific program\n * @param products Products to claim rewards for\n * @param programIds Programs to claim rewards for\n */\n function claim(IProduct[] calldata products, uint256[][] calldata programIds)\n external\n nonReentrant\n {\n if (products.length != programIds.length) revert IncentivizerBatchClaimArgumentMismatchError();\n for (uint256 i; i < products.length; i++) {\n _claimProduct(products[i], programIds[i]);\n }\n }\n\n /**\n * @notice Claims all of `msg.sender`'s rewards for `product` programs\n * @dev Internal helper with validation checks\n * @param product Product to claim rewards for\n * @param programIds Programs to claim rewards for\n */\n function _claimProduct(IProduct product, uint256[] memory programIds)\n private\n isProduct(product)\n notPaused\n settleForAccount(msg.sender, product)\n {\n for (uint256 i; i < programIds.length; i++) {\n _claimProgram(product, programIds[i]);\n }\n }\n\n /**\n * @notice Claims all of `msg.sender`'s rewards for `programId` on `product`\n * @dev Internal helper with validation checks\n * @param product Product to claim rewards for\n * @param programId Program to claim rewards for\n */\n function _claimProgram(IProduct product, uint256 programId)\n private\n isProgram(product, programId)\n {\n ProductManager storage productManager = _products[product];\n UFixed18 claimAmount = productManager.claim(msg.sender, programId);\n productManager.token(programId).push(msg.sender, claimAmount);\n emit Claim(product, msg.sender, programId, claimAmount);\n }\n\n /**\n * @notice Claims all `tokens` fees to the protocol treasury\n * @param tokens Tokens to claim fees for\n */\n function claimFee(Token18[] calldata tokens) external notPaused {\n for(uint256 i; i < tokens.length; i++) {\n Token18 token = tokens[i];\n UFixed18 amount = fees[token];\n\n fees[token] = UFixed18Lib.ZERO;\n token.push(controller().treasury(), amount);\n\n emit FeeClaim(token, amount);\n }\n }\n\n /**\n * @notice Returns the quantity of active programs for a given product\n * @param product Product to check for\n * @return Number of active programs\n */\n function active(IProduct product) public view returns (uint256) {\n return _products[product].active();\n }\n\n /**\n * @notice Returns the quantity of programs for a given product\n * @param product Product to check for\n * @return Number of programs (inactive or active)\n */\n function count(IProduct product) external view returns (uint256) {\n return _products[product].programInfos.length;\n }\n\n /**\n * @notice Returns program info for program `programId`\n * @param product Product to return for\n * @param programId Program to return for\n * @return Program info\n */\n function programInfos(IProduct product, uint256 programId) external view returns (ProgramInfo memory) {\n return _products[product].programInfos[programId];\n }\n\n /**\n * @notice Returns `account`'s total unclaimed rewards for a specific program\n * @param product Product to return for\n * @param account Account to return for\n * @param programId Program to return for\n * @return `account`'s total unclaimed rewards for `programId`\n */\n function unclaimed(IProduct product, address account, uint256 programId) external view returns (UFixed18) {\n return _products[product].unclaimed(account, programId);\n }\n\n /**\n * @notice Returns available rewards for a specific program\n * @param product Product to return for\n * @param programId Program to return for\n * @return Available rewards for `programId`\n */\n function available(IProduct product, uint256 programId) external view returns (UFixed18) {\n return _products[product].programs[programId].available;\n }\n\n /**\n * @notice Returns the version started for a specific program\n * @param product Product to return for\n * @param programId Program to return for\n * @return The version started for `programId`\n */\n function versionStarted(IProduct product, uint256 programId) external view returns (uint256) {\n return _products[product].programs[programId].versionStarted;\n }\n\n /**\n * @notice Returns the version completed for a specific program\n * @param product Product to return for\n * @param programId Program to return for\n * @return The version completed for `programId`\n */\n function versionComplete(IProduct product, uint256 programId) external view returns (uint256) {\n return _products[product].programs[programId].versionComplete;\n }\n\n /**\n * @notice Returns the owner of a specific program\n * @param product Product to return for\n * @param programId Program to return for\n * @return The owner of `programId`\n */\n function owner(IProduct product, uint256 programId) public view returns (address) {\n return controller().owner(_products[product].programInfos[programId].coordinatorId);\n }\n\n /**\n * @notice Returns the treasury of a specific program\n * @param product Product to return for\n * @param programId Program to return for\n * @return The treasury of `programId`\n */\n function treasury(IProduct product, uint256 programId) public view returns (address) {\n return controller().treasury(_products[product].programInfos[programId].coordinatorId);\n }\n\n /// @dev Helper to fully settle an account's state\n modifier settleForAccount(address account, IProduct product) {\n product.settleAccount(account);\n\n _;\n }\n\n /// @dev Only allow the owner of `programId` to call\n modifier onlyProgramOwner(IProduct product, uint256 programId) {\n if (msg.sender != owner(product, programId)) revert IncentivizerNotProgramOwnerError(product, programId);\n\n _;\n }\n\n /// @dev Only allow a valid `programId`\n modifier isProgram(IProduct product, uint256 programId) {\n if (!_products[product].valid(programId)) revert IncentivizerInvalidProgramError(product, programId);\n\n _;\n }\n}\n" - }, - "contracts/incentivizer/types/ProductManager.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport \"./Program.sol\";\n\n/// @dev ProductManager type\nstruct ProductManager {\n /// @dev Static program state\n ProgramInfo[] programInfos;\n\n /// @dev Dynamic program state\n mapping(uint256 => Program) programs;\n\n /// @dev Mapping of all active programs for each product\n EnumerableSet.UintSet activePrograms;\n\n /// @dev Mapping of all active programs for each user\n mapping(address => EnumerableSet.UintSet) activeProgramsFor;\n\n /// @dev Mapping of the next program to watch for for each user\n mapping(address => uint256) nextProgramFor;\n}\nusing ProductManagerLib for ProductManager global;\n\n/**\n * @title ProductManagerLib\n * @notice Library that manages each product's incentivization state and logic.\n */\nlibrary ProductManagerLib {\n using EnumerableSet for EnumerableSet.UintSet;\n\n /// @dev Result data for a sync event\n struct SyncResult {\n /// @dev The programId that was updated\n uint256 programId;\n\n /// @dev If non-zero, the new versionStart value of the program\n uint256 versionStarted;\n\n /// @dev If non-zero, the new versionComplete value of the program\n uint256 versionComplete;\n\n /// @dev If non-zero, the amount to refund due to completion\n UFixed18 refundAmount;\n }\n\n /**\n * @notice Registers a new program on this product\n * @param self The Product manager to operate on\n * @param programInfo The static program info\n * @return programId The new program's ID\n */\n function register(\n ProductManager storage self,\n ProgramInfo memory programInfo\n ) internal returns (uint256 programId) {\n programId = self.programInfos.length;\n self.programInfos.push(programInfo);\n self.programs[programId].initialize(programInfo);\n self.activePrograms.add(programId);\n }\n\n /**\n * @notice Syncs this product with the latest data\n * @param self The Program manager to operate on\n * @param product This Product\n * @param currentOracleVersion The preloaded current oracle version\n */\n function sync(\n ProductManager storage self,\n IProduct product,\n IOracleProvider.OracleVersion memory currentOracleVersion\n ) internal returns (SyncResult[] memory results) {\n\n uint256[] memory activeProgramIds = self.activePrograms.values();\n results = new SyncResult[](activeProgramIds.length);\n\n for (uint256 i; i < activeProgramIds.length; i++) {\n // Load program\n uint256 programId = activeProgramIds[i];\n ProgramInfo memory programInfo = self.programInfos[programId];\n Program storage program = self.programs[programId];\n\n // If timestamp-started, grab current version (first version after start)\n uint256 versionStarted;\n if (program.versionStarted == 0 && programInfo.isStarted(currentOracleVersion.timestamp)) {\n versionStarted = _start(self, programId, currentOracleVersion);\n }\n\n // If timestamp-completed, grab previous version (last version before completion)\n uint256 versionComplete;\n UFixed18 refundAmount;\n if (program.versionComplete == 0 && programInfo.isComplete(currentOracleVersion.timestamp)) {\n (versionComplete, refundAmount) = _complete(self, product, programId);\n }\n\n // Save result\n results[i] = SyncResult(programId, versionStarted, versionComplete, refundAmount);\n }\n }\n\n /**\n * @notice Syncs an account for this product with the latest data\n * @dev Assumes that sync() has already been called as part of the transaction flow\n * @param self The Program manager to operate on\n * @param product This Product\n * @param account The account to sync\n * @param currentOracleVersion The preloaded current oracle version\n */\n function syncAccount(\n ProductManager storage self,\n IProduct product,\n address account,\n IOracleProvider.OracleVersion memory currentOracleVersion\n ) internal {\n\n // Add any unseen programs\n uint256 fromProgramId = self.nextProgramFor[account];\n uint256 toProgramId = self.programInfos.length;\n for (uint256 programId = fromProgramId; programId < toProgramId; programId++) {\n self.activeProgramsFor[account].add(programId);\n }\n self.nextProgramFor[account] = toProgramId;\n\n // Settle programs\n uint256[] memory activeProgramIds = self.activeProgramsFor[account].values();\n for (uint256 i; i < activeProgramIds.length; i++) {\n uint256 programId = activeProgramIds[i];\n Program storage program = self.programs[programId];\n program.settle(product, self.programInfos[programId], account, currentOracleVersion);\n if (!self.activePrograms.contains(programId) && currentOracleVersion.version >= program.versionComplete) {\n self.activeProgramsFor[account].remove(programId);\n }\n }\n }\n\n /**\n * @notice Returns the quantity of active programs for this product\n * @param self The Program manager to operate on\n * @return The quantity of active programs\n */\n function active(ProductManager storage self) internal view returns (uint256) {\n return self.activePrograms.length();\n }\n\n /**\n * @notice Forces the specified program to complete if it hasn't already\n * @param self The Program manager to operate on\n * @param product The Product to operate on\n * @param programId The Program to complete\n * @return result The sync result data from completion\n */\n function complete(\n ProductManager storage self,\n IProduct product,\n uint256 programId\n ) internal returns (SyncResult memory result) {\n Program storage program = self.programs[programId];\n\n // If not started, start first\n if (program.versionStarted == 0) {\n result.versionStarted = _start(self, programId, product.currentVersion());\n }\n\n // If not completed already, complete\n if (program.versionComplete == 0) {\n (result.versionComplete, result.refundAmount) = _complete(self, product, programId);\n }\n }\n\n /**\n * @notice Starts the program\n * @dev Rewards do not start accruing until the program has started\n * Internal helper, does not prevent incorrectly-timed starting\n * @param self The Program manager to operate on\n * @param programId The Program to start\n * @param currentOracleVersion The effective starting oracle version\n * @return versionStarted The version that the program started\n */\n function _start(\n ProductManager storage self,\n uint256 programId,\n IOracleProvider.OracleVersion memory currentOracleVersion\n ) internal returns (uint256 versionStarted) {\n versionStarted = currentOracleVersion.version;\n self.programs[programId].start(currentOracleVersion.version);\n }\n\n /**\n * @notice Completes the program\n * @dev Completion stops rewards from accruing\n * Internal helper, does not prevent incorrectly-timed completion\n * @param self The Program manager to operate on\n * @param product The Product to operate on\n * @param programId The Program to complete\n * @return versionComplete The version that the program complete\n * @return refundAmount The refunded token amount\n */\n function _complete(\n ProductManager storage self,\n IProduct product,\n uint256 programId\n ) internal returns (uint256 versionComplete, UFixed18 refundAmount) {\n (versionComplete, refundAmount) = self.programs[programId].complete(product, self.programInfos[programId]);\n self.activePrograms.remove(programId);\n }\n\n /**\n * @notice Claims all of `account`'s rewards for a specific program\n * @param self The Program manager to operate on\n * @param account Account to claim rewards for\n * @param programId Program to claim rewards for\n * @return Amount claimed\n */\n function claim(ProductManager storage self, address account, uint256 programId) internal returns (UFixed18) {\n return self.programs[programId].claim(account);\n }\n\n /**\n * @notice Returns the total amount of unclaimed rewards for account `account`\n * @param self The Program manager to operate on\n * @param account The account to check for\n * @param programId The Program to check for\n * @return Total amount of unclaimed rewards for account\n */\n function unclaimed(ProductManager storage self, address account, uint256 programId) internal view returns (UFixed18) {\n if (!valid(self, programId)) return (UFixed18Lib.ZERO);\n return self.programs[programId].settled[account];\n }\n\n /**\n * @notice Returns the token denominatino of the program's rewards\n * @param self The Program manager to operate on\n * @param programId The Program to check for\n * @return The token for the program\n */\n function token(ProductManager storage self, uint256 programId) internal view returns (Token18) {\n return self.programInfos[programId].token;\n }\n\n /**\n * @notice Returns whether the supplied programId is valid\n * @param self The Program manager to operate on\n * @param programId The Program to check for\n * @return Whether the supplied programId is valid\n */\n function valid(ProductManager storage self, uint256 programId) internal view returns (bool) {\n return programId < self.programInfos.length;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/structs/EnumerableSet.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/structs/EnumerableSet.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping(bytes32 => uint256) _indexes;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (lastIndex != toDeleteIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._values[toDeleteIndex] = lastValue;\n // Update the index for the moved value\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the index for the deleted slot\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._indexes[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n return _values(set._inner);\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n assembly {\n result := store\n }\n\n return result;\n }\n}\n" - }, - "contracts/incentivizer/types/Program.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../../interfaces/types/ProgramInfo.sol\";\n\n/// @dev Program type\nstruct Program {\n /// @dev Mapping of latest rewards settled for each account\n mapping(address => UFixed18) settled;\n\n /// @dev Total amount of rewards yet to be claimed\n UFixed18 available;\n\n /// @dev Oracle version that the program started, 0 when hasn't started\n uint256 versionStarted;\n\n /// @dev Oracle version that the program completed, 0 is still ongoing\n uint256 versionComplete;\n}\nusing ProgramLib for Program global;\n\n/**\n * @title ProgramLib\n * @notice Library that manages all of the mutable state for a single incentivization program.\n */\nlibrary ProgramLib {\n /**\n * @notice Initializes the program state\n * @param self The Program to operate on\n * @param programInfo Static program information\n */\n function initialize(Program storage self, ProgramInfo memory programInfo) internal {\n self.available = programInfo.amount.sum();\n }\n\n /**\n * @notice Starts the program\n * @dev Rewards do not start accruing until the program has started accruing\n * Does not stop double-starting\n * @param self The Program to operate on\n * @param oracleVersion The effective starting oracle version\n */\n function start(Program storage self, uint256 oracleVersion) internal {\n self.versionStarted = oracleVersion;\n }\n\n /**\n * @notice Completes the program\n * @dev Completion stops rewards from accruing\n * Does not prevent double-completion\n * @param self The Program to operate on\n * @param product The Product to operate on\n * @param programInfo Static program information\n * @return versionComplete The version that the program completed on\n * @return refundAmount The refund amount from the program\n */\n function complete(\n Program storage self,\n IProduct product,\n ProgramInfo memory programInfo\n ) internal returns (uint256 versionComplete, UFixed18 refundAmount) {\n uint256 versionStarted = self.versionStarted;\n versionComplete = Math.max(versionStarted, product.latestVersion());\n self.versionComplete = versionComplete;\n\n IOracleProvider.OracleVersion memory fromOracleVersion = product.atVersion(versionStarted);\n IOracleProvider.OracleVersion memory toOracleVersion = product.atVersion(versionComplete);\n\n uint256 inactiveDuration = programInfo.duration - (toOracleVersion.timestamp - fromOracleVersion.timestamp);\n refundAmount = programInfo.amount.sum().muldiv(inactiveDuration, programInfo.duration);\n self.available = self.available.sub(refundAmount);\n }\n\n /**\n * @notice Settles unclaimed rewards for account `account`\n * @param self The Program to operate on\n * @param product The Product to operate on\n * @param programInfo Static program information\n * @param account The account to settle for\n * @param currentOracleVersion The preloaded current oracle version\n */\n function settle(\n Program storage self,\n IProduct product,\n ProgramInfo memory programInfo,\n address account,\n IOracleProvider.OracleVersion memory currentOracleVersion\n ) internal {\n UFixed18 unsettledAmount = _unsettled(self, product, programInfo, account, currentOracleVersion);\n self.settled[account] = self.settled[account].add(unsettledAmount);\n self.available = self.available.sub(unsettledAmount);\n }\n\n /**\n * @notice Claims settled rewards for account `account`\n * @param self The Program to operate on\n * @param account The account to claim for\n */\n function claim(Program storage self, address account) internal returns (UFixed18 claimedAmount) {\n claimedAmount = self.settled[account];\n self.settled[account] = UFixed18Lib.ZERO;\n }\n\n /**\n * @notice Returns the unsettled amount of unclaimed rewards for account `account`\n * @dev Clears when a program is closed\n * Assumes that position is unchanged since last settlement, must be settled prior to user position update\n * @param self The Program to operate on\n * @param product The Product to operate on\n * @param programInfo Static program information\n * @param account The account to claim for\n * @param currentOracleVersion Current oracle version\n * @return amount Amount of unsettled rewards for account\n */\n function _unsettled(\n Program storage self,\n IProduct product,\n ProgramInfo memory programInfo,\n address account,\n IOracleProvider.OracleVersion memory currentOracleVersion\n ) private view returns (UFixed18 amount) {\n // program stage overview\n //\n // V = latest user settle version, V' = current user settle version\n // S = versionStarted, E = versionEnded\n //\n // (1) V V' S E program not yet started\n // (2) V S V' E use versionStarted -> V' for userShareDelta\n // (3) S V V' E use V -> V' for userShareDelta\n // (4) S V E V' use V -> versionComplete for userShareDelta\n // (5) S E V V' program already completed\n // (6) V S E V' use versionStarted -> versionComplete for userShareDelta\n //\n // NOTE: V == S and V' == E both default to the inner case\n\n (uint256 _versionStarted, uint256 _versionComplete) = (\n self.versionStarted == 0 ? currentOracleVersion.version : self.versionStarted, // start must be no earlier than current version\n self.versionComplete == 0 ? type(uint256).max : self.versionComplete // we don't know when completion occurs\n );\n\n // accruing must start between self.versionStarted and self.versionComplete\n uint256 fromVersion = Math.min(_versionComplete, Math.max(_versionStarted, product.latestVersion(account)));\n // accruing must complete between self.versionStarted and self.versionComplete, we know self.versionStarted must be no earlier than current version\n uint256 toVersion = Math.min(_versionComplete, currentOracleVersion.version);\n\n Accumulator memory globalShareDelta = product.shareAtVersion(toVersion).sub(product.shareAtVersion(fromVersion));\n Accumulator memory computedUserShareDelta = product.position(account).mul(globalShareDelta);\n amount = UFixed18Lib.from(programInfo.amountPerShare().mul(computedUserShareDelta).sum());\n }\n}\n" - }, - "@equilibria/emptyset-batcher/batcher/Batcher.sol": { - "content": "//SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"@equilibria/root/token/types/Token6.sol\";\nimport \"@equilibria/root/control/unstructured/UOwnable.sol\";\nimport \"../interfaces/IBatcher.sol\";\n\nabstract contract Batcher is IBatcher, UOwnable {\n using UFixed18Lib for UFixed18;\n using Token18Lib for Token18;\n using Token6Lib for Token6;\n\n IEmptySetReserve public immutable RESERVE;\n Token18 public immutable DSU;\n Token6 public immutable USDC;\n\n constructor(IEmptySetReserve reserve, Token18 dsu, Token6 usdc) {\n RESERVE = reserve;\n DSU = dsu;\n USDC = usdc;\n\n DSU.approve(address(RESERVE));\n USDC.approve(address(RESERVE));\n\n __UOwnable__initialize();\n }\n\n function totalBalance() public view returns (UFixed18) {\n return DSU.balanceOf().add(USDC.balanceOf());\n }\n\n function wrap(UFixed18 amount, address to) external {\n _wrap(amount, to);\n emit Wrap(to, amount);\n }\n\n function _wrap(UFixed18 amount, address to) virtual internal {\n USDC.pull(msg.sender, amount, true);\n DSU.push(to, amount);\n }\n\n function unwrap(UFixed18 amount, address to) external {\n _unwrap(amount, to);\n emit Unwrap(to, amount);\n }\n\n function _unwrap(UFixed18 amount, address to) virtual internal {\n DSU.pull(msg.sender, amount);\n USDC.push(to, amount);\n }\n\n function rebalance() external {\n (UFixed18 usdcBalance, UFixed18 dsuBalance) = (USDC.balanceOf(), DSU.balanceOf());\n\n _rebalance(USDC.balanceOf(), DSU.balanceOf());\n\n (UFixed18 oldBalance, UFixed18 newBalance) = (usdcBalance.add(dsuBalance), totalBalance());\n if (!oldBalance.eq(newBalance)) revert BatcherBalanceMismatchError(oldBalance, newBalance);\n\n emit Rebalance(usdcBalance, UFixed18Lib.ZERO);\n }\n\n function _rebalance(UFixed18 usdcBalance, UFixed18 dsuBalance) virtual internal;\n\n function close() external onlyOwner {\n UFixed18 usdcBalance = USDC.balanceOf();\n if (!usdcBalance.isZero()) RESERVE.mint(usdcBalance);\n\n UFixed18 dsuBalance = DSU.balanceOf();\n UFixed18 repayAmount = UFixed18Lib.min(RESERVE.debt(address(this)), dsuBalance);\n UFixed18 returnAmount = dsuBalance.sub(repayAmount);\n\n RESERVE.repay(address(this), repayAmount);\n if (!returnAmount.isZero()) DSU.push(address(RESERVE), dsuBalance.sub(repayAmount));\n\n emit Close(dsuBalance);\n }\n}\n\ninterface IEmptySetReserve {\n function debt(address borrower) external view returns (UFixed18);\n function repay(address borrower, UFixed18 amount) external;\n function mint(UFixed18 amount) external;\n function redeem(UFixed18 amount) external;\n}\n" - }, - "@equilibria/root/token/types/Token6.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"../../number/types/UFixed18.sol\";\n\n/// @dev Token6\ntype Token6 is address;\nusing Token6Lib for Token6 global;\ntype Token6Storage is bytes32;\nusing Token6StorageLib for Token6Storage global;\n\n/**\n * @title Token6Lib\n * @notice Library to manage 6-decimal ERC20s that is compliant with the fixed-decimal types.\n * @dev Automatically converts from Base-6 token amounts to Base-18 UFixed18 amounts, with optional rounding\n */\nlibrary Token6Lib {\n using SafeERC20 for IERC20;\n\n Token6 public constant ZERO = Token6.wrap(address(0));\n\n uint256 private constant OFFSET = 1e12;\n\n /**\n * @notice Returns whether a token is the zero address\n * @param self Token to check for\n * @return Whether the token is the zero address\n */\n function isZero(Token6 self) internal pure returns (bool) {\n return Token6.unwrap(self) == Token6.unwrap(ZERO);\n }\n\n /**\n * @notice Returns whether the two tokens are equal\n * @param a First token to compare\n * @param b Second token to compare\n * @return Whether the two tokens are equal\n */\n function eq(Token6 a, Token6 b) internal pure returns (bool) {\n return Token6.unwrap(a) == Token6.unwrap(b);\n }\n\n /**\n * @notice Approves `grantee` to spend infinite tokens from the caller\n * @param self Token to transfer\n * @param grantee Address to allow spending\n */\n function approve(Token6 self, address grantee) internal {\n IERC20(Token6.unwrap(self)).safeApprove(grantee, type(uint256).max);\n }\n\n /**\n * @notice Approves `grantee` to spend `amount` tokens from the caller\n * @dev There are important race conditions to be aware of when using this function\n with values other than 0. This will revert if moving from non-zero to non-zero amounts\n See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/a55b7d13722e7ce850b626da2313f3e66ca1d101/contracts/token/ERC20/IERC20.sol#L57\n * @param self Token to transfer\n * @param grantee Address to allow spending\n * @param amount Amount of tokens to approve to spend\n */\n function approve(Token6 self, address grantee, UFixed18 amount) internal {\n IERC20(Token6.unwrap(self)).safeApprove(grantee, toTokenAmount(amount, false));\n }\n\n /**\n * @notice Approves `grantee` to spend `amount` tokens from the caller\n * @dev There are important race conditions to be aware of when using this function\n with values other than 0. This will revert if moving from non-zero to non-zero amounts\n See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/a55b7d13722e7ce850b626da2313f3e66ca1d101/contracts/token/ERC20/IERC20.sol#L57\n * @param self Token to transfer\n * @param grantee Address to allow spending\n * @param amount Amount of tokens to approve to spend\n * @param roundUp Whether to round decimal token amount up to the next unit\n */\n function approve(Token6 self, address grantee, UFixed18 amount, bool roundUp) internal {\n IERC20(Token6.unwrap(self)).safeApprove(grantee, toTokenAmount(amount, roundUp));\n }\n\n /**\n * @notice Transfers all held tokens from the caller to the `recipient`\n * @param self Token to transfer\n * @param recipient Address to receive the tokens\n */\n function push(Token6 self, address recipient) internal {\n push(self, recipient, balanceOf(self, address(this)));\n }\n\n /**\n * @notice Transfers `amount` tokens from the caller to the `recipient`\n * @param self Token to transfer\n * @param recipient Address to transfer tokens to\n * @param amount Amount of tokens to transfer\n */\n function push(Token6 self, address recipient, UFixed18 amount) internal {\n IERC20(Token6.unwrap(self)).safeTransfer(recipient, toTokenAmount(amount, false));\n }\n\n /**\n * @notice Transfers `amount` tokens from the caller to the `recipient`\n * @param self Token to transfer\n * @param recipient Address to transfer tokens to\n * @param amount Amount of tokens to transfer\n * @param roundUp Whether to round decimal token amount up to the next unit\n */\n function push(Token6 self, address recipient, UFixed18 amount, bool roundUp) internal {\n IERC20(Token6.unwrap(self)).safeTransfer(recipient, toTokenAmount(amount, roundUp));\n }\n\n /**\n * @notice Transfers `amount` tokens from the `benefactor` to the caller\n * @dev Reverts if trying to pull Ether\n * @param self Token to transfer\n * @param benefactor Address to transfer tokens from\n * @param amount Amount of tokens to transfer\n */\n function pull(Token6 self, address benefactor, UFixed18 amount) internal {\n IERC20(Token6.unwrap(self)).safeTransferFrom(benefactor, address(this), toTokenAmount(amount, false));\n }\n\n /**\n * @notice Transfers `amount` tokens from the `benefactor` to the caller\n * @dev Reverts if trying to pull Ether\n * @param self Token to transfer\n * @param benefactor Address to transfer tokens from\n * @param amount Amount of tokens to transfer\n * @param roundUp Whether to round decimal token amount up to the next unit\n */\n function pull(Token6 self, address benefactor, UFixed18 amount, bool roundUp) internal {\n IERC20(Token6.unwrap(self)).safeTransferFrom(benefactor, address(this), toTokenAmount(amount, roundUp));\n }\n\n /**\n * @notice Transfers `amount` tokens from the `benefactor` to `recipient`\n * @dev Reverts if trying to pull Ether\n * @param self Token to transfer\n * @param benefactor Address to transfer tokens from\n * @param recipient Address to transfer tokens to\n * @param amount Amount of tokens to transfer\n */\n function pullTo(Token6 self, address benefactor, address recipient, UFixed18 amount) internal {\n IERC20(Token6.unwrap(self)).safeTransferFrom(benefactor, recipient, toTokenAmount(amount, false));\n }\n\n /**\n * @notice Transfers `amount` tokens from the `benefactor` to `recipient`\n * @dev Reverts if trying to pull Ether\n * @param self Token to transfer\n * @param benefactor Address to transfer tokens from\n * @param recipient Address to transfer tokens to\n * @param amount Amount of tokens to transfer\n * @param roundUp Whether to round decimal token amount up to the next unit\n */\n function pullTo(Token6 self, address benefactor, address recipient, UFixed18 amount, bool roundUp) internal {\n IERC20(Token6.unwrap(self)).safeTransferFrom(benefactor, recipient, toTokenAmount(amount, roundUp));\n }\n\n /**\n * @notice Returns the name of the token\n * @param self Token to check for\n * @return Token name\n */\n function name(Token6 self) internal view returns (string memory) {\n return IERC20Metadata(Token6.unwrap(self)).name();\n }\n\n /**\n * @notice Returns the symbol of the token\n * @param self Token to check for\n * @return Token symbol\n */\n function symbol(Token6 self) internal view returns (string memory) {\n return IERC20Metadata(Token6.unwrap(self)).symbol();\n }\n\n /**\n * @notice Returns the `self` token balance of the caller\n * @param self Token to check for\n * @return Token balance of the caller\n */\n function balanceOf(Token6 self) internal view returns (UFixed18) {\n return balanceOf(self, address(this));\n }\n\n /**\n * @notice Returns the `self` token balance of `account`\n * @param self Token to check for\n * @param account Account to check\n * @return Token balance of the account\n */\n function balanceOf(Token6 self, address account) internal view returns (UFixed18) {\n return fromTokenAmount(IERC20(Token6.unwrap(self)).balanceOf(account));\n }\n\n /**\n * @notice Converts the unsigned fixed-decimal amount into the token amount according to\n * it's defined decimals\n * @dev Provides the ability to \"round up\" the token amount which is useful in situations where\n * are swapping one token for another and don't want to give away \"free\" units due to rounding\n * errors in the favor of the user.\n * @param amount Amount to convert\n * @param roundUp Whether to round decimal token amount up to the next unit\n * @return Normalized token amount\n */\n function toTokenAmount(UFixed18 amount, bool roundUp) private pure returns (uint256) {\n return roundUp ? Math.ceilDiv(UFixed18.unwrap(amount), OFFSET) : UFixed18.unwrap(amount) / OFFSET;\n }\n\n /**\n * @notice Converts the token amount into the unsigned fixed-decimal amount according to\n * it's defined decimals\n * @param amount Token amount to convert\n * @return Normalized unsigned fixed-decimal amount\n */\n function fromTokenAmount(uint256 amount) private pure returns (UFixed18) {\n return UFixed18.wrap(amount * OFFSET);\n }\n}\n\nlibrary Token6StorageLib {\n function read(Token6Storage self) internal view returns (Token6 value) {\n assembly {\n value := sload(self)\n }\n }\n\n function store(Token6Storage self, Token6 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "@equilibria/root/control/unstructured/UOwnable.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"./UInitializable.sol\";\nimport \"../../storage/UStorage.sol\";\n\n/**\n * @title UOwnable\n * @notice Library to manage the ownership lifecycle of upgradeable contracts.\n * @dev This contract has been extended from the Open Zeppelin library to include an\n * unstructured storage pattern so that it can be safely mixed in with upgradeable\n * contracts without affecting their storage patterns through inheritance.\n */\nabstract contract UOwnable is UInitializable {\n event OwnerUpdated(address indexed newOwner);\n event PendingOwnerUpdated(address indexed newPendingOwner);\n\n error UOwnableNotOwnerError(address sender);\n error UOwnableNotPendingOwnerError(address sender);\n\n /// @dev The owner address\n AddressStorage private constant _owner = AddressStorage.wrap(keccak256(\"equilibria.root.UOwnable.owner\"));\n function owner() public view returns (address) { return _owner.read(); }\n\n /// @dev The pending owner address\n AddressStorage private constant _pendingOwner = AddressStorage.wrap(keccak256(\"equilibria.root.UOwnable.pendingOwner\"));\n function pendingOwner() public view returns (address) { return _pendingOwner.read(); }\n\n /**\n * @notice Initializes the contract setting `msg.sender` as the initial owner\n */\n function __UOwnable__initialize() internal onlyInitializer {\n _updateOwner(msg.sender);\n }\n\n /**\n * @notice Updates the new pending owner\n * @dev Can only be called by the current owner\n * New owner does not take affect until that address calls `acceptOwner()`\n * @param newPendingOwner New pending owner address\n */\n function updatePendingOwner(address newPendingOwner) public onlyOwner {\n _pendingOwner.store(newPendingOwner);\n emit PendingOwnerUpdated(newPendingOwner);\n }\n\n /**\n * @notice Accepts and transfers the ownership of the contract to the pending owner\n * @dev Can only be called by the pending owner to ensure correctness\n */\n function acceptOwner() external {\n if (msg.sender != pendingOwner()) revert UOwnableNotPendingOwnerError(msg.sender);\n\n _updateOwner(pendingOwner());\n updatePendingOwner(address(0));\n }\n\n /**\n * @notice Updates the owner address\n * @param newOwner New owner address\n */\n function _updateOwner(address newOwner) private {\n _owner.store(newOwner);\n emit OwnerUpdated(newOwner);\n }\n\n /// @dev Throws if called by any account other than the owner\n modifier onlyOwner() {\n if (owner() != msg.sender) revert UOwnableNotOwnerError(msg.sender);\n _;\n }\n}\n" - }, - "@equilibria/emptyset-batcher/interfaces/IBatcher.sol": { - "content": "//SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\n\ninterface IBatcher {\n event Wrap(address indexed to, UFixed18 amount);\n event Unwrap(address indexed to, UFixed18 amount);\n event Rebalance(UFixed18 newMinted, UFixed18 newRedeemed);\n event Close(UFixed18 amount);\n\n error BatcherNotImplementedError();\n error BatcherBalanceMismatchError(UFixed18 oldBalance, UFixed18 newBalance);\n\n function totalBalance() external view returns (UFixed18);\n function wrap(UFixed18 amount, address to) external;\n function unwrap(UFixed18 amount, address to) external;\n function rebalance() external;\n}\n" - }, - "contracts/test/TestnetReserve.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol\";\nimport \"@equilibria/emptyset-batcher/interfaces/IBatcher.sol\";\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"@equilibria/root/token/types/Token6.sol\";\n\ncontract TestnetReserve {\n Token18 public immutable DSU; // solhint-disable-line var-name-mixedcase\n Token6 public immutable USDC; // solhint-disable-line var-name-mixedcase\n\n // solhint-disable-next-line no-empty-blocks\n constructor(Token18 dsu_, Token6 usdc_) {\n DSU = dsu_;\n USDC = usdc_;\n }\n\n function mint(UFixed18 amount, address to) external {\n USDC.pull(msg.sender, amount, true);\n ERC20PresetMinterPauser(Token18.unwrap(DSU)).mint(to, UFixed18.unwrap(amount));\n }\n\n function redeem(UFixed18 amount, address to) external {\n DSU.pull(msg.sender, amount);\n ERC20Burnable(Token18.unwrap(DSU)).burn(UFixed18.unwrap(amount));\n USDC.push(to, amount, true);\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/presets/ERC20PresetMinterPauser.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20.sol\";\nimport \"../extensions/ERC20Burnable.sol\";\nimport \"../extensions/ERC20Pausable.sol\";\nimport \"../../../access/AccessControlEnumerable.sol\";\nimport \"../../../utils/Context.sol\";\n\n/**\n * @dev {ERC20} token, including:\n *\n * - ability for holders to burn (destroy) their tokens\n * - a minter role that allows for token minting (creation)\n * - a pauser role that allows to stop all token transfers\n *\n * This contract uses {AccessControl} to lock permissioned functions using the\n * different roles - head to its documentation for details.\n *\n * The account that deploys the contract will be granted the minter and pauser\n * roles, as well as the default admin role, which will let it grant both minter\n * and pauser roles to other accounts.\n *\n * _Deprecated in favor of https://wizard.openzeppelin.com/[Contracts Wizard]._\n */\ncontract ERC20PresetMinterPauser is Context, AccessControlEnumerable, ERC20Burnable, ERC20Pausable {\n bytes32 public constant MINTER_ROLE = keccak256(\"MINTER_ROLE\");\n bytes32 public constant PAUSER_ROLE = keccak256(\"PAUSER_ROLE\");\n\n /**\n * @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE` and `PAUSER_ROLE` to the\n * account that deploys the contract.\n *\n * See {ERC20-constructor}.\n */\n constructor(string memory name, string memory symbol) ERC20(name, symbol) {\n _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());\n\n _setupRole(MINTER_ROLE, _msgSender());\n _setupRole(PAUSER_ROLE, _msgSender());\n }\n\n /**\n * @dev Creates `amount` new tokens for `to`.\n *\n * See {ERC20-_mint}.\n *\n * Requirements:\n *\n * - the caller must have the `MINTER_ROLE`.\n */\n function mint(address to, uint256 amount) public virtual {\n require(hasRole(MINTER_ROLE, _msgSender()), \"ERC20PresetMinterPauser: must have minter role to mint\");\n _mint(to, amount);\n }\n\n /**\n * @dev Pauses all token transfers.\n *\n * See {ERC20Pausable} and {Pausable-_pause}.\n *\n * Requirements:\n *\n * - the caller must have the `PAUSER_ROLE`.\n */\n function pause() public virtual {\n require(hasRole(PAUSER_ROLE, _msgSender()), \"ERC20PresetMinterPauser: must have pauser role to pause\");\n _pause();\n }\n\n /**\n * @dev Unpauses all token transfers.\n *\n * See {ERC20Pausable} and {Pausable-_unpause}.\n *\n * Requirements:\n *\n * - the caller must have the `PAUSER_ROLE`.\n */\n function unpause() public virtual {\n require(hasRole(PAUSER_ROLE, _msgSender()), \"ERC20PresetMinterPauser: must have pauser role to unpause\");\n _unpause();\n }\n\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual override(ERC20, ERC20Pausable) {\n super._beforeTokenTransfer(from, to, amount);\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Burnable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20.sol\";\nimport \"../../../utils/Context.sol\";\n\n/**\n * @dev Extension of {ERC20} that allows token holders to destroy both their own\n * tokens and those that they have an allowance for, in a way that can be\n * recognized off-chain (via event analysis).\n */\nabstract contract ERC20Burnable is Context, ERC20 {\n /**\n * @dev Destroys `amount` tokens from the caller.\n *\n * See {ERC20-_burn}.\n */\n function burn(uint256 amount) public virtual {\n _burn(_msgSender(), amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, deducting from the caller's\n * allowance.\n *\n * See {ERC20-_burn} and {ERC20-allowance}.\n *\n * Requirements:\n *\n * - the caller must have allowance for ``accounts``'s tokens of at least\n * `amount`.\n */\n function burnFrom(address account, uint256 amount) public virtual {\n _spendAllowance(account, _msgSender(), amount);\n _burn(account, amount);\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/ERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.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 * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\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 ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => 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 * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\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 override 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 override 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 value {ERC20} uses, unless this function is\n * 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 override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override 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 `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` 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 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\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 `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `sender` to `recipient`.\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 * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n }\n _balances[to] += amount;\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` 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 function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/ERC20Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20.sol\";\nimport \"../../../security/Pausable.sol\";\n\n/**\n * @dev ERC20 token with pausable token transfers, minting and burning.\n *\n * Useful for scenarios such as preventing trades until the end of an evaluation\n * period, or having an emergency switch for freezing all token transfers in the\n * event of a large bug.\n */\nabstract contract ERC20Pausable is ERC20, Pausable {\n /**\n * @dev See {ERC20-_beforeTokenTransfer}.\n *\n * Requirements:\n *\n * - the contract must not be paused.\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual override {\n super._beforeTokenTransfer(from, to, amount);\n\n require(!paused(), \"ERC20Pausable: token transfer while paused\");\n }\n}\n" - }, - "@openzeppelin/contracts/access/AccessControlEnumerable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControlEnumerable.sol\";\nimport \"./AccessControl.sol\";\nimport \"../utils/structs/EnumerableSet.sol\";\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override {\n super._grantRole(role, account);\n _roleMembers[role].add(account);\n }\n\n /**\n * @dev Overload {_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override {\n super._revokeRole(role, account);\n _roleMembers[role].remove(account);\n }\n}\n" - }, - "@openzeppelin/contracts/security/Pausable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract Pausable is Context {\n /**\n * @dev Emitted when the pause is triggered by `account`.\n */\n event Paused(address account);\n\n /**\n * @dev Emitted when the pause is lifted by `account`.\n */\n event Unpaused(address account);\n\n bool private _paused;\n\n /**\n * @dev Initializes the contract in unpaused state.\n */\n constructor() {\n _paused = false;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n require(!paused(), \"Pausable: paused\");\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n require(paused(), \"Pausable: not paused\");\n _;\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n}\n" - }, - "@openzeppelin/contracts/access/IAccessControlEnumerable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n" - }, - "@openzeppelin/contracts/access/AccessControl.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\nimport \"../utils/Context.sol\";\nimport \"../utils/Strings.sol\";\nimport \"../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address => bool) members;\n bytes32 adminRole;\n }\n\n mapping(bytes32 => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with a standardized message including the required role.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n *\n * _Available since v4.1._\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n return _roles[role].members[account];\n }\n\n /**\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\n * Overriding this function changes the behavior of the {onlyRole} modifier.\n *\n * Format of the revert message is described in {_checkRole}.\n *\n * _Available since v4.6._\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Revert with a standard message if `account` is missing `role`.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert(\n string(\n abi.encodePacked(\n \"AccessControl: account \",\n Strings.toHexString(uint160(account), 20),\n \" is missing role \",\n Strings.toHexString(uint256(role), 32)\n )\n )\n );\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) public virtual override {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn't perform any\n * checks on the calling account.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n *\n * NOTE: This function is deprecated in favor of {_grantRole}.\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(role, account);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * Internal function without access restriction.\n */\n function _grantRole(bytes32 role, address account) internal virtual {\n if (!hasRole(role, account)) {\n _roles[role].members[account] = true;\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * Internal function without access restriction.\n */\n function _revokeRole(bytes32 role, address account) internal virtual {\n if (hasRole(role, account)) {\n _roles[role].members[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n" - }, - "@openzeppelin/contracts/access/IAccessControl.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n" - }, - "@openzeppelin/contracts/utils/Strings.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\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 // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\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 if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\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 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_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/introspection/ERC165.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 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 *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/introspection/IERC165.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\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[EIP 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" - }, - "contracts/test/TestnetBatcher.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol\";\nimport \"@equilibria/emptyset-batcher/interfaces/IBatcher.sol\";\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"@equilibria/root/token/types/Token6.sol\";\nimport \"./TestnetReserve.sol\";\n\ncontract TestnetBatcher is IBatcher {\n TestnetReserve public reserve;\n\n // solhint-disable-next-line no-empty-blocks\n constructor(TestnetReserve reserve_) {\n reserve = reserve_;\n }\n\n function totalBalance() external pure returns (UFixed18) {\n return UFixed18Lib.from(type(uint256).max);\n }\n\n // Passthrough to Reserve\n function wrap(UFixed18 amount, address to) external {\n reserve.mint(amount, to);\n\n emit Wrap(to, amount);\n }\n\n // Passthrough to Reserve\n function unwrap(UFixed18 amount, address to) external {\n reserve.redeem(amount, to);\n\n emit Unwrap(to, amount);\n }\n\n function rebalance() external pure {\n revert BatcherNotImplementedError();\n }\n}\n" - }, - "contracts/interfaces/IForwarder.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"@equilibria/root/token/types/Token6.sol\";\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/emptyset-batcher/interfaces/IBatcher.sol\";\nimport \"./ICollateral.sol\";\n\ninterface IForwarder {\n error ForwarderNotContractAddressError();\n\n event WrapAndDeposit(address indexed account, IProduct indexed product, UFixed18 amount);\n\n function USDC() external view returns (Token6); // solhint-disable-line func-name-mixedcase\n function DSU() external view returns (Token18); // solhint-disable-line func-name-mixedcase\n function batcher() external view returns (IBatcher);\n function collateral() external view returns (ICollateral);\n function wrapAndDeposit(address account, IProduct product, UFixed18 amount) external;\n}\n" - }, - "contracts/interfaces/IPerennialLens.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"./IProduct.sol\";\nimport \"./ICollateral.sol\";\nimport \"./IController.sol\";\n\n/**\n * @title Lens contract to conveniently pull protocol, product, and userproduct data\n * @notice All functions should be called using `callStatic`\n */\ninterface IPerennialLens {\n /// @dev Snapshot of Product information\n struct ProductSnapshot {\n IProduct.ProductInfo productInfo;\n address productAddress;\n Fixed18 rate;\n Fixed18 dailyRate;\n IOracleProvider.OracleVersion latestVersion;\n UFixed18 maintenance;\n UFixed18 collateral;\n UFixed18 shortfall;\n PrePosition pre;\n Position position;\n UFixed18 productFee;\n UFixed18 protocolFee;\n Position openInterest;\n }\n\n /// @dev Snapshot of User state for a Product\n struct UserProductSnapshot {\n address productAddress;\n address userAddress;\n UFixed18 collateral;\n UFixed18 maintenance;\n PrePosition pre;\n Position position;\n bool liquidatable;\n Position openInterest;\n UFixed18 fees;\n UFixed18 exposure;\n }\n\n // Protocol Values\n function controller() external view returns (IController);\n function collateral() external view returns (ICollateral);\n\n // Snapshot Functions for batch values\n function snapshots(IProduct[] calldata productAddresses) external returns (ProductSnapshot[] memory);\n function snapshot(IProduct product) external returns (ProductSnapshot memory);\n function snapshots(address account, IProduct[] calldata productAddresses) external returns (UserProductSnapshot[] memory);\n function snapshot(address account, IProduct product) external returns (UserProductSnapshot memory);\n\n // Product Values\n function name(IProduct product) external view returns (string memory);\n function symbol(IProduct product) external view returns (string memory);\n function info(IProduct product) external view returns (IProduct.ProductInfo memory _info);\n function collateral(IProduct product) external returns (UFixed18);\n function shortfall(IProduct product) external returns (UFixed18);\n function pre(IProduct product) external returns (PrePosition memory);\n function fees(IProduct product) external returns (UFixed18 protocolFees, UFixed18 productFees);\n function position(IProduct product) external returns (Position memory);\n function globalPosition(IProduct product) external returns (PrePosition memory, Position memory);\n function latestVersion(IProduct product) external returns (IOracleProvider.OracleVersion memory);\n function atVersions(IProduct product, uint[] memory versions) external returns (IOracleProvider.OracleVersion[] memory prices);\n function rate(IProduct product) external returns (Fixed18);\n function openInterest(IProduct product) external returns (Position memory);\n function dailyRate(IProduct product) external returns (Fixed18);\n\n // UserProduct Values\n function collateral(address account, IProduct product) external returns (UFixed18);\n function maintenance(address account, IProduct product) external returns (UFixed18);\n function liquidatable(address account, IProduct product) external returns (bool);\n function pre(address account, IProduct product) external returns (PrePosition memory);\n function position(address account, IProduct product) external returns (Position memory);\n function userPosition(address account, IProduct product) external returns (PrePosition memory, Position memory);\n function fees(address account, IProduct product) external returns (UFixed18);\n function openInterest(address account, IProduct product) external returns (Position memory);\n function exposure(address account, IProduct product) external returns (UFixed18);\n function maintenanceRequired(\n address account,\n IProduct product,\n UFixed18 positionSize\n ) external returns (UFixed18);\n function unclaimedIncentiveRewards(address account, IProduct product)\n external\n returns (Token18[] memory tokens, UFixed18[] memory amounts);\n function unclaimedIncentiveRewards(\n address account,\n IProduct product,\n uint256[] calldata programIds\n ) external returns (Token18[] memory tokens, UFixed18[] memory amounts);\n}\n" - }, - "contracts/lens/PerennialLens.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../interfaces/IPerennialLens.sol\";\n\n/**\n * @title Lens contract to conveniently pull protocol data\n * @notice All functions should be called using `callStatic`\n */\ncontract PerennialLens is IPerennialLens {\n /**\n * @notice Protocol controller\n * @return Protocol controller\n */\n IController public immutable controller;\n\n /// @param _controller Protocol controller address\n constructor(IController _controller) {\n controller = _controller;\n }\n\n /**\n * @notice Protocol collateral address\n * @return Protocol collateral address\n */\n function collateral() public view returns (ICollateral) {\n return controller.collateral();\n }\n\n /**\n * Snapshot Functions\n */\n\n /**\n * @notice Returns the snapshots of the provided `productAddresses`\n * @param productAddresses Product addresses\n * @return Snapshot for each product after settle\n */\n function snapshots(IProduct[] calldata productAddresses) public returns (ProductSnapshot[] memory) {\n ProductSnapshot[] memory _snapshots = new ProductSnapshot[](productAddresses.length);\n for (uint256 i = 0; i < productAddresses.length; i++) {\n _snapshots[i] = snapshot(productAddresses[i]);\n }\n\n return _snapshots;\n }\n\n /**\n * @notice Returns the snapshot of the provided `product`\n * @param product Product address\n * @return Snapshot for the product after settle\n */\n function snapshot(IProduct product) public settle(product) returns (ProductSnapshot memory) {\n ProductSnapshot memory _snapshot;\n\n _snapshot.productInfo = info(product);\n _snapshot.productAddress = address(product);\n _snapshot.rate = rate(product);\n _snapshot.dailyRate = dailyRate(product);\n _snapshot.latestVersion = latestVersion(product);\n _snapshot.maintenance = product.maintenance();\n _snapshot.collateral = collateral(product);\n _snapshot.shortfall = shortfall(product);\n _snapshot.pre = pre(product);\n _snapshot.position = position(product);\n (UFixed18 productFee, UFixed18 protocolFee) = fees(product);\n _snapshot.productFee = productFee;\n _snapshot.protocolFee = protocolFee;\n _snapshot.openInterest = openInterest(product);\n\n return _snapshot;\n }\n\n /**\n * @notice Returns the user snapshots for the provided `productAddresses`\n * @param account User addresses\n * @param productAddresses Product addresses\n * @return UserSnapshot for each product after settle\n */\n function snapshots(address account, IProduct[] memory productAddresses)\n public returns (UserProductSnapshot[] memory)\n {\n UserProductSnapshot[] memory _snapshots = new UserProductSnapshot[](productAddresses.length);\n for (uint256 i = 0; i < productAddresses.length; i++) {\n _snapshots[i] = snapshot(account, productAddresses[i]);\n }\n\n return _snapshots;\n }\n\n /**\n * @notice Returns the user snapshot for the provided `product`\n * @param account User addresses\n * @param product Product address\n * @return UserSnapshot for the product after settle\n */\n function snapshot(address account, IProduct product)\n public\n settleAccount(account, product)\n returns (UserProductSnapshot memory)\n {\n UserProductSnapshot memory _snapshot;\n\n _snapshot.productAddress = address(product);\n _snapshot.userAddress = account;\n _snapshot.collateral = collateral(account, product);\n _snapshot.maintenance = maintenance(account, product);\n _snapshot.pre = pre(account, product);\n _snapshot.position = position(account, product);\n _snapshot.liquidatable = liquidatable(account, product);\n _snapshot.openInterest = openInterest(account, product);\n _snapshot.fees = fees(account, product);\n _snapshot.exposure = exposure(account, product);\n\n return _snapshot;\n }\n\n /**\n * End Snapshot Functions\n */\n\n /**\n * Product Individual Fields Functions\n */\n\n /**\n * @notice Returns the name of the provided `product`\n * @param product Product address\n * @return Name of the product\n */\n function name(IProduct product) public view returns (string memory) {\n return product.name();\n }\n\n /**\n * @notice Returns the symbol of the provided `product`\n * @param product Product address\n * @return Symbol of the product\n */\n function symbol(IProduct product) public view returns (string memory) {\n return product.symbol();\n }\n\n /**\n * @notice Returns the info of the provided `product`\n * @param product Product address\n * @return _info of the product\n */\n function info(IProduct product) public view returns (IProduct.ProductInfo memory _info) {\n _info.name = name(product);\n _info.symbol = symbol(product);\n _info.payoffDefinition = product.payoffDefinition();\n _info.oracle = product.oracle();\n _info.maintenance = product.maintenance();\n _info.fundingFee = product.fundingFee();\n _info.makerFee = product.makerFee();\n _info.takerFee = product.takerFee();\n _info.makerLimit = product.makerLimit();\n _info.utilizationCurve = product.utilizationCurve();\n }\n\n /**\n * @notice Product total collateral amount after settle\n * @param product Product address\n * @return Total collateral for product\n */\n function collateral(IProduct product) public settle(product) returns (UFixed18) {\n return collateral().collateral(product);\n }\n\n /**\n * @notice Product total shortfall amount after settle\n * @param product Product address\n * @return Total shortfall for product\n */\n function shortfall(IProduct product) public settle(product) returns (UFixed18) {\n return collateral().shortfall(product);\n }\n\n /**\n * @notice Product pre position after settle\n * @param product Product address\n * @return Product pre-position\n */\n function pre(IProduct product) public settle(product) returns (PrePosition memory) {\n return product.pre();\n }\n\n /**\n * @notice Product position after settle\n * @param product Product address\n * @return product position\n */\n function position(IProduct product) public settle(product) returns (Position memory) {\n return _latestPosition(product);\n }\n\n /**\n * @notice Product pre-position and position after settle\n * @param product Product address\n * @return Product pre-position\n * @return Product position\n */\n function globalPosition(IProduct product) public settle(product) returns (PrePosition memory, Position memory) {\n return (product.pre(), _latestPosition(product));\n }\n\n /**\n * @notice Current price of product after settle\n * @param product Product address\n * @return Product latest price\n */\n function latestVersion(IProduct product) public settle(product) returns (IOracleProvider.OracleVersion memory) {\n return _latestVersion(product);\n }\n\n /**\n * @notice Prices of product at specified versions after settle\n * @param product Product address\n * @param versions Oracle versions to query\n * @return prices Product prices at specified versions\n */\n function atVersions(IProduct product, uint256[] memory versions)\n public\n settle(product)\n returns (IOracleProvider.OracleVersion[] memory prices)\n {\n prices = new IOracleProvider.OracleVersion[](versions.length);\n for (uint256 i = 0; i < versions.length; i++) {\n prices[i] = product.atVersion(versions[i]);\n }\n }\n\n /**\n * @notice Product funding rate after settle\n * @param product Product address\n * @return Product current funding rate\n */\n function rate(IProduct product) public settle(product) returns (Fixed18) {\n Position memory position_ = _latestPosition(product);\n return product.rate(position_);\n }\n\n /**\n * @notice Product funding extrapolated to a daily rate after settle\n * @param product Product address\n * @return Product current funding extrapolated to a daily rate\n */\n function dailyRate(IProduct product) public settle(product) returns (Fixed18) {\n Position memory position_ = _latestPosition(product);\n return product.rate(position_).mul(Fixed18Lib.from(60 * 60 * 24));\n }\n\n /**\n * @notice Fees accumulated by product and protocol treasuries after settle\n * @param product Product address\n * @return protocolFees fees accrued by the protocol\n * @return productFees fees accrued by the product owner\n */\n function fees(IProduct product) public settle(product) returns (UFixed18 protocolFees, UFixed18 productFees) {\n address protocolTreasury = controller.treasury();\n address productTreasury = controller.treasury(product);\n\n protocolFees = collateral().fees(protocolTreasury);\n productFees = collateral().fees(productTreasury);\n }\n\n /**\n * @notice Product total open interest after settle\n * @param product Product address\n * @return Product maker and taker position multiplied by latest price after settle\n */\n function openInterest(IProduct product) public settle(product) returns (Position memory) {\n return _latestPosition(product).mul(_latestVersion(product).price.abs());\n }\n\n /**\n * End Product Individual Fields Functions\n */\n\n /**\n * UserProduct Individual Fields Functions\n */\n\n /**\n * @notice User collateral amount for product after settle\n * @param account Account address\n * @param product Product address\n * @return User deposited collateral for product\n */\n function collateral(address account, IProduct product) public settleAccount(account, product) returns (UFixed18) {\n return collateral().collateral(account, product);\n }\n\n /**\n * @notice User maintenance amount for product after settle\n * @param account Account address\n * @param product Product address\n * @return Maximum of user maintenance, and maintenanceNext\n */\n function maintenance(address account, IProduct product) public settleAccount(account, product) returns (UFixed18) {\n return UFixed18Lib.max(product.maintenance(account), product.maintenanceNext(account));\n }\n\n /**\n * @notice User liquidatble status for product after settle\n * @param account Account address\n * @param product Product address\n * @return Whether or not the user's position eligible to be liquidated\n */\n function liquidatable(address account, IProduct product) public settleAccount(account, product) returns (bool) {\n return collateral().liquidatable(account, product);\n }\n\n /**\n * @notice User pre position for product after settle\n * @param account Account address\n * @param product Product address\n * @return User pre-position\n */\n function pre(address account, IProduct product)\n public\n settleAccount(account, product)\n returns (PrePosition memory)\n {\n return product.pre(account);\n }\n\n /**\n * @notice User position for product after settle\n * @param account Account address\n * @param product Product address\n * @return User position\n */\n function position(address account, IProduct product)\n public\n settleAccount(account, product)\n returns (Position memory)\n {\n return product.position(account);\n }\n\n /**\n * @notice User pre-position and position for product after settle\n * @param account Account address\n * @param product Product address\n * @return User pre-position\n * @return User position\n */\n function userPosition(address account, IProduct product)\n public\n settleAccount(account, product)\n returns (PrePosition memory, Position memory)\n {\n return (product.pre(account), product.position(account));\n }\n\n /**\n * @notice Fees accumulated by account after settle\n * @param account Account address\n * @param product Product address\n * @return sum of all fees accrued by the account\n */\n function fees(address account, IProduct product) public settleAccount(account, product) returns (UFixed18) {\n return collateral().fees(account);\n }\n\n /**\n * @notice User's open interest in product after settle\n * @param account Account address\n * @param product Product address\n * @return User's maker or taker position multiplied by latest price after settle\n */\n function openInterest(address account, IProduct product)\n public\n settleAccount(account, product)\n returns (Position memory)\n {\n return product.position(account).mul(_latestVersion(product).price.abs());\n }\n\n /**\n * @notice User's exposure in product after settle\n * @param account Account address\n * @param product Product address\n * @return User's exposure (openInterest * utilization) after settle\n */\n function exposure(address account, IProduct product) public settleAccount(account, product) returns (UFixed18) {\n (, Position memory _pos) = globalPosition(product);\n if (_pos.maker.eq(UFixed18Lib.ZERO)) { return UFixed18Lib.ZERO; }\n\n UFixed18 utilization = _pos.taker.div(_pos.maker);\n Position memory _openInterest = openInterest(account, product);\n\n return utilization.mul(_openInterest.maker.gte(UFixed18Lib.ZERO) ? _openInterest.maker : _openInterest.taker);\n }\n\n /**\n * @notice User's maintenance required for position size in product after settle\n * @param account Account address\n * @param product Product address\n * @param positionSize size of position for maintenance calculation\n * @return Maintenance required for position in product\n */\n function maintenanceRequired(\n address account,\n IProduct product,\n UFixed18 positionSize\n ) public settleAccount(account, product) returns (UFixed18) {\n UFixed18 notional = positionSize.mul(_latestVersion(product).price.abs());\n return notional.mul(product.maintenance());\n }\n\n /**\n * @notice User's unclaimed rewards for all programs for product after settle\n * @param account Account address\n * @param product Product address\n * @return tokens Token addresses of unclaimed incentive rewards for given product\n * @return amounts Token amounts of unclaimed incentive rewards for given product\n */\n function unclaimedIncentiveRewards(address account, IProduct product)\n public\n settleAccount(account, product)\n returns (Token18[] memory tokens, UFixed18[] memory amounts)\n {\n IIncentivizer incentivizer = controller.incentivizer();\n\n uint256 programsLength = incentivizer.count(product);\n tokens = new Token18[](programsLength);\n amounts = new UFixed18[](programsLength);\n for (uint256 i = 0; i < programsLength; i++) {\n ProgramInfo memory programInfo = incentivizer.programInfos(product, i);\n tokens[i] = programInfo.token;\n amounts[i] = incentivizer.unclaimed(product, account, i);\n }\n }\n\n /**\n * @notice User's unclaimed rewards for provided programs for product after settle\n * @param account Account address\n * @param product Product address\n * @param programIds Program IDs to query\n * @return tokens Token addresses of unclaimed incentive rewards for given program IDs\n * @return amounts Token amounts of unclaimed incentive rewards for given program IDs\n */\n function unclaimedIncentiveRewards(\n address account,\n IProduct product,\n uint256[] calldata programIds\n ) public settleAccount(account, product) returns (Token18[] memory tokens, UFixed18[] memory amounts) {\n IIncentivizer incentivizer = controller.incentivizer();\n tokens = new Token18[](programIds.length);\n amounts = new UFixed18[](programIds.length);\n for (uint256 i = 0; i < programIds.length; i++) {\n ProgramInfo memory programInfo = incentivizer.programInfos(product, programIds[i]);\n tokens[i] = programInfo.token;\n amounts[i] = incentivizer.unclaimed(product, account, programIds[i]);\n }\n }\n\n /**\n * End UserProduct Individual Fields Functions\n */\n\n /**\n * Private Helper Functions\n */\n\n /**\n * @notice Returns the Product's latest position\n * @dev Private function, does not call settle itself\n * @param product Product address\n * @return Latest position for the product\n */\n function _latestPosition(IProduct product) private view returns (Position memory) {\n return product.positionAtVersion(product.latestVersion());\n }\n\n /**\n * @notice Returns the Product's latest version\n * @dev Private function, does not call settle itself\n * @param product Product address\n * @return Latest version for the product\n */\n function _latestVersion(IProduct product) private view returns (IOracleProvider.OracleVersion memory) {\n return product.atVersion(product.latestVersion());\n }\n\n /**\n * End Private Helper Functions\n */\n\n /**\n * Modifier Functions\n */\n\n /// @dev Settles the product\n modifier settle(IProduct product) {\n product.settle();\n _;\n }\n\n /// @dev Settles the product. product.settleAccount also settles the product\n modifier settleAccount(address account, IProduct product) {\n product.settleAccount(account);\n _;\n }\n\n /**\n * End Modifier Functions\n */\n}\n" - }, - "contracts/forwarder/Forwarder.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../interfaces/IForwarder.sol\";\n\n/**\n * @title Forwarder\n * @notice Facilitates collateral deposits to the protocol where the amount is supplied\n * in USDC then wrapped as DSU before being deposited.\n */\ncontract Forwarder is IForwarder {\n // @dev USDC stablecoin\n Token6 public immutable USDC; // solhint-disable-line var-name-mixedcase\n\n // @dev DSU stablecoin\n Token18 public immutable DSU; // solhint-disable-line var-name-mixedcase\n\n /// @dev Contract that wraps USDC to DSU\n IBatcher public immutable batcher;\n\n /// @dev Contract managing state for collateral accounts in the protocol\n ICollateral public immutable collateral;\n\n /**\n * @notice Initializes the contract state\n * @param usdc_ The USDC token contract address\n * @param dsu_ The DSU token contract address\n * @param batcher_ The USDC-to-DSU batcher contract address\n * @param collateral_ The perennial collateral contract address\n */\n constructor(\n Token6 usdc_,\n Token18 dsu_,\n IBatcher batcher_,\n ICollateral collateral_\n ) {\n if (!Address.isContract(Token6.unwrap(usdc_))) revert ForwarderNotContractAddressError();\n if (!Address.isContract(Token18.unwrap(dsu_))) revert ForwarderNotContractAddressError();\n if (!Address.isContract(address(batcher_))) revert ForwarderNotContractAddressError();\n if (!Address.isContract(address(collateral_))) revert ForwarderNotContractAddressError();\n\n USDC = usdc_;\n DSU = dsu_;\n batcher = batcher_;\n collateral = collateral_;\n\n USDC.approve(address(batcher));\n DSU.approve(address(collateral));\n }\n\n /**\n * @notice Pulls `amount` of USDC from `msg.sender`'s balance, wraps it as DSU,\n and deposits it as collateral to `account`'s `product` account\n * @param account Account to deposit the collateral for\n * @param product Product to credit the collateral to\n * @param amount 18 decimals-normalized stablecoin (USDC, DSU) value of collateral to deposit\n */\n function wrapAndDeposit(\n address account,\n IProduct product,\n UFixed18 amount\n ) external {\n USDC.pull(msg.sender, amount, true);\n batcher.wrap(amount, address(this));\n collateral.depositTo(account, product, amount);\n emit WrapAndDeposit(account, product, amount);\n }\n}\n" - }, - "contracts/test/TestnetUSDC.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol\";\n\ncontract TestnetUSDC is ERC20, ERC20Burnable {\n // solhint-disable-next-line no-empty-blocks\n constructor() ERC20(\"USD Coin\", \"USDC\") { }\n\n function decimals() override public pure returns (uint8) {\n return 6;\n }\n\n function mint(address account, uint256 amount) external {\n _mint(account, amount);\n }\n}\n" - }, - "contracts/test/TestnetDSU.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol\";\n\ncontract TestnetDSU is ERC20, ERC20Burnable {\n uint256 private constant LIMIT = 1_000_000e18;\n\n error TestnetDSUOverLimitError();\n\n // solhint-disable-next-line no-empty-blocks\n constructor() ERC20(\"Digital Standard Unit\", \"DSU\") { }\n\n function mint(address account, uint256 amount) external {\n if (amount > LIMIT) revert TestnetDSUOverLimitError();\n\n _mint(account, amount);\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev _Available since v3.1._\n */\ninterface IERC1155Receiver is IERC165 {\n /**\n * @dev Handles the receipt of a single ERC1155 token type. This function is\n * called at the end of a `safeTransferFrom` after the balance has been updated.\n *\n * NOTE: To accept the transfer, this must return\n * `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))`\n * (i.e. 0xf23a6e61, or its own function selector).\n *\n * @param operator The address which initiated the transfer (i.e. msg.sender)\n * @param from The address which previously owned the token\n * @param id The ID of the token being transferred\n * @param value The amount of tokens being transferred\n * @param data Additional data with no specified format\n * @return `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))` if transfer is allowed\n */\n function onERC1155Received(\n address operator,\n address from,\n uint256 id,\n uint256 value,\n bytes calldata data\n ) external returns (bytes4);\n\n /**\n * @dev Handles the receipt of a multiple ERC1155 token types. This function\n * is called at the end of a `safeBatchTransferFrom` after the balances have\n * been updated.\n *\n * NOTE: To accept the transfer(s), this must return\n * `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))`\n * (i.e. 0xbc197c81, or its own function selector).\n *\n * @param operator The address which initiated the batch transfer (i.e. msg.sender)\n * @param from The address which previously owned the token\n * @param ids An array containing ids of each token being transferred (order and length must match values array)\n * @param values An array containing amounts of each token being transferred (order and length must match ids array)\n * @param data Additional data with no specified format\n * @return `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))` if transfer is allowed\n */\n function onERC1155BatchReceived(\n address operator,\n address from,\n uint256[] calldata ids,\n uint256[] calldata values,\n bytes calldata data\n ) external returns (bytes4);\n}\n" - }, - "@openzeppelin/contracts/governance/TimelockController.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (governance/TimelockController.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../access/AccessControl.sol\";\nimport \"../token/ERC721/IERC721Receiver.sol\";\nimport \"../token/ERC1155/IERC1155Receiver.sol\";\n\n/**\n * @dev Contract module which acts as a timelocked controller. When set as the\n * owner of an `Ownable` smart contract, it enforces a timelock on all\n * `onlyOwner` maintenance operations. This gives time for users of the\n * controlled contract to exit before a potentially dangerous maintenance\n * operation is applied.\n *\n * By default, this contract is self administered, meaning administration tasks\n * have to go through the timelock process. The proposer (resp executor) role\n * is in charge of proposing (resp executing) operations. A common use case is\n * to position this {TimelockController} as the owner of a smart contract, with\n * a multisig or a DAO as the sole proposer.\n *\n * _Available since v3.3._\n */\ncontract TimelockController is AccessControl, IERC721Receiver, IERC1155Receiver {\n bytes32 public constant TIMELOCK_ADMIN_ROLE = keccak256(\"TIMELOCK_ADMIN_ROLE\");\n bytes32 public constant PROPOSER_ROLE = keccak256(\"PROPOSER_ROLE\");\n bytes32 public constant EXECUTOR_ROLE = keccak256(\"EXECUTOR_ROLE\");\n bytes32 public constant CANCELLER_ROLE = keccak256(\"CANCELLER_ROLE\");\n uint256 internal constant _DONE_TIMESTAMP = uint256(1);\n\n mapping(bytes32 => uint256) private _timestamps;\n uint256 private _minDelay;\n\n /**\n * @dev Emitted when a call is scheduled as part of operation `id`.\n */\n event CallScheduled(\n bytes32 indexed id,\n uint256 indexed index,\n address target,\n uint256 value,\n bytes data,\n bytes32 predecessor,\n uint256 delay\n );\n\n /**\n * @dev Emitted when a call is performed as part of operation `id`.\n */\n event CallExecuted(bytes32 indexed id, uint256 indexed index, address target, uint256 value, bytes data);\n\n /**\n * @dev Emitted when operation `id` is cancelled.\n */\n event Cancelled(bytes32 indexed id);\n\n /**\n * @dev Emitted when the minimum delay for future operations is modified.\n */\n event MinDelayChange(uint256 oldDuration, uint256 newDuration);\n\n /**\n * @dev Initializes the contract with a given `minDelay`, and a list of\n * initial proposers and executors. The proposers receive both the\n * proposer and the canceller role (for backward compatibility). The\n * executors receive the executor role.\n *\n * NOTE: At construction, both the deployer and the timelock itself are\n * administrators. This helps further configuration of the timelock by the\n * deployer. After configuration is done, it is recommended that the\n * deployer renounces its admin position and relies on timelocked\n * operations to perform future maintenance.\n */\n constructor(\n uint256 minDelay,\n address[] memory proposers,\n address[] memory executors\n ) {\n _setRoleAdmin(TIMELOCK_ADMIN_ROLE, TIMELOCK_ADMIN_ROLE);\n _setRoleAdmin(PROPOSER_ROLE, TIMELOCK_ADMIN_ROLE);\n _setRoleAdmin(EXECUTOR_ROLE, TIMELOCK_ADMIN_ROLE);\n _setRoleAdmin(CANCELLER_ROLE, TIMELOCK_ADMIN_ROLE);\n\n // deployer + self administration\n _setupRole(TIMELOCK_ADMIN_ROLE, _msgSender());\n _setupRole(TIMELOCK_ADMIN_ROLE, address(this));\n\n // register proposers and cancellers\n for (uint256 i = 0; i < proposers.length; ++i) {\n _setupRole(PROPOSER_ROLE, proposers[i]);\n _setupRole(CANCELLER_ROLE, proposers[i]);\n }\n\n // register executors\n for (uint256 i = 0; i < executors.length; ++i) {\n _setupRole(EXECUTOR_ROLE, executors[i]);\n }\n\n _minDelay = minDelay;\n emit MinDelayChange(0, minDelay);\n }\n\n /**\n * @dev Modifier to make a function callable only by a certain role. In\n * addition to checking the sender's role, `address(0)` 's role is also\n * considered. Granting a role to `address(0)` is equivalent to enabling\n * this role for everyone.\n */\n modifier onlyRoleOrOpenRole(bytes32 role) {\n if (!hasRole(role, address(0))) {\n _checkRole(role, _msgSender());\n }\n _;\n }\n\n /**\n * @dev Contract might receive/hold ETH as part of the maintenance process.\n */\n receive() external payable {}\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, AccessControl) returns (bool) {\n return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns whether an id correspond to a registered operation. This\n * includes both Pending, Ready and Done operations.\n */\n function isOperation(bytes32 id) public view virtual returns (bool pending) {\n return getTimestamp(id) > 0;\n }\n\n /**\n * @dev Returns whether an operation is pending or not.\n */\n function isOperationPending(bytes32 id) public view virtual returns (bool pending) {\n return getTimestamp(id) > _DONE_TIMESTAMP;\n }\n\n /**\n * @dev Returns whether an operation is ready or not.\n */\n function isOperationReady(bytes32 id) public view virtual returns (bool ready) {\n uint256 timestamp = getTimestamp(id);\n return timestamp > _DONE_TIMESTAMP && timestamp <= block.timestamp;\n }\n\n /**\n * @dev Returns whether an operation is done or not.\n */\n function isOperationDone(bytes32 id) public view virtual returns (bool done) {\n return getTimestamp(id) == _DONE_TIMESTAMP;\n }\n\n /**\n * @dev Returns the timestamp at with an operation becomes ready (0 for\n * unset operations, 1 for done operations).\n */\n function getTimestamp(bytes32 id) public view virtual returns (uint256 timestamp) {\n return _timestamps[id];\n }\n\n /**\n * @dev Returns the minimum delay for an operation to become valid.\n *\n * This value can be changed by executing an operation that calls `updateDelay`.\n */\n function getMinDelay() public view virtual returns (uint256 duration) {\n return _minDelay;\n }\n\n /**\n * @dev Returns the identifier of an operation containing a single\n * transaction.\n */\n function hashOperation(\n address target,\n uint256 value,\n bytes calldata data,\n bytes32 predecessor,\n bytes32 salt\n ) public pure virtual returns (bytes32 hash) {\n return keccak256(abi.encode(target, value, data, predecessor, salt));\n }\n\n /**\n * @dev Returns the identifier of an operation containing a batch of\n * transactions.\n */\n function hashOperationBatch(\n address[] calldata targets,\n uint256[] calldata values,\n bytes[] calldata payloads,\n bytes32 predecessor,\n bytes32 salt\n ) public pure virtual returns (bytes32 hash) {\n return keccak256(abi.encode(targets, values, payloads, predecessor, salt));\n }\n\n /**\n * @dev Schedule an operation containing a single transaction.\n *\n * Emits a {CallScheduled} event.\n *\n * Requirements:\n *\n * - the caller must have the 'proposer' role.\n */\n function schedule(\n address target,\n uint256 value,\n bytes calldata data,\n bytes32 predecessor,\n bytes32 salt,\n uint256 delay\n ) public virtual onlyRole(PROPOSER_ROLE) {\n bytes32 id = hashOperation(target, value, data, predecessor, salt);\n _schedule(id, delay);\n emit CallScheduled(id, 0, target, value, data, predecessor, delay);\n }\n\n /**\n * @dev Schedule an operation containing a batch of transactions.\n *\n * Emits one {CallScheduled} event per transaction in the batch.\n *\n * Requirements:\n *\n * - the caller must have the 'proposer' role.\n */\n function scheduleBatch(\n address[] calldata targets,\n uint256[] calldata values,\n bytes[] calldata payloads,\n bytes32 predecessor,\n bytes32 salt,\n uint256 delay\n ) public virtual onlyRole(PROPOSER_ROLE) {\n require(targets.length == values.length, \"TimelockController: length mismatch\");\n require(targets.length == payloads.length, \"TimelockController: length mismatch\");\n\n bytes32 id = hashOperationBatch(targets, values, payloads, predecessor, salt);\n _schedule(id, delay);\n for (uint256 i = 0; i < targets.length; ++i) {\n emit CallScheduled(id, i, targets[i], values[i], payloads[i], predecessor, delay);\n }\n }\n\n /**\n * @dev Schedule an operation that is to becomes valid after a given delay.\n */\n function _schedule(bytes32 id, uint256 delay) private {\n require(!isOperation(id), \"TimelockController: operation already scheduled\");\n require(delay >= getMinDelay(), \"TimelockController: insufficient delay\");\n _timestamps[id] = block.timestamp + delay;\n }\n\n /**\n * @dev Cancel an operation.\n *\n * Requirements:\n *\n * - the caller must have the 'canceller' role.\n */\n function cancel(bytes32 id) public virtual onlyRole(CANCELLER_ROLE) {\n require(isOperationPending(id), \"TimelockController: operation cannot be cancelled\");\n delete _timestamps[id];\n\n emit Cancelled(id);\n }\n\n /**\n * @dev Execute an (ready) operation containing a single transaction.\n *\n * Emits a {CallExecuted} event.\n *\n * Requirements:\n *\n * - the caller must have the 'executor' role.\n */\n // This function can reenter, but it doesn't pose a risk because _afterCall checks that the proposal is pending,\n // thus any modifications to the operation during reentrancy should be caught.\n // slither-disable-next-line reentrancy-eth\n function execute(\n address target,\n uint256 value,\n bytes calldata data,\n bytes32 predecessor,\n bytes32 salt\n ) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) {\n bytes32 id = hashOperation(target, value, data, predecessor, salt);\n _beforeCall(id, predecessor);\n _call(id, 0, target, value, data);\n _afterCall(id);\n }\n\n /**\n * @dev Execute an (ready) operation containing a batch of transactions.\n *\n * Emits one {CallExecuted} event per transaction in the batch.\n *\n * Requirements:\n *\n * - the caller must have the 'executor' role.\n */\n function executeBatch(\n address[] calldata targets,\n uint256[] calldata values,\n bytes[] calldata payloads,\n bytes32 predecessor,\n bytes32 salt\n ) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) {\n require(targets.length == values.length, \"TimelockController: length mismatch\");\n require(targets.length == payloads.length, \"TimelockController: length mismatch\");\n\n bytes32 id = hashOperationBatch(targets, values, payloads, predecessor, salt);\n _beforeCall(id, predecessor);\n for (uint256 i = 0; i < targets.length; ++i) {\n _call(id, i, targets[i], values[i], payloads[i]);\n }\n _afterCall(id);\n }\n\n /**\n * @dev Checks before execution of an operation's calls.\n */\n function _beforeCall(bytes32 id, bytes32 predecessor) private view {\n require(isOperationReady(id), \"TimelockController: operation is not ready\");\n require(predecessor == bytes32(0) || isOperationDone(predecessor), \"TimelockController: missing dependency\");\n }\n\n /**\n * @dev Checks after execution of an operation's calls.\n */\n function _afterCall(bytes32 id) private {\n require(isOperationReady(id), \"TimelockController: operation is not ready\");\n _timestamps[id] = _DONE_TIMESTAMP;\n }\n\n /**\n * @dev Execute an operation's call.\n *\n * Emits a {CallExecuted} event.\n */\n function _call(\n bytes32 id,\n uint256 index,\n address target,\n uint256 value,\n bytes calldata data\n ) private {\n (bool success, ) = target.call{value: value}(data);\n require(success, \"TimelockController: underlying transaction reverted\");\n\n emit CallExecuted(id, index, target, value, data);\n }\n\n /**\n * @dev Changes the minimum timelock duration for future operations.\n *\n * Emits a {MinDelayChange} event.\n *\n * Requirements:\n *\n * - the caller must be the timelock itself. This can only be achieved by scheduling and later executing\n * an operation where the timelock is the target and the data is the ABI-encoded call to this function.\n */\n function updateDelay(uint256 newDelay) external virtual {\n require(msg.sender == address(this), \"TimelockController: caller must be timelock\");\n emit MinDelayChange(_minDelay, newDelay);\n _minDelay = newDelay;\n }\n\n /**\n * @dev See {IERC721Receiver-onERC721Received}.\n */\n function onERC721Received(\n address,\n address,\n uint256,\n bytes memory\n ) public virtual override returns (bytes4) {\n return this.onERC721Received.selector;\n }\n\n /**\n * @dev See {IERC1155Receiver-onERC1155Received}.\n */\n function onERC1155Received(\n address,\n address,\n uint256,\n uint256,\n bytes memory\n ) public virtual override returns (bytes4) {\n return this.onERC1155Received.selector;\n }\n\n /**\n * @dev See {IERC1155Receiver-onERC1155BatchReceived}.\n */\n function onERC1155BatchReceived(\n address,\n address,\n uint256[] memory,\n uint256[] memory,\n bytes memory\n ) public virtual override returns (bytes4) {\n return this.onERC1155BatchReceived.selector;\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" - }, - "contracts/hardhat-dependency-compiler/@openzeppelin/contracts/governance/TimelockController.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@openzeppelin/contracts/governance/TimelockController.sol';\n" - }, - "contracts/hardhat-dependency-compiler/@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol';\n" - }, - "contracts/hardhat-dependency-compiler/@equilibria/emptyset-batcher/batcher/Batcher.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@equilibria/emptyset-batcher/batcher/Batcher.sol';\n" - }, - "contracts/hardhat-dependency-compiler/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol';\n" - }, - "contracts/hardhat-dependency-compiler/@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol';\n" - }, - "@equilibria/perennial-oracle/contracts/ReservoirFeedOracle.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol\";\nimport \"./interfaces/IOracleProvider.sol\";\n\n/**\n * @title ReservoirFeedOracle\n * @notice Reservoir implementation of the IOracle interface, using Reservoir's AggregatorV3Interface adaptors\n * @dev This is a naive implementation which pushes all validation to the underlying. No staleness checks are possible\n This oracle should not be used for regular Chainlink Data Feeds\n */\ncontract ReservoirFeedOracle is IOracleProvider {\n error InvalidOracleVersion();\n\n /// @dev Chainlink price feed to read from\n AggregatorV3Interface public immutable feed;\n\n /// @dev Decimal offset used to normalize chainlink price to 18 decimals\n int256 private immutable _decimalOffset;\n\n /// @dev Which underlying round to consider version 0: version = roundId - _versionOffset\n uint80 private immutable _versionOffset;\n\n /**\n * @notice Initializes the contract state\n * @param feed_ Reservoir price feed\n * @param versionOffset_ Version offset from source round ID\n */\n constructor(AggregatorV3Interface feed_, uint80 versionOffset_) {\n feed = feed_;\n _versionOffset = versionOffset_;\n _decimalOffset = SafeCast.toInt256(10 ** feed_.decimals());\n }\n\n /**\n * @notice Checks for a new price. Does not perform staleness validation as the underlying oracle does not\n support this.\n * @return The current oracle version after sync\n */\n function sync() external view returns (OracleVersion memory) {\n (uint80 roundId, int256 feedPrice, , uint256 timestamp,) = feed.latestRoundData();\n\n return _buildOracleVersion(roundId, feedPrice, timestamp);\n }\n\n /**\n * @notice Returns the current oracle version\n * @return oracleVersion Current oracle version\n */\n function currentVersion() public view returns (OracleVersion memory oracleVersion) {\n (uint80 roundId, int256 feedPrice, , uint256 timestamp,) = feed.latestRoundData();\n\n return _buildOracleVersion(roundId, feedPrice, timestamp);\n }\n\n /**\n * @notice Returns the oracle version specified\n * @dev Converts the passed in version to a roundID by adding _versionOffset\n * @param version The version of which to lookup\n * @return oracleVersion Oracle version at version `version`\n */\n function atVersion(uint256 version) public view returns (OracleVersion memory oracleVersion) {\n // To convert from version to roundId, we add the versionOffset\n uint256 feedRoundID = version + _versionOffset;\n if (feedRoundID > type(uint80).max) revert InvalidOracleVersion();\n (uint80 roundId, int256 feedPrice, , uint256 timestamp,) = feed.getRoundData(uint80(feedRoundID));\n\n return _buildOracleVersion(roundId, feedPrice, timestamp);\n }\n\n /**\n * @notice Builds an oracle version object from a Chainlink round object\n * @dev Converts the passed in roundID to a version by subtracting _versionOffset\n * @param roundId ReservoirRoundId round to build from\n * @param feedPrice price returns by the oracle\n * @param timestamp round timestamps\n * @return Built oracle version\n */\n function _buildOracleVersion(uint80 roundId, int256 feedPrice, uint256 timestamp)\n private view returns (OracleVersion memory) {\n Fixed18 price = Fixed18Lib.ratio(feedPrice, _decimalOffset);\n\n // To convert from roundId to version, we subtract the versionOffset\n return OracleVersion({ version: roundId - _versionOffset, timestamp: timestamp, price: price });\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/SafeCast.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/math/SafeCast.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCast {\n /**\n * @dev Returns the downcasted 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 require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\n return uint224(value);\n }\n\n /**\n * @dev Returns the downcasted 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 require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return uint128(value);\n }\n\n /**\n * @dev Returns the downcasted 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 require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\n return uint96(value);\n }\n\n /**\n * @dev Returns the downcasted 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 require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return uint64(value);\n }\n\n /**\n * @dev Returns the downcasted 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 require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return uint32(value);\n }\n\n /**\n * @dev Returns the downcasted 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 require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return uint16(value);\n }\n\n /**\n * @dev Returns the downcasted uint8 from uint256, reverting on\n * overflow (when the input is greater than largest uint8).\n *\n * Counterpart to Solidity's `uint8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits.\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return uint8(value);\n }\n\n /**\n * @dev Converts a signed int256 into an unsigned uint256.\n *\n * Requirements:\n *\n * - input must be greater than or equal to 0.\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n require(value >= 0, \"SafeCast: value must be positive\");\n return uint256(value);\n }\n\n /**\n * @dev Returns the downcasted int128 from int256, reverting on\n * overflow (when the input is less than smallest int128 or\n * greater than largest int128).\n *\n * Counterpart to Solidity's `int128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v3.1._\n */\n function toInt128(int256 value) internal pure returns (int128) {\n require(value >= type(int128).min && value <= type(int128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return int128(value);\n }\n\n /**\n * @dev Returns the downcasted int64 from int256, reverting on\n * overflow (when the input is less than smallest int64 or\n * greater than largest int64).\n *\n * Counterpart to Solidity's `int64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v3.1._\n */\n function toInt64(int256 value) internal pure returns (int64) {\n require(value >= type(int64).min && value <= type(int64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return int64(value);\n }\n\n /**\n * @dev Returns the downcasted int32 from int256, reverting on\n * overflow (when the input is less than smallest int32 or\n * greater than largest int32).\n *\n * Counterpart to Solidity's `int32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v3.1._\n */\n function toInt32(int256 value) internal pure returns (int32) {\n require(value >= type(int32).min && value <= type(int32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return int32(value);\n }\n\n /**\n * @dev Returns the downcasted int16 from int256, reverting on\n * overflow (when the input is less than smallest int16 or\n * greater than largest int16).\n *\n * Counterpart to Solidity's `int16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v3.1._\n */\n function toInt16(int256 value) internal pure returns (int16) {\n require(value >= type(int16).min && value <= type(int16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return int16(value);\n }\n\n /**\n * @dev Returns the downcasted int8 from int256, reverting on\n * overflow (when the input is less than smallest int8 or\n * greater than largest int8).\n *\n * Counterpart to Solidity's `int8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits.\n *\n * _Available since v3.1._\n */\n function toInt8(int256 value) internal pure returns (int8) {\n require(value >= type(int8).min && value <= type(int8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return int8(value);\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 require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n" - }, - "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface AggregatorV3Interface {\n function decimals() external view returns (uint8);\n\n function description() external view returns (string memory);\n\n function version() external view returns (uint256);\n\n // getRoundData and latestRoundData should both raise \"No data present\"\n // if they do not have data to report, instead of returning unset values\n // which could be misinterpreted as actual reported values.\n function getRoundData(uint80 _roundId)\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n function latestRoundData()\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n}\n" - }, - "@equilibria/perennial-oracle/contracts/test/PassthroughDataFeed.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol\";\n\ncontract PassthroughDataFeed {\n AggregatorV3Interface private _underlying;\n\n constructor(AggregatorV3Interface underlying_) {\n _underlying = underlying_;\n }\n\n function decimals() external view returns (uint8) {\n return _underlying.decimals();\n }\n\n function getRoundData(uint80 roundId) external view returns (uint80, int256, uint256, uint256, uint80) {\n return _underlying.getRoundData(roundId);\n }\n\n function latestRoundData() external view returns (uint80, int256, uint256, uint256, uint80) {\n return _underlying.latestRoundData();\n }\n}\n" - }, - "contracts/hardhat-dependency-compiler/@equilibria/perennial-oracle/contracts/test/PassthroughDataFeed.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@equilibria/perennial-oracle/contracts/test/PassthroughDataFeed.sol';\n" - }, - "@equilibria/perennial-oracle/contracts/types/ChainlinkRound.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol\";\n\n/// @dev ChainlinkRound type\nstruct ChainlinkRound {\n uint256 timestamp;\n int256 answer;\n uint80 roundId;\n}\nusing ChainlinkRoundLib for ChainlinkRound global;\n\n/**\n * @title ChainlinkRoundLib\n * @notice Library that manages Chainlink round parsing.\n */\nlibrary ChainlinkRoundLib {\n /// @dev Phase ID offset location in the round ID\n uint256 constant private PHASE_OFFSET = 64;\n\n /**\n * @notice Computes the chainlink phase ID from a round\n * @param self Round to compute from\n * @return Chainlink phase ID\n */\n function phaseId(ChainlinkRound memory self) internal pure returns (uint16) {\n return uint16(self.roundId >> PHASE_OFFSET);\n }\n}\n" - }, - "@equilibria/perennial-oracle/contracts/types/ChainlinkRegistry.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@chainlink/contracts/src/v0.8/interfaces/FeedRegistryInterface.sol\";\nimport \"./ChainlinkRound.sol\";\n\n/// @dev ChainlinkRegistry type\ntype ChainlinkRegistry is address;\nusing ChainlinkRegistryLib for ChainlinkRegistry global;\n\n/**\n * @title ChainlinkRegistryLib\n * @notice Library that manages interfacing with the Chainlink Feed Registry.\n */\nlibrary ChainlinkRegistryLib {\n /**\n * @notice Returns the decimal amount for a specific feed\n * @param self Chainlink Feed Registry to operate on\n * @param base Base currency token address\n * @param quote Quote currency token address\n * @return Decimal amount\n */\n function decimals(ChainlinkRegistry self, address base, address quote) internal view returns (uint8) {\n return FeedRegistryInterface(ChainlinkRegistry.unwrap(self)).decimals(base, quote);\n }\n\n /**\n * @notice Returns the latest round data for a specific feed\n * @param self Chainlink Feed Registry to operate on\n * @param base Base currency token address\n * @param quote Quote currency token address\n * @return Latest round data\n */\n function getLatestRound(ChainlinkRegistry self, address base, address quote) internal view returns (ChainlinkRound memory) {\n (uint80 roundId, int256 answer, , uint256 updatedAt, ) =\n FeedRegistryInterface(ChainlinkRegistry.unwrap(self)).latestRoundData(base, quote);\n return ChainlinkRound({roundId: roundId, timestamp: updatedAt, answer: answer});\n }\n\n /**\n * @notice Returns a specific round's data for a specific feed\n * @param self Chainlink Feed Registry to operate on\n * @param base Base currency token address\n * @param quote Quote currency token address\n * @param roundId The specific round to fetch data for\n * @return Specific round's data\n */\n function getRound(ChainlinkRegistry self, address base, address quote, uint80 roundId) internal view returns (ChainlinkRound memory) {\n (, int256 answer, , uint256 updatedAt, ) =\n FeedRegistryInterface(ChainlinkRegistry.unwrap(self)).getRoundData(base, quote, roundId);\n return ChainlinkRound({roundId: roundId, timestamp: updatedAt, answer: answer});\n }\n\n\n /**\n * @notice Returns the first round ID for a specific phase ID\n * @param self Chainlink Feed Registry to operate on\n * @param base Base currency token address\n * @param quote Quote currency token address\n * @param phaseId The specific phase to fetch data for\n * @return startingRoundId The starting round ID for the phase\n */\n function getStartingRoundId(ChainlinkRegistry self, address base, address quote, uint16 phaseId)\n internal view returns (uint80 startingRoundId) {\n (startingRoundId, ) =\n FeedRegistryInterface(ChainlinkRegistry.unwrap(self)).getPhaseRange(base, quote, phaseId);\n }\n\n /**\n * @notice Returns the quantity of rounds for a specific phase ID\n * @param self Chainlink Feed Registry to operate on\n * @param base Base currency token address\n * @param quote Quote currency token address\n * @param phaseId The specific phase to fetch data for\n * @return The quantity of rounds for the phase\n */\n function getRoundCount(ChainlinkRegistry self, address base, address quote, uint16 phaseId)\n internal view returns (uint80) {\n (uint80 startingRoundId, uint80 endingRoundId) =\n FeedRegistryInterface(ChainlinkRegistry.unwrap(self)).getPhaseRange(base, quote, phaseId);\n return endingRoundId - startingRoundId + 1;\n }\n}\n" - }, - "@chainlink/contracts/src/v0.8/interfaces/FeedRegistryInterface.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\npragma abicoder v2;\n\nimport \"./AggregatorV2V3Interface.sol\";\n\ninterface FeedRegistryInterface {\n struct Phase {\n uint16 phaseId;\n uint80 startingAggregatorRoundId;\n uint80 endingAggregatorRoundId;\n }\n\n event FeedProposed(\n address indexed asset,\n address indexed denomination,\n address indexed proposedAggregator,\n address currentAggregator,\n address sender\n );\n event FeedConfirmed(\n address indexed asset,\n address indexed denomination,\n address indexed latestAggregator,\n address previousAggregator,\n uint16 nextPhaseId,\n address sender\n );\n\n // V3 AggregatorV3Interface\n\n function decimals(address base, address quote) external view returns (uint8);\n\n function description(address base, address quote) external view returns (string memory);\n\n function version(address base, address quote) external view returns (uint256);\n\n function latestRoundData(address base, address quote)\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n function getRoundData(\n address base,\n address quote,\n uint80 _roundId\n )\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n // V2 AggregatorInterface\n\n function latestAnswer(address base, address quote) external view returns (int256 answer);\n\n function latestTimestamp(address base, address quote) external view returns (uint256 timestamp);\n\n function latestRound(address base, address quote) external view returns (uint256 roundId);\n\n function getAnswer(\n address base,\n address quote,\n uint256 roundId\n ) external view returns (int256 answer);\n\n function getTimestamp(\n address base,\n address quote,\n uint256 roundId\n ) external view returns (uint256 timestamp);\n\n // Registry getters\n\n function getFeed(address base, address quote) external view returns (AggregatorV2V3Interface aggregator);\n\n function getPhaseFeed(\n address base,\n address quote,\n uint16 phaseId\n ) external view returns (AggregatorV2V3Interface aggregator);\n\n function isFeedEnabled(address aggregator) external view returns (bool);\n\n function getPhase(\n address base,\n address quote,\n uint16 phaseId\n ) external view returns (Phase memory phase);\n\n // Round helpers\n\n function getRoundFeed(\n address base,\n address quote,\n uint80 roundId\n ) external view returns (AggregatorV2V3Interface aggregator);\n\n function getPhaseRange(\n address base,\n address quote,\n uint16 phaseId\n ) external view returns (uint80 startingRoundId, uint80 endingRoundId);\n\n function getPreviousRoundId(\n address base,\n address quote,\n uint80 roundId\n ) external view returns (uint80 previousRoundId);\n\n function getNextRoundId(\n address base,\n address quote,\n uint80 roundId\n ) external view returns (uint80 nextRoundId);\n\n // Feed management\n\n function proposeFeed(\n address base,\n address quote,\n address aggregator\n ) external;\n\n function confirmFeed(\n address base,\n address quote,\n address aggregator\n ) external;\n\n // Proposed aggregator\n\n function getProposedFeed(address base, address quote)\n external\n view\n returns (AggregatorV2V3Interface proposedAggregator);\n\n function proposedGetRoundData(\n address base,\n address quote,\n uint80 roundId\n )\n external\n view\n returns (\n uint80 id,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n function proposedLatestRoundData(address base, address quote)\n external\n view\n returns (\n uint80 id,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n // Phases\n function getCurrentPhaseId(address base, address quote) external view returns (uint16 currentPhaseId);\n}\n" - }, - "@chainlink/contracts/src/v0.8/interfaces/AggregatorV2V3Interface.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"./AggregatorInterface.sol\";\nimport \"./AggregatorV3Interface.sol\";\n\ninterface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface {}\n" - }, - "@chainlink/contracts/src/v0.8/interfaces/AggregatorInterface.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface AggregatorInterface {\n function latestAnswer() external view returns (int256);\n\n function latestTimestamp() external view returns (uint256);\n\n function latestRound() external view returns (uint256);\n\n function getAnswer(uint256 roundId) external view returns (int256);\n\n function getTimestamp(uint256 roundId) external view returns (uint256);\n\n event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 updatedAt);\n\n event NewRound(uint256 indexed roundId, address indexed startedBy, uint256 startedAt);\n}\n" - }, - "@equilibria/perennial-oracle/contracts/test/PassthroughChainlinkFeed.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@chainlink/contracts/src/v0.8/interfaces/FeedRegistryInterface.sol\";\n\ncontract PassthroughChainlinkFeed {\n FeedRegistryInterface private _underlying;\n\n constructor(FeedRegistryInterface underlying_) {\n _underlying = underlying_;\n }\n\n function decimals(address base, address quote) external view returns (uint8) {\n return _underlying.decimals(base, quote);\n }\n\n function getRoundData(address base, address quote, uint80 roundId) external view returns (uint80, int256, uint256, uint256, uint80) {\n return _underlying.getRoundData(base, quote, roundId);\n }\n\n function getPhaseRange(address base, address quote, uint16 phaseId) external view returns (uint80, uint80) {\n return _underlying.getPhaseRange(base, quote, phaseId);\n }\n\n function latestRoundData(address base, address quote) external view returns (uint80, int256, uint256, uint256, uint80) {\n return _underlying.latestRoundData(base, quote);\n }\n}\n" - }, - "contracts/hardhat-dependency-compiler/@equilibria/perennial-oracle/contracts/test/PassthroughChainlinkFeed.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@equilibria/perennial-oracle/contracts/test/PassthroughChainlinkFeed.sol';\n" - }, - "@equilibria/perennial-oracle/contracts/ChainlinkOracle.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@chainlink/contracts/src/v0.8/interfaces/FeedRegistryInterface.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"./interfaces/IOracleProvider.sol\";\nimport \"./types/ChainlinkRegistry.sol\";\n\n/**\n * @title ChainlinkOracle\n * @notice Chainlink implementation of the IOracle interface.\n * @dev One instance per Chainlink price feed should be deployed. Multiple products may use the same\n * ChainlinkOracle instance if their payoff functions are based on the same underlying oracle.\n * This implementation only support non-negative prices.\n */\ncontract ChainlinkOracle is IOracleProvider {\n /// @dev Chainlink registry feed address\n ChainlinkRegistry public immutable registry;\n\n /// @dev Base token address for the Chainlink oracle\n address public immutable base;\n\n /// @dev Quote token address for the Chainlink oracle\n address public immutable quote;\n\n /// @dev Decimal offset used to normalize chainlink price to 18 decimals\n int256 private immutable _decimalOffset;\n\n /// @dev Mapping of the first oracle version for each underlying phase ID\n uint256[] private _startingVersionForPhaseId;\n\n /**\n * @notice Initializes the contract state\n * @param registry_ Chainlink price feed registry\n * @param base_ base currency for feed\n * @param quote_ quote currency for feed\n */\n constructor(ChainlinkRegistry registry_, address base_, address quote_) {\n registry = registry_;\n base = base_;\n quote = quote_;\n\n _startingVersionForPhaseId.push(0); // phaseId is 1-indexed, skip index 0\n _startingVersionForPhaseId.push(0); // phaseId is 1-indexed, first phase starts as version 0\n _decimalOffset = SafeCast.toInt256(10 ** registry_.decimals(base, quote));\n }\n\n /**\n * @notice Checks for a new price and updates the internal phase annotation state accordingly\n * @return The current oracle version after sync\n */\n function sync() external returns (OracleVersion memory) {\n // Fetch latest round\n ChainlinkRound memory round = registry.getLatestRound(base, quote);\n\n // Update phase annotation when new phase detected\n while (round.phaseId() > _latestPhaseId()) {\n uint256 roundCount = registry.getRoundCount(base, quote, _latestPhaseId());\n _startingVersionForPhaseId.push(roundCount);\n }\n\n // Return packaged oracle version\n return _buildOracleVersion(round);\n }\n\n /**\n * @notice Returns the current oracle version\n * @return oracleVersion Current oracle version\n */\n function currentVersion() public view returns (OracleVersion memory oracleVersion) {\n return _buildOracleVersion(registry.getLatestRound(base, quote));\n }\n\n /**\n * @notice Returns the current oracle version\n * @param version The version of which to lookup\n * @return oracleVersion Oracle version at version `version`\n */\n function atVersion(uint256 version) public view returns (OracleVersion memory oracleVersion) {\n return _buildOracleVersion(registry.getRound(base, quote, _versionToRoundId(version)), version);\n }\n\n /**\n * @notice Builds an oracle version object from a Chainlink round object\n * @dev Computes the version for the round\n * @param round Chainlink round to build from\n * @return Built oracle version\n */\n function _buildOracleVersion(ChainlinkRound memory round) private view returns (OracleVersion memory) {\n uint256 version = _startingVersionForPhaseId[round.phaseId()] +\n uint256(round.roundId - registry.getStartingRoundId(base, quote, round.phaseId()));\n return _buildOracleVersion(round, version);\n }\n\n /**\n * @notice Builds an oracle version object from a Chainlink round object\n * @param round Chainlink round to build from\n * @param version Determined version for the round\n * @return Built oracle version\n */\n function _buildOracleVersion(ChainlinkRound memory round, uint256 version)\n private view returns (OracleVersion memory) {\n Fixed18 price = Fixed18Lib.ratio(round.answer, _decimalOffset);\n return OracleVersion({ version: version, timestamp: round.timestamp, price: price });\n }\n\n /**\n * @notice Computes the chainlink round ID from a version\n * @notice version Version to compute from\n * @return Chainlink round ID\n */\n function _versionToRoundId(uint256 version) private view returns (uint80) {\n uint16 phaseId = _versionToPhaseId(version);\n return registry.getStartingRoundId(base, quote, phaseId) +\n uint80(version - _startingVersionForPhaseId[phaseId]);\n }\n\n /**\n * @notice Computes the chainlink phase ID from a version\n * @param version Version to compute from\n * @return phaseId Chainlink phase ID\n */\n function _versionToPhaseId(uint256 version) private view returns (uint16 phaseId) {\n phaseId = _latestPhaseId();\n while (_startingVersionForPhaseId[phaseId] > version) {\n phaseId--;\n }\n }\n\n /**\n * @notice Returns the latest phase ID that this contract has seen via `sync()`\n * @return Latest seen phase ID\n */\n function _latestPhaseId() private view returns (uint16) {\n return uint16(_startingVersionForPhaseId.length - 1);\n }\n}\n" - }, - "contracts/hardhat-dependency-compiler/@equilibria/perennial-oracle/contracts/ChainlinkOracle.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@equilibria/perennial-oracle/contracts/ChainlinkOracle.sol';\n" - }, - "contracts/hardhat-dependency-compiler/@equilibria/perennial-oracle/contracts/ReservoirFeedOracle.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@equilibria/perennial-oracle/contracts/ReservoirFeedOracle.sol';\n" - }, - "contracts/hardhat-dependency-compiler/@equilibria/perennial-oracle/contracts/test/TestnetChainlinkFeedRegistry.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@equilibria/perennial-oracle/contracts/test/TestnetChainlinkFeedRegistry.sol';\n" - }, - "@equilibria/perennial-oracle/contracts/test/TestnetChainlinkFeedRegistry.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\ncontract TestnetChainlinkFeedRegistry {\n mapping(address => mapping(address => uint8)) public decimals;\n\n function registerFeed(address base, address quote, uint8 newDecimals) external {\n decimals[base][quote] = newDecimals;\n }\n}\n" - } - }, - "settings": { - "optimizer": { - "enabled": false, - "runs": 1000000 - }, - "outputSelection": { - "*": { - "*": [ - "storageLayout", - "abi", - "evm.bytecode", - "evm.deployedBytecode", - "evm.methodIdentifiers", - "metadata", - "devdoc", - "userdoc", - "evm.gasEstimates" - ], - "": ["ast"] - } - }, - "metadata": { - "useLiteralContent": true - } - } -} diff --git a/packages/perennial/deployments/kovan/solcInputs/dd52f03d8fef7833844e4ba864fd9fba.json b/packages/perennial/deployments/kovan/solcInputs/dd52f03d8fef7833844e4ba864fd9fba.json deleted file mode 100644 index 9bd4b8f52..000000000 --- a/packages/perennial/deployments/kovan/solcInputs/dd52f03d8fef7833844e4ba864fd9fba.json +++ /dev/null @@ -1,342 +0,0 @@ -{ - "language": "Solidity", - "sources": { - "contracts/collateral/Collateral.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/root/control/unstructured/UInitializable.sol\";\nimport \"@equilibria/root/control/unstructured/UReentrancyGuard.sol\";\nimport \"../interfaces/ICollateral.sol\";\nimport \"./types/OptimisticLedger.sol\";\nimport \"../controller/UControllerProvider.sol\";\n\n/**\n * @title Collateral\n * @notice Manages logic and state for all collateral accounts in the protocol.\n */\ncontract Collateral is ICollateral, UInitializable, UControllerProvider, UReentrancyGuard {\n /// @dev ERC20 stablecoin for collateral\n Token18 public immutable token;\n\n /// @dev Per product collateral state\n mapping(IProduct => OptimisticLedger) private _products;\n\n /// @dev Protocol and product fees collected, but not yet claimed\n mapping(address => UFixed18) public fees;\n\n /**\n * @notice Initializes the immutable contract state\n * @dev Called at implementation instantiate and constant for that implementation.\n * @param token_ Collateral ERC20 stablecoin address\n */\n constructor(Token18 token_) {\n token = token_;\n }\n\n /**\n * @notice Initializes the contract state\n * @dev Must be called atomically as part of the upgradeable proxy deployment to\n * avoid front-running\n * @param controller_ Factory contract address\n */\n function initialize(IController controller_) external initializer(1) {\n __UControllerProvider__initialize(controller_);\n __UReentrancyGuard__initialize();\n }\n\n /**\n * @notice Deposits `amount` collateral from `msg.sender` to `account`'s `product`\n * account\n * @param account Account to deposit the collateral for\n * @param product Product to credit the collateral to\n * @param amount Amount of collateral to deposit\n */\n function depositTo(address account, IProduct product, UFixed18 amount)\n external\n nonReentrant\n notPaused\n notZeroAddress(account)\n isProduct(product)\n collateralInvariant(account, product)\n {\n _products[product].creditAccount(account, amount);\n token.pull(msg.sender, amount);\n\n emit Deposit(account, product, amount);\n }\n\n /**\n * @notice Withdraws `amount` collateral from `msg.sender`'s `product` account\n * and sends it to `account`\n * @param account Account to withdraw the collateral to\n * @param product Product to withdraw the collateral from\n * @param amount Amount of collateral to withdraw\n */\n function withdrawTo(address account, IProduct product, UFixed18 amount)\n external\n nonReentrant\n notPaused\n notZeroAddress(account)\n isProduct(product)\n settleForAccount(msg.sender, product)\n collateralInvariant(msg.sender, product)\n maintenanceInvariant(msg.sender, product)\n {\n amount = amount.eq(UFixed18Lib.MAX) ? collateral(msg.sender, product) : amount;\n _products[product].debitAccount(msg.sender, amount);\n token.push(account, amount);\n\n emit Withdrawal(msg.sender, product, amount);\n }\n\n /**\n * @notice Liquidates `account`'s `product` collateral account\n * @dev Account must be under-collateralized, fee returned immediately to `msg.sender`\n * @param account Account to liquidate\n * @param product Product to liquidate for\n */\n function liquidate(address account, IProduct product)\n external\n nonReentrant\n notPaused\n isProduct(product)\n settleForAccount(account, product)\n {\n UFixed18 totalMaintenance = product.maintenance(account);\n UFixed18 totalCollateral = collateral(account, product);\n\n if (!totalMaintenance.gt(totalCollateral))\n revert CollateralCantLiquidate(totalMaintenance, totalCollateral);\n\n product.closeAll(account);\n\n // claim fee\n UFixed18 liquidationFee = controller().liquidationFee();\n UFixed18 fee = UFixed18Lib.min(totalCollateral, totalMaintenance.mul(liquidationFee));\n\n _products[product].debitAccount(account, fee);\n token.push(msg.sender, fee);\n\n emit Liquidation(account, product, msg.sender, fee);\n }\n\n /**\n * @notice Credits `amount` to `account`'s collateral account\n * @dev Callable only by the corresponding product as part of the settlement flywheel.\n * Moves collateral within a product, any collateral leaving the product due to\n * fees has already been accounted for in the settleProduct flywheel.\n * Debits in excess of the account balance get recorded as shortfall, and can be\n * resolved by the product owner as needed.\n * @param account Account to credit\n * @param amount Amount to credit the account (can be negative)\n */\n function settleAccount(address account, Fixed18 amount) external onlyProduct {\n IProduct product = IProduct(msg.sender);\n\n UFixed18 newShortfall = _products[product].settleAccount(account, amount);\n\n emit AccountSettle(product, account, amount, newShortfall);\n }\n\n /**\n * @notice Debits `amount` from product's total collateral account\n * @dev Callable only by the corresponding product as part of the settlement flywheel\n * Removes collateral from the product as fees.\n * @param amount Amount to debit from the account\n */\n function settleProduct(UFixed18 amount) external onlyProduct {\n (IProduct product, IController controller) = (IProduct(msg.sender), controller());\n\n address protocolTreasury = controller.treasury();\n address productTreasury = controller.treasury(product);\n\n UFixed18 protocolFee = amount.mul(controller.protocolFee());\n UFixed18 productFee = amount.sub(protocolFee);\n\n _products[product].debit(amount);\n fees[protocolTreasury] = fees[protocolTreasury].add(protocolFee);\n fees[productTreasury] = fees[productTreasury].add(productFee);\n\n emit ProductSettle(product, protocolFee, productFee);\n }\n\n /**\n * @notice Returns the balance of `account`'s `product` collateral account\n * @param account Account to return for\n * @param product Product to return for\n * @return The balance of the collateral account\n */\n function collateral(address account, IProduct product) public view returns (UFixed18) {\n return _products[product].balances[account];\n }\n\n /**\n * @notice Returns the total balance of `product`'s collateral\n * @param product Product to return for\n * @return The total balance of collateral in the product\n */\n function collateral(IProduct product) external view returns (UFixed18) {\n return _products[product].total;\n }\n\n /**\n * @notice Returns the current shortfall of `product`'s collateral\n * @param product Product to return for\n * @return The current shortfall of the product\n */\n function shortfall(IProduct product) external view returns (UFixed18) {\n return _products[product].shortfall;\n }\n\n /**\n * @notice Returns whether `account`'s `product` collateral account can be liquidated\n * @param account Account to return for\n * @param product Product to return for\n * @return Whether the account can be liquidated\n */\n function liquidatable(address account, IProduct product) external view returns (bool) {\n return product.maintenance(account).gt(collateral(account, product));\n }\n\n /**\n * @notice Returns whether `account`'s `product` collateral account can be liquidated\n * after the next oracle version settlement\n * @dev Takes into account the current pre-position on the account\n * @param account Account to return for\n * @param product Product to return for\n * @return Whether the account can be liquidated\n */\n function liquidatableNext(address account, IProduct product) external view returns (bool) {\n return product.maintenanceNext(account).gt(collateral(account, product));\n }\n\n /**\n * @notice Injects additional collateral into a product to resolve shortfall\n * @dev Shortfall is a measure of settled insolvency in the market\n * This hook can be used by the product owner or an insurance fund to re-capitalize an insolvent market\n * @param product Product to resolve shortfall for\n * @param amount Amount of shortfall to resolve\n */\n function resolveShortfall(IProduct product, UFixed18 amount) external isProduct(product) notPaused {\n _products[product].resolve(amount);\n token.pull(msg.sender, amount);\n\n emit ShortfallResolution(product, amount);\n }\n\n /**\n * @notice Claims all of `msg.sender`'s fees\n */\n function claimFee() external notPaused {\n UFixed18 amount = fees[msg.sender];\n\n fees[msg.sender] = UFixed18Lib.ZERO;\n token.push(msg.sender, amount);\n\n emit FeeClaim(msg.sender, amount);\n }\n\n /// @dev Ensure that the address is non-zero\n modifier notZeroAddress(address account) {\n if (account == address(0)) revert CollateralZeroAddressError();\n\n _;\n }\n\n /// @dev Ensure that the user has sufficient margin for both current and next maintenance\n modifier maintenanceInvariant(address account, IProduct product) {\n _;\n\n UFixed18 maintenance = product.maintenance(account);\n UFixed18 maintenanceNext = product.maintenanceNext(account);\n\n if (UFixed18Lib.max(maintenance, maintenanceNext).gt(collateral(account, product)))\n revert CollateralInsufficientCollateralError();\n }\n\n /// @dev Ensure that the account is either empty or above the collateral minimum\n modifier collateralInvariant(address account, IProduct product) {\n _;\n\n UFixed18 accountCollateral = collateral(account, product);\n if (!accountCollateral.isZero() && accountCollateral.lt(controller().minCollateral()))\n revert CollateralUnderLimitError();\n }\n\n /// @dev Helper to fully settle an account's state\n modifier settleForAccount(address account, IProduct product) {\n product.settleAccount(account);\n\n _;\n }\n}\n" - }, - "@equilibria/root/control/unstructured/UInitializable.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"../../storage/UStorage.sol\";\n\n/**\n * @title UInitializable\n * @notice Library to manage the initialization lifecycle of upgradeable contracts\n * @dev `UInitializable` allows the creation of pseudo-constructors for upgradeable contracts. One\n * `initializer` should be declared per top-level contract. Child contracts can use the `onlyInitializer`\n * modifier to tag their internal initialization functions to ensure that they can only be called\n * from a top-level `initializer` or a constructor.\n */\nabstract contract UInitializable {\n error UInitializableZeroVersionError();\n error UInitializableAlreadyInitializedError(uint256 version);\n error UInitializableNotInitializingError();\n\n event Initialized(uint256 version);\n\n /// @dev The initialized flag\n Uint256Storage private constant _version = Uint256Storage.wrap(keccak256(\"equilibria.root.UInitializable.version\"));\n\n /// @dev The initializing flag\n BoolStorage private constant _initializing = BoolStorage.wrap(keccak256(\"equilibria.root.UInitializable.initializing\"));\n\n /// @dev Can only be called once per version, `version` is 1-indexed\n modifier initializer(uint256 version) {\n if (version == 0) revert UInitializableZeroVersionError();\n if (_version.read() >= version) revert UInitializableAlreadyInitializedError(version);\n\n _version.store(version);\n _initializing.store(true);\n\n _;\n\n _initializing.store(false);\n emit Initialized(version);\n }\n\n /// @dev Can only be called from an initializer or constructor\n modifier onlyInitializer() {\n if (!_constructing() && !_initializing.read()) revert UInitializableNotInitializingError();\n _;\n }\n\n /**\n * @notice Returns whether the contract is currently being constructed\n * @dev {Address.isContract} returns false for contracts currently in the process of being constructed\n * @return Whether the contract is currently being constructed\n */\n function _constructing() private view returns (bool) {\n return !Address.isContract(address(this));\n }\n}\n" - }, - "@equilibria/root/control/unstructured/UReentrancyGuard.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"./UInitializable.sol\";\nimport \"../../storage/UStorage.sol\";\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n *\n * NOTE: This contract has been extended from the Open Zeppelin library to include an\n * unstructured storage pattern, so that it can be safely mixed in with upgradeable\n * contracts without affecting their storage patterns through inheritance.\n */\nabstract contract UReentrancyGuard is UInitializable {\n error UReentrancyGuardReentrantCallError();\n\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n /**\n * @dev unstructured storage slot for the reentrancy status\n */\n Uint256Storage private constant _status = Uint256Storage.wrap(keccak256(\"equilibria.root.UReentrancyGuard.status\"));\n\n /**\n * @dev Initializes the contract setting the status to _NOT_ENTERED.\n */\n function __UReentrancyGuard__initialize() internal onlyInitializer {\n _status.store(_NOT_ENTERED);\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and make it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n // On the first call to nonReentrant, _notEntered will be true\n if (_status.read() == _ENTERED) revert UReentrancyGuardReentrantCallError();\n\n // Any calls to nonReentrant after this point will fail\n _status.store(_ENTERED);\n\n _;\n\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status.store(_NOT_ENTERED);\n }\n}\n" - }, - "contracts/interfaces/ICollateral.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/root/number/types/Fixed18.sol\";\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"./IController.sol\";\nimport \"./IProduct.sol\";\n\ninterface ICollateral {\n event Deposit(address indexed user, IProduct indexed product, UFixed18 amount);\n event Withdrawal(address indexed user, IProduct indexed product, UFixed18 amount);\n event AccountSettle(IProduct indexed product, address indexed account, Fixed18 amount, UFixed18 newShortfall);\n event ProductSettle(IProduct indexed product, UFixed18 protocolFee, UFixed18 productFee);\n event Liquidation(address indexed user, IProduct indexed product, address liquidator, UFixed18 fee);\n event ShortfallResolution(IProduct indexed product, UFixed18 amount);\n event FeeClaim(address indexed account, UFixed18 amount);\n\n error CollateralCantLiquidate(UFixed18 totalMaintenance, UFixed18 totalCollateral);\n error CollateralInsufficientCollateralError();\n error CollateralUnderLimitError();\n error CollateralZeroAddressError();\n\n function token() external view returns (Token18);\n function fees(address account) external view returns (UFixed18);\n function initialize(IController controller_) external;\n function depositTo(address account, IProduct product, UFixed18 amount) external;\n function withdrawTo(address account, IProduct product, UFixed18 amount) external;\n function liquidate(address account, IProduct product) external;\n function settleAccount(address account, Fixed18 amount) external;\n function settleProduct(UFixed18 amount) external;\n function collateral(address account, IProduct product) external view returns (UFixed18);\n function collateral(IProduct product) external view returns (UFixed18);\n function shortfall(IProduct product) external view returns (UFixed18);\n function liquidatable(address account, IProduct product) external view returns (bool);\n function liquidatableNext(address account, IProduct product) external view returns (bool);\n function resolveShortfall(IProduct product, UFixed18 amount) external;\n function claimFee() external;\n}\n" - }, - "contracts/collateral/types/OptimisticLedger.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\n\n/// @dev OptimisticLedger type\nstruct OptimisticLedger {\n /// @dev Individual account collateral balances\n mapping(address => UFixed18) balances;\n\n /// @dev Total ledger collateral balance\n UFixed18 total;\n\n /// @dev Total ledger collateral shortfall\n UFixed18 shortfall;\n}\nusing OptimisticLedgerLib for OptimisticLedger global;\n\n/**\n * @title OptimisticLedgerLib\n * @notice Library that manages a global vs account ledger where the global ledger is settled separately,\n * and ahead of, the user-level accounts.\n * @dev Ensures that no more collateral leaves the ledger than goes it, while allowing user-level accounts\n * to settle as a follow up step. Overdrafts on the user-level are accounted as \"shortall\". Shortfall\n * in the system is the quantity of insolvency that can be optionally resolved by the ledger owner.\n * Until the shortfall is resolved, collateral may be withdrawn from the ledger on a FCFS basis. However\n * once the ledger total has been depleted, users will not be able to withdraw even if they have non-zero\n * user level balances until the shortfall is resolved, recapitalizing the ledger.\n */\nlibrary OptimisticLedgerLib {\n /**\n * @notice Credits `account` with `amount` collateral\n * @param self The struct to operate on\n * @param account Account to credit collateral to\n * @param amount Amount of collateral to credit\n */\n function creditAccount(OptimisticLedger storage self, address account, UFixed18 amount) internal {\n self.balances[account] = self.balances[account].add(amount);\n self.total = self.total.add(amount);\n }\n\n /**\n * @notice Debits `account` `amount` collateral\n * @param self The struct to operate on\n * @param account Account to debit collateral from\n * @param amount Amount of collateral to debit\n */\n function debitAccount(OptimisticLedger storage self, address account, UFixed18 amount) internal {\n self.balances[account] = self.balances[account].sub(amount);\n self.total = self.total.sub(amount);\n }\n\n /**\n * @notice Credits `account` with `amount` collateral\n * @dev Funds come from inside the product, not totals are updated\n * Shortfall is created if more funds are debited from an account than exist\n * @param self The struct to operate on\n * @param account Account to credit collateral to\n * @param amount Amount of collateral to credit\n * @return newShortfall Any new shortfall incurred during this settlement\n */\n function settleAccount(OptimisticLedger storage self, address account, Fixed18 amount)\n internal returns (UFixed18 newShortfall) {\n Fixed18 newBalance = Fixed18Lib.from(self.balances[account]).add(amount);\n\n if (newBalance.sign() == -1) {\n newShortfall = newBalance.abs();\n newBalance = Fixed18Lib.ZERO;\n }\n\n self.balances[account] = newBalance.abs();\n self.shortfall = self.shortfall.add(newShortfall);\n }\n\n /**\n * @notice Debits ledger globally `amount` collateral\n * @dev Removes balance from total that is accounted for elsewhere (e.g. product-level accumulators)\n * @param self The struct to operate on\n * @param amount Amount of collateral to debit\n */\n function debit(OptimisticLedger storage self, UFixed18 amount) internal {\n self.total = self.total.sub(amount);\n }\n\n /**\n * @notice Reduces the amount of collateral shortfall in the ledger\n * @param self The struct to operate on\n * @param amount Amount of shortfall to resolve\n */\n function resolve(OptimisticLedger storage self, UFixed18 amount) internal {\n self.shortfall = self.shortfall.sub(amount);\n self.total = self.total.add(amount);\n }\n}\n" - }, - "contracts/controller/UControllerProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/root/control/unstructured/UInitializable.sol\";\nimport \"@equilibria/root/storage/UStorage.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"../interfaces/IController.sol\";\nimport \"../interfaces/IProduct.sol\";\n\n/**\n * @title UControllerProvider\n * @notice Mix-in that manages a controller pointer and associated permissioning modifiers.\n * @dev Uses unstructured storage so that it is safe to mix-in to upgreadable contracts without modifying\n * their storage layout.\n */\nabstract contract UControllerProvider is UInitializable {\n error NotOwnerError(uint256 coordinatorId);\n error NotProductError(IProduct product);\n error NotCollateralError();\n error PausedError();\n error InvalidControllerError();\n\n /// @dev The controller contract address\n AddressStorage private constant _controller = AddressStorage.wrap(keccak256(\"equilibria.perennial.UControllerProvider.controller\"));\n function controller() public view returns (IController) { return IController(_controller.read()); }\n\n /**\n * @notice Initializes the contract state\n * @param controller_ Protocol Controller contract address\n */\n // solhint-disable-next-line func-name-mixedcase\n function __UControllerProvider__initialize(IController controller_) internal onlyInitializer {\n if (!Address.isContract(address(controller_))) revert InvalidControllerError();\n _controller.store(address(controller_));\n }\n\n /// @dev Only allow a valid product contract to call\n modifier onlyProduct {\n if (!controller().isProduct(IProduct(msg.sender))) revert NotProductError(IProduct(msg.sender));\n\n _;\n }\n\n /// @dev Verify that `product` is a valid product contract\n modifier isProduct(IProduct product) {\n if (!controller().isProduct(product)) revert NotProductError(product);\n\n _;\n }\n\n /// @dev Only allow the Collateral contract to call\n modifier onlyCollateral {\n if (msg.sender != address(controller().collateral())) revert NotCollateralError();\n\n _;\n }\n\n /// @dev Only allow the coordinator owner to call\n modifier onlyOwner(uint256 coordinatorId) {\n if (msg.sender != controller().owner(coordinatorId)) revert NotOwnerError(coordinatorId);\n\n _;\n }\n\n /// @dev Only allow if the protocol is currently unpaused\n modifier notPaused() {\n if (controller().paused()) revert PausedError();\n\n _;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Address.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // 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\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" - }, - "@equilibria/root/storage/UStorage.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"../number/types/UFixed18.sol\";\n\n/// @dev Stored boolean slot\ntype BoolStorage is bytes32;\nusing BoolStorageLib for BoolStorage global;\n\n/// @dev Stored uint256 slot\ntype Uint256Storage is bytes32;\nusing Uint256StorageLib for Uint256Storage global;\n\n/// @dev Stored int256 slot\ntype Int256Storage is bytes32;\nusing Int256StorageLib for Int256Storage global;\n\n/// @dev Stored address slot\ntype AddressStorage is bytes32;\nusing AddressStorageLib for AddressStorage global;\n\n/// @dev Stored bytes32 slot\ntype Bytes32Storage is bytes32;\nusing Bytes32StorageLib for Bytes32Storage global;\n\n/**\n * @title BoolStorageLib\n * @notice Library to manage storage and retrival of a boolean at a fixed storage slot\n */\nlibrary BoolStorageLib {\n /**\n * @notice Retrieves the stored value\n * @param self Storage slot\n * @return value Stored bool value\n */\n function read(BoolStorage self) internal view returns (bool value) {\n assembly {\n value := sload(self)\n }\n }\n\n /**\n * @notice Stores the value at the specific slot\n * @param self Storage slot\n * @param value boolean value to store\n */\n function store(BoolStorage self, bool value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n\n/**\n * @title Uint256StorageLib\n * @notice Library to manage storage and retrival of an uint256 at a fixed storage slot\n */\nlibrary Uint256StorageLib {\n /**\n * @notice Retrieves the stored value\n * @param self Storage slot\n * @return value Stored uint256 value\n */\n function read(Uint256Storage self) internal view returns (uint256 value) {\n assembly {\n value := sload(self)\n }\n }\n\n /**\n * @notice Stores the value at the specific slot\n * @param self Storage slot\n * @param value uint256 value to store\n */\n function store(Uint256Storage self, uint256 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n\n/**\n * @title Int256StorageLib\n * @notice Library to manage storage and retrival of an int256 at a fixed storage slot\n */\nlibrary Int256StorageLib {\n /**\n * @notice Retrieves the stored value\n * @param self Storage slot\n * @return value Stored int256 value\n */\n function read(Int256Storage self) internal view returns (int256 value) {\n assembly {\n value := sload(self)\n }\n }\n\n /**\n * @notice Stores the value at the specific slot\n * @param self Storage slot\n * @param value int256 value to store\n */\n function store(Int256Storage self, int256 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n\n/**\n * @title AddressStorageLib\n * @notice Library to manage storage and retrival of an address at a fixed storage slot\n */\nlibrary AddressStorageLib {\n /**\n * @notice Retrieves the stored value\n * @param self Storage slot\n * @return value Stored address value\n */\n function read(AddressStorage self) internal view returns (address value) {\n assembly {\n value := sload(self)\n }\n }\n\n /**\n * @notice Stores the value at the specific slot\n * @param self Storage slot\n * @param value address value to store\n */\n function store(AddressStorage self, address value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n\n/**\n * @title Bytes32StorageLib\n * @notice Library to manage storage and retrival of a bytes32 at a fixed storage slot\n */\nlibrary Bytes32StorageLib {\n /**\n * @notice Retrieves the stored value\n * @param self Storage slot\n * @return value Stored bytes32 value\n */\n function read(Bytes32Storage self) internal view returns (bytes32 value) {\n assembly {\n value := sload(self)\n }\n }\n\n /**\n * @notice Stores the value at the specific slot\n * @param self Storage slot\n * @param value bytes32 value to store\n */\n function store(Bytes32Storage self, bytes32 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "@equilibria/root/number/types/UFixed18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"./Fixed18.sol\";\nimport \"./PackedUFixed18.sol\";\n\n/// @dev UFixed18 type\ntype UFixed18 is uint256;\nusing UFixed18Lib for UFixed18 global;\ntype UFixed18Storage is bytes32;\nusing UFixed18StorageLib for UFixed18Storage global;\n\n/**\n * @title UFixed18Lib\n * @notice Library for the unsigned fixed-decimal type.\n */\nlibrary UFixed18Lib {\n error UFixed18UnderflowError(int256 value);\n error UFixed18PackingOverflowError(uint256 value);\n\n uint256 private constant BASE = 1e18;\n UFixed18 public constant ZERO = UFixed18.wrap(0);\n UFixed18 public constant ONE = UFixed18.wrap(BASE);\n UFixed18 public constant MAX = UFixed18.wrap(type(uint256).max);\n\n /**\n * @notice Creates a unsigned fixed-decimal from a signed fixed-decimal\n * @param a Signed fixed-decimal\n * @return New unsigned fixed-decimal\n */\n function from(Fixed18 a) internal pure returns (UFixed18) {\n int256 value = Fixed18.unwrap(a);\n if (value < 0) revert UFixed18UnderflowError(value);\n return UFixed18.wrap(uint256(value));\n }\n\n /**\n * @notice Creates a unsigned fixed-decimal from a unsigned integer\n * @param a Unsigned number\n * @return New unsigned fixed-decimal\n */\n function from(uint256 a) internal pure returns (UFixed18) {\n return UFixed18.wrap(a * BASE);\n }\n\n /**\n * @notice Creates a packed unsigned fixed-decimal from an unsigned fixed-decimal\n * @param a unsigned fixed-decimal\n * @return New packed unsigned fixed-decimal\n */\n function pack(UFixed18 a) internal pure returns (PackedUFixed18) {\n uint256 value = UFixed18.unwrap(a);\n if (value > type(uint128).max) revert UFixed18PackingOverflowError(value);\n return PackedUFixed18.wrap(uint128(value));\n }\n\n /**\n * @notice Returns whether the unsigned fixed-decimal is equal to zero.\n * @param a Unsigned fixed-decimal\n * @return Whether the unsigned fixed-decimal is zero.\n */\n function isZero(UFixed18 a) internal pure returns (bool) {\n return UFixed18.unwrap(a) == 0;\n }\n\n /**\n * @notice Adds two unsigned fixed-decimals `a` and `b` together\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Resulting summed unsigned fixed-decimal\n */\n function add(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) + UFixed18.unwrap(b));\n }\n\n /**\n * @notice Subtracts unsigned fixed-decimal `b` from `a`\n * @param a Unsigned fixed-decimal to subtract from\n * @param b Unsigned fixed-decimal to subtract\n * @return Resulting subtracted unsigned fixed-decimal\n */\n function sub(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) - UFixed18.unwrap(b));\n }\n\n /**\n * @notice Multiplies two unsigned fixed-decimals `a` and `b` together\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Resulting multiplied unsigned fixed-decimal\n */\n function mul(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / BASE);\n }\n\n /**\n * @notice Divides unsigned fixed-decimal `a` by `b`\n * @param a Unsigned fixed-decimal to divide\n * @param b Unsigned fixed-decimal to divide by\n * @return Resulting divided unsigned fixed-decimal\n */\n function div(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) * BASE / UFixed18.unwrap(b));\n }\n\n /**\n * @notice Divides unsigned fixed-decimal `a` by `b`\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0` and `MAX` for `n/0`.\n * @param a Unsigned fixed-decimal to divide\n * @param b Unsigned fixed-decimal to divide by\n * @return Resulting divided unsigned fixed-decimal\n */\n function unsafeDiv(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n if (isZero(b)) {\n return isZero(a) ? ONE : MAX;\n } else {\n return div(a, b);\n }\n }\n\n /**\n * @notice Computes a * b / c without loss of precision due to BASE conversion\n * @param a First unsigned fixed-decimal\n * @param b Unsigned number to multiply by\n * @param c Unsigned number to divide by\n * @return Resulting computation\n */\n function muldiv(UFixed18 a, uint256 b, uint256 c) internal pure returns (UFixed18) {\n return muldiv(a, UFixed18.wrap(b), UFixed18.wrap(c));\n }\n\n /**\n * @notice Computes a * b / c without loss of precision due to BASE conversion\n * @param a First unsigned fixed-decimal\n * @param b Unsigned fixed-decimal to multiply by\n * @param c Unsigned fixed-decimal to divide by\n * @return Resulting computation\n */\n function muldiv(UFixed18 a, UFixed18 b, UFixed18 c) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / UFixed18.unwrap(c));\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is equal to `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is equal to `b`\n */\n function eq(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return compare(a, b) == 1;\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is greater than `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is greater than `b`\n */\n function gt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return compare(a, b) == 2;\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is less than `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is less than `b`\n */\n function lt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return compare(a, b) == 0;\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is greater than or equal to `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is greater than or equal to `b`\n */\n function gte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return gt(a, b) || eq(a, b);\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is less than or equal to `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is less than or equal to `b`\n */\n function lte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return lt(a, b) || eq(a, b);\n }\n\n /**\n * @notice Compares the unsigned fixed-decimals `a` and `b`\n * @dev Returns: 2 for greater than\n * 1 for equal to\n * 0 for less than\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Compare result of `a` and `b`\n */\n function compare(UFixed18 a, UFixed18 b) internal pure returns (uint256) {\n (uint256 au, uint256 bu) = (UFixed18.unwrap(a), UFixed18.unwrap(b));\n if (au > bu) return 2;\n if (au < bu) return 0;\n return 1;\n }\n\n /**\n * @notice Returns a unsigned fixed-decimal representing the ratio of `a` over `b`\n * @param a First unsigned number\n * @param b Second unsigned number\n * @return Ratio of `a` over `b`\n */\n function ratio(uint256 a, uint256 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(a * BASE / b);\n }\n\n /**\n * @notice Returns the minimum of unsigned fixed-decimals `a` and `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Minimum of `a` and `b`\n */\n function min(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(Math.min(UFixed18.unwrap(a), UFixed18.unwrap(b)));\n }\n\n /**\n * @notice Returns the maximum of unsigned fixed-decimals `a` and `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Maximum of `a` and `b`\n */\n function max(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(Math.max(UFixed18.unwrap(a), UFixed18.unwrap(b)));\n }\n\n /**\n * @notice Converts the unsigned fixed-decimal into an integer, truncating any decimal portion\n * @param a Unsigned fixed-decimal\n * @return Truncated unsigned number\n */\n function truncate(UFixed18 a) internal pure returns (uint256) {\n return UFixed18.unwrap(a) / BASE;\n }\n}\n\nlibrary UFixed18StorageLib {\n function read(UFixed18Storage self) internal view returns (UFixed18 value) {\n assembly {\n value := sload(self)\n }\n }\n\n function store(UFixed18Storage self, UFixed18 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return 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 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 up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a / b + (a % b == 0 ? 0 : 1);\n }\n}\n" - }, - "@equilibria/root/number/types/Fixed18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/SignedMath.sol\";\nimport \"./UFixed18.sol\";\nimport \"./PackedFixed18.sol\";\n\n/// @dev Fixed18 type\ntype Fixed18 is int256;\nusing Fixed18Lib for Fixed18 global;\ntype Fixed18Storage is bytes32;\nusing Fixed18StorageLib for Fixed18Storage global;\n\n/**\n * @title Fixed18Lib\n * @notice Library for the signed fixed-decimal type.\n */\nlibrary Fixed18Lib {\n error Fixed18OverflowError(uint256 value);\n error Fixed18PackingOverflowError(int256 value);\n error Fixed18PackingUnderflowError(int256 value);\n\n int256 private constant BASE = 1e18;\n Fixed18 public constant ZERO = Fixed18.wrap(0);\n Fixed18 public constant ONE = Fixed18.wrap(BASE);\n Fixed18 public constant NEG_ONE = Fixed18.wrap(-1 * BASE);\n Fixed18 public constant MAX = Fixed18.wrap(type(int256).max);\n Fixed18 public constant MIN = Fixed18.wrap(type(int256).min);\n\n /**\n * @notice Creates a signed fixed-decimal from an unsigned fixed-decimal\n * @param a Unsigned fixed-decimal\n * @return New signed fixed-decimal\n */\n function from(UFixed18 a) internal pure returns (Fixed18) {\n uint256 value = UFixed18.unwrap(a);\n if (value > uint256(type(int256).max)) revert Fixed18OverflowError(value);\n return Fixed18.wrap(int256(value));\n }\n\n /**\n * @notice Creates a signed fixed-decimal from a sign and an unsigned fixed-decimal\n * @param s Sign\n * @param m Unsigned fixed-decimal magnitude\n * @return New signed fixed-decimal\n */\n function from(int256 s, UFixed18 m) internal pure returns (Fixed18) {\n if (s > 0) return from(m);\n if (s < 0) return Fixed18.wrap(-1 * Fixed18.unwrap(from(m)));\n return ZERO;\n }\n\n /**\n * @notice Creates a signed fixed-decimal from a signed integer\n * @param a Signed number\n * @return New signed fixed-decimal\n */\n function from(int256 a) internal pure returns (Fixed18) {\n return Fixed18.wrap(a * BASE);\n }\n\n /**\n * @notice Creates a packed signed fixed-decimal from an signed fixed-decimal\n * @param a signed fixed-decimal\n * @return New packed signed fixed-decimal\n */\n function pack(Fixed18 a) internal pure returns (PackedFixed18) {\n int256 value = Fixed18.unwrap(a);\n if (value > type(int128).max) revert Fixed18PackingOverflowError(value);\n if (value < type(int128).min) revert Fixed18PackingUnderflowError(value);\n return PackedFixed18.wrap(int128(value));\n }\n\n /**\n * @notice Returns whether the signed fixed-decimal is equal to zero.\n * @param a Signed fixed-decimal\n * @return Whether the signed fixed-decimal is zero.\n */\n function isZero(Fixed18 a) internal pure returns (bool) {\n return Fixed18.unwrap(a) == 0;\n }\n\n /**\n * @notice Adds two signed fixed-decimals `a` and `b` together\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Resulting summed signed fixed-decimal\n */\n function add(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) + Fixed18.unwrap(b));\n }\n\n /**\n * @notice Subtracts signed fixed-decimal `b` from `a`\n * @param a Signed fixed-decimal to subtract from\n * @param b Signed fixed-decimal to subtract\n * @return Resulting subtracted signed fixed-decimal\n */\n function sub(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) - Fixed18.unwrap(b));\n }\n\n /**\n * @notice Multiplies two signed fixed-decimals `a` and `b` together\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Resulting multiplied signed fixed-decimal\n */\n function mul(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / BASE);\n }\n\n /**\n * @notice Divides signed fixed-decimal `a` by `b`\n * @param a Signed fixed-decimal to divide\n * @param b Signed fixed-decimal to divide by\n * @return Resulting divided signed fixed-decimal\n */\n function div(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) * BASE / Fixed18.unwrap(b));\n }\n\n /**\n * @notice Divides unsigned fixed-decimal `a` by `b`\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0`, `MAX` for `n/0`, and `MIN` for `-n/0`.\n * @param a Unsigned fixed-decimal to divide\n * @param b Unsigned fixed-decimal to divide by\n * @return Resulting divided unsigned fixed-decimal\n */\n function unsafeDiv(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n if (isZero(b)) {\n if (gt(a, ZERO)) return MAX;\n if (lt(a, ZERO)) return MIN;\n return ONE;\n } else {\n return div(a, b);\n }\n }\n\n /**\n * @notice Computes a * b / c without loss of precision due to BASE conversion\n * @param a First signed fixed-decimal\n * @param b Signed number to multiply by\n * @param c Signed number to divide by\n * @return Resulting computation\n */\n function muldiv(Fixed18 a, int256 b, int256 c) internal pure returns (Fixed18) {\n return muldiv(a, Fixed18.wrap(b), Fixed18.wrap(c));\n }\n\n /**\n * @notice Computes a * b / c without loss of precision due to BASE conversion\n * @param a First signed fixed-decimal\n * @param b Signed fixed-decimal to multiply by\n * @param c Signed fixed-decimal to divide by\n * @return Resulting computation\n */\n function muldiv(Fixed18 a, Fixed18 b, Fixed18 c) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / Fixed18.unwrap(c));\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is equal to `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is equal to `b`\n */\n function eq(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return compare(a, b) == 1;\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is greater than `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is greater than `b`\n */\n function gt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return compare(a, b) == 2;\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is less than `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is less than `b`\n */\n function lt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return compare(a, b) == 0;\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is greater than or equal to `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is greater than or equal to `b`\n */\n function gte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return gt(a, b) || eq(a, b);\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is less than or equal to `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is less than or equal to `b`\n */\n function lte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return lt(a, b) || eq(a, b);\n }\n\n /**\n * @notice Compares the signed fixed-decimals `a` and `b`\n * @dev Returns: 2 for greater than\n * 1 for equal to\n * 0 for less than\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Compare result of `a` and `b`\n */\n function compare(Fixed18 a, Fixed18 b) internal pure returns (uint256) {\n (int256 au, int256 bu) = (Fixed18.unwrap(a), Fixed18.unwrap(b));\n if (au > bu) return 2;\n if (au < bu) return 0;\n return 1;\n }\n\n /**\n * @notice Returns a signed fixed-decimal representing the ratio of `a` over `b`\n * @param a First signed number\n * @param b Second signed number\n * @return Ratio of `a` over `b`\n */\n function ratio(int256 a, int256 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(a * BASE / b);\n }\n\n /**\n * @notice Returns the minimum of signed fixed-decimals `a` and `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Minimum of `a` and `b`\n */\n function min(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(SignedMath.min(Fixed18.unwrap(a), Fixed18.unwrap(b)));\n }\n\n /**\n * @notice Returns the maximum of signed fixed-decimals `a` and `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Maximum of `a` and `b`\n */\n function max(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(SignedMath.max(Fixed18.unwrap(a), Fixed18.unwrap(b)));\n }\n\n /**\n * @notice Converts the signed fixed-decimal into an integer, truncating any decimal portion\n * @param a Signed fixed-decimal\n * @return Truncated signed number\n */\n function truncate(Fixed18 a) internal pure returns (int256) {\n return Fixed18.unwrap(a) / BASE;\n }\n\n /**\n * @notice Returns the sign of the signed fixed-decimal\n * @dev Returns: -1 for negative\n * 0 for zero\n * 1 for positive\n * @param a Signed fixed-decimal\n * @return Sign of the signed fixed-decimal\n */\n function sign(Fixed18 a) internal pure returns (int256) {\n if (Fixed18.unwrap(a) > 0) return 1;\n if (Fixed18.unwrap(a) < 0) return -1;\n return 0;\n }\n\n /**\n * @notice Returns the absolute value of the signed fixed-decimal\n * @param a Signed fixed-decimal\n * @return Absolute value of the signed fixed-decimal\n */\n function abs(Fixed18 a) internal pure returns (UFixed18) {\n return UFixed18.wrap(SignedMath.abs(Fixed18.unwrap(a)));\n }\n}\n\nlibrary Fixed18StorageLib {\n function read(Fixed18Storage self) internal view returns (Fixed18 value) {\n assembly {\n value := sload(self)\n }\n }\n\n function store(Fixed18Storage self, Fixed18 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "@equilibria/root/number/types/PackedUFixed18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"./UFixed18.sol\";\n\n/// @dev PackedUFixed18 type\ntype PackedUFixed18 is uint128;\nusing PackedUFixed18Lib for PackedUFixed18 global;\n\n/**\n * @title PackedUFixed18Lib\n * @dev A packed version of the UFixed18 which takes up half the storage space (two PackedUFixed18 can be packed\n * into a single slot). Only valid within the range 0 <= x <= 3.4028237e+20.\n * @notice Library for the packed unsigned fixed-decimal type.\n */\nlibrary PackedUFixed18Lib {\n PackedUFixed18 public constant MAX = PackedUFixed18.wrap(type(uint128).max);\n\n /**\n * @notice Creates an unpacked unsigned fixed-decimal from a packed unsigned fixed-decimal\n * @param self packed unsigned fixed-decimal\n * @return New unpacked unsigned fixed-decimal\n */\n function unpack(PackedUFixed18 self) internal pure returns (UFixed18) {\n return UFixed18.wrap(uint256(PackedUFixed18.unwrap(self)));\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/SignedMath.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n /**\n * @dev Returns the largest of two signed numbers.\n */\n function max(int256 a, int256 b) internal pure returns (int256) {\n return 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 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 // must be unchecked in order to support `n = type(int256).min`\n return uint256(n >= 0 ? n : -n);\n }\n }\n}\n" - }, - "@equilibria/root/number/types/PackedFixed18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"./Fixed18.sol\";\n\n/// @dev PackedFixed18 type\ntype PackedFixed18 is int128;\nusing PackedFixed18Lib for PackedFixed18 global;\n\n/**\n * @title PackedFixed18Lib\n * @dev A packed version of the Fixed18 which takes up half the storage space (two PackedFixed18 can be packed\n * into a single slot). Only valid within the range -1.7014118e+20 <= x <= 1.7014118e+20.\n * @notice Library for the packed signed fixed-decimal type.\n */\nlibrary PackedFixed18Lib {\n PackedFixed18 public constant MAX = PackedFixed18.wrap(type(int128).max);\n PackedFixed18 public constant MIN = PackedFixed18.wrap(type(int128).min);\n\n /**\n * @notice Creates an unpacked signed fixed-decimal from a packed signed fixed-decimal\n * @param self packed signed fixed-decimal\n * @return New unpacked signed fixed-decimal\n */\n function unpack(PackedFixed18 self) internal pure returns (Fixed18) {\n return Fixed18.wrap(int256(PackedFixed18.unwrap(self)));\n }\n}\n" - }, - "@equilibria/root/token/types/Token18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"../../number/types/UFixed18.sol\";\n\n/// @dev Token18\ntype Token18 is address;\nusing Token18Lib for Token18 global;\ntype Token18Storage is bytes32;\nusing Token18StorageLib for Token18Storage global;\n\n/**\n * @title Token18Lib\n * @notice Library to manage 18-decimal ERC20s that is compliant with the fixed-decimal types.\n * @dev Maintains significant gas savings over other Token implementations since no conversion take place\n */\nlibrary Token18Lib {\n using SafeERC20 for IERC20;\n\n Token18 public constant ZERO = Token18.wrap(address(0));\n\n /**\n * @notice Returns whether a token is the zero address\n * @param self Token to check for\n * @return Whether the token is the zero address\n */\n function isZero(Token18 self) internal pure returns (bool) {\n return Token18.unwrap(self) == Token18.unwrap(ZERO);\n }\n\n /**\n * @notice Returns whether the two tokens are equal\n * @param a First token to compare\n * @param b Second token to compare\n * @return Whether the two tokens are equal\n */\n function eq(Token18 a, Token18 b) internal pure returns (bool) {\n return Token18.unwrap(a) == Token18.unwrap(b);\n }\n\n /**\n * @notice Approves `grantee` to spend infinite tokens from the caller\n * @param self Token to transfer\n * @param grantee Address to allow spending\n */\n function approve(Token18 self, address grantee) internal {\n IERC20(Token18.unwrap(self)).safeApprove(grantee, type(uint256).max);\n }\n\n /**\n * @notice Approves `grantee` to spend `amount` tokens from the caller\n * @dev There are important race conditions to be aware of when using this function\n with values other than 0. This will revert if moving from non-zero to non-zero amounts\n See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/a55b7d13722e7ce850b626da2313f3e66ca1d101/contracts/token/ERC20/IERC20.sol#L57\n * @param self Token to transfer\n * @param grantee Address to allow spending\n * @param amount Amount of tokens to approve to spend\n */\n function approve(Token18 self, address grantee, UFixed18 amount) internal {\n IERC20(Token18.unwrap(self)).safeApprove(grantee, UFixed18.unwrap(amount));\n }\n\n /**\n * @notice Transfers all held tokens from the caller to the `recipient`\n * @param self Token to transfer\n * @param recipient Address to receive the tokens\n */\n function push(Token18 self, address recipient) internal {\n push(self, recipient, balanceOf(self, address(this)));\n }\n\n /**\n * @notice Transfers `amount` tokens from the caller to the `recipient`\n * @param self Token to transfer\n * @param recipient Address to transfer tokens to\n * @param amount Amount of tokens to transfer\n */\n function push(Token18 self, address recipient, UFixed18 amount) internal {\n IERC20(Token18.unwrap(self)).safeTransfer(recipient, UFixed18.unwrap(amount));\n }\n\n /**\n * @notice Transfers `amount` tokens from the `benefactor` to the caller\n * @dev Reverts if trying to pull Ether\n * @param self Token to transfer\n * @param benefactor Address to transfer tokens from\n * @param amount Amount of tokens to transfer\n */\n function pull(Token18 self, address benefactor, UFixed18 amount) internal {\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, address(this), UFixed18.unwrap(amount));\n }\n\n /**\n * @notice Transfers `amount` tokens from the `benefactor` to `recipient`\n * @dev Reverts if trying to pull Ether\n * @param self Token to transfer\n * @param benefactor Address to transfer tokens from\n * @param recipient Address to transfer tokens to\n * @param amount Amount of tokens to transfer\n */\n function pullTo(Token18 self, address benefactor, address recipient, UFixed18 amount) internal {\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, recipient, UFixed18.unwrap(amount));\n }\n\n /**\n * @notice Returns the name of the token\n * @param self Token to check for\n * @return Token name\n */\n function name(Token18 self) internal view returns (string memory) {\n return IERC20Metadata(Token18.unwrap(self)).name();\n }\n\n /**\n * @notice Returns the symbol of the token\n * @param self Token to check for\n * @return Token symbol\n */\n function symbol(Token18 self) internal view returns (string memory) {\n return IERC20Metadata(Token18.unwrap(self)).symbol();\n }\n\n /**\n * @notice Returns the `self` token balance of the caller\n * @param self Token to check for\n * @return Token balance of the caller\n */\n function balanceOf(Token18 self) internal view returns (UFixed18) {\n return balanceOf(self, address(this));\n }\n\n /**\n * @notice Returns the `self` token balance of `account`\n * @param self Token to check for\n * @param account Account to check\n * @return Token balance of the account\n */\n function balanceOf(Token18 self, address account) internal view returns (UFixed18) {\n return UFixed18.wrap(IERC20(Token18.unwrap(self)).balanceOf(account));\n }\n}\n\nlibrary Token18StorageLib {\n function read(Token18Storage self) internal view returns (Token18 value) {\n assembly {\n value := sload(self)\n }\n }\n\n function store(Token18Storage self, Token18 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "contracts/interfaces/IController.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\";\nimport \"./ICollateral.sol\";\nimport \"./IIncentivizer.sol\";\nimport \"./IProduct.sol\";\nimport \"./types/PayoffDefinition.sol\";\n\ninterface IController {\n /// @dev Coordinator of a one or many products\n struct Coordinator {\n /// @dev Pending owner of the product, can accept ownership\n address pendingOwner;\n\n /// @dev Owner of the product, allowed to update select parameters\n address owner;\n\n /// @dev Treasury of the product, collects fees\n address treasury;\n }\n\n event CollateralUpdated(ICollateral newCollateral);\n event IncentivizerUpdated(IIncentivizer newIncentivizer);\n event ProductBeaconUpdated(IBeacon newProductBeacon);\n event ProtocolFeeUpdated(UFixed18 newProtocolFee);\n event MinFundingFeeUpdated(UFixed18 newMinFundingFee);\n event LiquidationFeeUpdated(UFixed18 newLiquidationFee);\n event IncentivizationFeeUpdated(UFixed18 newIncentivizationFee);\n event MinCollateralUpdated(UFixed18 newMinCollateral);\n event ProgramsPerProductUpdated(uint256 newProgramsPerProduct);\n event PauserUpdated(address newPauser);\n event PausedUpdated(bool newPaused);\n event CoordinatorPendingOwnerUpdated(uint256 indexed coordinatorId, address newPendingOwner);\n event CoordinatorOwnerUpdated(uint256 indexed coordinatorId, address newOwner);\n event CoordinatorTreasuryUpdated(uint256 indexed coordinatorId, address newTreasury);\n event CoordinatorCreated(uint256 indexed coordinatorId, address owner);\n event ProductCreated(IProduct indexed product, IProduct.ProductInfo productInfo);\n\n error ControllerNoZeroCoordinatorError();\n error ControllerNotPauserError();\n error ControllerNotOwnerError(uint256 controllerId);\n error ControllerNotPendingOwnerError(uint256 controllerId);\n error ControllerInvalidProtocolFeeError();\n error ControllerInvalidMinFundingFeeError();\n error ControllerInvalidLiquidationFeeError();\n error ControllerInvalidIncentivizationFeeError();\n error ControllerNotContractAddressError();\n\n function collateral() external view returns (ICollateral);\n function incentivizer() external view returns (IIncentivizer);\n function productBeacon() external view returns (IBeacon);\n function coordinators(uint256 collateralId) external view returns (Coordinator memory);\n function coordinatorFor(IProduct product) external view returns (uint256);\n function protocolFee() external view returns (UFixed18);\n function minFundingFee() external view returns (UFixed18);\n function liquidationFee() external view returns (UFixed18);\n function incentivizationFee() external view returns (UFixed18);\n function minCollateral() external view returns (UFixed18);\n function programsPerProduct() external view returns (uint256);\n function pauser() external view returns (address);\n function paused() external view returns (bool);\n function initialize(ICollateral collateral_, IIncentivizer incentivizer_, IBeacon productBeacon_) external;\n function createCoordinator() external returns (uint256);\n function updateCoordinatorPendingOwner(uint256 coordinatorId, address newPendingOwner) external;\n function acceptCoordinatorOwner(uint256 coordinatorId) external;\n function updateCoordinatorTreasury(uint256 coordinatorId, address newTreasury) external;\n function createProduct(uint256 coordinatorId, IProduct.ProductInfo calldata productInfo) external returns (IProduct);\n function updateCollateral(ICollateral newCollateral) external;\n function updateIncentivizer(IIncentivizer newIncentivizer) external;\n function updateProductBeacon(IBeacon newProductBeacon) external;\n function updateProtocolFee(UFixed18 newProtocolFee) external;\n function updateMinFundingFee(UFixed18 newMinFundingFee) external;\n function updateLiquidationFee(UFixed18 newLiquidationFee) external;\n function updateIncentivizationFee(UFixed18 newIncentivizationFee) external;\n function updateMinCollateral(UFixed18 newMinCollateral) external;\n function updateProgramsPerProduct(uint256 newProductsPerProduct) external;\n function updatePauser(address newPauser) external;\n function updatePaused(bool newPaused) external;\n function isProduct(IProduct product) external view returns (bool);\n function owner() external view returns (address);\n function owner(uint256 coordinatorId) external view returns (address);\n function owner(IProduct product) external view returns (address);\n function treasury() external view returns (address);\n function treasury(uint256 coordinatorId) external view returns (address);\n function treasury(IProduct product) external view returns (address);\n}\n" - }, - "contracts/interfaces/IProduct.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\";\nimport \"./IPayoffProvider.sol\";\nimport \"./IParamProvider.sol\";\nimport \"./types/PayoffDefinition.sol\";\nimport \"./types/Position.sol\";\nimport \"./types/PrePosition.sol\";\nimport \"./types/Accumulator.sol\";\n\ninterface IProduct is IPayoffProvider, IParamProvider {\n /// @dev Product Creation parameters\n struct ProductInfo {\n /// @dev name of the product\n string name;\n\n /// @dev symbol of the product\n string symbol;\n\n /// @dev product payoff definition\n PayoffDefinition payoffDefinition;\n\n /// @dev oracle address\n IOracleProvider oracle;\n\n /// @dev product maintenance ratio\n UFixed18 maintenance;\n\n /// @dev product funding fee\n UFixed18 fundingFee;\n\n /// @dev product maker fee\n UFixed18 makerFee;\n\n /// @dev product taker fee\n UFixed18 takerFee;\n\n /// @dev product maker limit\n UFixed18 makerLimit;\n\n /// @dev utulization curve definition\n JumpRateUtilizationCurve utilizationCurve;\n }\n\n event Settle(uint256 preVersion, uint256 toVersion);\n event AccountSettle(address indexed account, uint256 preVersion, uint256 toVersion);\n event MakeOpened(address indexed account, uint256 version, UFixed18 amount);\n event TakeOpened(address indexed account, uint256 version, UFixed18 amount);\n event MakeClosed(address indexed account, uint256 version, UFixed18 amount);\n event TakeClosed(address indexed account, uint256 version, UFixed18 amount);\n event ClosedUpdated(bool indexed newClosed, uint256 version);\n\n error ProductInsufficientLiquidityError(UFixed18 socializationFactor);\n error ProductDoubleSidedError();\n error ProductOverClosedError();\n error ProductInsufficientCollateralError();\n error ProductInLiquidationError();\n error ProductMakerOverLimitError();\n error ProductOracleBootstrappingError();\n error ProductNotOwnerError();\n error ProductInvalidOracle();\n error ProductClosedError();\n\n function name() external view returns (string memory);\n function symbol() external view returns (string memory);\n function initialize(ProductInfo calldata productInfo_) external;\n function settle() external;\n function settleAccount(address account) external;\n function openTake(UFixed18 amount) external;\n function closeTake(UFixed18 amount) external;\n function openMake(UFixed18 amount) external;\n function closeMake(UFixed18 amount) external;\n function closeAll(address account) external;\n function maintenance(address account) external view returns (UFixed18);\n function maintenanceNext(address account) external view returns (UFixed18);\n function isClosed(address account) external view returns (bool);\n function isLiquidating(address account) external view returns (bool);\n function position(address account) external view returns (Position memory);\n function pre(address account) external view returns (PrePosition memory);\n function latestVersion() external view returns (uint256);\n function positionAtVersion(uint256 oracleVersion) external view returns (Position memory);\n function pre() external view returns (PrePosition memory);\n function valueAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\n function shareAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\n function latestVersion(address account) external view returns (uint256);\n function rate(Position memory position) external view returns (Fixed18);\n function closed() external view returns (bool);\n function updateClosed(bool newClosed) external;\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/IERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\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 amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` 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(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\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" - }, - "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 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 using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\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 function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" - }, - "@openzeppelin/contracts/proxy/beacon/IBeacon.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n" - }, - "contracts/interfaces/IIncentivizer.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"./types/ProgramInfo.sol\";\nimport \"./IController.sol\";\nimport \"./IProduct.sol\";\n\ninterface IIncentivizer {\n event ProgramCreated(IProduct indexed product, uint256 indexed programId, ProgramInfo programInfo, UFixed18 programFeeAmount);\n event ProgramStarted(IProduct indexed product, uint256 indexed programId, uint256 version);\n event ProgramComplete(IProduct indexed product, uint256 indexed programId, uint256 version);\n event Claim(IProduct indexed product, address indexed account, uint256 indexed programId, UFixed18 amount);\n event FeeClaim(Token18 indexed token, UFixed18 amount);\n\n error IncentivizerNotAllowedError(IProduct product);\n error IncentivizerTooManyProgramsError();\n error IncentivizerNotProgramOwnerError(IProduct product, uint256 programId);\n error IncentivizerInvalidProgramError(IProduct product, uint256 programId);\n error IncentivizerBatchClaimArgumentMismatchError();\n\n function programInfos(IProduct product, uint256 programId) external view returns (ProgramInfo memory);\n function fees(Token18 token) external view returns (UFixed18);\n function initialize(IController controller_) external;\n function create(IProduct product, ProgramInfo calldata info) external returns (uint256);\n function complete(IProduct product, uint256 programId) external;\n function sync(IOracleProvider.OracleVersion memory currentOracleVersion) external;\n function syncAccount(address account, IOracleProvider.OracleVersion memory currentOracleVersion) external;\n function claim(IProduct product, uint256[] calldata programIds) external;\n function claim(IProduct[] calldata products, uint256[][] calldata programIds) external;\n function claimFee(Token18[] calldata tokens) external;\n function active(IProduct product) external view returns (uint256);\n function count(IProduct product) external view returns (uint256);\n function unclaimed(IProduct product, address account, uint256 programId) external view returns (UFixed18);\n function available(IProduct product, uint256 programId) external view returns (UFixed18);\n function versionStarted(IProduct product, uint256 programId) external view returns (uint256);\n function versionComplete(IProduct product, uint256 programId) external view returns (uint256);\n function owner(IProduct product, uint256 programId) external view returns (address);\n function treasury(IProduct product, uint256 programId) external view returns (address);\n}\n" - }, - "contracts/interfaces/types/PayoffDefinition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"../../interfaces/IContractPayoffProvider.sol\";\n\n/// @dev PayoffDefinition tyoe\nstruct PayoffDefinition {\n PayoffDefinitionLib.PayoffType payoffType;\n PayoffDefinitionLib.PayoffDirection payoffDirection;\n bytes30 data;\n}\nusing PayoffDefinitionLib for PayoffDefinition global;\ntype PayoffDefinitionStorage is bytes32;\nusing PayoffDefinitionStorageLib for PayoffDefinitionStorage global;\n\n/**\n * @title PayoffDefinitionLib\n * @dev Library that surfaces logic for PayoffDefinition type functionality\n * @notice Library for the PayoffDefinition type. Performs validity and price transformation\n based on the payoff definition type.\n */\nlibrary PayoffDefinitionLib {\n using Address for address;\n\n error PayoffDefinitionUnsupportedTransform(PayoffType payoffType, PayoffDirection payoffDirection);\n error PayoffDefinitionNotContract(PayoffType payoffType, bytes30 data);\n\n /// @dev Payoff function type enum\n enum PayoffType { PASSTHROUGH, CONTRACT }\n enum PayoffDirection { LONG, SHORT }\n\n /**\n * @notice Checks validity of the payoff definition\n * @param self a payoff definition\n * @return Whether the payoff definition is valid for it's given type\n */\n function valid(PayoffDefinition memory self) internal view returns (bool) {\n if (self.payoffType == PayoffType.CONTRACT) return address(_providerContract(self)).isContract();\n\n // All other payoff types should have no data\n return uint(bytes32(self.data)) == 0;\n }\n\n /**\n * @notice Transforms a price based on the payoff definition\n * @param self a payoff definition\n * @param price raw oracle price\n * @return Price transformed by the payoff definition function\n */\n function transform(\n PayoffDefinition memory self,\n Fixed18 price\n ) internal view returns (Fixed18) {\n PayoffType payoffType = self.payoffType;\n PayoffDirection payoffDirection = self.payoffDirection;\n Fixed18 transformedPrice;\n\n // First get the price depending on the type\n if (payoffType == PayoffType.PASSTHROUGH) transformedPrice = price;\n else if (payoffType == PayoffType.CONTRACT) transformedPrice = _payoffFromContract(self, price);\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\n\n // Then transform it depending on the direction flag\n if (self.payoffDirection == PayoffDirection.LONG) return transformedPrice;\n else if (self.payoffDirection == PayoffDirection.SHORT) return transformedPrice.mul(Fixed18Lib.NEG_ONE);\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\n }\n\n /**\n * @notice Parses the data field into an address\n * @dev Reverts if payoffType is not CONTRACT\n * @param self a payoff definition\n * @return IContractPayoffProvider address\n */\n function _providerContract(\n PayoffDefinition memory self\n ) private pure returns (IContractPayoffProvider) {\n if (self.payoffType != PayoffType.CONTRACT) revert PayoffDefinitionNotContract(self.payoffType, self.data);\n // Shift to pull the last 20 bytes, then cast to an address\n return IContractPayoffProvider(address(bytes20(self.data << 80)));\n }\n\n /**\n * @notice Performs a price transformation by calling the underlying payoff contract\n * @param self a payoff definition\n * @param price raw oracle price\n * @return Price transformed by the payoff definition function on the contract\n */\n function _payoffFromContract(\n PayoffDefinition memory self,\n Fixed18 price\n ) private view returns (Fixed18) {\n bytes memory ret = address(_providerContract(self)).functionStaticCall(\n abi.encodeCall(IContractPayoffProvider.payoff, price)\n );\n return Fixed18.wrap(abi.decode(ret, (int256)));\n }\n}\n\n/**\n * @title PayoffDefinitionStorageLib\n * @notice Library that surfaces storage read and writes for the PayoffDefinition type\n */\nlibrary PayoffDefinitionStorageLib {\n function read(PayoffDefinitionStorage self) internal view returns (PayoffDefinition memory) {\n return _storagePointer(self);\n }\n\n function store(PayoffDefinitionStorage self, PayoffDefinition memory value) internal {\n PayoffDefinition storage storagePointer = _storagePointer(self);\n\n storagePointer.payoffType = value.payoffType;\n storagePointer.payoffDirection = value.payoffDirection;\n storagePointer.data = value.data;\n }\n\n function _storagePointer(\n PayoffDefinitionStorage self\n ) private pure returns (PayoffDefinition storage pointer) {\n assembly { pointer.slot := self }\n }\n}\n" - }, - "@equilibria/root/curve/types/JumpRateUtilizationCurve.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"../CurveMath.sol\";\nimport \"../../number/types/PackedUFixed18.sol\";\nimport \"../../number/types/PackedFixed18.sol\";\n\n/// @dev JumpRateUtilizationCurve type\nstruct JumpRateUtilizationCurve {\n PackedFixed18 minRate;\n PackedFixed18 maxRate;\n PackedFixed18 targetRate;\n PackedUFixed18 targetUtilization;\n}\nusing JumpRateUtilizationCurveLib for JumpRateUtilizationCurve global;\ntype JumpRateUtilizationCurveStorage is bytes32;\nusing JumpRateUtilizationCurveStorageLib for JumpRateUtilizationCurveStorage global;\n\n/**\n * @title JumpRateUtilizationCurveLib\n * @notice Library for the Jump Rate utilization curve type\n */\nlibrary JumpRateUtilizationCurveLib {\n /**\n * @notice Computes the corresponding rate for a utilization ratio\n * @param utilization The utilization ratio\n * @return The corresponding rate\n */\n function compute(JumpRateUtilizationCurve memory self, UFixed18 utilization) internal pure returns (Fixed18) {\n UFixed18 targetUtilization = self.targetUtilization.unpack();\n if (utilization.lt(targetUtilization)) {\n return CurveMath.linearInterpolation(\n UFixed18Lib.ZERO,\n self.minRate.unpack(),\n targetUtilization,\n self.targetRate.unpack(),\n utilization\n );\n }\n if (utilization.lt(UFixed18Lib.ONE)) {\n return CurveMath.linearInterpolation(\n targetUtilization,\n self.targetRate.unpack(),\n UFixed18Lib.ONE,\n self.maxRate.unpack(),\n utilization\n );\n }\n return self.maxRate.unpack();\n }\n}\n\nlibrary JumpRateUtilizationCurveStorageLib {\n function read(JumpRateUtilizationCurveStorage self) internal view returns (JumpRateUtilizationCurve memory) {\n return _storagePointer(self);\n }\n\n function store(JumpRateUtilizationCurveStorage self, JumpRateUtilizationCurve memory value) internal {\n JumpRateUtilizationCurve storage storagePointer = _storagePointer(self);\n\n storagePointer.minRate = value.minRate;\n storagePointer.maxRate = value.maxRate;\n storagePointer.targetRate = value.targetRate;\n storagePointer.targetUtilization = value.targetUtilization;\n }\n\n function _storagePointer(JumpRateUtilizationCurveStorage self)\n private pure returns (JumpRateUtilizationCurve storage pointer) {\n assembly { pointer.slot := self }\n }\n}" - }, - "contracts/interfaces/IPayoffProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/Fixed18.sol\";\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"./types/PayoffDefinition.sol\";\n\ninterface IPayoffProvider {\n error PayoffProviderInvalidOracle();\n error PayoffProviderInvalidPayoffDefinitionError();\n\n function oracle() external view returns (IOracleProvider);\n function payoffDefinition() external view returns (PayoffDefinition memory);\n function currentVersion() external view returns (IOracleProvider.OracleVersion memory);\n function atVersion(uint256 oracleVersion) external view returns (IOracleProvider.OracleVersion memory);\n}\n" - }, - "contracts/interfaces/IParamProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\";\n\ninterface IParamProvider {\n event MaintenanceUpdated(UFixed18 newMaintenance);\n event FundingFeeUpdated(UFixed18 newFundingFee);\n event MakerFeeUpdated(UFixed18 newMakerFee);\n event TakerFeeUpdated(UFixed18 newTakerFee);\n event MakerLimitUpdated(UFixed18 newMakerLimit);\n event JumpRateUtilizationCurveUpdated(\n Fixed18 minRate,\n Fixed18 maxRate,\n Fixed18 targetRate,\n UFixed18 targetUtilization\n );\n\n error ParamProviderInvalidMakerFee();\n error ParamProviderInvalidTakerFee();\n error ParamProviderInvalidFundingFee();\n \n function maintenance() external view returns (UFixed18);\n function updateMaintenance(UFixed18 newMaintenance) external;\n function fundingFee() external view returns (UFixed18);\n function updateFundingFee(UFixed18 newFundingFee) external;\n function makerFee() external view returns (UFixed18);\n function updateMakerFee(UFixed18 newMakerFee) external;\n function takerFee() external view returns (UFixed18);\n function updateTakerFee(UFixed18 newTakerFee) external;\n function makerLimit() external view returns (UFixed18);\n function updateMakerLimit(UFixed18 newMakerLimit) external;\n function utilizationCurve() external view returns (JumpRateUtilizationCurve memory);\n function updateUtilizationCurve(JumpRateUtilizationCurve memory newUtilizationCurve) external;\n}\n" - }, - "contracts/interfaces/types/Position.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"../IProduct.sol\";\nimport \"./Accumulator.sol\";\nimport \"./PrePosition.sol\";\nimport \"./PackedPosition.sol\";\n\n/// @dev Position type\nstruct Position {\n /// @dev Quantity of the maker position\n UFixed18 maker;\n /// @dev Quantity of the taker position\n UFixed18 taker;\n}\nusing PositionLib for Position global;\n\n/**\n * @title PositionLib\n * @notice Library that surfaces math and settlement computations for the Position type.\n * @dev Positions track the current quantity of the account's maker and taker positions respectively\n * denominated as a unit of the product's payoff function.\n */\nlibrary PositionLib {\n /**\n * @notice Creates a packed position from an position\n * @param self A position\n * @return New packed position\n */\n function pack(Position memory self) internal pure returns (PackedPosition memory) {\n return PackedPosition({maker: self.maker.pack(), taker: self.taker.pack()});\n }\n\n /**\n * @notice Returns whether the position is fully empty\n * @param self A position\n * @return Whether the position is empty\n */\n function isEmpty(Position memory self) internal pure returns (bool) {\n return self.maker.isZero() && self.taker.isZero();\n }\n\n /**\n * @notice Adds position `a` and `b` together, returning the result\n * @param a The first position to sum\n * @param b The second position to sum\n * @return Resulting summed position\n */\n function add(Position memory a, Position memory b) internal pure returns (Position memory) {\n return Position({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\n }\n\n /**\n * @notice Subtracts position `b` from `a`, returning the result\n * @param a The position to subtract from\n * @param b The position to subtract\n * @return Resulting subtracted position\n */\n function sub(Position memory a, Position memory b) internal pure returns (Position memory) {\n return Position({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\n }\n\n /**\n * @notice Multiplies position `self` by accumulator `accumulator` and returns the resulting accumulator\n * @param self The Position to operate on\n * @param accumulator The accumulator to multiply by\n * @return Resulting multiplied accumulator\n */\n function mul(Position memory self, Accumulator memory accumulator) internal pure returns (Accumulator memory) {\n return Accumulator({\n maker: Fixed18Lib.from(self.maker).mul(accumulator.maker),\n taker: Fixed18Lib.from(self.taker).mul(accumulator.taker)\n });\n }\n\n /**\n * @notice Scales position `self` by fixed-decimal `scale` and returns the resulting position\n * @param self The Position to operate on\n * @param scale The Fixed-decimal to scale by\n * @return Resulting scaled position\n */\n function mul(Position memory self, UFixed18 scale) internal pure returns (Position memory) {\n return Position({maker: self.maker.mul(scale), taker: self.taker.mul(scale)});\n }\n\n /**\n * @notice Divides position `self` by `b` and returns the resulting accumulator\n * @param self The Position to operate on\n * @param b The number to divide by\n * @return Resulting divided accumulator\n */\n function div(Position memory self, uint256 b) internal pure returns (Accumulator memory) {\n return Accumulator({\n maker: Fixed18Lib.from(self.maker).div(Fixed18Lib.from(UFixed18Lib.from(b))),\n taker: Fixed18Lib.from(self.taker).div(Fixed18Lib.from(UFixed18Lib.from(b)))\n });\n }\n\n /**\n * @notice Returns the maximum of `self`'s maker and taker values\n * @param self The struct to operate on\n * @return Resulting maximum value\n */\n function max(Position memory self) internal pure returns (UFixed18) {\n return UFixed18Lib.max(self.maker, self.taker);\n }\n\n /**\n * @notice Sums the maker and taker together from a single position\n * @param self The struct to operate on\n * @return The sum of its maker and taker\n */\n function sum(Position memory self) internal pure returns (UFixed18) {\n return self.maker.add(self.taker);\n }\n\n /**\n * @notice Computes the next position after the pending-settlement position delta is included\n * @param self The current Position\n * @param pre The pending-settlement position delta\n * @return Next Position\n */\n function next(Position memory self, PrePosition memory pre) internal pure returns (Position memory) {\n return sub(add(self, pre.openPosition), pre.closePosition);\n }\n\n /**\n * @notice Returns the settled position at oracle version `toOracleVersion`\n * @dev Checks if a new position is ready to be settled based on the provided `toOracleVersion`\n * and `pre` and returns accordingly\n * @param self The current Position\n * @param pre The pending-settlement position delta\n * @param toOracleVersion The oracle version to settle to\n * @return Settled position at oracle version\n * @return Fee accrued from opening or closing the position\n * @return Whether a new position was settled\n */\n function settled(\n Position memory self,\n PrePosition memory pre,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal view returns (Position memory, UFixed18, bool) {\n return pre.canSettle(toOracleVersion) ? (next(self, pre), pre.computeFee(toOracleVersion), true) : (self, UFixed18Lib.ZERO, false);\n }\n\n /**\n * @notice Returns the socialization factor for the current position\n * @dev Socialization account for the case where `taker` > `maker` temporarily due to a liquidation\n * on the maker side. This dampens the taker's exposure pro-rata to ensure that the maker side\n * is never exposed over 1 x short.\n * @param self The Position to operate on\n * @return Socialization factor\n */\n function socializationFactor(Position memory self) internal pure returns (UFixed18) {\n return self.taker.isZero() ? UFixed18Lib.ONE : UFixed18Lib.min(UFixed18Lib.ONE, self.maker.div(self.taker));\n }\n}\n" - }, - "contracts/interfaces/types/PrePosition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"./Position.sol\";\nimport \"../IProduct.sol\";\n\n/// @dev PrePosition type\nstruct PrePosition {\n /// @dev Oracle version at which the new position delta was recorded\n uint256 oracleVersion;\n\n /// @dev Size of position to open at oracle version\n Position openPosition;\n\n /// @dev Size of position to close at oracle version\n Position closePosition;\n}\nusing PrePositionLib for PrePosition global;\n\n/**\n * @title PrePositionLib\n * @notice Library that manages a pre-settlement position delta.\n * @dev PrePositions track the currently awaiting-settlement deltas to a settled Position. These are\n * Primarily necessary to introduce lag into the settlement system such that oracle lag cannot be\n * gamed to a user's advantage. When a user opens or closes a new position, it sits as a PrePosition\n * for one oracle version until it's settle into the Position, making it then effective. PrePositions\n * are automatically settled at the correct oracle version even if a flywheel call doesn't happen until\n * several version into the future by using the historical version lookups in the corresponding \"Versioned\"\n * global state types.\n */\nlibrary PrePositionLib {\n /**\n * @notice Returns whether there is no pending-settlement position delta\n * @dev Can be \"empty\" even with a non-zero oracleVersion if a position is opened and\n * closed in the same version netting out to a zero position delta\n * @param self The struct to operate on\n * @return Whether the pending-settlement position delta is empty\n */\n function isEmpty(PrePosition memory self) internal pure returns (bool) {\n return self.openPosition.isEmpty() && self.closePosition.isEmpty();\n }\n\n /**\n * @notice Increments the maker side of the open position delta\n * @dev Nets out open and close deltas to minimize the size of each\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @param amount The position amount to open\n */\n function openMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\n self.openPosition.maker = self.openPosition.maker.add(amount);\n self.oracleVersion = currentVersion;\n _netMake(self);\n }\n\n /**\n * @notice Increments the maker side of the close position delta\n * @dev Nets out open and close deltas to minimize the size of each\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @param amount The maker position amount to close\n */\n function closeMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\n self.closePosition.maker = self.closePosition.maker.add(amount);\n self.oracleVersion = currentVersion;\n _netMake(self);\n }\n\n /**\n * @notice Increments the taker side of the open position delta\n * @dev Nets out open and close deltas to minimize the size of each\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @param amount The taker position amount to open\n */\n function openTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\n self.openPosition.taker = self.openPosition.taker.add(amount);\n self.oracleVersion = currentVersion;\n _netTake(self);\n }\n\n /**\n * @notice Increments the taker side of the close position delta\n * @dev Nets out open and close deltas to minimize the size of each\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @param amount The taker position amount to close\n */\n function closeTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\n self.closePosition.taker = self.closePosition.taker.add(amount);\n self.oracleVersion = currentVersion;\n _netTake(self);\n }\n\n /**\n * @notice Nets out the open and close on the maker side of the position delta\n * @param self The struct to operate on\n */\n function _netMake(PrePosition storage self) private {\n if (self.openPosition.maker.gt(self.closePosition.maker)) {\n self.openPosition.maker = self.openPosition.maker.sub(self.closePosition.maker);\n self.closePosition.maker = UFixed18Lib.ZERO;\n } else {\n self.closePosition.maker = self.closePosition.maker.sub(self.openPosition.maker);\n self.openPosition.maker = UFixed18Lib.ZERO;\n }\n }\n\n /**\n * @notice Nets out the open and close on the taker side of the position delta\n * @param self The struct to operate on\n */\n function _netTake(PrePosition storage self) private {\n if (self.openPosition.taker.gt(self.closePosition.taker)) {\n self.openPosition.taker = self.openPosition.taker.sub(self.closePosition.taker);\n self.closePosition.taker = UFixed18Lib.ZERO;\n } else {\n self.closePosition.taker = self.closePosition.taker.sub(self.openPosition.taker);\n self.openPosition.taker = UFixed18Lib.ZERO;\n }\n }\n\n /**\n * @notice Returns whether the the pending position delta can be settled at version `toOracleVersion`\n * @dev Pending-settlement positions deltas can be settled (1) oracle version after they are recorded\n * @param self The struct to operate on\n * @param toOracleVersion The potential oracle version to settle\n * @return Whether the position delta can be settled\n */\n function canSettle(\n PrePosition memory self,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal pure returns (bool) {\n return !isEmpty(self) && toOracleVersion.version > self.oracleVersion;\n }\n\n /**\n * @notice Computes the fee incurred for opening or closing the pending-settlement position\n * @dev Must be called from a valid product to get the proper fee amounts\n * @param self The struct to operate on\n * @param toOracleVersion The oracle version at which settlement takes place\n * @return positionFee The maker / taker fee incurred\n */\n function computeFee(\n PrePosition memory self,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal view returns (UFixed18) {\n Position memory positionDelta = self.openPosition.add(self.closePosition);\n\n (UFixed18 makerNotional, UFixed18 takerNotional) = (\n Fixed18Lib.from(positionDelta.maker).mul(toOracleVersion.price).abs(),\n Fixed18Lib.from(positionDelta.taker).mul(toOracleVersion.price).abs()\n );\n\n IProduct product = IProduct(address(this));\n return makerNotional.mul(product.makerFee()).add(takerNotional.mul(product.takerFee()));\n }\n\n /**\n * @notice Computes the next oracle version to settle\n * @dev - If there is no pending-settlement position delta, returns the current oracle version\n * - Otherwise returns the oracle version at which the pending-settlement position delta can be first settled\n *\n * Corresponds to point (b) in the Position settlement flow\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @return Next oracle version to settle\n */\n function settleVersion(PrePosition storage self, uint256 currentVersion) internal view returns (uint256) {\n uint256 _oracleVersion = self.oracleVersion;\n return _oracleVersion == 0 ? currentVersion : _oracleVersion + 1;\n }\n}\n" - }, - "contracts/interfaces/types/Accumulator.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/Fixed18.sol\";\nimport \"./PackedAccumulator.sol\";\n\n/// @dev Accumulator type\nstruct Accumulator {\n /// @dev maker accumulator per share\n Fixed18 maker;\n /// @dev taker accumulator per share\n Fixed18 taker;\n}\nusing AccumulatorLib for Accumulator global;\n\n/**\n * @title AccountAccumulatorLib\n * @notice Library that surfaces math operations for the Accumulator type.\n * @dev Accumulators track the cumulative change in position value over time for the maker and taker positions\n * respectively. Account-level accumulators can then use two of these values `a` and `a'` to compute the\n * change in position value since last sync. This change in value is then used to compute P&L and fees.\n */\nlibrary AccumulatorLib {\n /**\n * @notice Creates a packed accumulator from an accumulator\n * @param self an accumulator\n * @return New packed accumulator\n */\n function pack(Accumulator memory self) internal pure returns (PackedAccumulator memory) {\n return PackedAccumulator({maker: self.maker.pack(), taker: self.taker.pack()});\n }\n\n /**\n * @notice Adds two accumulators together\n * @param a The first accumulator to sum\n * @param b The second accumulator to sum\n * @return The resulting summed accumulator\n */\n function add(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\n return Accumulator({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\n }\n\n /**\n * @notice Subtracts accumulator `b` from `a`\n * @param a The accumulator to subtract from\n * @param b The accumulator to subtract\n * @return The resulting subtracted accumulator\n */\n function sub(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\n return Accumulator({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\n }\n\n /**\n * @notice Multiplies two accumulators together\n * @param a The first accumulator to multiply\n * @param b The second accumulator to multiply\n * @return The resulting multiplied accumulator\n */\n function mul(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\n return Accumulator({maker: a.maker.mul(b.maker), taker: a.taker.mul(b.taker)});\n }\n\n /**\n * @notice Sums the maker and taker together from a single accumulator\n * @param self The struct to operate on\n * @return The sum of its maker and taker\n */\n function sum(Accumulator memory self) internal pure returns (Fixed18) {\n return self.maker.add(self.taker);\n }\n}\n" - }, - "@equilibria/root/curve/CurveMath.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"../number/types/UFixed18.sol\";\nimport \"../number/types/Fixed18.sol\";\n\n/**\n * @title CurveMath\n * @notice Library for managing math operations for utilization curves.\n */\nlibrary CurveMath {\n error CurveMathOutOfBoundsError();\n\n /**\n * @notice Computes a linear interpolation between two points\n * @param startX First point's x-coordinate\n * @param startY First point's y-coordinate\n * @param endX Second point's x-coordinate\n * @param endY Second point's y-coordinate\n * @param targetX x-coordinate to interpolate\n * @return y-coordinate for `targetX` along the line from (`startX`, `startY`) -> (`endX`, `endY`)\n */\n function linearInterpolation(\n UFixed18 startX,\n Fixed18 startY,\n UFixed18 endX,\n Fixed18 endY,\n UFixed18 targetX\n ) internal pure returns (Fixed18) {\n if (targetX.lt(startX) || targetX.gt(endX)) revert CurveMathOutOfBoundsError();\n\n UFixed18 xRange = endX.sub(startX);\n Fixed18 yRange = endY.sub(startY);\n UFixed18 xRatio = targetX.sub(startX).div(xRange);\n return yRange.mul(Fixed18Lib.from(xRatio)).add(startY);\n }\n}\n" - }, - "@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/Fixed18.sol\";\n\ninterface IOracleProvider {\n /// @dev A singular oracle version with its corresponding data\n struct OracleVersion {\n /// @dev The iterative version\n uint256 version;\n\n /// @dev the timestamp of the oracle update\n uint256 timestamp;\n\n /// @dev The oracle price of the corresponding version\n Fixed18 price;\n }\n\n function sync() external returns (OracleVersion memory);\n function currentVersion() external view returns (OracleVersion memory);\n function atVersion(uint256 oracleVersion) external view returns (OracleVersion memory);\n}\n" - }, - "contracts/interfaces/IContractPayoffProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/Fixed18.sol\";\n\ninterface IContractPayoffProvider {\n function payoff(Fixed18 price) external view returns (Fixed18 payoff);\n}\n" - }, - "contracts/interfaces/types/PackedPosition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/PackedUFixed18.sol\";\nimport \"./Position.sol\";\n\n/// @dev PackedPosition type\nstruct PackedPosition {\n /// @dev Quantity of the maker position\n PackedUFixed18 maker;\n /// @dev Quantity of the taker position\n PackedUFixed18 taker;\n}\nusing PackedPositionLib for PackedPosition global;\n\n/**\n * @title PackedPositionLib\n * @dev A packed version of the Position which takes up a single storage slot using `PackedFixed18` values.\n * @notice Library for the packed Position type.\n */\nlibrary PackedPositionLib {\n /**\n * @notice Creates an position from a packed position\n * @param self packed position\n * @return New position\n */\n function unpack(PackedPosition memory self) internal pure returns (Position memory) {\n return Position({maker: self.maker.unpack(), taker: self.taker.unpack()});\n }\n}\n" - }, - "contracts/interfaces/types/PackedAccumulator.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/PackedFixed18.sol\";\nimport \"./Accumulator.sol\";\n\n/// @dev PackedAccumulator type\nstruct PackedAccumulator {\n /// @dev maker accumulator per share\n PackedFixed18 maker;\n /// @dev taker accumulator per share\n PackedFixed18 taker;\n}\nusing PackedAccumulatorLib for PackedAccumulator global;\n\n/**\n * @title PackedAccumulatorLib\n * @dev A packed version of the Accumulator which takes up a single storage slot using `PackedFixed18` values.\n * @notice Library for the packed Accumulator type.\n */\nlibrary PackedAccumulatorLib {\n /**\n * @notice Creates an accumulator from a packed accumulator\n * @param self packed accumulator\n * @return New accumulator\n */\n function unpack(PackedAccumulator memory self) internal pure returns (Accumulator memory) {\n return Accumulator({maker: self.maker.unpack(), taker: self.taker.unpack()});\n }\n}\n" - }, - "contracts/interfaces/types/ProgramInfo.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"../IProduct.sol\";\nimport \"./Position.sol\";\nimport \"./Accumulator.sol\";\n\n/// @dev ProgramInfo type\nstruct ProgramInfo {\n /// @dev Coordinator for this program\n uint256 coordinatorId;\n\n /// @dev Amount of total maker and taker rewards\n Position amount;\n\n /// @dev start timestamp of the program\n uint256 start;\n\n /// @dev duration of the program (in seconds)\n uint256 duration;\n\n /**\n * @dev Reward ERC20 token contract\n * @notice Perennial does not support non-standard ERC20s as reward tokens for incentive programs, including,\n but not limited to: fee on transfer and rebase tokens. Using such a non-standard token will likely\n result in loss of funds.\n */\n Token18 token;\n}\nusing ProgramInfoLib for ProgramInfo global;\n\n/**\n * @title ProgramInfoLib\n * @notice Library that snapshots the static information for a single program.\n * @dev This information does not change during the operation of a program.\n */\nlibrary ProgramInfoLib {\n uint256 private constant MIN_DURATION = 1 days;\n uint256 private constant MAX_DURATION = 2 * 365 days;\n\n error ProgramInvalidStartError();\n error ProgramInvalidDurationError();\n\n /**\n * @notice Validates and creates a new Program\n * @dev Reverts for invalid programInfos\n * @param programInfo Un-sanitized static program information\n */\n function validate(ProgramInfo memory programInfo) internal view {\n if (isStarted(programInfo, block.timestamp)) revert ProgramInvalidStartError();\n if (programInfo.duration < MIN_DURATION || programInfo.duration > MAX_DURATION) revert ProgramInvalidDurationError();\n }\n\n /**\n * @notice Computes a new program info with the fee taken out of the amount\n * @param programInfo Original program info\n * @param incentivizationFee The incentivization fee\n * @return New program info\n * @return Fee amount\n */\n function deductFee(ProgramInfo memory programInfo, UFixed18 incentivizationFee)\n internal pure returns (ProgramInfo memory, UFixed18) {\n Position memory newProgramAmount = programInfo.amount.mul(UFixed18Lib.ONE.sub(incentivizationFee));\n UFixed18 programFeeAmount = programInfo.amount.sub(newProgramAmount).sum();\n programInfo.amount = newProgramAmount;\n return (programInfo, programFeeAmount);\n }\n\n /**\n * @notice Returns the maker and taker amounts per position share\n * @param self The ProgramInfo to operate on\n * @return programFee Amounts per share\n */\n function amountPerShare(ProgramInfo memory self) internal pure returns (Accumulator memory) {\n return self.amount.div(self.duration);\n }\n\n /**\n * @notice Returns whether the program has started by timestamp `timestamp`\n * @param self The ProgramInfo to operate on\n * @param timestamp Timestamp to check for\n * @return Whether the program has started\n */\n function isStarted(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\n return timestamp >= self.start;\n }\n\n /**\n * @notice Returns whether the program is completed by timestamp `timestamp`\n * @param self The ProgramInfo to operate on\n * @param timestamp Timestamp to check for\n * @return Whether the program is completed\n */\n function isComplete(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\n return timestamp >= (self.start + self.duration);\n }\n}\n" - }, - "contracts/product/UParamProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/control/unstructured/UInitializable.sol\";\nimport \"../controller/UControllerProvider.sol\";\nimport \"../interfaces/IParamProvider.sol\";\nimport \"../interfaces/IProduct.sol\";\n\nabstract contract UParamProvider is IParamProvider, UControllerProvider {\n /**\n * @notice Initializes the contract state\n * @param maintenance_ product maintenance ratio\n * @param fundingFee_ product funding fee\n * @param makerFee_ product maker fee\n * @param takerFee_ product taker fee\n * @param makerLimit_ product maker limit\n * @param utilizationCurve_ utulization curve definition\n */\n // solhint-disable-next-line func-name-mixedcase\n function __UParamProvider__initialize(\n UFixed18 maintenance_,\n UFixed18 fundingFee_,\n UFixed18 makerFee_,\n UFixed18 takerFee_,\n UFixed18 makerLimit_,\n JumpRateUtilizationCurve memory utilizationCurve_\n ) internal onlyInitializer {\n _updateMaintenance(maintenance_);\n _updateFundingFee(fundingFee_);\n _updateMakerFee(makerFee_);\n _updateTakerFee(takerFee_);\n _updateMakerLimit(makerLimit_);\n _updateUtilizationCurve(utilizationCurve_);\n }\n\n /// @dev Only allow the Product's coordinator owner to call\n modifier onlyProductOwner {\n uint256 coordinatorId = controller().coordinatorFor(IProduct(address(this)));\n if (controller().owner(coordinatorId) != msg.sender) revert NotOwnerError(coordinatorId);\n\n _;\n }\n\n /// @dev The maintenance value\n UFixed18Storage private constant _maintenance = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.UParamProvider.maintenance\"));\n function maintenance() public view returns (UFixed18) { return _maintenance.read(); }\n\n /// @dev The funding fee value\n UFixed18Storage private constant _fundingFee = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.UParamProvider.fundingFee\"));\n function fundingFee() public view returns (UFixed18) { return _fundingFee.read(); }\n\n /// @dev The maker fee value\n UFixed18Storage private constant _makerFee = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.UParamProvider.makerFee\"));\n function makerFee() public view returns (UFixed18) { return _makerFee.read(); }\n\n /// @dev The taker fee value\n UFixed18Storage private constant _takerFee = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.UParamProvider.takerFee\"));\n function takerFee() public view returns (UFixed18) { return _takerFee.read(); }\n\n /// @dev The maker limit value\n UFixed18Storage private constant _makerLimit = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.UParamProvider.makerLimit\"));\n function makerLimit() public view returns (UFixed18) { return _makerLimit.read(); }\n\n /// @dev The JumpRateUtilizationCurve params\n JumpRateUtilizationCurveStorage private constant _utilizationCurve =\n JumpRateUtilizationCurveStorage.wrap(keccak256(\"equilibria.perennial.UParamProvider.jumpRateUtilizationCurve\"));\n function utilizationCurve() public view returns (JumpRateUtilizationCurve memory) { return _utilizationCurve.read(); }\n\n /**\n * @notice Updates the maintenance to `newMaintenance`\n * @param newMaintenance new maintenance value\n */\n function _updateMaintenance(UFixed18 newMaintenance) private {\n _maintenance.store(newMaintenance);\n emit MaintenanceUpdated(newMaintenance);\n }\n\n /**\n * @notice Updates the maintenance to `newMaintenance`\n * @dev only callable by product owner\n * @param newMaintenance new maintenance value\n */\n function updateMaintenance(UFixed18 newMaintenance) external onlyProductOwner {\n _updateMaintenance(newMaintenance);\n }\n\n /**\n * @notice Updates the funding fee to `newFundingFee`\n * @param newFundingFee new funding fee value\n */\n function _updateFundingFee(UFixed18 newFundingFee) private {\n if (newFundingFee.gt(UFixed18Lib.ONE)) revert ParamProviderInvalidFundingFee();\n _fundingFee.store(newFundingFee);\n emit FundingFeeUpdated(newFundingFee);\n }\n\n /**\n * @notice Updates the funding fee to `newFundingFee`\n * @dev only callable by product owner\n * @param newFundingFee new funding fee value\n */\n function updateFundingFee(UFixed18 newFundingFee) external onlyProductOwner {\n _updateFundingFee(newFundingFee);\n }\n\n /**\n * @notice Updates the maker fee to `newMakerFee`\n * @param newMakerFee new maker fee value\n */\n function _updateMakerFee(UFixed18 newMakerFee) private {\n if (newMakerFee.gt(UFixed18Lib.ONE)) revert ParamProviderInvalidMakerFee();\n _makerFee.store(newMakerFee);\n emit MakerFeeUpdated(newMakerFee);\n }\n\n /**\n * @notice Updates the maker fee to `newMakerFee`\n * @dev only callable by product owner\n * @param newMakerFee new maker fee value\n */\n function updateMakerFee(UFixed18 newMakerFee) external onlyProductOwner {\n _updateMakerFee(newMakerFee);\n }\n\n /**\n * @notice Updates the taker fee to `newTakerFee`\n * @param newTakerFee new taker fee value\n */\n function _updateTakerFee(UFixed18 newTakerFee) private {\n if (newTakerFee.gt(UFixed18Lib.ONE)) revert ParamProviderInvalidTakerFee();\n _takerFee.store(newTakerFee);\n emit TakerFeeUpdated(newTakerFee);\n }\n\n /**\n * @notice Updates the taker fee to `newTakerFee`\n * @dev only callable by product owner\n * @param newTakerFee new taker fee value\n */\n function updateTakerFee(UFixed18 newTakerFee) external onlyProductOwner {\n _updateTakerFee(newTakerFee);\n }\n\n /**\n * @notice Updates the maker limit to `newMakerLimit`\n * @param newMakerLimit new maker limit value\n */\n function _updateMakerLimit(UFixed18 newMakerLimit) private {\n _makerLimit.store(newMakerLimit);\n emit MakerLimitUpdated(newMakerLimit);\n }\n\n /**\n * @notice Updates the maker limit to `newMakerLimit`\n * @dev only callable by product owner\n * @param newMakerLimit new maker limit value\n */\n function updateMakerLimit(UFixed18 newMakerLimit) external onlyProductOwner {\n _updateMakerLimit(newMakerLimit);\n }\n\n /**\n * @notice Updates the utilization curve to `newUtilizationCurve`\n * @param newUtilizationCurve new utilization curve value\n */\n function _updateUtilizationCurve(JumpRateUtilizationCurve memory newUtilizationCurve) private {\n _utilizationCurve.store(newUtilizationCurve);\n emit JumpRateUtilizationCurveUpdated(\n newUtilizationCurve.minRate.unpack(),\n newUtilizationCurve.maxRate.unpack(),\n newUtilizationCurve.targetRate.unpack(),\n newUtilizationCurve.targetUtilization.unpack()\n );\n }\n\n /**\n * @notice Updates the utilization curve to `newUtilizationCurve`\n * @dev only callable by product owner\n * @param newUtilizationCurve new utilization curve value\n */\n function updateUtilizationCurve(JumpRateUtilizationCurve calldata newUtilizationCurve) external onlyProductOwner {\n _updateUtilizationCurve(newUtilizationCurve);\n }\n}\n" - }, - "contracts/product/types/accumulator/VersionedAccumulator.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../../../interfaces/IProduct.sol\";\nimport \"../../../interfaces/types/Accumulator.sol\";\nimport \"../position/VersionedPosition.sol\";\n\n/// @dev VersionedAccumulator type\nstruct VersionedAccumulator {\n /// @dev Latest synced oracle version\n uint256 latestVersion;\n\n /// @dev Mapping of accumulator value at each settled oracle version\n mapping(uint256 => PackedAccumulator) _valueAtVersion;\n\n /// @dev Mapping of accumulator share at each settled oracle version\n mapping(uint256 => PackedAccumulator) _shareAtVersion;\n}\nusing VersionedAccumulatorLib for VersionedAccumulator global;\n\n/**\n * @title VersionedAccumulatorLib\n * @notice Library that manages global versioned accumulator state.\n * @dev Manages two accumulators: value and share. The value accumulator measures the change in position value\n * over time. The share accumulator measures the change in liquidity ownership over time (for tracking\n * incentivization rewards).\n *\n * Both accumulators are stamped for historical lookup anytime there is a global settlement, which services\n * the delayed-position accounting. It is not guaranteed that every version will have a value stamped, but\n * only versions when a settlement occurred are needed for this historical computation.\n */\nlibrary VersionedAccumulatorLib {\n /**\n * @notice Returns the stamped value accumulator at `oracleVersion`\n * @param self The struct to operate on\n * @param oracleVersion The oracle version to retrieve the value at\n * @return The stamped value accumulator at the requested version\n */\n function valueAtVersion(VersionedAccumulator storage self, uint256 oracleVersion) internal view returns (Accumulator memory) {\n return self._valueAtVersion[oracleVersion].unpack();\n }\n\n /**\n * @notice Returns the stamped share accumulator at `oracleVersion`\n * @param self The struct to operate on\n * @param oracleVersion The oracle version to retrieve the share at\n * @return The stamped share accumulator at the requested version\n */\n function shareAtVersion(VersionedAccumulator storage self, uint256 oracleVersion) internal view returns (Accumulator memory) {\n return self._shareAtVersion[oracleVersion].unpack();\n }\n\n /**\n * @notice Globally accumulates all value (position + funding) and share since last oracle update\n * @param self The struct to operate on\n * @param fundingFee The funding fee rate for the product\n * @param position Pointer to global position\n * @param latestOracleVersion The oracle version to accumulate from\n * @param toOracleVersion The oracle version to accumulate to\n * @return accumulatedFee The total fee accrued from accumulation\n */\n function accumulate(\n VersionedAccumulator storage self,\n UFixed18 fundingFee,\n VersionedPosition storage position,\n IOracleProvider.OracleVersion memory latestOracleVersion,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal returns (UFixed18 accumulatedFee) {\n Position memory latestPosition = position.positionAtVersion(latestOracleVersion.version);\n\n // accumulate funding\n Accumulator memory accumulatedPosition;\n (accumulatedPosition, accumulatedFee) =\n _accumulateFunding(fundingFee, latestPosition, latestOracleVersion, toOracleVersion);\n\n // accumulate position\n accumulatedPosition = accumulatedPosition.add(\n _accumulatePosition(latestPosition, latestOracleVersion, toOracleVersion));\n\n // accumulate share\n Accumulator memory accumulatedShare =\n _accumulateShare(latestPosition, latestOracleVersion, toOracleVersion);\n\n // save update\n self._valueAtVersion[toOracleVersion.version] = valueAtVersion(self, latestOracleVersion.version)\n .add(accumulatedPosition)\n .pack();\n self._shareAtVersion[toOracleVersion.version] = shareAtVersion(self, latestOracleVersion.version)\n .add(accumulatedShare)\n .pack();\n self.latestVersion = toOracleVersion.version;\n }\n\n /**\n * @notice Globally accumulates all funding since last oracle update\n * @dev If an oracle version is skipped due to no pre positions, funding will continue to be\n * pegged to the price of the last snapshotted oracleVersion until a new one is accumulated.\n * This is an acceptable approximation.\n * @param fundingFee The funding fee rate for the product\n * @param latestPosition The latest global position\n * @param latestOracleVersion The oracle version to accumulate from\n * @param toOracleVersion The oracle version to accumulate to\n * @return accumulatedFunding The total amount accumulated from funding\n * @return accumulatedFee The total fee accrued from funding accumulation\n */\n function _accumulateFunding(\n UFixed18 fundingFee,\n Position memory latestPosition,\n IOracleProvider.OracleVersion memory latestOracleVersion,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) private view returns (Accumulator memory accumulatedFunding, UFixed18 accumulatedFee) {\n if (_product().closed()) return (Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO), UFixed18Lib.ZERO);\n if (latestPosition.taker.isZero()) return (Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO), UFixed18Lib.ZERO);\n if (latestPosition.maker.isZero()) return (Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO), UFixed18Lib.ZERO);\n\n uint256 elapsed = toOracleVersion.timestamp - latestOracleVersion.timestamp;\n\n UFixed18 takerNotional = Fixed18Lib.from(latestPosition.taker).mul(latestOracleVersion.price).abs();\n UFixed18 socializedNotional = takerNotional.mul(latestPosition.socializationFactor());\n\n Fixed18 rateAccumulated = _product().rate(latestPosition)\n .mul(Fixed18Lib.from(UFixed18Lib.from(elapsed)));\n Fixed18 fundingAccumulated = rateAccumulated.mul(Fixed18Lib.from(socializedNotional));\n accumulatedFee = fundingAccumulated.abs().mul(fundingFee);\n\n Fixed18 fundingAccumulatedWithoutFee = Fixed18Lib.from(\n fundingAccumulated.sign(),\n fundingAccumulated.abs().sub(accumulatedFee)\n );\n\n bool makerPaysFunding = fundingAccumulated.sign() < 0;\n accumulatedFunding.maker = (makerPaysFunding ? fundingAccumulated : fundingAccumulatedWithoutFee)\n .div(Fixed18Lib.from(latestPosition.maker));\n accumulatedFunding.taker = (makerPaysFunding ? fundingAccumulatedWithoutFee : fundingAccumulated)\n .div(Fixed18Lib.from(latestPosition.taker)).mul(Fixed18Lib.NEG_ONE);\n }\n\n /**\n * @notice Globally accumulates position PNL since last oracle update\n * @param latestPosition The latest global position\n * @param latestOracleVersion The oracle version to accumulate from\n * @param toOracleVersion The oracle version to accumulate to\n * @return accumulatedPosition The total amount accumulated from position PNL\n */\n function _accumulatePosition(\n Position memory latestPosition,\n IOracleProvider.OracleVersion memory latestOracleVersion,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) private view returns (Accumulator memory accumulatedPosition) {\n if (_product().closed()) return Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO);\n if (latestPosition.taker.isZero()) return Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO);\n if (latestPosition.maker.isZero()) return Accumulator(Fixed18Lib.ZERO, Fixed18Lib.ZERO);\n\n Fixed18 oracleDelta = toOracleVersion.price.sub(latestOracleVersion.price);\n Fixed18 totalTakerDelta = oracleDelta.mul(Fixed18Lib.from(latestPosition.taker));\n Fixed18 socializedTakerDelta = totalTakerDelta.mul(Fixed18Lib.from(latestPosition.socializationFactor()));\n\n accumulatedPosition.maker = socializedTakerDelta.div(Fixed18Lib.from(latestPosition.maker)).mul(Fixed18Lib.NEG_ONE);\n accumulatedPosition.taker = socializedTakerDelta.div(Fixed18Lib.from(latestPosition.taker));\n }\n\n /**\n * @notice Globally accumulates position's share of the total market since last oracle update\n * @dev This is used to compute incentivization rewards based on market participation\n * @param latestPosition The latest global position\n * @param latestOracleVersion The oracle version to accumulate from\n * @param toOracleVersion The oracle version to accumulate to\n * @return accumulatedShare The total share amount accumulated per position\n */\n function _accumulateShare(\n Position memory latestPosition,\n IOracleProvider.OracleVersion memory latestOracleVersion,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) private pure returns (Accumulator memory accumulatedShare) {\n uint256 elapsed = toOracleVersion.timestamp - latestOracleVersion.timestamp;\n\n accumulatedShare.maker = latestPosition.maker.isZero() ?\n Fixed18Lib.ZERO :\n Fixed18Lib.from(UFixed18Lib.from(elapsed).div(latestPosition.maker));\n accumulatedShare.taker = latestPosition.taker.isZero() ?\n Fixed18Lib.ZERO :\n Fixed18Lib.from(UFixed18Lib.from(elapsed).div(latestPosition.taker));\n }\n\n function _product() private view returns (IProduct) {\n return IProduct(address(this));\n }\n}\n" - }, - "contracts/product/types/position/VersionedPosition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../../../interfaces/types/PrePosition.sol\";\nimport \"../../../interfaces/types/PackedPosition.sol\";\n\n//// @dev VersionedPosition type\nstruct VersionedPosition {\n /// @dev Mapping of global position at each version\n mapping(uint256 => PackedPosition) _positionAtVersion;\n\n /// @dev Current global pending-settlement position delta\n PrePosition pre;\n}\nusing VersionedPositionLib for VersionedPosition global;\n\n/**\n * @title VersionedPositionLib\n * @notice Library that manages global position state.\n * @dev Global position state is used to compute utilization rate and socialization, and to account for and\n * distribute fees globally.\n *\n * Positions are stamped for historical lookup anytime there is a global settlement, which services\n * the delayed-position accounting. It is not guaranteed that every version will have a value stamped, but\n * only versions when a settlement occurred are needed for this historical computation.\n */\nlibrary VersionedPositionLib {\n /**\n * @notice Returns the current global position\n * @return Current global position\n */\n function positionAtVersion(VersionedPosition storage self, uint256 oracleVersion) internal view returns (Position memory) {\n return self._positionAtVersion[oracleVersion].unpack();\n }\n\n /**\n * @notice Settled the global position to oracle version `toOracleVersion`\n * @param self The struct to operate on\n * @param latestVersion The latest settled oracle version\n * @param toOracleVersion The oracle version to settle to\n * @return positionFee The fee accrued from opening or closing a new position\n */\n function settle(\n VersionedPosition storage self,\n uint256 latestVersion,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal returns (UFixed18) {\n (Position memory newPosition, UFixed18 positionFee, bool settled) =\n positionAtVersion(self, latestVersion).settled(self.pre, toOracleVersion);\n\n self._positionAtVersion[toOracleVersion.version] = newPosition.pack();\n if (settled) delete self.pre;\n\n return positionFee;\n }\n}\n" - }, - "contracts/test/TestnetProductProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\";\nimport \"../interfaces/IContractPayoffProvider.sol\";\n\ncontract TestnetContractPayoffProvider is IContractPayoffProvider {\n function payoff(Fixed18 price) public pure returns (Fixed18) {\n return price.mul(price);\n }\n}\n" - }, - "contracts/product/types/accumulator/AccountAccumulator.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../../../interfaces/types/Accumulator.sol\";\nimport \"../position/AccountPosition.sol\";\nimport \"./VersionedAccumulator.sol\";\n\n/// @dev AccountAccumulator type\nstruct AccountAccumulator {\n /// @dev latest version that the account was synced too\n uint256 latestVersion;\n}\nusing AccountAccumulatorLib for AccountAccumulator global;\n\n/**\n * @title AccountAccumulatorLib\n * @notice Library that manages syncing an account-level accumulator.\n */\nlibrary AccountAccumulatorLib {\n /**\n * @notice Syncs the account to oracle version `versionTo`\n * @param self The struct to operate on\n * @param global Pointer to global accumulator\n * @param position Pointer to global position\n * @param versionTo Oracle version to sync account to\n * @return value The value accumulated sync last sync\n */\n function syncTo(\n AccountAccumulator storage self,\n VersionedAccumulator storage global,\n AccountPosition storage position,\n uint256 versionTo\n ) internal returns (Accumulator memory value) {\n Accumulator memory valueAccumulated = global.valueAtVersion(versionTo)\n .sub(global.valueAtVersion(self.latestVersion));\n value = position.position.mul(valueAccumulated);\n self.latestVersion = versionTo;\n }\n}\n" - }, - "contracts/product/types/position/AccountPosition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../../../interfaces/IProduct.sol\";\nimport \"../../../interfaces/types/PrePosition.sol\";\n\n/// @dev AccountPosition type\nstruct AccountPosition {\n /// @dev The current settled position of the account\n Position position;\n\n /// @dev The current position delta pending-settlement\n PrePosition pre;\n\n /// @dev Whether the account is currently locked for liquidation\n bool liquidation;\n}\nusing AccountPositionLib for AccountPosition global;\n\n/**\n * @title AccountPositionLib\n * @notice Library that manages an account-level position.\n */\nlibrary AccountPositionLib {\n /**\n * @notice Settled the account's position to oracle version `toOracleVersion`\n * @param self The struct to operate on\n * @param toOracleVersion The oracle version to accumulate to\n * @return positionFee The fee accrued from opening or closing a new position\n */\n function settle(\n AccountPosition storage self,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal returns (UFixed18 positionFee) {\n bool settled;\n (self.position, positionFee, settled) = self.position.settled(self.pre, toOracleVersion);\n if (settled) {\n delete self.pre;\n self.liquidation = false;\n }\n }\n\n /**\n * @notice Returns the current maintenance requirement for the account\n * @dev Must be called from a valid product to get the proper maintenance value\n * @param self The struct to operate on\n * @return Current maintenance requirement for the account\n */\n function maintenance(AccountPosition storage self) internal view returns (UFixed18) {\n if (self.liquidation) return UFixed18Lib.ZERO;\n return _maintenance(self.position);\n }\n\n /**\n * @notice Returns the maintenance requirement after the next oracle version settlement\n * @dev Includes the current pending-settlement position delta, assumes no price change\n * @param self The struct to operate on\n * @return Next maintenance requirement for the account\n */\n function maintenanceNext(AccountPosition storage self) internal view returns (UFixed18) {\n return _maintenance(self.position.next(self.pre));\n }\n\n /**\n * @notice Returns the maintenance requirement for a given `position`\n * @dev Internal helper\n * @param position The position to compete the maintenance requirement for\n * @return Next maintenance requirement for the account\n */\n function _maintenance(Position memory position) private view returns (UFixed18) {\n IProduct product = IProduct(address(this));\n Fixed18 oraclePrice = product.currentVersion().price;\n UFixed18 notionalMax = Fixed18Lib.from(position.max()).mul(oraclePrice).abs();\n return notionalMax.mul(product.maintenance());\n }\n\n /**\n * @notice Returns whether an account is completely closed, i.e. no position or pre-position\n * @param self The struct to operate on\n * @return Whether the account is closed\n */\n function isClosed(AccountPosition memory self) internal pure returns (bool) {\n return self.pre.isEmpty() && self.position.isEmpty();\n }\n\n /**\n * @notice Returns whether an account has opened position on both sides of the market (maker vs taker)\n * @dev Used to verify the invariant that a single account can only have a position on one side of the\n * market at a time\n * @param self The struct to operate on\n * @return Whether the account is currently doubled sided\n */\n function isDoubleSided(AccountPosition storage self) internal view returns (bool) {\n bool makerEmpty = self.position.maker.isZero() && self.pre.openPosition.maker.isZero() && self.pre.closePosition.maker.isZero();\n bool takerEmpty = self.position.taker.isZero() && self.pre.openPosition.taker.isZero() && self.pre.closePosition.taker.isZero();\n\n return !makerEmpty && !takerEmpty;\n }\n\n /**\n * @notice Returns whether the account's pending-settlement delta closes more position than is open\n * @dev Used to verify the invariant that an account cannot settle into having a negative position\n * @param self The struct to operate on\n * @return Whether the account is currently over closed\n */\n function isOverClosed(AccountPosition storage self) internal view returns (bool) {\n Position memory nextOpen = self.position.add(self.pre.openPosition);\n\n return self.pre.closePosition.maker.gt(nextOpen.maker) || self.pre.closePosition.taker.gt(nextOpen.taker);\n }\n}\n" - }, - "contracts/product/UPayoffProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/control/unstructured/UInitializable.sol\";\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"@equilibria/root/storage/UStorage.sol\";\nimport \"../interfaces/IPayoffProvider.sol\";\nimport \"../interfaces/types/PayoffDefinition.sol\";\n\n/**\n * @title UPayoffProvider\n * @notice Library for manage storing, surfacing, and upgrading a payoff provider.\n * @dev Uses an unstructured storage pattern to store the oracle address and payoff definition which allows this\n provider to be safely used with upgradeable contracts.\n */\nabstract contract UPayoffProvider is IPayoffProvider, UInitializable {\n /// @dev The oracle contract address\n AddressStorage private constant _oracle =\n AddressStorage.wrap(keccak256(\"equilibria.perennial.UPayoffProvider.oracle\"));\n function oracle() public view returns (IOracleProvider) { return IOracleProvider(_oracle.read()); }\n\n /// @dev Payoff definition struct\n PayoffDefinitionStorage private constant _payoffDefinition =\n PayoffDefinitionStorage.wrap(keccak256(\"equilibria.perennial.UPayoffProvider.payoffDefinition\"));\n function payoffDefinition() public view returns (PayoffDefinition memory) { return _payoffDefinition.read(); }\n\n /**\n * @notice Initializes the contract state\n * @param oracle_ Oracle address\n * @param payoffDefinition_ Payoff provider\n */\n // solhint-disable-next-line func-name-mixedcase\n function __UPayoffProvider__initialize(IOracleProvider oracle_, PayoffDefinition calldata payoffDefinition_) internal onlyInitializer {\n if (!Address.isContract(address(oracle_))) revert PayoffProviderInvalidOracle();\n _oracle.store(address(oracle_));\n\n if (!payoffDefinition_.valid()) revert PayoffProviderInvalidPayoffDefinitionError();\n _payoffDefinition.store(payoffDefinition_);\n }\n\n /**\n * @notice Returns the current oracle version transformed by the payoff definition\n * @return Current oracle version transformed by the payoff definition\n */\n function currentVersion() public view returns (IOracleProvider.OracleVersion memory) {\n return _transform(oracle().currentVersion());\n }\n\n /**\n * @notice Returns the oracle version at `oracleVersion` transformed by the payoff definition\n * @param oracleVersion Oracle version to return for\n * @return Oracle version at `oracleVersion` with price transformed by payoff function\n */\n function atVersion(uint256 oracleVersion) public view returns (IOracleProvider.OracleVersion memory) {\n return _transform(oracle().atVersion(oracleVersion));\n }\n\n /**\n * @notice Yook to call sync() on the oracle provider and transform the resulting oracle version\n */\n function _sync() internal returns (IOracleProvider.OracleVersion memory) {\n return _transform(oracle().sync());\n }\n\n /**\n * @notice Returns the transformed oracle version\n * @param oracleVersion Oracle version to transform\n * @return Transformed oracle version\n */\n function _transform(IOracleProvider.OracleVersion memory oracleVersion)\n internal view virtual returns (IOracleProvider.OracleVersion memory) {\n oracleVersion.price = payoffDefinition().transform(oracleVersion.price);\n return oracleVersion;\n }\n}\n" - }, - "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/UpgradeableBeacon.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IBeacon.sol\";\nimport \"../../access/Ownable.sol\";\nimport \"../../utils/Address.sol\";\n\n/**\n * @dev This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their\n * implementation contract, which is where they will delegate all function calls.\n *\n * An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.\n */\ncontract UpgradeableBeacon is IBeacon, Ownable {\n address private _implementation;\n\n /**\n * @dev Emitted when the implementation returned by the beacon is changed.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the\n * beacon.\n */\n constructor(address implementation_) {\n _setImplementation(implementation_);\n }\n\n /**\n * @dev Returns the current implementation address.\n */\n function implementation() public view virtual override returns (address) {\n return _implementation;\n }\n\n /**\n * @dev Upgrades the beacon to a new implementation.\n *\n * Emits an {Upgraded} event.\n *\n * Requirements:\n *\n * - msg.sender must be the owner of the contract.\n * - `newImplementation` must be a contract.\n */\n function upgradeTo(address newImplementation) public virtual onlyOwner {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Sets the implementation contract address for this beacon\n *\n * Requirements:\n *\n * - `newImplementation` must be a contract.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"UpgradeableBeacon: implementation is not a contract\");\n _implementation = newImplementation;\n }\n}\n" - }, - "@openzeppelin/contracts/access/Ownable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n _;\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Context.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n" - }, - "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/ProxyAdmin.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./TransparentUpgradeableProxy.sol\";\nimport \"../../access/Ownable.sol\";\n\n/**\n * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an\n * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.\n */\ncontract ProxyAdmin is Ownable {\n /**\n * @dev Returns the current implementation of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"implementation()\")) == 0x5c60da1b\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"5c60da1b\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Returns the current admin of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"admin()\")) == 0xf851a440\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"f851a440\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Changes the admin of `proxy` to `newAdmin`.\n *\n * Requirements:\n *\n * - This contract must be the current admin of `proxy`.\n */\n function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {\n proxy.changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {\n proxy.upgradeTo(implementation);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See\n * {TransparentUpgradeableProxy-upgradeToAndCall}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgradeAndCall(\n TransparentUpgradeableProxy proxy,\n address implementation,\n bytes memory data\n ) public payable virtual onlyOwner {\n proxy.upgradeToAndCall{value: msg.value}(implementation, data);\n }\n}\n" - }, - "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC1967/ERC1967Proxy.sol\";\n\n/**\n * @dev This contract implements a proxy that is upgradeable by an admin.\n *\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\n * clashing], which can potentially be used in an attack, this contract uses the\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\n * things that go hand in hand:\n *\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\n * that call matches one of the admin functions exposed by the proxy itself.\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\n * \"admin cannot fallback to proxy target\".\n *\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\n * to sudden errors when trying to call a function from the proxy implementation.\n *\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\n */\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\n /**\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\n */\n constructor(\n address _logic,\n address admin_,\n bytes memory _data\n ) payable ERC1967Proxy(_logic, _data) {\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.admin\")) - 1));\n _changeAdmin(admin_);\n }\n\n /**\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\n */\n modifier ifAdmin() {\n if (msg.sender == _getAdmin()) {\n _;\n } else {\n _fallback();\n }\n }\n\n /**\n * @dev Returns the current admin.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\n */\n function admin() external ifAdmin returns (address admin_) {\n admin_ = _getAdmin();\n }\n\n /**\n * @dev Returns the current implementation.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\n */\n function implementation() external ifAdmin returns (address implementation_) {\n implementation_ = _implementation();\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\n */\n function changeAdmin(address newAdmin) external virtual ifAdmin {\n _changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\n */\n function upgradeTo(address newImplementation) external ifAdmin {\n _upgradeToAndCall(newImplementation, bytes(\"\"), false);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\n * proxied contract.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\n */\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\n _upgradeToAndCall(newImplementation, data, true);\n }\n\n /**\n * @dev Returns the current admin.\n */\n function _admin() internal view virtual returns (address) {\n return _getAdmin();\n }\n\n /**\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\n */\n function _beforeFallback() internal virtual override {\n require(msg.sender != _getAdmin(), \"TransparentUpgradeableProxy: admin cannot fallback to proxy target\");\n super._beforeFallback();\n }\n}\n" - }, - "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Proxy.sol\";\nimport \"./ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\n * implementation address that can be changed. This address is stored in storage in the location specified by\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\n * implementation behind the proxy.\n */\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\n /**\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\n *\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\n */\n constructor(address _logic, bytes memory _data) payable {\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.implementation\")) - 1));\n _upgradeToAndCall(_logic, _data, false);\n }\n\n /**\n * @dev Returns the current implementation address.\n */\n function _implementation() internal view virtual override returns (address impl) {\n return ERC1967Upgrade._getImplementation();\n }\n}\n" - }, - "@openzeppelin/contracts/proxy/Proxy.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n /**\n * @dev Delegates the current call to `implementation`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _delegate(address implementation) internal virtual {\n assembly {\n // Copy msg.data. We take full control of memory in this inline assembly\n // block because it will not return to Solidity code. We overwrite the\n // Solidity scratch pad at memory position 0.\n calldatacopy(0, 0, calldatasize())\n\n // Call the implementation.\n // out and outsize are 0 because we don't know the size yet.\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n // Copy the returned data.\n returndatacopy(0, 0, returndatasize())\n\n switch result\n // delegatecall returns 0 on error.\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n /**\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\n * and {_fallback} should delegate.\n */\n function _implementation() internal view virtual returns (address);\n\n /**\n * @dev Delegates the current call to the address returned by `_implementation()`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _fallback() internal virtual {\n _beforeFallback();\n _delegate(_implementation());\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n * function in the contract matches the call data.\n */\n fallback() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\n * is empty.\n */\n receive() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\n * call, or as part of the Solidity `fallback` or `receive` functions.\n *\n * If overridden should call `super._beforeFallback()`.\n */\n function _beforeFallback() internal virtual {}\n}\n" - }, - "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeacon.sol\";\nimport \"../../interfaces/draft-IERC1822.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/StorageSlot.sol\";\n\n/**\n * @dev This abstract contract provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\n *\n * _Available since v4.1._\n *\n * @custom:oz-upgrades-unsafe-allow delegatecall\n */\nabstract contract ERC1967Upgrade {\n // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\n\n /**\n * @dev Storage slot with the address of the current implementation.\n * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @dev Emitted when the implementation is upgraded.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Returns the current implementation address.\n */\n function _getImplementation() internal view returns (address) {\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 implementation slot.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n }\n\n /**\n * @dev Perform implementation upgrade\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeTo(address newImplementation) internal {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Perform implementation upgrade with additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCall(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n _upgradeTo(newImplementation);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(newImplementation, data);\n }\n }\n\n /**\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCallUUPS(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n // Upgrades from old implementations will perform a rollback test. This test requires the new\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\n // this special case will break upgrade paths from old UUPS implementation to new ones.\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\n _setImplementation(newImplementation);\n } else {\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n require(slot == _IMPLEMENTATION_SLOT, \"ERC1967Upgrade: unsupported proxiableUUID\");\n } catch {\n revert(\"ERC1967Upgrade: new implementation is not UUPS\");\n }\n _upgradeToAndCall(newImplementation, data, forceCall);\n }\n }\n\n /**\n * @dev Storage slot with the admin of the contract.\n * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n /**\n * @dev Emitted when the admin account has changed.\n */\n event AdminChanged(address previousAdmin, address newAdmin);\n\n /**\n * @dev Returns the current admin.\n */\n function _getAdmin() internal view returns (address) {\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 admin slot.\n */\n function _setAdmin(address newAdmin) private {\n require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n */\n function _changeAdmin(address newAdmin) internal {\n emit AdminChanged(_getAdmin(), newAdmin);\n _setAdmin(newAdmin);\n }\n\n /**\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n */\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n /**\n * @dev Emitted when the beacon is upgraded.\n */\n event BeaconUpgraded(address indexed beacon);\n\n /**\n * @dev Returns the current beacon.\n */\n function _getBeacon() internal view returns (address) {\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\n }\n\n /**\n * @dev Stores a new beacon in the EIP1967 beacon slot.\n */\n function _setBeacon(address newBeacon) private {\n require(Address.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n require(\n Address.isContract(IBeacon(newBeacon).implementation()),\n \"ERC1967: beacon implementation is not a contract\"\n );\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n }\n\n /**\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n *\n * Emits a {BeaconUpgraded} event.\n */\n function _upgradeBeaconToAndCall(\n address newBeacon,\n bytes memory data,\n bool forceCall\n ) internal {\n _setBeacon(newBeacon);\n emit BeaconUpgraded(newBeacon);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/interfaces/draft-IERC1822.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822Proxiable {\n /**\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n * address.\n *\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n * function revert if invoked through a proxy.\n */\n function proxiableUUID() external view returns (bytes32);\n}\n" - }, - "@openzeppelin/contracts/utils/StorageSlot.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\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 ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\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(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\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 /**\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 {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n assembly {\n r.slot := slot\n }\n }\n}\n" - }, - "contracts/hardhat-dependency-compiler/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol';\n" - }, - "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/BeaconProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IBeacon.sol\";\nimport \"../Proxy.sol\";\nimport \"../ERC1967/ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements a proxy that gets the implementation address for each call from a {UpgradeableBeacon}.\n *\n * The beacon address is stored in storage slot `uint256(keccak256('eip1967.proxy.beacon')) - 1`, so that it doesn't\n * conflict with the storage layout of the implementation behind the proxy.\n *\n * _Available since v3.4._\n */\ncontract BeaconProxy is Proxy, ERC1967Upgrade {\n /**\n * @dev Initializes the proxy with `beacon`.\n *\n * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This\n * will typically be an encoded function call, and allows initializating the storage of the proxy like a Solidity\n * constructor.\n *\n * Requirements:\n *\n * - `beacon` must be a contract with the interface {IBeacon}.\n */\n constructor(address beacon, bytes memory data) payable {\n assert(_BEACON_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.beacon\")) - 1));\n _upgradeBeaconToAndCall(beacon, data, false);\n }\n\n /**\n * @dev Returns the current beacon address.\n */\n function _beacon() internal view virtual returns (address) {\n return _getBeacon();\n }\n\n /**\n * @dev Returns the current implementation address of the associated beacon.\n */\n function _implementation() internal view virtual override returns (address) {\n return IBeacon(_getBeacon()).implementation();\n }\n\n /**\n * @dev Changes the proxy to use a new beacon. Deprecated: see {_upgradeBeaconToAndCall}.\n *\n * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon.\n *\n * Requirements:\n *\n * - `beacon` must be a contract.\n * - The implementation returned by `beacon` must be a contract.\n */\n function _setBeacon(address beacon, bytes memory data) internal virtual {\n _upgradeBeaconToAndCall(beacon, data, false);\n }\n}\n" - }, - "contracts/controller/Controller.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/root/control/unstructured/UInitializable.sol\";\nimport \"@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol\";\nimport \"../interfaces/IController.sol\";\nimport \"../interfaces/ICollateral.sol\";\nimport \"../interfaces/IIncentivizer.sol\";\nimport \"../interfaces/IProduct.sol\";\n\n/**\n * @title Controller\n * @notice Manages creating new products and global protocol parameters.\n */\ncontract Controller is IController, UInitializable {\n /// @dev Collateral contract address for the protocol\n AddressStorage private constant _collateral = AddressStorage.wrap(keccak256(\"equilibria.perennial.Controller.collateral\"));\n function collateral() public view returns (ICollateral) { return ICollateral(_collateral.read()); }\n\n /// @dev Incentivizer contract address for the protocol\n AddressStorage private constant _incentivizer = AddressStorage.wrap(keccak256(\"equilibria.perennial.Controller.incentivizer\"));\n function incentivizer() public view returns (IIncentivizer) { return IIncentivizer(_incentivizer.read()); }\n\n /// @dev Product implementation beacon address for the protocol\n AddressStorage private constant _productBeacon = AddressStorage.wrap(keccak256(\"equilibria.perennial.Controller.productBeacon\"));\n function productBeacon() public view returns (IBeacon) { return IBeacon(_productBeacon.read()); }\n\n /// @dev Percent of collected fees that go to the protocol treasury vs the product treasury\n UFixed18Storage private constant _protocolFee = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.Controller.protocolFee\"));\n function protocolFee() public view returns (UFixed18) { return _protocolFee.read(); }\n\n /// @dev Minimum allowable funding fee for a product\n UFixed18Storage private constant _minFundingFee = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.Controller.minFundingFee\"));\n function minFundingFee() public view returns (UFixed18) { return _minFundingFee.read(); }\n\n /// @dev Fee on maintenance for liquidation\n UFixed18Storage private constant _liquidationFee = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.Controller.liquidationFee\"));\n function liquidationFee() public view returns (UFixed18) { return _liquidationFee.read(); }\n\n /// @dev Fee on incentivization programs\n UFixed18Storage private constant _incentivizationFee = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.Controller.incentivizationFee\"));\n function incentivizationFee() public view returns (UFixed18) { return _incentivizationFee.read(); }\n\n /// @dev Minimum allowable collateral amount per user account\n UFixed18Storage private constant _minCollateral = UFixed18Storage.wrap(keccak256(\"equilibria.perennial.Controller.minCollateral\"));\n function minCollateral() public view returns (UFixed18) { return _minCollateral.read(); }\n\n /// @dev Maximum incentivization programs per product allowed\n Uint256Storage private constant _programsPerProduct = Uint256Storage.wrap(keccak256(\"equilibria.perennial.Controller.programsPerProduct\"));\n function programsPerProduct() public view returns (uint256) { return _programsPerProduct.read(); }\n\n /// @dev Protocol pauser address. address(0) defaults to owner(0)\n AddressStorage private constant _pauser = AddressStorage.wrap(keccak256(\"equilibria.perennial.Controller.pauser\"));\n function pauser() public view returns (address) {\n address pauser_ = _pauser.read();\n return pauser_ == address(0) ? owner() : pauser_;\n }\n\n /// @dev The paused status of the protocol\n BoolStorage private constant _paused = BoolStorage.wrap(keccak256(\"equilibria.perennial.Controller.paused\"));\n function paused() public view returns (bool) { return _paused.read(); }\n\n /// @dev List of product coordinators\n Coordinator[] private _coordinators;\n\n /// @dev Mapping of the coordinator for each product\n mapping(IProduct => uint256) public coordinatorFor;\n\n /**\n * @notice Initializes the contract state\n * @dev Must be called atomically as part of the upgradeable proxy deployment to\n * avoid front-running\n * @param collateral_ Collateral contract address\n * @param incentivizer_ Incentivizer contract address\n * @param productBeacon_ Product implementation beacon address\n */\n function initialize(\n ICollateral collateral_,\n IIncentivizer incentivizer_,\n IBeacon productBeacon_\n ) external initializer(1) {\n _createCoordinator();\n\n updateCollateral(collateral_);\n updateIncentivizer(incentivizer_);\n updateProductBeacon(productBeacon_);\n }\n\n /**\n * @notice Creates a new coordinator with `msg.sender` as the owner\n * @dev Can only be called by the protocol owner\n * @return New coordinator ID\n */\n function createCoordinator() external returns (uint256) {\n return _createCoordinator();\n }\n\n /**\n * @notice Creates a new coordinator with `msg.sender` as the owner\n * @dev `treasury` and `pauser` initialize as the 0-address, defaulting to the `owner`\n * @return New coordinator ID\n */\n function _createCoordinator() private returns (uint256) {\n uint256 coordinatorId = _coordinators.length;\n\n _coordinators.push(Coordinator({\n pendingOwner: address(0),\n owner: msg.sender,\n treasury: address(0)\n }));\n\n emit CoordinatorCreated(coordinatorId, msg.sender);\n\n return coordinatorId;\n }\n\n /**\n * @notice Updates the pending owner of an existing coordinator\n * @dev Must be called by the coordinator's current owner\n * @param coordinatorId Coordinator to update\n * @param newPendingOwner New pending owner address\n */\n function updateCoordinatorPendingOwner(uint256 coordinatorId, address newPendingOwner) external onlyOwner(coordinatorId) {\n _coordinators[coordinatorId].pendingOwner = newPendingOwner;\n emit CoordinatorPendingOwnerUpdated(coordinatorId, newPendingOwner);\n }\n\n /**\n * @notice Accepts ownership over an existing coordinator\n * @dev Must be called by the coordinator's pending owner\n * @param coordinatorId Coordinator to update\n */\n function acceptCoordinatorOwner(uint256 coordinatorId) external {\n Coordinator storage coordinator = _coordinators[coordinatorId];\n address newPendingOwner = coordinator.pendingOwner;\n\n if (msg.sender != newPendingOwner) revert ControllerNotPendingOwnerError(coordinatorId);\n\n coordinator.pendingOwner = address(0);\n coordinator.owner = newPendingOwner;\n emit CoordinatorOwnerUpdated(coordinatorId, newPendingOwner);\n }\n\n /**\n * @notice Updates the treasury of an existing coordinator\n * @dev Must be called by the coordinator's current owner. Defaults to the coordinator `owner` if set to address(0)\n * @param coordinatorId Coordinator to update\n * @param newTreasury New treasury address\n */\n function updateCoordinatorTreasury(uint256 coordinatorId, address newTreasury) external onlyOwner(coordinatorId) {\n _coordinators[coordinatorId].treasury = newTreasury;\n emit CoordinatorTreasuryUpdated(coordinatorId, newTreasury);\n }\n\n /**\n * @notice Creates a new product market with `provider`\n * @dev Can only be called by the coordinator owner\n * @param coordinatorId Coordinator that will own the product\n * @param productInfo Product params used to initialize the product\n * @return New product contract address\n */\n function createProduct(uint256 coordinatorId, IProduct.ProductInfo calldata productInfo)\n external onlyOwner(coordinatorId) returns (IProduct) {\n if (coordinatorId == 0) revert ControllerNoZeroCoordinatorError();\n\n BeaconProxy newProductProxy = new BeaconProxy(address(productBeacon()), abi.encodeCall(IProduct.initialize, productInfo));\n IProduct newProduct = IProduct(address(newProductProxy));\n coordinatorFor[newProduct] = coordinatorId;\n emit ProductCreated(newProduct, productInfo);\n\n return newProduct;\n }\n\n /**\n * @notice Updates the Collateral contract address\n * @param newCollateral New Collateral contract address\n */\n function updateCollateral(ICollateral newCollateral) public onlyOwner(0) {\n if (!Address.isContract(address(newCollateral))) revert ControllerNotContractAddressError();\n _collateral.store(address(newCollateral));\n emit CollateralUpdated(newCollateral);\n }\n\n /**\n * @notice Updates the Incentivizer contract address\n * @param newIncentivizer New Incentivizer contract address\n */\n function updateIncentivizer(IIncentivizer newIncentivizer) public onlyOwner(0) {\n if (!Address.isContract(address(newIncentivizer))) revert ControllerNotContractAddressError();\n _incentivizer.store(address(newIncentivizer));\n emit IncentivizerUpdated(newIncentivizer);\n }\n\n /**\n * @notice Updates the Product implementation beacon address\n * @param newProductBeacon New Product implementation beacon address\n */\n function updateProductBeacon(IBeacon newProductBeacon) public onlyOwner(0) {\n if (!Address.isContract(address(newProductBeacon))) revert ControllerNotContractAddressError();\n _productBeacon.store(address(newProductBeacon));\n emit ProductBeaconUpdated(newProductBeacon);\n }\n\n /**\n * @notice Updates the protocol-product fee split\n * @param newProtocolFee New protocol-product fee split\n */\n function updateProtocolFee(UFixed18 newProtocolFee) public onlyOwner(0) {\n if (newProtocolFee.gt(UFixed18Lib.ONE)) revert ControllerInvalidProtocolFeeError();\n\n _protocolFee.store(newProtocolFee);\n emit ProtocolFeeUpdated(newProtocolFee);\n }\n\n /**\n * @notice Updates the minimum allowed funding fee\n * @param newMinFundingFee New minimum allowed funding fee\n */\n function updateMinFundingFee(UFixed18 newMinFundingFee) public onlyOwner(0) {\n if (newMinFundingFee.gt(UFixed18Lib.ONE)) revert ControllerInvalidMinFundingFeeError();\n\n _minFundingFee.store(newMinFundingFee);\n emit MinFundingFeeUpdated(newMinFundingFee);\n }\n\n /**\n * @notice Updates the liquidation fee\n * @param newLiquidationFee New liquidation fee\n */\n function updateLiquidationFee(UFixed18 newLiquidationFee) public onlyOwner(0) {\n if (newLiquidationFee.gt(UFixed18Lib.ONE)) revert ControllerInvalidLiquidationFeeError();\n\n _liquidationFee.store(newLiquidationFee);\n emit LiquidationFeeUpdated(newLiquidationFee);\n }\n\n /**\n * @notice Updates the incentivization fee\n * @param newIncentivizationFee New incentivization fee\n */\n function updateIncentivizationFee(UFixed18 newIncentivizationFee) public onlyOwner(0) {\n if (newIncentivizationFee.gt(UFixed18Lib.ONE)) revert ControllerInvalidIncentivizationFeeError();\n\n _incentivizationFee.store(newIncentivizationFee);\n emit IncentivizationFeeUpdated(newIncentivizationFee);\n }\n\n /**\n * @notice Updates the minimum allowed collateral amount per user account\n * @param newMinCollateral New minimum allowed collateral amount\n */\n function updateMinCollateral(UFixed18 newMinCollateral) public onlyOwner(0) {\n _minCollateral.store(newMinCollateral);\n emit MinCollateralUpdated(newMinCollateral);\n }\n\n /**\n * @notice Updates the maximum incentivization programs per product allowed\n * @param newProgramsPerProduct New maximum incentivization programs per product allowed\n */\n function updateProgramsPerProduct(uint256 newProgramsPerProduct) public onlyOwner(0) {\n _programsPerProduct.store(newProgramsPerProduct);\n emit ProgramsPerProductUpdated(newProgramsPerProduct);\n }\n\n /**\n * @notice Updates the protocol pauser address. Zero address defaults to owner(0)\n * @param newPauser New protocol pauser address\n */\n function updatePauser(address newPauser) public onlyOwner(0) {\n _pauser.store(newPauser);\n emit PauserUpdated(newPauser);\n }\n\n /**\n * @notice Updates the protocol paused state\n * @param newPaused New protocol paused state\n */\n function updatePaused(bool newPaused) public onlyPauser {\n _paused.store(newPaused);\n emit PausedUpdated(newPaused);\n }\n\n /**\n * @notice Returns whether a contract is a product\n * @param product Contract address to check\n * @return Whether a contract is a product\n */\n function isProduct(IProduct product) external view returns (bool) {\n return coordinatorFor[product] != 0;\n }\n\n /**\n * @notice Returns coordinator state for coordinator `coordinatorId`\n * @param coordinatorId Coordinator to return for\n * @return Coordinator state\n */\n function coordinators(uint256 coordinatorId) external view returns (Coordinator memory) {\n return _coordinators[coordinatorId];\n }\n\n /**\n * @notice Returns the pending owner of the protocol\n * @return Owner of the protocol\n */\n function pendingOwner() public view returns (address) {\n return pendingOwner(0);\n }\n\n /**\n * @notice Returns the pending owner of the coordinator `coordinatorId`\n * @param coordinatorId Coordinator to return for\n * @return Pending owner of the coordinator\n */\n function pendingOwner(uint256 coordinatorId) public view returns (address) {\n return _coordinators[coordinatorId].pendingOwner;\n }\n\n /**\n * @notice Returns the owner of the protocol\n * @return Owner of the protocol\n */\n function owner() public view returns (address) {\n return owner(0);\n }\n\n /**\n * @notice Returns the owner of the coordinator `coordinatorId`\n * @param coordinatorId Coordinator to return for\n * @return Owner of the coordinator\n */\n function owner(uint256 coordinatorId) public view returns (address) {\n return _coordinators[coordinatorId].owner;\n }\n\n /**\n * @notice Returns the owner of the product `product`\n * @param product Product to return for\n * @return Owner of the product\n */\n function owner(IProduct product) external view returns (address) {\n return owner(coordinatorFor[product]);\n }\n\n /**\n * @notice Returns the treasury of the protocol\n * @dev Defaults to the `owner` when `treasury` is unset\n * @return Treasury of the protocol\n */\n function treasury() external view returns (address) {\n return treasury(0);\n }\n\n /**\n * @notice Returns the treasury of the coordinator `coordinatorId`\n * @dev Defaults to the `owner` when `treasury` is unset\n * @param coordinatorId Coordinator to return for\n * @return Treasury of the coordinator\n */\n function treasury(uint256 coordinatorId) public view returns (address) {\n address _treasury = _coordinators[coordinatorId].treasury;\n return _treasury == address(0) ? owner(coordinatorId) : _treasury;\n }\n\n /**\n * @notice Returns the treasury of the product `product`\n * @dev Defaults to the `owner` when `treasury` is unset\n * @param product Product to return for\n * @return Treasury of the product\n */\n function treasury(IProduct product) external view returns (address) {\n return treasury(coordinatorFor[product]);\n }\n\n /// @dev Only allow owner of `coordinatorId` to call\n modifier onlyOwner(uint256 coordinatorId) {\n if (msg.sender != owner(coordinatorId)) revert ControllerNotOwnerError(coordinatorId);\n\n _;\n }\n\n /// @dev Only allow the pauser to call\n modifier onlyPauser {\n if (msg.sender != pauser()) revert ControllerNotPauserError();\n\n _;\n }\n}\n" - }, - "contracts/incentivizer/Incentivizer.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/root/control/unstructured/UInitializable.sol\";\nimport \"@equilibria/root/control/unstructured/UReentrancyGuard.sol\";\nimport \"../interfaces/IIncentivizer.sol\";\nimport \"../interfaces/IController.sol\";\nimport \"../controller/UControllerProvider.sol\";\nimport \"./types/ProductManager.sol\";\n\n/**\n * @title Incentivizer\n * @notice Manages logic and state for all incentive programs in the protocol.\n */\ncontract Incentivizer is IIncentivizer, UInitializable, UControllerProvider, UReentrancyGuard {\n /// @dev Product management state\n mapping(IProduct => ProductManager) private _products;\n\n /// @dev Fees that have been collected, but remain unclaimed\n mapping(Token18 => UFixed18) public fees;\n\n /**\n * @notice Initializes the contract state\n * @dev Must be called atomically as part of the upgradeable proxy deployment to\n * avoid front-running\n * @param controller_ Factory contract address\n */\n function initialize(IController controller_) external initializer(1) {\n __UControllerProvider__initialize(controller_);\n __UReentrancyGuard__initialize();\n }\n\n /**\n * @notice Creates a new incentive program\n * @dev Must be called as the product or protocol owner\n * @param product The product to create the new program on\n * @param programInfo Parameters for the new program\n * @return programId New program's ID\n */\n function create(IProduct product, ProgramInfo calldata programInfo)\n external\n nonReentrant\n isProduct(product)\n notPaused\n onlyOwner(programInfo.coordinatorId)\n returns (uint256 programId) {\n IController _controller = controller();\n\n // Validate\n if (programInfo.coordinatorId != 0 && programInfo.coordinatorId != _controller.coordinatorFor(product))\n revert IncentivizerNotAllowedError(product);\n if (active(product) >= _controller.programsPerProduct())\n revert IncentivizerTooManyProgramsError();\n ProgramInfoLib.validate(programInfo);\n\n // Take fee\n (ProgramInfo memory newProgramInfo, UFixed18 programFeeAmount) = ProgramInfoLib.deductFee(programInfo, _controller.incentivizationFee());\n fees[newProgramInfo.token] = fees[newProgramInfo.token].add(programFeeAmount);\n\n // Register program\n programId = _products[product].register(newProgramInfo);\n\n // Charge creator\n newProgramInfo.token.pull(msg.sender, programInfo.amount.sum());\n\n emit ProgramCreated(\n product,\n programId,\n newProgramInfo,\n programFeeAmount\n );\n }\n\n /**\n * @notice Completes an in-progress program early\n * @dev Must be called as the program owner\n * @param product Product that the program is running on\n * @param programId Program to complete early\n */\n function complete(IProduct product, uint256 programId)\n external\n nonReentrant\n isProgram(product, programId)\n notPaused\n onlyProgramOwner(product, programId)\n {\n ProductManagerLib.SyncResult memory syncResult = _products[product].complete(product, programId);\n _handleSyncResult(product, syncResult);\n }\n\n /**\n * @notice Starts and completes programs as they become available\n * @dev Called every settle() from each product\n * @param currentOracleVersion The preloaded current oracle version\n */\n function sync(IOracleProvider.OracleVersion memory currentOracleVersion) external onlyProduct {\n IProduct product = IProduct(msg.sender);\n\n ProductManagerLib.SyncResult[] memory syncResults = _products[product].sync(product, currentOracleVersion);\n for (uint256 i = 0; i < syncResults.length; i++) {\n _handleSyncResult(product, syncResults[i]);\n }\n }\n\n /**\n * @notice Handles refunding and event emitting on program start and completion\n * @param product Product that the program is running on\n * @param syncResult The data from the sync event to handle\n */\n function _handleSyncResult(IProduct product, ProductManagerLib.SyncResult memory syncResult) private {\n uint256 programId = syncResult.programId;\n if (!syncResult.refundAmount.isZero())\n _products[product].token(programId).push(treasury(product, programId), syncResult.refundAmount);\n if (syncResult.versionStarted != 0)\n emit ProgramStarted(product, programId, syncResult.versionStarted);\n if (syncResult.versionComplete != 0)\n emit ProgramComplete(product, programId, syncResult.versionComplete);\n }\n\n /**\n * @notice Settles unsettled balance for `account`\n * @dev Called immediately proceeding a position update in the corresponding product\n * @param account Account to sync\n * @param currentOracleVersion The preloaded current oracle version\n */\n function syncAccount(\n address account,\n IOracleProvider.OracleVersion memory currentOracleVersion\n ) external onlyProduct {\n IProduct product = IProduct(msg.sender);\n _products[product].syncAccount(product, account, currentOracleVersion);\n }\n\n /**\n * @notice Claims all of `msg.sender`'s rewards for `product` programs\n * @param product Product to claim rewards for\n * @param programIds Programs to claim rewards for\n */\n function claim(IProduct product, uint256[] calldata programIds)\n external\n nonReentrant\n {\n _claimProduct(product, programIds);\n }\n\n /**\n * @notice Claims all of `msg.sender`'s rewards for a specific program\n * @param products Products to claim rewards for\n * @param programIds Programs to claim rewards for\n */\n function claim(IProduct[] calldata products, uint256[][] calldata programIds)\n external\n nonReentrant\n {\n if (products.length != programIds.length) revert IncentivizerBatchClaimArgumentMismatchError();\n for (uint256 i; i < products.length; i++) {\n _claimProduct(products[i], programIds[i]);\n }\n }\n\n /**\n * @notice Claims all of `msg.sender`'s rewards for `product` programs\n * @dev Internal helper with validation checks\n * @param product Product to claim rewards for\n * @param programIds Programs to claim rewards for\n */\n function _claimProduct(IProduct product, uint256[] memory programIds)\n private\n isProduct(product)\n notPaused\n settleForAccount(msg.sender, product)\n {\n for (uint256 i; i < programIds.length; i++) {\n _claimProgram(product, programIds[i]);\n }\n }\n\n /**\n * @notice Claims all of `msg.sender`'s rewards for `programId` on `product`\n * @dev Internal helper with validation checks\n * @param product Product to claim rewards for\n * @param programId Program to claim rewards for\n */\n function _claimProgram(IProduct product, uint256 programId)\n private\n isProgram(product, programId)\n {\n ProductManager storage productManager = _products[product];\n UFixed18 claimAmount = productManager.claim(msg.sender, programId);\n productManager.token(programId).push(msg.sender, claimAmount);\n emit Claim(product, msg.sender, programId, claimAmount);\n }\n\n /**\n * @notice Claims all `tokens` fees to the protocol treasury\n * @param tokens Tokens to claim fees for\n */\n function claimFee(Token18[] calldata tokens) external notPaused {\n for(uint256 i; i < tokens.length; i++) {\n Token18 token = tokens[i];\n UFixed18 amount = fees[token];\n\n fees[token] = UFixed18Lib.ZERO;\n token.push(controller().treasury(), amount);\n\n emit FeeClaim(token, amount);\n }\n }\n\n /**\n * @notice Returns the quantity of active programs for a given product\n * @param product Product to check for\n * @return Number of active programs\n */\n function active(IProduct product) public view returns (uint256) {\n return _products[product].active();\n }\n\n /**\n * @notice Returns the quantity of programs for a given product\n * @param product Product to check for\n * @return Number of programs (inactive or active)\n */\n function count(IProduct product) external view returns (uint256) {\n return _products[product].programInfos.length;\n }\n\n /**\n * @notice Returns program info for program `programId`\n * @param product Product to return for\n * @param programId Program to return for\n * @return Program info\n */\n function programInfos(IProduct product, uint256 programId) external view returns (ProgramInfo memory) {\n return _products[product].programInfos[programId];\n }\n\n /**\n * @notice Returns `account`'s total unclaimed rewards for a specific program\n * @param product Product to return for\n * @param account Account to return for\n * @param programId Program to return for\n * @return `account`'s total unclaimed rewards for `programId`\n */\n function unclaimed(IProduct product, address account, uint256 programId) external view returns (UFixed18) {\n return _products[product].unclaimed(account, programId);\n }\n\n /**\n * @notice Returns available rewards for a specific program\n * @param product Product to return for\n * @param programId Program to return for\n * @return Available rewards for `programId`\n */\n function available(IProduct product, uint256 programId) external view returns (UFixed18) {\n return _products[product].programs[programId].available;\n }\n\n /**\n * @notice Returns the version started for a specific program\n * @param product Product to return for\n * @param programId Program to return for\n * @return The version started for `programId`\n */\n function versionStarted(IProduct product, uint256 programId) external view returns (uint256) {\n return _products[product].programs[programId].versionStarted;\n }\n\n /**\n * @notice Returns the version completed for a specific program\n * @param product Product to return for\n * @param programId Program to return for\n * @return The version completed for `programId`\n */\n function versionComplete(IProduct product, uint256 programId) external view returns (uint256) {\n return _products[product].programs[programId].versionComplete;\n }\n\n /**\n * @notice Returns the owner of a specific program\n * @param product Product to return for\n * @param programId Program to return for\n * @return The owner of `programId`\n */\n function owner(IProduct product, uint256 programId) public view returns (address) {\n return controller().owner(_products[product].programInfos[programId].coordinatorId);\n }\n\n /**\n * @notice Returns the treasury of a specific program\n * @param product Product to return for\n * @param programId Program to return for\n * @return The treasury of `programId`\n */\n function treasury(IProduct product, uint256 programId) public view returns (address) {\n return controller().treasury(_products[product].programInfos[programId].coordinatorId);\n }\n\n /// @dev Helper to fully settle an account's state\n modifier settleForAccount(address account, IProduct product) {\n product.settleAccount(account);\n\n _;\n }\n\n /// @dev Only allow the owner of `programId` to call\n modifier onlyProgramOwner(IProduct product, uint256 programId) {\n if (msg.sender != owner(product, programId)) revert IncentivizerNotProgramOwnerError(product, programId);\n\n _;\n }\n\n /// @dev Only allow a valid `programId`\n modifier isProgram(IProduct product, uint256 programId) {\n if (!_products[product].valid(programId)) revert IncentivizerInvalidProgramError(product, programId);\n\n _;\n }\n}\n" - }, - "contracts/incentivizer/types/ProductManager.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport \"./Program.sol\";\n\n/// @dev ProductManager type\nstruct ProductManager {\n /// @dev Static program state\n ProgramInfo[] programInfos;\n\n /// @dev Dynamic program state\n mapping(uint256 => Program) programs;\n\n /// @dev Mapping of all active programs for each product\n EnumerableSet.UintSet activePrograms;\n\n /// @dev Mapping of all active programs for each user\n mapping(address => EnumerableSet.UintSet) activeProgramsFor;\n\n /// @dev Mapping of the next program to watch for for each user\n mapping(address => uint256) nextProgramFor;\n}\nusing ProductManagerLib for ProductManager global;\n\n/**\n * @title ProductManagerLib\n * @notice Library that manages each product's incentivization state and logic.\n */\nlibrary ProductManagerLib {\n using EnumerableSet for EnumerableSet.UintSet;\n\n /// @dev Result data for a sync event\n struct SyncResult {\n /// @dev The programId that was updated\n uint256 programId;\n\n /// @dev If non-zero, the new versionStart value of the program\n uint256 versionStarted;\n\n /// @dev If non-zero, the new versionComplete value of the program\n uint256 versionComplete;\n\n /// @dev If non-zero, the amount to refund due to completion\n UFixed18 refundAmount;\n }\n\n /**\n * @notice Registers a new program on this product\n * @param self The Product manager to operate on\n * @param programInfo The static program info\n * @return programId The new program's ID\n */\n function register(\n ProductManager storage self,\n ProgramInfo memory programInfo\n ) internal returns (uint256 programId) {\n programId = self.programInfos.length;\n self.programInfos.push(programInfo);\n self.programs[programId].initialize(programInfo);\n self.activePrograms.add(programId);\n }\n\n /**\n * @notice Syncs this product with the latest data\n * @param self The Program manager to operate on\n * @param product This Product\n * @param currentOracleVersion The preloaded current oracle version\n */\n function sync(\n ProductManager storage self,\n IProduct product,\n IOracleProvider.OracleVersion memory currentOracleVersion\n ) internal returns (SyncResult[] memory results) {\n\n uint256[] memory activeProgramIds = self.activePrograms.values();\n results = new SyncResult[](activeProgramIds.length);\n\n for (uint256 i; i < activeProgramIds.length; i++) {\n // Load program\n uint256 programId = activeProgramIds[i];\n ProgramInfo memory programInfo = self.programInfos[programId];\n Program storage program = self.programs[programId];\n\n // If timestamp-started, grab current version (first version after start)\n uint256 versionStarted;\n if (program.versionStarted == 0 && programInfo.isStarted(currentOracleVersion.timestamp)) {\n versionStarted = _start(self, programId, currentOracleVersion);\n }\n\n // If timestamp-completed, grab previous version (last version before completion)\n uint256 versionComplete;\n UFixed18 refundAmount;\n if (program.versionComplete == 0 && programInfo.isComplete(currentOracleVersion.timestamp)) {\n (versionComplete, refundAmount) = _complete(self, product, programId);\n }\n\n // Save result\n results[i] = SyncResult(programId, versionStarted, versionComplete, refundAmount);\n }\n }\n\n /**\n * @notice Syncs an account for this product with the latest data\n * @dev Assumes that sync() has already been called as part of the transaction flow\n * @param self The Program manager to operate on\n * @param product This Product\n * @param account The account to sync\n * @param currentOracleVersion The preloaded current oracle version\n */\n function syncAccount(\n ProductManager storage self,\n IProduct product,\n address account,\n IOracleProvider.OracleVersion memory currentOracleVersion\n ) internal {\n\n // Add any unseen programs\n uint256 fromProgramId = self.nextProgramFor[account];\n uint256 toProgramId = self.programInfos.length;\n for (uint256 programId = fromProgramId; programId < toProgramId; programId++) {\n self.activeProgramsFor[account].add(programId);\n }\n self.nextProgramFor[account] = toProgramId;\n\n // Settle programs\n uint256[] memory activeProgramIds = self.activeProgramsFor[account].values();\n for (uint256 i; i < activeProgramIds.length; i++) {\n uint256 programId = activeProgramIds[i];\n Program storage program = self.programs[programId];\n program.settle(product, self.programInfos[programId], account, currentOracleVersion);\n if (!self.activePrograms.contains(programId) && currentOracleVersion.version >= program.versionComplete) {\n self.activeProgramsFor[account].remove(programId);\n }\n }\n }\n\n /**\n * @notice Returns the quantity of active programs for this product\n * @param self The Program manager to operate on\n * @return The quantity of active programs\n */\n function active(ProductManager storage self) internal view returns (uint256) {\n return self.activePrograms.length();\n }\n\n /**\n * @notice Forces the specified program to complete if it hasn't already\n * @param self The Program manager to operate on\n * @param product The Product to operate on\n * @param programId The Program to complete\n * @return result The sync result data from completion\n */\n function complete(\n ProductManager storage self,\n IProduct product,\n uint256 programId\n ) internal returns (SyncResult memory result) {\n Program storage program = self.programs[programId];\n\n // If not started, start first\n if (program.versionStarted == 0) {\n result.versionStarted = _start(self, programId, product.currentVersion());\n }\n\n // If not completed already, complete\n if (program.versionComplete == 0) {\n (result.versionComplete, result.refundAmount) = _complete(self, product, programId);\n }\n }\n\n /**\n * @notice Starts the program\n * @dev Rewards do not start accruing until the program has started\n * Internal helper, does not prevent incorrectly-timed starting\n * @param self The Program manager to operate on\n * @param programId The Program to start\n * @param currentOracleVersion The effective starting oracle version\n * @return versionStarted The version that the program started\n */\n function _start(\n ProductManager storage self,\n uint256 programId,\n IOracleProvider.OracleVersion memory currentOracleVersion\n ) internal returns (uint256 versionStarted) {\n versionStarted = currentOracleVersion.version;\n self.programs[programId].start(currentOracleVersion.version);\n }\n\n /**\n * @notice Completes the program\n * @dev Completion stops rewards from accruing\n * Internal helper, does not prevent incorrectly-timed completion\n * @param self The Program manager to operate on\n * @param product The Product to operate on\n * @param programId The Program to complete\n * @return versionComplete The version that the program complete\n * @return refundAmount The refunded token amount\n */\n function _complete(\n ProductManager storage self,\n IProduct product,\n uint256 programId\n ) internal returns (uint256 versionComplete, UFixed18 refundAmount) {\n (versionComplete, refundAmount) = self.programs[programId].complete(product, self.programInfos[programId]);\n self.activePrograms.remove(programId);\n }\n\n /**\n * @notice Claims all of `account`'s rewards for a specific program\n * @param self The Program manager to operate on\n * @param account Account to claim rewards for\n * @param programId Program to claim rewards for\n * @return Amount claimed\n */\n function claim(ProductManager storage self, address account, uint256 programId) internal returns (UFixed18) {\n return self.programs[programId].claim(account);\n }\n\n /**\n * @notice Returns the total amount of unclaimed rewards for account `account`\n * @param self The Program manager to operate on\n * @param account The account to check for\n * @param programId The Program to check for\n * @return Total amount of unclaimed rewards for account\n */\n function unclaimed(ProductManager storage self, address account, uint256 programId) internal view returns (UFixed18) {\n if (!valid(self, programId)) return (UFixed18Lib.ZERO);\n return self.programs[programId].settled[account];\n }\n\n /**\n * @notice Returns the token denominatino of the program's rewards\n * @param self The Program manager to operate on\n * @param programId The Program to check for\n * @return The token for the program\n */\n function token(ProductManager storage self, uint256 programId) internal view returns (Token18) {\n return self.programInfos[programId].token;\n }\n\n /**\n * @notice Returns whether the supplied programId is valid\n * @param self The Program manager to operate on\n * @param programId The Program to check for\n * @return Whether the supplied programId is valid\n */\n function valid(ProductManager storage self, uint256 programId) internal view returns (bool) {\n return programId < self.programInfos.length;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/structs/EnumerableSet.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/structs/EnumerableSet.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping(bytes32 => uint256) _indexes;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (lastIndex != toDeleteIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._values[toDeleteIndex] = lastValue;\n // Update the index for the moved value\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the index for the deleted slot\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._indexes[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n return _values(set._inner);\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n assembly {\n result := store\n }\n\n return result;\n }\n}\n" - }, - "contracts/incentivizer/types/Program.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../../interfaces/types/ProgramInfo.sol\";\n\n/// @dev Program type\nstruct Program {\n /// @dev Mapping of latest rewards settled for each account\n mapping(address => UFixed18) settled;\n\n /// @dev Total amount of rewards yet to be claimed\n UFixed18 available;\n\n /// @dev Oracle version that the program started, 0 when hasn't started\n uint256 versionStarted;\n\n /// @dev Oracle version that the program completed, 0 is still ongoing\n uint256 versionComplete;\n}\nusing ProgramLib for Program global;\n\n/**\n * @title ProgramLib\n * @notice Library that manages all of the mutable state for a single incentivization program.\n */\nlibrary ProgramLib {\n /**\n * @notice Initializes the program state\n * @param self The Program to operate on\n * @param programInfo Static program information\n */\n function initialize(Program storage self, ProgramInfo memory programInfo) internal {\n self.available = programInfo.amount.sum();\n }\n\n /**\n * @notice Starts the program\n * @dev Rewards do not start accruing until the program has started accruing\n * Does not stop double-starting\n * @param self The Program to operate on\n * @param oracleVersion The effective starting oracle version\n */\n function start(Program storage self, uint256 oracleVersion) internal {\n self.versionStarted = oracleVersion;\n }\n\n /**\n * @notice Completes the program\n * @dev Completion stops rewards from accruing\n * Does not prevent double-completion\n * @param self The Program to operate on\n * @param product The Product to operate on\n * @param programInfo Static program information\n * @return versionComplete The version that the program completed on\n * @return refundAmount The refund amount from the program\n */\n function complete(\n Program storage self,\n IProduct product,\n ProgramInfo memory programInfo\n ) internal returns (uint256 versionComplete, UFixed18 refundAmount) {\n uint256 versionStarted = self.versionStarted;\n versionComplete = Math.max(versionStarted, product.latestVersion());\n self.versionComplete = versionComplete;\n\n IOracleProvider.OracleVersion memory fromOracleVersion = product.atVersion(versionStarted);\n IOracleProvider.OracleVersion memory toOracleVersion = product.atVersion(versionComplete);\n\n uint256 inactiveDuration = programInfo.duration - (toOracleVersion.timestamp - fromOracleVersion.timestamp);\n refundAmount = programInfo.amount.sum().muldiv(inactiveDuration, programInfo.duration);\n self.available = self.available.sub(refundAmount);\n }\n\n /**\n * @notice Settles unclaimed rewards for account `account`\n * @param self The Program to operate on\n * @param product The Product to operate on\n * @param programInfo Static program information\n * @param account The account to settle for\n * @param currentOracleVersion The preloaded current oracle version\n */\n function settle(\n Program storage self,\n IProduct product,\n ProgramInfo memory programInfo,\n address account,\n IOracleProvider.OracleVersion memory currentOracleVersion\n ) internal {\n UFixed18 unsettledAmount = _unsettled(self, product, programInfo, account, currentOracleVersion);\n self.settled[account] = self.settled[account].add(unsettledAmount);\n self.available = self.available.sub(unsettledAmount);\n }\n\n /**\n * @notice Claims settled rewards for account `account`\n * @param self The Program to operate on\n * @param account The account to claim for\n */\n function claim(Program storage self, address account) internal returns (UFixed18 claimedAmount) {\n claimedAmount = self.settled[account];\n self.settled[account] = UFixed18Lib.ZERO;\n }\n\n /**\n * @notice Returns the unsettled amount of unclaimed rewards for account `account`\n * @dev Clears when a program is closed\n * Assumes that position is unchanged since last settlement, must be settled prior to user position update\n * @param self The Program to operate on\n * @param product The Product to operate on\n * @param programInfo Static program information\n * @param account The account to claim for\n * @param currentOracleVersion Current oracle version\n * @return amount Amount of unsettled rewards for account\n */\n function _unsettled(\n Program storage self,\n IProduct product,\n ProgramInfo memory programInfo,\n address account,\n IOracleProvider.OracleVersion memory currentOracleVersion\n ) private view returns (UFixed18 amount) {\n // program stage overview\n //\n // V = latest user settle version, V' = current user settle version\n // S = versionStarted, E = versionEnded\n //\n // (1) V V' S E program not yet started\n // (2) V S V' E use versionStarted -> V' for userShareDelta\n // (3) S V V' E use V -> V' for userShareDelta\n // (4) S V E V' use V -> versionComplete for userShareDelta\n // (5) S E V V' program already completed\n // (6) V S E V' use versionStarted -> versionComplete for userShareDelta\n //\n // NOTE: V == S and V' == E both default to the inner case\n\n (uint256 _versionStarted, uint256 _versionComplete) = (\n self.versionStarted == 0 ? currentOracleVersion.version : self.versionStarted, // start must be no earlier than current version\n self.versionComplete == 0 ? type(uint256).max : self.versionComplete // we don't know when completion occurs\n );\n\n // accruing must start between self.versionStarted and self.versionComplete\n uint256 fromVersion = Math.min(_versionComplete, Math.max(_versionStarted, product.latestVersion(account)));\n // accruing must complete between self.versionStarted and self.versionComplete, we know self.versionStarted must be no earlier than current version\n uint256 toVersion = Math.min(_versionComplete, currentOracleVersion.version);\n\n Accumulator memory globalShareDelta = product.shareAtVersion(toVersion).sub(product.shareAtVersion(fromVersion));\n Accumulator memory computedUserShareDelta = product.position(account).mul(globalShareDelta);\n amount = UFixed18Lib.from(programInfo.amountPerShare().mul(computedUserShareDelta).sum());\n }\n}\n" - }, - "@equilibria/emptyset-batcher/batcher/Batcher.sol": { - "content": "//SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"@equilibria/root/token/types/Token6.sol\";\nimport \"@equilibria/root/control/unstructured/UOwnable.sol\";\nimport \"../interfaces/IBatcher.sol\";\n\nabstract contract Batcher is IBatcher, UOwnable {\n using UFixed18Lib for UFixed18;\n using Token18Lib for Token18;\n using Token6Lib for Token6;\n\n IEmptySetReserve public immutable RESERVE;\n Token18 public immutable DSU;\n Token6 public immutable USDC;\n\n constructor(IEmptySetReserve reserve, Token18 dsu, Token6 usdc) {\n RESERVE = reserve;\n DSU = dsu;\n USDC = usdc;\n\n DSU.approve(address(RESERVE));\n USDC.approve(address(RESERVE));\n\n __UOwnable__initialize();\n }\n\n function totalBalance() public view returns (UFixed18) {\n return DSU.balanceOf().add(USDC.balanceOf());\n }\n\n function wrap(UFixed18 amount, address to) external {\n _wrap(amount, to);\n emit Wrap(to, amount);\n }\n\n function _wrap(UFixed18 amount, address to) virtual internal {\n USDC.pull(msg.sender, amount, true);\n DSU.push(to, amount);\n }\n\n function unwrap(UFixed18 amount, address to) external {\n _unwrap(amount, to);\n emit Unwrap(to, amount);\n }\n\n function _unwrap(UFixed18 amount, address to) virtual internal {\n DSU.pull(msg.sender, amount);\n USDC.push(to, amount);\n }\n\n function rebalance() external {\n (UFixed18 usdcBalance, UFixed18 dsuBalance) = (USDC.balanceOf(), DSU.balanceOf());\n\n _rebalance(USDC.balanceOf(), DSU.balanceOf());\n\n (UFixed18 oldBalance, UFixed18 newBalance) = (usdcBalance.add(dsuBalance), totalBalance());\n if (!oldBalance.eq(newBalance)) revert BatcherBalanceMismatchError(oldBalance, newBalance);\n\n emit Rebalance(usdcBalance, UFixed18Lib.ZERO);\n }\n\n function _rebalance(UFixed18 usdcBalance, UFixed18 dsuBalance) virtual internal;\n\n function close() external onlyOwner {\n UFixed18 usdcBalance = USDC.balanceOf();\n if (!usdcBalance.isZero()) RESERVE.mint(usdcBalance);\n\n UFixed18 dsuBalance = DSU.balanceOf();\n UFixed18 repayAmount = UFixed18Lib.min(RESERVE.debt(address(this)), dsuBalance);\n UFixed18 returnAmount = dsuBalance.sub(repayAmount);\n\n RESERVE.repay(address(this), repayAmount);\n if (!returnAmount.isZero()) DSU.push(address(RESERVE), dsuBalance.sub(repayAmount));\n\n emit Close(dsuBalance);\n }\n}\n\ninterface IEmptySetReserve {\n function debt(address borrower) external view returns (UFixed18);\n function repay(address borrower, UFixed18 amount) external;\n function mint(UFixed18 amount) external;\n function redeem(UFixed18 amount) external;\n}\n" - }, - "@equilibria/root/token/types/Token6.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"../../number/types/UFixed18.sol\";\n\n/// @dev Token6\ntype Token6 is address;\nusing Token6Lib for Token6 global;\ntype Token6Storage is bytes32;\nusing Token6StorageLib for Token6Storage global;\n\n/**\n * @title Token6Lib\n * @notice Library to manage 6-decimal ERC20s that is compliant with the fixed-decimal types.\n * @dev Automatically converts from Base-6 token amounts to Base-18 UFixed18 amounts, with optional rounding\n */\nlibrary Token6Lib {\n using SafeERC20 for IERC20;\n\n Token6 public constant ZERO = Token6.wrap(address(0));\n\n uint256 private constant OFFSET = 1e12;\n\n /**\n * @notice Returns whether a token is the zero address\n * @param self Token to check for\n * @return Whether the token is the zero address\n */\n function isZero(Token6 self) internal pure returns (bool) {\n return Token6.unwrap(self) == Token6.unwrap(ZERO);\n }\n\n /**\n * @notice Returns whether the two tokens are equal\n * @param a First token to compare\n * @param b Second token to compare\n * @return Whether the two tokens are equal\n */\n function eq(Token6 a, Token6 b) internal pure returns (bool) {\n return Token6.unwrap(a) == Token6.unwrap(b);\n }\n\n /**\n * @notice Approves `grantee` to spend infinite tokens from the caller\n * @param self Token to transfer\n * @param grantee Address to allow spending\n */\n function approve(Token6 self, address grantee) internal {\n IERC20(Token6.unwrap(self)).safeApprove(grantee, type(uint256).max);\n }\n\n /**\n * @notice Approves `grantee` to spend `amount` tokens from the caller\n * @dev There are important race conditions to be aware of when using this function\n with values other than 0. This will revert if moving from non-zero to non-zero amounts\n See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/a55b7d13722e7ce850b626da2313f3e66ca1d101/contracts/token/ERC20/IERC20.sol#L57\n * @param self Token to transfer\n * @param grantee Address to allow spending\n * @param amount Amount of tokens to approve to spend\n */\n function approve(Token6 self, address grantee, UFixed18 amount) internal {\n IERC20(Token6.unwrap(self)).safeApprove(grantee, toTokenAmount(amount, false));\n }\n\n /**\n * @notice Approves `grantee` to spend `amount` tokens from the caller\n * @dev There are important race conditions to be aware of when using this function\n with values other than 0. This will revert if moving from non-zero to non-zero amounts\n See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/a55b7d13722e7ce850b626da2313f3e66ca1d101/contracts/token/ERC20/IERC20.sol#L57\n * @param self Token to transfer\n * @param grantee Address to allow spending\n * @param amount Amount of tokens to approve to spend\n * @param roundUp Whether to round decimal token amount up to the next unit\n */\n function approve(Token6 self, address grantee, UFixed18 amount, bool roundUp) internal {\n IERC20(Token6.unwrap(self)).safeApprove(grantee, toTokenAmount(amount, roundUp));\n }\n\n /**\n * @notice Transfers all held tokens from the caller to the `recipient`\n * @param self Token to transfer\n * @param recipient Address to receive the tokens\n */\n function push(Token6 self, address recipient) internal {\n push(self, recipient, balanceOf(self, address(this)));\n }\n\n /**\n * @notice Transfers `amount` tokens from the caller to the `recipient`\n * @param self Token to transfer\n * @param recipient Address to transfer tokens to\n * @param amount Amount of tokens to transfer\n */\n function push(Token6 self, address recipient, UFixed18 amount) internal {\n IERC20(Token6.unwrap(self)).safeTransfer(recipient, toTokenAmount(amount, false));\n }\n\n /**\n * @notice Transfers `amount` tokens from the caller to the `recipient`\n * @param self Token to transfer\n * @param recipient Address to transfer tokens to\n * @param amount Amount of tokens to transfer\n * @param roundUp Whether to round decimal token amount up to the next unit\n */\n function push(Token6 self, address recipient, UFixed18 amount, bool roundUp) internal {\n IERC20(Token6.unwrap(self)).safeTransfer(recipient, toTokenAmount(amount, roundUp));\n }\n\n /**\n * @notice Transfers `amount` tokens from the `benefactor` to the caller\n * @dev Reverts if trying to pull Ether\n * @param self Token to transfer\n * @param benefactor Address to transfer tokens from\n * @param amount Amount of tokens to transfer\n */\n function pull(Token6 self, address benefactor, UFixed18 amount) internal {\n IERC20(Token6.unwrap(self)).safeTransferFrom(benefactor, address(this), toTokenAmount(amount, false));\n }\n\n /**\n * @notice Transfers `amount` tokens from the `benefactor` to the caller\n * @dev Reverts if trying to pull Ether\n * @param self Token to transfer\n * @param benefactor Address to transfer tokens from\n * @param amount Amount of tokens to transfer\n * @param roundUp Whether to round decimal token amount up to the next unit\n */\n function pull(Token6 self, address benefactor, UFixed18 amount, bool roundUp) internal {\n IERC20(Token6.unwrap(self)).safeTransferFrom(benefactor, address(this), toTokenAmount(amount, roundUp));\n }\n\n /**\n * @notice Transfers `amount` tokens from the `benefactor` to `recipient`\n * @dev Reverts if trying to pull Ether\n * @param self Token to transfer\n * @param benefactor Address to transfer tokens from\n * @param recipient Address to transfer tokens to\n * @param amount Amount of tokens to transfer\n */\n function pullTo(Token6 self, address benefactor, address recipient, UFixed18 amount) internal {\n IERC20(Token6.unwrap(self)).safeTransferFrom(benefactor, recipient, toTokenAmount(amount, false));\n }\n\n /**\n * @notice Transfers `amount` tokens from the `benefactor` to `recipient`\n * @dev Reverts if trying to pull Ether\n * @param self Token to transfer\n * @param benefactor Address to transfer tokens from\n * @param recipient Address to transfer tokens to\n * @param amount Amount of tokens to transfer\n * @param roundUp Whether to round decimal token amount up to the next unit\n */\n function pullTo(Token6 self, address benefactor, address recipient, UFixed18 amount, bool roundUp) internal {\n IERC20(Token6.unwrap(self)).safeTransferFrom(benefactor, recipient, toTokenAmount(amount, roundUp));\n }\n\n /**\n * @notice Returns the name of the token\n * @param self Token to check for\n * @return Token name\n */\n function name(Token6 self) internal view returns (string memory) {\n return IERC20Metadata(Token6.unwrap(self)).name();\n }\n\n /**\n * @notice Returns the symbol of the token\n * @param self Token to check for\n * @return Token symbol\n */\n function symbol(Token6 self) internal view returns (string memory) {\n return IERC20Metadata(Token6.unwrap(self)).symbol();\n }\n\n /**\n * @notice Returns the `self` token balance of the caller\n * @param self Token to check for\n * @return Token balance of the caller\n */\n function balanceOf(Token6 self) internal view returns (UFixed18) {\n return balanceOf(self, address(this));\n }\n\n /**\n * @notice Returns the `self` token balance of `account`\n * @param self Token to check for\n * @param account Account to check\n * @return Token balance of the account\n */\n function balanceOf(Token6 self, address account) internal view returns (UFixed18) {\n return fromTokenAmount(IERC20(Token6.unwrap(self)).balanceOf(account));\n }\n\n /**\n * @notice Converts the unsigned fixed-decimal amount into the token amount according to\n * it's defined decimals\n * @dev Provides the ability to \"round up\" the token amount which is useful in situations where\n * are swapping one token for another and don't want to give away \"free\" units due to rounding\n * errors in the favor of the user.\n * @param amount Amount to convert\n * @param roundUp Whether to round decimal token amount up to the next unit\n * @return Normalized token amount\n */\n function toTokenAmount(UFixed18 amount, bool roundUp) private pure returns (uint256) {\n return roundUp ? Math.ceilDiv(UFixed18.unwrap(amount), OFFSET) : UFixed18.unwrap(amount) / OFFSET;\n }\n\n /**\n * @notice Converts the token amount into the unsigned fixed-decimal amount according to\n * it's defined decimals\n * @param amount Token amount to convert\n * @return Normalized unsigned fixed-decimal amount\n */\n function fromTokenAmount(uint256 amount) private pure returns (UFixed18) {\n return UFixed18.wrap(amount * OFFSET);\n }\n}\n\nlibrary Token6StorageLib {\n function read(Token6Storage self) internal view returns (Token6 value) {\n assembly {\n value := sload(self)\n }\n }\n\n function store(Token6Storage self, Token6 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "@equilibria/root/control/unstructured/UOwnable.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"./UInitializable.sol\";\nimport \"../../storage/UStorage.sol\";\n\n/**\n * @title UOwnable\n * @notice Library to manage the ownership lifecycle of upgradeable contracts.\n * @dev This contract has been extended from the Open Zeppelin library to include an\n * unstructured storage pattern so that it can be safely mixed in with upgradeable\n * contracts without affecting their storage patterns through inheritance.\n */\nabstract contract UOwnable is UInitializable {\n event OwnerUpdated(address indexed newOwner);\n event PendingOwnerUpdated(address indexed newPendingOwner);\n\n error UOwnableNotOwnerError(address sender);\n error UOwnableNotPendingOwnerError(address sender);\n\n /// @dev The owner address\n AddressStorage private constant _owner = AddressStorage.wrap(keccak256(\"equilibria.root.UOwnable.owner\"));\n function owner() public view returns (address) { return _owner.read(); }\n\n /// @dev The pending owner address\n AddressStorage private constant _pendingOwner = AddressStorage.wrap(keccak256(\"equilibria.root.UOwnable.pendingOwner\"));\n function pendingOwner() public view returns (address) { return _pendingOwner.read(); }\n\n /**\n * @notice Initializes the contract setting `msg.sender` as the initial owner\n */\n function __UOwnable__initialize() internal onlyInitializer {\n _updateOwner(msg.sender);\n }\n\n /**\n * @notice Updates the new pending owner\n * @dev Can only be called by the current owner\n * New owner does not take affect until that address calls `acceptOwner()`\n * @param newPendingOwner New pending owner address\n */\n function updatePendingOwner(address newPendingOwner) public onlyOwner {\n _pendingOwner.store(newPendingOwner);\n emit PendingOwnerUpdated(newPendingOwner);\n }\n\n /**\n * @notice Accepts and transfers the ownership of the contract to the pending owner\n * @dev Can only be called by the pending owner to ensure correctness\n */\n function acceptOwner() external {\n if (msg.sender != pendingOwner()) revert UOwnableNotPendingOwnerError(msg.sender);\n\n _updateOwner(pendingOwner());\n updatePendingOwner(address(0));\n }\n\n /**\n * @notice Updates the owner address\n * @param newOwner New owner address\n */\n function _updateOwner(address newOwner) private {\n _owner.store(newOwner);\n emit OwnerUpdated(newOwner);\n }\n\n /// @dev Throws if called by any account other than the owner\n modifier onlyOwner() {\n if (owner() != msg.sender) revert UOwnableNotOwnerError(msg.sender);\n _;\n }\n}\n" - }, - "@equilibria/emptyset-batcher/interfaces/IBatcher.sol": { - "content": "//SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\n\ninterface IBatcher {\n event Wrap(address indexed to, UFixed18 amount);\n event Unwrap(address indexed to, UFixed18 amount);\n event Rebalance(UFixed18 newMinted, UFixed18 newRedeemed);\n event Close(UFixed18 amount);\n\n error BatcherNotImplementedError();\n error BatcherBalanceMismatchError(UFixed18 oldBalance, UFixed18 newBalance);\n\n function totalBalance() external view returns (UFixed18);\n function wrap(UFixed18 amount, address to) external;\n function unwrap(UFixed18 amount, address to) external;\n function rebalance() external;\n}\n" - }, - "contracts/interfaces/IForwarder.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"@equilibria/root/token/types/Token6.sol\";\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/emptyset-batcher/interfaces/IBatcher.sol\";\nimport \"./ICollateral.sol\";\n\ninterface IForwarder {\n error ForwarderNotContractAddressError();\n\n event WrapAndDeposit(address indexed account, IProduct indexed product, UFixed18 amount);\n\n function USDC() external view returns (Token6); // solhint-disable-line func-name-mixedcase\n function DSU() external view returns (Token18); // solhint-disable-line func-name-mixedcase\n function batcher() external view returns (IBatcher);\n function collateral() external view returns (ICollateral);\n function wrapAndDeposit(address account, IProduct product, UFixed18 amount) external;\n}\n" - }, - "contracts/interfaces/IPerennialLens.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"./IProduct.sol\";\nimport \"./ICollateral.sol\";\nimport \"./IController.sol\";\n\ninterface IPerennialLens {\n function controller() external view returns (IController);\n function name(IProduct product) external view returns (string memory);\n function symbol(IProduct product) external view returns (string memory);\n function collateral() external view returns (ICollateral);\n function collateral(address account, IProduct product) external returns (UFixed18);\n function collateral(IProduct product) external returns (UFixed18);\n function shortfall(IProduct product) external returns (UFixed18);\n function maintenance(address account, IProduct product) external returns (UFixed18);\n function liquidatable(address account, IProduct product) external returns (bool);\n function pre(address account, IProduct product) external returns (PrePosition memory);\n function pre(IProduct product) external returns (PrePosition memory);\n function position(address account, IProduct product) external returns (Position memory);\n function position(IProduct product) external returns (Position memory);\n function userPosition(address account, IProduct product) external returns (PrePosition memory, Position memory);\n function globalPosition(IProduct product) external returns (PrePosition memory, Position memory);\n function price(IProduct product) external returns (Fixed18);\n function fees(IProduct product) external returns (UFixed18 protocolFees, UFixed18 productFees);\n function fees(address account, IProduct[] memory products) external returns (UFixed18);\n function openInterest(address account, IProduct product) external returns (Position memory);\n function openInterest(IProduct product) external returns (Position memory);\n function rate(IProduct product) external returns (Fixed18);\n function dailyRate(IProduct product) external returns (Fixed18);\n function maintenanceRequired(\n address account,\n IProduct product,\n UFixed18 positionSize\n ) external returns (UFixed18);\n function unclaimedIncentiveRewards(address account, IProduct product)\n external\n returns (Token18[] memory tokens, UFixed18[] memory amounts);\n function unclaimedIncentiveRewards(\n address account,\n IProduct product,\n uint256[] calldata programIds\n ) external returns (Token18[] memory tokens, UFixed18[] memory amounts);\n}\n" - }, - "contracts/lens/PerennialLens.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../interfaces/IPerennialLens.sol\";\n\n/**\n * @title Lens contract to conveniently pull protocol data\n * @notice All functions should be called using `callStatic`\n */\ncontract PerennialLens is IPerennialLens {\n /**\n * @notice Protocol controller\n * @return Protocol controller\n */\n IController public immutable controller;\n\n /// @param _controller Protocol controller address\n constructor(IController _controller) {\n controller = _controller;\n }\n\n /**\n * @notice Returns the name of the provided `product`\n * @param product Product address\n * @return Name of the product\n */\n function name(IProduct product) external view returns (string memory) {\n return product.name();\n }\n\n /**\n * @notice Returns the symbol of the provided `product`\n * @param product Product address\n * @return Symbol of the product\n */\n function symbol(IProduct product) external view returns (string memory) {\n return product.symbol();\n }\n\n /**\n * @notice Protocol collateral address\n * @return Protocol collateral address\n */\n function collateral() public view returns (ICollateral) {\n return controller.collateral();\n }\n\n /**\n * @notice User collateral amount for product after settle\n * @param account Account address\n * @param product Product address\n * @return User deposited collateral for product\n */\n function collateral(address account, IProduct product) external settleAccount(account, product) returns (UFixed18) {\n return collateral().collateral(account, product);\n }\n\n /**\n * @notice Product total collateral amount after settle\n * @param product Product address\n * @return Total collateral for product\n */\n function collateral(IProduct product) external settle(product) returns (UFixed18) {\n return collateral().collateral(product);\n }\n\n /**\n * @notice Product total shortfall amount after settle\n * @param product Product address\n * @return Total shortfall for product\n */\n function shortfall(IProduct product) external settle(product) returns (UFixed18) {\n return collateral().shortfall(product);\n }\n\n /**\n * @notice User maintenance amount for product after settle\n * @param account Account address\n * @param product Product address\n * @return Maximum of user maintenance, and maintenanceNext\n */\n function maintenance(address account, IProduct product)\n external\n settleAccount(account, product)\n returns (UFixed18)\n {\n return UFixed18Lib.max(product.maintenance(account), product.maintenanceNext(account));\n }\n\n /**\n * @notice User liquidatble status for product after settle\n * @param account Account address\n * @param product Product address\n * @return Whether or not the user's position eligible to be liquidated\n */\n function liquidatable(address account, IProduct product) external settleAccount(account, product) returns (bool) {\n return collateral().liquidatable(account, product);\n }\n\n /**\n * @notice User pre position for product after settle\n * @param account Account address\n * @param product Product address\n * @return User pre-position\n */\n function pre(address account, IProduct product)\n external\n settleAccount(account, product)\n returns (PrePosition memory)\n {\n return product.pre(account);\n }\n\n /**\n * @notice Product pre position after settle\n * @param product Product address\n * @return Product pre-position\n */\n function pre(IProduct product) external settle(product) returns (PrePosition memory) {\n return product.pre();\n }\n\n /**\n * @notice User position for product after settle\n * @param account Account address\n * @param product Product address\n * @return User position\n */\n function position(address account, IProduct product)\n external\n settleAccount(account, product)\n returns (Position memory)\n {\n return product.position(account);\n }\n\n /**\n * @notice Product position after settle\n * @param product Product address\n * @return product position\n */\n function position(IProduct product) external settle(product) returns (Position memory) {\n return _latestPosition(product);\n }\n\n /**\n * @notice User pre-position and position for product after settle\n * @param account Account address\n * @param product Product address\n * @return User pre-position\n * @return User position\n */\n function userPosition(address account, IProduct product)\n external\n settleAccount(account, product)\n returns (PrePosition memory, Position memory)\n {\n return (product.pre(account), product.position(account));\n }\n\n /**\n * @notice Product pre-position and position after settle\n * @param product Product address\n * @return Product pre-position\n * @return Product position\n */\n function globalPosition(IProduct product) external settle(product) returns (PrePosition memory, Position memory) {\n return (product.pre(), _latestPosition(product));\n }\n\n /**\n * @notice Current price of product after settle\n * @param product Product address\n * @return Product latest price\n */\n function price(IProduct product) external settle(product) returns (Fixed18) {\n return _latestVersion(product).price;\n }\n\n /**\n * @notice Fees accumulated by product and protocol treasuries after settle\n * @param product Product address\n * @return protocolFees fees accrued by the protocol\n * @return productFees fees accrued by the product owner\n */\n function fees(IProduct product) external settle(product) returns (UFixed18 protocolFees, UFixed18 productFees) {\n address protocolTreasury = controller.treasury();\n address productTreasury = controller.treasury(product);\n\n protocolFees = collateral().fees(protocolTreasury);\n productFees = collateral().fees(productTreasury);\n }\n\n /**\n * @notice Fees accumulated by treasury after settle\n * @param account Account address\n * @param products Product addresses\n * @return sum of all fees accrued by the account\n */\n function fees(address account, IProduct[] memory products) external returns (UFixed18) {\n for (uint256 i = 0; i < products.length; i++) {\n products[i].settle();\n }\n\n return collateral().fees(account);\n }\n\n /**\n * @notice User's open interest in product after settle\n * @param account Account address\n * @param product Product address\n * @return User's maker or taker position multiplied by latest price after settle\n */\n function openInterest(address account, IProduct product)\n external\n settleAccount(account, product)\n returns (Position memory)\n {\n return product.position(account).mul(_latestVersion(product).price.abs());\n }\n\n /**\n * @notice Product total open interest after settle\n * @param product Product address\n * @return Product maker and taker position multiplied by latest price after settle\n */\n function openInterest(IProduct product) external settle(product) returns (Position memory) {\n return _latestPosition(product).mul(_latestVersion(product).price.abs());\n }\n\n /**\n * @notice Product funding rate after settle\n * @param product Product address\n * @return Product current funding rate\n */\n function rate(IProduct product) external settle(product) returns (Fixed18) {\n Position memory position_ = _latestPosition(product);\n return product.rate(position_);\n }\n\n /**\n * @notice Product funding extrapolated to a daily rate after settle\n * @param product Product address\n * @return Product current funding extrapolated to a daily rate\n */\n function dailyRate(IProduct product) external settle(product) returns (Fixed18) {\n Position memory position_ = _latestPosition(product);\n return product.rate(position_).mul(Fixed18Lib.from(60 * 60 * 24));\n }\n\n /**\n * @notice User's maintenance required for position size in product after settle\n * @param account Account address\n * @param product Product address\n * @param positionSize size of position for maintenance calculation\n * @return Maintenance required for position in product\n */\n function maintenanceRequired(\n address account,\n IProduct product,\n UFixed18 positionSize\n ) external settleAccount(account, product) returns (UFixed18) {\n UFixed18 notional = positionSize.mul(_latestVersion(product).price.abs());\n return notional.mul(product.maintenance());\n }\n\n /**\n * @notice User's unclaimed rewards for all programs for product after settle\n * @param account Account address\n * @param product Product address\n * @return tokens Token addresses of unclaimed incentive rewards for given product\n * @return amounts Token amounts of unclaimed incentive rewards for given product\n */\n function unclaimedIncentiveRewards(address account, IProduct product)\n external\n settleAccount(account, product)\n returns (Token18[] memory tokens, UFixed18[] memory amounts)\n {\n IIncentivizer incentivizer = controller.incentivizer();\n\n uint256 programsLength = incentivizer.count(product);\n tokens = new Token18[](programsLength);\n amounts = new UFixed18[](programsLength);\n for (uint256 i = 0; i < programsLength; i++) {\n ProgramInfo memory programInfo = incentivizer.programInfos(product, i);\n tokens[i] = programInfo.token;\n amounts[i] = incentivizer.unclaimed(product, account, i);\n }\n }\n\n /**\n * @notice User's unclaimed rewards for provided programs for product after settle\n * @param account Account address\n * @param product Product address\n * @param programIds Program IDs to query\n * @return tokens Token addresses of unclaimed incentive rewards for given program IDs\n * @return amounts Token amounts of unclaimed incentive rewards for given program IDs\n */\n function unclaimedIncentiveRewards(\n address account,\n IProduct product,\n uint256[] calldata programIds\n ) external settleAccount(account, product) returns (Token18[] memory tokens, UFixed18[] memory amounts) {\n IIncentivizer incentivizer = controller.incentivizer();\n tokens = new Token18[](programIds.length);\n amounts = new UFixed18[](programIds.length);\n for (uint256 i = 0; i < programIds.length; i++) {\n ProgramInfo memory programInfo = incentivizer.programInfos(product, programIds[i]);\n tokens[i] = programInfo.token;\n amounts[i] = incentivizer.unclaimed(product, account, programIds[i]);\n }\n }\n\n // TODO: all data for Product, all data for User, batching\n\n /**\n * @notice Returns the Product's latest position\n * @dev Private function, does not call settle itself\n * @param product Product address\n * @return Latest position for the product\n */\n function _latestPosition(IProduct product) private view returns (Position memory) {\n return product.positionAtVersion(product.latestVersion());\n }\n\n /**\n * @notice Returns the Product's latest version\n * @dev Private function, does not call settle itself\n * @param product Product address\n * @return Latest version for the product\n */\n function _latestVersion(IProduct product) private view returns (IOracleProvider.OracleVersion memory) {\n return product.currentVersion();\n }\n\n /// @dev Settles the product\n modifier settle(IProduct product) {\n product.settle();\n _;\n }\n\n /// @dev Settles the product. product.settleAccount also settles the product\n modifier settleAccount(address account, IProduct product) {\n product.settleAccount(account);\n _;\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/ERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.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 * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\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 ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => 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 * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\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 override 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 override 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 value {ERC20} uses, unless this function is\n * 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 override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override 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 `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` 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 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\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 `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `sender` to `recipient`.\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 * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n }\n _balances[to] += amount;\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` 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 function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n" - }, - "contracts/test/TestnetUSDC.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol\";\n\ncontract TestnetUSDC is ERC20, ERC20Burnable {\n // solhint-disable-next-line no-empty-blocks\n constructor() ERC20(\"USD Coin\", \"USDC\") { }\n\n function decimals() override public pure returns (uint8) {\n return 6;\n }\n\n function mint(address account, uint256 amount) external {\n _mint(account, amount);\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Burnable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20.sol\";\nimport \"../../../utils/Context.sol\";\n\n/**\n * @dev Extension of {ERC20} that allows token holders to destroy both their own\n * tokens and those that they have an allowance for, in a way that can be\n * recognized off-chain (via event analysis).\n */\nabstract contract ERC20Burnable is Context, ERC20 {\n /**\n * @dev Destroys `amount` tokens from the caller.\n *\n * See {ERC20-_burn}.\n */\n function burn(uint256 amount) public virtual {\n _burn(_msgSender(), amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, deducting from the caller's\n * allowance.\n *\n * See {ERC20-_burn} and {ERC20-allowance}.\n *\n * Requirements:\n *\n * - the caller must have allowance for ``accounts``'s tokens of at least\n * `amount`.\n */\n function burnFrom(address account, uint256 amount) public virtual {\n _spendAllowance(account, _msgSender(), amount);\n _burn(account, amount);\n }\n}\n" - }, - "contracts/test/TestnetDSU.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol\";\n\ncontract TestnetDSU is ERC20, ERC20Burnable {\n uint256 private constant LIMIT = 1_000_000e18;\n\n error TestnetDSUOverLimitError();\n\n // solhint-disable-next-line no-empty-blocks\n constructor() ERC20(\"Digital Standard Unit\", \"DSU\") { }\n\n function mint(address account, uint256 amount) external {\n if (amount > LIMIT) revert TestnetDSUOverLimitError();\n\n _mint(account, amount);\n }\n}\n" - }, - "@openzeppelin/contracts/security/Pausable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract Pausable is Context {\n /**\n * @dev Emitted when the pause is triggered by `account`.\n */\n event Paused(address account);\n\n /**\n * @dev Emitted when the pause is lifted by `account`.\n */\n event Unpaused(address account);\n\n bool private _paused;\n\n /**\n * @dev Initializes the contract in unpaused state.\n */\n constructor() {\n _paused = false;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n require(!paused(), \"Pausable: paused\");\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n require(paused(), \"Pausable: not paused\");\n _;\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/ERC20Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20.sol\";\nimport \"../../../security/Pausable.sol\";\n\n/**\n * @dev ERC20 token with pausable token transfers, minting and burning.\n *\n * Useful for scenarios such as preventing trades until the end of an evaluation\n * period, or having an emergency switch for freezing all token transfers in the\n * event of a large bug.\n */\nabstract contract ERC20Pausable is ERC20, Pausable {\n /**\n * @dev See {ERC20-_beforeTokenTransfer}.\n *\n * Requirements:\n *\n * - the contract must not be paused.\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual override {\n super._beforeTokenTransfer(from, to, amount);\n\n require(!paused(), \"ERC20Pausable: token transfer while paused\");\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/presets/ERC20PresetMinterPauser.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20.sol\";\nimport \"../extensions/ERC20Burnable.sol\";\nimport \"../extensions/ERC20Pausable.sol\";\nimport \"../../../access/AccessControlEnumerable.sol\";\nimport \"../../../utils/Context.sol\";\n\n/**\n * @dev {ERC20} token, including:\n *\n * - ability for holders to burn (destroy) their tokens\n * - a minter role that allows for token minting (creation)\n * - a pauser role that allows to stop all token transfers\n *\n * This contract uses {AccessControl} to lock permissioned functions using the\n * different roles - head to its documentation for details.\n *\n * The account that deploys the contract will be granted the minter and pauser\n * roles, as well as the default admin role, which will let it grant both minter\n * and pauser roles to other accounts.\n *\n * _Deprecated in favor of https://wizard.openzeppelin.com/[Contracts Wizard]._\n */\ncontract ERC20PresetMinterPauser is Context, AccessControlEnumerable, ERC20Burnable, ERC20Pausable {\n bytes32 public constant MINTER_ROLE = keccak256(\"MINTER_ROLE\");\n bytes32 public constant PAUSER_ROLE = keccak256(\"PAUSER_ROLE\");\n\n /**\n * @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE` and `PAUSER_ROLE` to the\n * account that deploys the contract.\n *\n * See {ERC20-constructor}.\n */\n constructor(string memory name, string memory symbol) ERC20(name, symbol) {\n _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());\n\n _setupRole(MINTER_ROLE, _msgSender());\n _setupRole(PAUSER_ROLE, _msgSender());\n }\n\n /**\n * @dev Creates `amount` new tokens for `to`.\n *\n * See {ERC20-_mint}.\n *\n * Requirements:\n *\n * - the caller must have the `MINTER_ROLE`.\n */\n function mint(address to, uint256 amount) public virtual {\n require(hasRole(MINTER_ROLE, _msgSender()), \"ERC20PresetMinterPauser: must have minter role to mint\");\n _mint(to, amount);\n }\n\n /**\n * @dev Pauses all token transfers.\n *\n * See {ERC20Pausable} and {Pausable-_pause}.\n *\n * Requirements:\n *\n * - the caller must have the `PAUSER_ROLE`.\n */\n function pause() public virtual {\n require(hasRole(PAUSER_ROLE, _msgSender()), \"ERC20PresetMinterPauser: must have pauser role to pause\");\n _pause();\n }\n\n /**\n * @dev Unpauses all token transfers.\n *\n * See {ERC20Pausable} and {Pausable-_unpause}.\n *\n * Requirements:\n *\n * - the caller must have the `PAUSER_ROLE`.\n */\n function unpause() public virtual {\n require(hasRole(PAUSER_ROLE, _msgSender()), \"ERC20PresetMinterPauser: must have pauser role to unpause\");\n _unpause();\n }\n\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual override(ERC20, ERC20Pausable) {\n super._beforeTokenTransfer(from, to, amount);\n }\n}\n" - }, - "@openzeppelin/contracts/access/AccessControlEnumerable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControlEnumerable.sol\";\nimport \"./AccessControl.sol\";\nimport \"../utils/structs/EnumerableSet.sol\";\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override {\n super._grantRole(role, account);\n _roleMembers[role].add(account);\n }\n\n /**\n * @dev Overload {_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override {\n super._revokeRole(role, account);\n _roleMembers[role].remove(account);\n }\n}\n" - }, - "@openzeppelin/contracts/access/IAccessControlEnumerable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n" - }, - "@openzeppelin/contracts/access/AccessControl.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\nimport \"../utils/Context.sol\";\nimport \"../utils/Strings.sol\";\nimport \"../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address => bool) members;\n bytes32 adminRole;\n }\n\n mapping(bytes32 => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with a standardized message including the required role.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n *\n * _Available since v4.1._\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n return _roles[role].members[account];\n }\n\n /**\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\n * Overriding this function changes the behavior of the {onlyRole} modifier.\n *\n * Format of the revert message is described in {_checkRole}.\n *\n * _Available since v4.6._\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Revert with a standard message if `account` is missing `role`.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert(\n string(\n abi.encodePacked(\n \"AccessControl: account \",\n Strings.toHexString(uint160(account), 20),\n \" is missing role \",\n Strings.toHexString(uint256(role), 32)\n )\n )\n );\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) public virtual override {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn't perform any\n * checks on the calling account.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n *\n * NOTE: This function is deprecated in favor of {_grantRole}.\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(role, account);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * Internal function without access restriction.\n */\n function _grantRole(bytes32 role, address account) internal virtual {\n if (!hasRole(role, account)) {\n _roles[role].members[account] = true;\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * Internal function without access restriction.\n */\n function _revokeRole(bytes32 role, address account) internal virtual {\n if (hasRole(role, account)) {\n _roles[role].members[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n" - }, - "@openzeppelin/contracts/access/IAccessControl.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n" - }, - "@openzeppelin/contracts/utils/Strings.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\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 // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\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 if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\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 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_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/introspection/ERC165.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 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 *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/introspection/IERC165.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\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[EIP 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" - }, - "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev _Available since v3.1._\n */\ninterface IERC1155Receiver is IERC165 {\n /**\n * @dev Handles the receipt of a single ERC1155 token type. This function is\n * called at the end of a `safeTransferFrom` after the balance has been updated.\n *\n * NOTE: To accept the transfer, this must return\n * `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))`\n * (i.e. 0xf23a6e61, or its own function selector).\n *\n * @param operator The address which initiated the transfer (i.e. msg.sender)\n * @param from The address which previously owned the token\n * @param id The ID of the token being transferred\n * @param value The amount of tokens being transferred\n * @param data Additional data with no specified format\n * @return `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))` if transfer is allowed\n */\n function onERC1155Received(\n address operator,\n address from,\n uint256 id,\n uint256 value,\n bytes calldata data\n ) external returns (bytes4);\n\n /**\n * @dev Handles the receipt of a multiple ERC1155 token types. This function\n * is called at the end of a `safeBatchTransferFrom` after the balances have\n * been updated.\n *\n * NOTE: To accept the transfer(s), this must return\n * `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))`\n * (i.e. 0xbc197c81, or its own function selector).\n *\n * @param operator The address which initiated the batch transfer (i.e. msg.sender)\n * @param from The address which previously owned the token\n * @param ids An array containing ids of each token being transferred (order and length must match values array)\n * @param values An array containing amounts of each token being transferred (order and length must match ids array)\n * @param data Additional data with no specified format\n * @return `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))` if transfer is allowed\n */\n function onERC1155BatchReceived(\n address operator,\n address from,\n uint256[] calldata ids,\n uint256[] calldata values,\n bytes calldata data\n ) external returns (bytes4);\n}\n" - }, - "@openzeppelin/contracts/governance/TimelockController.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (governance/TimelockController.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../access/AccessControl.sol\";\nimport \"../token/ERC721/IERC721Receiver.sol\";\nimport \"../token/ERC1155/IERC1155Receiver.sol\";\n\n/**\n * @dev Contract module which acts as a timelocked controller. When set as the\n * owner of an `Ownable` smart contract, it enforces a timelock on all\n * `onlyOwner` maintenance operations. This gives time for users of the\n * controlled contract to exit before a potentially dangerous maintenance\n * operation is applied.\n *\n * By default, this contract is self administered, meaning administration tasks\n * have to go through the timelock process. The proposer (resp executor) role\n * is in charge of proposing (resp executing) operations. A common use case is\n * to position this {TimelockController} as the owner of a smart contract, with\n * a multisig or a DAO as the sole proposer.\n *\n * _Available since v3.3._\n */\ncontract TimelockController is AccessControl, IERC721Receiver, IERC1155Receiver {\n bytes32 public constant TIMELOCK_ADMIN_ROLE = keccak256(\"TIMELOCK_ADMIN_ROLE\");\n bytes32 public constant PROPOSER_ROLE = keccak256(\"PROPOSER_ROLE\");\n bytes32 public constant EXECUTOR_ROLE = keccak256(\"EXECUTOR_ROLE\");\n bytes32 public constant CANCELLER_ROLE = keccak256(\"CANCELLER_ROLE\");\n uint256 internal constant _DONE_TIMESTAMP = uint256(1);\n\n mapping(bytes32 => uint256) private _timestamps;\n uint256 private _minDelay;\n\n /**\n * @dev Emitted when a call is scheduled as part of operation `id`.\n */\n event CallScheduled(\n bytes32 indexed id,\n uint256 indexed index,\n address target,\n uint256 value,\n bytes data,\n bytes32 predecessor,\n uint256 delay\n );\n\n /**\n * @dev Emitted when a call is performed as part of operation `id`.\n */\n event CallExecuted(bytes32 indexed id, uint256 indexed index, address target, uint256 value, bytes data);\n\n /**\n * @dev Emitted when operation `id` is cancelled.\n */\n event Cancelled(bytes32 indexed id);\n\n /**\n * @dev Emitted when the minimum delay for future operations is modified.\n */\n event MinDelayChange(uint256 oldDuration, uint256 newDuration);\n\n /**\n * @dev Initializes the contract with a given `minDelay`, and a list of\n * initial proposers and executors. The proposers receive both the\n * proposer and the canceller role (for backward compatibility). The\n * executors receive the executor role.\n *\n * NOTE: At construction, both the deployer and the timelock itself are\n * administrators. This helps further configuration of the timelock by the\n * deployer. After configuration is done, it is recommended that the\n * deployer renounces its admin position and relies on timelocked\n * operations to perform future maintenance.\n */\n constructor(\n uint256 minDelay,\n address[] memory proposers,\n address[] memory executors\n ) {\n _setRoleAdmin(TIMELOCK_ADMIN_ROLE, TIMELOCK_ADMIN_ROLE);\n _setRoleAdmin(PROPOSER_ROLE, TIMELOCK_ADMIN_ROLE);\n _setRoleAdmin(EXECUTOR_ROLE, TIMELOCK_ADMIN_ROLE);\n _setRoleAdmin(CANCELLER_ROLE, TIMELOCK_ADMIN_ROLE);\n\n // deployer + self administration\n _setupRole(TIMELOCK_ADMIN_ROLE, _msgSender());\n _setupRole(TIMELOCK_ADMIN_ROLE, address(this));\n\n // register proposers and cancellers\n for (uint256 i = 0; i < proposers.length; ++i) {\n _setupRole(PROPOSER_ROLE, proposers[i]);\n _setupRole(CANCELLER_ROLE, proposers[i]);\n }\n\n // register executors\n for (uint256 i = 0; i < executors.length; ++i) {\n _setupRole(EXECUTOR_ROLE, executors[i]);\n }\n\n _minDelay = minDelay;\n emit MinDelayChange(0, minDelay);\n }\n\n /**\n * @dev Modifier to make a function callable only by a certain role. In\n * addition to checking the sender's role, `address(0)` 's role is also\n * considered. Granting a role to `address(0)` is equivalent to enabling\n * this role for everyone.\n */\n modifier onlyRoleOrOpenRole(bytes32 role) {\n if (!hasRole(role, address(0))) {\n _checkRole(role, _msgSender());\n }\n _;\n }\n\n /**\n * @dev Contract might receive/hold ETH as part of the maintenance process.\n */\n receive() external payable {}\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, AccessControl) returns (bool) {\n return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns whether an id correspond to a registered operation. This\n * includes both Pending, Ready and Done operations.\n */\n function isOperation(bytes32 id) public view virtual returns (bool pending) {\n return getTimestamp(id) > 0;\n }\n\n /**\n * @dev Returns whether an operation is pending or not.\n */\n function isOperationPending(bytes32 id) public view virtual returns (bool pending) {\n return getTimestamp(id) > _DONE_TIMESTAMP;\n }\n\n /**\n * @dev Returns whether an operation is ready or not.\n */\n function isOperationReady(bytes32 id) public view virtual returns (bool ready) {\n uint256 timestamp = getTimestamp(id);\n return timestamp > _DONE_TIMESTAMP && timestamp <= block.timestamp;\n }\n\n /**\n * @dev Returns whether an operation is done or not.\n */\n function isOperationDone(bytes32 id) public view virtual returns (bool done) {\n return getTimestamp(id) == _DONE_TIMESTAMP;\n }\n\n /**\n * @dev Returns the timestamp at with an operation becomes ready (0 for\n * unset operations, 1 for done operations).\n */\n function getTimestamp(bytes32 id) public view virtual returns (uint256 timestamp) {\n return _timestamps[id];\n }\n\n /**\n * @dev Returns the minimum delay for an operation to become valid.\n *\n * This value can be changed by executing an operation that calls `updateDelay`.\n */\n function getMinDelay() public view virtual returns (uint256 duration) {\n return _minDelay;\n }\n\n /**\n * @dev Returns the identifier of an operation containing a single\n * transaction.\n */\n function hashOperation(\n address target,\n uint256 value,\n bytes calldata data,\n bytes32 predecessor,\n bytes32 salt\n ) public pure virtual returns (bytes32 hash) {\n return keccak256(abi.encode(target, value, data, predecessor, salt));\n }\n\n /**\n * @dev Returns the identifier of an operation containing a batch of\n * transactions.\n */\n function hashOperationBatch(\n address[] calldata targets,\n uint256[] calldata values,\n bytes[] calldata payloads,\n bytes32 predecessor,\n bytes32 salt\n ) public pure virtual returns (bytes32 hash) {\n return keccak256(abi.encode(targets, values, payloads, predecessor, salt));\n }\n\n /**\n * @dev Schedule an operation containing a single transaction.\n *\n * Emits a {CallScheduled} event.\n *\n * Requirements:\n *\n * - the caller must have the 'proposer' role.\n */\n function schedule(\n address target,\n uint256 value,\n bytes calldata data,\n bytes32 predecessor,\n bytes32 salt,\n uint256 delay\n ) public virtual onlyRole(PROPOSER_ROLE) {\n bytes32 id = hashOperation(target, value, data, predecessor, salt);\n _schedule(id, delay);\n emit CallScheduled(id, 0, target, value, data, predecessor, delay);\n }\n\n /**\n * @dev Schedule an operation containing a batch of transactions.\n *\n * Emits one {CallScheduled} event per transaction in the batch.\n *\n * Requirements:\n *\n * - the caller must have the 'proposer' role.\n */\n function scheduleBatch(\n address[] calldata targets,\n uint256[] calldata values,\n bytes[] calldata payloads,\n bytes32 predecessor,\n bytes32 salt,\n uint256 delay\n ) public virtual onlyRole(PROPOSER_ROLE) {\n require(targets.length == values.length, \"TimelockController: length mismatch\");\n require(targets.length == payloads.length, \"TimelockController: length mismatch\");\n\n bytes32 id = hashOperationBatch(targets, values, payloads, predecessor, salt);\n _schedule(id, delay);\n for (uint256 i = 0; i < targets.length; ++i) {\n emit CallScheduled(id, i, targets[i], values[i], payloads[i], predecessor, delay);\n }\n }\n\n /**\n * @dev Schedule an operation that is to becomes valid after a given delay.\n */\n function _schedule(bytes32 id, uint256 delay) private {\n require(!isOperation(id), \"TimelockController: operation already scheduled\");\n require(delay >= getMinDelay(), \"TimelockController: insufficient delay\");\n _timestamps[id] = block.timestamp + delay;\n }\n\n /**\n * @dev Cancel an operation.\n *\n * Requirements:\n *\n * - the caller must have the 'canceller' role.\n */\n function cancel(bytes32 id) public virtual onlyRole(CANCELLER_ROLE) {\n require(isOperationPending(id), \"TimelockController: operation cannot be cancelled\");\n delete _timestamps[id];\n\n emit Cancelled(id);\n }\n\n /**\n * @dev Execute an (ready) operation containing a single transaction.\n *\n * Emits a {CallExecuted} event.\n *\n * Requirements:\n *\n * - the caller must have the 'executor' role.\n */\n // This function can reenter, but it doesn't pose a risk because _afterCall checks that the proposal is pending,\n // thus any modifications to the operation during reentrancy should be caught.\n // slither-disable-next-line reentrancy-eth\n function execute(\n address target,\n uint256 value,\n bytes calldata data,\n bytes32 predecessor,\n bytes32 salt\n ) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) {\n bytes32 id = hashOperation(target, value, data, predecessor, salt);\n _beforeCall(id, predecessor);\n _call(id, 0, target, value, data);\n _afterCall(id);\n }\n\n /**\n * @dev Execute an (ready) operation containing a batch of transactions.\n *\n * Emits one {CallExecuted} event per transaction in the batch.\n *\n * Requirements:\n *\n * - the caller must have the 'executor' role.\n */\n function executeBatch(\n address[] calldata targets,\n uint256[] calldata values,\n bytes[] calldata payloads,\n bytes32 predecessor,\n bytes32 salt\n ) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) {\n require(targets.length == values.length, \"TimelockController: length mismatch\");\n require(targets.length == payloads.length, \"TimelockController: length mismatch\");\n\n bytes32 id = hashOperationBatch(targets, values, payloads, predecessor, salt);\n _beforeCall(id, predecessor);\n for (uint256 i = 0; i < targets.length; ++i) {\n _call(id, i, targets[i], values[i], payloads[i]);\n }\n _afterCall(id);\n }\n\n /**\n * @dev Checks before execution of an operation's calls.\n */\n function _beforeCall(bytes32 id, bytes32 predecessor) private view {\n require(isOperationReady(id), \"TimelockController: operation is not ready\");\n require(predecessor == bytes32(0) || isOperationDone(predecessor), \"TimelockController: missing dependency\");\n }\n\n /**\n * @dev Checks after execution of an operation's calls.\n */\n function _afterCall(bytes32 id) private {\n require(isOperationReady(id), \"TimelockController: operation is not ready\");\n _timestamps[id] = _DONE_TIMESTAMP;\n }\n\n /**\n * @dev Execute an operation's call.\n *\n * Emits a {CallExecuted} event.\n */\n function _call(\n bytes32 id,\n uint256 index,\n address target,\n uint256 value,\n bytes calldata data\n ) private {\n (bool success, ) = target.call{value: value}(data);\n require(success, \"TimelockController: underlying transaction reverted\");\n\n emit CallExecuted(id, index, target, value, data);\n }\n\n /**\n * @dev Changes the minimum timelock duration for future operations.\n *\n * Emits a {MinDelayChange} event.\n *\n * Requirements:\n *\n * - the caller must be the timelock itself. This can only be achieved by scheduling and later executing\n * an operation where the timelock is the target and the data is the ABI-encoded call to this function.\n */\n function updateDelay(uint256 newDelay) external virtual {\n require(msg.sender == address(this), \"TimelockController: caller must be timelock\");\n emit MinDelayChange(_minDelay, newDelay);\n _minDelay = newDelay;\n }\n\n /**\n * @dev See {IERC721Receiver-onERC721Received}.\n */\n function onERC721Received(\n address,\n address,\n uint256,\n bytes memory\n ) public virtual override returns (bytes4) {\n return this.onERC721Received.selector;\n }\n\n /**\n * @dev See {IERC1155Receiver-onERC1155Received}.\n */\n function onERC1155Received(\n address,\n address,\n uint256,\n uint256,\n bytes memory\n ) public virtual override returns (bytes4) {\n return this.onERC1155Received.selector;\n }\n\n /**\n * @dev See {IERC1155Receiver-onERC1155BatchReceived}.\n */\n function onERC1155BatchReceived(\n address,\n address,\n uint256[] memory,\n uint256[] memory,\n bytes memory\n ) public virtual override returns (bytes4) {\n return this.onERC1155BatchReceived.selector;\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" - }, - "contracts/hardhat-dependency-compiler/@openzeppelin/contracts/governance/TimelockController.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@openzeppelin/contracts/governance/TimelockController.sol';\n" - }, - "contracts/hardhat-dependency-compiler/@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol';\n" - }, - "contracts/forwarder/Forwarder.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../interfaces/IForwarder.sol\";\n\n/**\n * @title Forwarder\n * @notice Facilitates collateral deposits to the protocol where the amount is supplied\n * in USDC then wrapped as DSU before being deposited.\n */\ncontract Forwarder is IForwarder {\n // @dev USDC stablecoin\n Token6 public immutable USDC; // solhint-disable-line var-name-mixedcase\n\n // @dev DSU stablecoin\n Token18 public immutable DSU; // solhint-disable-line var-name-mixedcase\n\n /// @dev Contract that wraps USDC to DSU\n IBatcher public immutable batcher;\n\n /// @dev Contract managing state for collateral accounts in the protocol\n ICollateral public immutable collateral;\n\n /**\n * @notice Initializes the contract state\n * @param usdc_ The USDC token contract address\n * @param dsu_ The DSU token contract address\n * @param batcher_ The USDC-to-DSU batcher contract address\n * @param collateral_ The perennial collateral contract address\n */\n constructor(\n Token6 usdc_,\n Token18 dsu_,\n IBatcher batcher_,\n ICollateral collateral_\n ) {\n if (!Address.isContract(Token6.unwrap(usdc_))) revert ForwarderNotContractAddressError();\n if (!Address.isContract(Token18.unwrap(dsu_))) revert ForwarderNotContractAddressError();\n if (!Address.isContract(address(batcher_))) revert ForwarderNotContractAddressError();\n if (!Address.isContract(address(collateral_))) revert ForwarderNotContractAddressError();\n\n USDC = usdc_;\n DSU = dsu_;\n batcher = batcher_;\n collateral = collateral_;\n\n USDC.approve(address(batcher));\n DSU.approve(address(collateral));\n }\n\n /**\n * @notice Pulls `amount` of USDC from `msg.sender`'s balance, wraps it as DSU,\n and deposits it as collateral to `account`'s `product` account\n * @param account Account to deposit the collateral for\n * @param product Product to credit the collateral to\n * @param amount 18 decimals-normalized stablecoin (USDC, DSU) value of collateral to deposit\n */\n function wrapAndDeposit(\n address account,\n IProduct product,\n UFixed18 amount\n ) external {\n USDC.pull(msg.sender, amount, true);\n batcher.wrap(amount, address(this));\n collateral.depositTo(account, product, amount);\n emit WrapAndDeposit(account, product, amount);\n }\n}\n" - }, - "contracts/hardhat-dependency-compiler/@equilibria/emptyset-batcher/batcher/Batcher.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@equilibria/emptyset-batcher/batcher/Batcher.sol';\n" - }, - "contracts/hardhat-dependency-compiler/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol';\n" - }, - "contracts/hardhat-dependency-compiler/@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol';\n" - }, - "@equilibria/perennial-oracle/contracts/ReservoirFeedOracle.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol\";\nimport \"./interfaces/IOracleProvider.sol\";\n\n/**\n * @title ReservoirFeedOracle\n * @notice Reservoir implementation of the IOracle interface, using Reservoir's AggregatorV3Interface adaptors\n * @dev This is a naive implementation which pushes all validation to the underlying. No staleness checks are possible\n This oracle should not be used for regular Chainlink Data Feeds\n */\ncontract ReservoirFeedOracle is IOracleProvider {\n error InvalidOracleVersion();\n\n /// @dev Chainlink price feed to read from\n AggregatorV3Interface public immutable feed;\n\n /// @dev Decimal offset used to normalize chainlink price to 18 decimals\n int256 private immutable _decimalOffset;\n\n /// @dev Which underlying round to consider version 0: version = roundId - _versionOffset\n uint80 private immutable _versionOffset;\n\n /**\n * @notice Initializes the contract state\n * @param feed_ Reservoir price feed\n * @param versionOffset_ Version offset from source round ID\n */\n constructor(AggregatorV3Interface feed_, uint80 versionOffset_) {\n feed = feed_;\n _versionOffset = versionOffset_;\n _decimalOffset = SafeCast.toInt256(10 ** feed_.decimals());\n }\n\n /**\n * @notice Checks for a new price. Does not perform staleness validation as the underlying oracle does not\n support this.\n * @return The current oracle version after sync\n */\n function sync() external view returns (OracleVersion memory) {\n (uint80 roundId, int256 feedPrice, , uint256 timestamp,) = feed.latestRoundData();\n\n return _buildOracleVersion(roundId, feedPrice, timestamp);\n }\n\n /**\n * @notice Returns the current oracle version\n * @return oracleVersion Current oracle version\n */\n function currentVersion() public view returns (OracleVersion memory oracleVersion) {\n (uint80 roundId, int256 feedPrice, , uint256 timestamp,) = feed.latestRoundData();\n\n return _buildOracleVersion(roundId, feedPrice, timestamp);\n }\n\n /**\n * @notice Returns the oracle version specified\n * @dev Converts the passed in version to a roundID by adding _versionOffset\n * @param version The version of which to lookup\n * @return oracleVersion Oracle version at version `version`\n */\n function atVersion(uint256 version) public view returns (OracleVersion memory oracleVersion) {\n // To convert from version to roundId, we add the versionOffset\n uint256 feedRoundID = version + _versionOffset;\n if (feedRoundID > type(uint80).max) revert InvalidOracleVersion();\n (uint80 roundId, int256 feedPrice, , uint256 timestamp,) = feed.getRoundData(uint80(feedRoundID));\n\n return _buildOracleVersion(roundId, feedPrice, timestamp);\n }\n\n /**\n * @notice Builds an oracle version object from a Chainlink round object\n * @dev Converts the passed in roundID to a version by subtracting _versionOffset\n * @param roundId ReservoirRoundId round to build from\n * @param feedPrice price returns by the oracle\n * @param timestamp round timestamps\n * @return Built oracle version\n */\n function _buildOracleVersion(uint80 roundId, int256 feedPrice, uint256 timestamp)\n private view returns (OracleVersion memory) {\n Fixed18 price = Fixed18Lib.ratio(feedPrice, _decimalOffset);\n\n // To convert from roundId to version, we subtract the versionOffset\n return OracleVersion({ version: roundId - _versionOffset, timestamp: timestamp, price: price });\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/SafeCast.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/math/SafeCast.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCast {\n /**\n * @dev Returns the downcasted 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 require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\n return uint224(value);\n }\n\n /**\n * @dev Returns the downcasted 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 require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return uint128(value);\n }\n\n /**\n * @dev Returns the downcasted 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 require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\n return uint96(value);\n }\n\n /**\n * @dev Returns the downcasted 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 require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return uint64(value);\n }\n\n /**\n * @dev Returns the downcasted 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 require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return uint32(value);\n }\n\n /**\n * @dev Returns the downcasted 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 require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return uint16(value);\n }\n\n /**\n * @dev Returns the downcasted uint8 from uint256, reverting on\n * overflow (when the input is greater than largest uint8).\n *\n * Counterpart to Solidity's `uint8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits.\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return uint8(value);\n }\n\n /**\n * @dev Converts a signed int256 into an unsigned uint256.\n *\n * Requirements:\n *\n * - input must be greater than or equal to 0.\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n require(value >= 0, \"SafeCast: value must be positive\");\n return uint256(value);\n }\n\n /**\n * @dev Returns the downcasted int128 from int256, reverting on\n * overflow (when the input is less than smallest int128 or\n * greater than largest int128).\n *\n * Counterpart to Solidity's `int128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v3.1._\n */\n function toInt128(int256 value) internal pure returns (int128) {\n require(value >= type(int128).min && value <= type(int128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return int128(value);\n }\n\n /**\n * @dev Returns the downcasted int64 from int256, reverting on\n * overflow (when the input is less than smallest int64 or\n * greater than largest int64).\n *\n * Counterpart to Solidity's `int64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v3.1._\n */\n function toInt64(int256 value) internal pure returns (int64) {\n require(value >= type(int64).min && value <= type(int64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return int64(value);\n }\n\n /**\n * @dev Returns the downcasted int32 from int256, reverting on\n * overflow (when the input is less than smallest int32 or\n * greater than largest int32).\n *\n * Counterpart to Solidity's `int32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v3.1._\n */\n function toInt32(int256 value) internal pure returns (int32) {\n require(value >= type(int32).min && value <= type(int32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return int32(value);\n }\n\n /**\n * @dev Returns the downcasted int16 from int256, reverting on\n * overflow (when the input is less than smallest int16 or\n * greater than largest int16).\n *\n * Counterpart to Solidity's `int16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v3.1._\n */\n function toInt16(int256 value) internal pure returns (int16) {\n require(value >= type(int16).min && value <= type(int16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return int16(value);\n }\n\n /**\n * @dev Returns the downcasted int8 from int256, reverting on\n * overflow (when the input is less than smallest int8 or\n * greater than largest int8).\n *\n * Counterpart to Solidity's `int8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits.\n *\n * _Available since v3.1._\n */\n function toInt8(int256 value) internal pure returns (int8) {\n require(value >= type(int8).min && value <= type(int8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return int8(value);\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 require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n" - }, - "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface AggregatorV3Interface {\n function decimals() external view returns (uint8);\n\n function description() external view returns (string memory);\n\n function version() external view returns (uint256);\n\n // getRoundData and latestRoundData should both raise \"No data present\"\n // if they do not have data to report, instead of returning unset values\n // which could be misinterpreted as actual reported values.\n function getRoundData(uint80 _roundId)\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n function latestRoundData()\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n}\n" - }, - "@equilibria/perennial-oracle/contracts/test/PassthroughDataFeed.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol\";\n\ncontract PassthroughDataFeed {\n AggregatorV3Interface private _underlying;\n\n constructor(AggregatorV3Interface underlying_) {\n _underlying = underlying_;\n }\n\n function decimals() external view returns (uint8) {\n return _underlying.decimals();\n }\n\n function getRoundData(uint80 roundId) external view returns (uint80, int256, uint256, uint256, uint80) {\n return _underlying.getRoundData(roundId);\n }\n\n function latestRoundData() external view returns (uint80, int256, uint256, uint256, uint80) {\n return _underlying.latestRoundData();\n }\n}\n" - }, - "contracts/hardhat-dependency-compiler/@equilibria/perennial-oracle/contracts/test/PassthroughDataFeed.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@equilibria/perennial-oracle/contracts/test/PassthroughDataFeed.sol';\n" - }, - "@equilibria/perennial-oracle/contracts/types/ChainlinkRound.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol\";\n\n/// @dev ChainlinkRound type\nstruct ChainlinkRound {\n uint256 timestamp;\n int256 answer;\n uint80 roundId;\n}\nusing ChainlinkRoundLib for ChainlinkRound global;\n\n/**\n * @title ChainlinkRoundLib\n * @notice Library that manages Chainlink round parsing.\n */\nlibrary ChainlinkRoundLib {\n /// @dev Phase ID offset location in the round ID\n uint256 constant private PHASE_OFFSET = 64;\n\n /**\n * @notice Computes the chainlink phase ID from a round\n * @param self Round to compute from\n * @return Chainlink phase ID\n */\n function phaseId(ChainlinkRound memory self) internal pure returns (uint16) {\n return uint16(self.roundId >> PHASE_OFFSET);\n }\n}\n" - }, - "@equilibria/perennial-oracle/contracts/types/ChainlinkRegistry.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@chainlink/contracts/src/v0.8/interfaces/FeedRegistryInterface.sol\";\nimport \"./ChainlinkRound.sol\";\n\n/// @dev ChainlinkRegistry type\ntype ChainlinkRegistry is address;\nusing ChainlinkRegistryLib for ChainlinkRegistry global;\n\n/**\n * @title ChainlinkRegistryLib\n * @notice Library that manages interfacing with the Chainlink Feed Registry.\n */\nlibrary ChainlinkRegistryLib {\n /**\n * @notice Returns the decimal amount for a specific feed\n * @param self Chainlink Feed Registry to operate on\n * @param base Base currency token address\n * @param quote Quote currency token address\n * @return Decimal amount\n */\n function decimals(ChainlinkRegistry self, address base, address quote) internal view returns (uint8) {\n return FeedRegistryInterface(ChainlinkRegistry.unwrap(self)).decimals(base, quote);\n }\n\n /**\n * @notice Returns the latest round data for a specific feed\n * @param self Chainlink Feed Registry to operate on\n * @param base Base currency token address\n * @param quote Quote currency token address\n * @return Latest round data\n */\n function getLatestRound(ChainlinkRegistry self, address base, address quote) internal view returns (ChainlinkRound memory) {\n (uint80 roundId, int256 answer, , uint256 updatedAt, ) =\n FeedRegistryInterface(ChainlinkRegistry.unwrap(self)).latestRoundData(base, quote);\n return ChainlinkRound({roundId: roundId, timestamp: updatedAt, answer: answer});\n }\n\n /**\n * @notice Returns a specific round's data for a specific feed\n * @param self Chainlink Feed Registry to operate on\n * @param base Base currency token address\n * @param quote Quote currency token address\n * @param roundId The specific round to fetch data for\n * @return Specific round's data\n */\n function getRound(ChainlinkRegistry self, address base, address quote, uint80 roundId) internal view returns (ChainlinkRound memory) {\n (, int256 answer, , uint256 updatedAt, ) =\n FeedRegistryInterface(ChainlinkRegistry.unwrap(self)).getRoundData(base, quote, roundId);\n return ChainlinkRound({roundId: roundId, timestamp: updatedAt, answer: answer});\n }\n\n\n /**\n * @notice Returns the first round ID for a specific phase ID\n * @param self Chainlink Feed Registry to operate on\n * @param base Base currency token address\n * @param quote Quote currency token address\n * @param phaseId The specific phase to fetch data for\n * @return startingRoundId The starting round ID for the phase\n */\n function getStartingRoundId(ChainlinkRegistry self, address base, address quote, uint16 phaseId)\n internal view returns (uint80 startingRoundId) {\n (startingRoundId, ) =\n FeedRegistryInterface(ChainlinkRegistry.unwrap(self)).getPhaseRange(base, quote, phaseId);\n }\n\n /**\n * @notice Returns the quantity of rounds for a specific phase ID\n * @param self Chainlink Feed Registry to operate on\n * @param base Base currency token address\n * @param quote Quote currency token address\n * @param phaseId The specific phase to fetch data for\n * @return The quantity of rounds for the phase\n */\n function getRoundCount(ChainlinkRegistry self, address base, address quote, uint16 phaseId)\n internal view returns (uint80) {\n (uint80 startingRoundId, uint80 endingRoundId) =\n FeedRegistryInterface(ChainlinkRegistry.unwrap(self)).getPhaseRange(base, quote, phaseId);\n return endingRoundId - startingRoundId + 1;\n }\n}\n" - }, - "@chainlink/contracts/src/v0.8/interfaces/FeedRegistryInterface.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\npragma abicoder v2;\n\nimport \"./AggregatorV2V3Interface.sol\";\n\ninterface FeedRegistryInterface {\n struct Phase {\n uint16 phaseId;\n uint80 startingAggregatorRoundId;\n uint80 endingAggregatorRoundId;\n }\n\n event FeedProposed(\n address indexed asset,\n address indexed denomination,\n address indexed proposedAggregator,\n address currentAggregator,\n address sender\n );\n event FeedConfirmed(\n address indexed asset,\n address indexed denomination,\n address indexed latestAggregator,\n address previousAggregator,\n uint16 nextPhaseId,\n address sender\n );\n\n // V3 AggregatorV3Interface\n\n function decimals(address base, address quote) external view returns (uint8);\n\n function description(address base, address quote) external view returns (string memory);\n\n function version(address base, address quote) external view returns (uint256);\n\n function latestRoundData(address base, address quote)\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n function getRoundData(\n address base,\n address quote,\n uint80 _roundId\n )\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n // V2 AggregatorInterface\n\n function latestAnswer(address base, address quote) external view returns (int256 answer);\n\n function latestTimestamp(address base, address quote) external view returns (uint256 timestamp);\n\n function latestRound(address base, address quote) external view returns (uint256 roundId);\n\n function getAnswer(\n address base,\n address quote,\n uint256 roundId\n ) external view returns (int256 answer);\n\n function getTimestamp(\n address base,\n address quote,\n uint256 roundId\n ) external view returns (uint256 timestamp);\n\n // Registry getters\n\n function getFeed(address base, address quote) external view returns (AggregatorV2V3Interface aggregator);\n\n function getPhaseFeed(\n address base,\n address quote,\n uint16 phaseId\n ) external view returns (AggregatorV2V3Interface aggregator);\n\n function isFeedEnabled(address aggregator) external view returns (bool);\n\n function getPhase(\n address base,\n address quote,\n uint16 phaseId\n ) external view returns (Phase memory phase);\n\n // Round helpers\n\n function getRoundFeed(\n address base,\n address quote,\n uint80 roundId\n ) external view returns (AggregatorV2V3Interface aggregator);\n\n function getPhaseRange(\n address base,\n address quote,\n uint16 phaseId\n ) external view returns (uint80 startingRoundId, uint80 endingRoundId);\n\n function getPreviousRoundId(\n address base,\n address quote,\n uint80 roundId\n ) external view returns (uint80 previousRoundId);\n\n function getNextRoundId(\n address base,\n address quote,\n uint80 roundId\n ) external view returns (uint80 nextRoundId);\n\n // Feed management\n\n function proposeFeed(\n address base,\n address quote,\n address aggregator\n ) external;\n\n function confirmFeed(\n address base,\n address quote,\n address aggregator\n ) external;\n\n // Proposed aggregator\n\n function getProposedFeed(address base, address quote)\n external\n view\n returns (AggregatorV2V3Interface proposedAggregator);\n\n function proposedGetRoundData(\n address base,\n address quote,\n uint80 roundId\n )\n external\n view\n returns (\n uint80 id,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n function proposedLatestRoundData(address base, address quote)\n external\n view\n returns (\n uint80 id,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n // Phases\n function getCurrentPhaseId(address base, address quote) external view returns (uint16 currentPhaseId);\n}\n" - }, - "@chainlink/contracts/src/v0.8/interfaces/AggregatorV2V3Interface.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"./AggregatorInterface.sol\";\nimport \"./AggregatorV3Interface.sol\";\n\ninterface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface {}\n" - }, - "@chainlink/contracts/src/v0.8/interfaces/AggregatorInterface.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface AggregatorInterface {\n function latestAnswer() external view returns (int256);\n\n function latestTimestamp() external view returns (uint256);\n\n function latestRound() external view returns (uint256);\n\n function getAnswer(uint256 roundId) external view returns (int256);\n\n function getTimestamp(uint256 roundId) external view returns (uint256);\n\n event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 updatedAt);\n\n event NewRound(uint256 indexed roundId, address indexed startedBy, uint256 startedAt);\n}\n" - }, - "@equilibria/perennial-oracle/contracts/test/PassthroughChainlinkFeed.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@chainlink/contracts/src/v0.8/interfaces/FeedRegistryInterface.sol\";\n\ncontract PassthroughChainlinkFeed {\n FeedRegistryInterface private _underlying;\n\n constructor(FeedRegistryInterface underlying_) {\n _underlying = underlying_;\n }\n\n function decimals(address base, address quote) external view returns (uint8) {\n return _underlying.decimals(base, quote);\n }\n\n function getRoundData(address base, address quote, uint80 roundId) external view returns (uint80, int256, uint256, uint256, uint80) {\n return _underlying.getRoundData(base, quote, roundId);\n }\n\n function getPhaseRange(address base, address quote, uint16 phaseId) external view returns (uint80, uint80) {\n return _underlying.getPhaseRange(base, quote, phaseId);\n }\n\n function latestRoundData(address base, address quote) external view returns (uint80, int256, uint256, uint256, uint80) {\n return _underlying.latestRoundData(base, quote);\n }\n}\n" - }, - "contracts/hardhat-dependency-compiler/@equilibria/perennial-oracle/contracts/test/PassthroughChainlinkFeed.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@equilibria/perennial-oracle/contracts/test/PassthroughChainlinkFeed.sol';\n" - }, - "@equilibria/perennial-oracle/contracts/ChainlinkOracle.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@chainlink/contracts/src/v0.8/interfaces/FeedRegistryInterface.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"./interfaces/IOracleProvider.sol\";\nimport \"./types/ChainlinkRegistry.sol\";\n\n/**\n * @title ChainlinkOracle\n * @notice Chainlink implementation of the IOracle interface.\n * @dev One instance per Chainlink price feed should be deployed. Multiple products may use the same\n * ChainlinkOracle instance if their payoff functions are based on the same underlying oracle.\n * This implementation only support non-negative prices.\n */\ncontract ChainlinkOracle is IOracleProvider {\n /// @dev Chainlink registry feed address\n ChainlinkRegistry public immutable registry;\n\n /// @dev Base token address for the Chainlink oracle\n address public immutable base;\n\n /// @dev Quote token address for the Chainlink oracle\n address public immutable quote;\n\n /// @dev Decimal offset used to normalize chainlink price to 18 decimals\n int256 private immutable _decimalOffset;\n\n /// @dev Mapping of the first oracle version for each underlying phase ID\n uint256[] private _startingVersionForPhaseId;\n\n /**\n * @notice Initializes the contract state\n * @param registry_ Chainlink price feed registry\n * @param base_ base currency for feed\n * @param quote_ quote currency for feed\n */\n constructor(ChainlinkRegistry registry_, address base_, address quote_) {\n registry = registry_;\n base = base_;\n quote = quote_;\n\n _startingVersionForPhaseId.push(0); // phaseId is 1-indexed, skip index 0\n _startingVersionForPhaseId.push(0); // phaseId is 1-indexed, first phase starts as version 0\n _decimalOffset = SafeCast.toInt256(10 ** registry_.decimals(base, quote));\n }\n\n /**\n * @notice Checks for a new price and updates the internal phase annotation state accordingly\n * @return The current oracle version after sync\n */\n function sync() external returns (OracleVersion memory) {\n // Fetch latest round\n ChainlinkRound memory round = registry.getLatestRound(base, quote);\n\n // Update phase annotation when new phase detected\n while (round.phaseId() > _latestPhaseId()) {\n uint256 roundCount = registry.getRoundCount(base, quote, _latestPhaseId());\n _startingVersionForPhaseId.push(roundCount);\n }\n\n // Return packaged oracle version\n return _buildOracleVersion(round);\n }\n\n /**\n * @notice Returns the current oracle version\n * @return oracleVersion Current oracle version\n */\n function currentVersion() public view returns (OracleVersion memory oracleVersion) {\n return _buildOracleVersion(registry.getLatestRound(base, quote));\n }\n\n /**\n * @notice Returns the current oracle version\n * @param version The version of which to lookup\n * @return oracleVersion Oracle version at version `version`\n */\n function atVersion(uint256 version) public view returns (OracleVersion memory oracleVersion) {\n return _buildOracleVersion(registry.getRound(base, quote, _versionToRoundId(version)), version);\n }\n\n /**\n * @notice Builds an oracle version object from a Chainlink round object\n * @dev Computes the version for the round\n * @param round Chainlink round to build from\n * @return Built oracle version\n */\n function _buildOracleVersion(ChainlinkRound memory round) private view returns (OracleVersion memory) {\n uint256 version = _startingVersionForPhaseId[round.phaseId()] +\n uint256(round.roundId - registry.getStartingRoundId(base, quote, round.phaseId()));\n return _buildOracleVersion(round, version);\n }\n\n /**\n * @notice Builds an oracle version object from a Chainlink round object\n * @param round Chainlink round to build from\n * @param version Determined version for the round\n * @return Built oracle version\n */\n function _buildOracleVersion(ChainlinkRound memory round, uint256 version)\n private view returns (OracleVersion memory) {\n Fixed18 price = Fixed18Lib.ratio(round.answer, _decimalOffset);\n return OracleVersion({ version: version, timestamp: round.timestamp, price: price });\n }\n\n /**\n * @notice Computes the chainlink round ID from a version\n * @notice version Version to compute from\n * @return Chainlink round ID\n */\n function _versionToRoundId(uint256 version) private view returns (uint80) {\n uint16 phaseId = _versionToPhaseId(version);\n return registry.getStartingRoundId(base, quote, phaseId) +\n uint80(version - _startingVersionForPhaseId[phaseId]);\n }\n\n /**\n * @notice Computes the chainlink phase ID from a version\n * @param version Version to compute from\n * @return phaseId Chainlink phase ID\n */\n function _versionToPhaseId(uint256 version) private view returns (uint16 phaseId) {\n phaseId = _latestPhaseId();\n while (_startingVersionForPhaseId[phaseId] > version) {\n phaseId--;\n }\n }\n\n /**\n * @notice Returns the latest phase ID that this contract has seen via `sync()`\n * @return Latest seen phase ID\n */\n function _latestPhaseId() private view returns (uint16) {\n return uint16(_startingVersionForPhaseId.length - 1);\n }\n}\n" - }, - "contracts/hardhat-dependency-compiler/@equilibria/perennial-oracle/contracts/ChainlinkOracle.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@equilibria/perennial-oracle/contracts/ChainlinkOracle.sol';\n" - }, - "contracts/hardhat-dependency-compiler/@equilibria/perennial-oracle/contracts/ReservoirFeedOracle.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@equilibria/perennial-oracle/contracts/ReservoirFeedOracle.sol';\n" - } - }, - "settings": { - "optimizer": { - "enabled": true, - "runs": 1000000 - }, - "outputSelection": { - "*": { - "*": [ - "abi", - "evm.bytecode", - "evm.deployedBytecode", - "evm.methodIdentifiers", - "metadata", - "devdoc", - "userdoc", - "storageLayout", - "evm.gasEstimates" - ], - "": ["ast"] - } - }, - "metadata": { - "useLiteralContent": true - } - } -} diff --git a/packages/perennial/deployments/kovan/solcInputs/e484d2e5fa479b8a786df3b9532acd09.json b/packages/perennial/deployments/kovan/solcInputs/e484d2e5fa479b8a786df3b9532acd09.json deleted file mode 100644 index 08c58a4cd..000000000 --- a/packages/perennial/deployments/kovan/solcInputs/e484d2e5fa479b8a786df3b9532acd09.json +++ /dev/null @@ -1,123 +0,0 @@ -{ - "language": "Solidity", - "sources": { - "contracts/lens/PerennialLens.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"../interfaces/IPerennialLens.sol\";\n\n/**\n * @title Lens contract to conveniently pull protocol data\n * @notice All functions should be called using `callStatic`\n */\ncontract PerennialLens is IPerennialLens {\n /**\n * @notice Protocol controller\n * @return Protocol controller\n */\n IController public immutable controller;\n\n /// @param _controller Protocol controller address\n constructor(IController _controller) {\n controller = _controller;\n }\n\n /**\n * @notice Returns the name of the provided `product`\n * @param product Product address\n * @return Name of the product\n */\n function name(IProduct product) external view returns (string memory) {\n return product.name();\n }\n\n /**\n * @notice Returns the symbol of the provided `product`\n * @param product Product address\n * @return Symbol of the product\n */\n function symbol(IProduct product) external view returns (string memory) {\n return product.symbol();\n }\n\n /**\n * @notice Protocol collateral address\n * @return Protocol collateral address\n */\n function collateral() public view returns (ICollateral) {\n return controller.collateral();\n }\n\n /**\n * @notice User collateral amount for product after settle\n * @param account Account address\n * @param product Product address\n * @return User deposited collateral for product\n */\n function collateral(address account, IProduct product) external settleAccount(account, product) returns (UFixed18) {\n return collateral().collateral(account, product);\n }\n\n /**\n * @notice Product total collateral amount after settle\n * @param product Product address\n * @return Total collateral for product\n */\n function collateral(IProduct product) external settle(product) returns (UFixed18) {\n return collateral().collateral(product);\n }\n\n /**\n * @notice Product total shortfall amount after settle\n * @param product Product address\n * @return Total shortfall for product\n */\n function shortfall(IProduct product) external settle(product) returns (UFixed18) {\n return collateral().shortfall(product);\n }\n\n /**\n * @notice User maintenance amount for product after settle\n * @param account Account address\n * @param product Product address\n * @return Maximum of user maintenance, and maintenanceNext\n */\n function maintenance(address account, IProduct product)\n external\n settleAccount(account, product)\n returns (UFixed18)\n {\n return UFixed18Lib.max(product.maintenance(account), product.maintenanceNext(account));\n }\n\n /**\n * @notice User liquidatble status for product after settle\n * @param account Account address\n * @param product Product address\n * @return Whether or not the user's position eligible to be liquidated\n */\n function liquidatable(address account, IProduct product) external settleAccount(account, product) returns (bool) {\n return collateral().liquidatable(account, product);\n }\n\n /**\n * @notice User pre position for product after settle\n * @param account Account address\n * @param product Product address\n * @return User pre-position\n */\n function pre(address account, IProduct product)\n external\n settleAccount(account, product)\n returns (PrePosition memory)\n {\n return product.pre(account);\n }\n\n /**\n * @notice Product pre position after settle\n * @param product Product address\n * @return Product pre-position\n */\n function pre(IProduct product) external settle(product) returns (PrePosition memory) {\n return product.pre();\n }\n\n /**\n * @notice User position for product after settle\n * @param account Account address\n * @param product Product address\n * @return User position\n */\n function position(address account, IProduct product)\n external\n settleAccount(account, product)\n returns (Position memory)\n {\n return product.position(account);\n }\n\n /**\n * @notice Product position after settle\n * @param product Product address\n * @return product position\n */\n function position(IProduct product) external settle(product) returns (Position memory) {\n return _latestPosition(product);\n }\n\n /**\n * @notice User pre-position and position for product after settle\n * @param account Account address\n * @param product Product address\n * @return User pre-position\n * @return User position\n */\n function userPosition(address account, IProduct product)\n external\n settleAccount(account, product)\n returns (PrePosition memory, Position memory)\n {\n return (product.pre(account), product.position(account));\n }\n\n /**\n * @notice Product pre-position and position after settle\n * @param product Product address\n * @return Product pre-position\n * @return Product position\n */\n function globalPosition(IProduct product) external settle(product) returns (PrePosition memory, Position memory) {\n return (product.pre(), _latestPosition(product));\n }\n\n /**\n * @notice Current price of product after settle\n * @param product Product address\n * @return Product latest price\n */\n function price(IProduct product) external settle(product) returns (Fixed18) {\n return _latestVersion(product).price;\n }\n\n /**\n * @notice Current price of product at specified version after settle\n * @param product Product address\n * @param version Oracle version\n * @return Product price at specified version\n */\n function priceAtVersion(IProduct product, uint version) external settle(product) returns (Fixed18) {\n return product.atVersion(version).price;\n }\n\n /**\n * @notice Prices of product at specified versions after settle\n * @param product Product address\n * @param versions Oracle versions to query\n * @return prices Product prices at specified versions\n */\n function pricesAtVersions(IProduct product, uint[] memory versions)\n external settle(product) returns (Fixed18[] memory prices) {\n prices = new Fixed18[](versions.length);\n for (uint256 i = 0; i < versions.length; i++) {\n prices[i] = product.atVersion(versions[i]).price;\n }\n }\n\n /**\n * @notice Fees accumulated by product and protocol treasuries after settle\n * @param product Product address\n * @return protocolFees fees accrued by the protocol\n * @return productFees fees accrued by the product owner\n */\n function fees(IProduct product) external settle(product) returns (UFixed18 protocolFees, UFixed18 productFees) {\n address protocolTreasury = controller.treasury();\n address productTreasury = controller.treasury(product);\n\n protocolFees = collateral().fees(protocolTreasury);\n productFees = collateral().fees(productTreasury);\n }\n\n /**\n * @notice Fees accumulated by treasury after settle\n * @param account Account address\n * @param products Product addresses\n * @return sum of all fees accrued by the account\n */\n function fees(address account, IProduct[] memory products) external returns (UFixed18) {\n for (uint256 i = 0; i < products.length; i++) {\n products[i].settle();\n }\n\n return collateral().fees(account);\n }\n\n /**\n * @notice User's open interest in product after settle\n * @param account Account address\n * @param product Product address\n * @return User's maker or taker position multiplied by latest price after settle\n */\n function openInterest(address account, IProduct product)\n external\n settleAccount(account, product)\n returns (Position memory)\n {\n return product.position(account).mul(_latestVersion(product).price.abs());\n }\n\n /**\n * @notice Product total open interest after settle\n * @param product Product address\n * @return Product maker and taker position multiplied by latest price after settle\n */\n function openInterest(IProduct product) external settle(product) returns (Position memory) {\n return _latestPosition(product).mul(_latestVersion(product).price.abs());\n }\n\n /**\n * @notice Product funding rate after settle\n * @param product Product address\n * @return Product current funding rate\n */\n function rate(IProduct product) external settle(product) returns (Fixed18) {\n Position memory position_ = _latestPosition(product);\n return product.rate(position_);\n }\n\n /**\n * @notice Product funding extrapolated to a daily rate after settle\n * @param product Product address\n * @return Product current funding extrapolated to a daily rate\n */\n function dailyRate(IProduct product) external settle(product) returns (Fixed18) {\n Position memory position_ = _latestPosition(product);\n return product.rate(position_).mul(Fixed18Lib.from(60 * 60 * 24));\n }\n\n /**\n * @notice User's maintenance required for position size in product after settle\n * @param account Account address\n * @param product Product address\n * @param positionSize size of position for maintenance calculation\n * @return Maintenance required for position in product\n */\n function maintenanceRequired(\n address account,\n IProduct product,\n UFixed18 positionSize\n ) external settleAccount(account, product) returns (UFixed18) {\n UFixed18 notional = positionSize.mul(_latestVersion(product).price.abs());\n return notional.mul(product.maintenance());\n }\n\n /**\n * @notice User's unclaimed rewards for all programs for product after settle\n * @param account Account address\n * @param product Product address\n * @return tokens Token addresses of unclaimed incentive rewards for given product\n * @return amounts Token amounts of unclaimed incentive rewards for given product\n */\n function unclaimedIncentiveRewards(address account, IProduct product)\n external\n settleAccount(account, product)\n returns (Token18[] memory tokens, UFixed18[] memory amounts)\n {\n IIncentivizer incentivizer = controller.incentivizer();\n\n uint256 programsLength = incentivizer.count(product);\n tokens = new Token18[](programsLength);\n amounts = new UFixed18[](programsLength);\n for (uint256 i = 0; i < programsLength; i++) {\n ProgramInfo memory programInfo = incentivizer.programInfos(product, i);\n tokens[i] = programInfo.token;\n amounts[i] = incentivizer.unclaimed(product, account, i);\n }\n }\n\n /**\n * @notice User's unclaimed rewards for provided programs for product after settle\n * @param account Account address\n * @param product Product address\n * @param programIds Program IDs to query\n * @return tokens Token addresses of unclaimed incentive rewards for given program IDs\n * @return amounts Token amounts of unclaimed incentive rewards for given program IDs\n */\n function unclaimedIncentiveRewards(\n address account,\n IProduct product,\n uint256[] calldata programIds\n ) external settleAccount(account, product) returns (Token18[] memory tokens, UFixed18[] memory amounts) {\n IIncentivizer incentivizer = controller.incentivizer();\n tokens = new Token18[](programIds.length);\n amounts = new UFixed18[](programIds.length);\n for (uint256 i = 0; i < programIds.length; i++) {\n ProgramInfo memory programInfo = incentivizer.programInfos(product, programIds[i]);\n tokens[i] = programInfo.token;\n amounts[i] = incentivizer.unclaimed(product, account, programIds[i]);\n }\n }\n\n // TODO: all data for Product, all data for User, batching\n\n /**\n * @notice Returns the Product's latest position\n * @dev Private function, does not call settle itself\n * @param product Product address\n * @return Latest position for the product\n */\n function _latestPosition(IProduct product) private view returns (Position memory) {\n return product.positionAtVersion(product.latestVersion());\n }\n\n /**\n * @notice Returns the Product's latest version\n * @dev Private function, does not call settle itself\n * @param product Product address\n * @return Latest version for the product\n */\n function _latestVersion(IProduct product) private view returns (IOracleProvider.OracleVersion memory) {\n return product.currentVersion();\n }\n\n /// @dev Settles the product\n modifier settle(IProduct product) {\n product.settle();\n _;\n }\n\n /// @dev Settles the product. product.settleAccount also settles the product\n modifier settleAccount(address account, IProduct product) {\n product.settleAccount(account);\n _;\n }\n}\n" - }, - "contracts/interfaces/IPerennialLens.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"./IProduct.sol\";\nimport \"./ICollateral.sol\";\nimport \"./IController.sol\";\n\ninterface IPerennialLens {\n function controller() external view returns (IController);\n function name(IProduct product) external view returns (string memory);\n function symbol(IProduct product) external view returns (string memory);\n function collateral() external view returns (ICollateral);\n function collateral(address account, IProduct product) external returns (UFixed18);\n function collateral(IProduct product) external returns (UFixed18);\n function shortfall(IProduct product) external returns (UFixed18);\n function maintenance(address account, IProduct product) external returns (UFixed18);\n function liquidatable(address account, IProduct product) external returns (bool);\n function pre(address account, IProduct product) external returns (PrePosition memory);\n function pre(IProduct product) external returns (PrePosition memory);\n function position(address account, IProduct product) external returns (Position memory);\n function position(IProduct product) external returns (Position memory);\n function userPosition(address account, IProduct product) external returns (PrePosition memory, Position memory);\n function globalPosition(IProduct product) external returns (PrePosition memory, Position memory);\n function price(IProduct product) external returns (Fixed18);\n function fees(IProduct product) external returns (UFixed18 protocolFees, UFixed18 productFees);\n function fees(address account, IProduct[] memory products) external returns (UFixed18);\n function openInterest(address account, IProduct product) external returns (Position memory);\n function openInterest(IProduct product) external returns (Position memory);\n function rate(IProduct product) external returns (Fixed18);\n function dailyRate(IProduct product) external returns (Fixed18);\n function maintenanceRequired(\n address account,\n IProduct product,\n UFixed18 positionSize\n ) external returns (UFixed18);\n function unclaimedIncentiveRewards(address account, IProduct product)\n external\n returns (Token18[] memory tokens, UFixed18[] memory amounts);\n function unclaimedIncentiveRewards(\n address account,\n IProduct product,\n uint256[] calldata programIds\n ) external returns (Token18[] memory tokens, UFixed18[] memory amounts);\n}\n" - }, - "@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/Fixed18.sol\";\n\ninterface IOracleProvider {\n /// @dev A singular oracle version with its corresponding data\n struct OracleVersion {\n /// @dev The iterative version\n uint256 version;\n\n /// @dev the timestamp of the oracle update\n uint256 timestamp;\n\n /// @dev The oracle price of the corresponding version\n Fixed18 price;\n }\n\n function sync() external returns (OracleVersion memory);\n function currentVersion() external view returns (OracleVersion memory);\n function atVersion(uint256 oracleVersion) external view returns (OracleVersion memory);\n}\n" - }, - "contracts/interfaces/IProduct.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\";\nimport \"./IPayoffProvider.sol\";\nimport \"./IParamProvider.sol\";\nimport \"./types/PayoffDefinition.sol\";\nimport \"./types/Position.sol\";\nimport \"./types/PrePosition.sol\";\nimport \"./types/Accumulator.sol\";\n\ninterface IProduct is IPayoffProvider, IParamProvider {\n /// @dev Product Creation parameters\n struct ProductInfo {\n /// @dev name of the product\n string name;\n\n /// @dev symbol of the product\n string symbol;\n\n /// @dev product payoff definition\n PayoffDefinition payoffDefinition;\n\n /// @dev oracle address\n IOracleProvider oracle;\n\n /// @dev product maintenance ratio\n UFixed18 maintenance;\n\n /// @dev product funding fee\n UFixed18 fundingFee;\n\n /// @dev product maker fee\n UFixed18 makerFee;\n\n /// @dev product taker fee\n UFixed18 takerFee;\n\n /// @dev product maker limit\n UFixed18 makerLimit;\n\n /// @dev utulization curve definition\n JumpRateUtilizationCurve utilizationCurve;\n }\n\n event Settle(uint256 preVersion, uint256 toVersion);\n event AccountSettle(address indexed account, uint256 preVersion, uint256 toVersion);\n event MakeOpened(address indexed account, uint256 version, UFixed18 amount);\n event TakeOpened(address indexed account, uint256 version, UFixed18 amount);\n event MakeClosed(address indexed account, uint256 version, UFixed18 amount);\n event TakeClosed(address indexed account, uint256 version, UFixed18 amount);\n event ClosedUpdated(bool indexed newClosed, uint256 version);\n\n error ProductInsufficientLiquidityError(UFixed18 socializationFactor);\n error ProductDoubleSidedError();\n error ProductOverClosedError();\n error ProductInsufficientCollateralError();\n error ProductInLiquidationError();\n error ProductMakerOverLimitError();\n error ProductOracleBootstrappingError();\n error ProductNotOwnerError();\n error ProductInvalidOracle();\n error ProductClosedError();\n\n function name() external view returns (string memory);\n function symbol() external view returns (string memory);\n function initialize(ProductInfo calldata productInfo_) external;\n function settle() external;\n function settleAccount(address account) external;\n function openTake(UFixed18 amount) external;\n function closeTake(UFixed18 amount) external;\n function openMake(UFixed18 amount) external;\n function closeMake(UFixed18 amount) external;\n function closeAll(address account) external;\n function maintenance(address account) external view returns (UFixed18);\n function maintenanceNext(address account) external view returns (UFixed18);\n function isClosed(address account) external view returns (bool);\n function isLiquidating(address account) external view returns (bool);\n function position(address account) external view returns (Position memory);\n function pre(address account) external view returns (PrePosition memory);\n function latestVersion() external view returns (uint256);\n function positionAtVersion(uint256 oracleVersion) external view returns (Position memory);\n function pre() external view returns (PrePosition memory);\n function valueAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\n function shareAtVersion(uint256 oracleVersion) external view returns (Accumulator memory);\n function latestVersion(address account) external view returns (uint256);\n function rate(Position memory position) external view returns (Fixed18);\n function closed() external view returns (bool);\n function updateClosed(bool newClosed) external;\n}\n" - }, - "contracts/interfaces/ICollateral.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/root/number/types/Fixed18.sol\";\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"./IController.sol\";\nimport \"./IProduct.sol\";\n\ninterface ICollateral {\n event Deposit(address indexed user, IProduct indexed product, UFixed18 amount);\n event Withdrawal(address indexed user, IProduct indexed product, UFixed18 amount);\n event AccountSettle(IProduct indexed product, address indexed account, Fixed18 amount, UFixed18 newShortfall);\n event ProductSettle(IProduct indexed product, UFixed18 protocolFee, UFixed18 productFee);\n event Liquidation(address indexed user, IProduct indexed product, address liquidator, UFixed18 fee);\n event ShortfallResolution(IProduct indexed product, UFixed18 amount);\n event FeeClaim(address indexed account, UFixed18 amount);\n\n error CollateralCantLiquidate(UFixed18 totalMaintenance, UFixed18 totalCollateral);\n error CollateralInsufficientCollateralError();\n error CollateralUnderLimitError();\n error CollateralZeroAddressError();\n\n function token() external view returns (Token18);\n function fees(address account) external view returns (UFixed18);\n function initialize(IController controller_) external;\n function depositTo(address account, IProduct product, UFixed18 amount) external;\n function withdrawTo(address account, IProduct product, UFixed18 amount) external;\n function liquidate(address account, IProduct product) external;\n function settleAccount(address account, Fixed18 amount) external;\n function settleProduct(UFixed18 amount) external;\n function collateral(address account, IProduct product) external view returns (UFixed18);\n function collateral(IProduct product) external view returns (UFixed18);\n function shortfall(IProduct product) external view returns (UFixed18);\n function liquidatable(address account, IProduct product) external view returns (bool);\n function liquidatableNext(address account, IProduct product) external view returns (bool);\n function resolveShortfall(IProduct product, UFixed18 amount) external;\n function claimFee() external;\n}\n" - }, - "contracts/interfaces/IController.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\";\nimport \"./ICollateral.sol\";\nimport \"./IIncentivizer.sol\";\nimport \"./IProduct.sol\";\nimport \"./types/PayoffDefinition.sol\";\n\ninterface IController {\n /// @dev Coordinator of a one or many products\n struct Coordinator {\n /// @dev Pending owner of the product, can accept ownership\n address pendingOwner;\n\n /// @dev Owner of the product, allowed to update select parameters\n address owner;\n\n /// @dev Treasury of the product, collects fees\n address treasury;\n }\n\n event CollateralUpdated(ICollateral newCollateral);\n event IncentivizerUpdated(IIncentivizer newIncentivizer);\n event ProductBeaconUpdated(IBeacon newProductBeacon);\n event ProtocolFeeUpdated(UFixed18 newProtocolFee);\n event MinFundingFeeUpdated(UFixed18 newMinFundingFee);\n event LiquidationFeeUpdated(UFixed18 newLiquidationFee);\n event IncentivizationFeeUpdated(UFixed18 newIncentivizationFee);\n event MinCollateralUpdated(UFixed18 newMinCollateral);\n event ProgramsPerProductUpdated(uint256 newProgramsPerProduct);\n event PauserUpdated(address newPauser);\n event PausedUpdated(bool newPaused);\n event CoordinatorPendingOwnerUpdated(uint256 indexed coordinatorId, address newPendingOwner);\n event CoordinatorOwnerUpdated(uint256 indexed coordinatorId, address newOwner);\n event CoordinatorTreasuryUpdated(uint256 indexed coordinatorId, address newTreasury);\n event CoordinatorCreated(uint256 indexed coordinatorId, address owner);\n event ProductCreated(IProduct indexed product, IProduct.ProductInfo productInfo);\n\n error ControllerNoZeroCoordinatorError();\n error ControllerNotPauserError();\n error ControllerNotOwnerError(uint256 controllerId);\n error ControllerNotPendingOwnerError(uint256 controllerId);\n error ControllerInvalidProtocolFeeError();\n error ControllerInvalidMinFundingFeeError();\n error ControllerInvalidLiquidationFeeError();\n error ControllerInvalidIncentivizationFeeError();\n error ControllerNotContractAddressError();\n\n function collateral() external view returns (ICollateral);\n function incentivizer() external view returns (IIncentivizer);\n function productBeacon() external view returns (IBeacon);\n function coordinators(uint256 collateralId) external view returns (Coordinator memory);\n function coordinatorFor(IProduct product) external view returns (uint256);\n function protocolFee() external view returns (UFixed18);\n function minFundingFee() external view returns (UFixed18);\n function liquidationFee() external view returns (UFixed18);\n function incentivizationFee() external view returns (UFixed18);\n function minCollateral() external view returns (UFixed18);\n function programsPerProduct() external view returns (uint256);\n function pauser() external view returns (address);\n function paused() external view returns (bool);\n function initialize(ICollateral collateral_, IIncentivizer incentivizer_, IBeacon productBeacon_) external;\n function createCoordinator() external returns (uint256);\n function updateCoordinatorPendingOwner(uint256 coordinatorId, address newPendingOwner) external;\n function acceptCoordinatorOwner(uint256 coordinatorId) external;\n function updateCoordinatorTreasury(uint256 coordinatorId, address newTreasury) external;\n function createProduct(uint256 coordinatorId, IProduct.ProductInfo calldata productInfo) external returns (IProduct);\n function updateCollateral(ICollateral newCollateral) external;\n function updateIncentivizer(IIncentivizer newIncentivizer) external;\n function updateProductBeacon(IBeacon newProductBeacon) external;\n function updateProtocolFee(UFixed18 newProtocolFee) external;\n function updateMinFundingFee(UFixed18 newMinFundingFee) external;\n function updateLiquidationFee(UFixed18 newLiquidationFee) external;\n function updateIncentivizationFee(UFixed18 newIncentivizationFee) external;\n function updateMinCollateral(UFixed18 newMinCollateral) external;\n function updateProgramsPerProduct(uint256 newProductsPerProduct) external;\n function updatePauser(address newPauser) external;\n function updatePaused(bool newPaused) external;\n function isProduct(IProduct product) external view returns (bool);\n function owner() external view returns (address);\n function owner(uint256 coordinatorId) external view returns (address);\n function owner(IProduct product) external view returns (address);\n function treasury() external view returns (address);\n function treasury(uint256 coordinatorId) external view returns (address);\n function treasury(IProduct product) external view returns (address);\n}\n" - }, - "@equilibria/root/number/types/Fixed18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/SignedMath.sol\";\nimport \"./UFixed18.sol\";\nimport \"./PackedFixed18.sol\";\n\n/// @dev Fixed18 type\ntype Fixed18 is int256;\nusing Fixed18Lib for Fixed18 global;\ntype Fixed18Storage is bytes32;\nusing Fixed18StorageLib for Fixed18Storage global;\n\n/**\n * @title Fixed18Lib\n * @notice Library for the signed fixed-decimal type.\n */\nlibrary Fixed18Lib {\n error Fixed18OverflowError(uint256 value);\n error Fixed18PackingOverflowError(int256 value);\n error Fixed18PackingUnderflowError(int256 value);\n\n int256 private constant BASE = 1e18;\n Fixed18 public constant ZERO = Fixed18.wrap(0);\n Fixed18 public constant ONE = Fixed18.wrap(BASE);\n Fixed18 public constant NEG_ONE = Fixed18.wrap(-1 * BASE);\n Fixed18 public constant MAX = Fixed18.wrap(type(int256).max);\n Fixed18 public constant MIN = Fixed18.wrap(type(int256).min);\n\n /**\n * @notice Creates a signed fixed-decimal from an unsigned fixed-decimal\n * @param a Unsigned fixed-decimal\n * @return New signed fixed-decimal\n */\n function from(UFixed18 a) internal pure returns (Fixed18) {\n uint256 value = UFixed18.unwrap(a);\n if (value > uint256(type(int256).max)) revert Fixed18OverflowError(value);\n return Fixed18.wrap(int256(value));\n }\n\n /**\n * @notice Creates a signed fixed-decimal from a sign and an unsigned fixed-decimal\n * @param s Sign\n * @param m Unsigned fixed-decimal magnitude\n * @return New signed fixed-decimal\n */\n function from(int256 s, UFixed18 m) internal pure returns (Fixed18) {\n if (s > 0) return from(m);\n if (s < 0) return Fixed18.wrap(-1 * Fixed18.unwrap(from(m)));\n return ZERO;\n }\n\n /**\n * @notice Creates a signed fixed-decimal from a signed integer\n * @param a Signed number\n * @return New signed fixed-decimal\n */\n function from(int256 a) internal pure returns (Fixed18) {\n return Fixed18.wrap(a * BASE);\n }\n\n /**\n * @notice Creates a packed signed fixed-decimal from an signed fixed-decimal\n * @param a signed fixed-decimal\n * @return New packed signed fixed-decimal\n */\n function pack(Fixed18 a) internal pure returns (PackedFixed18) {\n int256 value = Fixed18.unwrap(a);\n if (value > type(int128).max) revert Fixed18PackingOverflowError(value);\n if (value < type(int128).min) revert Fixed18PackingUnderflowError(value);\n return PackedFixed18.wrap(int128(value));\n }\n\n /**\n * @notice Returns whether the signed fixed-decimal is equal to zero.\n * @param a Signed fixed-decimal\n * @return Whether the signed fixed-decimal is zero.\n */\n function isZero(Fixed18 a) internal pure returns (bool) {\n return Fixed18.unwrap(a) == 0;\n }\n\n /**\n * @notice Adds two signed fixed-decimals `a` and `b` together\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Resulting summed signed fixed-decimal\n */\n function add(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) + Fixed18.unwrap(b));\n }\n\n /**\n * @notice Subtracts signed fixed-decimal `b` from `a`\n * @param a Signed fixed-decimal to subtract from\n * @param b Signed fixed-decimal to subtract\n * @return Resulting subtracted signed fixed-decimal\n */\n function sub(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) - Fixed18.unwrap(b));\n }\n\n /**\n * @notice Multiplies two signed fixed-decimals `a` and `b` together\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Resulting multiplied signed fixed-decimal\n */\n function mul(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / BASE);\n }\n\n /**\n * @notice Divides signed fixed-decimal `a` by `b`\n * @param a Signed fixed-decimal to divide\n * @param b Signed fixed-decimal to divide by\n * @return Resulting divided signed fixed-decimal\n */\n function div(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) * BASE / Fixed18.unwrap(b));\n }\n\n /**\n * @notice Divides unsigned fixed-decimal `a` by `b`\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0`, `MAX` for `n/0`, and `MIN` for `-n/0`.\n * @param a Unsigned fixed-decimal to divide\n * @param b Unsigned fixed-decimal to divide by\n * @return Resulting divided unsigned fixed-decimal\n */\n function unsafeDiv(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n if (isZero(b)) {\n if (gt(a, ZERO)) return MAX;\n if (lt(a, ZERO)) return MIN;\n return ONE;\n } else {\n return div(a, b);\n }\n }\n\n /**\n * @notice Computes a * b / c without loss of precision due to BASE conversion\n * @param a First signed fixed-decimal\n * @param b Signed number to multiply by\n * @param c Signed number to divide by\n * @return Resulting computation\n */\n function muldiv(Fixed18 a, int256 b, int256 c) internal pure returns (Fixed18) {\n return muldiv(a, Fixed18.wrap(b), Fixed18.wrap(c));\n }\n\n /**\n * @notice Computes a * b / c without loss of precision due to BASE conversion\n * @param a First signed fixed-decimal\n * @param b Signed fixed-decimal to multiply by\n * @param c Signed fixed-decimal to divide by\n * @return Resulting computation\n */\n function muldiv(Fixed18 a, Fixed18 b, Fixed18 c) internal pure returns (Fixed18) {\n return Fixed18.wrap(Fixed18.unwrap(a) * Fixed18.unwrap(b) / Fixed18.unwrap(c));\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is equal to `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is equal to `b`\n */\n function eq(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return compare(a, b) == 1;\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is greater than `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is greater than `b`\n */\n function gt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return compare(a, b) == 2;\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is less than `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is less than `b`\n */\n function lt(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return compare(a, b) == 0;\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is greater than or equal to `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is greater than or equal to `b`\n */\n function gte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return gt(a, b) || eq(a, b);\n }\n\n /**\n * @notice Returns whether signed fixed-decimal `a` is less than or equal to `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Whether `a` is less than or equal to `b`\n */\n function lte(Fixed18 a, Fixed18 b) internal pure returns (bool) {\n return lt(a, b) || eq(a, b);\n }\n\n /**\n * @notice Compares the signed fixed-decimals `a` and `b`\n * @dev Returns: 2 for greater than\n * 1 for equal to\n * 0 for less than\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Compare result of `a` and `b`\n */\n function compare(Fixed18 a, Fixed18 b) internal pure returns (uint256) {\n (int256 au, int256 bu) = (Fixed18.unwrap(a), Fixed18.unwrap(b));\n if (au > bu) return 2;\n if (au < bu) return 0;\n return 1;\n }\n\n /**\n * @notice Returns a signed fixed-decimal representing the ratio of `a` over `b`\n * @param a First signed number\n * @param b Second signed number\n * @return Ratio of `a` over `b`\n */\n function ratio(int256 a, int256 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(a * BASE / b);\n }\n\n /**\n * @notice Returns the minimum of signed fixed-decimals `a` and `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Minimum of `a` and `b`\n */\n function min(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(SignedMath.min(Fixed18.unwrap(a), Fixed18.unwrap(b)));\n }\n\n /**\n * @notice Returns the maximum of signed fixed-decimals `a` and `b`\n * @param a First signed fixed-decimal\n * @param b Second signed fixed-decimal\n * @return Maximum of `a` and `b`\n */\n function max(Fixed18 a, Fixed18 b) internal pure returns (Fixed18) {\n return Fixed18.wrap(SignedMath.max(Fixed18.unwrap(a), Fixed18.unwrap(b)));\n }\n\n /**\n * @notice Converts the signed fixed-decimal into an integer, truncating any decimal portion\n * @param a Signed fixed-decimal\n * @return Truncated signed number\n */\n function truncate(Fixed18 a) internal pure returns (int256) {\n return Fixed18.unwrap(a) / BASE;\n }\n\n /**\n * @notice Returns the sign of the signed fixed-decimal\n * @dev Returns: -1 for negative\n * 0 for zero\n * 1 for positive\n * @param a Signed fixed-decimal\n * @return Sign of the signed fixed-decimal\n */\n function sign(Fixed18 a) internal pure returns (int256) {\n if (Fixed18.unwrap(a) > 0) return 1;\n if (Fixed18.unwrap(a) < 0) return -1;\n return 0;\n }\n\n /**\n * @notice Returns the absolute value of the signed fixed-decimal\n * @param a Signed fixed-decimal\n * @return Absolute value of the signed fixed-decimal\n */\n function abs(Fixed18 a) internal pure returns (UFixed18) {\n return UFixed18.wrap(SignedMath.abs(Fixed18.unwrap(a)));\n }\n}\n\nlibrary Fixed18StorageLib {\n function read(Fixed18Storage self) internal view returns (Fixed18 value) {\n assembly {\n value := sload(self)\n }\n }\n\n function store(Fixed18Storage self, Fixed18 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/SignedMath.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n /**\n * @dev Returns the largest of two signed numbers.\n */\n function max(int256 a, int256 b) internal pure returns (int256) {\n return 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 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 // must be unchecked in order to support `n = type(int256).min`\n return uint256(n >= 0 ? n : -n);\n }\n }\n}\n" - }, - "@equilibria/root/number/types/UFixed18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"./Fixed18.sol\";\nimport \"./PackedUFixed18.sol\";\n\n/// @dev UFixed18 type\ntype UFixed18 is uint256;\nusing UFixed18Lib for UFixed18 global;\ntype UFixed18Storage is bytes32;\nusing UFixed18StorageLib for UFixed18Storage global;\n\n/**\n * @title UFixed18Lib\n * @notice Library for the unsigned fixed-decimal type.\n */\nlibrary UFixed18Lib {\n error UFixed18UnderflowError(int256 value);\n error UFixed18PackingOverflowError(uint256 value);\n\n uint256 private constant BASE = 1e18;\n UFixed18 public constant ZERO = UFixed18.wrap(0);\n UFixed18 public constant ONE = UFixed18.wrap(BASE);\n UFixed18 public constant MAX = UFixed18.wrap(type(uint256).max);\n\n /**\n * @notice Creates a unsigned fixed-decimal from a signed fixed-decimal\n * @param a Signed fixed-decimal\n * @return New unsigned fixed-decimal\n */\n function from(Fixed18 a) internal pure returns (UFixed18) {\n int256 value = Fixed18.unwrap(a);\n if (value < 0) revert UFixed18UnderflowError(value);\n return UFixed18.wrap(uint256(value));\n }\n\n /**\n * @notice Creates a unsigned fixed-decimal from a unsigned integer\n * @param a Unsigned number\n * @return New unsigned fixed-decimal\n */\n function from(uint256 a) internal pure returns (UFixed18) {\n return UFixed18.wrap(a * BASE);\n }\n\n /**\n * @notice Creates a packed unsigned fixed-decimal from an unsigned fixed-decimal\n * @param a unsigned fixed-decimal\n * @return New packed unsigned fixed-decimal\n */\n function pack(UFixed18 a) internal pure returns (PackedUFixed18) {\n uint256 value = UFixed18.unwrap(a);\n if (value > type(uint128).max) revert UFixed18PackingOverflowError(value);\n return PackedUFixed18.wrap(uint128(value));\n }\n\n /**\n * @notice Returns whether the unsigned fixed-decimal is equal to zero.\n * @param a Unsigned fixed-decimal\n * @return Whether the unsigned fixed-decimal is zero.\n */\n function isZero(UFixed18 a) internal pure returns (bool) {\n return UFixed18.unwrap(a) == 0;\n }\n\n /**\n * @notice Adds two unsigned fixed-decimals `a` and `b` together\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Resulting summed unsigned fixed-decimal\n */\n function add(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) + UFixed18.unwrap(b));\n }\n\n /**\n * @notice Subtracts unsigned fixed-decimal `b` from `a`\n * @param a Unsigned fixed-decimal to subtract from\n * @param b Unsigned fixed-decimal to subtract\n * @return Resulting subtracted unsigned fixed-decimal\n */\n function sub(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) - UFixed18.unwrap(b));\n }\n\n /**\n * @notice Multiplies two unsigned fixed-decimals `a` and `b` together\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Resulting multiplied unsigned fixed-decimal\n */\n function mul(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / BASE);\n }\n\n /**\n * @notice Divides unsigned fixed-decimal `a` by `b`\n * @param a Unsigned fixed-decimal to divide\n * @param b Unsigned fixed-decimal to divide by\n * @return Resulting divided unsigned fixed-decimal\n */\n function div(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) * BASE / UFixed18.unwrap(b));\n }\n\n /**\n * @notice Divides unsigned fixed-decimal `a` by `b`\n * @dev Does not revert on divide-by-0, instead returns `ONE` for `0/0` and `MAX` for `n/0`.\n * @param a Unsigned fixed-decimal to divide\n * @param b Unsigned fixed-decimal to divide by\n * @return Resulting divided unsigned fixed-decimal\n */\n function unsafeDiv(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n if (isZero(b)) {\n return isZero(a) ? ONE : MAX;\n } else {\n return div(a, b);\n }\n }\n\n /**\n * @notice Computes a * b / c without loss of precision due to BASE conversion\n * @param a First unsigned fixed-decimal\n * @param b Unsigned number to multiply by\n * @param c Unsigned number to divide by\n * @return Resulting computation\n */\n function muldiv(UFixed18 a, uint256 b, uint256 c) internal pure returns (UFixed18) {\n return muldiv(a, UFixed18.wrap(b), UFixed18.wrap(c));\n }\n\n /**\n * @notice Computes a * b / c without loss of precision due to BASE conversion\n * @param a First unsigned fixed-decimal\n * @param b Unsigned fixed-decimal to multiply by\n * @param c Unsigned fixed-decimal to divide by\n * @return Resulting computation\n */\n function muldiv(UFixed18 a, UFixed18 b, UFixed18 c) internal pure returns (UFixed18) {\n return UFixed18.wrap(UFixed18.unwrap(a) * UFixed18.unwrap(b) / UFixed18.unwrap(c));\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is equal to `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is equal to `b`\n */\n function eq(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return compare(a, b) == 1;\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is greater than `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is greater than `b`\n */\n function gt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return compare(a, b) == 2;\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is less than `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is less than `b`\n */\n function lt(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return compare(a, b) == 0;\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is greater than or equal to `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is greater than or equal to `b`\n */\n function gte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return gt(a, b) || eq(a, b);\n }\n\n /**\n * @notice Returns whether unsigned fixed-decimal `a` is less than or equal to `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Whether `a` is less than or equal to `b`\n */\n function lte(UFixed18 a, UFixed18 b) internal pure returns (bool) {\n return lt(a, b) || eq(a, b);\n }\n\n /**\n * @notice Compares the unsigned fixed-decimals `a` and `b`\n * @dev Returns: 2 for greater than\n * 1 for equal to\n * 0 for less than\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Compare result of `a` and `b`\n */\n function compare(UFixed18 a, UFixed18 b) internal pure returns (uint256) {\n (uint256 au, uint256 bu) = (UFixed18.unwrap(a), UFixed18.unwrap(b));\n if (au > bu) return 2;\n if (au < bu) return 0;\n return 1;\n }\n\n /**\n * @notice Returns a unsigned fixed-decimal representing the ratio of `a` over `b`\n * @param a First unsigned number\n * @param b Second unsigned number\n * @return Ratio of `a` over `b`\n */\n function ratio(uint256 a, uint256 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(a * BASE / b);\n }\n\n /**\n * @notice Returns the minimum of unsigned fixed-decimals `a` and `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Minimum of `a` and `b`\n */\n function min(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(Math.min(UFixed18.unwrap(a), UFixed18.unwrap(b)));\n }\n\n /**\n * @notice Returns the maximum of unsigned fixed-decimals `a` and `b`\n * @param a First unsigned fixed-decimal\n * @param b Second unsigned fixed-decimal\n * @return Maximum of `a` and `b`\n */\n function max(UFixed18 a, UFixed18 b) internal pure returns (UFixed18) {\n return UFixed18.wrap(Math.max(UFixed18.unwrap(a), UFixed18.unwrap(b)));\n }\n\n /**\n * @notice Converts the unsigned fixed-decimal into an integer, truncating any decimal portion\n * @param a Unsigned fixed-decimal\n * @return Truncated unsigned number\n */\n function truncate(UFixed18 a) internal pure returns (uint256) {\n return UFixed18.unwrap(a) / BASE;\n }\n}\n\nlibrary UFixed18StorageLib {\n function read(UFixed18Storage self) internal view returns (UFixed18 value) {\n assembly {\n value := sload(self)\n }\n }\n\n function store(UFixed18Storage self, UFixed18 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "@equilibria/root/number/types/PackedFixed18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"./Fixed18.sol\";\n\n/// @dev PackedFixed18 type\ntype PackedFixed18 is int128;\nusing PackedFixed18Lib for PackedFixed18 global;\n\n/**\n * @title PackedFixed18Lib\n * @dev A packed version of the Fixed18 which takes up half the storage space (two PackedFixed18 can be packed\n * into a single slot). Only valid within the range -1.7014118e+20 <= x <= 1.7014118e+20.\n * @notice Library for the packed signed fixed-decimal type.\n */\nlibrary PackedFixed18Lib {\n PackedFixed18 public constant MAX = PackedFixed18.wrap(type(int128).max);\n PackedFixed18 public constant MIN = PackedFixed18.wrap(type(int128).min);\n\n /**\n * @notice Creates an unpacked signed fixed-decimal from a packed signed fixed-decimal\n * @param self packed signed fixed-decimal\n * @return New unpacked signed fixed-decimal\n */\n function unpack(PackedFixed18 self) internal pure returns (Fixed18) {\n return Fixed18.wrap(int256(PackedFixed18.unwrap(self)));\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return 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 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 up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a / b + (a % b == 0 ? 0 : 1);\n }\n}\n" - }, - "@equilibria/root/number/types/PackedUFixed18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"./UFixed18.sol\";\n\n/// @dev PackedUFixed18 type\ntype PackedUFixed18 is uint128;\nusing PackedUFixed18Lib for PackedUFixed18 global;\n\n/**\n * @title PackedUFixed18Lib\n * @dev A packed version of the UFixed18 which takes up half the storage space (two PackedUFixed18 can be packed\n * into a single slot). Only valid within the range 0 <= x <= 3.4028237e+20.\n * @notice Library for the packed unsigned fixed-decimal type.\n */\nlibrary PackedUFixed18Lib {\n PackedUFixed18 public constant MAX = PackedUFixed18.wrap(type(uint128).max);\n\n /**\n * @notice Creates an unpacked unsigned fixed-decimal from a packed unsigned fixed-decimal\n * @param self packed unsigned fixed-decimal\n * @return New unpacked unsigned fixed-decimal\n */\n function unpack(PackedUFixed18 self) internal pure returns (UFixed18) {\n return UFixed18.wrap(uint256(PackedUFixed18.unwrap(self)));\n }\n}\n" - }, - "@equilibria/root/curve/types/JumpRateUtilizationCurve.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"../CurveMath.sol\";\nimport \"../../number/types/PackedUFixed18.sol\";\nimport \"../../number/types/PackedFixed18.sol\";\n\n/// @dev JumpRateUtilizationCurve type\nstruct JumpRateUtilizationCurve {\n PackedFixed18 minRate;\n PackedFixed18 maxRate;\n PackedFixed18 targetRate;\n PackedUFixed18 targetUtilization;\n}\nusing JumpRateUtilizationCurveLib for JumpRateUtilizationCurve global;\ntype JumpRateUtilizationCurveStorage is bytes32;\nusing JumpRateUtilizationCurveStorageLib for JumpRateUtilizationCurveStorage global;\n\n/**\n * @title JumpRateUtilizationCurveLib\n * @notice Library for the Jump Rate utilization curve type\n */\nlibrary JumpRateUtilizationCurveLib {\n /**\n * @notice Computes the corresponding rate for a utilization ratio\n * @param utilization The utilization ratio\n * @return The corresponding rate\n */\n function compute(JumpRateUtilizationCurve memory self, UFixed18 utilization) internal pure returns (Fixed18) {\n UFixed18 targetUtilization = self.targetUtilization.unpack();\n if (utilization.lt(targetUtilization)) {\n return CurveMath.linearInterpolation(\n UFixed18Lib.ZERO,\n self.minRate.unpack(),\n targetUtilization,\n self.targetRate.unpack(),\n utilization\n );\n }\n if (utilization.lt(UFixed18Lib.ONE)) {\n return CurveMath.linearInterpolation(\n targetUtilization,\n self.targetRate.unpack(),\n UFixed18Lib.ONE,\n self.maxRate.unpack(),\n utilization\n );\n }\n return self.maxRate.unpack();\n }\n}\n\nlibrary JumpRateUtilizationCurveStorageLib {\n function read(JumpRateUtilizationCurveStorage self) internal view returns (JumpRateUtilizationCurve memory) {\n return _storagePointer(self);\n }\n\n function store(JumpRateUtilizationCurveStorage self, JumpRateUtilizationCurve memory value) internal {\n JumpRateUtilizationCurve storage storagePointer = _storagePointer(self);\n\n storagePointer.minRate = value.minRate;\n storagePointer.maxRate = value.maxRate;\n storagePointer.targetRate = value.targetRate;\n storagePointer.targetUtilization = value.targetUtilization;\n }\n\n function _storagePointer(JumpRateUtilizationCurveStorage self)\n private pure returns (JumpRateUtilizationCurve storage pointer) {\n assembly { pointer.slot := self }\n }\n}" - }, - "contracts/interfaces/IPayoffProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/Fixed18.sol\";\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"./types/PayoffDefinition.sol\";\n\ninterface IPayoffProvider {\n error PayoffProviderInvalidOracle();\n error PayoffProviderInvalidPayoffDefinitionError();\n\n function oracle() external view returns (IOracleProvider);\n function payoffDefinition() external view returns (PayoffDefinition memory);\n function currentVersion() external view returns (IOracleProvider.OracleVersion memory);\n function atVersion(uint256 oracleVersion) external view returns (IOracleProvider.OracleVersion memory);\n}\n" - }, - "contracts/interfaces/IParamProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/root/curve/types/JumpRateUtilizationCurve.sol\";\n\ninterface IParamProvider {\n event MaintenanceUpdated(UFixed18 newMaintenance);\n event FundingFeeUpdated(UFixed18 newFundingFee);\n event MakerFeeUpdated(UFixed18 newMakerFee);\n event TakerFeeUpdated(UFixed18 newTakerFee);\n event MakerLimitUpdated(UFixed18 newMakerLimit);\n event JumpRateUtilizationCurveUpdated(\n Fixed18 minRate,\n Fixed18 maxRate,\n Fixed18 targetRate,\n UFixed18 targetUtilization\n );\n\n error ParamProviderInvalidMakerFee();\n error ParamProviderInvalidTakerFee();\n error ParamProviderInvalidFundingFee();\n \n function maintenance() external view returns (UFixed18);\n function updateMaintenance(UFixed18 newMaintenance) external;\n function fundingFee() external view returns (UFixed18);\n function updateFundingFee(UFixed18 newFundingFee) external;\n function makerFee() external view returns (UFixed18);\n function updateMakerFee(UFixed18 newMakerFee) external;\n function takerFee() external view returns (UFixed18);\n function updateTakerFee(UFixed18 newTakerFee) external;\n function makerLimit() external view returns (UFixed18);\n function updateMakerLimit(UFixed18 newMakerLimit) external;\n function utilizationCurve() external view returns (JumpRateUtilizationCurve memory);\n function updateUtilizationCurve(JumpRateUtilizationCurve memory newUtilizationCurve) external;\n}\n" - }, - "contracts/interfaces/types/PayoffDefinition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.15;\n\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"../../interfaces/IContractPayoffProvider.sol\";\n\n/// @dev PayoffDefinition tyoe\nstruct PayoffDefinition {\n PayoffDefinitionLib.PayoffType payoffType;\n PayoffDefinitionLib.PayoffDirection payoffDirection;\n bytes30 data;\n}\nusing PayoffDefinitionLib for PayoffDefinition global;\ntype PayoffDefinitionStorage is bytes32;\nusing PayoffDefinitionStorageLib for PayoffDefinitionStorage global;\n\n/**\n * @title PayoffDefinitionLib\n * @dev Library that surfaces logic for PayoffDefinition type functionality\n * @notice Library for the PayoffDefinition type. Performs validity and price transformation\n based on the payoff definition type.\n */\nlibrary PayoffDefinitionLib {\n using Address for address;\n\n error PayoffDefinitionUnsupportedTransform(PayoffType payoffType, PayoffDirection payoffDirection);\n error PayoffDefinitionNotContract(PayoffType payoffType, bytes30 data);\n\n /// @dev Payoff function type enum\n enum PayoffType { PASSTHROUGH, CONTRACT }\n enum PayoffDirection { LONG, SHORT }\n\n /**\n * @notice Checks validity of the payoff definition\n * @param self a payoff definition\n * @return Whether the payoff definition is valid for it's given type\n */\n function valid(PayoffDefinition memory self) internal view returns (bool) {\n if (self.payoffType == PayoffType.CONTRACT) return address(_providerContract(self)).isContract();\n\n // All other payoff types should have no data\n return uint(bytes32(self.data)) == 0;\n }\n\n /**\n * @notice Transforms a price based on the payoff definition\n * @param self a payoff definition\n * @param price raw oracle price\n * @return Price transformed by the payoff definition function\n */\n function transform(\n PayoffDefinition memory self,\n Fixed18 price\n ) internal view returns (Fixed18) {\n PayoffType payoffType = self.payoffType;\n PayoffDirection payoffDirection = self.payoffDirection;\n Fixed18 transformedPrice;\n\n // First get the price depending on the type\n if (payoffType == PayoffType.PASSTHROUGH) transformedPrice = price;\n else if (payoffType == PayoffType.CONTRACT) transformedPrice = _payoffFromContract(self, price);\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\n\n // Then transform it depending on the direction flag\n if (self.payoffDirection == PayoffDirection.LONG) return transformedPrice;\n else if (self.payoffDirection == PayoffDirection.SHORT) return transformedPrice.mul(Fixed18Lib.NEG_ONE);\n else revert PayoffDefinitionUnsupportedTransform(payoffType, payoffDirection);\n }\n\n /**\n * @notice Parses the data field into an address\n * @dev Reverts if payoffType is not CONTRACT\n * @param self a payoff definition\n * @return IContractPayoffProvider address\n */\n function _providerContract(\n PayoffDefinition memory self\n ) private pure returns (IContractPayoffProvider) {\n if (self.payoffType != PayoffType.CONTRACT) revert PayoffDefinitionNotContract(self.payoffType, self.data);\n // Shift to pull the last 20 bytes, then cast to an address\n return IContractPayoffProvider(address(bytes20(self.data << 80)));\n }\n\n /**\n * @notice Performs a price transformation by calling the underlying payoff contract\n * @param self a payoff definition\n * @param price raw oracle price\n * @return Price transformed by the payoff definition function on the contract\n */\n function _payoffFromContract(\n PayoffDefinition memory self,\n Fixed18 price\n ) private view returns (Fixed18) {\n bytes memory ret = address(_providerContract(self)).functionStaticCall(\n abi.encodeCall(IContractPayoffProvider.payoff, price)\n );\n return Fixed18.wrap(abi.decode(ret, (int256)));\n }\n}\n\n/**\n * @title PayoffDefinitionStorageLib\n * @notice Library that surfaces storage read and writes for the PayoffDefinition type\n */\nlibrary PayoffDefinitionStorageLib {\n function read(PayoffDefinitionStorage self) internal view returns (PayoffDefinition memory) {\n return _storagePointer(self);\n }\n\n function store(PayoffDefinitionStorage self, PayoffDefinition memory value) internal {\n PayoffDefinition storage storagePointer = _storagePointer(self);\n\n storagePointer.payoffType = value.payoffType;\n storagePointer.payoffDirection = value.payoffDirection;\n storagePointer.data = value.data;\n }\n\n function _storagePointer(\n PayoffDefinitionStorage self\n ) private pure returns (PayoffDefinition storage pointer) {\n assembly { pointer.slot := self }\n }\n}\n" - }, - "contracts/interfaces/types/Position.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"../IProduct.sol\";\nimport \"./Accumulator.sol\";\nimport \"./PrePosition.sol\";\nimport \"./PackedPosition.sol\";\n\n/// @dev Position type\nstruct Position {\n /// @dev Quantity of the maker position\n UFixed18 maker;\n /// @dev Quantity of the taker position\n UFixed18 taker;\n}\nusing PositionLib for Position global;\n\n/**\n * @title PositionLib\n * @notice Library that surfaces math and settlement computations for the Position type.\n * @dev Positions track the current quantity of the account's maker and taker positions respectively\n * denominated as a unit of the product's payoff function.\n */\nlibrary PositionLib {\n /**\n * @notice Creates a packed position from an position\n * @param self A position\n * @return New packed position\n */\n function pack(Position memory self) internal pure returns (PackedPosition memory) {\n return PackedPosition({maker: self.maker.pack(), taker: self.taker.pack()});\n }\n\n /**\n * @notice Returns whether the position is fully empty\n * @param self A position\n * @return Whether the position is empty\n */\n function isEmpty(Position memory self) internal pure returns (bool) {\n return self.maker.isZero() && self.taker.isZero();\n }\n\n /**\n * @notice Adds position `a` and `b` together, returning the result\n * @param a The first position to sum\n * @param b The second position to sum\n * @return Resulting summed position\n */\n function add(Position memory a, Position memory b) internal pure returns (Position memory) {\n return Position({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\n }\n\n /**\n * @notice Subtracts position `b` from `a`, returning the result\n * @param a The position to subtract from\n * @param b The position to subtract\n * @return Resulting subtracted position\n */\n function sub(Position memory a, Position memory b) internal pure returns (Position memory) {\n return Position({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\n }\n\n /**\n * @notice Multiplies position `self` by accumulator `accumulator` and returns the resulting accumulator\n * @param self The Position to operate on\n * @param accumulator The accumulator to multiply by\n * @return Resulting multiplied accumulator\n */\n function mul(Position memory self, Accumulator memory accumulator) internal pure returns (Accumulator memory) {\n return Accumulator({\n maker: Fixed18Lib.from(self.maker).mul(accumulator.maker),\n taker: Fixed18Lib.from(self.taker).mul(accumulator.taker)\n });\n }\n\n /**\n * @notice Scales position `self` by fixed-decimal `scale` and returns the resulting position\n * @param self The Position to operate on\n * @param scale The Fixed-decimal to scale by\n * @return Resulting scaled position\n */\n function mul(Position memory self, UFixed18 scale) internal pure returns (Position memory) {\n return Position({maker: self.maker.mul(scale), taker: self.taker.mul(scale)});\n }\n\n /**\n * @notice Divides position `self` by `b` and returns the resulting accumulator\n * @param self The Position to operate on\n * @param b The number to divide by\n * @return Resulting divided accumulator\n */\n function div(Position memory self, uint256 b) internal pure returns (Accumulator memory) {\n return Accumulator({\n maker: Fixed18Lib.from(self.maker).div(Fixed18Lib.from(UFixed18Lib.from(b))),\n taker: Fixed18Lib.from(self.taker).div(Fixed18Lib.from(UFixed18Lib.from(b)))\n });\n }\n\n /**\n * @notice Returns the maximum of `self`'s maker and taker values\n * @param self The struct to operate on\n * @return Resulting maximum value\n */\n function max(Position memory self) internal pure returns (UFixed18) {\n return UFixed18Lib.max(self.maker, self.taker);\n }\n\n /**\n * @notice Sums the maker and taker together from a single position\n * @param self The struct to operate on\n * @return The sum of its maker and taker\n */\n function sum(Position memory self) internal pure returns (UFixed18) {\n return self.maker.add(self.taker);\n }\n\n /**\n * @notice Computes the next position after the pending-settlement position delta is included\n * @param self The current Position\n * @param pre The pending-settlement position delta\n * @return Next Position\n */\n function next(Position memory self, PrePosition memory pre) internal pure returns (Position memory) {\n return sub(add(self, pre.openPosition), pre.closePosition);\n }\n\n /**\n * @notice Returns the settled position at oracle version `toOracleVersion`\n * @dev Checks if a new position is ready to be settled based on the provided `toOracleVersion`\n * and `pre` and returns accordingly\n * @param self The current Position\n * @param pre The pending-settlement position delta\n * @param toOracleVersion The oracle version to settle to\n * @return Settled position at oracle version\n * @return Fee accrued from opening or closing the position\n * @return Whether a new position was settled\n */\n function settled(\n Position memory self,\n PrePosition memory pre,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal view returns (Position memory, UFixed18, bool) {\n return pre.canSettle(toOracleVersion) ? (next(self, pre), pre.computeFee(toOracleVersion), true) : (self, UFixed18Lib.ZERO, false);\n }\n\n /**\n * @notice Returns the socialization factor for the current position\n * @dev Socialization account for the case where `taker` > `maker` temporarily due to a liquidation\n * on the maker side. This dampens the taker's exposure pro-rata to ensure that the maker side\n * is never exposed over 1 x short.\n * @param self The Position to operate on\n * @return Socialization factor\n */\n function socializationFactor(Position memory self) internal pure returns (UFixed18) {\n return self.taker.isZero() ? UFixed18Lib.ONE : UFixed18Lib.min(UFixed18Lib.ONE, self.maker.div(self.taker));\n }\n}\n" - }, - "contracts/interfaces/types/PrePosition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"./Position.sol\";\nimport \"../IProduct.sol\";\n\n/// @dev PrePosition type\nstruct PrePosition {\n /// @dev Oracle version at which the new position delta was recorded\n uint256 oracleVersion;\n\n /// @dev Size of position to open at oracle version\n Position openPosition;\n\n /// @dev Size of position to close at oracle version\n Position closePosition;\n}\nusing PrePositionLib for PrePosition global;\n\n/**\n * @title PrePositionLib\n * @notice Library that manages a pre-settlement position delta.\n * @dev PrePositions track the currently awaiting-settlement deltas to a settled Position. These are\n * Primarily necessary to introduce lag into the settlement system such that oracle lag cannot be\n * gamed to a user's advantage. When a user opens or closes a new position, it sits as a PrePosition\n * for one oracle version until it's settle into the Position, making it then effective. PrePositions\n * are automatically settled at the correct oracle version even if a flywheel call doesn't happen until\n * several version into the future by using the historical version lookups in the corresponding \"Versioned\"\n * global state types.\n */\nlibrary PrePositionLib {\n /**\n * @notice Returns whether there is no pending-settlement position delta\n * @dev Can be \"empty\" even with a non-zero oracleVersion if a position is opened and\n * closed in the same version netting out to a zero position delta\n * @param self The struct to operate on\n * @return Whether the pending-settlement position delta is empty\n */\n function isEmpty(PrePosition memory self) internal pure returns (bool) {\n return self.openPosition.isEmpty() && self.closePosition.isEmpty();\n }\n\n /**\n * @notice Increments the maker side of the open position delta\n * @dev Nets out open and close deltas to minimize the size of each\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @param amount The position amount to open\n */\n function openMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\n self.openPosition.maker = self.openPosition.maker.add(amount);\n self.oracleVersion = currentVersion;\n _netMake(self);\n }\n\n /**\n * @notice Increments the maker side of the close position delta\n * @dev Nets out open and close deltas to minimize the size of each\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @param amount The maker position amount to close\n */\n function closeMake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\n self.closePosition.maker = self.closePosition.maker.add(amount);\n self.oracleVersion = currentVersion;\n _netMake(self);\n }\n\n /**\n * @notice Increments the taker side of the open position delta\n * @dev Nets out open and close deltas to minimize the size of each\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @param amount The taker position amount to open\n */\n function openTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\n self.openPosition.taker = self.openPosition.taker.add(amount);\n self.oracleVersion = currentVersion;\n _netTake(self);\n }\n\n /**\n * @notice Increments the taker side of the close position delta\n * @dev Nets out open and close deltas to minimize the size of each\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @param amount The taker position amount to close\n */\n function closeTake(PrePosition storage self, uint256 currentVersion, UFixed18 amount) internal {\n self.closePosition.taker = self.closePosition.taker.add(amount);\n self.oracleVersion = currentVersion;\n _netTake(self);\n }\n\n /**\n * @notice Nets out the open and close on the maker side of the position delta\n * @param self The struct to operate on\n */\n function _netMake(PrePosition storage self) private {\n if (self.openPosition.maker.gt(self.closePosition.maker)) {\n self.openPosition.maker = self.openPosition.maker.sub(self.closePosition.maker);\n self.closePosition.maker = UFixed18Lib.ZERO;\n } else {\n self.closePosition.maker = self.closePosition.maker.sub(self.openPosition.maker);\n self.openPosition.maker = UFixed18Lib.ZERO;\n }\n }\n\n /**\n * @notice Nets out the open and close on the taker side of the position delta\n * @param self The struct to operate on\n */\n function _netTake(PrePosition storage self) private {\n if (self.openPosition.taker.gt(self.closePosition.taker)) {\n self.openPosition.taker = self.openPosition.taker.sub(self.closePosition.taker);\n self.closePosition.taker = UFixed18Lib.ZERO;\n } else {\n self.closePosition.taker = self.closePosition.taker.sub(self.openPosition.taker);\n self.openPosition.taker = UFixed18Lib.ZERO;\n }\n }\n\n /**\n * @notice Returns whether the the pending position delta can be settled at version `toOracleVersion`\n * @dev Pending-settlement positions deltas can be settled (1) oracle version after they are recorded\n * @param self The struct to operate on\n * @param toOracleVersion The potential oracle version to settle\n * @return Whether the position delta can be settled\n */\n function canSettle(\n PrePosition memory self,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal pure returns (bool) {\n return !isEmpty(self) && toOracleVersion.version > self.oracleVersion;\n }\n\n /**\n * @notice Computes the fee incurred for opening or closing the pending-settlement position\n * @dev Must be called from a valid product to get the proper fee amounts\n * @param self The struct to operate on\n * @param toOracleVersion The oracle version at which settlement takes place\n * @return positionFee The maker / taker fee incurred\n */\n function computeFee(\n PrePosition memory self,\n IOracleProvider.OracleVersion memory toOracleVersion\n ) internal view returns (UFixed18) {\n Position memory positionDelta = self.openPosition.add(self.closePosition);\n\n (UFixed18 makerNotional, UFixed18 takerNotional) = (\n Fixed18Lib.from(positionDelta.maker).mul(toOracleVersion.price).abs(),\n Fixed18Lib.from(positionDelta.taker).mul(toOracleVersion.price).abs()\n );\n\n IProduct product = IProduct(address(this));\n return makerNotional.mul(product.makerFee()).add(takerNotional.mul(product.takerFee()));\n }\n\n /**\n * @notice Computes the next oracle version to settle\n * @dev - If there is no pending-settlement position delta, returns the current oracle version\n * - Otherwise returns the oracle version at which the pending-settlement position delta can be first settled\n *\n * Corresponds to point (b) in the Position settlement flow\n * @param self The struct to operate on\n * @param currentVersion The current oracle version index\n * @return Next oracle version to settle\n */\n function settleVersion(PrePosition storage self, uint256 currentVersion) internal view returns (uint256) {\n uint256 _oracleVersion = self.oracleVersion;\n return _oracleVersion == 0 ? currentVersion : _oracleVersion + 1;\n }\n}\n" - }, - "contracts/interfaces/types/Accumulator.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/Fixed18.sol\";\nimport \"./PackedAccumulator.sol\";\n\n/// @dev Accumulator type\nstruct Accumulator {\n /// @dev maker accumulator per share\n Fixed18 maker;\n /// @dev taker accumulator per share\n Fixed18 taker;\n}\nusing AccumulatorLib for Accumulator global;\n\n/**\n * @title AccountAccumulatorLib\n * @notice Library that surfaces math operations for the Accumulator type.\n * @dev Accumulators track the cumulative change in position value over time for the maker and taker positions\n * respectively. Account-level accumulators can then use two of these values `a` and `a'` to compute the\n * change in position value since last sync. This change in value is then used to compute P&L and fees.\n */\nlibrary AccumulatorLib {\n /**\n * @notice Creates a packed accumulator from an accumulator\n * @param self an accumulator\n * @return New packed accumulator\n */\n function pack(Accumulator memory self) internal pure returns (PackedAccumulator memory) {\n return PackedAccumulator({maker: self.maker.pack(), taker: self.taker.pack()});\n }\n\n /**\n * @notice Adds two accumulators together\n * @param a The first accumulator to sum\n * @param b The second accumulator to sum\n * @return The resulting summed accumulator\n */\n function add(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\n return Accumulator({maker: a.maker.add(b.maker), taker: a.taker.add(b.taker)});\n }\n\n /**\n * @notice Subtracts accumulator `b` from `a`\n * @param a The accumulator to subtract from\n * @param b The accumulator to subtract\n * @return The resulting subtracted accumulator\n */\n function sub(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\n return Accumulator({maker: a.maker.sub(b.maker), taker: a.taker.sub(b.taker)});\n }\n\n /**\n * @notice Multiplies two accumulators together\n * @param a The first accumulator to multiply\n * @param b The second accumulator to multiply\n * @return The resulting multiplied accumulator\n */\n function mul(Accumulator memory a, Accumulator memory b) internal pure returns (Accumulator memory) {\n return Accumulator({maker: a.maker.mul(b.maker), taker: a.taker.mul(b.taker)});\n }\n\n /**\n * @notice Sums the maker and taker together from a single accumulator\n * @param self The struct to operate on\n * @return The sum of its maker and taker\n */\n function sum(Accumulator memory self) internal pure returns (Fixed18) {\n return self.maker.add(self.taker);\n }\n}\n" - }, - "@equilibria/root/curve/CurveMath.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"../number/types/UFixed18.sol\";\nimport \"../number/types/Fixed18.sol\";\n\n/**\n * @title CurveMath\n * @notice Library for managing math operations for utilization curves.\n */\nlibrary CurveMath {\n error CurveMathOutOfBoundsError();\n\n /**\n * @notice Computes a linear interpolation between two points\n * @param startX First point's x-coordinate\n * @param startY First point's y-coordinate\n * @param endX Second point's x-coordinate\n * @param endY Second point's y-coordinate\n * @param targetX x-coordinate to interpolate\n * @return y-coordinate for `targetX` along the line from (`startX`, `startY`) -> (`endX`, `endY`)\n */\n function linearInterpolation(\n UFixed18 startX,\n Fixed18 startY,\n UFixed18 endX,\n Fixed18 endY,\n UFixed18 targetX\n ) internal pure returns (Fixed18) {\n if (targetX.lt(startX) || targetX.gt(endX)) revert CurveMathOutOfBoundsError();\n\n UFixed18 xRange = endX.sub(startX);\n Fixed18 yRange = endY.sub(startY);\n UFixed18 xRatio = targetX.sub(startX).div(xRange);\n return yRange.mul(Fixed18Lib.from(xRatio)).add(startY);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Address.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // 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\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" - }, - "contracts/interfaces/IContractPayoffProvider.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/Fixed18.sol\";\n\ninterface IContractPayoffProvider {\n function payoff(Fixed18 price) external view returns (Fixed18 payoff);\n}\n" - }, - "contracts/interfaces/types/PackedPosition.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/PackedUFixed18.sol\";\nimport \"./Position.sol\";\n\n/// @dev PackedPosition type\nstruct PackedPosition {\n /// @dev Quantity of the maker position\n PackedUFixed18 maker;\n /// @dev Quantity of the taker position\n PackedUFixed18 taker;\n}\nusing PackedPositionLib for PackedPosition global;\n\n/**\n * @title PackedPositionLib\n * @dev A packed version of the Position which takes up a single storage slot using `PackedFixed18` values.\n * @notice Library for the packed Position type.\n */\nlibrary PackedPositionLib {\n /**\n * @notice Creates an position from a packed position\n * @param self packed position\n * @return New position\n */\n function unpack(PackedPosition memory self) internal pure returns (Position memory) {\n return Position({maker: self.maker.unpack(), taker: self.taker.unpack()});\n }\n}\n" - }, - "contracts/interfaces/types/PackedAccumulator.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/number/types/PackedFixed18.sol\";\nimport \"./Accumulator.sol\";\n\n/// @dev PackedAccumulator type\nstruct PackedAccumulator {\n /// @dev maker accumulator per share\n PackedFixed18 maker;\n /// @dev taker accumulator per share\n PackedFixed18 taker;\n}\nusing PackedAccumulatorLib for PackedAccumulator global;\n\n/**\n * @title PackedAccumulatorLib\n * @dev A packed version of the Accumulator which takes up a single storage slot using `PackedFixed18` values.\n * @notice Library for the packed Accumulator type.\n */\nlibrary PackedAccumulatorLib {\n /**\n * @notice Creates an accumulator from a packed accumulator\n * @param self packed accumulator\n * @return New accumulator\n */\n function unpack(PackedAccumulator memory self) internal pure returns (Accumulator memory) {\n return Accumulator({maker: self.maker.unpack(), taker: self.taker.unpack()});\n }\n}\n" - }, - "@equilibria/root/token/types/Token18.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"../../number/types/UFixed18.sol\";\n\n/// @dev Token18\ntype Token18 is address;\nusing Token18Lib for Token18 global;\ntype Token18Storage is bytes32;\nusing Token18StorageLib for Token18Storage global;\n\n/**\n * @title Token18Lib\n * @notice Library to manage 18-decimal ERC20s that is compliant with the fixed-decimal types.\n * @dev Maintains significant gas savings over other Token implementations since no conversion take place\n */\nlibrary Token18Lib {\n using SafeERC20 for IERC20;\n\n Token18 public constant ZERO = Token18.wrap(address(0));\n\n /**\n * @notice Returns whether a token is the zero address\n * @param self Token to check for\n * @return Whether the token is the zero address\n */\n function isZero(Token18 self) internal pure returns (bool) {\n return Token18.unwrap(self) == Token18.unwrap(ZERO);\n }\n\n /**\n * @notice Returns whether the two tokens are equal\n * @param a First token to compare\n * @param b Second token to compare\n * @return Whether the two tokens are equal\n */\n function eq(Token18 a, Token18 b) internal pure returns (bool) {\n return Token18.unwrap(a) == Token18.unwrap(b);\n }\n\n /**\n * @notice Approves `grantee` to spend infinite tokens from the caller\n * @param self Token to transfer\n * @param grantee Address to allow spending\n */\n function approve(Token18 self, address grantee) internal {\n IERC20(Token18.unwrap(self)).safeApprove(grantee, type(uint256).max);\n }\n\n /**\n * @notice Approves `grantee` to spend `amount` tokens from the caller\n * @dev There are important race conditions to be aware of when using this function\n with values other than 0. This will revert if moving from non-zero to non-zero amounts\n See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/a55b7d13722e7ce850b626da2313f3e66ca1d101/contracts/token/ERC20/IERC20.sol#L57\n * @param self Token to transfer\n * @param grantee Address to allow spending\n * @param amount Amount of tokens to approve to spend\n */\n function approve(Token18 self, address grantee, UFixed18 amount) internal {\n IERC20(Token18.unwrap(self)).safeApprove(grantee, UFixed18.unwrap(amount));\n }\n\n /**\n * @notice Transfers all held tokens from the caller to the `recipient`\n * @param self Token to transfer\n * @param recipient Address to receive the tokens\n */\n function push(Token18 self, address recipient) internal {\n push(self, recipient, balanceOf(self, address(this)));\n }\n\n /**\n * @notice Transfers `amount` tokens from the caller to the `recipient`\n * @param self Token to transfer\n * @param recipient Address to transfer tokens to\n * @param amount Amount of tokens to transfer\n */\n function push(Token18 self, address recipient, UFixed18 amount) internal {\n IERC20(Token18.unwrap(self)).safeTransfer(recipient, UFixed18.unwrap(amount));\n }\n\n /**\n * @notice Transfers `amount` tokens from the `benefactor` to the caller\n * @dev Reverts if trying to pull Ether\n * @param self Token to transfer\n * @param benefactor Address to transfer tokens from\n * @param amount Amount of tokens to transfer\n */\n function pull(Token18 self, address benefactor, UFixed18 amount) internal {\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, address(this), UFixed18.unwrap(amount));\n }\n\n /**\n * @notice Transfers `amount` tokens from the `benefactor` to `recipient`\n * @dev Reverts if trying to pull Ether\n * @param self Token to transfer\n * @param benefactor Address to transfer tokens from\n * @param recipient Address to transfer tokens to\n * @param amount Amount of tokens to transfer\n */\n function pullTo(Token18 self, address benefactor, address recipient, UFixed18 amount) internal {\n IERC20(Token18.unwrap(self)).safeTransferFrom(benefactor, recipient, UFixed18.unwrap(amount));\n }\n\n /**\n * @notice Returns the name of the token\n * @param self Token to check for\n * @return Token name\n */\n function name(Token18 self) internal view returns (string memory) {\n return IERC20Metadata(Token18.unwrap(self)).name();\n }\n\n /**\n * @notice Returns the symbol of the token\n * @param self Token to check for\n * @return Token symbol\n */\n function symbol(Token18 self) internal view returns (string memory) {\n return IERC20Metadata(Token18.unwrap(self)).symbol();\n }\n\n /**\n * @notice Returns the `self` token balance of the caller\n * @param self Token to check for\n * @return Token balance of the caller\n */\n function balanceOf(Token18 self) internal view returns (UFixed18) {\n return balanceOf(self, address(this));\n }\n\n /**\n * @notice Returns the `self` token balance of `account`\n * @param self Token to check for\n * @param account Account to check\n * @return Token balance of the account\n */\n function balanceOf(Token18 self, address account) internal view returns (UFixed18) {\n return UFixed18.wrap(IERC20(Token18.unwrap(self)).balanceOf(account));\n }\n}\n\nlibrary Token18StorageLib {\n function read(Token18Storage self) internal view returns (Token18 value) {\n assembly {\n value := sload(self)\n }\n }\n\n function store(Token18Storage self, Token18 value) internal {\n assembly {\n sstore(self, value)\n }\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/IERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\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 amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` 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(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\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" - }, - "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 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 using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\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 function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" - }, - "@openzeppelin/contracts/proxy/beacon/IBeacon.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n" - }, - "contracts/interfaces/IIncentivizer.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"@equilibria/root/number/types/UFixed18.sol\";\nimport \"@equilibria/perennial-oracle/contracts/interfaces/IOracleProvider.sol\";\nimport \"./types/ProgramInfo.sol\";\nimport \"./IController.sol\";\nimport \"./IProduct.sol\";\n\ninterface IIncentivizer {\n event ProgramCreated(IProduct indexed product, uint256 indexed programId, ProgramInfo programInfo, UFixed18 programFeeAmount);\n event ProgramStarted(IProduct indexed product, uint256 indexed programId, uint256 version);\n event ProgramComplete(IProduct indexed product, uint256 indexed programId, uint256 version);\n event Claim(IProduct indexed product, address indexed account, uint256 indexed programId, UFixed18 amount);\n event FeeClaim(Token18 indexed token, UFixed18 amount);\n\n error IncentivizerNotAllowedError(IProduct product);\n error IncentivizerTooManyProgramsError();\n error IncentivizerNotProgramOwnerError(IProduct product, uint256 programId);\n error IncentivizerInvalidProgramError(IProduct product, uint256 programId);\n error IncentivizerBatchClaimArgumentMismatchError();\n\n function programInfos(IProduct product, uint256 programId) external view returns (ProgramInfo memory);\n function fees(Token18 token) external view returns (UFixed18);\n function initialize(IController controller_) external;\n function create(IProduct product, ProgramInfo calldata info) external returns (uint256);\n function complete(IProduct product, uint256 programId) external;\n function sync(IOracleProvider.OracleVersion memory currentOracleVersion) external;\n function syncAccount(address account, IOracleProvider.OracleVersion memory currentOracleVersion) external;\n function claim(IProduct product, uint256[] calldata programIds) external;\n function claim(IProduct[] calldata products, uint256[][] calldata programIds) external;\n function claimFee(Token18[] calldata tokens) external;\n function active(IProduct product) external view returns (uint256);\n function count(IProduct product) external view returns (uint256);\n function unclaimed(IProduct product, address account, uint256 programId) external view returns (UFixed18);\n function available(IProduct product, uint256 programId) external view returns (UFixed18);\n function versionStarted(IProduct product, uint256 programId) external view returns (uint256);\n function versionComplete(IProduct product, uint256 programId) external view returns (uint256);\n function owner(IProduct product, uint256 programId) external view returns (address);\n function treasury(IProduct product, uint256 programId) external view returns (address);\n}\n" - }, - "contracts/interfaces/types/ProgramInfo.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"@equilibria/root/token/types/Token18.sol\";\nimport \"../IProduct.sol\";\nimport \"./Position.sol\";\nimport \"./Accumulator.sol\";\n\n/// @dev ProgramInfo type\nstruct ProgramInfo {\n /// @dev Coordinator for this program\n uint256 coordinatorId;\n\n /// @dev Amount of total maker and taker rewards\n Position amount;\n\n /// @dev start timestamp of the program\n uint256 start;\n\n /// @dev duration of the program (in seconds)\n uint256 duration;\n\n /**\n * @dev Reward ERC20 token contract\n * @notice Perennial does not support non-standard ERC20s as reward tokens for incentive programs, including,\n but not limited to: fee on transfer and rebase tokens. Using such a non-standard token will likely\n result in loss of funds.\n */\n Token18 token;\n}\nusing ProgramInfoLib for ProgramInfo global;\n\n/**\n * @title ProgramInfoLib\n * @notice Library that snapshots the static information for a single program.\n * @dev This information does not change during the operation of a program.\n */\nlibrary ProgramInfoLib {\n uint256 private constant MIN_DURATION = 1 days;\n uint256 private constant MAX_DURATION = 2 * 365 days;\n\n error ProgramInvalidStartError();\n error ProgramInvalidDurationError();\n\n /**\n * @notice Validates and creates a new Program\n * @dev Reverts for invalid programInfos\n * @param programInfo Un-sanitized static program information\n */\n function validate(ProgramInfo memory programInfo) internal view {\n if (isStarted(programInfo, block.timestamp)) revert ProgramInvalidStartError();\n if (programInfo.duration < MIN_DURATION || programInfo.duration > MAX_DURATION) revert ProgramInvalidDurationError();\n }\n\n /**\n * @notice Computes a new program info with the fee taken out of the amount\n * @param programInfo Original program info\n * @param incentivizationFee The incentivization fee\n * @return New program info\n * @return Fee amount\n */\n function deductFee(ProgramInfo memory programInfo, UFixed18 incentivizationFee)\n internal pure returns (ProgramInfo memory, UFixed18) {\n Position memory newProgramAmount = programInfo.amount.mul(UFixed18Lib.ONE.sub(incentivizationFee));\n UFixed18 programFeeAmount = programInfo.amount.sub(newProgramAmount).sum();\n programInfo.amount = newProgramAmount;\n return (programInfo, programFeeAmount);\n }\n\n /**\n * @notice Returns the maker and taker amounts per position share\n * @param self The ProgramInfo to operate on\n * @return programFee Amounts per share\n */\n function amountPerShare(ProgramInfo memory self) internal pure returns (Accumulator memory) {\n return self.amount.div(self.duration);\n }\n\n /**\n * @notice Returns whether the program has started by timestamp `timestamp`\n * @param self The ProgramInfo to operate on\n * @param timestamp Timestamp to check for\n * @return Whether the program has started\n */\n function isStarted(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\n return timestamp >= self.start;\n }\n\n /**\n * @notice Returns whether the program is completed by timestamp `timestamp`\n * @param self The ProgramInfo to operate on\n * @param timestamp Timestamp to check for\n * @return Whether the program is completed\n */\n function isComplete(ProgramInfo memory self, uint256 timestamp) internal pure returns (bool) {\n return timestamp >= (self.start + self.duration);\n }\n}\n" - } - }, - "settings": { - "optimizer": { - "enabled": false, - "runs": 1000000 - }, - "outputSelection": { - "*": { - "*": [ - "storageLayout", - "abi", - "evm.bytecode", - "evm.deployedBytecode", - "evm.methodIdentifiers", - "metadata", - "devdoc", - "userdoc", - "evm.gasEstimates" - ], - "": ["ast"] - } - }, - "metadata": { - "useLiteralContent": true - } - } -}